UDS testDiagnosticSessionControl
Posted: Sun 28. Apr 2024, 20:53
I am learning UDS and exploring UDS API. I am trying to run example testDiagnosticSessionControl from 06_client_all_request solution here is my code
Mapping does not produces error. Application log produces NO UDS Response error
UDS request from 0x0011 (to 0x0022, with extension address 0x00) - result: 0 - OK !
-> Length: 2, Data= 10 02
/!\ ERROR: NO UDS RESPONSE !!
Free request message: 0
Free response message: 0
Free confirmation message: 0
Diagnostic Session Information: 0, 0x0022 => 1 = [0032; 01F4]
Assert that Auto TesterPresent Frame is sent...
Should transmit an Auto TesterPresent Frame
Should transmit an Auto TesterPresent Frame
When looking at GRID-View trace
I also including mapping information from ECUBus I am trying to replicate. Thank you for any help.
!! changed to a readable format by ADMIN - please see Forum Rules !!
Code: Select all
cantp_handle client_handle;
uds_status status;
UInt32 dw_buffer;
uds_msgconfig config = new uds_msgconfig();
// Set the PCAN-Channel to use
client_handle = cantp_handle.PCANTP_HANDLE_USBBUS1; // TODO: modify the value according to your available PCAN devices.
status = UDSApi.Initialize_2013(client_handle, cantp_baudrate.PCANTP_BAUDRATE_250K);
Console.WriteLine("Initialize UDS: {0}", (int)status);
//cantp_handle channel = cantp_handle.PCANTP_HANDLE_USBBUS1;
cantp_status result;
cantp_mapping request_mapping = new cantp_mapping();
cantp_mapping response_mapping;
request_mapping.can_id = 0x781;
request_mapping.can_id_flow_ctrl = 0x7F1;
request_mapping.netaddrinfo.source_addr = 0x11;
request_mapping.netaddrinfo.target_addr = 0x22;
request_mapping.netaddrinfo.extension_addr = 0x0;
request_mapping.can_msgtype = cantp_can_msgtype.PCANTP_CAN_MSGTYPE_STANDARD;
request_mapping.netaddrinfo.format = cantp_isotp_format.PCANTP_ISOTP_FORMAT_NORMAL;
request_mapping.netaddrinfo.msgtype = cantp_isotp_msgtype.PCANTP_ISOTP_MSGTYPE_DIAGNOSTIC;
request_mapping.netaddrinfo.target_type = cantp_isotp_addressing.PCANTP_ISOTP_ADDRESSING_PHYSICAL;
// Defines a second mapping to allow communication from Destination 0x22 to Source 0x11.
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.netaddrinfo.source_addr = request_mapping.netaddrinfo.target_addr;
response_mapping.netaddrinfo.target_addr = request_mapping.netaddrinfo.source_addr;
// Add request mapping
result = CanTpApi.AddMapping_2016(client_handle, ref request_mapping);
if (!CanTpApi.StatusIsOk_2016(result, cantp_status.PCANTP_STATUS_OK))
{
Console.WriteLine("Failed to add request mapping.");
}
result = CanTpApi.AddMapping_2016(client_handle, ref response_mapping);
if (!CanTpApi.StatusIsOk_2016(result, cantp_status.PCANTP_STATUS_OK))
{
Console.WriteLine("Failed to add response mapping.");
}
// Define TimeOuts
dw_buffer = CanTpApi.PCANTP_ISO_TIMEOUTS_15765_4;
status = UDSApi.SetValue_2013(client_handle, uds_parameter.PUDS_PARAMETER_ISO_TIMEOUTS, ref dw_buffer, sizeof(UInt32));
Console.WriteLine("Set ISO 15765-4 timeouts values: {0}", (int)status);
waitGetch();
// Define Network Address Information used for all the tests
//config.can_id = (UInt32)0xFFFFFFFF;
config.can_id = (UInt16)0x781;
config.can_msgtype = cantp_can_msgtype.PCANTP_CAN_MSGTYPE_STANDARD;
config.nai.protocol = uds_msgprotocol.PUDS_MSGPROTOCOL_ISO_15765_2_11B_NORMAL;
config.nai.target_type = cantp_isotp_addressing.PCANTP_ISOTP_ADDRESSING_PHYSICAL;
config.type = uds_msgtype.PUDS_MSGTYPE_USDT;//usdt
//config.nai.source_addr = (UInt16)uds_address.PUDS_ADDRESS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
//config.nai.target_addr = (UInt16)uds_address.PUDS_ADDRESS_ISO_15765_4_ADDR_ECU_1;
config.nai.source_addr = (UInt16)0x11;
config.nai.target_addr = (UInt16)0x22;
// The following functions call UDS Services
testDiagnosticSessionControl(client_handle, config);
UDS request from 0x0011 (to 0x0022, with extension address 0x00) - result: 0 - OK !
-> Length: 2, Data= 10 02
/!\ ERROR: NO UDS RESPONSE !!
Free request message: 0
Free response message: 0
Free confirmation message: 0
Diagnostic Session Information: 0, 0x0022 => 1 = [0032; 01F4]
Assert that Auto TesterPresent Frame is sent...
Should transmit an Auto TesterPresent Frame
Should transmit an Auto TesterPresent Frame
When looking at GRID-View trace
I see that message sent 02 10 01 55 55 55 55 55 but should be 02 10 01 00 00 00 00 00. Response message looks correct 02 50 01 00 00 00 00 00;$FILEVERSION=1.1
;$STARTTIME=45410.563111713
;
; Start time: 4/28/2024 13:30:52.852.0
; Generated by PCAN-View v5.2.0.926
;
; Message Number
; | Time Offset (ms)
; | | Type
; | | | ID (hex)
; | | | | Data Length
; | | | | | Data Bytes (hex) ...
; | | | | | |
;---+-- ----+---- --+-- ----+--- + -+ -- -- -- -- -- -- --
1) 1013.9 Warng FFFFFFFF 4 00 00 00 08 BUSHEAVY
2) 37370.1 Rx 0781 8 02 10 01 55 55 55 55 55
3) 37371.7 Rx 07F1 8 02 50 01 00 00 00 00 00
4) 47432.0 Rx 0781 8 02 10 02 55 55 55 55 55
5) 47433.7 Rx 07F1 8 02 50 02 00 00 00 00 00
6) 61511.9 Rx 0781 8 02 10 01 55 55 55 55 55
7) 61513.6 Rx 07F1 8 02 50 01 00 00 00 00 00
I also including mapping information from ECUBus I am trying to replicate. Thank you for any help.
!! changed to a readable format by ADMIN - please see Forum Rules !!