OpenWRT查看并修改串口的波特率等属性

By | 2020-04-07

Openwrt默认使用的波特率是115200,修改方法如下:

1、 控制台更新软件源列表

opkg update

2、 安装coreutils-stty工具

opkg install coreutils-stty

3、 查看波特率等信息,stty -F /dev/ttyS0 -a

root@OpenWrt:~# stty -F /dev/ttyS0 -a
speed 115200 baud; rows 0; columns 0; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; 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

4、 用stty设置串口参数

stty -F /dev/ttyS0 raw 9600 cs8

串口波特率已经修改为9600了,cs8是8位数据模式

发表评论

邮箱地址不会被公开。 必填项已用*标注