Skip to main content

pympacds-gpio

GPIO server service for pympacds. Monitors GPIO line state and edge events and exposes reads, writes, and change notifications over D-Bus.

Features

  • Reads (get_value, get_lines) and writes (set_value) of GPIO lines over D-Bus, with per-output-line default (reset) values (get_default_value / set_default_value).
  • Edge-event watching (line_changed signal) driven by the kernel gpiod edge-event API, polled asynchronously with a short timeout so the event loop is never stalled.
  • Kernel-side debounce via debounce_us (passed to libgpiod), and active_low inversion for watched lines. No software debounce.
  • A configurable line-name mapping ([gpio.linemap]) so lines can be referenced by human-readable name or numeric offset on the D-Bus API.
  • Runtime configuration: [gpio] keys are writable via the framework ConfigContract.
  • Exports the framework HealthContract (always) and ConfigContract (opt-in via [dbus] contract_config = true) alongside the GPIO contract.

Why gpiod

The service uses the gpiod Python bindings (libgpiod v2 API) because it is the reference userspace interface to the kernel GPIO character-device subsystem: line requests, edge events, and debounce are all handled in the kernel. It is isolated in this service's own package, so the core pympacds framework keeps its zero-dependency property.

Installation

Using PIP

pip install pympacds-gpio

Using pip installs the Python package only — the D-Bus policy, systemd unit, and udev rule are not installed. You can still run the service directly with pympacds-gpio -c /etc/pympacds/gpio.ini, or register and enable it system-wide with the admin script. Since there is no packaged unit, pass the pip-installed executable via --program so the unit is generated:

sudo pympacds-admin setup                      # one-time: user, log dir, D-Bus policy
sudo pympacds-admin install gpio \
    --program "$(command -v pympacds-gpio)" \
    --config /etc/pympacds/gpio.ini --start

Under pip you must also grant access to /dev/gpiochip* yourself (see Device access below); the udev rule ships only with the Debian package.

Alternatively, install the Debian package (see below), which already ships the unit, policy, and udev rule.

Using PPA

Debian packages are provided through launchpad ppa (dargor0/mpacds):

sudo add-apt-repository ppa:dargor0/mpacds
sudo apt update
sudo apt install python3-pympacds-gpio

The package installs the service system-wide (executable, systemd unit, D-Bus policy, udev rule, and the gpio.ini.example config) and depends on python3-pympacds.

Repository has been tested on Ubuntu (plucky, resolute, stonking) and Debian (stable, testing, unstable).

Configuration

The service reads its parameters from the [gpio] INI section and the optional [gpio.linemap] section (see config/gpio.ini.example):

Key Default Description
chip "" GPIO chip path (empty = auto-detect)
lines "" Comma-separated line names/offsets to expose and read
watch_lines "" Lines watched for edge events
edge both Edge to watch: rising, falling, both
debounce_us 0 Kernel debounce period (µs) for watched lines
active_low false Invert line logic for watched lines
output_lines "" Lines driven as outputs
default_values "" line=value pairs for output defaults (e.g. relay1=0,5=1)

The [gpio.linemap] section maps human-readable names to offsets (btn = 0). Names must not begin with a digit.

Run with:

pympacds-gpio -c /etc/pympacds/gpio.ini

Device access (permissions)

The service does not require root. Access to /dev/gpiochip* is granted via a udev rule (shipped by the Debian package) that assigns the device to the gpio group with mode 0660; add the service user to the gpio group:

sudo usermod -aG gpio <service-user>

D-Bus API

Interface org.pympacds.GPIO at object path /org/pympacds/gpio:

Member Type Description
get_value(line) get_value(s) -> b Read a line's value
set_value(line, value) set_value(sb) -> b Set an output line
get_default_value(line) get_default_value(s) -> b Default (reset) value of an output
set_default_value(line, value) set_default_value(sb) -> b Set the default value
get_lines() get_lines() -> s JSON values of all exposed lines
status() status() -> s JSON chip/line configuration + values
line_changed(name, offset, value) signal (sub) Emitted on a watched edge event
watched_lines property (as) List of watched lines

A line argument is a decimal offset or a [gpio.linemap] name, resolved number-first-then-name. An unresolvable line produces a D-Bus error reply.

The framework HealthContract (at .../health) and ConfigContract ([dbus] contract_config = true) are also exported.

Metadata

Release files for pympacds-gpio 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pympacds-gpio 0.1.3
File Size Uploaded Provenance Actions
pympacds_gpio-0.1.3.tar.gz 18.5 kB Without provenance Details for pympacds_gpio-0.1.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pympacds-gpio 0.1.3
File Interpreter ABI Platform Actions
pympacds_gpio-0.1.3-py3-none-any.whl Python 3 none any Details for pympacds_gpio-0.1.3-py3-none-any.whl

Total release size: 28.6 kB

Release files / pympacds_gpio-0.1.3.tar.gz

Download URL pympacds_gpio-0.1.3.tar.gz
Size 18.5 kB
Tags Source
SHA-256 checksum
How to use checksums
086f735fb7f7c8a59a3ce17acab8d04f5f9d5624034f6d7f0e032018bb590685
BLAKE2b-256 checksum
How to use checksums
188709e6c9de0b370168ed89b8644c168892f9de01b50a7ad6cfd1561ca56c56
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Release files / pympacds_gpio-0.1.3-py3-none-any.whl

Download URL pympacds_gpio-0.1.3-py3-none-any.whl
Size 10.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bd124826ab3c2a031b39ff58fce871aa3f3b3709ed97cfc432f50b5950551b81
BLAKE2b-256 checksum
How to use checksums
ee84f1a148845dd4a0abac78d118f669489b20c568d03e7260f0f930b15e0468
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Security for pympacds-gpio 0.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page