Skip to content

Commit

Permalink
Safety: increase buffer for sampled signals. TBD a violation feedback…
Browse files Browse the repository at this point in the history
… from board to prevent car faults
  • Loading branch information
Commaremote committed Jun 4, 2018
1 parent b0541a8 commit bf70f51
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions board/safety.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// sample struct that keeps 3 samples in memory
struct sample_t {
int values[3];
int values[6];
int min;
int max;
} sample_t_default = {{0, 0, 0}, 0, 0};
} sample_t_default = {{0}, 0, 0};

void safety_rx_hook(CAN_FIFOMailBox_TypeDef *to_push);
int safety_tx_hook(CAN_FIFOMailBox_TypeDef *to_send);
Expand Down
3 changes: 1 addition & 2 deletions board/safety/safety_cadillac.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ static void cadillac_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) {
if (addr == 356) {
int torque_driver_new = ((to_push->RDLR & 0x7) << 8) | ((to_push->RDLR >> 8) & 0xFF);
torque_driver_new = to_signed(torque_driver_new, 11);

// update array of sample
// update array of samples
update_sample(&cadillac_torque_driver, torque_driver_new);
}

Expand Down
7 changes: 5 additions & 2 deletions tests/safety/test_toyota.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def _torque_driver_msg(self, torque):
return to_send

def _torque_driver_msg_array(self, torque):
for i in range(3):
for i in range(6):
self.safety.toyota_ipas_rx_hook(self._torque_driver_msg(torque))

def _angle_meas_msg(self, angle):
Expand All @@ -74,7 +74,7 @@ def _angle_meas_msg(self, angle):
return to_send

def _angle_meas_msg_array(self, angle):
for i in range(3):
for i in range(6):
self.safety.toyota_ipas_rx_hook(self._angle_meas_msg(angle))

def _torque_msg(self, torque):
Expand Down Expand Up @@ -229,6 +229,9 @@ def test_torque_measurements(self):
self.safety.toyota_rx_hook(self._torque_meas_msg(50))
self.safety.toyota_rx_hook(self._torque_meas_msg(-50))
self.safety.toyota_rx_hook(self._torque_meas_msg(0))
self.safety.toyota_rx_hook(self._torque_meas_msg(0))
self.safety.toyota_rx_hook(self._torque_meas_msg(0))
self.safety.toyota_rx_hook(self._torque_meas_msg(0))

self.assertEqual(-51, self.safety.get_torque_meas_min())
self.assertEqual(51, self.safety.get_torque_meas_max())
Expand Down

0 comments on commit bf70f51

Please sign in to comment.