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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: rox_icu-0.5.0.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.0.tar.gz
Algorithm Hash digest
SHA256 197822611be0ca1393948bd3a172982898255e0a6274371807b52fafaa4f1467
MD5 4bc441f7cfb20589d5ee82318870108d
BLAKE2b-256 c1ec944bb9f56ced83adad21aa7259342689530e34f8c7ee2b3ad10ade592645

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rox_icu-0.5.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 94fb26cc761d3ad64cd0380711e7f0599f097f74edb62b32bd7d40e703c0aaf3
MD5 2c4a7dafacb4784696da76dec3ba6dc7
BLAKE2b-256 e739d13f8501599e9c5f392a3ccc1c485433d484e6cc85a25752834a52bb6811

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