#Serial ports over TCP/IP with socat

<div class="text-success lead">
This article illustrates how to realize a lan to serial gateway
</div>

##Remote unit

On the remote unit install __ser2net__  then add this line in __/etc/ser2net.conf__ 
configuration file 

<pre class="minicom">
2000:raw:600:/dev/ttyS1:115200 8DATABITS NONE 1STOPBIT
</pre>

Launch ser2net:

<pre class="minicom">
# <b>ser2net</b>
</pre>

##Local unit

Install the __socat__ utility.

Create a directory called __$HOME/dev__

Launch socat:

<pre class="minicom">
$ <b>socat pty,link=$HOME/dev/ttyV0,waitslave tcp:</b>remoteip:remoteport
</pre> 

Open minicom on __/dev/ttyV0__ and send chars to your remote port.

##Examples

Serial port on stdin

<pre class="minicom">
socat /dev/ttyUSB0,b115200,raw,echo=0,crnl -
</pre>

#Remote console

##Board

<pre class="minicom">
socat /dev/ttyS2,b115200,raw,echo=0 TCP:terzo.acmesystems.it:2002
socat /dev/ttyS4,b115200,raw,echo=0 TCP:terzo.acmesystems.it:2004
</pre>

#Server web

<pre class="minicom">
socat TCP-LISTEN:2002 PTY,link=ttyV2,raw,crnl
socat TCP-LISTEN:2004 PTY,link=ttyV2,raw,crnl
</pre>

## Design tips

Using the <a href="/roadrunner">RoadRunner SOM</a> it is possible to manage up to 10 serial ports over a network 
link.

<a href="/roadrunner">
<img src="/photos/products_128/ROADRUNNER-Q0.jpg">
</a>

* Read more about the <a href="/roadrunner">RoadRunner SOM</a>
* @article='roadrunner_serial'

## Related links

* [Socat man](http://www.dest-unreach.org/socat/doc/socat.html)
* [Connecting to a Remote Serial Port over TCP/IP](http://techtinkering.com/2013/04/02/connecting-to-a-remote-serial-port-over-tcpip/)

@include='adv_main'

