Mares Smart Apnea

Jef Driesen jef at libdivecomputer.org
Wed Sep 9 04:56:52 PDT 2015


On 2015-09-06 19:12, Giorgio Marzano wrote:
> I have some good news:
> 
> I have found thaf each diving session is made by:
> 1) 4 byte header. The first two are the total size in bytes of the 
> diving
> session
> 2) a sequence of "NSAMPLES" dives. Each dive is composed by a 14 bytes
> preamble (with dive time, surface time, max depth, ...) and a stream of
> exactly "divetime" 16-bit dive measurements.
> 3) an 80 bytes footer with the session overall data: date, time,
> temperature, max depth, ... I noticed that bytes 37 and 38  of this 
> footer
>  contain the TOTAL_DIVETIME, and that bytes 76 and 77 contain NSAMPLES.
> 
> So, to read backwards the diving session one could move back
> HEADER_SIZE + NSAMPLES * SAMPLE_HEADER_SIZE + 2 *
> TOTAL_DIVETIME+FOOTER_SIZE bytes,
> 
> where
> 
> HEADER_SIZE=4
> NSAMPLES = 16 bit value at -6 bytes from end of session
> SAMPLE_HEADER_SIZE = 14
> TOTAL_DIVETIME = 16 bit value at -44 bytes from end of session
> FOOTER_SIZE = 80
> 
> At that address you will find the first item of the session data which 
> is,
> by the way, exactly its size

Nice work! This looks all correct to me. With the attached smartapnea 
patch I'm able to locate the dives. This is definitely a step in the 
right direction. But of course this will need to be integrated in such a 
way that it doesn't break anything for the other variants. As I 
explained in my previous email, we need some way to detect the correct 
data format.

I noticed the nsamples and type fields moved back with two bytes and 
there are now two zero bytes at the end. Maybe that's something we can 
use? There might be other things in the header too.

> Attaching here an archive with:
> - a dump of my DC generated printing the "data[][]" and the 
> "buffer[][]"
> variables in the mares_iconhd_extract_dives function (run.log.20150906)
> - an annotated version of the above dump with my notes about the 
> meanings
> of the data (run.log.20150906.annotated)
> - the output.bin file generated by the "universal" utility
> - a folder with the dump of the mares SW that I used to decode the 
> dumps.
> They are all CSV files, with an ODS that I used to do some 
> calculations.
> 
> The relevant sessions are DiveOrganizer_2015-08-31T10.08.00 (quite 
> long)
> and DiveOrganizer_2015-08-10T18.56.00 (only 2 dives)

With the second patch the individual dives get dumped into separate 
files. That's a bit more practical than looking at one huge memory dump.

> My weekend spare time is over and I still have to figure out how to fit
> this in the library :(

Let's first get everything working, and then have a look at how to 
integrate it properly.

Jef
-------------- next part --------------
A non-text attachment was scrubbed...
Name: wip_smartapnea.patch
Type: text/x-diff
Size: 1622 bytes
Desc: not available
URL: <http://libdivecomputer.org/pipermail/devel/attachments/20150909/1e73bcc1/attachment.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: wip_universal_dives.patch
Type: text/x-diff
Size: 682 bytes
Desc: not available
URL: <http://libdivecomputer.org/pipermail/devel/attachments/20150909/1e73bcc1/attachment-0001.patch>


More information about the devel mailing list