-
Notifications
You must be signed in to change notification settings - Fork 1
Usage Python
Rylan Meilutis edited this page Jan 25, 2026
·
20 revisions
Python bindings are built with pyo3 and maturin. The Python module name is sedsprintf_rs.
Option 1: use build.py (recommended in this repo)
./build.py python
Option 2: maturin
maturin develop
If you want a wheel:
./build.py maturin-build
import sedsprintf_rs as seds
DT = seds.DataType
EP = seds.DataEndpoint
RM = seds.RouterMode
def now_ms():
return 0
def tx(bytes_buf, link_id=None):
# send bytes to transport
pass
def on_packet(pkt, link_id=None):
print(pkt)
handlers = [
(int(EP.SD_CARD), on_packet, None),
]
router = seds.Router(tx=tx, now_ms=now_ms, handlers=handlers, mode=RM.Sink)
router.log_f32(ty=DT.GPS_DATA, values=[1.0, 2.0, 3.0])
router.process_all_queues()
See python-example/main.py for a more complete multi-process example.
The Python API exposes typed log helpers that mirror the Rust API:
-
log_f32,log_i16,log_u32, etc. -
log_stringfor UTF-8 payloads. -
log_binaryfor raw bytes.
If you already have a packet or bytes, use:
tx_serialized(bytes)rx_serialized(bytes)
Handlers are registered as tuples:
(endpoint_id, handler_fn, user)
handler_fn receives (packet, link_id).
If you do not care about the link, ignore link_id.
The router can queue RX/TX operations. If you use the queue variants, call:
process_rx_queue()process_tx_queue()process_all_queues()
If you receive data from multiple links, use the *_from variants to tag ingress. The router will pass the link_id to your handlers and TX callback so you can avoid echoing.
-
print(pkt)uses the packet's string formatter. - If a log call fails, check the schema for payload size/type mismatches.
- Ensure your Python environment matches the one used by
maturin develop.