mirror of https://github.com/commaai/panda.git
parent
194f2d9657
commit
f1cd12651c
|
@ -59,7 +59,7 @@ int get_rtc_pkt(void *dat) {
|
||||||
void comms_endpoint2_write(uint8_t *data, uint32_t len) {
|
void comms_endpoint2_write(uint8_t *data, uint32_t len) {
|
||||||
uart_ring *ur = get_ring_by_number(data[0]);
|
uart_ring *ur = get_ring_by_number(data[0]);
|
||||||
if ((len != 0U) && (ur != NULL)) {
|
if ((len != 0U) && (ur != NULL)) {
|
||||||
if ((data[0] < 2U) || (data[0] >= 4U) || safety_tx_lin_hook(data[0] - 2U, &data[1], len - 1U)) {
|
if ((data[0] < 2U) || (data[0] >= 4U)) {
|
||||||
for (uint32_t i = 1; i < len; i++) {
|
for (uint32_t i = 1; i < len; i++) {
|
||||||
while (!putc(ur, data[i])) {
|
while (!putc(ur, data[i])) {
|
||||||
// wait
|
// wait
|
||||||
|
|
|
@ -85,10 +85,6 @@ bool safety_tx_hook(CANPacket_t *to_send) {
|
||||||
return !relay_malfunction && whitelisted && safety_allowed;
|
return !relay_malfunction && whitelisted && safety_allowed;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool safety_tx_lin_hook(int lin_num, uint8_t *data, int len) {
|
|
||||||
return current_hooks->tx_lin(lin_num, data, len);
|
|
||||||
}
|
|
||||||
|
|
||||||
int safety_fwd_hook(int bus_num, int addr) {
|
int safety_fwd_hook(int bus_num, int addr) {
|
||||||
return (relay_malfunction ? -1 : current_hooks->fwd(bus_num, addr));
|
return (relay_malfunction ? -1 : current_hooks->fwd(bus_num, addr));
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,5 @@ const safety_hooks body_hooks = {
|
||||||
.init = body_init,
|
.init = body_init,
|
||||||
.rx = body_rx_hook,
|
.rx = body_rx_hook,
|
||||||
.tx = body_tx_hook,
|
.tx = body_tx_hook,
|
||||||
.tx_lin = nooutput_tx_lin_hook,
|
|
||||||
.fwd = default_fwd_hook,
|
.fwd = default_fwd_hook,
|
||||||
};
|
};
|
||||||
|
|
|
@ -286,7 +286,6 @@ const safety_hooks chrysler_hooks = {
|
||||||
.init = chrysler_init,
|
.init = chrysler_init,
|
||||||
.rx = chrysler_rx_hook,
|
.rx = chrysler_rx_hook,
|
||||||
.tx = chrysler_tx_hook,
|
.tx = chrysler_tx_hook,
|
||||||
.tx_lin = nooutput_tx_lin_hook,
|
|
||||||
.fwd = chrysler_fwd_hook,
|
.fwd = chrysler_fwd_hook,
|
||||||
.get_counter = chrysler_get_counter,
|
.get_counter = chrysler_get_counter,
|
||||||
.get_checksum = chrysler_get_checksum,
|
.get_checksum = chrysler_get_checksum,
|
||||||
|
|
|
@ -14,13 +14,6 @@ static bool nooutput_tx_hook(CANPacket_t *to_send) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool nooutput_tx_lin_hook(int lin_num, uint8_t *data, int len) {
|
|
||||||
UNUSED(lin_num);
|
|
||||||
UNUSED(data);
|
|
||||||
UNUSED(len);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int default_fwd_hook(int bus_num, int addr) {
|
static int default_fwd_hook(int bus_num, int addr) {
|
||||||
UNUSED(bus_num);
|
UNUSED(bus_num);
|
||||||
UNUSED(addr);
|
UNUSED(addr);
|
||||||
|
@ -31,7 +24,6 @@ const safety_hooks nooutput_hooks = {
|
||||||
.init = nooutput_init,
|
.init = nooutput_init,
|
||||||
.rx = default_rx_hook,
|
.rx = default_rx_hook,
|
||||||
.tx = nooutput_tx_hook,
|
.tx = nooutput_tx_hook,
|
||||||
.tx_lin = nooutput_tx_lin_hook,
|
|
||||||
.fwd = default_fwd_hook,
|
.fwd = default_fwd_hook,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -52,13 +44,6 @@ static bool alloutput_tx_hook(CANPacket_t *to_send) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool alloutput_tx_lin_hook(int lin_num, uint8_t *data, int len) {
|
|
||||||
UNUSED(lin_num);
|
|
||||||
UNUSED(data);
|
|
||||||
UNUSED(len);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int alloutput_fwd_hook(int bus_num, int addr) {
|
static int alloutput_fwd_hook(int bus_num, int addr) {
|
||||||
int bus_fwd = -1;
|
int bus_fwd = -1;
|
||||||
UNUSED(addr);
|
UNUSED(addr);
|
||||||
|
@ -79,6 +64,5 @@ const safety_hooks alloutput_hooks = {
|
||||||
.init = alloutput_init,
|
.init = alloutput_init,
|
||||||
.rx = default_rx_hook,
|
.rx = default_rx_hook,
|
||||||
.tx = alloutput_tx_hook,
|
.tx = alloutput_tx_hook,
|
||||||
.tx_lin = alloutput_tx_lin_hook,
|
|
||||||
.fwd = alloutput_fwd_hook,
|
.fwd = alloutput_fwd_hook,
|
||||||
};
|
};
|
||||||
|
|
|
@ -17,26 +17,10 @@ static bool elm327_tx_hook(CANPacket_t *to_send) {
|
||||||
return tx;
|
return tx;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool elm327_tx_lin_hook(int lin_num, uint8_t *data, int len) {
|
|
||||||
int tx = 1;
|
|
||||||
if (lin_num != 0) {
|
|
||||||
tx = 0; // Only operate on LIN 0, aka serial 2
|
|
||||||
}
|
|
||||||
if ((len < 5) || (len > 11)) {
|
|
||||||
tx = 0; // Valid KWP size
|
|
||||||
}
|
|
||||||
if (!(((data[0] & 0xF8U) == 0xC0U) && ((data[0] & 0x07U) != 0U) &&
|
|
||||||
(data[1] == 0x33U) && (data[2] == 0xF1U))) {
|
|
||||||
tx = 0; // Bad msg
|
|
||||||
}
|
|
||||||
return tx;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If current_board->has_obd and safety_param == 0, bus 1 is multiplexed to the OBD-II port
|
// If current_board->has_obd and safety_param == 0, bus 1 is multiplexed to the OBD-II port
|
||||||
const safety_hooks elm327_hooks = {
|
const safety_hooks elm327_hooks = {
|
||||||
.init = nooutput_init,
|
.init = nooutput_init,
|
||||||
.rx = default_rx_hook,
|
.rx = default_rx_hook,
|
||||||
.tx = elm327_tx_hook,
|
.tx = elm327_tx_hook,
|
||||||
.tx_lin = elm327_tx_lin_hook,
|
|
||||||
.fwd = default_fwd_hook,
|
.fwd = default_fwd_hook,
|
||||||
};
|
};
|
||||||
|
|
|
@ -417,7 +417,6 @@ const safety_hooks ford_hooks = {
|
||||||
.init = ford_init,
|
.init = ford_init,
|
||||||
.rx = ford_rx_hook,
|
.rx = ford_rx_hook,
|
||||||
.tx = ford_tx_hook,
|
.tx = ford_tx_hook,
|
||||||
.tx_lin = nooutput_tx_lin_hook,
|
|
||||||
.fwd = ford_fwd_hook,
|
.fwd = ford_fwd_hook,
|
||||||
.get_counter = ford_get_counter,
|
.get_counter = ford_get_counter,
|
||||||
.get_checksum = ford_get_checksum,
|
.get_checksum = ford_get_checksum,
|
||||||
|
|
|
@ -240,6 +240,5 @@ const safety_hooks gm_hooks = {
|
||||||
.init = gm_init,
|
.init = gm_init,
|
||||||
.rx = gm_rx_hook,
|
.rx = gm_rx_hook,
|
||||||
.tx = gm_tx_hook,
|
.tx = gm_tx_hook,
|
||||||
.tx_lin = nooutput_tx_lin_hook,
|
|
||||||
.fwd = gm_fwd_hook,
|
.fwd = gm_fwd_hook,
|
||||||
};
|
};
|
||||||
|
|
|
@ -458,7 +458,6 @@ const safety_hooks honda_nidec_hooks = {
|
||||||
.init = honda_nidec_init,
|
.init = honda_nidec_init,
|
||||||
.rx = honda_rx_hook,
|
.rx = honda_rx_hook,
|
||||||
.tx = honda_tx_hook,
|
.tx = honda_tx_hook,
|
||||||
.tx_lin = nooutput_tx_lin_hook,
|
|
||||||
.fwd = honda_nidec_fwd_hook,
|
.fwd = honda_nidec_fwd_hook,
|
||||||
.get_counter = honda_get_counter,
|
.get_counter = honda_get_counter,
|
||||||
.get_checksum = honda_get_checksum,
|
.get_checksum = honda_get_checksum,
|
||||||
|
@ -469,7 +468,6 @@ const safety_hooks honda_bosch_hooks = {
|
||||||
.init = honda_bosch_init,
|
.init = honda_bosch_init,
|
||||||
.rx = honda_rx_hook,
|
.rx = honda_rx_hook,
|
||||||
.tx = honda_tx_hook,
|
.tx = honda_tx_hook,
|
||||||
.tx_lin = nooutput_tx_lin_hook,
|
|
||||||
.fwd = honda_bosch_fwd_hook,
|
.fwd = honda_bosch_fwd_hook,
|
||||||
.get_counter = honda_get_counter,
|
.get_counter = honda_get_counter,
|
||||||
.get_checksum = honda_get_checksum,
|
.get_checksum = honda_get_checksum,
|
||||||
|
|
|
@ -327,7 +327,6 @@ const safety_hooks hyundai_hooks = {
|
||||||
.init = hyundai_init,
|
.init = hyundai_init,
|
||||||
.rx = hyundai_rx_hook,
|
.rx = hyundai_rx_hook,
|
||||||
.tx = hyundai_tx_hook,
|
.tx = hyundai_tx_hook,
|
||||||
.tx_lin = nooutput_tx_lin_hook,
|
|
||||||
.fwd = hyundai_fwd_hook,
|
.fwd = hyundai_fwd_hook,
|
||||||
.get_counter = hyundai_get_counter,
|
.get_counter = hyundai_get_counter,
|
||||||
.get_checksum = hyundai_get_checksum,
|
.get_checksum = hyundai_get_checksum,
|
||||||
|
@ -338,7 +337,6 @@ const safety_hooks hyundai_legacy_hooks = {
|
||||||
.init = hyundai_legacy_init,
|
.init = hyundai_legacy_init,
|
||||||
.rx = hyundai_rx_hook,
|
.rx = hyundai_rx_hook,
|
||||||
.tx = hyundai_tx_hook,
|
.tx = hyundai_tx_hook,
|
||||||
.tx_lin = nooutput_tx_lin_hook,
|
|
||||||
.fwd = hyundai_fwd_hook,
|
.fwd = hyundai_fwd_hook,
|
||||||
.get_counter = hyundai_get_counter,
|
.get_counter = hyundai_get_counter,
|
||||||
.get_checksum = hyundai_get_checksum,
|
.get_checksum = hyundai_get_checksum,
|
||||||
|
|
|
@ -353,7 +353,6 @@ const safety_hooks hyundai_canfd_hooks = {
|
||||||
.init = hyundai_canfd_init,
|
.init = hyundai_canfd_init,
|
||||||
.rx = hyundai_canfd_rx_hook,
|
.rx = hyundai_canfd_rx_hook,
|
||||||
.tx = hyundai_canfd_tx_hook,
|
.tx = hyundai_canfd_tx_hook,
|
||||||
.tx_lin = nooutput_tx_lin_hook,
|
|
||||||
.fwd = hyundai_canfd_fwd_hook,
|
.fwd = hyundai_canfd_fwd_hook,
|
||||||
.get_counter = hyundai_canfd_get_counter,
|
.get_counter = hyundai_canfd_get_counter,
|
||||||
.get_checksum = hyundai_canfd_get_checksum,
|
.get_checksum = hyundai_canfd_get_checksum,
|
||||||
|
|
|
@ -125,6 +125,5 @@ const safety_hooks mazda_hooks = {
|
||||||
.init = mazda_init,
|
.init = mazda_init,
|
||||||
.rx = mazda_rx_hook,
|
.rx = mazda_rx_hook,
|
||||||
.tx = mazda_tx_hook,
|
.tx = mazda_tx_hook,
|
||||||
.tx_lin = nooutput_tx_lin_hook,
|
|
||||||
.fwd = mazda_fwd_hook,
|
.fwd = mazda_fwd_hook,
|
||||||
};
|
};
|
||||||
|
|
|
@ -155,6 +155,5 @@ const safety_hooks nissan_hooks = {
|
||||||
.init = nissan_init,
|
.init = nissan_init,
|
||||||
.rx = nissan_rx_hook,
|
.rx = nissan_rx_hook,
|
||||||
.tx = nissan_tx_hook,
|
.tx = nissan_tx_hook,
|
||||||
.tx_lin = nooutput_tx_lin_hook,
|
|
||||||
.fwd = nissan_fwd_hook,
|
.fwd = nissan_fwd_hook,
|
||||||
};
|
};
|
||||||
|
|
|
@ -288,7 +288,6 @@ const safety_hooks subaru_hooks = {
|
||||||
.init = subaru_init,
|
.init = subaru_init,
|
||||||
.rx = subaru_rx_hook,
|
.rx = subaru_rx_hook,
|
||||||
.tx = subaru_tx_hook,
|
.tx = subaru_tx_hook,
|
||||||
.tx_lin = nooutput_tx_lin_hook,
|
|
||||||
.fwd = subaru_fwd_hook,
|
.fwd = subaru_fwd_hook,
|
||||||
.get_counter = subaru_get_counter,
|
.get_counter = subaru_get_counter,
|
||||||
.get_checksum = subaru_get_checksum,
|
.get_checksum = subaru_get_checksum,
|
||||||
|
|
|
@ -122,6 +122,5 @@ const safety_hooks subaru_preglobal_hooks = {
|
||||||
.init = subaru_preglobal_init,
|
.init = subaru_preglobal_init,
|
||||||
.rx = subaru_preglobal_rx_hook,
|
.rx = subaru_preglobal_rx_hook,
|
||||||
.tx = subaru_preglobal_tx_hook,
|
.tx = subaru_preglobal_tx_hook,
|
||||||
.tx_lin = nooutput_tx_lin_hook,
|
|
||||||
.fwd = subaru_preglobal_fwd_hook,
|
.fwd = subaru_preglobal_fwd_hook,
|
||||||
};
|
};
|
||||||
|
|
|
@ -222,6 +222,5 @@ const safety_hooks tesla_hooks = {
|
||||||
.init = tesla_init,
|
.init = tesla_init,
|
||||||
.rx = tesla_rx_hook,
|
.rx = tesla_rx_hook,
|
||||||
.tx = tesla_tx_hook,
|
.tx = tesla_tx_hook,
|
||||||
.tx_lin = nooutput_tx_lin_hook,
|
|
||||||
.fwd = tesla_fwd_hook,
|
.fwd = tesla_fwd_hook,
|
||||||
};
|
};
|
||||||
|
|
|
@ -261,7 +261,6 @@ const safety_hooks toyota_hooks = {
|
||||||
.init = toyota_init,
|
.init = toyota_init,
|
||||||
.rx = toyota_rx_hook,
|
.rx = toyota_rx_hook,
|
||||||
.tx = toyota_tx_hook,
|
.tx = toyota_tx_hook,
|
||||||
.tx_lin = nooutput_tx_lin_hook,
|
|
||||||
.fwd = toyota_fwd_hook,
|
.fwd = toyota_fwd_hook,
|
||||||
.get_checksum = toyota_get_checksum,
|
.get_checksum = toyota_get_checksum,
|
||||||
.compute_checksum = toyota_compute_checksum,
|
.compute_checksum = toyota_compute_checksum,
|
||||||
|
|
|
@ -282,7 +282,6 @@ const safety_hooks volkswagen_mqb_hooks = {
|
||||||
.init = volkswagen_mqb_init,
|
.init = volkswagen_mqb_init,
|
||||||
.rx = volkswagen_mqb_rx_hook,
|
.rx = volkswagen_mqb_rx_hook,
|
||||||
.tx = volkswagen_mqb_tx_hook,
|
.tx = volkswagen_mqb_tx_hook,
|
||||||
.tx_lin = nooutput_tx_lin_hook,
|
|
||||||
.fwd = volkswagen_mqb_fwd_hook,
|
.fwd = volkswagen_mqb_fwd_hook,
|
||||||
.get_counter = volkswagen_mqb_get_counter,
|
.get_counter = volkswagen_mqb_get_counter,
|
||||||
.get_checksum = volkswagen_mqb_get_checksum,
|
.get_checksum = volkswagen_mqb_get_checksum,
|
||||||
|
|
|
@ -248,7 +248,6 @@ const safety_hooks volkswagen_pq_hooks = {
|
||||||
.init = volkswagen_pq_init,
|
.init = volkswagen_pq_init,
|
||||||
.rx = volkswagen_pq_rx_hook,
|
.rx = volkswagen_pq_rx_hook,
|
||||||
.tx = volkswagen_pq_tx_hook,
|
.tx = volkswagen_pq_tx_hook,
|
||||||
.tx_lin = nooutput_tx_lin_hook,
|
|
||||||
.fwd = volkswagen_pq_fwd_hook,
|
.fwd = volkswagen_pq_fwd_hook,
|
||||||
.get_counter = volkswagen_pq_get_counter,
|
.get_counter = volkswagen_pq_get_counter,
|
||||||
.get_checksum = volkswagen_pq_get_checksum,
|
.get_checksum = volkswagen_pq_get_checksum,
|
||||||
|
|
|
@ -148,7 +148,6 @@ typedef bool (*get_quality_flag_valid_t)(CANPacket_t *to_push);
|
||||||
|
|
||||||
bool safety_rx_hook(CANPacket_t *to_push);
|
bool safety_rx_hook(CANPacket_t *to_push);
|
||||||
bool safety_tx_hook(CANPacket_t *to_send);
|
bool safety_tx_hook(CANPacket_t *to_send);
|
||||||
bool safety_tx_lin_hook(int lin_num, uint8_t *data, int len);
|
|
||||||
uint32_t get_ts_elapsed(uint32_t ts, uint32_t ts_last);
|
uint32_t get_ts_elapsed(uint32_t ts, uint32_t ts_last);
|
||||||
int to_signed(int d, int bits);
|
int to_signed(int d, int bits);
|
||||||
void update_sample(struct sample_t *sample, int sample_new);
|
void update_sample(struct sample_t *sample, int sample_new);
|
||||||
|
@ -194,14 +193,12 @@ void pcm_cruise_check(bool cruise_engaged);
|
||||||
typedef safety_config (*safety_hook_init)(uint16_t param);
|
typedef safety_config (*safety_hook_init)(uint16_t param);
|
||||||
typedef void (*rx_hook)(CANPacket_t *to_push);
|
typedef void (*rx_hook)(CANPacket_t *to_push);
|
||||||
typedef bool (*tx_hook)(CANPacket_t *to_send);
|
typedef bool (*tx_hook)(CANPacket_t *to_send);
|
||||||
typedef bool (*tx_lin_hook)(int lin_num, uint8_t *data, int len);
|
|
||||||
typedef int (*fwd_hook)(int bus_num, int addr);
|
typedef int (*fwd_hook)(int bus_num, int addr);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
safety_hook_init init;
|
safety_hook_init init;
|
||||||
rx_hook rx;
|
rx_hook rx;
|
||||||
tx_hook tx;
|
tx_hook tx;
|
||||||
tx_lin_hook tx_lin;
|
|
||||||
fwd_hook fwd;
|
fwd_hook fwd;
|
||||||
get_checksum_t get_checksum;
|
get_checksum_t get_checksum;
|
||||||
compute_checksum_t compute_checksum;
|
compute_checksum_t compute_checksum;
|
||||||
|
|
|
@ -27,7 +27,6 @@ typedef struct {
|
||||||
ffi.cdef("""
|
ffi.cdef("""
|
||||||
bool safety_rx_hook(CANPacket_t *to_send);
|
bool safety_rx_hook(CANPacket_t *to_send);
|
||||||
bool safety_tx_hook(CANPacket_t *to_push);
|
bool safety_tx_hook(CANPacket_t *to_push);
|
||||||
bool safety_tx_lin_hook(int lin_num, uint8_t *data, int len);
|
|
||||||
int safety_fwd_hook(int bus_num, int addr);
|
int safety_fwd_hook(int bus_num, int addr);
|
||||||
int set_safety_hooks(uint16_t mode, uint16_t param);
|
int set_safety_hooks(uint16_t mode, uint16_t param);
|
||||||
""")
|
""")
|
||||||
|
@ -78,7 +77,6 @@ class Panda(PandaSafety, Protocol):
|
||||||
# safety
|
# safety
|
||||||
def safety_rx_hook(self, to_send: CANPacket) -> int: ...
|
def safety_rx_hook(self, to_send: CANPacket) -> int: ...
|
||||||
def safety_tx_hook(self, to_push: CANPacket) -> int: ...
|
def safety_tx_hook(self, to_push: CANPacket) -> int: ...
|
||||||
def safety_tx_lin_hook(self, lin_num: int, data: bytes, _len: int) -> int: ...
|
|
||||||
def safety_fwd_hook(self, bus_num: int, addr: int) -> int: ...
|
def safety_fwd_hook(self, bus_num: int, addr: int) -> int: ...
|
||||||
def set_safety_hooks(self, mode: int, param: int) -> int: ...
|
def set_safety_hooks(self, mode: int, param: int) -> int: ...
|
||||||
|
|
||||||
|
|
|
@ -75,10 +75,6 @@ class PandaSafetyTestBase(unittest.TestCase):
|
||||||
def _tx(self, msg):
|
def _tx(self, msg):
|
||||||
return self.safety.safety_tx_hook(msg)
|
return self.safety.safety_tx_hook(msg)
|
||||||
|
|
||||||
def _tx_lin(self, priority: int, lin_num: int, to_addr: int, from_addr: int, dat: bytes):
|
|
||||||
msg = bytes([priority | len(dat), to_addr, from_addr]) + dat
|
|
||||||
return self.safety.safety_tx_lin_hook(lin_num, msg, len(msg))
|
|
||||||
|
|
||||||
def _generic_limit_safety_check(self, msg_function: MessageFunction, min_allowed_value: float, max_allowed_value: float,
|
def _generic_limit_safety_check(self, msg_function: MessageFunction, min_allowed_value: float, max_allowed_value: float,
|
||||||
min_possible_value: float, max_possible_value: float, test_delta: float = 1, inactive_value: float = 0,
|
min_possible_value: float, max_possible_value: float, test_delta: float = 1, inactive_value: float = 0,
|
||||||
msg_allowed = True, additional_setup: Optional[Callable[[float], None]] = None):
|
msg_allowed = True, additional_setup: Optional[Callable[[float], None]] = None):
|
||||||
|
|
|
@ -23,10 +23,6 @@ class TestNoOutput(TestDefaultRxHookBase):
|
||||||
self.safety.set_safety_hooks(Panda.SAFETY_NOOUTPUT, 0)
|
self.safety.set_safety_hooks(Panda.SAFETY_NOOUTPUT, 0)
|
||||||
self.safety.init_tests()
|
self.safety.init_tests()
|
||||||
|
|
||||||
def test_tx_lin_hook(self):
|
|
||||||
for lin_num in range(2):
|
|
||||||
self.assertFalse(self._tx_lin(0x0, lin_num, 0x0, 0x0, b'\x00' * 8), f"allowed TX LIN {lin_num=}")
|
|
||||||
|
|
||||||
|
|
||||||
class TestSilent(TestNoOutput):
|
class TestSilent(TestNoOutput):
|
||||||
"""SILENT uses same hooks as NOOUTPUT"""
|
"""SILENT uses same hooks as NOOUTPUT"""
|
||||||
|
@ -47,10 +43,6 @@ class TestAllOutput(TestDefaultRxHookBase):
|
||||||
self.safety.set_safety_hooks(Panda.SAFETY_ALLOUTPUT, 0)
|
self.safety.set_safety_hooks(Panda.SAFETY_ALLOUTPUT, 0)
|
||||||
self.safety.init_tests()
|
self.safety.init_tests()
|
||||||
|
|
||||||
def test_tx_lin_hook(self):
|
|
||||||
for lin_num in range(2):
|
|
||||||
self.assertTrue(self._tx_lin(0x0, lin_num, 0x0, 0x0, b'\x00' * 8), f"not allowed TX LIN {lin_num=}")
|
|
||||||
|
|
||||||
def test_spam_can_buses(self):
|
def test_spam_can_buses(self):
|
||||||
# asserts tx allowed for all scanned addrs
|
# asserts tx allowed for all scanned addrs
|
||||||
for bus in range(4):
|
for bus in range(4):
|
||||||
|
|
|
@ -31,20 +31,6 @@ class TestElm327(TestDefaultRxHookBase):
|
||||||
should_tx = msg_len == 8
|
should_tx = msg_len == 8
|
||||||
self.assertEqual(should_tx, self._tx(common.make_msg(0, 0x700, msg_len)))
|
self.assertEqual(should_tx, self._tx(common.make_msg(0, 0x700, msg_len)))
|
||||||
|
|
||||||
def test_tx_lin_hook(self):
|
|
||||||
# spot check some cases
|
|
||||||
self.assertFalse(self._tx_lin(0xC0, 1, 0x33, 0xF1, b'\x01\x0F')) # wrong lin number/bus
|
|
||||||
self.assertFalse(self._tx_lin(0xC0, 0, 0x33, 0xF1, b'')) # wrong length
|
|
||||||
self.assertFalse(self._tx_lin(0xB0, 0, 0x33, 0xF1, b'\x01\x0E')) # bad priority
|
|
||||||
self.assertFalse(self._tx_lin(0xC0, 0, 0x00, 0xF1, b'\x01\x0D')) # bad addr
|
|
||||||
self.assertFalse(self._tx_lin(0xC0, 0, 0x33, 0x00, b'\x01\x0C')) # bad addr
|
|
||||||
|
|
||||||
for msg_len in range(8 + 1):
|
|
||||||
# first three bytes are made up of priority, len, rx/tx addresses
|
|
||||||
# payload is not checked, try sending 0xFF
|
|
||||||
should_tx = 2 <= (msg_len) <= 7
|
|
||||||
self.assertEqual(should_tx, self._tx_lin(0xC0, 0, 0x33, 0xF1, b'\xFF' * msg_len))
|
|
||||||
|
|
||||||
def test_tx_hook_on_wrong_safety_mode(self):
|
def test_tx_hook_on_wrong_safety_mode(self):
|
||||||
# No point, since we allow many diagnostic addresses
|
# No point, since we allow many diagnostic addresses
|
||||||
pass
|
pass
|
||||||
|
|
Loading…
Reference in New Issue