add get_car_interface helper (#31738)

add helper
pull/31740/head
Justin Newberry 1 year ago committed by GitHub
parent e399136cb6
commit 233f0437d9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 9
      selfdrive/car/car_helpers.py

@ -197,6 +197,11 @@ def fingerprint(logcan, sendcan, num_pandas):
return car_platform, finger, vin, car_fw, source, exact_match
def get_car_interface(CP):
CarInterface, CarController, CarState = interfaces[CP.carFingerprint]
return CarInterface(CP, CarController, CarState)
def get_car(logcan, sendcan, experimental_long_allowed, num_pandas=1):
candidate, fingerprints, vin, car_fw, source, exact_match = fingerprint(logcan, sendcan, num_pandas)
@ -204,14 +209,14 @@ def get_car(logcan, sendcan, experimental_long_allowed, num_pandas=1):
cloudlog.event("car doesn't match any fingerprints", fingerprints=repr(fingerprints), error=True)
candidate = "mock"
CarInterface, CarController, CarState = interfaces[candidate]
CarInterface, _, _ = interfaces[candidate]
CP = CarInterface.get_params(candidate, fingerprints, car_fw, experimental_long_allowed, docs=False)
CP.carVin = vin
CP.carFw = car_fw
CP.fingerprintSource = source
CP.fuzzyFingerprint = not exact_match
return CarInterface(CP, CarController, CarState), CP
return get_car_interface(CP), CP
def write_car_param(platform=MOCK.MOCK):
params = Params()

Loading…
Cancel
Save