6

I need to use USB serial cable with baud rate of 115200. I tried to set the rate with stty command from MACbook terminal application as follows;

$stty -f /dev/tty.usbserial-A103BTIB 115200

and confirmed the settings as follows;

$stty -f /dev/tty.usbserial-A103BTIB -a

&speed 9600 baud; 0 rows; 0 columns;
lflags: -icanon -isig -iexten -echo -echoe -echok -echoke -echonl
    -echoctl -echoprt -altwerase -noflsh -tostop -flusho -pendin
    -nokerninfo -extproc
iflags: -istrip -icrnl -inlcr -igncr -ixon -ixoff -ixany -imaxbel -iutf8
    -ignbrk -brkint -inpck -ignpar -parmrk
oflags: -opost -onlcr -oxtabs -onocr -onlret
cflags: cread cs8 -parenb -parodd hupcl -clocal -cstopb crtscts -dsrflow
    -dtrflow -mdmbuf
cchars: discard = ^O; dsusp = ^Y; eof = ^D; eol = <undef>;
eol2 = <undef>; erase = ^?; intr = ^C; kill = ^U; lnext = ^V;
min = 1; quit = ^\; reprint = ^R; start = ^Q; status = ^T;
stop = ^S; susp = ^Z; time = 0; werase = ^W;

It looks baud rate is till 9600. Could somebody show me how to change this step by step ?

sandalwalk
  • 91
  • 1
  • 1
  • 7
  • Read the **man** page. For OSX you need to precede the desired baudrate *number* with the keyword `speed`. – sawdust Dec 11 '15 at 23:49
  • typed stty -f /dev/tty.usbserial-A103BTIB speed 115200 but still 9600.... – sandalwalk Dec 13 '15 at 00:46
  • Did you read the **man** page? I can only find the OSX 10.9 **man** pages online. What version are you using? – sawdust Dec 13 '15 at 01:05
  • Yes, I did. I use OSX 10.10. Do you change the baud speed with stty with OSX 10.9 ? Any possibility that this is an authorization problem ? – sandalwalk Dec 13 '15 at 09:19
  • I don't use OSX. If you mean permissions, then maybe. – sawdust Dec 14 '15 at 01:15
  • 1
    I usually do something like this: `exec 3<> /dev/cu.usbserial-AL02BXNR` and then the `stty` command. I think the baud rate only sticks if the port is opened. – nelsonjchen Jun 02 '16 at 23:32

3 Answers3

2

It seems like this is a common problem of stty command in OSX and not solved.

https://discussions.apple.com/thread/3798003?tstart=0

sandalwalk
  • 91
  • 1
  • 1
  • 7
2

I was able to set the baudrate temporarily by running screen session

$ screen /dev/cu.usbserial-FTHHQD0C 115200

and opening another terminal to run my script.

Lex Bryan
  • 750
  • 1
  • 9
  • 18
  • This is also useful if you want to talk to the serial port using screen (and need the changed speed) – gbarry Dec 10 '20 at 02:07
2

Other option to set a rigid baud value is to:

  1. Launch a connection with the usbserial port, redirecting the output by cat in separate terminal window (to keep the port open):

cat -v /dev/tty.usbserial-A103BTIB

  1. Set the baud:

stty -f /dev/tty.usbserial-A103BTIB 115200

The baud value stays set.

SSBakh
  • 1,487
  • 1
  • 14
  • 27
Aeneus
  • 21
  • 1