From da4a8a90c77a5f3e4633a92d7820213517927e58 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Tue, 10 Mar 2020 22:58:48 +0100 Subject: [PATCH] Add an extra delay after writing to the flash memory The S_BLOCK_WRITE (0x30) command sends a stream of bytes to the dive computer. Because the payload has no fixed length and there is no length field included, the hwOS firmware detects the end of the stream by means of a 400ms timeout. Therefore the ready byte is always delayed by this 400ms timeout. The same remark applies to the DISPLAY (0x6E) and CUSTOMTEXT (0x63) commands. But because libdivecomputer always pad the text with zeros and sends the maximum payload size, we won't hit the timeout. Reported-by: Ralph Lembcke --- src/hw_ostc3.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/hw_ostc3.c b/src/hw_ostc3.c index 552ed54..0b980e7 100644 --- a/src/hw_ostc3.c +++ b/src/hw_ostc3.c @@ -81,6 +81,7 @@ #define CR 0x05 #define NODELAY 0 +#define TIMEOUT 400 typedef enum hw_ostc3_state_t { OPEN, @@ -1253,7 +1254,7 @@ hw_ostc3_firmware_block_write (hw_ostc3_device_t *device, unsigned int addr, con array_uint24_be_set (buffer, addr); memcpy (buffer + 3, block, block_size); - return hw_ostc3_transfer (device, NULL, S_BLOCK_WRITE, buffer, 3 + block_size, NULL, 0, NODELAY); + return hw_ostc3_transfer (device, NULL, S_BLOCK_WRITE, buffer, 3 + block_size, NULL, 0, TIMEOUT); } static dc_status_t