FixedLength¶
- class ccsdspy.FixedLength(fields, apid=None, name=None, description=None)[source]¶
Bases:
_BasePacketDefine a fixed length packet to decode binary data.
Fixed length packets correspond to packets that are the same length and layout every time. A common example of this is housekeeping or status messages.
- Parameters:
- fieldslist of
PacketFieldorPacketArray Layout of packet fields contained in the definition.
- apidint, optional
APID of the packet. Acts as a unique identifier for the packet type. Used as metadata.
- namestr, optional
Name of the packet. Used as metadata.
- descriptionstr, optional
Description of the packet. Used as metadata.
- fieldslist of
- Raises:
- ValueError
one or more of the arguments are invalid
Methods Summary
load(file[, include_primary_header, ...])Decode a file-like object containing a sequence of these packets.
to_file(file, pkt_type, apid, ...[, seq_count])Encode a file containing a sequence of packet fields.
Methods Documentation
- load(file, include_primary_header=False, reset_file_obj=False)[source]¶
Decode a file-like object containing a sequence of these packets.
- Parameters:
- filestr
Path to file on the local file system, or file-like object
- include_primary_headerbool
If True, provides the primary header in the output. The names of the fields are:
CCSDS_VERSION_NUMBER,CCSDS_PACKET_TYPE,CCSDS_SECONDARY_FLAG,CCSDS_SEQUENCE_FLAG,CCSDS_APID,CCSDS_SEQUENCE_COUNT, andCCSDS_PACKET_LENGTH- reset_file_objbool
If True, leave the file object, when it is file buffer, where it was before load is called. Otherwise, (default), leave the file stream pos after the read packets. Does not apply when file is a string.
- Returns:
- field_arraysdict, string to NumPy array
dictionary mapping field names to NumPy arrays, with key order matching the order of fields in the packet.
- Warns:
- UserWarning
If the ccsds sequence count is not in order
- UserWarning
If the ccsds sequence count is missing packets
- UserWarning
If there are more than one APID
- to_file(file, pkt_type, apid, sec_header_flag, seq_flag, data, seq_count=0)[source]¶
Encode a file containing a sequence of packet fields. For more information about the CCSDS primary header see CCSDS.
- Parameters:
- filestr
Path to file on the local file system, or file-like object
- pkt_typeint
For the CCSDS primary header, for telemetry (or reporting), set to 0, for commanding set to 1.
- apiduint
For the CCSDS primary header, the Application process identifier (0 to 2047)
- sec_header_flaguint
For the CCSDS primary header, identicates the presence or absence of a secondary header. Set to 1 if present.
- seq_flaguint
For the CCSDS primary header, tet to 1 if the data is a continuation segment, set to 0 if it contains the first or only segment of data.
- seq_countuint
For the CCSDS primary header, the start sequence number for the packets
- datadict
The data to add to the file where the keys must match the packet field names and values are
ndarrayof the same length.
- Returns:
- filestr
A binary file with the packet data
- Raises:
- ValueError
If the number of elements in the data values are not the same.