serial to tcp bridge
Project description
ser2sock
A single-threaded, multi serial line to TCP bridge server.
Can run under python 2.6 up to 3.x (tested 3.8).
Installation
From within your favorite python environment:
pip install ser2sock
Usage
ser2net -c <configuration file>
Configuration
In order to provide flexibility, configuration is written in python.
The only requirement is to have a bridges
member which consists of a
sequence of bridges. A bridge is a dictionary with mandatory keys serial
and tcp
.
Example:
bridges = [
{
'serial': {'address': '/dev/ttyS0'},
'tcp': {'address': ("0", 18500)}
},
{
'serial': {'address': '/dev/ttyS1', 'baudrate': 19200},
'tcp': {'address': ("0", 18501), 'no_delay': False}
}
]
serial
:address
mandatory. Supports any keyword supported byserial.serial_for_url
(orserial.Serial
ifserial_for_url
does not existtcp
:address
mandatory (must be a pair bind host and port).reuse_addr
: (default: True) TCP reuse addressno_delay
: (default: True) disable Nagle's algorithmtos
: (default:0x10
, meaning low delay) type of service.
tcp
and serial
helpers are automatically loaded to the config namespace.
Here is the equivalent above config using helpers:
bridges = [
[serial(address="/dev/ttyS0"), tcp(address=("0", 18500))],
[serial(address="/dev/ttyS1", baudrate=19200),
tcp(address=("0", 18501), no_delay=False)],
]
You are free to put any code in your python configuration file. Here is an example setting up logging:
import logging
logging.basicConfig(
level=logging.DEBUG,
format='%(asctime)s %(levelname)s %(message)s'
)
bridges = [
[serial(address="/dev/ttyS0"), tcp(address=("0", 18500))],
[serial(address="/dev/ttyS1", baudrate=19200),
tcp(address=("0", 18501), no_delay=False)],
]
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ser2sock-2.0.0.tar.gz
(2.9 kB
view hashes)