From 6986840c0dfc965d599803b97a5f2b05166e1b9a Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Wed, 29 Jul 2020 14:39:53 +0200 Subject: [PATCH] Increase the receive timeout to 5 seconds When the fingerprint feature isn't used (or with a timestamp of zero), the response to the SIZE (0xC6) and DATA (0xC4) commands is received almost instantly: [0.302704] W: C60000000010270000 [0.366727] R: DCF90F00 [0.367829] W: C40000000010270000 [0.394812] R: E0F90F00 But when the fingerprint feature is used (with a non-zero timestamp), there is a noticable delay: [0.341218] W: C64CEB204D10270000 [1.927905] R: FE0B0000 [1.931610] W: C44CEB204D10270000 [5.092081] R: 020C0000 In this particular case, the total amount of dive data was close to 1M bytes, which pushed the delay over the 3 second timeout, and caused the download to fail. Increasing the timeout to 5 seconds fixed the problem. The most likely explanation is that the dive computer needs to scan its internal logbook to determine which dives and how many bytes to send. Because that involves reading relative slow flash memory, this can take up to a few seconds, especially if there are many dives present. The duration of the delay also depends on the value of the fingerprint timestamp: the less dives we try to download, the longer the delay! I suspect that's because the most recent dives are located near the end of the logbook. Hence, the less dives we request, the more dives the dive computer needs to skip. Below are some timings for downloading espectively 792410, 531856 and 270850 bytes from the same dive computer, but with a different fingerprint value: [0.216305] W: C6F8D5C84510270000 [0.373511] R: 56170C00 [0.378929] W: C4F8D5C84510270000 [0.661388] R: 5A170C00 [0.236246] W: C620D80F4810270000 [0.559608] R: 8C1D0800 [0.563755] W: C420D80F4810270000 [1.171631] R: 901D0800 [0.246193] W: C654E6434A10270000 [0.826365] R: FE210400 [0.831760] W: C454E6434A10270000 [1.974351] R: 02220400 --- src/uwatec_smart.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/uwatec_smart.c b/src/uwatec_smart.c index 23ce6b9..5918646 100644 --- a/src/uwatec_smart.c +++ b/src/uwatec_smart.c @@ -477,8 +477,8 @@ uwatec_smart_device_open (dc_device_t **out, dc_context_t *context, dc_iostream_ goto error_free; } - // Set the timeout for receiving data (3000ms). - status = dc_iostream_set_timeout (device->iostream, 3000); + // Set the timeout for receiving data (5000ms). + status = dc_iostream_set_timeout (device->iostream, 5000); if (status != DC_STATUS_SUCCESS) { ERROR (context, "Failed to set the timeout."); goto error_free;