jacobschaer / python-doipclient

Pure Python ISO 13400 Client
MIT License
151 stars 50 forks source link

How to customize the connection timeout? #27

Open amsyrena opened 1 year ago

amsyrena commented 1 year ago

I want to customize the connection timeout, how should I do it? One way that comes to my mind is to update the value of A_PROCESSING_TIME in constants.py. But how to update the value of A_PROCESSING_TIME in constants.py?

Thank you very much for providing this library, it is very useful!

jacobschaer commented 1 year ago

It's been a while since I looked at this, but most of the functions accept a timeout parameter, which is exposed to the udsoncan client and should make use of any request timeouts you set there. The only exception I think is _connect which is needed for establishing the initial socket.

If the issue you're having is in _connect, I imagine you could just monkeypatch it - might need to experiment with the import name you overwrite, but surely it can set externally. Not elegant but should get you started. I can imagine there probably exists some bad ECU somewhere that doesn't respect the rules or, perhaps, there's a gateway in the middle which is slow.

Ideally those would be class members that are override-able by the constructor or config dicts like udsoncan uses, but at the time it seemed like a bit of a nuisance to implement and test, and the spec called them out as constants so I just went with that.

If you would like to refactor to make that override-able by the constructor, feel free to MR and I can take a look.