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

问题描述 投票:4回答:3

我正在尝试使用

屏幕/ dev / ttyUSB0

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

我希望在这个网站上注册我会收到我的问题的答案。我已经搜索过并搜索过,但是还没想出要在我的命令行中输入正确的选项来从我的计算机中获取非胡言乱语的反馈(收到的文本都搞砸了)。

我的操作系统是CentOs,Gnome 2.16.0。我看到有一个名为KPPP的程序,它有一个“终端......”,但还没有想出那个。所以我试图将CLI与'screen'一起使用,但是我在设置正确的参数时遇到了麻烦(显然,我不明白如何将这些参数与stty一起使用)。它不是安装应用程序或使用此计算机执行任何操作的选项,因此我必须使用已经存在的内容。 “屏幕”似乎可以完成这项工作,但收到的文字是前面提到的乱码(“$$ @%idj ldj”等)

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

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

对于计算机二,我需要:

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

波特率很容易;

屏幕/ dev / ttyUSB0 9600

但我不知道如何处理剩下的事情。 。我找到了停止位的选项:

cstopb(使用两个停止位)

-cstopb(使用一站式位)

但是我该如何正确使用它?

screen / dev / ttyUSB0 9600 -cstopb

要么

screen / dev / ttyUSB0 9600,-cstopb

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

更新22. 2016年12月:

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

数据位是否与此选项相同?

   cs5 cs6 cs7 cs8
        Select character size (see termio(M)). 

平价:

   parodd (-parodd)
         Select odd (even) parity. 

停止位:

   cstopb (-cstopb)
         Use two (one) stop bits per character. 

但硬件控制怎么样?

无论如何;这仍然不起作用;

screen /dev/ttyUSB0 9600 cs8 oddp cstop 

要么

   screen /dev/ttyUSB0 9600 cs7 evenp -cstop
serial-port tty gnu-screen usbserial
3个回答
3
投票

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

要为计算机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

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

# 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

这同样适用于您的第二台计算机:

# 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

然后你可以启动屏幕@ 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

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

stty --help

0
投票

阅读这篇文章,了解有关minicom https://www.cyberciti.biz/tips/connect-soekris-single-board-computer-using-minicom.html的详细说明和使用

Minicom类似于gtkterm和串行端口通信的行业标准。


0
投票

选项之间的逗号是必需的!

要启用RTS/CTS flow control,请使用以下命令:

screen /dev/ttyS0 9600,crtscts

注意:并非所有USB到RS232转换器都实现了硬件流控制!

© www.soinside.com 2019 - 2024. All rights reserved.