Skip to main content

Utilities for RX/TX with Arduino devices

Project description

InoIO

Code style: black

A small library for RX/TX with Arduino devices.

Table of Contents

Installation

To install the library, simply run:

pip install inoio

Example

The following snippet demonstrates how to use the library:

import sys
from inoio import InoIO, errors


def 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:

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();
    }
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

inoio-0.3.0.tar.gz (5.3 kB view hashes)

Uploaded Source

Built Distribution

inoio-0.3.0-py3-none-any.whl (4.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page