diff --git a/board/health.h b/board/health.h index 359061dc..82c476e9 100644 --- a/board/health.h +++ b/board/health.h @@ -1,5 +1,5 @@ // When changing this struct, python/__init__.py needs to be kept up to date! -#define HEALTH_PACKET_VERSION 6 +#define HEALTH_PACKET_VERSION 7 struct __attribute__((packed)) health_t { uint32_t uptime_pkt; uint32_t voltage_pkt; @@ -16,7 +16,7 @@ struct __attribute__((packed)) health_t { uint8_t car_harness_status_pkt; uint8_t usb_power_mode_pkt; uint8_t safety_mode_pkt; - uint32_t safety_param_pkt; + uint16_t safety_param_pkt; uint8_t fault_status_pkt; uint8_t power_save_enabled_pkt; uint8_t heartbeat_lost_pkt; diff --git a/board/main.c b/board/main.c index 010d726b..27d32a53 100644 --- a/board/main.c +++ b/board/main.c @@ -69,7 +69,7 @@ void debug_ring_callback(uart_ring *ring) { // ****************************** safety mode ****************************** // this is the only way to leave silent mode -void set_safety_mode(uint16_t mode, uint32_t param) { +void set_safety_mode(uint16_t mode, uint16_t param) { uint16_t mode_copy = mode; int err = set_safety_hooks(mode_copy, param); if (err == -1) { diff --git a/board/safety.h b/board/safety.h index 2e4d20c4..873a2da5 100644 --- a/board/safety.h +++ b/board/safety.h @@ -45,7 +45,7 @@ #define SAFETY_BODY 27U uint16_t current_safety_mode = SAFETY_SILENT; -uint32_t current_safety_param = 0; +uint16_t current_safety_param = 0; const safety_hooks *current_hooks = &nooutput_hooks; const addr_checks *current_rx_checks = &default_rx_checks; @@ -262,7 +262,7 @@ const safety_hook_config safety_hook_registry[] = { #endif }; -int set_safety_hooks(uint16_t mode, uint32_t param) { +int set_safety_hooks(uint16_t mode, uint16_t param) { // reset state set by safety mode safety_mode_cnt = 0U; relay_malfunction = false; diff --git a/board/safety/safety_body.h b/board/safety/safety_body.h index e8745f53..5b382e76 100644 --- a/board/safety/safety_body.h +++ b/board/safety/safety_body.h @@ -31,7 +31,7 @@ static int body_tx_hook(CANPacket_t *to_send, bool longitudinal_allowed) { return tx; } -static const addr_checks* body_init(uint32_t param) { +static const addr_checks* body_init(uint16_t param) { UNUSED(param); controls_allowed = false; relay_malfunction_reset(); diff --git a/board/safety/safety_chrysler.h b/board/safety/safety_chrysler.h index 7d40124b..74eb2226 100644 --- a/board/safety/safety_chrysler.h +++ b/board/safety/safety_chrysler.h @@ -196,7 +196,7 @@ static int chrysler_fwd_hook(int bus_num, CANPacket_t *to_fwd) { return bus_fwd; } -static const addr_checks* chrysler_init(uint32_t param) { +static const addr_checks* chrysler_init(uint16_t param) { UNUSED(param); controls_allowed = false; relay_malfunction_reset(); diff --git a/board/safety/safety_defaults.h b/board/safety/safety_defaults.h index 5ae108de..c52432d2 100644 --- a/board/safety/safety_defaults.h +++ b/board/safety/safety_defaults.h @@ -10,7 +10,7 @@ int default_rx_hook(CANPacket_t *to_push) { // *** no output safety mode *** -static const addr_checks* nooutput_init(uint32_t param) { +static const addr_checks* nooutput_init(uint16_t param) { UNUSED(param); controls_allowed = false; relay_malfunction_reset(); @@ -50,7 +50,7 @@ const safety_hooks nooutput_hooks = { const uint16_t ALLOUTPUT_PARAM_PASSTHROUGH = 1; bool alloutput_passthrough = false; -static const addr_checks* alloutput_init(uint32_t param) { +static const addr_checks* alloutput_init(uint16_t param) { alloutput_passthrough = GET_FLAG(param, ALLOUTPUT_PARAM_PASSTHROUGH); controls_allowed = true; relay_malfunction_reset(); diff --git a/board/safety/safety_gm.h b/board/safety/safety_gm.h index d9695acb..53bf05d7 100644 --- a/board/safety/safety_gm.h +++ b/board/safety/safety_gm.h @@ -219,7 +219,7 @@ static int gm_tx_hook(CANPacket_t *to_send, bool longitudinal_allowed) { return tx; } -static const addr_checks* gm_init(uint32_t param) { +static const addr_checks* gm_init(uint16_t param) { UNUSED(param); controls_allowed = false; relay_malfunction_reset(); diff --git a/board/safety/safety_honda.h b/board/safety/safety_honda.h index 8f136bbf..e5a0bda7 100644 --- a/board/safety/safety_honda.h +++ b/board/safety/safety_honda.h @@ -362,7 +362,7 @@ static int honda_tx_hook(CANPacket_t *to_send, bool longitudinal_allowed) { return tx; } -static const addr_checks* honda_nidec_init(uint32_t param) { +static const addr_checks* honda_nidec_init(uint16_t param) { controls_allowed = false; relay_malfunction_reset(); gas_interceptor_detected = 0; @@ -378,7 +378,7 @@ static const addr_checks* honda_nidec_init(uint32_t param) { return &honda_rx_checks; } -static const addr_checks* honda_bosch_init(uint32_t param) { +static const addr_checks* honda_bosch_init(uint16_t param) { controls_allowed = false; relay_malfunction_reset(); honda_hw = HONDA_BOSCH; diff --git a/board/safety/safety_hyundai.h b/board/safety/safety_hyundai.h index d1a9e689..69ae74d2 100644 --- a/board/safety/safety_hyundai.h +++ b/board/safety/safety_hyundai.h @@ -377,7 +377,7 @@ static int hyundai_fwd_hook(int bus_num, CANPacket_t *to_fwd) { return bus_fwd; } -static const addr_checks* hyundai_init(uint32_t param) { +static const addr_checks* hyundai_init(uint16_t param) { controls_allowed = false; relay_malfunction_reset(); @@ -398,7 +398,7 @@ static const addr_checks* hyundai_init(uint32_t param) { return &hyundai_rx_checks; } -static const addr_checks* hyundai_legacy_init(uint32_t param) { +static const addr_checks* hyundai_legacy_init(uint16_t param) { controls_allowed = false; relay_malfunction_reset(); diff --git a/board/safety/safety_mazda.h b/board/safety/safety_mazda.h index 24f05f25..6e77d914 100644 --- a/board/safety/safety_mazda.h +++ b/board/safety/safety_mazda.h @@ -173,7 +173,7 @@ static int mazda_fwd_hook(int bus, CANPacket_t *to_fwd) { return bus_fwd; } -static const addr_checks* mazda_init(uint32_t param) { +static const addr_checks* mazda_init(uint16_t param) { UNUSED(param); controls_allowed = false; relay_malfunction_reset(); diff --git a/board/safety/safety_nissan.h b/board/safety/safety_nissan.h index 75fef908..ba3cc6e8 100644 --- a/board/safety/safety_nissan.h +++ b/board/safety/safety_nissan.h @@ -189,7 +189,7 @@ static int nissan_fwd_hook(int bus_num, CANPacket_t *to_fwd) { return bus_fwd; } -static const addr_checks* nissan_init(uint32_t param) { +static const addr_checks* nissan_init(uint16_t param) { controls_allowed = 0; nissan_alt_eps = param ? 1 : 0; relay_malfunction_reset(); diff --git a/board/safety/safety_subaru.h b/board/safety/safety_subaru.h index e20de5c7..451facfa 100644 --- a/board/safety/safety_subaru.h +++ b/board/safety/safety_subaru.h @@ -313,7 +313,7 @@ static int subaru_legacy_fwd_hook(int bus_num, CANPacket_t *to_fwd) { return bus_fwd; } -static const addr_checks* subaru_init(uint32_t param) { +static const addr_checks* subaru_init(uint16_t param) { UNUSED(param); controls_allowed = false; relay_malfunction_reset(); @@ -328,7 +328,7 @@ const safety_hooks subaru_hooks = { .fwd = subaru_fwd_hook, }; -static const addr_checks* subaru_legacy_init(uint32_t param) { +static const addr_checks* subaru_legacy_init(uint16_t param) { UNUSED(param); controls_allowed = false; relay_malfunction_reset(); diff --git a/board/safety/safety_tesla.h b/board/safety/safety_tesla.h index f78b7af4..fae23502 100644 --- a/board/safety/safety_tesla.h +++ b/board/safety/safety_tesla.h @@ -244,7 +244,7 @@ static int tesla_fwd_hook(int bus_num, CANPacket_t *to_fwd) { return bus_fwd; } -static const addr_checks* tesla_init(uint32_t param) { +static const addr_checks* tesla_init(uint16_t param) { tesla_powertrain = GET_FLAG(param, TESLA_FLAG_POWERTRAIN); tesla_longitudinal = GET_FLAG(param, TESLA_FLAG_LONGITUDINAL_CONTROL); controls_allowed = 0; diff --git a/board/safety/safety_toyota.h b/board/safety/safety_toyota.h index 395c9817..440de256 100644 --- a/board/safety/safety_toyota.h +++ b/board/safety/safety_toyota.h @@ -263,7 +263,7 @@ static int toyota_tx_hook(CANPacket_t *to_send, bool longitudinal_allowed) { return tx; } -static const addr_checks* toyota_init(uint32_t param) { +static const addr_checks* toyota_init(uint16_t param) { controls_allowed = 0; relay_malfunction_reset(); gas_interceptor_detected = 0; diff --git a/board/safety/safety_volkswagen_mqb.h b/board/safety/safety_volkswagen_mqb.h index dd51f4b3..1dce27a7 100644 --- a/board/safety/safety_volkswagen_mqb.h +++ b/board/safety/safety_volkswagen_mqb.h @@ -76,7 +76,7 @@ static uint8_t volkswagen_mqb_compute_crc(CANPacket_t *to_push) { return crc ^ 0xFFU; } -static const addr_checks* volkswagen_mqb_init(uint32_t param) { +static const addr_checks* volkswagen_mqb_init(uint16_t param) { UNUSED(param); controls_allowed = false; diff --git a/board/safety/safety_volkswagen_pq.h b/board/safety/safety_volkswagen_pq.h index 9c99fdc0..62714f6d 100644 --- a/board/safety/safety_volkswagen_pq.h +++ b/board/safety/safety_volkswagen_pq.h @@ -49,7 +49,7 @@ static uint8_t volkswagen_pq_compute_checksum(CANPacket_t *to_push) { return checksum; } -static const addr_checks* volkswagen_pq_init(uint32_t param) { +static const addr_checks* volkswagen_pq_init(uint16_t param) { UNUSED(param); controls_allowed = false; diff --git a/board/safety_declarations.h b/board/safety_declarations.h index a4e904a7..c237e1c1 100644 --- a/board/safety_declarations.h +++ b/board/safety_declarations.h @@ -84,7 +84,7 @@ void generic_rx_checks(bool stock_ecu_detected); void relay_malfunction_set(void); void relay_malfunction_reset(void); -typedef const addr_checks* (*safety_hook_init)(uint32_t param); +typedef const addr_checks* (*safety_hook_init)(uint16_t param); typedef int (*rx_hook)(CANPacket_t *to_push); typedef int (*tx_hook)(CANPacket_t *to_send, bool longitudinal_allowed); typedef int (*tx_lin_hook)(int lin_num, uint8_t *data, int len); diff --git a/board/usb_comms.h b/board/usb_comms.h index 577dfe42..699367d5 100644 --- a/board/usb_comms.h +++ b/board/usb_comms.h @@ -4,7 +4,7 @@ extern int _app_start[0xc000]; // Only first 3 sectors of size 0x4000 are used // Prototypes -void set_safety_mode(uint16_t mode, uint32_t param); +void set_safety_mode(uint16_t mode, uint16_t param); bool is_car_safety_mode(uint16_t mode); int get_health_pkt(void *dat) { @@ -273,7 +273,7 @@ int usb_cb_control_msg(USB_Setup_TypeDef *setup, uint8_t *resp) { // **** 0xdc: set safety mode case 0xdc: - set_safety_mode(setup->b.wValue.w, (uint32_t) setup->b.wIndex.w); + set_safety_mode(setup->b.wValue.w, (uint16_t)setup->b.wIndex.w); break; // **** 0xdd: get healthpacket and CANPacket versions case 0xdd: diff --git a/python/__init__.py b/python/__init__.py index d3a96cbe..c7930997 100644 --- a/python/__init__.py +++ b/python/__init__.py @@ -170,8 +170,8 @@ class Panda(object): HW_TYPE_RED_PANDA = b'\x07' CAN_PACKET_VERSION = 2 - HEALTH_PACKET_VERSION = 6 - HEALTH_STRUCT = struct.Struct("