PacketField

class ccsdspy.PacketField(name, data_type, bit_length, bit_offset=None, byte_order='big', description=None)[source]

Bases: object

A field contained in a packet.

Parameters:
namestr

String identifier for the field. The name specified how you may call upon this data later.

data_type{‘uint’, ‘int’, ‘float’, ‘str’, ‘fill’}

Data type of the field.

bit_lengthint

Number of bits contained in the field.

bit_offsetint, optional

Bit offset into packet, including the primary header which is 48 bits long. If this is not specified, than the bit offset will the be calculated automatically from its position inside the packet definition.

byte_order{‘big’, ‘little’}, or custom string of digits like “4321”

Byte order of the field. Can be “big”, “little”, or an arbitrary ordering Specified as a string of digits like “2341”. Defaults to big endian.

description: str, optional

Description of the field, used as metadata.

Raises:
TypeError

If one of the arguments is not of the correct type.

ValueError

data_type or byte_order is invalid

Attributes Summary

bit_length

Bit length of the field.

bit_offset

Bit offset of the field.

byte_order

Byte order of the field.

data_type

Data type of the field.

description

Description of the field.

field_type

Whether the field is an element or array.

name

Name of the field.

Attributes Documentation

bit_length

Bit length of the field.

Integer, must be non-negative.

bit_offset

Bit offset of the field.

Integer bit offset supplied in definition. If not manually specified, is None.

byte_order

Byte order of the field.

Applies to integer data types. Either ‘big’, ‘small’, ad-hoc byte order like “4312”.

Big endian stores the most significant byte of a word at the smallest memory address, and little endian stores the least-significant byte at the smallest address.

For ad-hoc byte orders outside of big or little endian, pass a string like “4312”

data_type

Data type of the field.

String, one of:

  • ‘uint’ (unsigned integer)

  • ‘int’ (signed integer)

  • ‘float’ (IEEE floating point)

  • ‘str’ (string)

  • ‘fill’ (placeholder used to fill space between other fields)

description

Description of the field.

Used for metadata purposes. If set, is a string. Otherwise, is None.

field_type

Whether the field is an element or array.

If instance created using PacketField, this will be set to the string “element”. If created using PacketArray, this will be “array”.

name

Name of the field.

Optional metadata. If set, is a string, otherwise is None.