UDS testDiagnosticSessionControl

A free API for the communication with control devices according to UDS (ISO 14229-1)
Locked
vmedvedev
Posts: 4
Joined: Sun 28. Apr 2024, 19:39

UDS testDiagnosticSessionControl

Post by vmedvedev » 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

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);
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
;$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 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
I also including mapping information from ECUBus I am trying to replicate.
mapsetting.png
mapsetting.png (258.38 KiB) Viewed 3586 times
Thank you for any help.

!! changed to a readable format by ADMIN - please see Forum Rules !!

K.Wagner
Software Development
Software Development
Posts: 1082
Joined: Wed 22. Sep 2010, 13:36

Re: UDS testDiagnosticSessionControl

Post by K.Wagner » Tue 30. Apr 2024, 16:08

Hello,
vmedvedev wrote:
Sun 28. Apr 2024, 20:53
I see that message sent 02 10 01 55 55 55 55 55 but should be 02 10 01 00 00 00 00 00.
Note that you are refering to the padding value. This is per default set to the value 0x55 in our API. If you want to use a different, in your case "0", then you have to configure this by using the parameter PUDS_PARAMETER_CAN_PADDING_VALUE. You can find more information about this 3.5.3, uds_parameter, page 49.
vmedvedev wrote:
Sun 28. Apr 2024, 20:53
Response message looks correct 02 50 01 00 00 00 00 00
According to the version of ISO-TP/UDS you are using, the API(s) may not respond to messages that are using a different value for padding bytes. Please check that you are using the latest versions of all APIs (PCAN-Basic, PCAN-ISO-TP, PCAN-UDS), and that you are using the same padding value for all messages involved.
Best regards,
Keneth

vmedvedev
Posts: 4
Joined: Sun 28. Apr 2024, 19:39

Re: UDS testDiagnosticSessionControl

Post by vmedvedev » Thu 2. May 2024, 17:32

Hi,
thank you for your suggestions.
I tested both disabling padding

Code: Select all

            dw_buffer = CanTpApi.PCANTP_CAN_DATA_PADDING_NONE;
            status = UDSApi.SetValue_2013(client_handle, uds_parameter.PUDS_PARAMETER_CAN_DATA_PADDING, ref dw_buffer, sizeof(UInt32));
            Console.WriteLine("Set Padding status: {0}", (int)status);
            waitGetch();
nopadding.png
nopadding.png (121.22 KiB) Viewed 3523 times
and setting padding value to 0

Code: Select all

           dw_buffer = CanTpApi.PCANTP_ISO_TIMEOUTS_15765_4;
           status = UDSApi.SetValue_2013(client_handle, uds_parameter.PUDS_PARAMETER_CAN_PADDING_VALUE, new byte[] {0x00 }, sizeof(UInt32));
           Console.WriteLine("Set Data Padding to None: {0}", (int)status);
           waitGetch();
zeropadding.png
zeropadding.png (203.87 KiB) Viewed 3523 times
The messages in Grid View Trace looks good now but I still have ERROR: NO UDS RESPONSE

Code: Select all

Setting a DEFAULT Diagnostic Session:
 UDS_SvcDiagnosticSessionControl_2013: 587202560

UDS request from 0x0011 (to 0x0022, with extension address 0x00) - result: 0 - OK !
-> Length: 2, Data= 10 01

 /!\ ERROR: NO UDS RESPONSE !!
 Free request message: 0
 Free response message: 0
 Free confirmation message: 0
 Diagnostic Session Information: 0, 0x0022 => 1 = [0032; 01F4]
I am using computer with W11 and only VS 2022 and peek environment installed. Here is dll versions I am using for the project
versions.png
versions.png (100.01 KiB) Viewed 3523 times
Please, advise what I need to check additionally.

Thank you,
Vladimr

K.Wagner
Software Development
Software Development
Posts: 1082
Joined: Wed 22. Sep 2010, 13:36

Re: UDS testDiagnosticSessionControl

Post by K.Wagner » Fri 3. May 2024, 12:12

Hello,

Note that you are using a different, non standard, communication context. In our Api you need to extra configure such a behavior. Please check the chapter 4.3.1, "Usage in a Non-Standardized Context" within the PCAN-UDS API documentation.

Moreover, I see some bus errors (BUS_HEAVY/BUS_LIGHT) in your trace. This could cause problems, as this is a hint of physical problems. And finally, I see a mixing of data with padding and without padding (optimized). This makes also a difference in the API for messages to be recognized or not. See "PUDS_PARAMETER_CAN_DATA_PADDING" for more information.
Best regards,
Keneth

vmedvedev
Posts: 4
Joined: Sun 28. Apr 2024, 19:39

Re: UDS testDiagnosticSessionControl

Post by vmedvedev » Fri 3. May 2024, 23:33

Hi,
thank you very much for your help. After deleting default mappings and using UDSApi.AddMapping_2013 instead of AddMapping_2016 the timeout error went away. It is working both with padding disabled (mixed mode) and padding enabled with value set to 0.

M.Heidemann
Sales & Support
Sales & Support
Posts: 1083
Joined: Fri 20. Sep 2019, 13:31

Re: UDS testDiagnosticSessionControl

Post by M.Heidemann » Mon 6. May 2024, 08:48

Thank you for letting us know!

For further questions, make sure you open a new topic.

Best Regards

Marvin

- Thread closed -
---
Marvin Heidemann
PEAK-Support Team

Locked