diff options
author | Marti Bolivar <mbolivar@leaflabs.com> | 2013-01-18 18:08:01 -0500 |
---|---|---|
committer | Marti Bolivar <mbolivar@leaflabs.com> | 2013-01-18 18:12:21 -0500 |
commit | 369f98af8dfdf0cf7610e735883b12a151c78260 (patch) | |
tree | c983e00039363add7f9a7dce857527f66b8de2c1 /wirish | |
parent | e7eac89b679f4dda632ff45da135207dbc1c8edb (diff) | |
parent | afb4199070e464c317b86741e107692120e05097 (diff) | |
download | librambutan-369f98af8dfdf0cf7610e735883b12a151c78260.tar.gz librambutan-369f98af8dfdf0cf7610e735883b12a151c78260.zip |
Merge branch 'bug/usb-full-ep'
This resolves issues related to sending full (64B) packets via USB
2.0. In this case, some hosts continue to expect more data. Add
infrastructure for sending 0-byte packets to signal end of
transmission, and use it in SerialUSB.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
Diffstat (limited to 'wirish')
-rw-r--r-- | wirish/usb_serial.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/wirish/usb_serial.cpp b/wirish/usb_serial.cpp index 380f197..d21766f 100644 --- a/wirish/usb_serial.cpp +++ b/wirish/usb_serial.cpp @@ -92,13 +92,24 @@ void USBSerial::write(const void *buf, uint32 len) { uint32 old_txed = 0; uint32 start = millis(); + uint32 sent = 0; + while (txed < len && (millis() - start < USB_TIMEOUT)) { - txed += usb_cdcacm_tx((const uint8*)buf + txed, len - txed); + sent = usb_cdcacm_tx((const uint8*)buf + txed, len - txed); + txed += sent; if (old_txed != txed) { start = millis(); } old_txed = txed; } + + + if (sent == USB_CDCACM_TX_EPSIZE) { + while (usb_cdcacm_is_transmitting() != 0) { + } + /* flush out to avoid having the pc wait for more data */ + usb_cdcacm_tx(NULL, 0); + } } uint32 USBSerial::available(void) { |