[PLUG] sending data from single serial port to multiple readers
bill at billbarry.org
Mon Sep 9 23:08:18 PDT 2013
On Mon, Sep 9, 2013 at 4:03 PM, Galen Seitz <galens at seitzassoc.com> wrote:
> I should have mentioned that I already tried socat(netcat on steroids).
> Here's the command I started with:
> socat tcp-l:9001,reuseaddr,fork /dev/ttyUSB0,raw,echo=0,crnl
> This is close to what I want, but the data from the serial port is not
> sent to all readers. I'm not sure, but I think there is a single file
> descriptor associated with the serial data, so it's a first reader wins
> situation, where the first reader is unpredictable. I sent a message to
> the socat developer asking for hints on how to accomplish my particular
> multiple reader situation, but I have yet to hear back.
Instead of the fork command you can use ncat that is part of the nmap
As the page above says:
"With --keep-open (or -k for short), the server receives everything
sent by any of its clients, and anything the server sends is sent to
all of them."
which is exactly what is needed.
Combine that with the socat command to send and receive data from the
and you get:
ncat --listen --keep-open localhost 9212 --sh-exec "socat -
Every client that connects to localhost 9212 will be able to send
things to the serial port and anything from the serial port will go
out to every client that is connected to localhost 9212.
I did not test it with a serial port, but did test it like this
from one terminal
ncat --listen --keep-open localhost 9300
from a second terminal
ncat --listen --keep-open localhost 9212 --sh-exec "socat - TCP:localhost:9300"
from a third and fourth terminal
ncat localhost 9212
Now anything typed into the third and fourth terminals appears in
terminal one and anything typed in terminal one goes out to terminals
three and four.
More information about the PLUG