Skip to main content

Module frame

Module frame 

Source
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 == 0 as 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§

FrameError

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 max or cannot be represented in a u32 length.