set timeout

A free API for the communication with control devices according to UDS (ISO 14229-1)
Post Reply
fabio.parodi@technoleader.it
Posts: 21
Joined: Thu 28. Apr 2022, 14:48

set timeout

Post by fabio.parodi@technoleader.it » Wed 14. Sep 2022, 17:30

Hello

I have this C# code that sends a "testerpresent" and waits for the answer, which may arrive or not.

Code: Select all

            result = UDSApi.SvcTesterPresent_2013(
                canport, config,
                out uds_msg request);
            if (UDSApi.StatusIsOk_2013(result))
                result = UDSApi.WaitForService_2013(canport,
                    ref request, out response, out request_confirmation);
If the answer does not arrive, the function WaitForService_2013() returns after 10 seconds.
I would like to reduce the timeout and return after a much shorter interval - like 10ms.

I've tried setting parameters PCANTP_PARAMETER_TIMEOUT_AS, AR, BS, CR: nothing changes.

It must be possible to set the timeout! How to do that?

One more thing: the default timeout is 1000*1000 microseconds = 1 second; still the function WaitForService_2013() returns after 10 seconds. ??

Thanks and regards

fabio

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

Re: set timeout

Post by F.Vergnaud » Wed 14. Sep 2022, 17:51

Hello,

You are looking for the following parameters: PUDS_PARAMETER_TIMEOUT_REQUEST and PUDS_PARAMETER_TIMEOUT_RESPONSE.
See page 47 in the user manuel:
PUDS_PARAMETER_TIMEOUT_REQUEST
Description: This value defines the maximum waiting time in milliseconds to receive a confirmation of a transmission (or request loopback). It is used in PCAN-UDS 2.x API utility functions like UDS_WaitForService_2013 or method like WaitForService_2013.
Default Value: PUDS_TIMEOUT_REQUEST (10000 milliseconds).
PUDS_PARAMETER_TIMEOUT_RESPONSE
Description: This value defines the maximum waiting time in milliseconds to receive a response indication.
Note that the exact timeout value is the sum of this parameter and the timeout defined in the active diagnostic session. It is used in PCAN-UDS 2.x API utility functions like UDS_WaitForService_2013 or methods
like WaitForService_2013.
Default Value: PUDS_TIMEOUT_RESPONSE (10000 milliseconds).
Best regards,
Fabrice

fabio.parodi@technoleader.it
Posts: 21
Joined: Thu 28. Apr 2022, 14:48

Re: set timeout

Post by fabio.parodi@technoleader.it » Thu 15. Sep 2022, 14:09

thanks. it works

Code: Select all

            // change timeouts
            UDSApi.GetValue_2013(canport, uds_parameter.PUDS_PARAMETER_TIMEOUT_REQUEST, out UInt32 timeout_request, sizeof(UInt32));
            UDSApi.GetValue_2013(canport, uds_parameter.PUDS_PARAMETER_TIMEOUT_RESPONSE, out UInt32 timeout_response, sizeof(UInt32));
            UInt32 temporary_timeout = 25;
            UDSApi.SetValue_2013(canport, uds_parameter.PUDS_PARAMETER_TIMEOUT_REQUEST, ref temporary_timeout, sizeof(UInt32));
            UDSApi.SetValue_2013(canport, uds_parameter.PUDS_PARAMETER_TIMEOUT_RESPONSE, ref temporary_timeout, sizeof(UInt32));

Post Reply