E2E tutorial

Get Actual CRC value from a CAN message

# example for getting actual CRC value from a CAN message with Profile 2
from project import *
from andi.e2e import get_actual_crc

# replace database_path with a correct path
database = andi.load_database(database_path)
# replace frame_id with a correct value
frame = database.get_frame_by_id(frame_id)
can_message = message_builder.create_can_message()
data = tuple(bytearray.fromhex('53 01 01 02 03 04 05 06 07 08 09 01 02'\
                        '03 04 05 06 07 08 09 01 02 03 04 05 06'\
                        '07 08 09 01 02 03'))
can_message.data_base = database
can_message.frame = frame
can_message.payload = data
print("Actual CRC : " + str(get_actual_crc(can_message)))

Get Actual counter value from a CAN message

# example for getting actual counter value from a CAN message with Profile 2
from project import *
from andi.e2e import get_actual_counter

# replace database_path with a correct path
database = andi.load_database(database_path)
# replace frame_id with a correct value
frame = database.get_frame_by_id(frame_id)
can_message = message_builder.create_can_message()
data = tuple(bytearray.fromhex('53 01 01 02 03 04 05 06 07 08 09 01 02'\
                        '03 04 05 06 07 08 09 01 02 03 04 05 06'\
                        '07 08 09 01 02 03'))
can_message.data_base = database
can_message.frame = frame
can_message.payload = data
print("Actual counter : " + str(get_actual_counter(can_message)))

Get Expected CRC value from a CAN message

# example for getting expected CRC value from a CAN message with Profile 2
from project import *
from andi.e2e import get_expected_crc

# replace database_path with a correct path
database = andi.load_database(database_path)
# replace frame_id with a correct value
frame = database.get_frame_by_id(frame_id)
can_message = message_builder.create_can_message()
data = tuple(bytearray.fromhex('53 01 01 02 03 04 05 06 07 08 09 01 02'\
                        '03 04 05 06 07 08 09 01 02 03 04 05 06'\
                        '07 08 09 01 02 03'))
can_message.data_base = database
can_message.frame = frame
can_message.payload = data
print("Expected CRC : " + str(get_expected_crc(can_message)))

E2E with SOME/IP-TP

# example for E2E methods with SOME/IP-TP messages
from project import *
from andi.e2e import increment_counter, protect
from andi.someip import segmentize

# replace differents variables with correct values
someip_message = message_builder.create_someip_message(sender, receiver)
someip_message.data_base = andi.load_database(database_path, "ethernet")
someip_message.someip_header.service_identifier = service_identifier
someip_message.someip_header.method_identifier = method_identifier
someip_message.someip_header.client_id = client_id
someip_message.someip_header.session_id = session_id
someip_message.someip_header.protocol_version = protocol_version
someip_message.someip_header.interface_version = interface_version
someip_message.someip_header.message_type = MessageType.NOTIFICATION
someip_message.someip_header.return_code = ReturnCode.E_OK
someip_message.payload = tuple(bytearray.fromhex('00') * 2000)

# protect the message after setting the payload and the different parameters
# protect updates the Length, DataId and CRC based on the e2e information in the database
protect(someip_message)

# in case we need to segmentize the message, this has to be done after protecting it
someip_segments = segmentize(someip_message, 1392)
for segment in someip_segments:
        segment.send()

# in case someip_message is going to be sent more than once,
# incremeting the counter is needed before sending the next message
increment_counter(someip_message)