Explicit parser frequencies made canValid=False when state-dependent messages are absent (PCM_BUTTONS is event-driven; MPC_LKAS_CMD/ACC_CMD only flow when stock ADAS is active), tripping EventName.canError. - Alive-check only control-critical messages, at a conservative 10Hz (1s timeout): ESC, BRAKE_APPLIED, PEDAL, STEER_MODULE, STEERING_TORQUE, DRIVE_STATE, ACC_HUD_ADAS - Parse-but-don't-alive-check (nan) the rest: STALKS, METER_CLUSTER, MPC_LKAS_CMD, ACC_CMD - PCM_BUTTONS is parsed on both pt and cam parsers (bus assignment is harness dependent); MADS reads LKAS_ON_BTN from whichever bus sees it Verified: canValid=True with idle stock ADAS, LKAS button events work from either bus, canValid stays True throughout.
31 lines
1.1 KiB
Python
31 lines
1.1 KiB
Python
"""
|
|
Copyright (c) 2021-, Haibin Wen, sunnypilot, and a number of other contributors.
|
|
|
|
This file is part of sunnypilot and is licensed under the MIT License.
|
|
See the LICENSE.md file in the root directory for more details.
|
|
"""
|
|
|
|
from enum import StrEnum
|
|
|
|
from opendbc.car import Bus, structs
|
|
|
|
from opendbc.sunnypilot.mads_base import MadsCarStateBase
|
|
from opendbc.can.parser import CANParser
|
|
|
|
|
|
class MadsCarState(MadsCarStateBase):
|
|
def __init__(self, CP: structs.CarParams, CP_SP: structs.CarParamsSP):
|
|
super().__init__(CP, CP_SP)
|
|
|
|
def update_mads(self, ret: structs.CarState, can_parsers: dict[StrEnum, CANParser]) -> None:
|
|
cp = can_parsers[Bus.pt]
|
|
cp_cam = can_parsers[Bus.cam]
|
|
|
|
# PCM_BUTTONS bus assignment is harness dependent; read from whichever bus sees it
|
|
lkas_button = cp.vl["PCM_BUTTONS"]["LKAS_ON_BTN"]
|
|
if not cp.vl_all["PCM_BUTTONS"]["LKAS_ON_BTN"] and cp_cam.vl_all["PCM_BUTTONS"]["LKAS_ON_BTN"]:
|
|
lkas_button = cp_cam.vl["PCM_BUTTONS"]["LKAS_ON_BTN"]
|
|
|
|
self.prev_lkas_button = self.lkas_button
|
|
self.lkas_button = lkas_button
|