master
Vasily Tarasov 2017-07-04 16:42:15 -07:00 committed by Jessy Diamond Exum
parent 5e1e45a4af
commit 41e5eec621
1 changed files with 17 additions and 17 deletions

View File

@ -523,29 +523,29 @@ int usb_cb_control_msg(USB_Setup_TypeDef *setup, uint8_t *resp, int hardwired) {
puts("\n");
if (canid >= CAN_MAX){
puts(" Out of range!\n");
return -1;
puts(" Out of range!\n");
return -1;
}
can_port_desc *port = &can_ports[canid];
//Fail if canid doesn't support gmlan
if(!port->gmlan_support)
return -1;
return -1;
//ACK the USB pipe but don't do anything; nothing to do.
if(port->gmlan == gmlan_enable){
puts("The CAN bus is already in the requested gmlan config.\n");
break;
puts("The CAN bus is already in the requested gmlan config.\n");
break;
}
// Check to see if anyther canid is acting as gmlan, disable it.
if(gmlan_enable)
for(i = 0; i < CAN_MAX; i++)
if(can_ports[i].gmlan){
puts("Disable old gmlan mode\n");
set_can_mode(i, 0);
}
for(i = 0; i < CAN_MAX; i++)
if(can_ports[i].gmlan){
puts("Disable old gmlan mode\n");
set_can_mode(i, 0);
}
set_can_mode(canid, gmlan_enable);
break;
@ -560,21 +560,21 @@ int usb_cb_control_msg(USB_Setup_TypeDef *setup, uint8_t *resp, int hardwired) {
break;
case 0xdd: // enable can forwarding
if (setup->b.wValue.w < CAN_MAX) { //Set forwarding
can_ports[setup->b.wValue.w].forwarding = setup->b.wIndex.w;
can_ports[setup->b.wValue.w].forwarding = setup->b.wIndex.w;
}else if(setup->b.wValue.w == 0xFF){ //Clear Forwarding
can_ports[setup->b.wValue.w].forwarding = -1;
can_ports[setup->b.wValue.w].forwarding = -1;
}else
return -1;
return -1;
break;
case 0xde: // Set Can bitrate
if (!(setup->b.wValue.w < CAN_MAX && setup->b.wLength.w == 4))
return -1;
return -1;
break;
case 0xdf: // Get Can bitrate
if (setup->b.wValue.w < CAN_MAX) {
memcpy(resp, (void *)&can_ports[setup->b.wValue.w].bitrate, 4);
resp_len = 4;
break;
memcpy(resp, (void *)&can_ports[setup->b.wValue.w].bitrate, 4);
resp_len = 4;
break;
}
puts("Invalid num\n");
return -1;