Skip to main content

A daemon to monitor and protect I2C device registers.

Project description

iic-guard: I2C Register Watchdog

PyPI version License: MIT

A lightweight daemon to continuously monitor and protect I2C device registers on embedded Linux systems.

iic-guard solves the problem of critical I2C device registers being unexpectedly reset or changed by other processes. It runs as a background service, checks registers at a configurable interval, and can forcibly write correct values back if a mismatch is detected, ensuring your hardware remains in a known-good state.

Features

  • Value Enforcement: Automatically rewrites correct values to registers if they change.
  • Change Logging: Monitors and logs value changes for debugging without enforcing them.
  • Daemonization: Runs as a proper background service with PID file management and logging.
  • Flexible Configuration: Uses a simple, human-readable YAML file.
  • Robust and Efficient: Built with a C core for minimal overhead on embedded systems.

Installation

The project is packaged and available on PyPI.

# It is recommended to install in a virtual environment
python -m venv .venv
source .venv/bin/activate

# Install from PyPI
pip install iic-guard

For local installation during development, see the Development section below.

Usage

1. Generate a Configuration File

First, generate a template configuration file. The comments inside explain what each field does.

iic-guard --generate-config > config.yaml

2. Edit the Configuration

Modify config.yaml to match your hardware. Set the I2C bus, device address, and the registers you want to monitor or enforce.

3. Run the Daemon

Foreground Mode (for Testing)

Run in the foreground to see logs printed directly to your terminal:

iic-guard -c config.yaml
Background Daemon Mode (for Production)

Use the --daemon flag to run as a background service. This is the recommended way to run on a production device.

# Run as a background daemon
sudo iic-guard -c /etc/iic-guard/config.yaml \\
               --daemon \\
               --pidfile /var/run/iic-guard.pid \\
               --logfile /var/log/iic-guard.log

Note: Using paths in /var/run and /var/log may require sudo permissions.

Development and Contributing

Contributions are welcome! Please feel free to open an issue or pull request.

To install in editable mode for development:

# Clone the repository
# git clone https://github.com/YOUR_USERNAME/iic-guard.git
# cd iic-guard

# Create venv and install in editable mode
python -m venv .venv
source .venv/bin/activate
pip install -e ./iic_guard

After making changes to the C source (.c or .h files), you must run pip install -e ./iic_guard again to recompile the C extension.

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

iic_guard-0.1.0.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

iic_guard-0.1.0-cp312-cp312-manylinux1_x86_64.manylinux_2_5_x86_64.whl (13.8 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.5+ x86-64

File details

Details for the file iic_guard-0.1.0.tar.gz.

File metadata

  • Download URL: iic_guard-0.1.0.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.2

File hashes

Hashes for iic_guard-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a8e6ad27a0e13fffe3ea4585724a8a22be6ea1ee5782ac300973ce5a788543f6
MD5 bfb496a202c8fe141739968d7d4b35d0
BLAKE2b-256 a88a4f183b473cfb27bb09722824ed0b32b4b8dd2216f0eca1cefc81eb3826f5

See more details on using hashes here.

File details

Details for the file iic_guard-0.1.0-cp312-cp312-manylinux1_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for iic_guard-0.1.0-cp312-cp312-manylinux1_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 b916883b05de135df7dcab3a0ceec96c0c0cbe0e0c32a38899dc3358f7f87a3e
MD5 266bbd21d2bcf63188ebecf8feaaaae1
BLAKE2b-256 f51760c7837e6991b6d63220923dffc3820ea5c5dd7eebf4021160d0c00296ed

See more details on using hashes here.

Supported by

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