Increase the timeout to 3 seconds
The BLE communication is significant slower than usb-serial. The first BLE data packet of each response often takes longer than one second to arrive. This causes the first attempt to fail with a timeout. The second attempt will appear to succeed, because it actually receives the response of the first attempt. But now the next command will fail, because it will receive the response of the second attempt of the previous command. Increasing the timeout and adding an extra delay before retrying, avoids this problem. Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
02ae8d3fdb
commit
018198dc17
@ -326,6 +326,7 @@ mares_iconhd_transfer (mares_iconhd_device_t *device, const unsigned char comman
|
||||
return rc;
|
||||
|
||||
// Discard any garbage bytes.
|
||||
dc_iostream_sleep (device->iostream, 100);
|
||||
dc_iostream_purge (device->iostream, DC_DIRECTION_INPUT);
|
||||
device->available = 0;
|
||||
device->offset = 0;
|
||||
@ -482,8 +483,8 @@ mares_iconhd_device_open (dc_device_t **out, dc_context_t *context, dc_iostream_
|
||||
goto error_free;
|
||||
}
|
||||
|
||||
// Set the timeout for receiving data (1000 ms).
|
||||
status = dc_iostream_set_timeout (device->iostream, 1000);
|
||||
// Set the timeout for receiving data (3000 ms).
|
||||
status = dc_iostream_set_timeout (device->iostream, 3000);
|
||||
if (status != DC_STATUS_SUCCESS) {
|
||||
ERROR (context, "Failed to set the timeout.");
|
||||
goto error_free;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user