7

I'm trying to connect a widget (192.168.1.214:20108) through Ethernet (serial to Ethernet) to a Linux box.

Under Windows using a virtual device driver mapping I can see the serial data, so I know the widget serial to Ethernet is working.

Now when I point to a Linux box all I am getting is a connection attempt when I use tcpdump:

21:00:07.322019 IP 192.168.1.214.20108 > development.local.8234: Flags [R], seq 4096, win 0, length 0

So the Ethernet packets are getting through but I can't find a way to map the serial data (over port 8234 Ethernet) to a device. Many variations of socat do not produce any data on the screen, for example:

$ sudo socat readline TCP-LISTEN:8234,bind=127.0.0.1

or attempting to bind it to a dev:

$ socat -d -d -d tcp-l:127.0.0.1:8234,reuseaddr,fork file:/dev/tty0,nonblock,waitlock=/var/run/tty0.lock

this gives an output of:

2013/11/11 21:19:41 socat[23757] I setting option "so-reuseaddr" to 1
2013/11/11 21:19:41 socat[23757] I setting option "fork" to 1
2013/11/11 21:19:41 socat[23757] I socket(2, 1, 6) -> 3
2013/11/11 21:19:41 socat[23757] I starting accept loop
2013/11/11 21:19:41 socat[23757] N listening on AF=2 0.0.0.0:8234

I'm completely stuck of how to read this serial data over Ethernet on a Linux box.

1 Answer 1

6

Looking through Stackoverflow I found this Q&A titled: Converting serial port data to TCP/IP in a linux environment. Specifically one of the answers to that question highlighted 2 tools that sound like what you're looking for:

  • ser2net - Serial to Network Proxy (ser2net)

    ser2net provides a way for a user to connect from a network connection to a serial port. I tried all the other ones I could find and found them lacking, so I wrote my own. It provides all the serial port setup, a configuration file to configure the ports, a control login for modifying port parameters, monitoring ports, and controlling ports.

  • remtty - remote tty

    remtty (short for "remote tty") makes TCP connections available as pseudo ttys. It allows you to use access servers with direct access to the modems (such as Cisco NAS) as ordinary dial-out modems for faxing, sending sms or visiting BBS'. It offers functionality similar to Cisco's Dialout Utility, but on GNU/Linux instead of Windows.

You also might want to take a look at this documentation which discusses how to use socat which I would expect to be able to do exactly what you're trying to do.

excerpt of that page

- You have a host with some serial device like a modem or a bluetooth interface
(modem server)
- You want to make use of this device on a different host. (client)

1) on the modem server start a process that accepts network connections and
links them with the serial device /dev/tty0:

$ socat tcp-l:54321,reuseaddr,fork \
     file:/dev/tty0,nonblock,waitlock=/var/run/tty0.lock

2) on the client start a process that creates a pseudo tty and links it with a
tcp connection to the modem server:

$ socat pty,link=$HOME/dev/vmodem0,waitslave tcp:modem-server:54321

NETWORK CONNECTION

There a some choices if a simple TCPv4 connection does not meet your
requirements:
TCPv6: simply replace the "tcp-l" and "tcp" keywords with "tcp6-l" and "tcp6"
Socks: if a socks server protects the connection, you can replace the
"tcp:modem-server:54321" clause with something like
"socks:socks-server:modem-server:54321" or 
"socks:socks-server:modem-server:54321,socksport=1081,socksuser=nobody"

SECURITY

SSL
If you want to protect your server from misuse or your data from sniffing and
manipulation, use a SSL connection with client and server authentication
(currently only over TCPv4 without socks or proxy). 
See <a href="socat-openssl.txt">socat-openssl.txt</a> for instructions.

IP Addresses
!!! bind=...
!!! range=...
!!! lowport (for root)
!!! sourceport
!!! tcpwrap=

FULL FEATURES
$ socat -d -d ssl-l:54321,reuseaddr,cert=server.pem,cafile=client.crt,fork \
     file:/dev/tty0,nonblock,echo=0,raw,waitlock=/var/run/tty0.lock

TROUBLESHOOTING
-v -x

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .