Improved some code comments.
This commit is contained in:
parent
4d4b0f141f
commit
d265228b26
@ -421,12 +421,12 @@ suunto_vyper_read_dive (vyper *device, unsigned char data[], unsigned int size,
|
|||||||
rc = serial_read (device->port, header, 2);
|
rc = serial_read (device->port, header, 2);
|
||||||
if (rc != 2 || memcmp (command, header, 1) != 0 ||
|
if (rc != 2 || memcmp (command, header, 1) != 0 ||
|
||||||
header[1] > SUUNTO_VYPER_PACKET_SIZE) {
|
header[1] > SUUNTO_VYPER_PACKET_SIZE) {
|
||||||
// If no data is received at this point (a timeout occured),
|
// If no data is received because a timeout occured, we assume
|
||||||
// we assume the last package was already received and the
|
// the last package was already received and the transmission
|
||||||
// transmission should be finished. This is not 100% reliable,
|
// can be finished. Unfortunately this is not 100% reliable,
|
||||||
// because there is always a small chance that more data will
|
// because there is always a small chance that more data will
|
||||||
// arrive later (especially with a short timeout). But I'm not
|
// arrive later (especially with a short timeout). But it works
|
||||||
// aware of a better method to detect the end of the transmission.
|
// good enough in practice.
|
||||||
// Only for the very first package, we can be sure there was
|
// Only for the very first package, we can be sure there was
|
||||||
// an error, because the DC always sends at least one package.
|
// an error, because the DC always sends at least one package.
|
||||||
if (rc == 0 && npackages != 0)
|
if (rc == 0 && npackages != 0)
|
||||||
@ -465,11 +465,10 @@ suunto_vyper_read_dive (vyper *device, unsigned char data[], unsigned int size,
|
|||||||
return SUUNTO_VYPER_ERROR_MEMORY;
|
return SUUNTO_VYPER_ERROR_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
// A null package (length zero) indicates the DC reached the end of
|
// The DC sends a null package (a package with length zero) when it
|
||||||
// its internal ring buffer and the transmission should be aborted.
|
// has reached the end of its internal ring buffer. From this point on,
|
||||||
// The remaining data of the current dive is overwritten with newer
|
// the current dive has been overwritten with newer data. Therefore,
|
||||||
// data and thus not transmitted by the DC. Therefore, the data that
|
// we discard the current (incomplete) dive and end the transmission.
|
||||||
// was already received is discarded.
|
|
||||||
if (len == 0)
|
if (len == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@ -481,9 +480,10 @@ suunto_vyper_read_dive (vyper *device, unsigned char data[], unsigned int size,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The DC traverses the internal ring buffer backwards while sending.
|
// The DC traverses its internal ring buffer backwards. The most recent
|
||||||
// Therefore, we restore the original order before returning the
|
// dive is send first (which allows you to download only the new dives),
|
||||||
// data to the application.
|
// but also the contents of each dive is reversed. Therefore, we reverse
|
||||||
|
// the bytes again before returning them to the application.
|
||||||
suunto_vyper_reverse (data, nbytes);
|
suunto_vyper_reverse (data, nbytes);
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user