gpt4 book ai didi

gnu-screen - GNU Screen 终端线路设置

转载 作者:行者123 更新时间:2023-12-04 17:52:26 26 4
gpt4 key购买 nike

我想使用 GNU screen 来监视这样的串行 USB 端口:

$ 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

就好像 screen 忽略了任何 stty 设置并将它们重置为它自己的默认值。这在我测试过的两台机器上都是一样的; Debain 8.7 和 macOS Sierra 10.12.4

我看过其他人面临类似问题的帖子,但没有人给出明确的答案。许多人最终推荐了一种替代像 minicom 这样的屏幕,但现在我很感兴趣。

stty 设置,比如 onlcr,可以和 screen 一起使用吗?

最佳答案

我只是经历了大致相同的过程,却发现无论如何屏幕​​都会破坏 stty 设置。这里的一条评论建议更改屏幕源代码:
How to toggle CR/LF in gnu screen?

最后,我很高兴地找到了一个更小的哑终端程序,它允许在命令行上传递 stty 风格的参数:
https://github.com/npat-efault/picocom

它还在启动时漂亮地打印串行端口设置,以便您可以轻松检查它们。

包存在于 Debian 派生的发行版 ( sudo apt-get install picocom ) 中,而对于其他发行版,编译似乎很简单。一个依赖项是 linenoise 库,它可以被禁用。

关于gnu-screen - GNU Screen 终端线路设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43583207/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com