mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-11-29 07:24:13 +01:00
usb cdc: avoid need for ZLP by using tx buffers smaller than max
USB CDC uses BULK endpoints to send/receive data. Typically, a USB host will enqueue large buffers on its IN (device-to-host) URBs. These buffers are larger than the max packet size for the bulk endpoint. The USB standard requires that an IN transfer ends when one of these is true: * a short packet (ie. less than max packet size) is sent by the device * a zero length packet (ZLP) * enough packets that the entire host buffer is filled Our device implementation never sends ZLPs. We sometimes send packets that are exactly max-packet-size bytes long. This would result in partially filling a host buffer without signalling (via ZLP) that the transmission had finished. The host would then wait until the next transfer had taken place before processing the first data, thus delaying the first data. This change simply forces all of our transfers to be short packets and avoids the need to worry about zero length packets. This is at the cost of some efficiency on the host side since its large buffers will only ever be partially filled. Conflicts: flight/PiOS/STM32F30x/pios_usb_cdc.c
This commit is contained in:
parent
366c573bab
commit
c22daec1b0
@ -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;
|
||||
|
@ -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)));
|
||||
|
Loading…
Reference in New Issue
Block a user