class ccsdspy.VariableLength(fields)[source]

Bases: _BasePacket

Define a variable length packet to decode binary data.

Variable length packets are packets which have a different length each time. Variable length fields are defined as PacketArray fields where array_shape="expand" (causing the field to grow to fill the packet) or array_shape="other_field" (causes the field named other_field to set the number of elements in this array).

Please note that while this class is able to parse fixed length packets, it is much slower. Use the FixedLength class instead.

Rules for variable length packets:
  • Do only specify a PacketArray with the array_shape="other_field" when other_field precedes it in the packet definition

  • Do not provide more than one expanding PacketArray with array_shape="expand"

  • Do not specify the primary header fields manually

  • Do not specify explicit bit_offsets (they will be computed automatically)

fieldslist of PacketField or PacketArray

Layout of packet fields contained in the definition. No more than one field should have array_shape=”expand”. The field must have no bit_offset’s. Do not include the primary header fields.


one or more of the arguments are invalid, or do not follow the specified rules.

Methods Summary

load(file[, include_primary_header])

Decode a file-like object containing a sequence of these packets.

Methods Documentation

load(file, include_primary_header=False)[source]

Decode a file-like object containing a sequence of these packets.


Path to file on the local file system, or file-like object


If True, provides the primary header in the output

field_arraysdict, string to NumPy array

dictionary mapping field names to NumPy arrays, with key order matching the order of fields in the packet.


If the ccsds sequence count is not in order


If the ccsds sequence count is missing packets


If there are more than one APID