mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-10-25 02:13:41 +08:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2cd73045c0 |
@@ -340,7 +340,7 @@ void safety_tick(void) {
|
||||
}
|
||||
|
||||
// enforce minimum frequency for safety-relevant messages
|
||||
bool frequency_invalid = !current_safety_config.rx_checks[i].msg[current_safety_config.rx_checks[i].status.index].ignore_frequency_check && (frequency < 10U);
|
||||
bool frequency_invalid = frequency < 10U;
|
||||
if (lagging || frequency_invalid || !is_msg_valid(current_safety_config.rx_checks, i)) {
|
||||
rx_checks_invalid = true;
|
||||
controls_allowed = false;
|
||||
|
||||
@@ -12,7 +12,6 @@ from opendbc.safety.tests.libsafety import libsafety_py
|
||||
from opendbc.car.lateral import MAX_LATERAL_ACCEL, MAX_LATERAL_JERK
|
||||
|
||||
from opendbc.safety.tests.mads_common import MadsSafetyTestBase
|
||||
from opendbc.safety.tests.rx_checks_common import RxChecksSafetyTestBase
|
||||
|
||||
MAX_WRONG_COUNTERS = 5
|
||||
MAX_SAMPLE_VALS = 6
|
||||
@@ -1041,7 +1040,7 @@ class SafetyTest(SafetyTestBase):
|
||||
|
||||
|
||||
@add_regen_tests
|
||||
class CarSafetyTest(SafetyTest, MadsSafetyTestBase, RxChecksSafetyTestBase):
|
||||
class CarSafetyTest(SafetyTest, MadsSafetyTestBase):
|
||||
STANDSTILL_THRESHOLD: float = 0.0
|
||||
GAS_PRESSED_THRESHOLD = 0
|
||||
RELAY_MALFUNCTION_ADDRS: dict[int, tuple[int, ...]] | None = None
|
||||
|
||||
@@ -46,46 +46,6 @@ void tick_mads_state(bool vm, bool acc_main, bool op_allowed, bool braking, bool
|
||||
mads_state_update(vm, acc_main, op_allowed, braking, steering_disengage);
|
||||
}
|
||||
|
||||
void set_unseen_rx_checks_valid(void){
|
||||
for (int i = 0; i < current_safety_config.rx_checks_len; i++) {
|
||||
RxStatus *status = ¤t_safety_config.rx_checks[i].status;
|
||||
if (!status->msg_seen) {
|
||||
status->msg_seen = true;
|
||||
status->index = 0;
|
||||
status->valid_checksum = true;
|
||||
status->wrong_counters = 0;
|
||||
status->valid_quality_flag = true;
|
||||
status->last_timestamp = microsecond_timer_get();
|
||||
status->lagging = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int get_ignore_frequency_check_count(void){
|
||||
int count = 0;
|
||||
for (int i = 0; i < current_safety_config.rx_checks_len; i++) {
|
||||
for (uint8_t j = 0U; (j < MAX_ADDR_CHECK_MSGS) && (current_safety_config.rx_checks[i].msg[j].addr != 0); j++) {
|
||||
if (current_safety_config.rx_checks[i].msg[j].ignore_frequency_check) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
bool get_rx_check_ignore_frequency(int addr, int bus){
|
||||
bool ignore = false;
|
||||
for (int i = 0; i < current_safety_config.rx_checks_len; i++) {
|
||||
for (uint8_t j = 0U; (j < MAX_ADDR_CHECK_MSGS) && (current_safety_config.rx_checks[i].msg[j].addr != 0); j++) {
|
||||
const CanMsgCheck *msg = ¤t_safety_config.rx_checks[i].msg[j];
|
||||
if ((msg->addr == addr) && ((int)msg->bus == bus) && msg->ignore_frequency_check) {
|
||||
ignore = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ignore;
|
||||
}
|
||||
|
||||
void set_relay_malfunction(bool c){
|
||||
relay_malfunction = c;
|
||||
}
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
"""
|
||||
Copyright (c) 2021-, Haibin Wen, sunnypilot, and a number of other contributors.
|
||||
|
||||
This file is part of sunnypilot and is licensed under the MIT License.
|
||||
See the LICENSE.md file in the root directory for more details.
|
||||
"""
|
||||
import unittest
|
||||
|
||||
from opendbc.safety.tests.libsafety import libsafety_py
|
||||
|
||||
|
||||
class RxChecksSafetyTestBase(unittest.TestCase):
|
||||
safety: libsafety_py.LibSafety
|
||||
|
||||
def _ignore_frequency_check_msgs(self):
|
||||
return []
|
||||
|
||||
def test_ignore_frequency_check(self):
|
||||
msgs = self._ignore_frequency_check_msgs()
|
||||
self.assertEqual(len(msgs), self.safety.get_ignore_frequency_check_count())
|
||||
|
||||
for msg in msgs:
|
||||
self.assertTrue(self._rx(msg))
|
||||
self.assertTrue(self.safety.get_rx_check_ignore_frequency(msg[0].addr, msg[0].bus))
|
||||
|
||||
self.safety.set_unseen_rx_checks_valid()
|
||||
self.safety.set_controls_allowed(True)
|
||||
self.safety.safety_tick()
|
||||
self.assertTrue(self.safety.get_controls_allowed())
|
||||
@@ -89,11 +89,6 @@ class TestChryslerSafety(common.CarSafetyTest, common.MotorTorqueSteeringSafetyT
|
||||
def _lkas_button_msg(self, enabled):
|
||||
values = {"TOGGLE_LKAS": enabled}
|
||||
return self.packer.make_can_msg_safety("TRACTION_BUTTON", 0, values)
|
||||
|
||||
def _ignore_frequency_check_msgs(self):
|
||||
return [self._lkas_button_msg(False)]
|
||||
|
||||
|
||||
class TestChryslerRamDTSafety(TestChryslerSafety):
|
||||
DBC = "chrysler_ram_dt_generated"
|
||||
|
||||
|
||||
@@ -489,9 +489,6 @@ class TestTeslaVehicleBusSafety(TestTeslaSafetyBase):
|
||||
values = {"UI_activeTouchPoints": 3 if enabled else 0}
|
||||
return self.packer_adas.make_can_msg_safety("UI_status2", CANBUS.vehicle, values)
|
||||
|
||||
def _ignore_frequency_check_msgs(self):
|
||||
return [self._lkas_button_msg(False)]
|
||||
|
||||
def _set_mads_screen_button_config(self, finger_flag):
|
||||
param_sp = TeslaSafetyFlagsSP.HAS_VEHICLE_BUS
|
||||
if finger_flag is not None:
|
||||
|
||||
@@ -37,10 +37,6 @@ class TestToyotaSafetyBase(common.CarSafetyTest, common.LongitudinalAccelSafetyT
|
||||
|
||||
SAFETY_PARAM_SP: int = 0
|
||||
|
||||
def setUp(self):
|
||||
libsafety_py.libsafety.set_current_safety_param_sp(self.SAFETY_PARAM_SP)
|
||||
super().setUp()
|
||||
|
||||
packer: CANPackerSafety
|
||||
safety: libsafety_py.LibSafety
|
||||
|
||||
@@ -99,9 +95,6 @@ class TestToyotaSafetyBase(common.CarSafetyTest, common.LongitudinalAccelSafetyT
|
||||
values = {"MAIN_ON": enabled}
|
||||
return self.packer.make_can_msg_safety(msg, 0, values)
|
||||
|
||||
def _ignore_frequency_check_msgs(self):
|
||||
return [self._acc_state_msg(False)] if self.SAFETY_PARAM_SP & ToyotaSafetyFlagsSP.UNSUPPORTED_DSU else []
|
||||
|
||||
def test_diagnostics(self, stock_longitudinal: bool = False, ecu_disabled: bool = True):
|
||||
for should_tx, msg in ((False, b"\x6D\x02\x3E\x00\x00\x00\x00\x00"), # fwdCamera tester present
|
||||
(False, b"\x0F\x03\xAA\xAA\x00\x00\x00\x00"), # non-tester present
|
||||
|
||||
@@ -1 +1 @@
|
||||
#define SUNNYPILOT_VERSION "2026.10.23-4973"
|
||||
#define SUNNYPILOT_VERSION "2026.003.000"
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user