In [1]:
from konfoo import Index, Byteorder, Float
Item type of the field class.
In [2]:
Float.item_type
Out[2]:
Checks if the field class is a bit field.
In [3]:
Float.is_bit()
Out[3]:
Checks if the field class is a boolean field.
In [4]:
Float.is_bool()
Out[4]:
Checks if the field class is a decimal number field.
In [5]:
Float.is_decimal()
Out[5]:
Checks if the field class is a floating point number field.
In [6]:
Float.is_float()
Out[6]:
Checks if the field class is a pointer field.
In [7]:
Float.is_pointer()
Out[7]:
Checks if the field class is a stream field.
In [8]:
Float.is_stream()
Out[8]:
Checks if the field class is a string field.
In [9]:
Float.is_string()
Out[9]:
In [10]:
real = Float(byte_order='auto')
In [11]:
real = Float()
In [12]:
real
Out[12]:
In [13]:
str(real)
Out[13]:
In [14]:
repr(real)
Out[14]:
In [15]:
real.name
Out[15]:
In [16]:
real.index
Out[16]:
Byte index of the field within the byte stream.
In [17]:
real.index.byte
Out[17]:
Bit offset relative to the byte index of the field within the byte stream.
In [18]:
real.index.bit
Out[18]:
Absolute address of the field within the data source.
In [19]:
real.index.address
Out[19]:
Base address of the byte stream within the data source.
In [20]:
real.index.base_address
Out[20]:
Indexes the field and returns the index after the field.
In [21]:
real.index_field(index=Index())
Out[21]:
In [22]:
real.alignment
Out[22]:
Byte size of the field group which the field is aligned to.
In [23]:
real.alignment.byte_size
Out[23]:
Bit offset of the field within its aligned field group.
In [24]:
real.alignment.bit_offset
Out[24]:
In [25]:
real.bit_size
Out[25]:
In [26]:
real.byte_order
Out[26]:
In [27]:
real.byte_order.value
Out[27]:
In [28]:
real.byte_order.name
Out[28]:
In [29]:
real.byte_order = 'auto'
In [30]:
real.byte_order = Byteorder.auto
Maximal float field value.
In [31]:
real.max()
Out[31]:
Minimal float field value.
In [32]:
real.min()
Out[32]:
Smallest float field value.
In [33]:
real.smallest()
Out[33]:
Epsilon float field value.
In [34]:
real.epsilon()
Out[34]:
Returns the float field value as a single precision floating point number.
In [35]:
real.value
Out[35]:
Returns the float field value aligned to its field group as a number of bytes.
In [36]:
bytes(real)
Out[36]:
In [37]:
bytes(real).hex()
Out[37]:
Returns the float field value as an integer number.
In [38]:
int(real)
Out[38]:
Returns the float field value as a single precision floating point number.
In [39]:
float(real)
Out[39]:
Returns the float field value as a boolean value.
In [40]:
bool(real)
Out[40]:
Returns the meatadata of the field as an ordered dictionary.
In [41]:
real.describe()
Out[41]:
In [42]:
real.deserialize(bytes.fromhex('0000803f'), byte_order='little')
Out[42]:
In [43]:
real.value
Out[43]:
In [44]:
bytes(real)
Out[44]:
In [45]:
bytes(real).hex()
Out[45]:
In [46]:
int(real)
Out[46]:
In [47]:
float(real)
Out[47]:
In [48]:
bool(real)
Out[48]:
In [49]:
buffer = bytearray()
In [50]:
real.value = 1
In [51]:
real.value = 1.0
In [52]:
real.value = 0x1
In [53]:
real.value = 0b1
In [54]:
real.value = 0o1
In [55]:
real.value = True
In [56]:
real.value = 1.0
In [57]:
real.serialize(buffer, byte_order='little')
Out[57]:
In [58]:
buffer.hex()
Out[58]:
In [59]:
bytes(real).hex()
Out[59]:
In [ ]: