Miniterm is now available as module instead of example. see serial.tools.miniterm for details.
This program opens a TCP/IP port. When a connection is made to that port (e.g. with telnet) it forwards all data to the serial port and vice versa.
This example only exports a raw socket connection. The next example below gives the client much more control over the remote serial port.
usage: tcp_serial_redirect.py [-h] [-q] [--parity {N,E,O,S,M}] [--rtscts]
[--xonxoff] [--rts RTS] [--dtr DTR]
[-P LOCALPORT]
SERIALPORT [BAUDRATE]
Simple Serial to Network (TCP/IP) redirector.
positional arguments:
SERIALPORT serial port name
BAUDRATE set baud rate, default: 9600
optional arguments:
-h, --help show this help message and exit
-q, --quiet suppress non error messages
serial port:
--parity {N,E,O,S,M} set parity, one of {N E O S M}, default: N
--rtscts enable RTS/CTS flow control (default off)
--xonxoff enable software flow control (default off)
--rts RTS set initial RTS line state (possible values: 0, 1)
--dtr DTR set initial DTR line state (possible values: 0, 1)
network settings:
-P LOCALPORT, --localport LOCALPORT
local TCP port
NOTE: no security measures are implemented. Anyone can remotely connect to
this service over the network. Only one connection at once is supported. When
the connection is terminated it waits for the next connect.
Simple cross platform RFC 2217 serial port server. It uses threads and is portable (runs on POSIX, Windows, etc).
usage: rfc2217_server.py [-h] [-p TCPPORT] [-v] SERIALPORT
RFC 2217 Serial to Network (TCP/IP) redirector.
positional arguments:
SERIALPORT
optional arguments:
-h, --help show this help message and exit
-p TCPPORT, --localport TCPPORT
local TCP port, default: 2217
-v, --verbose print more diagnostic messages (option can be given
multiple times)
NOTE: no security measures are implemented. Anyone can remotely connect to
this service over the network. Only one connection at once is supported. When
the connection is terminated it waits for the next connect.
New in version 2.5.
This example implements a TCP/IP to serial port service that works with multiple ports at once. It uses select, no threads, for the serial ports and the network sockets and therefore runs on POSIX systems only.
usage: port_publisher.py [options]
Announce the existence of devices using zeroconf and provide
a TCP/IP <-> serial port gateway (implements RFC 2217).
If running as daemon, write to syslog. Otherwise write to stdout.
optional arguments:
-h, --help show this help message and exit
serial port settings:
--ports-regex REGEX specify a regex to search against the serial devices
and their descriptions (default: /dev/ttyUSB[0-9]+)
network settings:
--tcp-port PORT specify lowest TCP port number (default: 7000)
daemon:
-d, --daemon start as daemon
--pidfile FILE specify a name for the PID file
diagnostics:
-o FILE, --logfile FILE
write messages file instead of stdout
-q, --quiet suppress most diagnostic messages
-v, --verbose increase diagnostic messages
NOTE: no security measures are implemented. Anyone can remotely connect to
this service over the network. Only one connection at once, per port, is
supported. When the connection is terminated, it waits for the next connect.
Requirements:
Installation as daemon:
New in version 2.5: new example
A simple terminal application for wxPython and a flexible serial port configuration dialog are shown here.
The project uses a number of unit test to verify the functionality. They all need a loop back connector. The scripts itself contain more information. All test scripts are contained in the directory test.
The unit tests are performed on port 0 unless a different device name or rfc2217:// URL is given on the command line (argv[1]).