Skip to content

Commit

Permalink
update unsafeMode to alternativeExperience (commaai#23995)
Browse files Browse the repository at this point in the history
* update unsafeMode to alternativeExperience

* fix

* fix

* bump submodules

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
# Conflicts:
#	cereal
#	panda
  • Loading branch information
sshane authored and budney committed Mar 28, 2022
1 parent 0012d15 commit 33466e4
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion cereal
Submodule cereal updated 5 files
+1 −1 car.capnp
+0 −287 legacy.capnp
+290 −2 log.capnp
+5 −5 messaging/__init__.py
+1 −0 services.py
8 changes: 4 additions & 4 deletions selfdrive/boardd/boardd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ bool safety_setter_thread(std::vector<Panda *> pandas) {
int safety_param;

auto safety_configs = car_params.getSafetyConfigs();
uint16_t unsafe_mode = car_params.getUnsafeMode();
uint16_t alternative_experience = car_params.getAlternativeExperience();
for (uint32_t i = 0; i < pandas.size(); i++) {
auto panda = pandas[i];

Expand All @@ -174,8 +174,8 @@ bool safety_setter_thread(std::vector<Panda *> pandas) {
safety_param = 0;
}

LOGW("panda %d: setting safety model: %d, param: %d, unsafe mode: %d", i, (int)safety_model, safety_param, unsafe_mode);
panda->set_unsafe_mode(unsafe_mode);
LOGW("panda %d: setting safety model: %d, param: %d, alternative experience: %d", i, (int)safety_model, safety_param, alternative_experience);
panda->set_alternative_experience(alternative_experience);
panda->set_safety_model(safety_model, safety_param);
}

Expand Down Expand Up @@ -362,7 +362,7 @@ std::optional<bool> send_panda_states(PubMaster *pm, const std::vector<Panda *>
ps.setFaultStatus(cereal::PandaState::FaultStatus(health.fault_status_pkt));
ps.setPowerSaveEnabled((bool)(health.power_save_enabled_pkt));
ps.setHeartbeatLost((bool)(health.heartbeat_lost_pkt));
ps.setUnsafeMode(health.unsafe_mode_pkt);
ps.setAlternativeExperience(health.alternative_experience_pkt);
ps.setHarnessStatus(cereal::PandaState::HarnessStatus(health.car_harness_status_pkt));

// Convert faults bitset to capnp list
Expand Down
4 changes: 2 additions & 2 deletions selfdrive/boardd/panda.cc
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,8 @@ void Panda::set_safety_model(cereal::CarParams::SafetyModel safety_model, int sa
usb_write(0xdc, (uint16_t)safety_model, safety_param);
}

void Panda::set_unsafe_mode(uint16_t unsafe_mode) {
usb_write(0xdf, unsafe_mode, 0);
void Panda::set_alternative_experience(uint16_t alternative_experience) {
usb_write(0xdf, alternative_experience, 0);
}

cereal::PandaState::PandaType Panda::get_hw_type() {
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/boardd/panda.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class Panda {
// Panda functionality
cereal::PandaState::PandaType get_hw_type();
void set_safety_model(cereal::CarParams::SafetyModel safety_model, int safety_param=0);
void set_unsafe_mode(uint16_t unsafe_mode);
void set_alternative_experience(uint16_t alternative_experience);
void set_rtc(struct tm sys_time);
struct tm get_rtc();
void set_fan_speed(uint16_t fan_speed);
Expand Down
4 changes: 2 additions & 2 deletions selfdrive/controls/controlsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def __init__(self, sm=None, pm=None, can_sock=None):
get_one_can(self.can_sock)

self.CI, self.CP = get_car(self.can_sock, self.pm.sock['sendcan'])
self.CP.unsafeMode = 0 # see panda/board/safety_declarations.h for allowed values
self.CP.alternativeExperience = 0 # see panda/board/safety_declarations.h for allowed values

# read params
self.is_metric = params.get_bool("IsMetric")
Expand Down Expand Up @@ -260,7 +260,7 @@ def update_events(self, CS):
if i < len(self.CP.safetyConfigs):
safety_mismatch = pandaState.safetyModel != self.CP.safetyConfigs[i].safetyModel or \
pandaState.safetyParam != self.CP.safetyConfigs[i].safetyParam or \
pandaState.unsafeMode != self.CP.unsafeMode
pandaState.alternativeExperience != self.CP.alternativeExperience
else:
safety_mismatch = pandaState.safetyModel not in IGNORED_SAFETY_MODES

Expand Down

0 comments on commit 33466e4

Please sign in to comment.