From 59ede3fe6183c5cfaa91d90df6ef8f852a71fa18 Mon Sep 17 00:00:00 2001 From: Igor Biletskyy Date: Fri, 16 Sep 2022 20:39:18 -0700 Subject: [PATCH] CAN health packet: add speed and canfd info (#1071) in --- board/can_health.h | 6 +++++- board/main_comms.h | 4 ++++ python/__init__.py | 8 ++++++-- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/board/can_health.h b/board/can_health.h index 45e0f006..b0bbbc50 100644 --- a/board/can_health.h +++ b/board/can_health.h @@ -1,5 +1,5 @@ // When changing this struct, python/__init__.py needs to be kept up to date! -#define CAN_HEALTH_PACKET_VERSION 1 +#define CAN_HEALTH_PACKET_VERSION 2 typedef struct __attribute__((packed)) { uint8_t bus_off; uint32_t bus_off_cnt; @@ -17,4 +17,8 @@ typedef struct __attribute__((packed)) { uint32_t total_tx_cnt; uint32_t total_rx_cnt; uint32_t total_fwd_cnt; // Messages forwarded from one bus to another + uint16_t can_speed; + uint16_t can_data_speed; + uint8_t canfd_enabled; + uint8_t brs_enabled; } can_health_t; diff --git a/board/main_comms.h b/board/main_comms.h index 1562293a..7da17cab 100644 --- a/board/main_comms.h +++ b/board/main_comms.h @@ -251,6 +251,10 @@ int comms_control_handler(ControlPacket_t *req, uint8_t *resp) { case 0xc2: COMPILE_TIME_ASSERT(sizeof(can_health_t) <= USBPACKET_MAX_SIZE); if (req->param1 < 3U) { + can_health[req->param1].can_speed = (bus_config[req->param1].can_speed / 10U); + can_health[req->param1].can_data_speed = (bus_config[req->param1].can_data_speed / 10U); + can_health[req->param1].canfd_enabled = bus_config[req->param1].canfd_enabled; + can_health[req->param1].brs_enabled = bus_config[req->param1].brs_enabled; resp_len = sizeof(can_health[req->param1]); (void)memcpy(resp, &can_health[req->param1], resp_len); } diff --git a/python/__init__.py b/python/__init__.py index 984b93f2..2b35ceb6 100644 --- a/python/__init__.py +++ b/python/__init__.py @@ -186,9 +186,9 @@ class Panda: CAN_PACKET_VERSION = 2 HEALTH_PACKET_VERSION = 10 - CAN_HEALTH_PACKET_VERSION = 1 + CAN_HEALTH_PACKET_VERSION = 2 HEALTH_STRUCT = struct.Struct("