controls not allowed by default

master
George Hotz 2017-05-01 23:40:49 -07:00
parent 8f859ceec6
commit 6cd08d6022
5 changed files with 15 additions and 2 deletions

View File

@ -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;

View File

@ -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;
}

View File

@ -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, '')

View File

@ -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]]:

View File

@ -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: