SharingSerialDevices

From Domoticz
Jump to: navigation, search

This guide is not finished

Ser2Net

With 'ser2net' you can share serial devices under unix over TCP/IP

Installation

sudo apt-get install ser2net

a configuration file is created in /etc/ser2net.conf

an example line to share an opentherm gateway can be:

2000:raw:400:/dev/ttyUSB0:9600 8DATABITS NONE 1STOPBIT

an example line to share an zwave usb stick:

2000:telnet:600:/dev/ttyUSB22:115200 8DATABITS NONE 1STOPBIT

In both cases the serial port is shared on port: 2000

Windows

It is possible to create a virtual comport that can connect to a ser2net share.

VSP application:

http://new.hwg.cz/download/sw/version/hw-vsp3-single_3-1-2.exe

Unix

To create a virtual comport, use the program socat

sudo apt-get install socat

example to create a USB device that connects to a share on host 192.168.0.116 on port 2000:

sudo socat pty,link=/dev/ttyUSB30,raw,echo=0 tcp:192.168.0.116:2000

this creates a /dev/ttyUSB30 serial device link

Auto start socat on boottime

git clone https://github.com/asaif/socat-init.git

sudo cp socat-init/socat /etc/init.d/
sudo chmod +x /etc/init.d/socat
sudo update-rc.d socat defaults

sudo cp socat-init/defaults/socat.conf /etc/default/

Now edit the configuration file like:

sudo vi /etc/default/socat.conf

OPTIONS="pty,link=/dev/ttyUSB30,raw,ignoreeof,echo=0 tcp:192.168.0.116:2000"

start the service with:

sudo service socat start

you can check the status with:

sudo service socat status