zserio.bitposition module

The module provides help methods for bit position calculation.

zserio.bitposition.alignto(alignment_value: int, bitposition: int) int[source]

Aligns the bit size to the given alignment value.

Parameters:
  • alignment_value – Value to align.

  • bitposition – Current bit position where to apply alignment.

Returns:

Aligned bit position.

zserio.bitposition.bits_to_bytes(numbits: int) int[source]

Converts number of bits to bytes.

Parameters:

numbits – The number of bits to convert.

Returns:

Number of bytes

Raises:

PythonRuntimeException – If number of bits to convert is not divisible by 8.

zserio.bitposition.bitsize_to_bytesize(bitsize: int) int[source]

Converts number of bits to number of bytes.

Parameters:

bitsize – Size in bits to convert.

Returns:

Size in bytes.

zserio.bitposition.bytes_to_bits(num_bytes: int) int[source]

Converts number of bytes to bits.

Parameters:

num_bytes – The n number of bytes to convert.

Returns:

Number of bits.