Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into deprecate-cs-events
Browse files Browse the repository at this point in the history
  • Loading branch information
sshane committed Oct 2, 2024
2 parents c70148c + 9cbd341 commit 82417e6
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 3 deletions.
2 changes: 2 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ def deviceStage(String stageName, String deviceType, List extra_env, def steps)
docker.image('ghcr.io/commaai/alpine-ssh').inside('--user=root') {
timeout(time: 35, unit: 'MINUTES') {
retry (3) {
def date = sh(script: 'date', returnStdout: true).trim();
device(device_ip, "set time", "date -s '" + date + "'")
device(device_ip, "git checkout", extra + "\n" + readFile("selfdrive/test/setup_device_ci.sh"))
}
steps.each { item ->
Expand Down
4 changes: 4 additions & 0 deletions cereal/car.capnp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ struct OnroadEvent @0x9b1657f34caf3ad3 {
startup @75;
startupNoCar @76;
startupNoControl @77;
startupNoSecOcKey @125;
startupMaster @78;
fcw @79;
steerSaturated @80;
Expand Down Expand Up @@ -517,6 +518,9 @@ struct CarParams {

wheelSpeedFactor @63 :Float32; # Multiplier on wheels speeds to computer actual speeds

secOcRequired @75 :Bool; # Car requires SecOC message authentication to operate
secOcKeyAvailable @76 :Bool; # Stored SecOC key loaded from params

struct SafetyConfig {
safetyModel @0 :SafetyModel;
safetyParam @3 :UInt16;
Expand Down
1 change: 1 addition & 0 deletions common/params.cc
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ std::unordered_map<std::string, uint32_t> keys = {
{"PrimeType", PERSISTENT},
{"RecordFront", PERSISTENT},
{"RecordFrontLock", PERSISTENT}, // for the internal fleet
{"SecOCKey", PERSISTENT | DONT_LOG},
{"RouteCount", PERSISTENT},
{"SnoozeUpdate", CLEAR_ON_MANAGER_START | CLEAR_ON_OFFROAD_TRANSITION},
{"SshEnabled", PERSISTENT},
Expand Down
2 changes: 1 addition & 1 deletion opendbc_repo
12 changes: 12 additions & 0 deletions selfdrive/car/card.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,18 @@ def __init__(self, CI=None, RI=None) -> None:
safety_config.safetyModel = structs.CarParams.SafetyModel.noOutput
self.CP.safetyConfigs = [safety_config]

if self.CP.secOcRequired and not self.params.get_bool("IsReleaseBranch"):
secoc_key = self.params.get("SecOCKey", encoding='utf8')
if secoc_key is not None:
saved_secoc_key = bytes.fromhex(secoc_key.strip())
if len(saved_secoc_key) == 16:
self.CP.secOcKeyAvailable = True
self.CI.CS.secoc_key = saved_secoc_key
if controller_available:
self.CI.CC.secoc_key = saved_secoc_key
else:
cloudlog.warning("Saved SecOC key is invalid")

# Write previous route's CarParams
prev_cp = self.params.get("CarParamsPersistent")
if prev_cp is not None:
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/controls/controlsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def state_control(self):
CC.enabled = self.sm['selfdriveState'].enabled

# Check which actuators can be enabled
standstill = CS.vEgo <= max(self.CP.minSteerSpeed, MIN_LATERAL_CONTROL_SPEED) or CS.standstill
standstill = abs(CS.vEgo) <= max(self.CP.minSteerSpeed, MIN_LATERAL_CONTROL_SPEED) or CS.standstill
CC.latActive = self.sm['selfdriveState'].active and not CS.steerFaultTemporary and not CS.steerFaultPermanent and not standstill
CC.longActive = CC.enabled and not any(e.overrideLongitudinal for e in self.sm['onroadEvents']) and self.CP.openpilotLongitudinalControl

Expand Down
6 changes: 6 additions & 0 deletions selfdrive/selfdrived/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,12 @@ def personality_changed_alert(CP: car.CarParams, CS: car.CarState, sm: messaging
ET.PERMANENT: StartupAlert("Dashcam mode for unsupported car"),
},

EventName.startupNoSecOcKey: {
ET.PERMANENT: NormalPermanentAlert("Dashcam Mode",
"Security Key Not Available",
priority=Priority.HIGH),
},

EventName.dashcamMode: {
ET.PERMANENT: NormalPermanentAlert("Dashcam Mode",
priority=Priority.LOWEST),
Expand Down
4 changes: 3 additions & 1 deletion selfdrive/selfdrived/selfdrived.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ def __init__(self):
self.startup_event = EventName.startupNoCar
elif car_recognized and self.CP.passive:
self.startup_event = EventName.startupNoControl
elif self.CP.secOcRequired and not self.CP.secOcKeyAvailable:
self.startup_event = EventName.startupNoSecOcKey

if not sounds_available:
self.events.add(EventName.soundsUnavailable, static=True)
Expand Down Expand Up @@ -338,7 +340,7 @@ def update_events(self, CS):
self.events.add(EventName.noGps)
if gps_ok:
self.distance_traveled = 0
self.distance_traveled += CS.vEgo * DT_CTRL
self.distance_traveled += abs(CS.vEgo) * DT_CTRL

if self.sm['modelV2'].frameDropPerc > 20:
self.events.add(EventName.modeldLagging)
Expand Down

0 comments on commit 82417e6

Please sign in to comment.