For a project we are using UDS with 29bit physical CAN IDs and NORMAL addressing. I am able to successfully initialize the UDS channel and send a DiagnosticSessionControl message to the ECU, to which it replies with the expected positive response as can be seen in CAN trace of PCAN-View.
However the UDS_WaitForService() function always returns the status 'PUDS_ERROR_NO_MESSAGE'... My assumption is that the ISO-TP implementation fails to make the mapping back towards the UDS layer based on the response CAN ID. So I went over the (addressing) configuration several times to check whether I have missed something obvious, but to my despair I can't find anything.
So I am hoping someone can help me figure out this issue.
Thanks in advance for any input!
I'm able to reproduce the issue with the following code:
Code: Select all
TPUDSCANHandle handle = PUDS_USBBUS1;
TPUDSStatus status = UDS_Initialize(handle, PUDS_BAUD_500K);
PCAN::ISO_TP::checkStatus(status);
//Note: The PCAN::ISO_TP::checkStatus() function checks the status and throws an exception in case it is not PCANTP_ERROR_OK
uint32_t timeout = 2000;
UDS_SetValue(handle, PUDS_PARAM_TIMEOUT_REQUEST, &timeout, sizeof(timeout));
UDS_SetValue(handle, PUDS_PARAM_TIMEOUT_RESPONSE, &timeout, sizeof(timeout));
uint16_t address = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
status = UDS_SetValue(handle,
PUDS_PARAM_SERVER_ADDRESS, &address, sizeof(address));
PCAN::ISO_TP::checkStatus(status);
TPUDSNetAddrInfo nai;
nai.SA = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
nai.TA = PUDS_ISO_15765_4_ADDR_ECU_1;
nai.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
nai.RA = 0x00;
nai.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_29B_NORMAL;
uint32_t request_id = 0x17fc008f;
uint32_t response_id = 0x17fe008f;
status = CANTP_AddMapping(handle,
request_id, response_id, PCANTP_ID_CAN_29BIT,
PCANTP_FORMAT_NORMAL, PCANTP_MESSAGE_DIAGNOSTIC,
nai.SA, nai.TA, PCANTP_ADDRESSING_PHYSICAL, nai.RA);
PCAN::ISO_TP::checkStatus(status);
status = CANTP_AddMapping(handle,
response_id, request_id, PCANTP_ID_CAN_29BIT,
PCANTP_FORMAT_NORMAL, PCANTP_MESSAGE_DIAGNOSTIC,
nai.TA, nai.SA, PCANTP_ADDRESSING_PHYSICAL, nai.RA);
PCAN::ISO_TP::checkStatus(status);
TPUDSMsg request = {0};
request.NETADDRINFO = nai;
status = UDS_SvcDiagnosticSessionControl(handle, &request, PUDS_SVC_PARAM_DSC_ECUEDS);
TPUDSMsg response = {0};
if (status == PUDS_ERROR_OK) {
status = UDS_WaitForService(handle, &response, &request);
}
PCAN::ISO_TP::checkStatus(status); // In this case always PUDS_ERROR_NO_MESSAGE