mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-18 08:54:15 +01:00
usbcdc: don't assert on calls when CDC is not initialized
The CDC interface is always advertised in the FW USB descriptors. It is NOT always enabled/initialized at runtime. Specifically, it can be Disabled in HwSettings. Previously, any CDC-related query that the host would send resulted in an assert and a watchdog. Now, a suitable return code indicating that the request is unsupported is returned in this scenario.
This commit is contained in:
parent
570917f331
commit
c056ac5261
@ -321,7 +321,10 @@ RESULT PIOS_USB_CDC_SetControlLineState(void)
|
||||
struct pios_usb_cdc_dev * usb_cdc_dev = (struct pios_usb_cdc_dev *)pios_usb_cdc_id;
|
||||
|
||||
bool valid = PIOS_USB_CDC_validate(usb_cdc_dev);
|
||||
PIOS_Assert(valid);
|
||||
if (!valid) {
|
||||
/* No CDC interface is configured */
|
||||
return USB_UNSUPPORT;
|
||||
}
|
||||
|
||||
uint8_t wValue0 = pInformation->USBwValue0;
|
||||
uint8_t wValue1 = pInformation->USBwValue1;
|
||||
@ -343,7 +346,10 @@ RESULT PIOS_USB_CDC_SetLineCoding(void)
|
||||
struct pios_usb_cdc_dev * usb_cdc_dev = (struct pios_usb_cdc_dev *)pios_usb_cdc_id;
|
||||
|
||||
bool valid = PIOS_USB_CDC_validate(usb_cdc_dev);
|
||||
PIOS_Assert(valid);
|
||||
if (!valid) {
|
||||
/* No CDC interface is configured */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return USB_SUCCESS;
|
||||
}
|
||||
@ -353,7 +359,10 @@ const uint8_t *PIOS_USB_CDC_GetLineCoding(uint16_t Length)
|
||||
struct pios_usb_cdc_dev * usb_cdc_dev = (struct pios_usb_cdc_dev *)pios_usb_cdc_id;
|
||||
|
||||
bool valid = PIOS_USB_CDC_validate(usb_cdc_dev);
|
||||
PIOS_Assert(valid);
|
||||
if (!valid) {
|
||||
/* No CDC interface is configured */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (Length == 0) {
|
||||
pInformation->Ctrl_Info.Usb_wLength = sizeof(line_coding);
|
||||
|
@ -341,7 +341,7 @@ static RESULT PIOS_USBHOOK_Data_Setup(uint8_t RequestNo)
|
||||
case 0: /* CDC Call Control Interface */
|
||||
switch (RequestNo) {
|
||||
case USB_CDC_REQ_GET_LINE_CODING:
|
||||
//CopyRoutine = PIOS_USB_CDC_GetLineCoding;
|
||||
CopyInRoutine = PIOS_USB_CDC_GetLineCoding;
|
||||
break;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user