After the Linux kernel is started, the baud rate of the serial port is usually 115200
or 9600
. At this time, if you want to modify the baud rate of the serial port, go to This can be accomplished through the stty
command in shell
without modifying the driver code.
stty
: set tty
. That is, change and print the terminal line settings, which are used to check and modify the communication parameters of the currently registered terminal.
View serial port parameters:
stty -F /dev/ttyS0 -a
Set serial port parameters:
stty -F /dev/ttyS0 115200 cs8 -parenb -cstopb
Set serial portttyS0
Baud rate115200
,8
bit data bits,1
Stop bit, no check bit
Generally speaking, if you just modify the serial port baud rate, then you only need:
stty -F /dev/ttyS0 115200
stty
的其它参数,可以用man
查看其它设置选项。
开启流控:
stty -F /dev/ttyS0 crtscts
关闭流控:
stty -F /dev/ttyS0 -crtscts
注意,这里的开启和关闭,是通过前面的符号-
来区别,-
表示关闭,否则表示开启。
The above is the detailed content of Linux system debugging - stty changes the serial port baud rate. For more information, please follow other related articles on the PHP Chinese website!