linux 机器上通过以太网的串行数据

Cra*_*nes 7 linux ethernet serial-port

我正在尝试通过以太网(串行到以太网)将小部件 (192.168.1.214:20108) 连接到 Linux 机器。

在使用虚拟设备驱动程序映射的 Windows 下,我可以看到串行数据,因此我知道串行到以太网的小部件正在工作。

现在,当我指向一个 Linux 机器时,我得到的只是使用 tcpdump 时的连接尝试:

21:00:07.322019 IP 192.168.1.214.20108 > development.local.8234: Flags [R], seq 4096, win 0, length 0

所以以太网数据包正在通过,但我找不到将串行数据(通过端口 8234 以太网)映射到设备的方法。的许多变体socat不会在屏幕上产生任何数据,例如:

$ sudo socat readline TCP-LISTEN:8234,bind=127.0.0.1
Run Code Online (Sandbox Code Playgroud)

或尝试将其绑定到开发人员:

$ socat -d -d -d tcp-l:127.0.0.1:8234,reuseaddr,fork file:/dev/tty0,nonblock,waitlock=/var/run/tty0.lock
Run Code Online (Sandbox Code Playgroud)

这给出了以下输出:

2013/11/11 21:19:41 socat[23757] I setting option "so-reuseaddr" to 1
2013/11/11 21:19:41 socat[23757] I setting option "fork" to 1
2013/11/11 21:19:41 socat[23757] I socket(2, 1, 6) -> 3
2013/11/11 21:19:41 socat[23757] I starting accept loop
2013/11/11 21:19:41 socat[23757] N listening on AF=2 0.0.0.0:8234
Run Code Online (Sandbox Code Playgroud)

我完全不知道如何在 Linux 机器上通过以太网读取这个串行数据。

slm*_*slm 6

查看 Stackoverflow,我发现这个问答题为:在 linux 环境中将串行端口数据转换为 TCP/IP。具体来说,该问题的答案之一强调了 2 个听起来像您正在寻找的工具:

  • ser2net - 串行到网络代理 (ser2net)

    ser2net 为用户提供了一种从网络连接到串行端口的连接方式。我尝试了我能找到的所有其他方法,但发现它们缺乏,所以我写了自己的。它提供了所有的串口设置、配置端口​​的配置文件、修改端口参数的控制登录、监控端口和控制端口。

  • remtty - 远程 tty

    remtty(“远程 tty”的缩写)使 TCP 连接可用作伪 tty。它允许您使用可以直接访问调制解调器(例如 Cisco NAS)的访问服务器作为普通拨出调制解调器用于传真、发送短信或访问 BBS。它提供类似于 Cisco 的 Dialout Utility 的功能,但在 GNU/Linux 上而不是在 Windows 上。

您可能还想查看此文档,其中讨论了如何使用socat我希望能够完全完成您正在尝试执行的操作。

该页面的摘录

- You have a host with some serial device like a modem or a bluetooth interface
(modem server)
- You want to make use of this device on a different host. (client)

1) on the modem server start a process that accepts network connections and
links them with the serial device /dev/tty0:

$ socat tcp-l:54321,reuseaddr,fork \
     file:/dev/tty0,nonblock,waitlock=/var/run/tty0.lock

2) on the client start a process that creates a pseudo tty and links it with a
tcp connection to the modem server:

$ socat pty,link=$HOME/dev/vmodem0,waitslave tcp:modem-server:54321

NETWORK CONNECTION

There a some choices if a simple TCPv4 connection does not meet your
requirements:
TCPv6: simply replace the "tcp-l" and "tcp" keywords with "tcp6-l" and "tcp6"
Socks: if a socks server protects the connection, you can replace the
"tcp:modem-server:54321" clause with something like
"socks:socks-server:modem-server:54321" or 
"socks:socks-server:modem-server:54321,socksport=1081,socksuser=nobody"

SECURITY

SSL
If you want to protect your server from misuse or your data from sniffing and
manipulation, use a SSL connection with client and server authentication
(currently only over TCPv4 without socks or proxy). 
See <a href="socat-openssl.txt">socat-openssl.txt</a> for instructions.

IP Addresses
!!! bind=...
!!! range=...
!!! lowport (for root)
!!! sourceport
!!! tcpwrap=

FULL FEATURES
$ socat -d -d ssl-l:54321,reuseaddr,cert=server.pem,cafile=client.crt,fork \
     file:/dev/tty0,nonblock,echo=0,raw,waitlock=/var/run/tty0.lock

TROUBLESHOOTING
-v -x
Run Code Online (Sandbox Code Playgroud)