I have the following situation:
I am writing a software in C# which uses the Peak UDS API to make some diagnostics of a can bus where 16 Devices are attached.
My current problem is, that I do not fully understand the Requese/Response mapping of the UDS API.
I have read the documentation and I do not understand the way, how the Function "AddMapping_2013" works. What is meant with nai.source and nai.target adress?
My CAN devices behave like the following:
Device 1: I send an UDS Request with CAN ID 0x280 and the device responses with a UDS response on CAN ID 0x2C0.
Device 2: I send an UDS Request with CAN ID 0x281 and the device responses with a UDS response on CAN ID 0x2C1.
Device 2: I send an UDS Request with CAN ID 0x282 and the device responses with a UDS response on CAN ID 0x2C2.
I have tried the following code and it works for Device 2 but I am still not sure if I use the API correctly.
I also do not understand, why it works with the source adress 0xF1 and Target adress 0xff. I just tried out some code snippets from the net.
Code: Select all
uds_mapping request_mapping = new uds_mapping();
request_mapping.can_id = 0x281;
request_mapping.can_id_flow_ctrl = 0x2C1;
request_mapping.can_msgtype = cantp_can_msgtype.PCANTP_CAN_MSGTYPE_STANDARD;
request_mapping.can_tx_dlc = 8;
request_mapping.nai.protocol = uds_msgprotocol.PUDS_MSGPROTOCOL_ISO_15765_2_11B_NORMAL;
request_mapping.nai.target_type = cantp_isotp_addressing.PCANTP_ISOTP_ADDRESSING_PHYSICAL;
request_mapping.nai.source_addr = (UInt16)uds_address.PUDS_ADDRESS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request_mapping. = 0xFF;
request_mapping.nai.extension_addr = 0;
uds_mapping response_mapping;
response_mapping = request_mapping;
response_mapping.can_id = request_mapping.can_id_flow_ctrl;
response_mapping.can_id_flow_ctrl = request_mapping.can_id;
response_mapping.nai.source_addr = request_mapping.nai.target_addr;
response_mapping.nai.target_addr = request_mapping.nai.source_addr;
UDSApi.AddMapping_2013(cantp_handle.PCANTP_HANDLE_USBBUS1, ref request_mapping);
UDSApi.AddMapping_2013(cantp_handle.PCANTP_HANDLE_USBBUS1, ref response_mapping);
WaitForService_2013 returns a timeout, even when the devices are responding on the CAN bus.
Can anybody help me please and explain:
- What is meant with nai.source_addr and nai.target_addr in general?
- How I can add the mappings for all my 16 Devices so that the API informs me about their responses?
