简体   繁体   English

使用socat将串行端口连接到tcp时出错

[英]Error Connecting serial port to tcp using socat

I am working on Embedded board having Openwrt os running on. 我正在运行Openwrt os的嵌入式板上。 one board is taking input via serial and need to forward tcp port (ie 192.168.1.1). 一块板通过串行输入,需要转发tcp端口(即192.168.1.1)。

another board is receiver which receives data over tcp and forwarding to serial out.(ie ip 192.168.1.2) 另一块板是接收器,它通过tcp接收数据并转发到串行输出。(即ip 192.168.1.2)

for tx board below isy command 用于isy命令下的TX板

socat pty,link=$HOME/dev/ttyS2,raw,echo=0,waitslave 192.168.1.2:port.
for rx side
socat tcp-l:5000,reuseaddr,fork file:/dev/ttyS2,nonblock,raw,echo=0.

Problem : - the transmission is happening if send data from on board terminal. 问题: -如果从车载终端发送数据,则传输正在发生。

But if I connect via serial-usb converter to the laptop and try to send data its not working. 但是,如果我通过串行USB转换器连接到笔记本电脑并尝试发送数据,则它无法正常工作。 On the receiving side, I can able to see output on laptop, not on board 在接收端,我可以在笔记本电脑上看到输出,而不是在板上

I have found workaround and solution. 我找到了解决方法和解决方案。

instead of linking the port i did this on tx side and working fine. 而不是链接端口,我这样做是在TX端,并且工作正常。 posting answer below if someone find it useful for them. 如果有人觉得对他们有用,请在下面发布答案。

socat file:/dev/YourSerialPort,baudrate,raw,echo=0 tcp:ipaddr:port

on rx side socat tcp-l:port,reuseaddr,fork file:/dev/YourSerialPort,baudrate,nonblock,echo=0,raw 在接收端socat tcp-l:port,reuseaddr,fork file:/dev/YourSerialPort,baudrate,nonblock,echo=0,raw

Thank you. 谢谢。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM