Linux command stty

Linux command stty

reference: https://blog.csdn.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 9600 baud; rows 0; columns 0; line = 0;
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 = 1; time = 0;
-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:

扫描二维码关注公众号,回复: 5507360 查看本文章
stty -F /dev/ttyS0 speed 115200 cs8 -parenb -cstopb  -echo
解释:通过stty设置/dev/ttyS0串口, 波特率为115200 ,数据位cs8,奇偶校验位-parenb,停止位-cstopb,同时-echo禁止终端回显。

猜你喜欢

转载自www.cnblogs.com/lianghong881018/p/10518283.html