From 8ee7b62ea2f46efa62d8227898f49b046e2dce57 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Tue, 25 Jan 2022 02:35:57 -0800 Subject: [PATCH] Add unsafe mode to health packet (#829) * add unsafe_mode to health packet this compiles update health packet fixes ahh forgot to set it! not actually needed update indices * fix struct Co-authored-by: Willem Melching --- board/usb_comms.h | 4 +++- python/__init__.py | 7 ++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/board/usb_comms.h b/board/usb_comms.h index 5b287c91..84d284a3 100644 --- a/board/usb_comms.h +++ b/board/usb_comms.h @@ -3,7 +3,7 @@ extern int _app_start[0xc000]; // Only first 3 sectors of size 0x4000 are used // When changing this struct, boardd and python/__init__.py needs to be kept up to date! -#define HEALTH_PACKET_VERSION 1 +#define HEALTH_PACKET_VERSION 2 struct __attribute__((packed)) health_t { uint32_t uptime_pkt; uint32_t voltage_pkt; @@ -24,6 +24,7 @@ struct __attribute__((packed)) health_t { uint8_t fault_status_pkt; uint8_t power_save_enabled_pkt; uint8_t heartbeat_lost_pkt; + int16_t unsafe_mode_pkt; }; // Prototypes @@ -52,6 +53,7 @@ int get_health_pkt(void *dat) { health->usb_power_mode_pkt = usb_power_mode; health->safety_mode_pkt = (uint8_t)(current_safety_mode); health->safety_param_pkt = current_safety_param; + health->unsafe_mode_pkt = unsafe_mode; health->power_save_enabled_pkt = (uint8_t)(power_save_status == POWER_SAVE_STATUS_ENABLED); health->heartbeat_lost_pkt = (uint8_t)(heartbeat_lost); diff --git a/python/__init__.py b/python/__init__.py index d71cf39f..6804d7a7 100644 --- a/python/__init__.py +++ b/python/__init__.py @@ -160,7 +160,7 @@ class Panda(object): HW_TYPE_RED_PANDA = b'\x07' CAN_PACKET_VERSION = 2 - HEALTH_PACKET_VERSION = 1 + HEALTH_PACKET_VERSION = 2 F2_DEVICES = [HW_TYPE_PEDAL] F4_DEVICES = [HW_TYPE_WHITE_PANDA, HW_TYPE_GREY_PANDA, HW_TYPE_BLACK_PANDA, HW_TYPE_UNO, HW_TYPE_DOS] @@ -353,8 +353,8 @@ class Panda(object): @ensure_health_packet_version def health(self): - dat = self._handle.controlRead(Panda.REQUEST_IN, 0xd2, 0, 0, 44) - a = struct.unpack("