The Uwatec Smart stores a sample value only when it's diffent from the
previous value. While this compressed format does save some space on the
device, it is less practical for use in an application. The original
uncompressed data can easily be obtained by copying missing sample
values from the previous sample.
The implementation uses a two pass approach. In the first pass, all
sample values that are explicitly stored in the profile date are
collected. Any sample value that is not present, will automatically
retain the value from the previous sample. In the second pass, all
sample values are passed back to the application. The presence of an
absolute value is used to decide which sample types are present in the
data.
The total memory size is hardcoded again because the protocol does not
allow to retrieve the correct memory layout in advance. As long as there
is no device with a different amount of memory, that should be fine.
When trying to read the last memory page from an Oceanic Atom 2, the
device does not respond. Strangely, other compatible devices are not
affected by this problem.
The Suunto Vyper, Spyder and Eon store a surface event after the last
depth sample. Adding an artificial zero depth sample avoids the problem
of having an incomplete sample without a depth measurement.
Because these devices also store the tank pressure and/or the
temperature at the begin/end of the dive, these measurements are
associated with the new surface samples.
The mingw native 64bit integer type is long long. The msvc __int64 type
is supported for compatibility reasons, but requires including one of
the standard C header files.
The internal memory appears to contain two separate areas. One for the
normal dives and one for the freedives. Currently, only the freedive
section is processed.
If the first few bytes of the timestamp are equal to zero, they were
incorrectly identified as part of the header marker. The correct header
marker is located a the start of this zero byte sequence, not the end.
Because the sample data contains a timestamp with a limited resolution
of only one minute, there can be consecutive samples with identical
timestamps. To deal with this situation, samples with identical
timestamps are distributed evenly inside the one minute interval. All
resulting non-integer timestamps are rounded to the nearest second.
For dives with a time based interval, the timestamps are now validated.
Not all devices appear to send the last zero byte, resulting in a
timeout. If a device does send this zero byte, it is automatically
flushed when sending the next command.
When the Sensus Ultra reaches the end of a memory page while recording
data, the next page is erased to all 0xFF, and the current page cursor
is advanced. With this memory usage scheme, the last page will be empty
if the previous one was just filled.