maslovw / serial_tcp_clients

Python script create a tcp server for sharing serial console

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Info

Python script starts TCP Server for sharing serial console

clientA <-->\
             | <-----> TcpServer <---> serial port
clientB <-->/

Serial port is opened if at least one client is connected.

If all clients are disconnected, then the serial port is closed.

If connection with serial device was lost, all TCP clients get notification, but connection will be kept, and the script will make attempts to open serial device.

Works in Windows and Linux (incl. RaspberryPi)

Requerements

python3

Install

using pip: pip install serial-tcp-clients

or using source via python setup: git clone https://github.com/maslovw/serial_tcp_clients.git

cd serial_tcp_clients

python3 setup.py install

Usage

python -m serialtcp -p PORT -d COM -b BAUDRATE

Arguments:

optional arguments:
  -h, --help            show this help message and exit
  --list                print list of serial devices
  -v {debug,info,warn,error,fatal}, --verbose {debug,info,warn,error,fatal}
                        logger level, default: error

TCP connection:
  -p TCP_PORT, --tcp-port TCP_PORT
                        TCP listen port

serial port:
  -d DEVICE, --device DEVICE
                        serial port/device
  -b BAUDRATE, --baudrate BAUDRATE
                        default: 115200
  --parity {N,E,O,S,M}  set parity, one of {N E O S M}, default: N
  -cd CHAR_DELAY, --char-delay CHAR_DELAY
                        set delay between chars for serial transmission,
                        default: 0.0s
  -we WAIT_ECHO, --wait-echo WAIT_ECHO
                        wait for echo char when transmitting, value represents
                        timeout in seconds, default: 0

example

python -m serialtcp -p 5001 -d COM1 -b 921600 -v info -we 1

About

Python script create a tcp server for sharing serial console

License:MIT License


Languages

Language:Python 100.0%