Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Write to MAC's serial port to talk to Arduino (fopen( /dev/tty.usbmodem1431) hangs forver)

Tags:

macos

arduino

I have a problem with TTY device on MAC. I created a script which talks to Arduino and works well on Linux. Problem I'm having with MAC is I can't "fopen" the device. For example, if I do

echo "foo" > /dev/tty.usbmodem1431

It hangs forever blocking the port. It works well from Arduino's Serial Monitor so theoretically I should be able talking to it.

OK. I found the solution. I have to write to

/dev/cu.usbmodem1431

I still don't know why TTY don't want to work.

like image 979
Lukasz Kujawa Avatar asked Oct 22 '25 04:10

Lukasz Kujawa


1 Answers

You can use tty with:

stty -f /dev/tty.usbmodem1431 cs8 115200 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts

echo "hello" > /dev/tty.usbmodem1431

Where 115200 is your Serial.begin speed.


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!