pylessard / python-udsoncan

Python implementation of UDS (ISO-14229) standard.
MIT License
564 stars 195 forks source link

TimeoutException and request timeout not respected? #235

Closed pompushko closed 1 month ago

pompushko commented 1 month ago

@pylessard Hello :)

I dont know, but sometimes my timeout settings wont respects...

                client = Client(conn, request_timeout=5)
                client.open()
                client.set_config('exception_on_negative_response', False)
                client.set_config('exception_on_timeout', False)
                client.set_config('p2_timeout', 10.0)
                client.set_config('p2_server_max', 10.0)
                client.set_config('request_timeout', 10.0)
                client.set_config('p2_star_timeout', 10.0)
                client.set_config('use_server_timing', False)

And sometimes my code throw this: [TimeoutException] : Did not receive response in time. Global request timeout time has expired (timeout=1.968 sec)

Why? Where is takes timeout=1.968 sec? Thank you.

pylessard commented 1 month ago

The error message is wrong. I can fix that. You hit your 10s timeout.

What happens is that the timeout value is used to block the thread, if it unblock and there is still time to wait, a new timeout value is computed. So 1.968 = 10-time_elapsed. That mainly happens if your device sends a NRC 0x78, meaning it respond but ask to wait.

See here: https://github.com/pylessard/python-udsoncan/blob/master/udsoncan/client.py#L2194

pompushko commented 1 month ago

Hmm, so I have to extend global time to avoid long NRCs?

pylessard commented 1 month ago

Yes, or you can disable the global timeout by setting it to None. Just note that the device can block your client forever if you do so

pylessard commented 1 month ago

Should we close this issue?

pompushko commented 1 month ago

Should we close this issue?

Well, if that is not an issue or fixed, yes. Please :D

pompushko commented 1 month ago

@pylessard weird, maybe I'm wrong.... Could you please help me to adjust my timings?

[TimeoutException] : Did not receive response in time. Global request timeout time has expired (timeout=1.971 sec)

Here Is my settings:

                client.set_config('exception_on_negative_response', False)
                client.set_config('exception_on_timeout', False)
                client.set_config('p2_timeout', 10.0)
                client.set_config('p2_server_max', 20.0)
                client.set_config('p2_star_server_max', 20.0)
                client.set_config('request_timeout', 10.0)
                client.set_config('p2_star_timeout', 10.0)
                client.set_config('use_server_timing', False)

That's only after one long routine which could take 5-7 seconds:

client.start_routine(Routine.EraseMemory,
                                     data=(segment.StartAddressEraseFlash + segment.StopAddressEraseFlash))
pylessard commented 1 month ago

you didn't get an answer after 10 seconds. Check your logs to see if there's one.

You are opening a lot of issues sir.

pompushko commented 1 month ago

timeout=1.971 sec

well, but it think that its not 10 seconds :(

pylessard commented 1 month ago

image

Look at the logs