mirror of https://github.com/commaai/panda.git
enable misra-c2012-17.3 (#1806)
This commit is contained in:
parent
93a06f1257
commit
3bd980eb39
|
@ -311,7 +311,8 @@ int comms_control_handler(ControlPacket_t *req, uint8_t *resp) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// read
|
// read
|
||||||
while ((resp_len < MIN(req->length, USBPACKET_MAX_SIZE)) &&
|
uint16_t req_length = MIN(req->length, USBPACKET_MAX_SIZE);
|
||||||
|
while ((resp_len < req_length) &&
|
||||||
get_char(ur, (char*)&resp[resp_len])) {
|
get_char(ur, (char*)&resp[resp_len])) {
|
||||||
++resp_len;
|
++resp_len;
|
||||||
}
|
}
|
||||||
|
|
|
@ -390,7 +390,8 @@ int set_safety_hooks(uint16_t mode, uint16_t param) {
|
||||||
// convert a trimmed integer to signed 32 bit int
|
// convert a trimmed integer to signed 32 bit int
|
||||||
int to_signed(int d, int bits) {
|
int to_signed(int d, int bits) {
|
||||||
int d_signed = d;
|
int d_signed = d;
|
||||||
if (d >= (1 << MAX((bits - 1), 0))) {
|
int max_value = (1 << MAX((bits - 1), 0));
|
||||||
|
if (d >= max_value) {
|
||||||
d_signed = d - (1 << MAX(bits, 0));
|
d_signed = d - (1 << MAX(bits, 0));
|
||||||
}
|
}
|
||||||
return d_signed;
|
return d_signed;
|
||||||
|
|
|
@ -264,7 +264,9 @@ static int chrysler_fwd_hook(int bus_num, int addr) {
|
||||||
|
|
||||||
static safety_config chrysler_init(uint16_t param) {
|
static safety_config chrysler_init(uint16_t param) {
|
||||||
safety_config ret;
|
safety_config ret;
|
||||||
if (GET_FLAG(param, CHRYSLER_PARAM_RAM_DT)) {
|
|
||||||
|
bool enable_ram_dt = GET_FLAG(param, CHRYSLER_PARAM_RAM_DT);
|
||||||
|
if (enable_ram_dt) {
|
||||||
chrysler_platform = CHRYSLER_RAM_DT;
|
chrysler_platform = CHRYSLER_RAM_DT;
|
||||||
chrysler_addrs = &CHRYSLER_RAM_DT_ADDRS;
|
chrysler_addrs = &CHRYSLER_RAM_DT_ADDRS;
|
||||||
ret = BUILD_SAFETY_CFG(chrysler_ram_dt_rx_checks, CHRYSLER_RAM_DT_TX_MSGS);
|
ret = BUILD_SAFETY_CFG(chrysler_ram_dt_rx_checks, CHRYSLER_RAM_DT_TX_MSGS);
|
||||||
|
|
|
@ -222,7 +222,8 @@ static void ford_rx_hook(const CANPacket_t *to_push) {
|
||||||
// Disable controls if speeds from ABS and PCM ECUs are too far apart.
|
// Disable controls if speeds from ABS and PCM ECUs are too far apart.
|
||||||
// Signal: Veh_V_ActlEng
|
// Signal: Veh_V_ActlEng
|
||||||
float filtered_pcm_speed = ((GET_BYTE(to_push, 6) << 8) | GET_BYTE(to_push, 7)) * 0.01 / 3.6;
|
float filtered_pcm_speed = ((GET_BYTE(to_push, 6) << 8) | GET_BYTE(to_push, 7)) * 0.01 / 3.6;
|
||||||
if (ABS(filtered_pcm_speed - ((float)vehicle_speed.values[0] / VEHICLE_SPEED_FACTOR)) > FORD_MAX_SPEED_DELTA) {
|
bool is_invalid_speed = ABS(filtered_pcm_speed - ((float)vehicle_speed.values[0] / VEHICLE_SPEED_FACTOR)) > FORD_MAX_SPEED_DELTA;
|
||||||
|
if (is_invalid_speed) {
|
||||||
controls_allowed = false;
|
controls_allowed = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -383,7 +383,9 @@ static safety_config honda_nidec_init(uint16_t param) {
|
||||||
enable_gas_interceptor = GET_FLAG(param, HONDA_PARAM_GAS_INTERCEPTOR);
|
enable_gas_interceptor = GET_FLAG(param, HONDA_PARAM_GAS_INTERCEPTOR);
|
||||||
|
|
||||||
safety_config ret;
|
safety_config ret;
|
||||||
if (GET_FLAG(param, HONDA_PARAM_NIDEC_ALT)) {
|
|
||||||
|
bool enable_nidec_alt = GET_FLAG(param, HONDA_PARAM_NIDEC_ALT);
|
||||||
|
if (enable_nidec_alt) {
|
||||||
enable_gas_interceptor ? SET_RX_CHECKS(honda_nidec_alt_interceptor_rx_checks, ret) : \
|
enable_gas_interceptor ? SET_RX_CHECKS(honda_nidec_alt_interceptor_rx_checks, ret) : \
|
||||||
SET_RX_CHECKS(honda_nidec_alt_rx_checks, ret);
|
SET_RX_CHECKS(honda_nidec_alt_rx_checks, ret);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -25,5 +25,4 @@ misra-c2012-8.7
|
||||||
misra-c2012-8.4
|
misra-c2012-8.4
|
||||||
misra-c2012-10.6
|
misra-c2012-10.6
|
||||||
misra-c2012-10.3
|
misra-c2012-10.3
|
||||||
misra-c2012-17.3
|
|
||||||
misra-c2012-21.15
|
misra-c2012-21.15
|
||||||
|
|
Loading…
Reference in New Issue