Library API¶
E2E Profiles¶
Profile 01¶
- e2e.p01.e2e_p01_protect(data: bytearray, data_id: int, *, data_id_mode: int = E2E_P01_DATAID_BOTH, length: int = 0, offset: int = 0, increment_counter: bool = True) None¶
Calculate CRC inplace according to AUTOSAR E2E Profile 1.
- Parameters:
data (bytearray) – Mutable bytes-like object starting with the CRC byte. This CRC byte will be updated inplace.
data_id (int) – A unique identifier which is used to protect against masquerading. The data_id is a 16bit unsigned integer.
data_id_mode (int) – This attribute describes the inclusion mode that is used to include the data_id. The possible inclusion modes are
E2E_P01_DATAID_BOTH,E2E_P01_DATAID_ALT,E2E_P01_DATAID_LOWandE2E_P01_DATAID_NIBBLE.length (int) – Number of bytes to consider for CRC calculation. If
length == 0, the full buffer length (len(data)) is used. Otherwise,2 <= length <= len(data)must hold.:param int offset: Byte offset of the E2E header.increment_counter (bool) – If True the counter in byte 1 will be incremented before calculating the CRC.
- e2e.p01.e2e_p01_check(data: bytearray, data_id: int, *, data_id_mode: int = E2E_P01_DATAID_BOTH, length: int = 0, offset: int = 0) bool¶
Return
Trueif CRC is correct according to AUTOSAR E2E Profile 1.- Parameters:
data (bytearray) –
Mutable bytes-like object starting with the CRC byte. This CRC byte will be updated inplace.
data_id (int) – A unique identifier which is used to protect against masquerading. The data_id is a 16bit unsigned integer.
data_id_mode (int) – Mode of the data ID. Possible values are
E2E_P01_DATAID_BOTH,E2E_P01_DATAID_ALT,E2E_P01_DATAID_LOWandE2E_P01_DATAID_NIBBLE.length (int) – Number of bytes to consider for CRC calculation. If
length == 0, the full buffer length (len(data)) is used. Otherwise,2 <= length <= len(data)must hold.:param int offset: Byte offset of the E2E header.
- Returns:
True if CRC is valid, otherwise return False
Profile 02¶
- e2e.p02.e2e_p02_protect(data: bytearray, data_id_list: bytes, *, length: int = 0, increment_counter: bool = True) None¶
Calculate CRC inplace according to AUTOSAR E2E Profile 2.
- Parameters:
data (bytearray) –
Mutable bytes-like object starting with the CRC byte. This CRC byte will be updated inplace.
data_id_list (bytes) –
A bytes-like object of length 16 which is used to protect against masquerading.
length (int) – Number of bytes to consider for CRC calculation. If
length == 0, the full buffer length (len(data)) is used. Otherwise,2 <= length <= len(data)must hold.:param bool increment_counter: If True the counter in byte 1 will be incremented before calculating the CRC.
- e2e.p02.e2e_p02_check(data: bytes, data_id_list: bytes, *, length: int) bool¶
Return
Trueif CRC is correct according to AUTOSAR E2E Profile 2.- Parameters:
data –
bytes-like object starting with the CRC byte.
data_id_list –
A bytes-like object of length 16 which is used to protect against masquerading.
length (int) – Number of bytes to consider for CRC calculation. If
length == 0, the full buffer length (len(data)) is used. Otherwise,2 <= length <= len(data)must hold.:return: True if CRC is valid, otherwise return False
Profile 04¶
- e2e.p04.e2e_p04_protect(data: bytearray, data_id: int, *, length: int = 0, offset: int = 0, increment_counter: bool = True) None¶
Calculate CRC inplace according to AUTOSAR E2E Profile 4.
- Parameters:
data (bytearray) –
Mutable bytes-like object.
data_id (int) – A unique identifier which is used to protect against masquerading. The data_id is a 32bit unsigned integer.
length (int) – Number of bytes to consider for CRC calculation. If
length == 0, the full buffer length (len(data)) is used. Otherwise,12 <= length <= len(data)must hold.:param int offset: Byte offset of the E2E header.increment_counter (bool) – If True the counter will be incremented before calculating the CRC.
- e2e.p04.e2e_p04_check(data: bytearray, data_id: int, *, length: int = 0, offset: int = 0) bool¶
Return
Trueif CRC is correct according to AUTOSAR E2E Profile 4.- Parameters:
data (bytearray) –
Mutable bytes-like object starting with the CRC byte.
data_id (int) – A unique identifier which is used to protect against masquerading.
length (int) – Number of bytes to consider for CRC calculation. If
length == 0, the full buffer length (len(data)) is used. Otherwise,12 <= length <= len(data)must hold.:param int offset: Byte offset of the E2E header.
- Returns:
True if CRC is valid, otherwise return False
Profile 05¶
- e2e.p05.e2e_p05_protect(data: bytearray, data_id: int, *, length: int = 0, offset: int = 0, increment_counter: bool = True) None¶
Calculate CRC inplace according to AUTOSAR E2E Profile 5.
- Parameters:
data (bytearray) –
Mutable bytes-like object.
data_id (int) – A unique identifier which is used to protect against masquerading. The data_id is a 16bit unsigned integer.
length (int) – Number of bytes to consider for CRC calculation. If
length == 0, the full buffer length (len(data)) is used. Otherwise,3 <= length <= len(data)must hold.:param int offset: Byte offset of the E2E header.increment_counter (bool) – If True the counter will be incremented before calculating the CRC.
- e2e.p05.e2e_p05_check(data: bytes, data_id: int, *, length: int = 0, offset: int = 0) bool¶
Return
Trueif CRC is correct according to AUTOSAR E2E Profile 5.- Parameters:
data –
data_id (int) – A unique identifier which is used to protect against masquerading. The data_id is a 16bit unsigned integer.
length (int) – Number of bytes to consider for CRC calculation. If
length == 0, the full buffer length (len(data)) is used. Otherwise,3 <= length <= len(data)must hold.:param int offset: Byte offset of the E2E header.
- Returns:
True if CRC is valid, otherwise return False
Profile 06¶
- e2e.p06.e2e_p06_protect(data: bytearray, data_id: int, *, length: int = 0, offset: int = 0, increment_counter: bool = True) None¶
Calculate CRC inplace according to AUTOSAR E2E Profile 6.
- Parameters:
data (bytearray) –
Mutable bytes-like object.
data_id (int) – A unique identifier which is used to protect against masquerading. The data_id is a 16bit unsigned integer.
length (int) – Number of bytes to consider for CRC calculation. If
length == 0, the full buffer length (len(data)) is used. Otherwise,5 <= length <= len(data)must hold.:param int offset: Byte offset of the E2E header.increment_counter (bool) – If True the counter will be incremented before calculating the CRC.
- e2e.p06.e2e_p06_check(data: bytes, data_id: int, *, length: int, offset: int = 0) bool¶
Return
Trueif CRC is correct according to AUTOSAR E2E Profile 6.- Parameters:
data –
data_id (int) – A unique identifier which is used to protect against masquerading. The data_id is a 16bit unsigned integer.
length (int) – Number of bytes to consider for CRC calculation. If
length == 0, the full buffer length (len(data)) is used. Otherwise,5 <= length <= len(data)must hold.:param int offset: Byte offset of the E2E header.
- Returns:
True if CRC is valid, otherwise return False
Profile 07¶
- e2e.p07.e2e_p07_protect(data: bytearray, data_id: int, *, length: int = 0, offset: int = 0, increment_counter: bool = True) None¶
Calculate CRC inplace according to AUTOSAR E2E Profile 7.
- Parameters:
data (bytearray) –
Mutable bytes-like object.
data_id (int) – A unique identifier which is used to protect against masquerading. The data_id is a 32bit unsigned integer.
length (int) – Number of bytes to consider for CRC calculation. If
length == 0, the full buffer length (len(data)) is used. Otherwise,20 <= length <= len(data)must hold.:param int offset: Byte offset of the E2E header.increment_counter (bool) – If True the counter will be incremented before calculating the CRC.
- e2e.p07.e2e_p07_check(data: bytes, data_id: int, *, length: int = 0, offset: int = 0) bool¶
Return
Trueif CRC is correct according to AUTOSAR E2E Profile 7.- Parameters:
data –
data_id (int) – A unique identifier which is used to protect against masquerading. The data_id is a 32bit unsigned integer.
length (int) – Number of bytes to consider for CRC calculation. If
length == 0, the full buffer length (len(data)) is used. Otherwise,20 <= length <= len(data)must hold.:param int offset: Byte offset of the E2E header.
- Returns:
True if CRC is valid, otherwise return False
Profile 11¶
- e2e.p11.e2e_p11_protect(data: bytearray, data_id: int, *, data_id_mode: int = E2E_P11_DATAID_BOTH, length: int = 0, offset: int = 0, increment_counter: bool = True) None¶
Calculate CRC inplace according to AUTOSAR E2E Profile 11.
- Parameters:
data (bytearray) –
Mutable bytes-like object. This CRC byte will be updated inplace.
data_id (int) – A unique identifier which is used to protect against masquerading. The data_id is a 16bit unsigned integer.
data_id_mode (int) – This attribute describes the inclusion mode that is used to include the data_id. The possible inclusion modes are
E2E_P11_DATAID_BOTHandE2E_P11_DATAID_NIBBLE.length (int) – Number of bytes to consider for CRC calculation. If
length == 0, the full buffer length (len(data)) is used. Otherwise,2 <= length <= len(data)must hold.:param int offset: Byte offset of the E2E header.increment_counter (bool) – If True the counter in byte 1 will be incremented before calculating the CRC.
- e2e.p11.e2e_p11_check(data: bytearray, data_id: int, *, data_id_mode: int = E2E_P11_DATAID_BOTH, length: int = 0, offset: int = 0) bool¶
Return
Trueif CRC is correct according to AUTOSAR E2E Profile 11.- Parameters:
data (bytearray) –
Mutable bytes-like object starting with the CRC byte. This CRC byte will be updated inplace.
data_id (int) – A unique identifier which is used to protect against masquerading. The data_id is a 16bit unsigned integer.
data_id_mode (int) – Mode of the data ID. Possible values are
E2E_P11_DATAID_BOTHandE2E_P11_DATAID_NIBBLE.length (int) – Number of bytes to consider for CRC calculation. If
length == 0, the full buffer length (len(data)) is used. Otherwise,2 <= length <= len(data)must hold.:param int offset: Byte offset of the E2E header.
- Returns:
True if CRC is valid, otherwise return False
CRC Functions¶
8-bit SAE J1850 CRC Calculation¶
- e2e.crc.calculate_crc8(data: bytes, start_value: int = 0xFF, first_call: bool = True) int¶
8-bit SAE J1850 CRC Calculation
- Parameters:
data (bytes) –
bytes-like object which contains the data for CRC calculation
start_value (int) – First CRC of the algorithm (ignored when first_call is True). In a sequence, this is expected to be the return value of the previous function call.
first_call (bool) – True if this is the first call of a sequence or an individual function call. False if this is a subsequent call in a sequence.
- Returns:
CRC value
8-bit 0x2F polynomial CRC Calculation¶
- e2e.crc.calculate_crc8_h2f(data: bytes, start_value: int = 0xFF, first_call: bool = True) int¶
8-bit 0x2F polynomial CRC Calculation
- Parameters:
data (bytes) –
bytes-like object which contains the data for CRC calculation
start_value (int) – First CRC of the algorithm (ignored when first_call is True). In a sequence, this is expected to be the return value of the previous function call.
first_call (bool) – True if this is the first call of a sequence or an individual function call. False if this is a subsequent call in a sequence.
- Returns:
CRC value
16-bit CCITT-FALSE CRC16¶
- e2e.crc.calculate_crc16(data: bytes, start_value: int = 0xFFFF, first_call: bool = True) int¶
16-bit CCITT-FALSE CRC16
- Parameters:
data (bytes) –
bytes-like object which contains the data for CRC calculation
start_value (int) – First CRC of the algorithm (ignored when first_call is True). In a sequence, this is expected to be the return value of the previous function call.
first_call (bool) – True if this is the first call of a sequence or an individual function call. False if this is a subsequent call in a sequence.
- Returns:
CRC value
16-bit 0x8005 polynomial CRC calculation¶
- e2e.crc.calculate_crc16_arc(data: bytes, start_value: int = 0x0000, first_call: bool = True) int¶
16-bit 0x8005 polynomial CRC calculation
- Parameters:
data (bytes) –
bytes-like object which contains the data for CRC calculation
start_value (int) – First CRC of the algorithm (ignored when first_call is True). In a sequence, this is expected to be the return value of the previous function call.
first_call (bool) – True if this is the first call of a sequence or an individual function call. False if this is a subsequent call in a sequence.
- Returns:
CRC value
32-bit Ethernet CRC Calculation¶
- e2e.crc.calculate_crc32(data: bytes, start_value: int = 0xFFFFFFFF, first_call: bool = True) int¶
32-bit Ethernet CRC Calculation
- Parameters:
data (bytes) –
bytes-like object which contains the data for CRC calculation
start_value (int) – First CRC of the algorithm (ignored when first_call is True). In a sequence, this is expected to be the return value of the previous function call.
first_call (bool) – True if this is the first call of a sequence or an individual function call. False if this is a subsequent call in a sequence.
- Returns:
CRC value
32-bit 0xF4ACFB13 polynomial CRC calculation¶
- e2e.crc.calculate_crc32_p4(data: bytes, start_value: int = 0xFFFFFFFF, first_call: bool = True) int¶
32-bit 0xF4ACFB13 polynomial CRC calculation
- Parameters:
data (bytes) –
bytes-like object which contains the data for CRC calculation
start_value (int) – First CRC of the algorithm (ignored when first_call is True). In a sequence, this is expected to be the return value of the previous function call.
first_call (bool) – True if this is the first call of a sequence or an individual function call. False if this is a subsequent call in a sequence.
- Returns:
CRC value
64-bit 0x42F0E1EBA9EA3693 polynomial CRC calculation¶
- e2e.crc.calculate_crc64(data: bytes, start_value: int = 0xFFFFFFFFFFFFFFFF, first_call: bool = True) int¶
64-bit 0x42F0E1EBA9EA3693 polynomial CRC calculation
- Parameters:
data (bytes) –
bytes-like object which contains the data for CRC calculation
start_value (int) – First CRC of the algorithm (ignored when first_call is True). In a sequence, this is expected to be the return value of the previous function call.
first_call (bool) – True if this is the first call of a sequence or an individual function call. False if this is a subsequent call in a sequence.
- Returns:
CRC value