Shared references / Getting Started

Encode and decode a frame

Run the standalone Python codec without connecting hardware.

1. Download the codec#

Download actuator_fd.py. Place it in an empty directory. Python 3.11 or later is required; no third-party Python package is needed.

2. Encode a discovery request#

Save the following as example.py in the same directory:

from actuator_fd import SCHEMAS, decode, encode, encode_identifier

values = {"nonce": 1, "slot_count": 8, "slot_duration_us": 1000}
payload = encode("discover", values)
identifier = encode_identifier(SCHEMAS["discover"], source=0, destination=127)
assert len(payload) == 12
assert decode("discover", payload) == values
assert identifier == 0x184007F1

3. Run the example#

python example.py

Successful assertions produce no output. The example validates the host codec and transmits no CAN frames.

4. Inspect the wire fields#

The discovery payload contains a 32-bit nonce, a 16-bit slot count, and a 32-bit slot duration in microseconds. It occupies ten content bytes and uses the twelve-byte CAN-FD DLC with zero padding.

See the wire reference for offsets and reference downloads for C codecs and test vectors.