[CLUE-Tech] socat and serial line discipline?

Jim Ockers ockers at ockers.net
Mon May 10 09:39:22 MDT 2004


Hi everyone,

I'm trying to use socat 1.3.2.2 to make a serial line extender.  If
you haven't heard of socat please visit http://www.dest-unreach.org/socat .
It is a similar to "netcat" but is much more powerful because it
supports so many more different types of sockets and connections.
It is a Most Excellent multipurpose tool.

There are probably other ways to do this but I do need a software
solution to this problem.  I welcome any suggestions on how to make
this work.  My question has to do with setting the serial port
baud rate and line discipline.  The socat documentation doesn't
address this particular question, and there is no mention of
the word "baud" or "rate" anywhere in the (Very large) socat
man page.

According to the socat documentation all you have to do to read
from a TCP socket and write to a serial port is:

socat TCP4-LISTEN:54321,reuseaddr /dev/ttyS0,nonblock

They expect you to use another copy of socat on the client to
create a "virtual modem" device that can be opened by a unix
process:

socat PTY,link=$HOME/dev/vmodem0 TCP4:modemserver.us.org:54321

Presumably whenever a process (say, pppd) opens up /dev/vmodem0
it will try to set the baud rate and line discipline, which
socat will observe and then communicate to the other end of the
connection so that the "real device" /dev/ttyS0 on the server
will get opened with the same baud rate and line discipline.

So I tried to make a serial line extender with socat reading
from a serial port on one end, and socat writing to a serial
port on the other end, and a TCP socket over a wireless ethernet 
network in between.

end A: socat /dev/ttyS0,raw TCP4:1.2.3.4:54321
end B: socat TCP4-LISTEN:54321,reuseaddr /dev/ttyS0,nonblock

I am not totally sure what the serial port options should be.

Anyway nowhere in there does the baud rate get set, or other
line discipline items.  I'm thinking about using a getty on
the serial port of "end A" so that the correct baud rate is
used.

I'm not sure how to correctly set the baud rate on the connection.
It needs to be 460800 bps since I know my hardware all works
fine at that speed.  Any suggestions?

Thanks in advance for any help,
Jim

-- 
Jim Ockers, P.Eng. (ockers at ockers.net)
Contact info: please see http://www.ockers.net/



More information about the clue-tech mailing list