SocatOptions (2017-05-25 23:35:50)

Useful socat options and recipies (to connect to device remotely, possibly behind restrictive firewall)

Traditional way to make a serial relay that TCP LISTENS on port 9001 is via ser2net :\n

echo '9001:raw:600:/dev/ttyUSB0:19200 8DATABITS NONE 1STOPBIT'>>/etc/ser2net.conf

TODO: socat equivalent (the order of descriptors might matter; tcp-l or the serial device should be first ? So that socat only opens the serial device when accepting incoming connectiong from TCP remote peer).

See OverTCPWireless


ser2net is very useful when connecting over LAN (or via WAN when one has firewall administration passwd and knowledge ).

However, very often people do NOT have firewall administration passwd => they cannot connect to their devices over WAN.

In that case the devices can be set up to CONNECT to some relay (similar to a "turn server") that listens on some known public address.

Since socat can open the serial device (without ser2net), perhaps ser2net is not needed AT ALL. Socat might be just enough on orangepi/raspi

[socat example]

Socat

So an example of running socat to tcp-connect (not listen!):\n

while [ ! -e /dev/shm/STOP ]; do socat file:/dev/ttyUSB0,b19200,raw,echo=0  tcp:svn.x-dsl.hu:8809,mss=1444,forever,interval=10,fork ; sleep 1; done

(run from terminal, socat -v option is your friend; only run from rc.local after it works as expected - even in case of network disconnects).

Point your VemsTune to svn.x-dsl.hu:8808 and it will connect to the serial port opened by socat if all goes well