mirror of https://github.com/commaai/panda.git
controls not allowed by default
This commit is contained in:
parent
8f859ceec6
commit
6cd08d6022
|
@ -622,6 +622,9 @@ int usb_cb_control_msg(USB_Setup_TypeDef *setup, uint8_t *resp, int hardwired) {
|
|||
case 0xdb: // toggle GMLAN
|
||||
set_can2_mode(setup->b.wValue.w);
|
||||
break;
|
||||
case 0xdc: // set controls allowed
|
||||
controls_allowed = setup->b.wValue.w == 0x1337;
|
||||
break;
|
||||
case 0xe0: // uart read
|
||||
ur = get_ring_by_number(setup->b.wValue.w);
|
||||
if (!ur) break;
|
||||
|
|
|
@ -4,10 +4,10 @@ void safety_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) {
|
|||
}
|
||||
|
||||
int safety_tx_hook(CAN_FIFOMailBox_TypeDef *to_send, int hardwired) {
|
||||
return hardwired;
|
||||
return hardwired && controls_allowed;
|
||||
}
|
||||
|
||||
int safety_tx_lin_hook(int lin_num, uint8_t *data, int len, int hardwired) {
|
||||
return hardwired;
|
||||
return hardwired && controls_allowed;
|
||||
}
|
||||
|
||||
|
|
|
@ -105,6 +105,12 @@ class Panda(object):
|
|||
|
||||
# ******************* configuration *******************
|
||||
|
||||
def set_controls_allowed(self, on):
|
||||
if on:
|
||||
self.handle.controlWrite(usb1.TYPE_VENDOR | usb1.RECIPIENT_DEVICE, 0xdc, 0x1337, 0, '')
|
||||
else:
|
||||
self.handle.controlWrite(usb1.TYPE_VENDOR | usb1.RECIPIENT_DEVICE, 0xdc, 0, 0, '')
|
||||
|
||||
def set_gmlan(self, on):
|
||||
if on:
|
||||
self.handle.controlWrite(usb1.TYPE_VENDOR | usb1.RECIPIENT_DEVICE, 0xdb, 1, 0, '')
|
||||
|
|
|
@ -25,6 +25,9 @@ def run_test():
|
|||
h = map(lambda x: Panda(x), pandas)
|
||||
print h
|
||||
|
||||
h[0].set_controls_allowed(True)
|
||||
h[1].set_controls_allowed(True)
|
||||
|
||||
# test both directions
|
||||
for ho in [[0,1], [1,0]]:
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ if __name__ == "__main__":
|
|||
p = Panda()
|
||||
print p.health()
|
||||
print p.get_serial()
|
||||
p.set_controls_allowed(True)
|
||||
|
||||
a = 0
|
||||
while 1:
|
||||
|
|
Loading…
Reference in New Issue