cpx_io.utils package

Submodules

cpx_io.utils.boollist module

Helper functions for converting lists of boolean values

cpx_io.utils.boollist.bytes_to_boollist(data: bytes, num_bytes: int | None = None, byteorder='little') list

Converts data in byte representation to a list of bools

cpx_io.utils.boollist.boollist_to_bytes(boollist: list) bytes

Converts a list of bools to byte representation

cpx_io.utils.boollist.boollist_to_int(boollist: list) int

Converts a list of bools to int representation

cpx_io.utils.boollist.int_to_boollist(number: int) list

Converts an int to a list of bool values

cpx_io.utils.helpers module

Helper functions

exception cpx_io.utils.helpers.ChannelIndexError(message='Channel out of range')

Bases: IndexError

Error should be raised if a non-existing channel is addressed

cpx_io.utils.helpers.div_ceil(x_val: int, y_val: int) int

Divides two integers and returns the ceiled result

cpx_io.utils.helpers.convert_uint32_to_octett(value: int) str

Convert one uint32 value to octett. Usually used for displaying ip addresses.

cpx_io.utils.helpers.convert_octett_to_uint32(octetts: str) int

Convert octett string to 32 bit value. Usually used for converting ip addresses.

cpx_io.utils.helpers.convert_to_mac_string(values: list[int]) str

Convert list of uint8 to mac adderss string.

cpx_io.utils.helpers.module_list_from_typecode(typecode: str, module_id_dict: dict) list

Creates a module list from a provided typecode.

cpx_io.utils.helpers.value_range_check(value: int, *args)

Raises ValueError if value is not in the given range.

cpx_io.utils.helpers.channel_range_check(channel: int, *args)

Raises IndexError if channel is not in the given range.

cpx_io.utils.helpers.instance_range_check(instance: int, *args)

Raises IndexError if instance is not in the given range.

cpx_io.utils.logging module

Contains class which contains logging methods.

class cpx_io.utils.logging.Logging(logging_level=20, filename=None)

Bases: object

Class that contains common functions for logging.

logger = <Logger cpx-io (WARNING)>
enable_stream_logging(logging_level)

Enables logging to stream using the provided log level with rich log formatting.

enable_file_logging(filename, logging_level)

Enables logging to a file using the provided filename and log level.

Module contents