Example #1
0
 def _send_gas_msg(self, gas):
     to_send = make_msg(0, 0x2C1)
     to_send[0].RDHR = (gas & 0xFF) << 16
     return to_send
Example #2
0
 def _speed_msg(self, speed):
   to_send = make_msg(0, 902)
   to_send[0].RDLR = speed & 0x3FFF;
   to_send[0].RDHR = (speed & 0x3FFF) << 16;
   return to_send
Example #3
0
 def _torque_msg(self, torque):
   to_send = make_msg(0, 832)
   to_send[0].RDLR = (torque + 1024) << 16
   return to_send
Example #4
0
 def test_disable_control_allowed_from_cruise(self):
   to_push = make_msg(0, 1057)
   self.safety.set_controls_allowed(1)
   self.safety.safety_rx_hook(to_push)
   self.assertFalse(self.safety.get_controls_allowed())
Example #5
0
 def _gas_msg(self, val):
   to_send = make_msg(0, 608)
   to_send[0].RDHR = (val & 0x3) << 30;
   return to_send
Example #6
0
 def _alt_brake_msg(self, brake):
     to_send = make_msg(0, 0x1BE)
     to_send[0].RDLR = 0x10 if brake else 0
     return to_send
Example #7
0
 def _send_steer_msg(self, steer):
     to_send = make_msg(0, 0xE4, 6)
     to_send[0].RDLR = steer
     return to_send
Example #8
0
 def _gas_msg(self, gas):
     to_send = make_msg(0, 308)
     to_send[0].RDHR = (gas & 0x7F) << 8
     to_send[0].RDHR |= (self.cnt_gas % 16) << 20
     self.__class__.cnt_gas += 1
     return to_send
Example #9
0
 def _gas_msg(self, gas):
     to_send = make_msg(0, 0x121)
     to_send[0].RDLR = (gas & 0xFF) << 12
     return to_send
Example #10
0
 def _torque_msg(self, torque):
     to_send = make_msg(0, 0x292)
     to_send[0].RDLR = ((torque + 1024) >> 8) + ((
         (torque + 1024) & 0xff) << 8)
     return to_send
Example #11
0
 def _speed_msg(self, speed):
     speed = int(speed / 0.071028)
     to_send = make_msg(0, 514, 4)
     to_send[0].RDLR = ((speed & 0xFF0) >> 4) + ((speed & 0xF) << 12) + \
                       ((speed & 0xFF0) << 12) + ((speed & 0xF) << 28)
     return to_send
Example #12
0
 def _accel_msg(self, accel):
     to_send = make_msg(0, 0x343)
     a = twos_comp(accel, 16)
     to_send[0].RDLR = (a & 0xFF) << 8 | (a >> 8)
     return to_send
Example #13
0
 def _torque_msg(self, torque):
     t = twos_comp(torque, 16)
     to_send = make_msg(0, 0x2E4)
     to_send[0].RDLR = t | ((t & 0xFF) << 16)
     return to_send
Example #14
0
 def _pcm_cruise_msg(self, cruise_on):
     to_send = make_msg(0, 0x1D2)
     to_send[0].RDLR = cruise_on << 5
     to_send[0].RDHR = to_send[0].RDHR | (
         toyota_checksum(to_send[0], 0x1D2, 8) << 24)
     return to_send
Example #15
0
    def _speed_msg(self, speed):
        to_send = make_msg(0, 0x1a0)
        speed = int(speed / 0.103)
        to_send[0].RDLR = (speed & 0xFFF)

        return to_send
Example #16
0
 def _button_msg(self, bit):
     to_send = make_msg(2, 0x12B)
     to_send[0].RDLR = 1 << bit
     return to_send
Example #17
0
    def _brake_msg(self, brake):
        to_send = make_msg(0, 168)
        to_send[0].RDHR = (brake * 0x3) << (61 - 32)

        return to_send
Example #18
0
 def test_enable_control_allowed_from_cruise(self):
     to_push = make_msg(0, 0x122)
     to_push[0].RDHR = 0x30000000
     self.safety.safety_rx_hook(to_push)
     self.assertTrue(self.safety.get_controls_allowed())
Example #19
0
 def _send_brake_msg(self, brake):
     to_send = make_msg(0, 0x1FA)
     to_send[0].RDLR = ((brake & 0x3) << 14) | ((brake & 0x3FF) >> 2)
     return to_send
Example #20
0
    def _lkas_state_msg(self, state):
        to_send = make_msg(0, 0x1b6)
        to_send[0].RDHR = (state & 0x1) << 6

        return to_send
Example #21
0
 def _interceptor_msg(self, gas, addr):
     to_send = make_msg(0, addr, 6)
     to_send[0].RDLR = ((gas & 0xff) << 8) | ((gas & 0xff00) >> 8) | \
                       ((gas & 0xff) << 24) | ((gas & 0xff00) << 8)
     return to_send
Example #22
0
    def _speed_msg(self, speed):
        to_send = make_msg(0, 0x29a)
        speed = int(speed / 0.00555 * 3.6)
        to_send[0].RDLR = ((speed & 0xFF) << 24) | ((speed & 0xFF00) << 8)

        return to_send
Example #23
0
 def _button_msg(self, buttons):
   to_send = make_msg(0, 1265)
   to_send[0].RDLR = buttons
   return to_send
Example #24
0
    def _brake_msg(self, brake):
        to_send = make_msg(1, 0x454)
        to_send[0].RDLR = ((brake & 0x1) << 23)

        return to_send
Example #25
0
 def _brake_msg(self, brake):
   to_send = make_msg(0, 916)
   to_send[0].RDHR = brake << 23;
   return to_send
Example #26
0
    def _send_gas_cmd(self, gas):
        to_send = make_msg(0, 0x15c)
        to_send[0].RDHR = ((gas & 0x3fc) << 6) | ((gas & 0x3) << 22)

        return to_send
Example #27
0
 def _torque_driver_msg(self, torque):
   to_send = make_msg(0, 897)
   to_send[0].RDLR = (torque + 2048) << 11
   return to_send
Example #28
0
    def _acc_button_cmd(self, buttons):
        to_send = make_msg(2, 0x20b)
        to_send[0].RDLR = (buttons << 8)

        return to_send
Example #29
0
 def test_enable_control_allowed_from_cruise(self):
   to_push = make_msg(0, 1057)
   to_push[0].RDLR = 1 << 13
   self.safety.safety_rx_hook(to_push)
   self.assertTrue(self.safety.get_controls_allowed())
Example #30
0
 def _brake_msg(self, brake):
     to_send = make_msg(0, MSG_MOTOR_2)
     to_send[0].RDLR = (0x1 << 16) if brake else 0
     # since this siganl's used for engagement status, preserve current state
     to_send[0].RDLR |= (self.safety.get_controls_allowed() & 0x3) << 22
     return to_send