Installing and configuring socat
socat can be installed by
apt-get install socat
After installation, socat can be started on the client side and the complete configuration is done by command line parameters.
socat pty,link=/dev/lio0,nonblock,raw,echo=0,ignoreof,waitslave tcp:RPI-AZ-2:4001
This instruction creates a device /dev/lio0 which is connected to port 4001 of the network device server RPI-AZ-2. The option nonblock opens the device in non-blocking mode, raw instructs socat to send data unprocessed and echo=0 switches local echo off. In our tests these three options could be omitted without any influences. But, the option ignoreof is important and causes that socat stays active after the port was closed by the client application. Since e.g. the LucidIoCtrl command line tool closes the serial port when it returns, socat must not close the device in order to be responsive for further calls.
As a short form the following call of socat is working well:
socat pty,link=/dev/lio0,ignoreof,waitslave tcp:RPI-AZ-2:4001
Calling socat blocks the terminal and it is also not useful to start socat in a script this way because it does not return.
(socat pty,link=/dev/lio0,ignoreof,waitslave tcp:RPI-AZ-2:4001) &
By calling socat this way a background process is started. The prompt returns immediately after the process has been installed and a script running this line does also not block anymore.
Note: It might be necessary to run socat as root. In this case socat assigns the root user as owner of the created device what prevents other users from accessing the device. This is not desired as it would require all applications accessing the created virtual port need to have root permissions.
(socat pty,link=/dev/lio0,user=klaus,group=dialout,mode=660,ignoreof,waitslave tcp:RPI-AZ-2:4001) &
The parameters user, group and mode make it possible to specify the privileges of the created device. In this example the device /dev/lio0 belongs to the user klaus, the group dialout and can be accessed by the user and the group. All users accessing any serial port must be member of the group dialout, so it makes sense to create also the virtual device with this group assigned.
When socat is running, the virtual device is accessible and LucidIoCtrl can communicate with the remote device like this:
Accessing a remote USB Analog Input Module connected to a Network Device Server
This instruction runs the LucidIoCtrl command line tool on the client. It connects through the remote network device server to the USB IO module and requests device information of the USB analog input module.