uds.utilities.conversions ========================= .. py:module:: uds.utilities.conversions .. autoapi-nested-parse:: Module with various conversion functions. Functions --------- .. autoapisummary:: uds.utilities.conversions.bytes_to_hex uds.utilities.conversions.bytes_to_int uds.utilities.conversions.int_to_bytes uds.utilities.conversions.obd_dtc_to_int uds.utilities.conversions.int_to_obd_dtc uds.utilities.conversions.get_signed_value_decoding_formula uds.utilities.conversions.get_signed_value_encoding_formula Module Contents --------------- .. py:function:: bytes_to_hex(bytes_list) Convert a list of bytes to hex string. :param bytes_list: List of bytes to convert. :return: String with provided list of bytes presented as hexadecimal values. .. py:function:: bytes_to_int(bytes_list, endianness = Endianness.BIG_ENDIAN) Convert a list of bytes to integer value. :param bytes_list: List of bytes to convert. :param endianness: Order of bytes to use. :return: The integer value represented by provided list of bytes. .. py:function:: int_to_bytes(int_value, size = None, endianness = Endianness.BIG_ENDIAN) Convert integer value to a list of bytes. :param int_value: Integer value to convert. :param size: Number of bytes in the output. Use None to use the smallest possible number of bytes. :param endianness: Order of bytes to use. :raise TypeError: At least one provided value has invalid type. :raise ValueError: At least one provided value is out of range. :raise InconsistencyError: Provided value of `size` is too small to contain entire `int_value`. :return: The value of bytes list that represents the provided integer value. .. py:function:: obd_dtc_to_int(obd_dtc) Convert text with DTC in OBD format into integer value (DTC in UDS format). :param obd_dtc: Text with DTC in OBD format. :raise TypeError: Provided value is not str type. :raise ValueError: Provided value is not DTC in OBD format. :return: Integer value representation of this DTC in UDS format. .. py:function:: int_to_obd_dtc(dtc) Encode integer value (DTC in UDS format) into text with DTC in OBD format. :param dtc: Integer with DTC in UDS format. :raise TypeError: Provided value is not int type. :raise ValueError: Provided value is not DTC in OBD format. :return: Text value representation of this DTC in OBD format. .. py:function:: get_signed_value_decoding_formula(bit_length) Get formula for decoding signed integer value. :param bit_length: Number of bits used for signed integer value. :raise TypeError: Provided value is not int type. :raise ValueError: Provided value is out of range. :return: Formula for decoding singed integer value from unsigned integer value. .. py:function:: get_signed_value_encoding_formula(bit_length) Get formula for encoding signed integer value. :param bit_length: Number of bits used for signed integer value. :raise TypeError: Provided value is not int type. :raise ValueError: Provided value is out of range. :return: Formula for encoding singed integer value into unsinged integer value.