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