Skip to content

Commit

Permalink
safety tests: set gas interceptor counter (#1775)
Browse files Browse the repository at this point in the history
* safety: check interceptor msg counter (#1738)

* toyota: check interceptor counter

* add counters and check rx

* honda: check counter

* clean up

* revert

* typing
  • Loading branch information
sshane authored Dec 14, 2023
1 parent e514113 commit 30647d6
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions tests/safety/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,21 +122,29 @@ class GasInterceptorSafetyTest(PandaSafetyTestBase):

INTERCEPTOR_THRESHOLD = 0

cnt_gas_cmd = 0
cnt_user_gas = 0

packer: CANPackerPanda

@classmethod
def setUpClass(cls):
if cls.__name__ == "GasInterceptorSafetyTest":
cls.safety = None
raise unittest.SkipTest

def _interceptor_gas_cmd(self, gas):
values = {}
def _interceptor_gas_cmd(self, gas: int):
values: dict[str, float | int] = {"COUNTER_PEDAL": self.__class__.cnt_gas_cmd & 0xF}
if gas > 0:
values["GAS_COMMAND"] = gas * 255.
values["GAS_COMMAND2"] = gas * 255.
self.__class__.cnt_gas_cmd += 1
return self.packer.make_can_msg_panda("GAS_COMMAND", 0, values)

def _interceptor_user_gas(self, gas):
values = {"INTERCEPTOR_GAS": gas, "INTERCEPTOR_GAS2": gas}
def _interceptor_user_gas(self, gas: int):
values = {"INTERCEPTOR_GAS": gas, "INTERCEPTOR_GAS2": gas,
"COUNTER_PEDAL": self.__class__.cnt_user_gas}
self.__class__.cnt_user_gas += 1
return self.packer.make_can_msg_panda("GAS_SENSOR", 0, values)

def test_prev_gas_interceptor(self):
Expand Down

0 comments on commit 30647d6

Please sign in to comment.