Linux command stty
reference: https://blog.****.net/lqxandroid2012/article/details/78929506
【Purpose】
Learning linux command stty for get/set serial uart speed
【Eevironment】
Ubuntu 16.04 terminal
【Procdeure】
example get uart speed:
root@IoTP:~# stty -F /dev/ttyUSB2 -a
speed baud; rows ; columns ; line = ;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^A; eol = <undef>;
eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
werase = ^W; lnext = ^V; discard = ^O; min = ; time = ;
-parenb -parodd -cmspar cs8 hupcl -cstopb cread clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl -ixon -ixoff
-iuclc -ixany -imaxbel -iutf8
-opost -olcuc -ocrnl -onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig -icanon iexten -echo -echoe echok -echonl -noflsh -xcase -tostop -echoprt
echoctl echoke -flusho -extproc
example set uart speed:
stty -F /dev/ttyS0 speed cs8 -parenb -cstopb -echo
解释:通过stty设置/dev/ttyS0串口, 波特率为115200 ,数据位cs8,奇偶校验位-parenb,停止位-cstopb,同时-echo禁止终端回显。