diff --git a/flight/pios/stm32f10x/pios_usb_cdc.c b/flight/pios/stm32f10x/pios_usb_cdc.c index 1a04f00f5..c321afab5 100644 --- a/flight/pios/stm32f10x/pios_usb_cdc.c +++ b/flight/pios/stm32f10x/pios_usb_cdc.c @@ -69,7 +69,12 @@ struct pios_usb_cdc_dev { uint32_t tx_out_context; uint8_t rx_packet_buffer[PIOS_USB_BOARD_CDC_DATA_LENGTH]; - uint8_t tx_packet_buffer[PIOS_USB_BOARD_CDC_DATA_LENGTH]; + /* + * NOTE: This is -1 as somewhat of a hack. It ensures that we always send packets + * that are strictly < maxPacketSize for this interface which means we never have + * to bother with zero length packets (ZLP). + */ + uint8_t tx_packet_buffer[PIOS_USB_BOARD_CDC_DATA_LENGTH - 1]; uint32_t rx_dropped; uint32_t rx_oversize; diff --git a/flight/pios/stm32f4xx/pios_usb_cdc.c b/flight/pios/stm32f4xx/pios_usb_cdc.c index 0b47c880b..cb0ce9bc7 100644 --- a/flight/pios/stm32f4xx/pios_usb_cdc.c +++ b/flight/pios/stm32f4xx/pios_usb_cdc.c @@ -73,7 +73,12 @@ struct pios_usb_cdc_dev { uint8_t rx_packet_buffer[PIOS_USB_BOARD_CDC_DATA_LENGTH] __attribute__ ((aligned(4))); volatile bool rx_active; - uint8_t tx_packet_buffer[PIOS_USB_BOARD_CDC_DATA_LENGTH] __attribute__ ((aligned(4))); + /* + * NOTE: This is -1 as somewhat of a hack. It ensures that we always send packets + * that are strictly < maxPacketSize for this interface which means we never have + * to bother with zero length packets (ZLP). + */ + uint8_t tx_packet_buffer[PIOS_USB_BOARD_CDC_DATA_LENGTH - 1] __attribute__ ((aligned(4))); volatile bool tx_active; uint8_t ctrl_tx_packet_buffer[PIOS_USB_BOARD_CDC_MGMT_LENGTH] __attribute__ ((aligned(4)));