Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions board/health.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ struct __attribute__((packed)) health_t {
uint16_t sbu2_voltage_mV;
uint8_t som_reset_triggered;
uint16_t sound_output_level_pkt;
uint8_t controls_allowed_lateral_pkt;
};

typedef struct __attribute__((packed)) {
Expand Down
5 changes: 5 additions & 0 deletions board/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,11 @@ static void tick_handler(void) {
heartbeat_engaged_mismatches = 0U;
}

// MADS lateral authorization has the same heartbeat fail-safe as normal controls.
if (controls_allowed_lateral && !heartbeat_engaged) {
controls_allowed_lateral = false;
}

if (!heartbeat_disabled) {
// if the heartbeat has been gone for a while, go to SILENT safety mode and enter power save
if (heartbeat_counter >= (started ? HEARTBEAT_IGNITION_CNT_ON : HEARTBEAT_IGNITION_CNT_OFF)) {
Expand Down
4 changes: 4 additions & 0 deletions board/main_comms.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ static int get_health_pkt(void *dat) {
health->ignition_can_pkt = ignition_can;

health->controls_allowed_pkt = controls_allowed;
health->controls_allowed_lateral_pkt = controls_allowed_lateral;
health->safety_tx_blocked_pkt = safety_tx_blocked;
health->safety_rx_invalid_pkt = safety_rx_invalid;
health->tx_buffer_overflow_pkt = tx_buffer_overflow;
Expand Down Expand Up @@ -298,6 +299,9 @@ int comms_control_handler(ControlPacket_t *req, uint8_t *resp) {
heartbeat_lost = false;
heartbeat_disabled = false;
heartbeat_engaged = (req->param1 == 1U);
if (!heartbeat_engaged) {
controls_allowed_lateral = false;
}
break;
}
// **** 0xf6: set siren enabled
Expand Down
1 change: 1 addition & 0 deletions python/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,7 @@ def health(self):
"sbu2_voltage_mV": a[23],
"som_reset_triggered": a[24],
"sound_output_level": a[25],
"controls_allowed_lateral": a[26],
}

@ensure_health_packet_version
Expand Down
Loading