Pipe One Serial Port to Another in Linux [closed]

本小妞迷上赌 提交于 2021-02-10 09:30:10

问题


I am looking for a means to pipe one serial ports data (regardless of data type) to another serial port. In my case I am trying to take in data from one serial port and output it through a radio connected to another serial port in real time.

I already know what ports I am using and have looked up a program called socat, which should be able to handle it but there are no examples of how to do this and I have not been able to figure out how to do it.

Has anybody been able to use socat or a bash scipt/some other method to accomplish this in Linux??

I am running Ubuntu 14.04.


回答1:


Assuming the serial port you are reading from is /dev/ttyS0, and the other you are writing to (where the radio is connected) is /dev/ttyS1 you shall simply do:

cat /dev/ttyS0 > /dev/ttyS1

or

dd if=/dev/ttyS0 of=/dev/ttyS1 bs=1

Of course before you should set all the serial ports' parameters using stty command.



来源:https://stackoverflow.com/questions/31593837/pipe-one-serial-port-to-another-in-linux

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!