lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame^] | 1 | ---------
|
| 2 |
|
| 3 | The remserial program acts as a communications bridge between a TCP/IP
|
| 4 | network port and a Linux device such as a serial port. Any character-oriented
|
| 5 | Linux /dev device will work.
|
| 6 |
|
| 7 | The program can also use pseudo-ttys as the device. A pseudo-tty is like
|
| 8 | a serial port in that it has a /dev entry that can be opened by a program
|
| 9 | that expects a serial port device, except that instead of belonging to
|
| 10 | a physical serial device, the data can be intercepted by another program.
|
| 11 | The 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
|
| 14 | 3 below for details.
|
| 15 |
|
| 16 | The program can operate as a server accepting network connections from
|
| 17 | other machines, or as a client, connecting to remote machine that
|
| 18 | is running the remserial program or some other program that accepts
|
| 19 | a raw network connection. The network connection passes data as-is,
|
| 20 | there is no control protocol over the network socket.
|
| 21 |
|
| 22 | Multiple copies of the program can run on the same computer at the same
|
| 23 | time assuming each is using a different network port and device.
|
| 24 |
|
| 25 | Some examples:
|
| 26 |
|
| 27 | 1) Give access to a RS232 device over a network.
|
| 28 |
|
| 29 | The computer with the serial port connected to the device (such as a
|
| 30 | data aquisition device) runs the remserial program:
|
| 31 |
|
| 32 | remserial -d -p 23000 -s "9600 raw" /dev/ttyS0 &
|
| 33 |
|
| 34 | This starts the program in daemon mode so that it runs in the background,
|
| 35 | it 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
|
| 37 | machine can then read and write to the device attached to the serial port.
|
| 38 |
|
| 39 | This can be started from /etc/rc.local or as an entry in /etc/inittab
|
| 40 | or set up as a system service with a file in /etc/rc.init/.
|
| 41 |
|
| 42 | 2) Connect an RS232 device to a specified server.
|
| 43 |
|
| 44 | The computer with the serial port connected to the device (such as a
|
| 45 | data aquisition device) runs the remserial program:
|
| 46 |
|
| 47 | remserial -d -r server-name -p 23000 -s "9600 raw" /dev/ttyS0 &
|
| 48 |
|
| 49 | This would be used with case number 1 above creating an end-to-end serial
|
| 50 | port connection. What goes in the serial port on one machine would come
|
| 51 | out the serial port of the other machine. The ports could be running at
|
| 52 | different baud rates or other serial port settings.
|
| 53 |
|
| 54 | 3) Connect a Linux program that needs a serial port to a remote serial port.
|
| 55 |
|
| 56 | Some programs are written to communicate directly with a serial port such
|
| 57 | as some data aquisition programs. The remserial program can use
|
| 58 | pseudo-ttys to fool the program into thinking that it is talking to a
|
| 59 | real serial port on the local machine:
|
| 60 |
|
| 61 | remserial -d -r server-name -p 23000 -l /dev/remserial1 /dev/ptmx &
|
| 62 |
|
| 63 | This creates a file called /dev/remserial1 which can be used by the
|
| 64 | data aquisition application as its serial port. Any data sent or received
|
| 65 | is passed to the remote server-name on port 23000 where a computer configured
|
| 66 | in case number 1 above passes it to a real serial port.
|
| 67 |
|
| 68 | The 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
|
| 70 | serial port named /dev/pts/something. Unfortunately, the actual device
|
| 71 | name created isn't consistent, so the remserial program creates a symbol
|
| 72 | link from the device name specified with the -l option to the /dev/pts/
|
| 73 | name that was created allowing the other application to be configured
|
| 74 | with a consistent device name.
|
| 75 |
|
| 76 | 4) Server farm console control.
|
| 77 |
|
| 78 | Assuming multiple Linux servers (such as web servers) are set up to have a
|
| 79 | serial port as their console instead of a monitor/keyboard, their serial
|
| 80 | ports could be connected to a control server using a multi-port serial board.
|
| 81 | On 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 |
|
| 89 | From any computer on the local network, use a telnet program to connect
|
| 90 | to the control server on the appropriate port:
|
| 91 |
|
| 92 | telnet control-server-name 23002
|
| 93 |
|
| 94 | This would connect through the associated serial port to the desired server's
|
| 95 | console. This example would then give the user console access to the 3rd
|
| 96 | server.
|
| 97 |
|
| 98 | Careful scripting such as using the Linux "expect" program could allow
|
| 99 | batches of commands to be run on each server.
|
| 100 |
|
| 101 | Other 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 |
|
| 133 | remserial Usage:
|
| 134 | ---------------
|
| 135 |
|
| 136 | remserial [-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
|
| 148 | device Character oriented device node such as /dev/ttyS0.
|
| 149 |
|