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_changedsignal) driven by the kernelgpiodedge-event API, polled asynchronously with a short timeout so the event loop is never stalled. - Kernel-side debounce via
debounce_us(passed to libgpiod), andactive_lowinversion 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 frameworkConfigContract. - Exports the framework
HealthContract(always) andConfigContract(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
pip install pympacds-gpio
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.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pympacds_gpio-0.1.0.tar.gz | 16.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pympacds_gpio-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 25.6 kB
Release files / pympacds_gpio-0.1.0.tar.gz
| Download URL | pympacds_gpio-0.1.0.tar.gz |
|---|---|
| Size | 16.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7f99127cab7ebd3edb2d22a424c9ac2e23d12df483205d66d7396821ac546219
|
|
BLAKE2b-256 checksum How to use checksums |
af27aca99f51419b1296f1f587e385b527fc8915d44ab6b899edf196499e4955
|
| 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.0-py3-none-any.whl
| Download URL | pympacds_gpio-0.1.0-py3-none-any.whl |
|---|---|
| Size | 9.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e172c1dd35f53c313c0f48bbe9ac21bf82249ce3397637399f43f7a4876a680b
|
|
BLAKE2b-256 checksum How to use checksums |
3d40a67ca386afc3cd9af394cb2e4433bd7bdb1d68f42f12b9db987fc7fd44bc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.4
|