Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/zmitchell/async-serial

Example code using asyncio, pyserial, and pyserial-asyncio
https://github.com/zmitchell/async-serial

asyncio pyserial python python3 serial

Last synced: 2 months ago
JSON representation

Example code using asyncio, pyserial, and pyserial-asyncio

Awesome Lists containing this project

README

        

# Async Serial

This is example code showing you how to do asynchronous serial communication such as ASCII-over-serial, as is common in scientific settings. There is an accompanying article here:

* [Bringing async to serial devices][post]

## Usage

This code relies on the experimental [`pyserial-asyncio`][pyserial-asyncio] library, which at this time only supports Unix-based systems (Linux, macOS, etc). As explained in the article, you'll need the tool [`socat`][socat] to create virtual serial ports so that you don't need a real device to try out the code.

### Install the dependencies

Clone this repository:

```bash
git clone https://github.com/zmitchell/async-serial.git
```

The dependencies are managed with [`pipenv`][pipenv], the new officially sanctioned packaging tool for Python. Install the dependencies via:

```bash
pipenv install
```

This will create a virtual environment and install the dependencies listed in the [`Pipfile`](Pipfile) into it.

### Run the code

You run the code in the virtual environment created by `pipenv` via

```bash
pipenv run python3 async_serial_protocol.py
```

To run one of the other programs, simply replace `async_serial_protocol.py` with the name of the program.

## License

Licensed under either of

* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
* MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)

at your option.

### Contribution

Unless you explicitly state otherwise, any contribution intentionally
submitted for inclusion in the work by you, as defined in the Apache-2.0
license, shall be dual licensed as above, without any additional terms or
conditions.

[post]: https://tinkering.xyz/async-serial/
[pyserial-asyncio]: http://pyserial-asyncio.readthedocs.io/en/latest/index.html
[socat]: http://www.dest-unreach.org/socat/
[pipenv]: https://github.com/pypa/pipenv