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_bits(rts=True, dtr=True)
bits = serial.get_modem_bits()
assert bits.rts is True
assert bits.dtr is True
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_bits(rts=True, dtr=True)
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 Distribution
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-0.1.1.tar.gz.
File metadata
- Download URL: serialx-0.1.1.tar.gz
- Upload date:
- Size: 25.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c546e30ede058518168ea2d4c1e0e1885417e02e2c3d26f2688049355f79b8c2
|
|
| MD5 |
08158e2480f50d7e1a78ad0ccba7f52e
|
|
| BLAKE2b-256 |
6f21e12efe359d755a82e860a01c8f80488ac3e8853e2f43cb092724c93a3628
|
Provenance
The following attestation bundles were made for serialx-0.1.1.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-0.1.1.tar.gz -
Subject digest:
c546e30ede058518168ea2d4c1e0e1885417e02e2c3d26f2688049355f79b8c2 - Sigstore transparency entry: 723454300
- Sigstore integration time:
-
Permalink:
puddly/serialx@66da809c24ad37164e59317aa3861bc73d910ccb -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/puddly
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@66da809c24ad37164e59317aa3861bc73d910ccb -
Trigger Event:
release
-
Statement type:
File details
Details for the file serialx-0.1.1-py3-none-any.whl.
File metadata
- Download URL: serialx-0.1.1-py3-none-any.whl
- Upload date:
- Size: 17.1 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 |
a81c72af93751488114a2e10966a9d702cb418b22213c344592ec306c96ac7be
|
|
| MD5 |
f08ea00f5d7879dc1bff66e5b13b9d50
|
|
| BLAKE2b-256 |
c1e7eb0b9c6cb359eb637d29755f47ea0c4528f2e4ad901f2896b2d3a026d042
|
Provenance
The following attestation bundles were made for serialx-0.1.1-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-0.1.1-py3-none-any.whl -
Subject digest:
a81c72af93751488114a2e10966a9d702cb418b22213c344592ec306c96ac7be - Sigstore transparency entry: 723454304
- Sigstore integration time:
-
Permalink:
puddly/serialx@66da809c24ad37164e59317aa3861bc73d910ccb -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/puddly
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@66da809c24ad37164e59317aa3861bc73d910ccb -
Trigger Event:
release
-
Statement type: