samps


Namesamps JSON
Version 0.4.0 PyPI version JSON
download
home_pageNone
SummaryA hypermodern, type-safe, zero-dependency python library for serial port I/O access
upload_time2025-10-28 16:44:31
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseMIT 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.
keywords baudrate io rs-232 rs-485 serial tty uart usb
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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.



            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "samps",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "baudrate, io, rs-232, rs-485, serial, tty, uart, usb",
    "author": null,
    "author_email": "michealroberts <michael@observerly.com>",
    "download_url": "https://files.pythonhosted.org/packages/39/3b/48865ce6466e213e3cfc67997b8c0af72b2e29729f3e1e01a34ec21309aa/samps-0.4.0.tar.gz",
    "platform": null,
    "description": "# samps\n\nA hypermodern, type-safe, zero-dependency Python library for serial port I/O access.\n\n## Installation\n\n```bash\npip install samps\n```\n\nor\n\nusing your preferred environment / package manager of choice, e.g., `poetry`, `conda` or `uv`:\n\n```bash\npoetry add samps\n```\n\n```bash\nconda install samps\n```\n\n```bash\nuv add samps\n```\n\n## Usage\n\nThe general usage of this library is to create a serial connection to the device you want to communicate with.\n\nYou'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.\n\nOnce 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:\n\n```python\nfrom samps import SerialCommonInterface as Serial\n\nserial = Serial(port=\"/dev/tty.usbserial-0001\", baudrate=9600)\n\nserial.open()\n\nprint([\"Serial Port Is Open?\", \"Yes\" if serial.is_open() else \"No\"])\n\nline = serial.readline()\n\nprint(line.decode(\"utf-8\").strip())\n\nserial.close()\n\nprint([\"Serial Port Closed\"])\n```\n\nor, using a context manager:\n\n```python\nfrom samps import SerialCommonInterface as Serial\n\nwith Serial(port=\"/dev/tty.usbserial-0001\", baudrate=9600) as serial:\n    print([\"Serial Port Is Open?\", \"Yes\" if serial.is_open() else \"No\"])\n\n    line = serial.readline()\n\n    print(line.decode(\"utf-8\").strip())\n\nprint([\"Serial Port Closed\"])\n```\n\nThe library also provides an asynchronous interface for serial communication, which can be used in an `asyncio` event loop. \n\nHere's an example of how to use the asynchronous interface:\n\n```python\nfrom samps import SerialAsyncCommonInterface as Serial\n\nasync with Serial(port=\"/dev/tty.usbserial-0001\", baudrate=9600) as serial:\n    print([\"Serial Port Is Open?\", \"Yes\" if serial.is_open() else \"No\"])\n\n    line = await serial.readline()\n\n    print(line.decode(\"utf-8\").strip())\n\nprint([\"Serial Port Closed\"])\n```\n\n## Milestones\n\n- [x] Implement SerialCommonInterface for POSIX systems\n- [x] Implement SerialAsyncCommonInterface for POSIX systems\n- [ ] Implement SerialCommonInterface for Windows systems\n- [ ] Implement SerialAsyncCommonInterface for Windows systems\n- [x] Implement SerialCommonInterface for MacOS systems\n- [x] Implement SerialAsyncCommonInterface for MacOS systems\n- [ ] Implement SerialOverTCP (e.g., telnet RFC 2217)\n- [ ] Documentation\n\n## Contributing\n\nContributions are welcome! Please read the [CONTRIBUTING.md](CONTRIBUTING.md) file for details on how to contribute to this project.\n\n### License\n\nThis project is licensed under the terms of the MIT license.\n\n\n",
    "bugtrack_url": null,
    "license": "MIT License\n        \n        Copyright (c) 2025 Michael J. Roberts\n        \n        Permission is hereby granted, free of charge, to any person obtaining a copy\n        of this software and associated documentation files (the \"Software\"), to deal\n        in the Software without restriction, including without limitation the rights\n        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n        copies of the Software, and to permit persons to whom the Software is\n        furnished to do so, subject to the following conditions:\n        \n        The above copyright notice and this permission notice shall be included in all\n        copies or substantial portions of the Software.\n        \n        THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n        SOFTWARE.",
    "summary": "A hypermodern, type-safe, zero-dependency python library for serial port I/O access",
    "version": "0.4.0",
    "project_urls": null,
    "split_keywords": [
        "baudrate",
        " io",
        " rs-232",
        " rs-485",
        " serial",
        " tty",
        " uart",
        " usb"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "539a347a2e74ce7d57b45568bb3c170e189bce65279b6f7f791ab7ca1a7f7c9b",
                "md5": "c7593097163bf0e8d41ab5101a344fac",
                "sha256": "f67fbbd40362eab7893c24e1c416eb3642f0d48dad1d07fcb42c1cba954b822c"
            },
            "downloads": -1,
            "filename": "samps-0.4.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c7593097163bf0e8d41ab5101a344fac",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 18246,
            "upload_time": "2025-10-28T16:44:29",
            "upload_time_iso_8601": "2025-10-28T16:44:29.697573Z",
            "url": "https://files.pythonhosted.org/packages/53/9a/347a2e74ce7d57b45568bb3c170e189bce65279b6f7f791ab7ca1a7f7c9b/samps-0.4.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "393b48865ce6466e213e3cfc67997b8c0af72b2e29729f3e1e01a34ec21309aa",
                "md5": "bbe1c8a3e8e16734878a94981db2b540",
                "sha256": "9f7e4e63abadf1afb4ab09ee66f87e33e63bd94c5244ab1ee3d0a6eaf849aa2b"
            },
            "downloads": -1,
            "filename": "samps-0.4.0.tar.gz",
            "has_sig": false,
            "md5_digest": "bbe1c8a3e8e16734878a94981db2b540",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 46940,
            "upload_time": "2025-10-28T16:44:31",
            "upload_time_iso_8601": "2025-10-28T16:44:31.096738Z",
            "url": "https://files.pythonhosted.org/packages/39/3b/48865ce6466e213e3cfc67997b8c0af72b2e29729f3e1e01a34ec21309aa/samps-0.4.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-10-28 16:44:31",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "samps"
}
        
Elapsed time: 2.29854s