Serial library with native async support for Windows and POSIX
Project description
Introduction
Serialx is a no-compromise serial communication library for Python targeting common platforms such as Linux (POSIX), macOS, and Windows. It provides both synchronous and native asynchronous APIs for all platforms.
Installation
pip install serialx
Usage
Serialx features a pyserial and pyserial-asyncio compatibility layer for easy testing.
As early as possible, run serialx.patch_pyserial() and it will provide API-compatible
replacements.
import serialx
serialx.patch_pyserial()
# These will now use serialx
import serial
import serial_asyncio
Serialx features a familiar synchronous API:
import serialx
with serialx.Serial("/dev/serial/by-id/port", baudrate=115200) as serial:
data = serial.readexactly(5)
serial.write(b"test")
serial.set_modem_pins(rts=True, dtr=True)
pins = serial.get_modem_pins()
assert pins.rts is serialx.PinState.HIGH
assert pins.dtr is serialx.PinState.HIGH
A high-level asynchronous serial (reader, writer) pair:
import asyncio
import contextlib
import serialx
async def main():
reader, writer = await serialx.open_serial_connection("/dev/serial/by-id/port", baudrate=115200)
with contextlib.closing(writer):
data = await reader.readexactly(5)
writer.write(b"test")
await writer.drain()
And a low-level asynchronous serial transport:
import asyncio
import serialx
async def main():
loop = asyncio.get_running_loop()
protocol = YourProtocol()
transport, protocol = await serialx.create_serial_connection(
loop,
lambda: protocol,
url="/dev/serial/by-id/port",
baudrate=115200
)
await transport.set_modem_pins(rts=True, dtr=True)
Development
All development dependencies are listed in pyproject.toml. To install them, use:
uv pip install '.[dev]'
On macOS and Windows, a Rust toolchain is required to build the native serial port enumeration extension. Install Rust via rustup.
Set up pre-commit hooks with pre-commit install. Your code will then be type checked
and auto-formatted when you run git commit. You can do this on-demand with
pre-commit run.
Serialx relies on automated testing. CI runs tests using both socat virtual PTYs
(Linux/macOS) and socket-based serial pairs. To also test with physical adapter pairs,
pass CLI flags to pytest:
pytest --adapter-pair=/dev/serial/by-id/left1:/dev/serial/by-id/right1 \
--adapter-pair=/dev/serial/by-id/left2:/dev/serial/by-id/right2
By default, tests run in parallel. You can disable this by passing -n 0 to pytest.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file serialx-1.0.0.tar.gz.
File metadata
- Download URL: serialx-1.0.0.tar.gz
- Upload date:
- Size: 502.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5a062f975a099c1d78f2fc58a9d127718f84844a5c5ccc3e30b7ec6815a3e9f8
|
|
| MD5 |
5387bb75360a73fe5255b643f8767082
|
|
| BLAKE2b-256 |
5fcac5159b5dfb83a0271bf55b763dd9e6a416586e2a2f6798154099e1290058
|
Provenance
The following attestation bundles were made for serialx-1.0.0.tar.gz:
Publisher:
publish-to-pypi.yml on puddly/serialx
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
serialx-1.0.0.tar.gz -
Subject digest:
5a062f975a099c1d78f2fc58a9d127718f84844a5c5ccc3e30b7ec6815a3e9f8 - Sigstore transparency entry: 1118873999
- Sigstore integration time:
-
Permalink:
puddly/serialx@97ffa29c76c1f4ea9bc76e0ef56dd42f89b59d08 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/puddly
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@97ffa29c76c1f4ea9bc76e0ef56dd42f89b59d08 -
Trigger Event:
release
-
Statement type:
File details
Details for the file serialx-1.0.0-py3-none-any.whl.
File metadata
- Download URL: serialx-1.0.0-py3-none-any.whl
- Upload date:
- Size: 49.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dd0977c12f076c9b6ac84e063ebd9e9d46d808fb493c854eb3fae48faeec30b5
|
|
| MD5 |
ebf5127fd221ea0a5d2e058957066ce6
|
|
| BLAKE2b-256 |
9924e35b90aa53e88625808d4ec6ea0873b5295445109dd3e2202b70eafbab0c
|
Provenance
The following attestation bundles were made for serialx-1.0.0-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on puddly/serialx
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
serialx-1.0.0-py3-none-any.whl -
Subject digest:
dd0977c12f076c9b6ac84e063ebd9e9d46d808fb493c854eb3fae48faeec30b5 - Sigstore transparency entry: 1118874017
- Sigstore integration time:
-
Permalink:
puddly/serialx@97ffa29c76c1f4ea9bc76e0ef56dd42f89b59d08 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/puddly
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@97ffa29c76c1f4ea9bc76e0ef56dd42f89b59d08 -
Trigger Event:
release
-
Statement type:
File details
Details for the file serialx-1.0.0-cp310-abi3-win_arm64.whl.
File metadata
- Download URL: serialx-1.0.0-cp310-abi3-win_arm64.whl
- Upload date:
- Size: 50.3 kB
- Tags: CPython 3.10+, Windows ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ae85935b0cc9428fde033fc999836d9d53601882250a8c05fded1d0ebd4ea071
|
|
| MD5 |
b05b64546e2e84a7880be2a06c9fbf1b
|
|
| BLAKE2b-256 |
7fca6d9379238f7d4185a0464c6c83205a696dec2c1bd6c4ffbdcc9820849d0b
|
Provenance
The following attestation bundles were made for serialx-1.0.0-cp310-abi3-win_arm64.whl:
Publisher:
publish-to-pypi.yml on puddly/serialx
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
serialx-1.0.0-cp310-abi3-win_arm64.whl -
Subject digest:
ae85935b0cc9428fde033fc999836d9d53601882250a8c05fded1d0ebd4ea071 - Sigstore transparency entry: 1118874015
- Sigstore integration time:
-
Permalink:
puddly/serialx@97ffa29c76c1f4ea9bc76e0ef56dd42f89b59d08 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/puddly
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@97ffa29c76c1f4ea9bc76e0ef56dd42f89b59d08 -
Trigger Event:
release
-
Statement type:
File details
Details for the file serialx-1.0.0-cp310-abi3-win_amd64.whl.
File metadata
- Download URL: serialx-1.0.0-cp310-abi3-win_amd64.whl
- Upload date:
- Size: 173.3 kB
- Tags: CPython 3.10+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
902db572ed1d428dab8ba3c83400e12dab95427dc2073a9271c89ba9f204e711
|
|
| MD5 |
11b7548b48719b8dad3f6b0b7b3093f8
|
|
| BLAKE2b-256 |
e8ae8d172ee9bd8c8adae8e53bca51a7b98f2c791b3a6c1d1a6ff37e972c6651
|
Provenance
The following attestation bundles were made for serialx-1.0.0-cp310-abi3-win_amd64.whl:
Publisher:
publish-to-pypi.yml on puddly/serialx
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
serialx-1.0.0-cp310-abi3-win_amd64.whl -
Subject digest:
902db572ed1d428dab8ba3c83400e12dab95427dc2073a9271c89ba9f204e711 - Sigstore transparency entry: 1118874006
- Sigstore integration time:
-
Permalink:
puddly/serialx@97ffa29c76c1f4ea9bc76e0ef56dd42f89b59d08 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/puddly
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@97ffa29c76c1f4ea9bc76e0ef56dd42f89b59d08 -
Trigger Event:
release
-
Statement type:
File details
Details for the file serialx-1.0.0-cp310-abi3-win32.whl.
File metadata
- Download URL: serialx-1.0.0-cp310-abi3-win32.whl
- Upload date:
- Size: 167.1 kB
- Tags: CPython 3.10+, Windows x86
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e3fa4cf570c818de55d5d6547c8f71b7b66d0e5ae983b61fc6ce2a6fd0a86a79
|
|
| MD5 |
ed23460d1472aaa453614d9419fddd8c
|
|
| BLAKE2b-256 |
8267355316a90cc39391f12f962b45e65689571cc40d5cc922edfc8853c979ad
|
Provenance
The following attestation bundles were made for serialx-1.0.0-cp310-abi3-win32.whl:
Publisher:
publish-to-pypi.yml on puddly/serialx
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
serialx-1.0.0-cp310-abi3-win32.whl -
Subject digest:
e3fa4cf570c818de55d5d6547c8f71b7b66d0e5ae983b61fc6ce2a6fd0a86a79 - Sigstore transparency entry: 1118874003
- Sigstore integration time:
-
Permalink:
puddly/serialx@97ffa29c76c1f4ea9bc76e0ef56dd42f89b59d08 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/puddly
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@97ffa29c76c1f4ea9bc76e0ef56dd42f89b59d08 -
Trigger Event:
release
-
Statement type:
File details
Details for the file serialx-1.0.0-cp310-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: serialx-1.0.0-cp310-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 268.2 kB
- Tags: CPython 3.10+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
316e2d704ad113520c61609f82c153ae42b85c3137ef5634b7c1b03202de0fda
|
|
| MD5 |
69fddb37149071b80695073d1ff81014
|
|
| BLAKE2b-256 |
4236b4fe6acf44c10a6f6f4300466ea233c36b811a0a6042577941d3ace1416e
|
Provenance
The following attestation bundles were made for serialx-1.0.0-cp310-abi3-macosx_11_0_arm64.whl:
Publisher:
publish-to-pypi.yml on puddly/serialx
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
serialx-1.0.0-cp310-abi3-macosx_11_0_arm64.whl -
Subject digest:
316e2d704ad113520c61609f82c153ae42b85c3137ef5634b7c1b03202de0fda - Sigstore transparency entry: 1118874011
- Sigstore integration time:
-
Permalink:
puddly/serialx@97ffa29c76c1f4ea9bc76e0ef56dd42f89b59d08 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/puddly
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@97ffa29c76c1f4ea9bc76e0ef56dd42f89b59d08 -
Trigger Event:
release
-
Statement type:
File details
Details for the file serialx-1.0.0-cp310-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: serialx-1.0.0-cp310-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 272.4 kB
- Tags: CPython 3.10+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0cfc2dbd2fd444651cd3bfa761d80a9f83df85889a0dcb0f2c3ec3a246339a5a
|
|
| MD5 |
f72bd8bb734257ae510400ea4e97ae6a
|
|
| BLAKE2b-256 |
adfd0400ae2d6aab086048971388bd65d97fc0b24673c7173ea3844f2f5fcd6b
|
Provenance
The following attestation bundles were made for serialx-1.0.0-cp310-abi3-macosx_10_12_x86_64.whl:
Publisher:
publish-to-pypi.yml on puddly/serialx
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
serialx-1.0.0-cp310-abi3-macosx_10_12_x86_64.whl -
Subject digest:
0cfc2dbd2fd444651cd3bfa761d80a9f83df85889a0dcb0f2c3ec3a246339a5a - Sigstore transparency entry: 1118874008
- Sigstore integration time:
-
Permalink:
puddly/serialx@97ffa29c76c1f4ea9bc76e0ef56dd42f89b59d08 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/puddly
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@97ffa29c76c1f4ea9bc76e0ef56dd42f89b59d08 -
Trigger Event:
release
-
Statement type: