Serial ports on OS X

If you’re talking to serial ports on OS X and just want to see the output, good ol’ cat is quite a nice little tool (yay for Terminal scrollback). In Linux, setting the baud rate persists across opens and closes of the serial port. In traditional Unix—including OS X—it does not. So if you run the traditional stty -f /dev/cu.usbserial-* speed 38400 command to set the baud rate to 38400, you’ll find that it immediately resets back to 9600, because stty opens the port, sets the baud rate, and then closes it, so the OS resets it back to the default.

So, what you want to do is:

exec 3<> /dev/cu.usbserial-*  # attach file descriptor 3 to serial port
stty -f /dev/cu.usbserial-* speed 38400  # set serial port to 38400
cat <&3  # run cat with stdin redirected from file descriptor 3

This pleases the oldskool Unix shell hacker in me.