mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-03-02 21:53:53 +08:00
disable_ecu.py: remove duplicate file (#25154)
* remove duplicate function * make executable
This commit is contained in:
14
selfdrive/car/disable_ecu.py
Normal file → Executable file
14
selfdrive/car/disable_ecu.py
Normal file → Executable file
@@ -6,6 +6,7 @@ EXT_DIAG_RESPONSE = b'\x50\x03'
|
||||
|
||||
COM_CONT_RESPONSE = b''
|
||||
|
||||
|
||||
def disable_ecu(logcan, sendcan, bus=0, addr=0x7d0, com_cont_req=b'\x28\x83\x01', timeout=0.1, retry=10, debug=False):
|
||||
"""Silence an ECU by disabling sending and receiving messages using UDS 0x28.
|
||||
The ECU will stay silent as long as openpilot keeps sending Tester Present.
|
||||
@@ -26,9 +27,22 @@ def disable_ecu(logcan, sendcan, bus=0, addr=0x7d0, com_cont_req=b'\x28\x83\x01'
|
||||
|
||||
cloudlog.warning("ecu disabled")
|
||||
return True
|
||||
|
||||
except Exception:
|
||||
cloudlog.exception("ecu disable exception")
|
||||
|
||||
print(f"ecu disable retry ({i+1}) ...")
|
||||
cloudlog.warning("ecu disable failed")
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import time
|
||||
import cereal.messaging as messaging
|
||||
sendcan = messaging.pub_sock('sendcan')
|
||||
logcan = messaging.sub_sock('can')
|
||||
time.sleep(1)
|
||||
|
||||
# honda bosch radar disable
|
||||
disabled = disable_ecu(logcan, sendcan, bus=1, addr=0x18DAB0F1, com_cont_req=b'\x28\x83\x03', timeout=0.5, debug=False)
|
||||
print(f"disabled: {disabled}")
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
import traceback
|
||||
|
||||
import cereal.messaging as messaging
|
||||
from selfdrive.car.isotp_parallel_query import IsoTpParallelQuery
|
||||
from system.swaglog import cloudlog
|
||||
|
||||
EXT_DIAG_REQUEST = b'\x10\x03'
|
||||
EXT_DIAG_RESPONSE = b'\x50\x03'
|
||||
COM_CONT_REQUEST = b'\x28\x83\x03'
|
||||
COM_CONT_RESPONSE = b''
|
||||
|
||||
def disable_ecu(ecu_addr, logcan, sendcan, bus, timeout=0.5, retry=5, debug=False):
|
||||
print(f"ecu disable {hex(ecu_addr)} ...")
|
||||
for i in range(retry):
|
||||
try:
|
||||
# enter extended diagnostic session
|
||||
query = IsoTpParallelQuery(sendcan, logcan, bus, [ecu_addr], [EXT_DIAG_REQUEST], [EXT_DIAG_RESPONSE], debug=debug)
|
||||
for _, _ in query.get_data(timeout).items(): # pylint: disable=unused-variable
|
||||
print("ecu communication control disable tx/rx ...")
|
||||
# communication control disable tx and rx
|
||||
query = IsoTpParallelQuery(sendcan, logcan, bus, [ecu_addr], [COM_CONT_REQUEST], [COM_CONT_RESPONSE], debug=debug)
|
||||
query.get_data(0)
|
||||
return True
|
||||
print(f"ecu disable retry ({i+1}) ...")
|
||||
except Exception:
|
||||
cloudlog.warning(f"ecu disable exception: {traceback.format_exc()}")
|
||||
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import time
|
||||
sendcan = messaging.pub_sock('sendcan')
|
||||
logcan = messaging.sub_sock('can')
|
||||
time.sleep(1)
|
||||
|
||||
# honda bosch radar disable
|
||||
disabled = disable_ecu(0x18DAB0F1, logcan, sendcan, 1, debug=False)
|
||||
print(f"disabled: {disabled}")
|
||||
Reference in New Issue
Block a user