Support code for unsafe mode unit tests (#478)

* Support code for unsafe mode tests

* Fix pre-existing MISRA warning while I'm here
This commit is contained in:
Jason Young 2020-04-01 10:17:51 -07:00 committed by GitHub
parent 5325b62bbe
commit 51e0a55d6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 3 deletions

View File

@ -472,9 +472,9 @@ int usb_cb_control_msg(USB_Setup_TypeDef *setup, uint8_t *resp, bool hardwired)
// **** 0xdf: set unsafe mode
case 0xdf:
// you can only set this if you are in a non car safety mode
if (current_safety_mode == SAFETY_SILENT ||
current_safety_mode == SAFETY_NOOUTPUT ||
current_safety_mode == SAFETY_ELM327) {
if ((current_safety_mode == SAFETY_SILENT) ||
(current_safety_mode == SAFETY_NOOUTPUT) ||
(current_safety_mode == SAFETY_ELM327)) {
unsafe_mode = setup->b.wValue.w;
}
break;

View File

@ -2,6 +2,13 @@ from panda.tests.safety import libpandasafety_py
MAX_WRONG_COUNTERS = 5
class UNSAFE_MODE:
DEFAULT = 0
DISABLE_DISENGAGE_ON_GAS = 1
DISABLE_STOCK_AEB = 2
ENABLE_WEAK_STEERING_WHILE_NOT_ENGAGED = 4
RAISE_LONGITUDINAL_LIMITS_TO_ISO_MAX = 8
def make_msg(bus, addr, length=8):
to_send = libpandasafety_py.ffi.new('CAN_FIFOMailBox_TypeDef *')
if addr >= 0x800:

View File

@ -32,6 +32,8 @@ typedef struct
void set_controls_allowed(bool c);
bool get_controls_allowed(void);
void set_unsafe_mode(int mode);
int get_unsafe_mode(void);
void set_relay_malfunction(bool c);
bool get_relay_malfunction(void);
void set_gas_interceptor_detected(bool c);

View File

@ -81,6 +81,10 @@ void set_controls_allowed(bool c){
controls_allowed = c;
}
void set_unsafe_mode(int mode){
unsafe_mode = mode;
}
void set_relay_malfunction(bool c){
relay_malfunction = c;
}
@ -93,6 +97,10 @@ bool get_controls_allowed(void){
return controls_allowed;
}
int get_unsafe_mode(void){
return unsafe_mode;
}
bool get_relay_malfunction(void){
return relay_malfunction;
}