Skip to content

Commit 7f3a471

Browse files
committed
pbio/drv/usb_ev3: extend transmit timeout
We are getting connection drops because host applications don't always read data in a timely manner. Ideally, we would remove this timeout completely, but some other work needs to be done to make that feasible.
1 parent aa8785c commit 7f3a471

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/pbio/drv/usb/usb_ev3.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -967,6 +967,8 @@ static pbio_error_t pbdrv_usb_ev3_process_thread(pbio_os_state_t *state, void *c
967967
is_transmitting = usb_tx_response_is_not_ready || usb_tx_status_is_not_ready || usb_tx_stdout_is_not_ready;
968968
if (was_transmitting && is_transmitting) {
969969
if (pbio_os_timer_is_expired(&tx_timeout_timer)) {
970+
// TODO: these state flags should also be reset when USB is
971+
// disconnected and if a host resets the device.
970972
// Flush _all_ TX packets
971973
while (HWREGB(USB0_BASE + USB_O_TXCSRL1) & USB_TXCSRL1_TXRDY) {
972974
HWREGB(USB0_BASE + USB_O_TXCSRL1) = USB_TXCSRL1_FLUSH;
@@ -984,7 +986,9 @@ static pbio_error_t pbdrv_usb_ev3_process_thread(pbio_os_state_t *state, void *c
984986
prev_status_flags = ~0;
985987
}
986988
} else if (!was_transmitting && is_transmitting) {
987-
pbio_os_timer_set(&tx_timeout_timer, 50);
989+
// TODO: remove this timer - apps can "sleep" for a while, so this
990+
// will break apps that do that
991+
pbio_os_timer_set(&tx_timeout_timer, 5000);
988992
}
989993
was_transmitting = is_transmitting;
990994

0 commit comments

Comments
 (0)