mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-02-23 20:43:53 +08:00
* format card * standalone process * no class member CS, there's no point also can be confusing; what else could be using this? * rename CoS * Update selfdrive/controls/controlsd.py * never works first time :D * canRcvTimeout is bool * hack * add cpu * see what testing closet comes up with * first * some clean up * support passable CI, fix test models * fix startup alert * process replay changes * test_fuzzy * gate carOutput valid on carControl valid * we should publish after we update carOutput * controlsd was using actuatorsOutput from 2 frames ago for torque, not the most up to date * check all checks for carControl in case controlsd dies * log more timestamps * more generic latency logger; needs some clean up latency_logger.py was difficult to understand and modify * card polls on can and carControl to get latest carControl possible * temp try to send earlier * add log * remove latencylogger * no mpld3! * old loop * detect first event * normal send * revert "card polls on can and carControl to get latest carControl possible" how it was is best * sheesh! update should be first * first timestamp * temp comment ( timestamp is slow :( ) * more final ordering, and make polling on/off test repeatable * Received can * new plot timestamps * clean up * no poll * add controllers (draft) * Revert "add controllers (draft)" This reverts commit e2c3f01b2fadcff74347bac90c8a5cc1ef4e27b3. * fix that * conventions * just use CS * consider controlsd state machine in card: not fully done * hmm it's just becoming controlsd * rm debugging * Revert "hmm it's just becoming controlsd" This reverts commit 534a357ee95bec4ed070667186af55d59421bbc7. * Revert "just use CS" This reverts commit 9fa7406f30c86200f20457f7b9ff95e731201bf9. * add vCruise * migrate car state * Revert "migrate car state" This reverts commit 4ae86ca163c6920070f410f608f7644ab632850b. * Revert "add vCruise" This reverts commit af247a8da41c3626ada4231b98042da1a1ae4633. * simple state machine in card (doesn't work as is) * Revert "simple state machine in card (doesn't work as is)" This reverts commit b4af8a9b0a2e17fdfc89d344c64678ef51305c24. * poll carState without conflate * bump * remove state transition * fix * update refs * ignore cumLagMs and don't ignore valid * fix controls mismatch; controlsd used to set alt exp * controlsd_config_callback not needed for card * revert ref temp * update refs * no poll * not builder! * test fix * need to migrate initialized * CC will be a reader * more as_reader! * fix None * init after publish like before - no real difference * controlsd clean up * remove redundant check and check passive for init * stash * flip * migrate missing carOutput for controlsd * Update ref_commit * bump cereal * comment * no class params * no class * Revert "no class" This reverts commit 5499b83c2dcb5462070626f8523e3aec6f4c209d. * add todo * regen and update refs * fix * update refs * and fix that * should be controlsstate * remove controlsState migration CoS.initialized isn't needed yet * fix * flip! * bump * fix that * update refs * fix * if canValid goes false, controlsd would still send * bump * rm diff * need to be very careful with initializing * update refs
122 lines
4.7 KiB
Python
122 lines
4.7 KiB
Python
import os
|
|
from parameterized import parameterized
|
|
|
|
from cereal import log, car
|
|
import cereal.messaging as messaging
|
|
from openpilot.common.params import Params
|
|
from openpilot.selfdrive.boardd.boardd_api_impl import can_list_to_can_capnp
|
|
from openpilot.selfdrive.car.fingerprints import _FINGERPRINTS
|
|
from openpilot.selfdrive.car.toyota.values import CAR as TOYOTA
|
|
from openpilot.selfdrive.car.mazda.values import CAR as MAZDA
|
|
from openpilot.selfdrive.controls.lib.events import EVENT_NAME
|
|
from openpilot.selfdrive.manager.process_config import managed_processes
|
|
|
|
EventName = car.CarEvent.EventName
|
|
Ecu = car.CarParams.Ecu
|
|
|
|
COROLLA_FW_VERSIONS = [
|
|
(Ecu.engine, 0x7e0, None, b'\x0230ZC2000\x00\x00\x00\x00\x00\x00\x00\x0050212000\x00\x00\x00\x00\x00\x00\x00\x00'),
|
|
(Ecu.abs, 0x7b0, None, b'F152602190\x00\x00\x00\x00\x00\x00'),
|
|
(Ecu.eps, 0x7a1, None, b'8965B02181\x00\x00\x00\x00\x00\x00'),
|
|
(Ecu.fwdRadar, 0x750, 0xf, b'8821F4702100\x00\x00\x00\x00'),
|
|
(Ecu.fwdCamera, 0x750, 0x6d, b'8646F0201101\x00\x00\x00\x00'),
|
|
(Ecu.dsu, 0x791, None, b'881510201100\x00\x00\x00\x00'),
|
|
]
|
|
COROLLA_FW_VERSIONS_FUZZY = COROLLA_FW_VERSIONS[:-1] + [(Ecu.dsu, 0x791, None, b'xxxxxx')]
|
|
COROLLA_FW_VERSIONS_NO_DSU = COROLLA_FW_VERSIONS[:-1]
|
|
|
|
CX5_FW_VERSIONS = [
|
|
(Ecu.engine, 0x7e0, None, b'PYNF-188K2-F\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'),
|
|
(Ecu.abs, 0x760, None, b'K123-437K2-E\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'),
|
|
(Ecu.eps, 0x730, None, b'KJ01-3210X-G-00\x00\x00\x00\x00\x00\x00\x00\x00\x00'),
|
|
(Ecu.fwdRadar, 0x764, None, b'K123-67XK2-F\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'),
|
|
(Ecu.fwdCamera, 0x706, None, b'B61L-67XK2-T\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'),
|
|
(Ecu.transmission, 0x7e1, None, b'PYNC-21PS1-B\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'),
|
|
]
|
|
|
|
|
|
@parameterized.expand([
|
|
# TODO: test EventName.startup for release branches
|
|
|
|
# officially supported car
|
|
(EventName.startupMaster, TOYOTA.TOYOTA_COROLLA, COROLLA_FW_VERSIONS, "toyota"),
|
|
(EventName.startupMaster, TOYOTA.TOYOTA_COROLLA, COROLLA_FW_VERSIONS, "toyota"),
|
|
|
|
# dashcamOnly car
|
|
(EventName.startupNoControl, MAZDA.MAZDA_CX5, CX5_FW_VERSIONS, "mazda"),
|
|
(EventName.startupNoControl, MAZDA.MAZDA_CX5, CX5_FW_VERSIONS, "mazda"),
|
|
|
|
# unrecognized car with no fw
|
|
(EventName.startupNoFw, None, None, ""),
|
|
(EventName.startupNoFw, None, None, ""),
|
|
|
|
# unrecognized car
|
|
(EventName.startupNoCar, None, COROLLA_FW_VERSIONS[:1], "toyota"),
|
|
(EventName.startupNoCar, None, COROLLA_FW_VERSIONS[:1], "toyota"),
|
|
|
|
# fuzzy match
|
|
(EventName.startupMaster, TOYOTA.TOYOTA_COROLLA, COROLLA_FW_VERSIONS_FUZZY, "toyota"),
|
|
(EventName.startupMaster, TOYOTA.TOYOTA_COROLLA, COROLLA_FW_VERSIONS_FUZZY, "toyota"),
|
|
])
|
|
def test_startup_alert(expected_event, car_model, fw_versions, brand):
|
|
controls_sock = messaging.sub_sock("controlsState")
|
|
pm = messaging.PubMaster(['can', 'pandaStates'])
|
|
|
|
params = Params()
|
|
params.put_bool("OpenpilotEnabledToggle", True)
|
|
|
|
# Build capnn version of FW array
|
|
if fw_versions is not None:
|
|
car_fw = []
|
|
cp = car.CarParams.new_message()
|
|
for ecu, addr, subaddress, version in fw_versions:
|
|
f = car.CarParams.CarFw.new_message()
|
|
f.ecu = ecu
|
|
f.address = addr
|
|
f.fwVersion = version
|
|
f.brand = brand
|
|
|
|
if subaddress is not None:
|
|
f.subAddress = subaddress
|
|
|
|
car_fw.append(f)
|
|
cp.carVin = "1" * 17
|
|
cp.carFw = car_fw
|
|
params.put("CarParamsCache", cp.to_bytes())
|
|
else:
|
|
os.environ['SKIP_FW_QUERY'] = '1'
|
|
|
|
managed_processes['controlsd'].start()
|
|
managed_processes['card'].start()
|
|
|
|
assert pm.wait_for_readers_to_update('can', 5)
|
|
pm.send('can', can_list_to_can_capnp([[0, 0, b"", 0]]))
|
|
|
|
assert pm.wait_for_readers_to_update('pandaStates', 5)
|
|
msg = messaging.new_message('pandaStates', 1)
|
|
msg.pandaStates[0].pandaType = log.PandaState.PandaType.uno
|
|
pm.send('pandaStates', msg)
|
|
|
|
# fingerprint
|
|
if (car_model is None) or (fw_versions is not None):
|
|
finger = {addr: 1 for addr in range(1, 100)}
|
|
else:
|
|
finger = _FINGERPRINTS[car_model][0]
|
|
|
|
msgs = [[addr, 0, b'\x00'*length, 0] for addr, length in finger.items()]
|
|
for _ in range(1000):
|
|
# card waits for boardd to echo back that it has changed the multiplexing mode
|
|
if not params.get_bool("ObdMultiplexingChanged"):
|
|
params.put_bool("ObdMultiplexingChanged", True)
|
|
|
|
pm.send('can', can_list_to_can_capnp(msgs))
|
|
assert pm.wait_for_readers_to_update('can', 5, dt=0.001), f"step: {_}"
|
|
|
|
ctrls = messaging.drain_sock(controls_sock)
|
|
if len(ctrls):
|
|
event_name = ctrls[0].controlsState.alertType.split("/")[0]
|
|
assert EVENT_NAME[expected_event] == event_name, f"expected {EVENT_NAME[expected_event]} for '{car_model}', got {event_name}"
|
|
break
|
|
else:
|
|
raise Exception(f"failed to fingerprint {car_model}")
|