简体   繁体   English

IPC管道通过文件/ dev / ttyS0和/ dev / ttyS1

[英]IPC pipe through files /dev/ttyS0 and /dev/ttyS1

I want to perform IPC pipe through serial port dev files. 我想通过串口dev文件执行IPC管道。 here are the requirements first of all I am trying to use 这是我首先要使用的要求

sudo socat /dev/ttyS0,raw,echo=0,crnl /dev/ttyS1,raw,echo=0,crnl

it is giving an error as follows 它给出了如下错误

2014/12/xx 10:33:19 socat[17848] E tcgetattr(4, 0x7fffe76ecaa0): Input/output error

Once the ttyS0 and ttyS1 are connected, I assume we can perform read/write operation as similar as using a pipe(), I will have two programs peer0.c and peer1.c, peer0.c opens /dev/ttyS0 and peer1.c opens /dev/ttyS1, so that read write operation should be as follows 一旦ttyS0和ttyS1连接起来,我假设我们可以像使用pipe()一样执行读/写操作,我将有两个程序peer0.c和peer1.c,peer0.c打开/ dev / ttyS0和peer1。 c打开/ dev / ttyS1,因此读写操作应如下

peer0=>ttyS0--->---ttyS1=>peer1
peer0<=ttyS0---<---ttyS1<=peer1

and since /dev/ttyS(0/1) are system wide, i can run peer0.c program in one terminal and peer1.c in another, 由于/ dev / ttyS(0/1)是系统范围的,因此我可以在一个终端中运行peer0.c程序,在另一终端中运行peer1.c,

Basically, I have linux based embedded application program which when ported to target hardware it will be controlled by linux based PC via minicom UART interface. 基本上,我有一个基于Linux的嵌入式应用程序,当移植到目标硬件时,它将由基于Linux的PC通过minicom UART接口进行控制。 target opens its ttyS0 to read uart data sent from PC, in PC, commands will be sent to target via minicom. 目标打开其ttyS0以读取从PC发送的uart数据,在PC中,命令将通过minicom发送到目标。 Now I want to run target application in same PC in one terminal and want to send command from another terminal/minicom. 现在,我想在一个终端中的同一台PC上运行目标应用程序,并希望从另一个终端/ minicom发送命令。 Also the communication should be bidirectional 同样,通信应该是双向的

is it possible to achieve this goal? 有可能实现这个目标吗? or is there any other similar way to achieve the same? 还是有其他类似的方法可以达到相同目的?

thanks in advance 提前致谢

如果只想传输文件,请使用协议通过串行链接进行传输,例如ZMODEM( http://en.wikipedia.org/wiki/ZMODEM ),如果要完整的IPC,请通过链接建立PPP连接( http://en.wikipedia.org/wiki/Point-to-Point_Protocol

 peer0=>ttyS0--->---ttyS1=>peer1 peer0<=ttyS0---<---ttyS1<=peer1 

You seem to want socat to take the part of the --->--- and ---<--- above. 您似乎希望socat参与上述--->------<--- This is not possible, because socat had to open ttyS0 and ttyS1 and compete with peer0 for input from ttyS0 as well as with peer1 for input from ttyS1 . 这是不可能的,因为socat必须打开ttyS0ttyS1并与peer0争夺ttyS0输入,并与peer1争夺ttyS1输入。 To achieve the goal of communicating with an application on one serial port via another port, just connect the two ports with a null modem cable. 要实现通过另一个端口与一个串行端口上的应用程序进行通信的目标,只需用一根空调制解调器电缆连接两个端口即可。

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

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