blob: 06a7ac0198de06728b6038fcaa95d1785902129e [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001---------
2
3The remserial program acts as a communications bridge between a TCP/IP
4network port and a Linux device such as a serial port. Any character-oriented
5Linux /dev device will work.
6
7The program can also use pseudo-ttys as the device. A pseudo-tty is like
8a serial port in that it has a /dev entry that can be opened by a program
9that expects a serial port device, except that instead of belonging to
10a physical serial device, the data can be intercepted by another program.
11The remserial program uses this to connect a network port to the
12"master" (programming) side of the pseudo-tty allowing the device driver
13(slave) side to be used by some program expecting a serial port. See example
143 below for details.
15
16The program can operate as a server accepting network connections from
17other machines, or as a client, connecting to remote machine that
18is running the remserial program or some other program that accepts
19a raw network connection. The network connection passes data as-is,
20there is no control protocol over the network socket.
21
22Multiple copies of the program can run on the same computer at the same
23time assuming each is using a different network port and device.
24
25Some examples:
26
271) Give access to a RS232 device over a network.
28
29The computer with the serial port connected to the device (such as a
30data aquisition device) runs the remserial program:
31
32 remserial -d -p 23000 -s "9600 raw" /dev/ttyS0 &
33
34This starts the program in daemon mode so that it runs in the background,
35it waits for connections on port 23000 and sets up the serial port
36/dev/ttyS0 at 9600 baud. Network connections to port 23000 from any
37machine can then read and write to the device attached to the serial port.
38
39This can be started from /etc/rc.local or as an entry in /etc/inittab
40or set up as a system service with a file in /etc/rc.init/.
41
422) Connect an RS232 device to a specified server.
43
44The computer with the serial port connected to the device (such as a
45data aquisition device) runs the remserial program:
46
47 remserial -d -r server-name -p 23000 -s "9600 raw" /dev/ttyS0 &
48
49This would be used with case number 1 above creating an end-to-end serial
50port connection. What goes in the serial port on one machine would come
51out the serial port of the other machine. The ports could be running at
52different baud rates or other serial port settings.
53
543) Connect a Linux program that needs a serial port to a remote serial port.
55
56Some programs are written to communicate directly with a serial port such
57as some data aquisition programs. The remserial program can use
58pseudo-ttys to fool the program into thinking that it is talking to a
59real serial port on the local machine:
60
61 remserial -d -r server-name -p 23000 -l /dev/remserial1 /dev/ptmx &
62
63This creates a file called /dev/remserial1 which can be used by the
64data aquisition application as its serial port. Any data sent or received
65is passed to the remote server-name on port 23000 where a computer configured
66in case number 1 above passes it to a real serial port.
67
68The remserial program uses the special pseudo-tty master device /dev/ptmx
69(see man ptmx) which creates a slave device that looks like a normal
70serial port named /dev/pts/something. Unfortunately, the actual device
71name created isn't consistent, so the remserial program creates a symbol
72link from the device name specified with the -l option to the /dev/pts/
73name that was created allowing the other application to be configured
74with a consistent device name.
75
764) Server farm console control.
77
78Assuming multiple Linux servers (such as web servers) are set up to have a
79serial port as their console instead of a monitor/keyboard, their serial
80ports could be connected to a control server using a multi-port serial board.
81On the control server, a copy of remserial is run for each server:
82
83 remserial -d -p 23000 -s "115200 raw" /dev/ttyS0 &
84 remserial -d -p 23001 -s "115200 raw" /dev/ttyS1 &
85 remserial -d -p 23002 -s "115200 raw" /dev/ttyS2 &
86 remserial -d -p 23003 -s "115200 raw" /dev/ttyS3 &
87 etc.
88
89From any computer on the local network, use a telnet program to connect
90to the control server on the appropriate port:
91
92 telnet control-server-name 23002
93
94This would connect through the associated serial port to the desired server's
95console. This example would then give the user console access to the 3rd
96server.
97
98Careful scripting such as using the Linux "expect" program could allow
99batches of commands to be run on each server.
100
101Other Linux program useful with remserial
102-----------------------------------------
103
104- nc - The netcat program is similar to remserial except that it creates
105 connections between network ports and command line standard input and
106 output.
107
108 For example, with case number 1 above, the following command run on
109 another computer will send the contents of the named file out the
110 serial port used by the remserial program:
111
112 nc server-name 23000 <file-name
113
114 Similarily, the following command will store incoming serial data in a file
115 until the program is manually interrupted:
116
117 nc server-name 23000 >file-name
118
119- telnet - The telnet program is normally used to log into a remote computer,
120 but when used with network ports other than number 23, it operates in a
121 raw data mode.
122
123 For example, with case number 1 above, the following command will allow
124 the user of the telnet program to see incoming serial port data and
125 type data on the keyboard to send to the serial port:
126
127 telnet server-name 23000
128
129 This is ideal for controlling the device connected to the serial port
130 if it has some sort of command line interface usable over the serial port.
131
132
133remserial Usage:
134---------------
135
136remserial [-r machinename] [-p netport] [-s "stty params"] device
137
138-r machinename The remote machine name to connect to. If not
139 specified, then this is the server side.
140-p netport Specifiy IP port# (default 23000)
141-s "stty params" If serial port, specify stty parameters, see man stty
142-d Run as daemon programs
143-x debuglevel Set debug level, 0 is default, 1,2 give more info
144-l linkname If the device is /dev/ptmx, creates a symbolic link
145 to the corresponding slave pseudo-tty so that another
146 application has a static device name to use.
147-m max-connections Maximum number of simultaneous client connections to allow
148device Character oriented device node such as /dev/ttyS0.
149