Serial server (SIOS)

From uCtrl
This page is kept for historical interest. It may document projects or methods that are obsolete and/or no longer relevant. The information here is not kept up-to-date.

This application was primarily used in the rack box project — which was terminated when I moved out of my first apartment.
Serial Server v1.17.0

Information

Serial Server runs locally on the computer with the modules connected. It gathers and analyses strings sent from the modules, if Serial Client is connected all necessary strings will be forwarded. Commands sent from Serial Client will also be forwarded to the correct serial port, thus the correct module. Serial Server has three basic configurations, timers, triggers and analog values.

The server also monitors the modules, making sure they are online. This check is based on the lifesignal status strings sent every 20. seconds. The status is forwarded to Serial Client. The last received status of any input or output, for all the modules, are saved in memory by Serial Server. When Serial Client is connected all this information is forwarded at login, setting every values to the actual state. One can also manually request I/O status from every module.

See also: Serial I/O system

Client

Serial Client is the front-end of the Serial I/O system, it connects to Serial Server using a TCP socket connection.

Read more about Serial Client.

TCP commands

To send simple commands to Serial Server a TCP socket is used, referred to as TCP command. When the string is received the socket connection is automatically terminated. The command string must start with the password and then the actual command.

In Windows the application "SerialTCPcommand.exe" is used:

SerialTCPcommand.exe password;002:o:08:1

In Linux the application "netcat" is used:

echo "password;002:o:08:1" | netcat ip-address port

COM ports

Rocketport 8-ports

Every module requires a serial port, it's therefore often necessary with extra ports on the computer. I use a serial expansion card from Comtrol with an external interface, it uses one PCI slot and provides 8 extra serial ports. The interface connectors is DB-25 female, using an adapter it's possible to connect a RS-232 DB-9 female cable.

It's also possible to use regular RS-232 controller cards, or a USB <-> RS-232 adapter. But with many modules this will use a lot of PCI slots and/or USB ports.

To make the modules wireless it should be possible to use a bluetooth RS-232 adapter. This would replace the serial cable by connecting a bluetooth dongle to the module and using a USB bluetooth interface on the computer. I have not tried this, but in theory it should work.

Configuration

Modules

Every module needs a config file. This file contains serial port configuration, start bit, module name, number of inputs and outputs and if the module can receive requests. The file name is module number.ini e.g. 001.ini and it must be located in the module folder specified in the settings.

Baud, Data bit, Start-char
Module name
Number of inputs
Number of outputs
Can receive requests (0/1)

Timers

Timers cause things happen at certain point in time. It's also possible to define what day of the weed the command should be carried out, like separating weekdays and weekends. The time can be specified using wild cards.

??:??:10 <- This will be carried out 10 seconds past every minute.

Triggers

Triggers cause things to happen when a certain situation occurs, like an activated in/output or a analog value to high/low. Every trigger has two actions, one occurring immediately and the other delayed by X 10/seconds.

Analog values

Serial Server calculated analog values (0-999) from the modules, to actual values using a certain formula. This calculated value is then forwarded to Serial Client is connected, and written to log files. This files can be used by other applications, like Mrtg or LCDsmartie.

Example calculation for temperature:

(Value * 5) = (mV - zero point in mV) / 10 = Temperature in degree 'C

For every analog input a virtual ports is made, the value is sent to Serial Client with two decimals and needs to be divided by 100.

000:a:01:1950 -> Analog input #1: 19,5'C

Log files

Serial Server makes three kinds of files:

Log files
Every action stored in one file. This file is read and parsed to a MySQL database periodically, and used for historical data.
Value files
The calculated value of every analog port is written in individual log files. Used for making mrtg graphs and for parsing values to Serial Client 4.x.
State files
The state of every module and I/O port is written in individual log files. Used for parsing values to Serial Client 4.x.

Screen shots