WaitForServiceFunctional question

A free API for the communication with control devices according to UDS (ISO 14229-1)
Post Reply
spoekles
Posts: 9
Joined: Tue 14. Mar 2023, 09:36

WaitForServiceFunctional question

Post by spoekles » Mon 17. Apr 2023, 14:36

Hello,

I would like to use UDS_SvcTesterPresent_2013 to get a count of all connected ECUs to the network and their addresses. My idea was to use functional addressing and read the responses with UDS_WaitForServiceFunctional_2013.
However it seems that no responses are read, but on PCAN-Explorer I see the correct responses from the ECUs.

The uds_msgconfig is configured as followed:

Code: Select all

    msgConfig.can_id = uint32_t();
    msgConfig.can_msgtype = PCANTP_CAN_MSGTYPE_EXTENDED;
    msgConfig.nai.protocol = PUDS_MSGPROTOCOL_ISO_15765_2_29B_FIXED_NORMAL;
    msgConfig.nai.target_type = PCANTP_ISOTP_ADDRESSING_PHYSICAL;
    msgConfig.type = PUDS_MSGTYPE_USDT;
    msgConfig.nai.source_addr = PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
    msgConfig.nai.target_addr = 0;
    msgConfig.nai.extension_addr = 0;
The tester present is being done as followed:

Code: Select all

    status = UDS_Initialize_2013(handle, PCANTP_BAUDRATE_500K);
    if (UDS_StatusIsOk_2013(status) == true)
    {
        uint32_t prio = 3; // 3 = 0x0CDAXXYY || XX = target addr, YY = source addr
        status = UDS_SetValue_2013(handle, uds_parameter::PUDS_PARAMETER_J1939_PRIORITY, &prio, sizeof(prio));
        PrintUdsStatusIfNotOk(status);
        uint32_t timeout = 100;
        status = UDS_SetValue_2013(handle, uds_parameter::PUDS_PARAMETER_TIMEOUT_RESPONSE, &timeout, sizeof(timeout));
        PrintUdsStatusIfNotOk(status);

        AppHelper::Print("Sending tester present\n");
        status = UDS_SvcTesterPresent_2013(handle, msgConfig, &msgRequest);
        if (UDS_StatusIsOk_2013(status) == true)
        {
            uint32_t count;
            uds_msg buff[10] = { uds_msg() };
            status = UDS_WaitForServiceFunctional_2013(handle, &msgRequest, 10, true, buff, &count, &responseConfirm);
            if (UDS_StatusIsOk_2013(status) == true)
            {
                AppHelper::Print("Tester present received\n");
            }
            else
            {
                PrintUdsStatusIfNotOk(status);
            }
        }
        else
        {
            PrintUdsStatusIfNotOk(status);
        }

        status = UDS_MsgFree_2013(&msgRequest);
        PrintUdsStatusIfNotOk(status);
        status = UDS_MsgFree_2013(&response);
        PrintUdsStatusIfNotOk(status);
        status = UDS_MsgFree_2013(&responseConfirm);
        PrintUdsStatusIfNotOk(status);
    }
I am aware that I configure my message with

Code: Select all

    msgConfig.nai.target_addr = 0;
    msgConfig.nai.target_type = PCANTP_ISOTP_ADDRESSING_PHYSICAL;
Changing the target_type to functional addresses changes the ID to 0x0CDB which is not the correct address. Changing the target_addr to the correct address of one of the ECUs, works in this case, but then I am not getting responses from all of the ECUs on the network.

Is there a method of making WaitForServiceFunctional work without changing the target type?

Many thanks.

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

Re: WaitForServiceFunctional question

Post by F.Vergnaud » Mon 17. Apr 2023, 14:53

Hello,

You need to:
- set the target_type to PCANTP_ISOTP_ADDRESSING_FUNCTIONAL. This is mandatory and defined in ISO 15765-2, otherwise your ECU behaves in a non-standard way.
- set the target address to something your ECUs listen to: they may be configured to listen to this standardized address PUDS_ISO_15765_4_ADDR_OBD_FUNCTIONAL (0x33).

If this does not work, you should check the specifications of your ECUs and see if they support functional addressing and how.
Best regards,
Fabrice

Post Reply