History of SocatOptions
Older Newer
2017-05-26 01:23:51 . . . . catv-80-98-142-196.catv.broadband.hu [socat example (poor man's turn server)]
2017-05-25 23:35:50 . . . . catv-80-98-142-196.catv.broadband.hu [socat example (eg b19200)]
2017-05-25 23:16:25 . . . . catv-80-98-142-196.catv.broadband.hu [minor formatting: socat options example]
2017-05-25 19:10:42 . . . . catv-80-98-142-196.catv.broadband.hu [socat example]


Changes by last author:

Added:
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 :

<code>

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

</code>

For some reason the ser2net + socat at the ECU side seem more reliable than just socat (maybe we have not fully mastered socat yet ?)

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

----

Poor man's "turn-server"

<code>

# On a public IP:

export SOCAT_DEFAULT_LISTEN_IP=.... (may or may not be needed)

socat tcp4-listen:9907,reuseaddr tcp4-listen:9906

# And on ser2net (assuming ser2net listens on 9001):

socat tcp:localhost:9001 tcp:public-ip.net:9907,forever,interval=10,fork

</code>

* Obviuosly since socat connects ser2net and 9907, so VT connect to public-ip.net:9906

* Expect runtime data rate of 5..8Hz (not 15..20Hz as locally).

----

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

* mss=1448 (1452 should mostly work, but probably no disadvantage of 1448 or 1444)

** mss option was needed for some telco in London that used mtu=1492 ( common in ADSL pppoe or similar)

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

<code>

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

</code>

(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

* note: 8808 (2N=even) and 8809 (2N+1: odd) are 2 ports of the SAME publically reachable dragon "relay" server.

* While it is experimental, it worked every time I tested. (if many users want to use it simultaneously, more server ports will be needed).