CAN 2.0 has a maximum data payload of 8 bytes per frame. ECSS PUS packets can be much larger (housekeeping reports, event logs). Fragmentation splits a large packet across multiple CAN frames and reassembly reconstructs it at the receiver.

This is essentially a simplified transport layer — similar to IP fragmentation or TCP segmentation, but constrained to the 8-byte CAN frame payload.

SpaceCAN fragmentation protocol:

First frame:

  • Byte 0: [4-bit frame_type=0x1][4-bit total_length_high]
  • Byte 1: total_length_low
  • Bytes 2-7: first 6 bytes of payload

Consecutive frames:

  • Byte 0: [4-bit frame_type=0x2][4-bit sequence_number]
  • Bytes 1-7: next 7 bytes of payload

Single frame (payload fits in one CAN frame):

  • Byte 0: [4-bit frame_type=0x0][4-bit payload_length]
  • Bytes 1-7: payload

Reassembly in no_std

The reassembler maintains a fixed-size buffer (heapless::Vec<u8, 256>) and a sequence counter. On first frame, reset state and copy initial payload. On consecutive frames, verify sequence number and append. On completion (received bytes == total_length), signal the application layer.

Timeout handling: If consecutive frames stop arriving, the partially-assembled packet must be discarded. In SpaceCAN's firmware, a RTIC timer task fires after 100ms of inactivity and resets the reassembler state. Without this, a lost frame causes the reassembler to wait forever.