StringifyBytesConverter

class ccsdspy.converters.StringifyBytesConverter(format='hex')[source]

Bases: Converter

Post-processing conversion which converts byte arrays or multi-byte numbers to strings in numeric representations such as binary, hexadecimal, or octal.

To convert individual bytes, the input field should be defined as a PacketArray constructed with data_type="uint" and bit_length=8. Otherwise, each element is converted as a single entity.

If the field is an array, the shape of the array is retained. The strings generated are not padded to a fixed length.

The converted strings contain prefixes such as 0b (binary), 0x (hex), or 0o (octal). If the number is signed and negative, the prefixes change to -0b (binary), -0x (hex), or -0o (octal).

Instantiate a StringifyBytesConverter object

Parameters:
format{“bin”, “hex”, “oct”}

Format used to encode the bytes in a string.

Methods Summary

convert(field_array)

Apply the conversion.

Methods Documentation

convert(field_array)[source]

Apply the conversion.

Parameters:
field_arrayNumPy array

decoded packet field values, must have at least two dimensions

Returns:
convertedNumPy array

converted form of the converted packet field values