A hypermodern, type-safe, zero-dependency python library for serial port I/O access
Project description
samps
A hypermodern, type-safe, zero-dependency Python library for serial port I/O access.
Installation
pip install samps
or
using your preferred environment / package manager of choice, e.g., poetry, conda or uv:
poetry add samps
conda install samps
uv add samps
Usage
The general usage of this library is to create a serial connection to the device you want to communicate with.
You'll need to know the serial port name and the baudrate of the device you want to communicate with, this is usually found in the device's documentation.
Once you have the serial port name and baudrate, you can create a SerialCommonInterface (or SerialAsyncCommonInterface) object and use it to communicate with the device as follows:
from samps import SerialCommonInterface as Serial
serial = Serial(port="/dev/tty.usbserial-0001", baudrate=9600)
serial.open()
print(["Serial Port Is Open?", "Yes" if serial.is_open() else "No"])
line = serial.readline()
print(line.decode("utf-8").strip())
serial.close()
print(["Serial Port Closed"])
or, using a context manager:
from samps import SerialCommonInterface as Serial
with Serial(port="/dev/tty.usbserial-0001", baudrate=9600) as serial:
print(["Serial Port Is Open?", "Yes" if serial.is_open() else "No"])
line = serial.readline()
print(line.decode("utf-8").strip())
print(["Serial Port Closed"])
The library also provides an asynchronous interface for serial communication, which can be used in an asyncio event loop.
Here's an example of how to use the asynchronous interface:
from samps import SerialAsyncCommonInterface as Serial
async with Serial(port="/dev/tty.usbserial-0001", baudrate=9600) as serial:
print(["Serial Port Is Open?", "Yes" if serial.is_open() else "No"])
line = await serial.readline()
print(line.decode("utf-8").strip())
print(["Serial Port Closed"])
Milestones
- Implement SerialCommonInterface for POSIX systems
- Implement SerialAsyncCommonInterface for POSIX systems
- Implement SerialCommonInterface for Windows systems
- Implement SerialAsyncCommonInterface for Windows systems
- Implement SerialCommonInterface for MacOS systems
- Implement SerialAsyncCommonInterface for MacOS systems
- Implement SerialOverTCP (e.g., telnet RFC 2217)
- Documentation
Contributing
Contributions are welcome! Please read the CONTRIBUTING.md file for details on how to contribute to this project.
License
This project is licensed under the terms of the MIT license.
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 samps-0.11.0.tar.gz.
File metadata
- Download URL: samps-0.11.0.tar.gz
- Upload date:
- Size: 51.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 |
c8199bf7c61c36acf666157429d428ebdf353d2e63ce6ff9dfeb56e230e27de9
|
|
| MD5 |
baf80e733d9bb4dc277b3c3dabd12ae6
|
|
| BLAKE2b-256 |
ce9b5fb111b5d9f2a7509aee02d5dd67bdd81fb7478f213247cc8faff23839a5
|
Provenance
The following attestation bundles were made for samps-0.11.0.tar.gz:
Publisher:
publish.yml on michealroberts/samps
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
samps-0.11.0.tar.gz -
Subject digest:
c8199bf7c61c36acf666157429d428ebdf353d2e63ce6ff9dfeb56e230e27de9 - Sigstore transparency entry: 736815296
- Sigstore integration time:
-
Permalink:
michealroberts/samps@ff49b3adfcbe2576afcd1e171351123691be42ef -
Branch / Tag:
refs/tags/v0.11.0 - Owner: https://github.com/michealroberts
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@ff49b3adfcbe2576afcd1e171351123691be42ef -
Trigger Event:
release
-
Statement type:
File details
Details for the file samps-0.11.0-py3-none-any.whl.
File metadata
- Download URL: samps-0.11.0-py3-none-any.whl
- Upload date:
- Size: 24.7 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 |
7968f6e3602a601a11e834cdd30a9c4aa7dcba5043e0159c40eea0e218c1ef0b
|
|
| MD5 |
c248b62b7858008a223a4683ee3a7e2a
|
|
| BLAKE2b-256 |
57036a686623bc2e24c06124d9174a3bdfba079aee13cb70a78ff1838ba21217
|
Provenance
The following attestation bundles were made for samps-0.11.0-py3-none-any.whl:
Publisher:
publish.yml on michealroberts/samps
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
samps-0.11.0-py3-none-any.whl -
Subject digest:
7968f6e3602a601a11e834cdd30a9c4aa7dcba5043e0159c40eea0e218c1ef0b - Sigstore transparency entry: 736815300
- Sigstore integration time:
-
Permalink:
michealroberts/samps@ff49b3adfcbe2576afcd1e171351123691be42ef -
Branch / Tag:
refs/tags/v0.11.0 - Owner: https://github.com/michealroberts
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@ff49b3adfcbe2576afcd1e171351123691be42ef -
Trigger Event:
release
-
Statement type: