Blankom-Encoder-EN-V3-2019-RR.docx
- 26 -
RRI 26. Februar 2019
different baud rates or other serial port settings.
3) Connect a Linux program that needs a serial port to a remote serial port.
Some programs are written to communicate directly with a serial port such
as some data aquisition programs. The remserial program can use
pseudo-ttys to fool the program into thinking that it is talking to a
real serial port on the local machine:
remserial -d -r server-name -p 23000 -l /dev/remserial1 /dev/ptmx &
This creates a file called /dev/remserial1 which can be used by the
data aquisition application as its serial port. Any data sent or received
is passed to the remote server-name on port 23000 where a computer configured
in case number 1 above passes it to a real serial port.
The remserial program uses the special pseudo-tty master device /dev/ptmx
(see man ptmx) which creates a slave device that looks like a normal
serial port named /dev/pts/something. Unfortunately, the actual device
name created isn't consistent, so the remserial program creates a symbol
link from the device name specified with the -l option to the /dev/pts/
name that was created allowing the other application to be configured
with a consistent device name.
4) Server farm console control.
Assuming multiple Linux servers (such as web servers) are set up to have a
serial port as their console instead of a monitor/keyboard, their serial
ports could be connected to a control server using a multi-port serial board.
On the control server, a copy of remserial is run for each server:
remserial -d -p 23000 -s "115200 raw" /dev/ttyS0 &
remserial -d -p 23001 -s "115200 raw" /dev/ttyS1 &
remserial -d -p 23002 -s "115200 raw" /dev/ttyS2 &
remserial -d -p 23003 -s "115200 raw" /dev/ttyS3 &
etc.
From any computer on the local network, use a telnet program to connect
to the control server on the appropriate port:
telnet control-server-name 23002
This would connect through the associated serial port to the desired server's
console. This example would then give the user console access to the 3rd
server.
Careful scripting such as using the Linux "expect" program could allow
batches of commands to be run on each server.
Other Linux program useful with remserial
-----------------------------------------
- nc - The netcat program is similar to remserial except that it creates
connections between network ports and command line standard input and
output.
For example, with case number 1 above, the following command run on
another computer will send the contents of the named file out the
serial port used by the remserial program:
nc server-name 23000 <file-name
Similarily, the following command will store incoming serial data in a file
until the program is manually interrupted:
nc server-name 23000 >file-name
- telnet - The telnet program is normally used to log into a remote computer,
but when used with network ports other than number 23, it operates in a
raw data mode.
For example, with case number 1 above, the following command will allow
the user of the telnet program to see incoming serial port data and
type data on the keyboard to send to the serial port:
telnet server-name 23000
This is ideal for controlling the device connected to the serial port
if it has some sort of command line interface usable over the serial port.
remserial Usage:
---------------
remserial [-r machinename] [-p netport] [-s "stty params"] device
-r machinename
The remote machine name to connect to. If not
specified, then this is the server side.
-p netport
Specifiy IP port# (default 23000)
-s "stty params"
If serial port, specify stty parameters, see man stty
-d
Run as daemon programs
-x debuglevel
Set debug level, 0 is default, 1,2 give more info
-l linkname
If the device is /dev/ptmx, creates a symbolic link
to the corresponding slave pseudo-tty so that another
application has a static device name to use.
-m max-connections Maximum number of simultaneous client connections to allow
device
Character oriented device node such as /dev/ttyS0.