Skip to main content

grated control unit

Project description

ROX-ICU python driver

This package provides a high-level interface to ROX Integrated Control Unit.

For more information see product page

Cli

The package installs icu command line tool with fuctional commands

  mock     Mock ICU device on CAN bus
  monitor  Monitor ICU devices on CAN bus
  output   Set output state, provide hex value

Quick start

import asyncio
import logging

from rox_icu.core import ICU
from rox_icu.utils import run_main_async

NODE_ID = 1

SENSOR_PIN = 7
RELAY_PIN = 0

log = logging.getLogger("main")


async def handle_input(icu: ICU) -> None:
    log.info("Starting input handler")

    sensor = icu.pins[SENSOR_PIN]
    relay = icu.pins[RELAY_PIN]
    relay.state = False

    while True:
        log.info("Waiting for high state")
        await sensor.high_event.wait()
        log.info(f"Sensor state: {sensor.state}")

        # toggle relay
        relay.state = True
        await asyncio.sleep(0.1)
        relay.state = False


async def main() -> None:

    icu = ICU(NODE_ID)
    await icu.start()

    try:
        await handle_input(icu)
    finally:
        await icu.stop()
        print("Done")


if __name__ == "__main__":
    run_main_async(main())

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

rox_icu-0.5.1.tar.gz (783.5 kB view details)

Uploaded Source

Built Distribution

rox_icu-0.5.1-py3-none-any.whl (16.1 kB view details)

Uploaded Python 3

File details

Details for the file rox_icu-0.5.1.tar.gz.

File metadata

  • Download URL: rox_icu-0.5.1.tar.gz
  • Upload date:
  • Size: 783.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.9

File hashes

Hashes for rox_icu-0.5.1.tar.gz
Algorithm Hash digest
SHA256 4074d10635daafacf460eddcf44adcde8c47357b4850e5b219065a479782745c
MD5 9e2406d4809876701d66c1d99fba019d
BLAKE2b-256 56cbbc2801507f16d71b42d893d10f495b02ecfc2f680d3bc1d1ad88e7ec2856

See more details on using hashes here.

File details

Details for the file rox_icu-0.5.1-py3-none-any.whl.

File metadata

  • Download URL: rox_icu-0.5.1-py3-none-any.whl
  • Upload date:
  • Size: 16.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.9

File hashes

Hashes for rox_icu-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bb8c3019f86115b2311a0945b9095950a1574190ecd48f33b5e2e4feffb4a224
MD5 5702f3873d489b9c662553820deb49aa
BLAKE2b-256 dbe56f78a1fe606325e3f1cdac05a0d6e9f9dad8c26703912398c595ab939362

See more details on using hashes here.

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