-late 2013 MBP, with Yosemite 10.10.2
While using a USB –> Serial cable(FTDI chipset), I am unable to get a set baud-rate and get it to stick while the device is not being open/wrote/read.
For example:
If I execute, "stty -f /dev/cu.xxxxxxxx 19200" while not doing anything software related with it, it will reset the baud back to 9600 instantly after.
However, if I run "cat -u < /dev/cu.xxxxxxxx" and THEN set the baud to 19200 while the cat is running, the baud rate will stick. This is also the case when I write some test code and execute the C system command open("/dev/cu.xxxxxxxx") and freeze the program.
Under the old BSD roots, this seems to be standard behavior. When I attempt this on a Debian box, the baud-rate sticks. This hints to me that it's system dependent, but is there a way to get the baud-rate to be the default/stick forever?
Best Answer
For anyone who stumble upon this (yes, another...), here a shell solution (Bash at least):
The 'trick' is to open a file descriptor for the serial port before using stty. And keeps it open during all the reading/writing.
Example:
Thanks to @crasysim for his comment on the same question.