屏幕/ dev / ttyUSB0具有不同的选项,例如数据位,奇偶校验等

Jon*_*der 6 serial-port gnu-screen usbserial tty

我正在尝试使用

屏幕/ dev / ttyUSB0

通过USB串行接口连接到旧计算机。

我希望在此网站上注册后,我会收到我问题的答案。我进行了搜索,但是还没有想出在命令行中放置正确的选项的方法,以从计算机中获得无垃圾的反馈(收到的文本都被弄乱了)。

我的操作系统是CentOs,Gnome 2.16.0。我看到有一个名为KPPP的程序,其中有一个“ Terminal ...”,但也没有弄清楚。因此,我试图将CLI与“ screen”一起使用,但是在设置正确的参数时遇到了麻烦(显然,我不知道如何将这些参数与stty一起使用)。这不是安装应用程序或对此计算机执行任何操作的选择,因此我必须使用已有的功能。“屏幕”似乎可以完成任务,但是如前所述,收到的文本是乱码(“ $$ @%idj ldj”等)

我需要这些参数用于计算机一:

波特:9600数据位:8奇偶校验:无停止位:2流量控制:硬件。

对于两台计算机,我需要:

波特率:9600数据位:7奇偶校验:偶数停止位:1流量控制:硬件

波特率很容易;

屏幕/ dev / ttyUSB0 9600

但是我不知道该怎么办。。我找到了停止位的选项:

cstopb(使用两个停止位)

-cstopb(使用一个停止位)

但是如何正确使用它?

屏幕/ dev / ttyUSB0 9600 -cstopb

要么

屏幕/ dev / ttyUSB0 9600,-cstopb

因此,如果有人可以通过所有列出的参数通过串行接口帮助我连接到另一台计算机,我将非常感激!

2016年12月22日更新:

我已经找到了这本有关stty的手册:http : //osr507doc.sco.com/man/html.C/stty.C.html

数据位与此选项相同吗?

   cs5 cs6 cs7 cs8
        Select character size (see termio(M)). 
Run Code Online (Sandbox Code Playgroud)

平价:

   parodd (-parodd)
         Select odd (even) parity. 
Run Code Online (Sandbox Code Playgroud)

停止位:

   cstopb (-cstopb)
         Use two (one) stop bits per character. 
Run Code Online (Sandbox Code Playgroud)

但是硬件控制呢?

无论如何; 这仍然无法正常工作;

screen /dev/ttyUSB0 9600 cs8 oddp cstop 
Run Code Online (Sandbox Code Playgroud)

要么

   screen /dev/ttyUSB0 9600 cs7 evenp -cstop
Run Code Online (Sandbox Code Playgroud)

Gáb*_*bor 7

选项之间需要逗号!

要启用RTS/CTS 流量控制,请使用以下命令:

screen /dev/ttyS0 9600,crtscts
Run Code Online (Sandbox Code Playgroud)

注意:并非所有 USB 至RS-232转换器都实现硬件流控制!


小智 5

我认为屏幕不支持所有这些不同的串行端口设置,仅支持最基本的参数。通过查看stty手册,您已经在正确的方向上,但是您必须将stty用作与屏幕不同的工具:首先,配置串行端口,然后使用screen连接到它。

为计算机配置串行端口1:

# stty - change and print terminal line settings
#
#    -F /dev/ttyUSB0      Change the settings of /dev/ttyUSB0
#    cs8                  Use 8 character bits
#    -parenb              Don't use a parity bit (the '-' means 'disable')
#    crtscts              Enable RTS/CTS handshaking (hardware flow control)
stty -F /dev/ttyUSB0 cs8 -parenb cstopb crtscts
Run Code Online (Sandbox Code Playgroud)

配置端口后,可以通过屏幕开始使用它:

# screen - screen manager with VT100/ANSI terminal emulation
#
#    /dev/ttyUSB0         Use /dev/ttyUSB0 as terminal
#    9600                 Open the serial port using 9600 baud
screen /dev/ttyUSB0 9600
Run Code Online (Sandbox Code Playgroud)

第二台计算机也是如此:

# stty - change and print terminal line settings
#
#    -F /dev/ttyUSB0      Change the settings of /dev/ttyUSB0
#    cs7                  Use 7 character bits
#    parenb               Enable the a parity bit
#    -parodd              Don't use ODD, but use EVEN parity
#    -cstopb              Don't use 2 stopbits, but just the regular 1
#    crtscts              Enable RTS/CTS handshaking (hardware flow control)
stty -F /dev/ttyUSB0 cs7 parenb -parodd -cstopb crtscts
Run Code Online (Sandbox Code Playgroud)

然后,您可以启动屏幕@ 9600波特:

# screen - screen manager with VT100/ANSI terminal emulation
#
#    /dev/ttyUSB0         Use /dev/ttyUSB0 as terminal
#    9600                 Open the serial port using 9600 baud
screen /dev/ttyUSB0 9600
Run Code Online (Sandbox Code Playgroud)

这应该可以解决问题。您可以在stty的帮助下找到更多配置选项:

stty --help
Run Code Online (Sandbox Code Playgroud)