Compare commits

...

1 Commits

Author SHA1 Message Date
Jason Wen
19eae6f318 init 2026-04-11 08:32:19 -04:00
6 changed files with 31 additions and 4 deletions

View File

@@ -16,6 +16,8 @@ inline static std::unordered_map<std::string, ParamKeyAttributes> keys = {
{"AthenadUploadQueue", {PERSISTENT, JSON}},
{"AthenadRecentlyViewedRoutes", {PERSISTENT, STRING}},
{"BootCount", {PERSISTENT, INT}},
{"BusDetectionChanged", {CLEAR_ON_MANAGER_START | CLEAR_ON_ONROAD_TRANSITION, BOOL}},
{"BusDetectionEnabled", {CLEAR_ON_MANAGER_START | CLEAR_ON_ONROAD_TRANSITION, BOOL}},
{"CalibrationParams", {PERSISTENT, BYTES}},
{"CameraDebugExpGain", {CLEAR_ON_MANAGER_START, STRING}},
{"CameraDebugExpTime", {CLEAR_ON_MANAGER_START, STRING}},

2
panda

Submodule panda updated: 18f37937cc...6fe23c4100

View File

@@ -15,7 +15,7 @@ from opendbc.car import DT_CTRL, structs
from opendbc.car.can_definitions import CanData, CanRecvCallable, CanSendCallable
from opendbc.car.carlog import carlog
from opendbc.car.fw_versions import ObdCallback
from opendbc.car.car_helpers import get_car, interfaces
from opendbc.car.car_helpers import get_car, interfaces, BusDetectionCallback
from opendbc.car.interfaces import CarInterfaceBase, RadarInterfaceBase
from openpilot.selfdrive.pandad import can_capnp_to_list, can_list_to_can_capnp
from openpilot.selfdrive.car.cruise import VCruiseHelper
@@ -39,6 +39,17 @@ def obd_callback(params: Params) -> ObdCallback:
return set_obd_multiplexing
def bus_detection_callback(params: Params) -> BusDetectionCallback:
def set_bus_detection(enabled: bool):
if params.get_bool("BusDetectionEnabled") != enabled:
cloudlog.warning(f"Setting bus detection mode to {enabled}")
params.remove("BusDetectionChanged")
params.put_bool("BusDetectionEnabled", enabled)
params.get_bool("BusDetectionChanged", block=True)
cloudlog.warning("Bus detection mode set successfully")
return set_bus_detection
def can_comm_callbacks(logcan: messaging.SubSocket, sendcan: messaging.PubSocket) -> tuple[CanRecvCallable, CanSendCallable]:
def can_recv(wait_for_one: bool = False) -> list[list[CanData]]:
"""
@@ -97,7 +108,8 @@ class Car:
with car.CarParams.from_bytes(cached_params_raw) as _cached_params:
cached_params = _cached_params
self.CI = get_car(*self.can_callbacks, obd_callback(self.params), alpha_long_allowed, is_release, cached_params)
self.CI = get_car(*self.can_callbacks, obd_callback(self.params), alpha_long_allowed, is_release, cached_params,
set_bus_detection=bus_detection_callback(self.params))
self.RI = interfaces[self.CI.CP.carFingerprint].RadarInterface(self.CI.CP)
self.CP = self.CI.CP

View File

@@ -35,6 +35,18 @@ void PandaSafety::updateMultiplexingMode() {
prev_obd_multiplexing_ = obd_multiplexing_requested;
params_.putBool("ObdMultiplexingChanged", true);
}
// Switch to noOutput passthrough for bus detection (relay engaged, forwarding enabled, no TX)
bool bus_detection_requested = params_.getBool("BusDetectionEnabled");
if (bus_detection_requested != prev_bus_detection_) {
if (bus_detection_requested) {
panda_->set_safety_model(cereal::CarParams::SafetyModel::NO_OUTPUT_PASSTHROUGH);
} else {
panda_->set_safety_model(cereal::CarParams::SafetyModel::ELM327, 1U);
}
prev_bus_detection_ = bus_detection_requested;
params_.putBool("BusDetectionChanged", true);
}
}
std::string PandaSafety::fetchCarParams() {

View File

@@ -21,6 +21,7 @@ private:
bool log_once_ = false;
bool safety_configured_ = false;
bool prev_obd_multiplexing_ = false;
bool prev_bus_detection_ = false;
Panda *panda_;
Params params_;
};