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:
This code relies on the experimental 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
to create virtual serial ports so that you don't need a real device to try out the code.
Clone this repository:
git clone https://github.com/zmitchell/async-serial.git
The dependencies are managed with pipenv
, the new officially sanctioned packaging tool for Python. Install the dependencies via:
pipenv install
This will create a virtual environment and install the dependencies listed in the Pipfile
into it.
You run the code in the virtual environment created by pipenv
via
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.
Licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
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.