From 7973ba4492b943aab93c4116cb98155c7fd03765 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Wed, 10 Sep 2025 20:00:41 -0700 Subject: [PATCH] CAN driver cleanup (#2276) * it's all the same thing * not live * less macro * lil more * bool * lil more --- board/can.h | 23 ++++++++++++++++--- board/can_declarations.h | 24 -------------------- board/drivers/can_common.h | 25 +++++++++------------ board/drivers/can_common_declarations.h | 30 +++++-------------------- board/drivers/fdcan.h | 15 +++++-------- board/drivers/fdcan_declarations.h | 11 ++------- board/faults_declarations.h | 10 --------- board/jungle/main.c | 2 +- board/jungle/main_comms.h | 6 ++--- board/main.c | 15 ++++--------- board/main_comms.h | 12 +++------- python/__init__.py | 6 ++--- tests/libpanda/SConscript | 2 +- tests/misra/test_mutation.py | 2 +- 14 files changed, 59 insertions(+), 124 deletions(-) delete mode 100644 board/can_declarations.h diff --git a/board/can.h b/board/can.h index 9b120038..952f4aab 100644 --- a/board/can.h +++ b/board/can.h @@ -1,7 +1,24 @@ #pragma once -#include "can_declarations.h" -static const uint8_t PANDA_CAN_CNT = 3U; -static const uint8_t PANDA_BUS_CNT = 3U; +#define PANDA_CAN_CNT 3U static const unsigned char dlc_to_len[] = {0U, 1U, 2U, 3U, 4U, 5U, 6U, 7U, 8U, 12U, 16U, 20U, 24U, 32U, 48U, 64U}; + +#define CANPACKET_HEAD_SIZE 6U // non-data portion of CANPacket_t +#define CANPACKET_DATA_SIZE_MAX 64U + +// bump this when changing the CAN packet +#define CAN_PACKET_VERSION 4 +typedef struct { + unsigned char fd : 1; + unsigned char bus : 3; + unsigned char data_len_code : 4; // lookup length with dlc_to_len + unsigned char rejected : 1; + unsigned char returned : 1; + unsigned char extended : 1; + unsigned int addr : 29; + unsigned char checksum; + unsigned char data[CANPACKET_DATA_SIZE_MAX]; +} __attribute__((packed, aligned(4))) CANPacket_t; + +#define GET_LEN(msg) (dlc_to_len[(msg)->data_len_code]) diff --git a/board/can_declarations.h b/board/can_declarations.h deleted file mode 100644 index 96135e04..00000000 --- a/board/can_declarations.h +++ /dev/null @@ -1,24 +0,0 @@ -#pragma once - -// bump this when changing the CAN packet -#define CAN_PACKET_VERSION 4 - -#define CANPACKET_HEAD_SIZE 6U - -#define CANPACKET_DATA_SIZE_MAX 64U - -typedef struct { - unsigned char fd : 1; - unsigned char bus : 3; - unsigned char data_len_code : 4; // lookup length with dlc_to_len - unsigned char rejected : 1; - unsigned char returned : 1; - unsigned char extended : 1; - unsigned int addr : 29; - unsigned char checksum; - unsigned char data[CANPACKET_DATA_SIZE_MAX]; -} __attribute__((packed, aligned(4))) CANPacket_t; - -#define GET_BUS(msg) ((msg)->bus) -#define GET_LEN(msg) (dlc_to_len[(msg)->data_len_code]) -#define GET_ADDR(msg) ((msg)->addr) diff --git a/board/drivers/can_common.h b/board/drivers/can_common.h index 23bc90f3..e5dffa52 100644 --- a/board/drivers/can_common.h +++ b/board/drivers/can_common.h @@ -5,15 +5,13 @@ uint32_t safety_rx_invalid = 0; uint32_t tx_buffer_overflow = 0; uint32_t rx_buffer_overflow = 0; -can_health_t can_health[CAN_HEALTH_ARRAY_SIZE] = {{0}, {0}, {0}}; +can_health_t can_health[PANDA_CAN_CNT] = {{0}, {0}, {0}}; // Ignition detected from CAN meessages bool ignition_can = false; uint32_t ignition_can_cnt = 0U; -int can_live = 0; -int pending_can_live = 0; -int can_silent = ALL_CAN_SILENT; +bool can_silent = true; bool can_loopback = false; // ********************* instantiate queues ********************* @@ -39,7 +37,7 @@ can_buffer(tx3_q, CAN_TX_BUFFER_SIZE) // FIXME: // cppcheck-suppress misra-c2012-9.3 -can_ring *can_queues[CAN_QUEUES_ARRAY_SIZE] = {&can_tx1_q, &can_tx2_q, &can_tx3_q}; +can_ring *can_queues[PANDA_CAN_CNT] = {&can_tx1_q, &can_tx2_q, &can_tx3_q}; // ********************* interrupt safe queue ********************* bool can_pop(can_ring *q, CANPacket_t *elem) { @@ -130,11 +128,10 @@ void can_clear(can_ring *q) { // Helpers // Panda: Bus 0=CAN1 Bus 1=CAN2 Bus 2=CAN3 -bus_config_t bus_config[BUS_CONFIG_ARRAY_SIZE] = { +bus_config_t bus_config[PANDA_CAN_CNT] = { { .bus_lookup = 0U, .can_num_lookup = 0U, .forwarding_bus = -1, .can_speed = 5000U, .can_data_speed = 20000U, .canfd_auto = false, .canfd_enabled = false, .brs_enabled = false, .canfd_non_iso = false }, { .bus_lookup = 1U, .can_num_lookup = 1U, .forwarding_bus = -1, .can_speed = 5000U, .can_data_speed = 20000U, .canfd_auto = false, .canfd_enabled = false, .brs_enabled = false, .canfd_non_iso = false }, { .bus_lookup = 2U, .can_num_lookup = 2U, .forwarding_bus = -1, .can_speed = 5000U, .can_data_speed = 20000U, .canfd_auto = false, .canfd_enabled = false, .brs_enabled = false, .canfd_non_iso = false }, - { .bus_lookup = 0xFFU, .can_num_lookup = 0xFFU, .forwarding_bus = -1, .can_speed = 333U, .can_data_speed = 333U, .canfd_auto = false, .canfd_enabled = false, .brs_enabled = false, .canfd_non_iso = false }, }; void can_init_all(void) { @@ -158,20 +155,18 @@ void can_set_forwarding(uint8_t from, uint8_t to) { #endif void ignition_can_hook(CANPacket_t *msg) { - int bus = GET_BUS(msg); - if (bus == 0) { - int addr = GET_ADDR(msg); + if (msg->bus == 0U) { int len = GET_LEN(msg); // GM exception - if ((addr == 0x1F1) && (len == 8)) { + if ((msg->addr == 0x1F1U) && (len == 8)) { // SystemPowerMode (2=Run, 3=Crank Request) ignition_can = (msg->data[0] & 0x2U) != 0U; ignition_can_cnt = 0U; } // Rivian R1S/T GEN1 exception - if ((addr == 0x152) && (len == 8)) { + if ((msg->addr == 0x152U) && (len == 8)) { // 0x152 overlaps with Subaru pre-global which has this bit as the high beam int counter = msg->data[1] & 0xFU; // max is only 14 @@ -185,7 +180,7 @@ void ignition_can_hook(CANPacket_t *msg) { } // Tesla Model 3/Y exception - if ((addr == 0x221) && (len == 8)) { + if ((msg->addr == 0x221U) && (len == 8)) { // 0x221 overlaps with Rivian which has random data on byte 0 int counter = msg->data[6] >> 4; @@ -200,7 +195,7 @@ void ignition_can_hook(CANPacket_t *msg) { } // Mazda exception - if ((addr == 0x9E) && (len == 8)) { + if ((msg->addr == 0x9EU) && (len == 8)) { ignition_can = (msg->data[0] >> 5) == 0x6U; ignition_can_cnt = 0U; } @@ -234,7 +229,7 @@ bool can_check_checksum(CANPacket_t *packet) { void can_send(CANPacket_t *to_push, uint8_t bus_number, bool skip_tx_hook) { if (skip_tx_hook || safety_tx_hook(to_push) != 0) { - if (bus_number < PANDA_BUS_CNT) { + if (bus_number < PANDA_CAN_CNT) { // add CAN packet to send queue tx_buffer_overflow += can_push(can_queues[bus_number], to_push) ? 0U : 1U; process_can(CAN_NUM_FROM_BUS_NUM(bus_number)); diff --git a/board/drivers/can_common_declarations.h b/board/drivers/can_common_declarations.h index 57bf87d9..75580b7b 100644 --- a/board/drivers/can_common_declarations.h +++ b/board/drivers/can_common_declarations.h @@ -1,5 +1,7 @@ #pragma once +#include "board/can.h" + typedef struct { volatile uint32_t w_ptr; volatile uint32_t r_ptr; @@ -24,19 +26,13 @@ extern uint32_t safety_rx_invalid; extern uint32_t tx_buffer_overflow; extern uint32_t rx_buffer_overflow; -#define CAN_HEALTH_ARRAY_SIZE 3 -extern can_health_t can_health[CAN_HEALTH_ARRAY_SIZE]; +extern can_health_t can_health[PANDA_CAN_CNT]; // Ignition detected from CAN meessages extern bool ignition_can; extern uint32_t ignition_can_cnt; -#define ALL_CAN_SILENT 0xFF -#define ALL_CAN_LIVE 0 - -extern int can_live; -extern int pending_can_live; -extern int can_silent; +extern bool can_silent; extern bool can_loopback; // ******************* functions prototypes ********************* @@ -44,8 +40,7 @@ bool can_init(uint8_t can_number); void process_can(uint8_t can_number); // ********************* instantiate queues ********************* -#define CAN_QUEUES_ARRAY_SIZE 3 -extern can_ring *can_queues[CAN_QUEUES_ARRAY_SIZE]; +extern can_ring *can_queues[PANDA_CAN_CNT]; // helpers #define WORD_TO_BYTE_ARRAY(dst8, src32) 0[dst8] = ((src32) & 0xFFU); 1[dst8] = (((src32) >> 8U) & 0xFFU); 2[dst8] = (((src32) >> 16U) & 0xFFU); 3[dst8] = (((src32) >> 24U) & 0xFFU) @@ -55,20 +50,7 @@ extern can_ring *can_queues[CAN_QUEUES_ARRAY_SIZE]; bool can_pop(can_ring *q, CANPacket_t *elem); bool can_push(can_ring *q, const CANPacket_t *elem); uint32_t can_slots_empty(const can_ring *q); - -// assign CAN numbering -// bus num: CAN Bus numbers in panda, sent to/from USB -// Min: 0; Max: 127; Bit 7 marks message as receipt (bus 129 is receipt for but 1) -// cans: Look up MCU can interface from bus number -// can number: numeric lookup for MCU CAN interfaces (0 = CAN1, 1 = CAN2, etc); -// bus_lookup: Translates from 'can number' to 'bus number'. -// can_num_lookup: Translates from 'bus number' to 'can number'. -// forwarding bus: If >= 0, forward all messages from this bus to the specified bus. - -// Helpers -// Panda: Bus 0=CAN1 Bus 1=CAN2 Bus 2=CAN3 -#define BUS_CONFIG_ARRAY_SIZE 4 -extern bus_config_t bus_config[BUS_CONFIG_ARRAY_SIZE]; +extern bus_config_t bus_config[PANDA_CAN_CNT]; #define CANIF_FROM_CAN_NUM(num) (cans[num]) #define BUS_NUM_FROM_CAN_NUM(num) (bus_config[num].bus_lookup) diff --git a/board/drivers/fdcan.h b/board/drivers/fdcan.h index f3f8d997..2aa64e97 100644 --- a/board/drivers/fdcan.h +++ b/board/drivers/fdcan.h @@ -1,6 +1,6 @@ #include "fdcan_declarations.h" -FDCAN_GlobalTypeDef *cans[CANS_ARRAY_SIZE] = {FDCAN1, FDCAN2, FDCAN3}; +FDCAN_GlobalTypeDef *cans[PANDA_CAN_CNT] = {FDCAN1, FDCAN2, FDCAN3}; static bool can_set_speed(uint8_t can_number) { bool ret = true; @@ -13,7 +13,7 @@ static bool can_set_speed(uint8_t can_number) { bus_config[bus_number].can_data_speed, bus_config[bus_number].canfd_non_iso, can_loopback, - (unsigned int)(can_silent) & (1U << can_number) + can_silent ); return ret; } @@ -32,7 +32,7 @@ void can_clear_send(FDCAN_GlobalTypeDef *FDCANx, uint8_t can_number) { } void update_can_health_pkt(uint8_t can_number, uint32_t ir_reg) { - uint8_t can_irq_number[3][2] = { + uint8_t can_irq_number[PANDA_CAN_CNT][2] = { { FDCAN1_IT0_IRQn, FDCAN1_IT1_IRQn }, { FDCAN2_IT0_IRQn, FDCAN2_IT1_IRQn }, { FDCAN3_IT0_IRQn, FDCAN3_IT1_IRQn }, @@ -63,7 +63,6 @@ void update_can_health_pkt(uint8_t can_number, uint32_t ir_reg) { can_health[can_number].irq0_call_rate = interrupts[can_irq_number[can_number][0]].call_rate; can_health[can_number].irq1_call_rate = interrupts[can_irq_number[can_number][1]].call_rate; - if (ir_reg != 0U) { // Clear error interrupts FDCANx->IR |= (FDCAN_IR_PED | FDCAN_IR_PEA | FDCAN_IR_EP | FDCAN_IR_BO | FDCAN_IR_RF0L); @@ -158,17 +157,13 @@ void can_rx(uint8_t can_number) { // Clear all new messages from Rx FIFO 0 FDCANx->IR |= FDCAN_IR_RF0N; - while((FDCANx->RXF0S & FDCAN_RXF0S_F0FL) != 0U) { + while ((FDCANx->RXF0S & FDCAN_RXF0S_F0FL) != 0U) { can_health[can_number].total_rx_cnt += 1U; - - // can is live - pending_can_live = 1; - // get the index of the next RX FIFO element (0 to FDCAN_RX_FIFO_0_EL_CNT - 1) uint32_t rx_fifo_idx = (uint8_t)((FDCANx->RXF0S >> FDCAN_RXF0S_F0GI_Pos) & 0x3FU); // Recommended to offset get index by at least +1 if RX FIFO is in overwrite mode and full (datasheet) - if((FDCANx->RXF0S & FDCAN_RXF0S_F0F) == FDCAN_RXF0S_F0F) { + if ((FDCANx->RXF0S & FDCAN_RXF0S_F0F) == FDCAN_RXF0S_F0F) { rx_fifo_idx = ((rx_fifo_idx + 1U) >= FDCAN_RX_FIFO_0_EL_CNT) ? 0U : (rx_fifo_idx + 1U); can_health[can_number].total_rx_lost_cnt += 1U; // At least one message was lost } diff --git a/board/drivers/fdcan_declarations.h b/board/drivers/fdcan_declarations.h index ffddc2e0..c77d1e31 100644 --- a/board/drivers/fdcan_declarations.h +++ b/board/drivers/fdcan_declarations.h @@ -1,26 +1,19 @@ #pragma once -// IRQs: FDCAN1_IT0, FDCAN1_IT1 -// FDCAN2_IT0, FDCAN2_IT1 -// FDCAN3_IT0, FDCAN3_IT1 +#include "board/can.h" typedef struct { volatile uint32_t header[2]; volatile uint32_t data_word[CANPACKET_DATA_SIZE_MAX/4U]; } canfd_fifo; -#define CANS_ARRAY_SIZE 3 -extern FDCAN_GlobalTypeDef *cans[CANS_ARRAY_SIZE]; +extern FDCAN_GlobalTypeDef *cans[PANDA_CAN_CNT]; #define CAN_ACK_ERROR 3U void can_clear_send(FDCAN_GlobalTypeDef *FDCANx, uint8_t can_number); void update_can_health_pkt(uint8_t can_number, uint32_t ir_reg); -// ***************************** CAN ***************************** -// FDFDCANx_IT1 IRQ Handler (TX) void process_can(uint8_t can_number); -// FDFDCANx_IT0 IRQ Handler (RX and errors) -// blink blue when we are receiving CAN messages void can_rx(uint8_t can_number); bool can_init(uint8_t can_number); diff --git a/board/faults_declarations.h b/board/faults_declarations.h index eab9fcc0..981e2375 100644 --- a/board/faults_declarations.h +++ b/board/faults_declarations.h @@ -11,20 +11,10 @@ #define FAULT_INTERRUPT_RATE_CAN_2 (1UL << 3) #define FAULT_INTERRUPT_RATE_CAN_3 (1UL << 4) #define FAULT_INTERRUPT_RATE_TACH (1UL << 5) -#define FAULT_INTERRUPT_RATE_GMLAN (1UL << 6) // deprecated #define FAULT_INTERRUPT_RATE_INTERRUPTS (1UL << 7) #define FAULT_INTERRUPT_RATE_SPI_DMA (1UL << 8) -#define FAULT_INTERRUPT_RATE_SPI_CS (1UL << 9) -#define FAULT_INTERRUPT_RATE_UART_1 (1UL << 10) -#define FAULT_INTERRUPT_RATE_UART_2 (1UL << 11) -#define FAULT_INTERRUPT_RATE_UART_3 (1UL << 12) -#define FAULT_INTERRUPT_RATE_UART_5 (1UL << 13) -#define FAULT_INTERRUPT_RATE_UART_DMA (1UL << 14) #define FAULT_INTERRUPT_RATE_USB (1UL << 15) -#define FAULT_INTERRUPT_RATE_TIM1 (1UL << 16) -#define FAULT_INTERRUPT_RATE_TIM3 (1UL << 17) #define FAULT_REGISTER_DIVERGENT (1UL << 18) -#define FAULT_INTERRUPT_RATE_KLINE_INIT (1UL << 19) #define FAULT_INTERRUPT_RATE_CLOCK_SOURCE (1UL << 20) #define FAULT_INTERRUPT_RATE_TICK (1UL << 21) #define FAULT_INTERRUPT_RATE_EXTI (1UL << 22) diff --git a/board/jungle/main.c b/board/jungle/main.c index 5127b42e..7bac6d75 100644 --- a/board/jungle/main.c +++ b/board/jungle/main.c @@ -175,7 +175,7 @@ int main(void) { print("**** INTERRUPTS ON ****\n"); enable_interrupts(); - can_silent = ALL_CAN_LIVE; + can_silent = false; set_safety_hooks(SAFETY_ALLOUTPUT, 0U); can_init_all(); diff --git a/board/jungle/main_comms.h b/board/jungle/main_comms.h index b646381d..b19f799a 100644 --- a/board/jungle/main_comms.h +++ b/board/jungle/main_comms.h @@ -189,7 +189,7 @@ int comms_control_handler(ControlPacket_t *req, uint8_t *resp) { break; // **** 0xde: set can bitrate case 0xde: - if ((req->param1 < PANDA_BUS_CNT) && is_speed_valid(req->param2, speeds, sizeof(speeds)/sizeof(speeds[0]))) { + if ((req->param1 < PANDA_CAN_CNT) && is_speed_valid(req->param2, speeds, sizeof(speeds)/sizeof(speeds[0]))) { bus_config[req->param1].can_speed = req->param2; bool ret = can_init(CAN_NUM_FROM_BUS_NUM(req->param1)); UNUSED(ret); @@ -212,7 +212,7 @@ int comms_control_handler(ControlPacket_t *req, uint8_t *resp) { if (req->param1 == 0xFFFFU) { print("Clearing CAN Rx queue\n"); can_clear(&can_rx_q); - } else if (req->param1 < PANDA_BUS_CNT) { + } else if (req->param1 < PANDA_CAN_CNT) { print("Clearing CAN Tx queue\n"); can_clear(can_queues[req->param1]); } else { @@ -225,7 +225,7 @@ int comms_control_handler(ControlPacket_t *req, uint8_t *resp) { break; // **** 0xf5: Set CAN silent mode case 0xf5: - can_silent = (req->param1 > 0U) ? ALL_CAN_SILENT : ALL_CAN_LIVE; + can_silent = (req->param1 > 0U); can_init_all(); break; // **** 0xf7: enable/disable header pin by number diff --git a/board/main.c b/board/main.c index bb20c070..11764d20 100644 --- a/board/main.c +++ b/board/main.c @@ -55,12 +55,12 @@ void set_safety_mode(uint16_t mode, uint16_t param) { case SAFETY_SILENT: set_intercept_relay(false, false); current_board->set_can_mode(CAN_MODE_NORMAL); - can_silent = ALL_CAN_SILENT; + can_silent = true; break; case SAFETY_NOOUTPUT: set_intercept_relay(false, false); current_board->set_can_mode(CAN_MODE_NORMAL); - can_silent = ALL_CAN_LIVE; + can_silent = false; break; case SAFETY_ELM327: set_intercept_relay(false, false); @@ -75,14 +75,14 @@ void set_safety_mode(uint16_t mode, uint16_t param) { } else { current_board->set_can_mode(CAN_MODE_NORMAL); } - can_silent = ALL_CAN_LIVE; + can_silent = false; break; default: set_intercept_relay(true, false); heartbeat_counter = 0U; heartbeat_lost = false; current_board->set_can_mode(CAN_MODE_NORMAL); - can_silent = ALL_CAN_LIVE; + can_silent = false; break; } can_init_all(); @@ -143,14 +143,7 @@ static void tick_handler(void) { // decimated to 1Hz if (loop_counter == 0U) { - can_live = pending_can_live; - //puth(usart1_dma); print(" "); puth(DMA2_Stream5->M0AR); print(" "); puth(DMA2_Stream5->NDTR); print("\n"); - - // reset this every 16th pass - if ((uptime_cnt & 0xFU) == 0U) { - pending_can_live = 0; - } #ifdef DEBUG print("** blink "); print("rx:"); puth4(can_rx_q.r_ptr); print("-"); puth4(can_rx_q.w_ptr); print(" "); diff --git a/board/main_comms.h b/board/main_comms.h index 5ea01ef1..ce61f625 100644 --- a/board/main_comms.h +++ b/board/main_comms.h @@ -210,13 +210,7 @@ int comms_control_handler(ControlPacket_t *req, uint8_t *resp) { break; // **** 0xdb: set OBD CAN multiplexing mode case 0xdb: - if (req->param1 == 1U) { - // Enable OBD CAN - current_board->set_can_mode(CAN_MODE_OBD_CAN2); - } else { - // Disable OBD CAN - current_board->set_can_mode(CAN_MODE_NORMAL); - } + current_board->set_can_mode((req->param1 == 1U) ? CAN_MODE_OBD_CAN2 : CAN_MODE_NORMAL); break; // **** 0xdc: set safety mode case 0xdc: @@ -231,7 +225,7 @@ int comms_control_handler(ControlPacket_t *req, uint8_t *resp) { break; // **** 0xde: set can bitrate case 0xde: - if ((req->param1 < PANDA_BUS_CNT) && is_speed_valid(req->param2, speeds, sizeof(speeds)/sizeof(speeds[0]))) { + if ((req->param1 < PANDA_CAN_CNT) && is_speed_valid(req->param2, speeds, sizeof(speeds)/sizeof(speeds[0]))) { bus_config[req->param1].can_speed = req->param2; bool ret = can_init(CAN_NUM_FROM_BUS_NUM(req->param1)); UNUSED(ret); @@ -280,7 +274,7 @@ int comms_control_handler(ControlPacket_t *req, uint8_t *resp) { if (req->param1 == 0xFFFFU) { print("Clearing CAN Rx queue\n"); can_clear(&can_rx_q); - } else if (req->param1 < PANDA_BUS_CNT) { + } else if (req->param1 < PANDA_CAN_CNT) { print("Clearing CAN Tx queue\n"); can_clear(can_queues[req->param1]); } else { diff --git a/python/__init__.py b/python/__init__.py index 0b979d18..c40c5c4e 100644 --- a/python/__init__.py +++ b/python/__init__.py @@ -23,7 +23,7 @@ __version__ = '0.0.10' CANPACKET_HEAD_SIZE = 0x6 DLC_TO_LEN = [0, 1, 2, 3, 4, 5, 6, 7, 8, 12, 16, 20, 24, 32, 48, 64] LEN_TO_DLC = {length: dlc for (dlc, length) in enumerate(DLC_TO_LEN)} -PANDA_BUS_CNT = 3 +PANDA_CAN_CNT = 3 def calculate_checksum(data): @@ -225,11 +225,11 @@ class Panda: self.can_reset_communications() # disable automatic CAN-FD switching - for bus in range(PANDA_BUS_CNT): + for bus in range(PANDA_CAN_CNT): self.set_canfd_auto(bus, False) # set CAN speed - for bus in range(PANDA_BUS_CNT): + for bus in range(PANDA_CAN_CNT): self.set_can_speed_kbps(bus, self._can_speed_kbps) @property diff --git a/tests/libpanda/SConscript b/tests/libpanda/SConscript index fc680723..c643a62a 100644 --- a/tests/libpanda/SConscript +++ b/tests/libpanda/SConscript @@ -21,7 +21,7 @@ env = Environment( '-Wfatal-errors', '-Wno-pointer-to-int-cast', ], - CPPPATH=[".", "../../board/", opendbc.INCLUDE_PATH], + CPPPATH=[".", "#", "../../board/", opendbc.INCLUDE_PATH], ) if system == "Darwin": env.PrependENVPath('PATH', '/opt/homebrew/bin') diff --git a/tests/misra/test_mutation.py b/tests/misra/test_mutation.py index 0d53026a..762ab852 100755 --- a/tests/misra/test_mutation.py +++ b/tests/misra/test_mutation.py @@ -53,7 +53,7 @@ patterns = [ all_files = glob.glob('board/**', root_dir=ROOT, recursive=True) files = [f for f in all_files if f.endswith(('.c', '.h')) and not f.startswith(IGNORED_PATHS)] -assert len(files) > 70, all(d in files for d in ('board/main.c', 'board/stm32h7/llfdcan.h')) +assert len(files) > 50, all(d in files for d in ('board/main.c', 'board/stm32h7/llfdcan.h')) for p in patterns: mutations.append((random.choice(files), p, True))