1010from openpilot .common .swaglog import cloudlog
1111
1212
13- def make_tester_present_msg (addr , bus , subaddr = None ):
13+ def _make_tester_present_msg (addr , bus , subaddr = None ):
1414 dat = [0x02 , SERVICE_TYPE .TESTER_PRESENT , 0x0 ]
1515 if subaddr is not None :
1616 dat .insert (0 , subaddr )
@@ -19,7 +19,7 @@ def make_tester_present_msg(addr, bus, subaddr=None):
1919 return make_can_msg (addr , bytes (dat ), bus )
2020
2121
22- def is_tester_present_response (msg : capnp .lib .capnp ._DynamicStructReader , subaddr : int = None ) -> bool :
22+ def _is_tester_present_response (msg : capnp .lib .capnp ._DynamicStructReader , subaddr : int = None ) -> bool :
2323 # ISO-TP messages are always padded to 8 bytes
2424 # tester present response is always a single frame
2525 dat_offset = 1 if subaddr is not None else 0
@@ -33,7 +33,7 @@ def is_tester_present_response(msg: capnp.lib.capnp._DynamicStructReader, subadd
3333 return False
3434
3535
36- def get_all_ecu_addrs (logcan : messaging .SubSocket , sendcan : messaging .PubSocket , bus : int , timeout : float = 1 , debug : bool = True ) -> set [EcuAddrBusType ]:
36+ def _get_all_ecu_addrs (logcan : messaging .SubSocket , sendcan : messaging .PubSocket , bus : int , timeout : float = 1 , debug : bool = True ) -> set [EcuAddrBusType ]:
3737 addr_list = [0x700 + i for i in range (256 )] + [0x18da00f1 + (i << 8 ) for i in range (256 )]
3838 queries : set [EcuAddrBusType ] = {(addr , None , bus ) for addr in addr_list }
3939 responses = queries
@@ -44,7 +44,7 @@ def get_ecu_addrs(logcan: messaging.SubSocket, sendcan: messaging.PubSocket, que
4444 responses : set [EcuAddrBusType ], timeout : float = 1 , debug : bool = False ) -> set [EcuAddrBusType ]:
4545 ecu_responses : set [EcuAddrBusType ] = set () # set((addr, subaddr, bus),)
4646 try :
47- msgs = [make_tester_present_msg (addr , bus , subaddr ) for addr , subaddr , bus in queries ]
47+ msgs = [_make_tester_present_msg (addr , bus , subaddr ) for addr , subaddr , bus in queries ]
4848
4949 messaging .drain_sock_raw (logcan )
5050 sendcan .send (can_list_to_can_capnp (msgs , msgtype = 'sendcan' ))
@@ -58,7 +58,7 @@ def get_ecu_addrs(logcan: messaging.SubSocket, sendcan: messaging.PubSocket, que
5858 continue
5959
6060 subaddr = None if (msg .address , None , msg .src ) in responses else msg .dat [0 ]
61- if (msg .address , subaddr , msg .src ) in responses and is_tester_present_response (msg , subaddr ):
61+ if (msg .address , subaddr , msg .src ) in responses and _is_tester_present_response (msg , subaddr ):
6262 if debug :
6363 print (f"CAN-RX: { hex (msg .address )} - 0x{ bytes .hex (msg .dat )} " )
6464 if (msg .address , subaddr , msg .src ) in ecu_responses :
@@ -94,7 +94,7 @@ def get_ecu_addrs(logcan: messaging.SubSocket, sendcan: messaging.PubSocket, que
9494 set_obd_multiplexing (params , not args .no_obd )
9595
9696 print ("Getting ECU addresses ..." )
97- ecu_addrs = get_all_ecu_addrs (logcan , sendcan , args .bus , args .timeout , debug = args .debug )
97+ ecu_addrs = _get_all_ecu_addrs (logcan , sendcan , args .bus , args .timeout , debug = args .debug )
9898
9999 print ()
100100 print ("Found ECUs on rx addresses:" )
0 commit comments