From de3fb61c0a1c47cbdeabe0d54b9387a8bb0758d5 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Sun, 4 Nov 2007 13:12:50 +0000 Subject: [PATCH] Handle null packages correctly. Abort the transmission and discard the data if a null package is received at the end of the internal ring buffer. --- suunto_vyper.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/suunto_vyper.c b/suunto_vyper.c index fefa642..aeac732 100644 --- a/suunto_vyper.c +++ b/suunto_vyper.c @@ -528,6 +528,14 @@ suunto_vyper_read_dive (vyper *device, unsigned char data[], unsigned int size, return -1; } + // A null package (length zero) indicates the DC reached the end of + // its internal ring buffer and the transmission should be aborted. + // The remaining data of the current dive is overwritten with newer + // data and thus not transmitted by the DC. Therefore, the data that + // was already received is discarded. + if (len == 0) + return 0; + // If a package is smaller than $SUUNTO_VYPER_PACKET_SIZE bytes, // we assume it's the last packet and the transmission can be // finished early. However, this approach does not work if the