Metadata-Version: 2.4
Name: samps
Version: 0.5.0
Summary: A hypermodern, type-safe, zero-dependency python library for serial port I/O access
Author-email: michealroberts <michael@observerly.com>
License: MIT License
        
        Copyright (c) 2025 Michael J. Roberts
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: baudrate,io,rs-232,rs-485,serial,tty,uart,usb
Classifier: Development Status :: 4 - Beta
Classifier: Framework :: AsyncIO
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: System Administrators
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: MacOS :: MacOS X
Classifier: Operating System :: POSIX :: Linux
Classifier: Operating System :: Unix
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Terminals :: Serial
Classifier: Typing :: Typed
Requires-Python: >=3.10
Description-Content-Type: text/markdown

# samps

A hypermodern, type-safe, zero-dependency Python library for serial port I/O access.

## Installation

```bash
pip install samps
```

or

using your preferred environment / package manager of choice, e.g., `poetry`, `conda` or `uv`:

```bash
poetry add samps
```

```bash
conda install samps
```

```bash
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:

```python
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:

```python
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:

```python
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

- [x] Implement SerialCommonInterface for POSIX systems
- [x] Implement SerialAsyncCommonInterface for POSIX systems
- [ ] Implement SerialCommonInterface for Windows systems
- [ ] Implement SerialAsyncCommonInterface for Windows systems
- [x] Implement SerialCommonInterface for MacOS systems
- [x] Implement SerialAsyncCommonInterface for MacOS systems
- [ ] Implement SerialOverTCP (e.g., telnet RFC 2217)
- [ ] Documentation

## Contributing

Contributions are welcome! Please read the [CONTRIBUTING.md](CONTRIBUTING.md) file for details on how to contribute to this project.

### License

This project is licensed under the terms of the MIT license.


