Skip to main content

Fast Cyphal/CAN transfer reassembly (Python wrapper over libcanard binary)

Project description

cyphal-reassemble

Standalone reassembler of Cyphal/CAN v1.0 transfers, built on libcanard. Reads an Arrow IPC stream of pre-filtered Cyphal frames from stdin and writes an Arrow IPC stream of reassembled transfers to stdout.

Designed as a fast, compiled replacement for the pycyphal-based reassembly step of the frame-decoding pipeline. It is deliberately channel/logger/session agnostic: all such semantics stay in the calling pipeline.

Build

sudo dnf install -y libarrow-devel cmake gcc-c++ git make   # Fedora
git clone --recurse-submodules <repo-url>
cd cyphal-reassemble
make

make configures and builds into build/ (Release by default). Other targets:

make clean                 # remove build/
make help                  # list targets and variables
make BUILD_TYPE=Debug      # debug build

Usage

build/cyphal-reassemble < frames.arrows > transfers.arrows
build/cyphal-reassemble --help

Input schema (Arrow IPC stream)

Column Type Required
timestamp timestamp[us, UTC] yes
id uint32 (29-bit CAN ID) yes
data binary (incl. tail) yes
rti uint8 no (default 0)

Extra columns are ignored. One invocation handles one reassembly domain (typically one CAN channel).

Output schema (Arrow IPC stream)

Column Type Required
timestamp timestamp[us, UTC] yes
type utf8 (Message|Request|Response) yes
id int16 (subject-id or service-id) yes
source uint8 (null if anonymous) no
dest uint8 (null for messages) no
priority uint8 no
transfer_id uint8 no
payload binary (raw reassembled bytes) no
length int32 (payload byte count) no

Matches sc_schema.TransferSchema minus channel, which the pipeline re-attaches.

Diagnostics and a summary line (frames_in / transfers_out / errors / oom) go to stderr. Exit code is non-zero only on fatal I/O or schema errors.

Test

make test

Other test targets:

make test-unit             # unit tests only
make test-golden           # golden parity tests (tests/data/)

Golden fixtures under tests/data/ are vendored from the frame-decoding pipeline.

License

MIT

Python package

Requires uv. Build the C++ binary first (see Build above), then:

uv sync

Usage:

import pyarrow.ipc as ipc
from cyphal_reassemble import reassemble

with open("tests/data/frames_CAN1.arrows", "rb") as f:
    frames = ipc.open_stream(f).read_all()

transfers = reassemble(frames)

Environment:

  • CYPHAL_REASSEMBLE_BIN — override path to the executable (optional)

Install from PyPI (Linux x86_64)

pip install cyphal-reassemble
# or: uv add cyphal-reassemble

Requires Linux x86_64 with glibc ≥ manylinux_2_28. The wheel bundles the cyphal-reassemble binary and libarrow; no local C++ build needed.

Other platforms: clone this repo, run make, then uv sync (editable install).

Run Python tests:

uv run pytest python_tests/ -v

Lint:

uv run ruff check .

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

cyphal_reassemble-0.1.0-py3-none-manylinux_2_28_x86_64.whl (15.3 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ x86-64

File details

Details for the file cyphal_reassemble-0.1.0-py3-none-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for cyphal_reassemble-0.1.0-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 78105af5a89a2e4b03e540ae5ba3e8b30c636a788d7a144b339e23bf295f499a
MD5 6b4a71f1c678259e653942c1000ed57c
BLAKE2b-256 078dabdec4ee57b8e62cc16aa88ff08a2d098ffa42b14fe4b43462a8a70431da

See more details on using hashes here.

Provenance

The following attestation bundles were made for cyphal_reassemble-0.1.0-py3-none-manylinux_2_28_x86_64.whl:

Publisher: wheels.yml on Finwood/cyphal-reassemble

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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