Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dsw7/inoio
Utilities for RX/TX with Arduino devices
https://github.com/dsw7/inoio
Last synced: 29 days ago
JSON representation
Utilities for RX/TX with Arduino devices
- Host: GitHub
- URL: https://github.com/dsw7/inoio
- Owner: dsw7
- License: mit
- Created: 2023-09-27T06:49:26.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2023-09-29T09:48:04.000Z (about 1 year ago)
- Last Synced: 2023-09-30T08:48:01.688Z (about 1 year ago)
- Language: Python
- Size: 40 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# InoIO
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)A small library for RX/TX with Arduino devices.
## Table of Contents
- [Installation](#installation)
- [Example](#example)## Installation
To install the library, simply run:
```
pip install inoio
```## Example
The following snippet demonstrates how to use the library:
```python
import sys
from inoio import InoIO, errorsdef main() -> None:
conn = InoIO(port="/dev/ttyS2", baudrate=9600)try:
conn.connect()
except errors.InoIOConnectionError:
sys.exit("Failed to connect")conn.write("A foo that bars")
print(conn.read())conn.disconnect()
if __name__ == "__main__":
main()
```
Running this small program would return:
```
Received message: A foo that bars
```
Assuming the following code is uploaded to the device and the device is running:
```C++
void setup()
{
unsigned int baudrate = 9600;
::Serial.begin(baudrate);unsigned int timeout_msec = 10;
::Serial.setTimeout(timeout_msec);
}void loop()
{
while (::Serial.available() > 0)
{
::String message = ::Serial.readString();
message.trim();::Serial.println("Received message: " + message);
::Serial.flush();
}
}
```