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-1.0.0.tar.gz (785.6 kB view details)

Uploaded Source

Built Distribution

rox_icu-1.0.0-py3-none-any.whl (17.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for rox_icu-1.0.0.tar.gz
Algorithm Hash digest
SHA256 bb2a89e36a1417319b096a591621a903ec7afa0400adc62c677a6f3eed580a2f
MD5 9ad8067660b06fbe75d76e9edf9daeaa
BLAKE2b-256 e223c54bad85f5a7472de87acb71d6b1cd7bd36d14d595cf1b3e87f1c46e0a3d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rox_icu-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 17.6 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-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4da3156c9b4090c7a2536f6c17b55520ad308181af6b8c1a1f8d4899018986fb
MD5 467a0dfcc27d68896ea351f1699dd605
BLAKE2b-256 e1695710bf5b7c5b85bcd051296f12fb06499985582258b121bdb6c7a7b69510

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