In [1]:
from konfoo import Index, Byteorder, Decimal, Decimal8, Decimal16, Decimal24, Decimal32, Decimal64
Item type of the field
class.
In [2]:
Decimal.item_type
Out[2]:
Checks if the field
class is a bit
field.
In [3]:
Decimal.is_bit()
Out[3]:
Checks if the field
class is a boolean
field.
In [4]:
Decimal.is_bool()
Out[4]:
Checks if the field
class is a decimal
number field.
In [5]:
Decimal.is_decimal()
Out[5]:
Checks if the field
class is a floating point
number field.
In [6]:
Decimal.is_float()
Out[6]:
Checks if the field
class is a pointer
field.
In [7]:
Decimal.is_pointer()
Out[7]:
Checks if the field
class is a stream
field.
In [8]:
Decimal.is_stream()
Out[8]:
Checks if the field
class is a string
field.
In [9]:
Decimal.is_string()
Out[9]:
In [10]:
decimal = Decimal(bit_size=32, align_to=None, signed=False, byte_order='auto')
In [11]:
decimal = Decimal(32)
In [12]:
decimal
Out[12]:
In [13]:
str(decimal)
Out[13]:
In [14]:
repr(decimal)
Out[14]:
In [15]:
decimal.name
Out[15]:
In [16]:
decimal.index
Out[16]:
Byte index
of the field
within the byte stream
.
In [17]:
decimal.index.byte
Out[17]:
Bit offset relative to the byte index
of the field
within the byte stream
.
In [18]:
decimal.index.bit
Out[18]:
Absolute address of the field
within the data source
.
In [19]:
decimal.index.address
Out[19]:
Base address of the byte stream
within the data source
.
In [20]:
decimal.index.base_address
Out[20]:
Indexes the field
and returns the index
after the field
.
In [21]:
decimal.index_field(index=Index())
Out[21]:
In [22]:
decimal.alignment
Out[22]:
Byte size of the field group
which the field
is aligned to.
In [23]:
decimal.alignment.byte_size
Out[23]:
Bit offset of the field
within its aligned field group
.
In [24]:
decimal.alignment.bit_offset
Out[24]:
In [25]:
decimal.bit_size
Out[25]:
In [26]:
decimal.byte_order
Out[26]:
In [27]:
decimal.byte_order.value
Out[27]:
In [28]:
decimal.byte_order.name
Out[28]:
In [29]:
decimal.byte_order = 'auto'
In [30]:
decimal.byte_order = Byteorder.auto
Checks if the decimal field
is signed or unsigned.
In [31]:
decimal.signed
Out[31]:
Maximal decimal field
value.
In [32]:
decimal.max()
Out[32]:
Minimal decimal field
value.
In [33]:
decimal.min()
Out[33]:
Returns the decimal field
value as an integer number.
In [34]:
decimal.value
Out[34]:
Returns the decimal field
value aligned to its field group
as a number of bytes.
In [35]:
bytes(decimal)
Out[35]:
In [36]:
bytes(decimal).hex()
Out[36]:
Returns the decimal field
value as an integer number.
In [37]:
int(decimal)
Out[37]:
Returns the decimal field
value as an floating point number.
In [38]:
float(decimal)
Out[38]:
Returns the decimal field
value as a lowercase hexadecimal string prefixed with 0x
.
In [39]:
hex(decimal)
Out[39]:
Returns the decimal field
value as a binary string prefixed with 0b
.
In [40]:
bin(decimal)
Out[40]:
Returns the decimal field
value as an octal string prefixed with 0o
.
In [41]:
oct(decimal)
Out[41]:
Returns the decimal field
value as a boolean value.
In [42]:
bool(decimal)
Out[42]:
Returns the decimal field
value as a signed integer number.
In [43]:
decimal.as_signed()
Out[43]:
Returns the decimal field
value as an unsigned integer number.
In [44]:
decimal.as_unsigned()
Out[44]:
Returns the meatadata
of the field
as an ordered dictionary.
In [45]:
decimal.describe()
Out[45]:
In [46]:
decimal.deserialize(bytes.fromhex('00010000'), byte_order='little')
Out[46]:
In [47]:
decimal.value
Out[47]:
In [48]:
bytes(decimal)
Out[48]:
In [49]:
bytes(decimal).hex()
Out[49]:
In [50]:
int(decimal)
Out[50]:
In [51]:
float(decimal)
Out[51]:
In [52]:
hex(decimal)
Out[52]:
In [53]:
bin(decimal)
Out[53]:
In [54]:
oct(decimal)
Out[54]:
In [55]:
bool(decimal)
Out[55]:
In [56]:
buffer = bytearray()
In [57]:
decimal.value = 256
In [58]:
decimal.value = 256.0
In [59]:
decimal.value = 0x100
In [60]:
decimal.value = 0b100000000
In [61]:
decimal.value = 0o400
In [62]:
decimal.value = False
In [63]:
decimal.value = 256
In [64]:
decimal.serialize(buffer, byte_order='little')
Out[64]:
In [65]:
buffer.hex()
Out[65]:
In [66]:
bytes(decimal).hex()
Out[66]:
In [ ]: