pylessard / python-udsoncan

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

Suppress response for TesterPresent 0x3E #160

Closed prasadghole closed 1 year ago

prasadghole commented 1 year ago

Current source code always expect response for Tester Present. In most of cases for saving bandwidth of CAN bus by default it should suppress the response. I suggest adding parameters to Tester Present API so that we should able to suppress the Tester Present response.

pylessard commented 1 year ago

Have you tried that? https://udsoncan.readthedocs.io/en/latest/udsoncan/client.html#suppress-positive-response

prasadghole commented 1 year ago

Yes I tried and it work. But I am still using python-can as I am not able to use functional address. Hence for tester present I am sending my own message instead of using TesterPresent API.

pylessard commented 1 year ago

Functional addressing is handled by the transport layer, not the UDS module. What are you using as the transport layer?

prasadghole commented 1 year ago

I am using PythonIsoTpConnectionas a transport layer.

pylessard commented 1 year ago

I see. PythonIsoTpConnection is the glue code for the python-can-isotp package TransportLayer object. You can achieve what you want to do, maybe not the cleanest solution, but will work. See this parameter : https://can-isotp.readthedocs.io/en/latest/isotp/implementation.html#default_target_address_type

isotp_layer = isotp.TransportLayer(...)
conn = PythonIsoTpConnection(isotp_layer)

with Client(conn) as client:
    with client.suppress_positive_response:
        isotp_layer.params.set('default_target_address_type', isotp.address.TargetAddressType.Functional)
        client.tester_present()
        isotp_layer.params.set('default_target_address_type', isotp.address.TargetAddressType.Physical)