Table Of Contents

Field

class Field(name)

Abstract root class for all other BitPacket classes. Initially, a field only has a name and no value. Field subclasses must provide field details, such as the size of the field, the implementation of how the field value will look like, that is, how the field should be built, and other field related details.

Initialize the field with the given name. And identity (returning the field’s value) calibration curve is set by default.

array(array)

Returns the given array appended with the field byte representation to it.

bytes()

Returns a string of bytes representing this field.

calibration_curve()

Returns the calibration curve function.

eng_value()

Returns the engineering value of this field. The engineering value is the result of applying a calibration curve to the value of this field. Some fields might represent temperatures, angles, etc. that need to be converted from its digital form to its analog form. This function will return the value after the conversion is done.

fields()

Returns a list of the children of this field. An empty list is returned if the field does not have any children.

hex_value()

Returns the hexadecimal integer representation of this field. That is, the bytes forming this field in its integer representation.

name()

Returns the name of the field.

parent()

Returns the parent of this field, or None if the field is not part of any other field.

root()

Returns the root of this field. The root is the top level container that this field belongs to, if any. If the field is not part of any other field the root is the field itself.

set_array(array)

Sets the given array bytes to the field. This function does the same as calling set_bytes with the bytes of the array.

set_bytes(bytes)

Sets a string of bytes to the field.

set_calibration_curve(curve)

Sets the calibration curve to be applied to this field in order to obtain a desired conversion. Some fields might represent temperatures, angles, etc. that need to be converted from its digital form to its analog form. The calibration curve provides the functionality to perform this conversion.

set_stream(stream)

Sets this field with the contents of the given stream. Note that only the bytes necessary for this field will be obtained from the stream. This means that the stream cursor will only advance as many bytes as the size of this field.

set_value(value)

Sets a new value to the field.

size()

Returns the size of the field.

str_eng_value()

Returns a human-readable representation of the engineering value. This function will first calculate the engineering value (by applying the calibration curve) and will return the string representation of it.

str_hex_value()

Returns a human-readable representation of the hexadecimal value of this field. Note that the type of the field can be a float, integer, etc. This is the real representation (in memory) of the value.

str_value()

Returns a human-readable representation of the value of this field. Note that the type of the field can be a float, integer, etc. So, the representation might be different for each type.

stream(stream)

Fill the given byte stream with the contents of this field.

value()

Returns the value of the field.

Writer

class Writer(config=<BitPacket.writers.WriterConfig.WriterConfig object at 0x257a810>)

This the abstract class for all bit fields sub-classes. All bit fields must inherit from this class and implement the non-implemented methods in it.

config()
end_block(field, userdata=None)
level()
start_block(field, userdata=None)
write(field, userdata=None)

Returns the name of the field.

WriterConfig

class WriterConfig(**kwargs)

Bases: object

set_config(**kwargs)