Skip to content

Commit 4ce19cc

Browse files
committed
use opendbc imports
1 parent 45182b4 commit 4ce19cc

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

extract_keys.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,9 @@
99
from tqdm import tqdm
1010

1111
from panda import Panda
12-
try:
13-
# If openpilot is installed
14-
from panda.python.uds import UdsClient, ACCESS_TYPE, SESSION_TYPE, DATA_IDENTIFIER_TYPE, SERVICE_TYPE, ROUTINE_CONTROL_TYPE, NegativeResponseError
15-
except ImportError:
16-
# If installed from pip
17-
from panda.uds import UdsClient, ACCESS_TYPE, SESSION_TYPE, DATA_IDENTIFIER_TYPE, SERVICE_TYPE, ROUTINE_CONTROL_TYPE, NegativeResponseError
12+
from opendbc.car.uds import UdsClient, ACCESS_TYPE, SESSION_TYPE, DATA_IDENTIFIER_TYPE, SERVICE_TYPE, ROUTINE_CONTROL_TYPE, NegativeResponseError
13+
from opendbc.car.structs import CarParams
14+
from opendbc.car.isotp import isotp_send
1815

1916
ADDR = 0x7a1
2017
DEBUG = False
@@ -58,11 +55,13 @@ def get_secoc_key(key_struct):
5855
except CalledProcessError as e:
5956
if e.returncode != 1: # 1 == no process found (boardd not running)
6057
raise e
58+
except FileNotFoundError:
59+
pass
6160

6261
panda = Panda()
63-
panda.set_safety_mode(Panda.SAFETY_ELM327)
62+
panda.set_safety_mode(CarParams.SafetyModel.elm327)
6463

65-
uds_client = UdsClient(panda, ADDR, ADDR + 8, BUS, timeout=0.1, response_pending_timeout=0.1, debug=DEBUG)
64+
uds_client = UdsClient(panda, ADDR, ADDR + 8, BUS, timeout=0.1, response_pending_timeout=0.1)
6665

6766
print("Getting application versions...")
6867

@@ -180,7 +179,7 @@ def get_secoc_key(key_struct):
180179
# Manually send so we don't get stuck waiting for the response
181180
# uds_client.routine_control(ROUTINE_CONTROL_TYPE.START, 0xff00, data)
182181
erase = b"\x31\x01\xff\x00" + data
183-
panda.isotp_send(ADDR, erase, bus=BUS)
182+
isotp_send(panda, erase, ADDR, bus=BUS)
184183

185184
print("\nDumping keys...")
186185
start = 0xfebe6e34

0 commit comments

Comments
 (0)