ubuntu 16.04强制串行终端速度

ubuntu 16.04强制串行终端速度

我无法在串行终端 /dev/ttyS0 上保持固定速度。我使用:

stty -F /dev/ttyS0 115200
root@ubuntu:/# stty -F /dev/ttyS0 -a
speed 115200 baud; rows 24; columns 80; 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 = <undef>; 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

显然,它已经改变了。但是,当我开始通过串行端口发送几个字符时(我 100% 肯定我使用了 115200,我已验证连接到 Windows com 端口),Ubuntu 终端又自动更改为 9600!

stty -F /dev/ttyS0 -a
speed 9600 baud; rows 24; columns 80; 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 = <undef>; 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

我如何强制终端使用固定的 115200?
显然它要么因为未知原因而更改为 9600,要么(试图)自动检测串行速度?

更多信息。GRUB(通过 /etc/default/grub 配置)在 115200 处正确输出

error: no video mode activated.

                    GNU GRUB  version 2.02~beta2-36ubuntu3.2

 +----------------------------------------------------------------------------+
 |*Ubuntu                                                                     |
 | Advanced options for Ubuntu                                                |
 | Memory test (memtest86+)                                                   |
 | Memory test (memtest86+, serial console 115200)                            |
 |                                                                            |
 |                                                                            |
 |                                                                            |
 |                                                                            |
 |                                                                            |
 |                                                                            |
 |                                                                            |
 |                                                                            |
 +----------------------------------------------------------------------------+

      Use the ^ and v keys to select which entry is highlighted.
      Press enter to boot the selected OS, `e' to edit the commands
      before booting or `c' for a command-line.
   The highlighted entry will be executed automatically in 0s.

但是在 GRUB 之后,只剩下垃圾,我的 ubuntu 16.04 再次以 9600 发送。

更多更新:根据这个,可能是agetty的一个bug
https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/1571500

systemctl status [email protected][email protected] - Serial Getty on ttyS0
   Loaded: loaded (/lib/systemd/system/[email protected]; disabled; vendor p
   Active: active (running) since Du 2016-11-13 17:58:28 EET; 1s ago
     Docs: man:agetty(8)
           man:systemd-getty-generator(8)
           http://0pointer.de/blog/projects/serial-console.html
 Main PID: 12526 (agetty)
   CGroup: /system.slice/system-serial\x2dgetty.slice/[email protected]
           └─12526 /sbin/agetty --keep-baud 115200 38400 9600 ttyS0 vt220

当我手动发出而不使用--keep-baud时,它可以工作

/sbin/agetty 115200 ttyS0 vt220

所以现在的问题是如何永久禁用 --keep-baud 选项。我找不到 agetty 的任何初始化。

提前致谢!

相关内容