How change the default UDS Standard adress

This forum covers issues concerning multiple software products.
Post Reply
Benoit_V
Posts: 7
Joined: Thu 7. Nov 2024, 13:40

How change the default UDS Standard adress

Post by Benoit_V » Thu 20. Mar 2025, 09:35

Hello,

I have a trouble with the implementation of the UDS library.
I want change the default CAN ID for the standard: 0x7E0 to another value like: 0x420 for example.

I try this:

Code: Select all

        uint16_t adress_ecu = (uint16_t)(0x420);
        address_diagtool = (uint16_t)(0x421);

        // Initialize a physical configuration
        config_physical.can_id = adress_ecu;
        config_physical.can_msgtype = PCANTP_CAN_MSGTYPE_STANDARD;
        config_physical.nai.protocol = PUDS_MSGPROTOCOL_ISO_15765_2_11B_NORMAL;
        config_physical.nai.target_type = PCANTP_ISOTP_ADDRESSING_PHYSICAL;
        config_physical.type = PUDS_MSGTYPE_USDT;
        config_physical.nai.source_addr = address_diagtool;
        config_physical.nai.target_addr = adress_ecu;
        config_physical.nai.extension_addr = 0;

        qDebug() << " config_physical.nai.source_addr = " << QString::number(address_diagtool);
        qDebug() << " config_physical.nai.target_addr = " << QString::number(adress_ecu);


        uds_msg request;
        uds_msg response;
        uds_msg confirmation;
        QString var_debug = "";

        memset(&request, 0, sizeof(uds_msg));
        memset(&response, 0, sizeof(uds_msg));
        memset(&confirmation, 0, sizeof(uds_msg));

        cantp_mapping mapping;
        cantp_can_msgtype can_msgtype;
        cantp_mapping reverse_mapping;

        memset(&mapping, 0, sizeof(cantp_mapping));
        memset(&reverse_mapping, 0, sizeof(cantp_mapping));

        can_msgtype = PCANTP_CAN_MSGTYPE_STANDARD;


        mapping.can_id = address_diagtool;
        mapping.can_id_flow_ctrl = adress_ecu;
        mapping.can_msgtype = can_msgtype;
        mapping.netaddrinfo.extension_addr = 0x00;
        mapping.netaddrinfo.format = PCANTP_ISOTP_FORMAT_NORMAL;
        mapping.netaddrinfo.msgtype = PCANTP_ISOTP_MSGTYPE_DIAGNOSTIC;
        mapping.netaddrinfo.source_addr = address_diagtool;
        mapping.netaddrinfo.target_addr = adress_ecu;
        mapping.netaddrinfo.target_type = PCANTP_ISOTP_ADDRESSING_PHYSICAL;

        // Create the associated isotp reversed mapping:
        reverse_mapping = mapping;
        reverse_mapping.can_id = mapping.can_id_flow_ctrl;
        reverse_mapping.can_id_flow_ctrl = mapping.can_id;
        reverse_mapping.netaddrinfo.source_addr = mapping.netaddrinfo.target_addr;
        reverse_mapping.netaddrinfo.target_addr = mapping.netaddrinfo.source_addr;


		status_cantp = CANTP_AddMapping_2016((cantp_handle)can_handler, &mapping);
		qDebug() << " status ADD MAPPING = " << QString::number(status_cantp);
	    status_cantp = CANTP_AddMapping_2016((cantp_handle)can_handler, &reverse_mapping);
		qDebug() << " status ADD MAPPING = " << QString::number(status_cantp);


The function "CANTP_AddMapping_2016" return errort code 14 => 0x0E => PCANTP_ERRSTATUS_MAPPING_INVALID.
And I don't understood why, I have this error.


I also test this, like indicated in the user manual Section: Usage in a Non-Standardized Context :

Code: Select all

       uds_mapping mappings[256];
        uint16_t count;
        uint16_t i;
        status = UDS_GetMappings_2013(tp_handle, mappings, 256, &count);
        if(!UDS_StatusIsOk_2013(status, PUDS_STATUS_OK, false))
        {
            qDebug() << "Get mappings failed.\n";
        }

        for (i = 0; i < count; i++)
        {
        status = UDS_RemoveMapping_2013(tp_handle, mappings[i]);
        if (!UDS_StatusIsOk_2013(status, PUDS_STATUS_OK, false))
        {
            qDebug() << "Remove mapping failed.\n";
        }
        else
        {
            qDebug() << "Remove mapping OK.\n";
        }
        }


        uint16_t param = address_diagtool;
        status = UDS_SetValue_2013(tp_handle, PUDS_PARAMETER_SERVER_ADDRESS, &param, sizeof(param));
        qDebug() << " status new parameter address_diagtool  = " << QString::number(status);


        // Listen to address 0x11
        param = adress_ecu;
        status = UDS_SetValue_2013(tp_handle, PUDS_PARAMETER_ADD_LISTENED_ADDRESS, &param,sizeof(param));
        qDebug() << " status new parameter address ECU  = " << QString::number(status);
No error, but the UDS CAN frame are not sent.

Do you have an idea, what I do wrong? Or do you have an example of implementation of change CAN ID standard?

Thanks in advance!

Best regards.
Last edited by F.Vergnaud on Mon 24. Mar 2025, 16:06, edited 1 time in total.
Reason: code formatting

F.Vergnaud
Software Development
Software Development
Posts: 305
Joined: Mon 9. Sep 2013, 12:21

Re: How change the default UDS Standard adress

Post by F.Vergnaud » Mon 24. Mar 2025, 16:16

Hello,

It seems you are confusing UDS addresses and CAN IDs:
- A UDS address is defined during network design and may not be visible in the UDS exchanges. It is an 8-bit value.
- That is why the UDS on CAN standards define mappings which associates Network Address Information with a CAN ID.
ISO-15765-4 defines for instance the following mapping: CAN ID 0x7E0 is the response of ECU address 0x01 to Tester Equipment address 0xF1.

You need to create a mapping for your CAN IDs 0x420 and 0x421. Please check UDS documentation page 770 and more especially §4.3.3 "PCAN-UDS 2.x Example" - "Configuration of Mappings": you'll see a complete example to define mappings.
Best regards,
Fabrice

Post Reply