Expand description
4-byte big-endian length-prefixed framing.
A frame is a 4-byte big-endian unsigned length followed by exactly that many payload bytes. This is the framing used by three contracts:
- MAVLink socket: payload is one raw MAVLink frame, max 65536, zero-length permitted (the Python server only checks the upper bound).
- plugin RPC socket: payload is a msgpack envelope, max 4 MiB, zero-length
rejected (the Python reader treats
length == 0as a protocol error). - state socket v2: payload is a msgpack state snapshot.
The reject-zero behaviour differs per contract, so decode_len takes it
as an argument rather than baking in one policy.
Enums§
Constants§
- HEADER_
SIZE - Size of the length prefix in bytes.
- MAVLINK_
MAX_ FRAME - Maximum MAVLink frame payload (Contract A:
MAX_FRAME_SIZE). - PLUGIN_
MAX_ FRAME - Maximum plugin RPC envelope payload (Contract C:
MAX_FRAME_BYTES).
Functions§
- decode_
len - Decode the payload length from a 4-byte big-endian header.
- encode_
frame - Encode a payload as a length-prefixed frame: 4-byte big-endian length
followed by the payload. Returns an error if the payload exceeds
maxor cannot be represented in a u32 length.