ser2tcp 2.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,35 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ jobs:
8
+ publish:
9
+ runs-on: ubuntu-latest
10
+ environment: pypi
11
+ permissions:
12
+ id-token: write
13
+
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+
17
+ - name: Set up Python
18
+ uses: actions/setup-python@v5
19
+ with:
20
+ python-version: "3.14"
21
+
22
+ - name: Install build dependencies
23
+ run: pip install build
24
+
25
+ - name: Install package
26
+ run: pip install .
27
+
28
+ - name: Run unit tests
29
+ run: python -m unittest discover -v tests/
30
+
31
+ - name: Build package
32
+ run: python -m build
33
+
34
+ - name: Publish to PyPI
35
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,29 @@
1
+ name: Tests
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ${{ matrix.os }}
12
+ strategy:
13
+ matrix:
14
+ os: [ubuntu-latest, windows-latest]
15
+ python-version: ["3.10", "3.14"]
16
+
17
+ steps:
18
+ - uses: actions/checkout@v4
19
+
20
+ - name: Set up Python ${{ matrix.python-version }}
21
+ uses: actions/setup-python@v5
22
+ with:
23
+ python-version: ${{ matrix.python-version }}
24
+
25
+ - name: Install package
26
+ run: pip install .
27
+
28
+ - name: Run unit tests
29
+ run: python -m unittest discover -v tests/
@@ -0,0 +1,12 @@
1
+ __pycache__
2
+ build
3
+ dist
4
+ .*
5
+ !.gitignore
6
+ !.github
7
+ !.mpyproject
8
+ *.egg-info
9
+ _version.py
10
+ *.md
11
+ !README*.md
12
+ scripts/
ser2tcp-2.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Pavel Revak
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
ser2tcp-2.1.0/PKG-INFO ADDED
@@ -0,0 +1,247 @@
1
+ Metadata-Version: 2.4
2
+ Name: ser2tcp
3
+ Version: 2.1.0
4
+ Summary: Serial port proxy to TCP or TELNET
5
+ Author-email: Pavel Revak <pavel.revak@gmail.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/cortexm/ser2tcp
8
+ Keywords: serial,tcp,telnet,proxy
9
+ Classifier: Development Status :: 5 - Production/Stable
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Topic :: Software Development :: Embedded Systems
12
+ Classifier: Programming Language :: Python :: 3
13
+ Requires-Python: >=3.8
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Requires-Dist: pyserial>=3.0
17
+ Dynamic: license-file
18
+
19
+ # Ser2tcp
20
+
21
+ Simple proxy for connecting over TCP or telnet to serial port
22
+
23
+ https://github.com/cortexm/ser2tcp
24
+
25
+ ## Features
26
+
27
+ - can serve multiple serial ports using pyserial library
28
+ - each serial port can have multiple servers
29
+ - server can use TCP or TELNET protocol
30
+ - TCP protocol just bridge whole RAW serial stream to TCP
31
+ - TELNET protocol will send every character immediately and not wait for ENTER, it is useful to use standard `telnet` as serial terminal
32
+ - servers accepts multiple connections at one time
33
+ - each connected client can sent to serial port
34
+ - serial port send received data to all connected clients
35
+ - non-blocking send with configurable timeout and buffer limit
36
+
37
+ ## Installation
38
+
39
+ ```
40
+ pip install ser2tcp
41
+ ```
42
+
43
+ or from source:
44
+
45
+ ```
46
+ pip install .
47
+ ```
48
+
49
+ ### Uninstall
50
+
51
+ ```
52
+ pip uninstall ser2tcp
53
+ ```
54
+
55
+ ## Command line options
56
+
57
+ ```
58
+ -h, --help show this help message and exit
59
+ -V, --version show program's version number and exit
60
+ -v, --verbose Increase verbosity
61
+ -u, --usb List USB serial devices and exit
62
+ -c CONFIG, --config CONFIG
63
+ configuration in JSON format
64
+ ```
65
+
66
+ ### Verbose
67
+
68
+ - By default print only ERROR and WARNING messages
69
+ - `-v`: will print INFO messages
70
+ - `-vv`: print also DEBUG messages
71
+
72
+ ## Configuration file example
73
+
74
+ ```json
75
+ [
76
+ {
77
+ "serial": {
78
+ "port": "/dev/ttyUSB0",
79
+ "baudrate": 115200,
80
+ "parity": "NONE",
81
+ "stopbits": "ONE"
82
+ },
83
+ "servers": [
84
+ {
85
+ "address": "127.0.0.1",
86
+ "port": 10001,
87
+ "protocol": "tcp"
88
+ },
89
+ {
90
+ "address": "0.0.0.0",
91
+ "port": 10002,
92
+ "protocol": "telnet",
93
+ "send_timeout": 5.0,
94
+ "buffer_limit": 65536
95
+ }
96
+ ]
97
+ }
98
+ ]
99
+ ```
100
+
101
+ ### Serial configuration
102
+
103
+ `serial` structure pass all parameters to [serial.Serial](https://pythonhosted.org/pyserial/pyserial_api.html#classes) constructor from pyserial library, this allows full control of the serial port.
104
+
105
+ #### USB device matching
106
+
107
+ Instead of specifying `port` directly, you can use `match` to find device by USB attributes:
108
+
109
+ ```json
110
+ {
111
+ "serial": {
112
+ "match": {
113
+ "vid": "0x303A",
114
+ "pid": "0x4001",
115
+ "serial_number": "dcda0c2004bc0000"
116
+ },
117
+ "baudrate": 115200
118
+ }
119
+ }
120
+ ```
121
+
122
+ Use `ser2tcp --usb` to list available USB devices with their attributes:
123
+
124
+ ```
125
+ $ ser2tcp --usb
126
+ /dev/cu.usbmodem1101
127
+ vid: 0x303A
128
+ pid: 0x4001
129
+ serial_number: dcda0c2004bc0000
130
+ manufacturer: Espressif Systems
131
+ product: Espressif Device
132
+ location: 1-1
133
+ ```
134
+
135
+ Match attributes: `vid`, `pid`, `serial_number`, `manufacturer`, `product`, `location`
136
+
137
+ - Wildcard `*` supported (e.g. `"product": "CP210*"`)
138
+ - Matching is case-insensitive
139
+ - Error if multiple devices match the criteria
140
+ - `baudrate` is optional (default 9600, CDC devices ignore it)
141
+
142
+ ### Server configuration
143
+
144
+ | Parameter | Description | Default |
145
+ |-----------|-------------|---------|
146
+ | `address` | Bind address | required |
147
+ | `port` | TCP port | required |
148
+ | `protocol` | `tcp` or `telnet` | required |
149
+ | `send_timeout` | Disconnect client if data cannot be sent within this time (seconds) | 5.0 |
150
+ | `buffer_limit` | Maximum send buffer size per client (bytes), `null` for unlimited | null |
151
+
152
+ ## Usage examples
153
+
154
+ ```
155
+ ser2tcp -c ser2tcp.conf
156
+ ```
157
+
158
+ Direct running from repository:
159
+
160
+ ```
161
+ python run.py -c ser2tcp.conf
162
+ ```
163
+
164
+ ### Connecting using telnet
165
+
166
+ ```
167
+ telnet localhost 10002
168
+ ```
169
+
170
+ (to exit telnet press `CTRL + ]` and type `quit`)
171
+
172
+ ## Installation as service
173
+
174
+ ### Linux - systemd user service
175
+
176
+ 1. Copy service file:
177
+ ```
178
+ cp ser2tcp.service ~/.config/systemd/user/
179
+ ```
180
+ 2. Create configuration file `~/.config/ser2tcp.conf`
181
+ 3. Reload user systemd services:
182
+ ```
183
+ systemctl --user daemon-reload
184
+ ```
185
+ 4. Start and enable service:
186
+ ```
187
+ systemctl --user enable --now ser2tcp
188
+ ```
189
+ 5. To allow user services running after boot you need to enable linger (if this is not configured, then service will start after user login and stop after logout):
190
+ ```
191
+ sudo loginctl enable-linger $USER
192
+ ```
193
+
194
+ ### Linux - systemd system service
195
+
196
+ 1. Create system user:
197
+ ```
198
+ sudo useradd -r -s /usr/sbin/nologin -G dialout ser2tcp
199
+ ```
200
+ 2. Copy service file:
201
+ ```
202
+ sudo cp ser2tcp-system.service /etc/systemd/system/ser2tcp.service
203
+ ```
204
+ 3. Create configuration file `/etc/ser2tcp.conf`
205
+ 4. Reload systemd and start service:
206
+ ```
207
+ sudo systemctl daemon-reload
208
+ sudo systemctl enable --now ser2tcp
209
+ ```
210
+
211
+ ### Useful commands
212
+
213
+ ```bash
214
+ # Check status
215
+ systemctl --user status ser2tcp
216
+
217
+ # View logs
218
+ journalctl --user-unit ser2tcp -e
219
+
220
+ # Restart
221
+ systemctl --user restart ser2tcp
222
+
223
+ # Stop
224
+ systemctl --user stop ser2tcp
225
+ ```
226
+
227
+ For system service, use `sudo systemctl` instead of `systemctl --user`.
228
+
229
+ ## Requirements
230
+
231
+ - Python 3.8+
232
+ - pyserial 3.0+
233
+
234
+ ### Running on
235
+
236
+ - Linux
237
+ - macOS
238
+ - Windows
239
+
240
+ ## Credits
241
+
242
+ (c) 2016-2026 by Pavel Revak
243
+
244
+ ### Support
245
+
246
+ - Basic support is free over GitHub issues.
247
+ - Professional support is available over email: [Pavel Revak](mailto:pavel.revak@gmail.com?subject=[GitHub]%20ser2tcp).
@@ -0,0 +1,229 @@
1
+ # Ser2tcp
2
+
3
+ Simple proxy for connecting over TCP or telnet to serial port
4
+
5
+ https://github.com/cortexm/ser2tcp
6
+
7
+ ## Features
8
+
9
+ - can serve multiple serial ports using pyserial library
10
+ - each serial port can have multiple servers
11
+ - server can use TCP or TELNET protocol
12
+ - TCP protocol just bridge whole RAW serial stream to TCP
13
+ - TELNET protocol will send every character immediately and not wait for ENTER, it is useful to use standard `telnet` as serial terminal
14
+ - servers accepts multiple connections at one time
15
+ - each connected client can sent to serial port
16
+ - serial port send received data to all connected clients
17
+ - non-blocking send with configurable timeout and buffer limit
18
+
19
+ ## Installation
20
+
21
+ ```
22
+ pip install ser2tcp
23
+ ```
24
+
25
+ or from source:
26
+
27
+ ```
28
+ pip install .
29
+ ```
30
+
31
+ ### Uninstall
32
+
33
+ ```
34
+ pip uninstall ser2tcp
35
+ ```
36
+
37
+ ## Command line options
38
+
39
+ ```
40
+ -h, --help show this help message and exit
41
+ -V, --version show program's version number and exit
42
+ -v, --verbose Increase verbosity
43
+ -u, --usb List USB serial devices and exit
44
+ -c CONFIG, --config CONFIG
45
+ configuration in JSON format
46
+ ```
47
+
48
+ ### Verbose
49
+
50
+ - By default print only ERROR and WARNING messages
51
+ - `-v`: will print INFO messages
52
+ - `-vv`: print also DEBUG messages
53
+
54
+ ## Configuration file example
55
+
56
+ ```json
57
+ [
58
+ {
59
+ "serial": {
60
+ "port": "/dev/ttyUSB0",
61
+ "baudrate": 115200,
62
+ "parity": "NONE",
63
+ "stopbits": "ONE"
64
+ },
65
+ "servers": [
66
+ {
67
+ "address": "127.0.0.1",
68
+ "port": 10001,
69
+ "protocol": "tcp"
70
+ },
71
+ {
72
+ "address": "0.0.0.0",
73
+ "port": 10002,
74
+ "protocol": "telnet",
75
+ "send_timeout": 5.0,
76
+ "buffer_limit": 65536
77
+ }
78
+ ]
79
+ }
80
+ ]
81
+ ```
82
+
83
+ ### Serial configuration
84
+
85
+ `serial` structure pass all parameters to [serial.Serial](https://pythonhosted.org/pyserial/pyserial_api.html#classes) constructor from pyserial library, this allows full control of the serial port.
86
+
87
+ #### USB device matching
88
+
89
+ Instead of specifying `port` directly, you can use `match` to find device by USB attributes:
90
+
91
+ ```json
92
+ {
93
+ "serial": {
94
+ "match": {
95
+ "vid": "0x303A",
96
+ "pid": "0x4001",
97
+ "serial_number": "dcda0c2004bc0000"
98
+ },
99
+ "baudrate": 115200
100
+ }
101
+ }
102
+ ```
103
+
104
+ Use `ser2tcp --usb` to list available USB devices with their attributes:
105
+
106
+ ```
107
+ $ ser2tcp --usb
108
+ /dev/cu.usbmodem1101
109
+ vid: 0x303A
110
+ pid: 0x4001
111
+ serial_number: dcda0c2004bc0000
112
+ manufacturer: Espressif Systems
113
+ product: Espressif Device
114
+ location: 1-1
115
+ ```
116
+
117
+ Match attributes: `vid`, `pid`, `serial_number`, `manufacturer`, `product`, `location`
118
+
119
+ - Wildcard `*` supported (e.g. `"product": "CP210*"`)
120
+ - Matching is case-insensitive
121
+ - Error if multiple devices match the criteria
122
+ - `baudrate` is optional (default 9600, CDC devices ignore it)
123
+
124
+ ### Server configuration
125
+
126
+ | Parameter | Description | Default |
127
+ |-----------|-------------|---------|
128
+ | `address` | Bind address | required |
129
+ | `port` | TCP port | required |
130
+ | `protocol` | `tcp` or `telnet` | required |
131
+ | `send_timeout` | Disconnect client if data cannot be sent within this time (seconds) | 5.0 |
132
+ | `buffer_limit` | Maximum send buffer size per client (bytes), `null` for unlimited | null |
133
+
134
+ ## Usage examples
135
+
136
+ ```
137
+ ser2tcp -c ser2tcp.conf
138
+ ```
139
+
140
+ Direct running from repository:
141
+
142
+ ```
143
+ python run.py -c ser2tcp.conf
144
+ ```
145
+
146
+ ### Connecting using telnet
147
+
148
+ ```
149
+ telnet localhost 10002
150
+ ```
151
+
152
+ (to exit telnet press `CTRL + ]` and type `quit`)
153
+
154
+ ## Installation as service
155
+
156
+ ### Linux - systemd user service
157
+
158
+ 1. Copy service file:
159
+ ```
160
+ cp ser2tcp.service ~/.config/systemd/user/
161
+ ```
162
+ 2. Create configuration file `~/.config/ser2tcp.conf`
163
+ 3. Reload user systemd services:
164
+ ```
165
+ systemctl --user daemon-reload
166
+ ```
167
+ 4. Start and enable service:
168
+ ```
169
+ systemctl --user enable --now ser2tcp
170
+ ```
171
+ 5. To allow user services running after boot you need to enable linger (if this is not configured, then service will start after user login and stop after logout):
172
+ ```
173
+ sudo loginctl enable-linger $USER
174
+ ```
175
+
176
+ ### Linux - systemd system service
177
+
178
+ 1. Create system user:
179
+ ```
180
+ sudo useradd -r -s /usr/sbin/nologin -G dialout ser2tcp
181
+ ```
182
+ 2. Copy service file:
183
+ ```
184
+ sudo cp ser2tcp-system.service /etc/systemd/system/ser2tcp.service
185
+ ```
186
+ 3. Create configuration file `/etc/ser2tcp.conf`
187
+ 4. Reload systemd and start service:
188
+ ```
189
+ sudo systemctl daemon-reload
190
+ sudo systemctl enable --now ser2tcp
191
+ ```
192
+
193
+ ### Useful commands
194
+
195
+ ```bash
196
+ # Check status
197
+ systemctl --user status ser2tcp
198
+
199
+ # View logs
200
+ journalctl --user-unit ser2tcp -e
201
+
202
+ # Restart
203
+ systemctl --user restart ser2tcp
204
+
205
+ # Stop
206
+ systemctl --user stop ser2tcp
207
+ ```
208
+
209
+ For system service, use `sudo systemctl` instead of `systemctl --user`.
210
+
211
+ ## Requirements
212
+
213
+ - Python 3.8+
214
+ - pyserial 3.0+
215
+
216
+ ### Running on
217
+
218
+ - Linux
219
+ - macOS
220
+ - Windows
221
+
222
+ ## Credits
223
+
224
+ (c) 2016-2026 by Pavel Revak
225
+
226
+ ### Support
227
+
228
+ - Basic support is free over GitHub issues.
229
+ - Professional support is available over email: [Pavel Revak](mailto:pavel.revak@gmail.com?subject=[GitHub]%20ser2tcp).
@@ -0,0 +1,37 @@
1
+ [build-system]
2
+ requires = ["setuptools", "setuptools-scm"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "ser2tcp"
7
+ dynamic = ["version"]
8
+ description = "Serial port proxy to TCP or TELNET"
9
+ readme = "README.md"
10
+ license = {text = "MIT"}
11
+ requires-python = ">=3.8"
12
+ authors = [
13
+ { name = "Pavel Revak", email = "pavel.revak@gmail.com" }
14
+ ]
15
+ keywords = ["serial", "tcp", "telnet", "proxy"]
16
+ classifiers = [
17
+ "Development Status :: 5 - Production/Stable",
18
+ "Intended Audience :: Developers",
19
+ "Topic :: Software Development :: Embedded Systems",
20
+ "Programming Language :: Python :: 3",
21
+ ]
22
+ dependencies = [
23
+ "pyserial>=3.0",
24
+ ]
25
+
26
+ [project.urls]
27
+ Homepage = "https://github.com/cortexm/ser2tcp"
28
+
29
+ [project.scripts]
30
+ ser2tcp = "ser2tcp.main:main"
31
+
32
+ [tool.setuptools.packages.find]
33
+ include = ["ser2tcp*"]
34
+
35
+ [tool.setuptools_scm]
36
+ write_to = "ser2tcp/_version.py"
37
+ fallback_version = "0.0.0"
ser2tcp-2.1.0/run.py ADDED
@@ -0,0 +1,7 @@
1
+ """__main__"""
2
+
3
+ import ser2tcp.main
4
+
5
+
6
+ if __name__ == '__main__':
7
+ ser2tcp.main.main()
File without changes
@@ -0,0 +1,34 @@
1
+ # file generated by setuptools-scm
2
+ # don't change, don't track in version control
3
+
4
+ __all__ = [
5
+ "__version__",
6
+ "__version_tuple__",
7
+ "version",
8
+ "version_tuple",
9
+ "__commit_id__",
10
+ "commit_id",
11
+ ]
12
+
13
+ TYPE_CHECKING = False
14
+ if TYPE_CHECKING:
15
+ from typing import Tuple
16
+ from typing import Union
17
+
18
+ VERSION_TUPLE = Tuple[Union[int, str], ...]
19
+ COMMIT_ID = Union[str, None]
20
+ else:
21
+ VERSION_TUPLE = object
22
+ COMMIT_ID = object
23
+
24
+ version: str
25
+ __version__: str
26
+ __version_tuple__: VERSION_TUPLE
27
+ version_tuple: VERSION_TUPLE
28
+ commit_id: COMMIT_ID
29
+ __commit_id__: COMMIT_ID
30
+
31
+ __version__ = version = '2.1.0'
32
+ __version_tuple__ = version_tuple = (2, 1, 0)
33
+
34
+ __commit_id__ = commit_id = 'g92b2f585a'