Skip to main content

scietex.adc_service

scietex.adc_service is a scietex.service worker connected to Valkey that owns one or more SPI ADC devices (MCP3204, MCP3208) through scietex.hal.adc. It opens the configured converters at startup, exposes single-ended and differential reads as adc:* tasks, and publishes a telemetry snapshot of the live devices. A device that fails to open does not stop the worker: it is recorded, reported as unavailable, and the remaining devices keep working. Configuration can also be pushed at runtime through the framework's remote-config channel.

Python ≥ 3.10 · License: MIT

Documentation

Installation

pip install "scietex.adc_service[spi]"      # spidev backend for /dev/spidev*
pip install "scietex.adc_service[gpiozero]" # plain-GPIO backend

The core package pulls in scietex.hal.adc, scietex.service[valkey], and msgspec. The backend extras are optional: a core install can still build a device from a caller-supplied transport, but an operator normally installs the extra that matches the board's wiring.

Quick start

1. Write a configuration file

The service reads adc/adc.yml under its config directory. Create it by hand, or let the service generate a default on first run. The file is the bootstrap layer of a four-layer merge: constructor defaults < adc.yml < the framework's config.yml snapshot < the remote adc section.

2. Run the service

start-adc-service --conf-dir /etc/scietex

The config directory resolves automatically when --conf-dir is omitted. The service runs in the foreground until SIGINT or SIGTERM.

3. Read a channel

Submit an adc:read task to the worker with payload {"device_id": "adc0", "channel": 0}. The result carries the raw 12-bit code and the scaled voltage. Add "samples": 4 to average four conversions of the input into that one result.

Configuration at a glance

Devices are keyed by a string id, which names the device in task payloads and telemetry:

devices:
  adc0:
    type: MCP3208
    port: 0
    device: 0
    v_ref: 3.3
    channels:
      - channel: 0
        poll_interval_ms: 1000
  adc1:
    type: MCP3204
    device: 1
    v_ref: 5.0
    poll: false
poll_enabled: true

Per-device fields: type (required, MCP3204 or MCP3208), port and device for the SPI wiring, clock_pin/mosi_pin/miso_pin/select_pin for the gpiozero backend, v_ref, label, log_level, poll (default true), and channels (per-input polling rows; an empty list means the device is not polled). port is the SPI bus number and device is the chip-select; both are integers. Top-level fields: devices and poll_enabled (default true). Unknown fields are rejected.

Each channels row carries channel, poll_interval_ms (default 1000), enabled (default true), and label. There is no device-level period: a device stays silent until its rows are defined.

Tasks

Task Lane Request Result
adc:list control optional device_id per-device device_id, available, error, v_ref, channels, differential, poll; plus poll_enabled
adc:read data device_id, channel, differential, samples device_id, channel, differential, code, voltage
adc:read_all data device_id device_id, codes, voltages

Differential reads use adc:read with differential: true; channel then names a differential pair instead of a single-ended input. An id that is configured but failed to open is a successful adc:list entry with available: false, not a task error.

Telemetry

The worker publishes to scietex:{service}:{instance_id}:telemetry every 2 s with a 6 s TTL. The snapshot lists every configured device with its open state, v_ref, channel_count, and poll flag, plus the service-wide poll_enabled switch. channel_count is absent for a device that failed to open. Polling is opt-out both per device (poll: false) and globally (poll_enabled: false), and a device stays silent until it has explicit channels rows.

Container and quadlet

podman build --build-arg VERSION=0.1.0 -t scietex-adc-service .
podman run --rm --device /dev/spidev0.0 -v ./config:/config scietex-adc-service

The container only dials Valkey, so it publishes no port and needs no capabilities. /dev/spidevX.Y must be passed with --device; without it the worker still starts and reports the device unavailable.

For a persistent deployment, install deploy/adc-service.container as ~/.config/containers/systemd/adc-service.container and the SPI drop-in as ~/.config/containers/systemd/adc-service.container.d/50-spi-devices.conf, then systemctl --user daemon-reload && systemctl --user start adc-service. The Quadlet bind-mounts ~/.config/scietex, so adc/adc.yml stays hand-editable on the host.

Development

Dependencies are managed with uv; checks and tests run through tox:

uv sync --all-extras
uv run tox                    # format, lint, type, py314
uv run tox -e py314           # tests only

Metadata

Release files for scietex.adc-service 0.2.0

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

Source distribution (sdist)

Source distribution for scietex.adc-service 0.2.0
File Size Uploaded Provenance Actions
scietex_adc_service-0.2.0.tar.gz 44.6 kB With provenance Details for scietex_adc_service-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for scietex.adc-service 0.2.0
File Interpreter ABI Platform Actions
scietex_adc_service-0.2.0-py3-none-any.whl Python 3 none any Details for scietex_adc_service-0.2.0-py3-none-any.whl

Total release size: 77.7 kB

Release files / scietex_adc_service-0.2.0.tar.gz

Download URL scietex_adc_service-0.2.0.tar.gz
Size 44.6 kB
Tags Source
SHA-256 checksum
How to use checksums
03838c2951c506a5c34826aef5e7fb71ffba69777e6e62e3aa4f3f5416e118f5
BLAKE2b-256 checksum
How to use checksums
1d20f639b48d26b4bbdc5509ee59daa20f24d1977f44045efe21eecdd227e61d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.

Transparency log

Release files / scietex_adc_service-0.2.0-py3-none-any.whl

Download URL scietex_adc_service-0.2.0-py3-none-any.whl
Size 33.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7d802e6af32b42ce0e2c212b242bc8b043d65efd62d02be4d69eb63e1d6807ef
BLAKE2b-256 checksum
How to use checksums
36765b20b13f5a9cd464d87f04684efe55a8fbe5025d9c4e11861c7f78c61f0d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.

Transparency log

Security for scietex.adc-service 0.2.0

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for scietex_adc_service-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.

Transparency log

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