Reputation: 39
I want to perform IPC pipe through serial port dev files. 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
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,
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. target opens its ttyS0 to read uart data sent from PC, in PC, commands will be sent to target via minicom. Now I want to run target application in same PC in one terminal and want to send command from another terminal/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
Upvotes: 0
Views: 958
Reputation: 19395
peer0=>ttyS0--->---ttyS1=>peer1 peer0<=ttyS0---<---ttyS1<=peer1
You seem to want socat
to take the part of the --->---
and ---<---
above. 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
.
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.
Upvotes: 0
Reputation: 15218
If you want to just transfer files, use a protocol for doing so over serial links, such as ZMODEM (http://en.wikipedia.org/wiki/ZMODEM), if you want full IPC, establish a PPP connection over the link (http://en.wikipedia.org/wiki/Point-to-Point_Protocol)
Upvotes: 0