uds.utilities.conversions
Module with various conversion functions.
Functions
|
Convert a list of bytes to hex string. |
|
Convert a list of bytes to integer value. |
|
Convert integer value to a list of bytes. |
Module Contents
- uds.utilities.conversions.bytes_to_hex(bytes_list)[source]
Convert a list of bytes to hex string.
- Parameters:
bytes_list (uds.utilities.common_types.RawBytesAlias) – List of bytes to convert.
- Returns:
String with provided list of bytes presented as hexadecimal values.
- Return type:
- uds.utilities.conversions.bytes_to_int(bytes_list, endianness=Endianness.BIG_ENDIAN)[source]
Convert a list of bytes to integer value.
- Parameters:
bytes_list (uds.utilities.common_types.RawBytesAlias) – List of bytes to convert.
endianness (uds.utilities.enums.Endianness) – Order of bytes to use.
- Returns:
The integer value represented by provided list of bytes.
- Return type:
- uds.utilities.conversions.int_to_bytes(int_value, size=None, endianness=Endianness.BIG_ENDIAN)[source]
Convert integer value to a list of bytes.
- Parameters:
int_value (int) – Integer value to convert.
size (Optional[int]) – Number of bytes in the output. Use None to use the smallest possible number of bytes.
endianness (uds.utilities.enums.Endianness) – Order of bytes to use.
- Raises:
TypeError – At least one provided value has invalid type.
ValueError – At least one provided value is out of range.
InconsistencyError – Provided value of size is too small to contain entire int_value.
- Returns:
The value of bytes list that represents the provided integer value.
- Return type: