我想使用GNU屏幕监控到这样的串行USB端口:GNU屏终端线路设置
$ screen /dev/ttyUSB0 115200
但我需要调整一些终端线路设置。我做了几次尝试,但似乎没有任何工作。例如,要发送NL + CR作为换行符,而不仅是NL,终端线路设置为onlcr。
尝试1 - 没有任何特殊的设置:
$ screen /dev/ttyUSB0 115200
# only sends NL
尝试2 - 经由屏幕:
$ screen /dev/ttyUSB0 115200,onlcr
# still only sends NL
尝试3 - 经由SSTY:
$ stty -F /dev/ttyUSB0 onlcr
$ screen /dev/ttyUSB0 115200
# still only sends NL
尝试4 - 通过两个:
$ stty -F /dev/ttyUSB0 onlcr
$ screen /dev/ttyUSB0 115200,onlcr
# still only sends NL
尝试5 - 在另外的顺序:
$ screen /dev/ttyUSB0 115200,onlcr
# then ctrl+a, ctrl+z to pause the screen session
$ stty -F /dev/ttyUSB0 onlcr
stty: /dev/ttyUSB0: Device or resource busy
在所有情况下,如果我跑的stty检查终端线路设置,我得到此:
运行屏幕前 - 注意-onlcr存在:
$ stty -F /dev/ttyUSB0
speed 115200 baud; line = 0;
kill = ^H; min = 100; time = 2;
-icrnl -imaxbel
-opost -onlcr
-isig -icanon -echo
更改stty设置 - 注意-onlcr将已经:
$ stty -F /dev/ttyUSB0 onlcr
$ stty -F /dev/ttyUSB0
speed 115200 baud; line = 0;
kill = ^H; min = 100; time = 2;
-icrnl -imaxbel
-opost
-isig -icanon -echo
运行屏幕后 - 注意-onlcr将被再次:
$ stty -F /dev/ttyUSB0
speed 115200 baud; line = 0;
kill = ^H; min = 100; time = 2;
-icrnl -imaxbel
-opost -onlcr
-isig -icanon -echo
这是因为如果屏幕忽略任何stty设置并将它们重置为它自己的默认设置。在我测试过的两台机器上都是这样; Debain 8.7和macOS Sierra 10.12.4
我看到其他人遇到类似问题的帖子,但没有给出明确的答案。许多人最终推荐了像minicom这样的屏幕替代品,但现在我感兴趣。
stty设置,如onlcr,可以在屏幕上使用吗?