<div dir="ltr">Hi,<div><br></div><div>thanks for your answer. </div><div><br></div><div>I have some good news:</div><div><br></div><div>I have found thaf each diving session is made by:</div><div>1) 4 byte header. The first two are the total size in bytes of the diving session</div><div>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.</div><div>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. </div><div><br></div><div>So, to read backwards the diving session one could move back</div><div><div>HEADER_SIZE + NSAMPLES * SAMPLE_HEADER_SIZE + 2 * TOTAL_DIVETIME+FOOTER_SIZE bytes, </div><div><br></div><div>where</div></div><div><br></div><div>HEADER_SIZE=4<br></div><div>NSAMPLES = 16 bit value at -6 bytes from end of session<br></div><div>SAMPLE_HEADER_SIZE = 14<br></div><div>TOTAL_DIVETIME = 16 bit value at -44 bytes from end of session</div><div>FOOTER_SIZE = 80<br></div><div><br></div><div>At that address you will find the first item of the session data which is, by the way, exactly its size</div><div><br></div><div>Attaching here an archive with:</div><div>- a dump of my DC generated printing the "data[][]" and the "buffer[][]" variables in the mares_iconhd_extract_dives function (run.log.20150906)</div><div>- an annotated version of the above dump with my notes about the meanings of the data (run.log.20150906.annotated)</div><div>- the output.bin file generated by the "universal" utility</div><div>- 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. </div><div><br></div><div>The relevant sessions are DiveOrganizer_2015-08-31T10.08.00 (quite long) and DiveOrganizer_2015-08-10T18.56.00 (only 2 dives)</div><div><br></div><div>My weekend spare time is over and I still have to figure out how to fit this in the library :(</div><div><br></div><div>Ciao</div><div><br></div><div>G</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2015-09-06 9:47 GMT+02:00 Jef Driesen <span dir="ltr"><<a href="mailto:jef@libdivecomputer.org" target="_blank">jef@libdivecomputer.org</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><span class="">I m currently travelling and will send a more detailed answer later.<br>
<br>
The backwards reading is by design. We always download the most recent dives first. That allows to stop downloading once we detect a previously downloaded dive. Normally we download dive per dive and not a full memory dump, but that has not been implemented yet for the iconhd. Thus starting at the start isnt even possible (especially if we only have the eop pointer).<br>
<br>
The format you describe reminds me of the nemo freedive format, which also records an entire freedive session as a dive. I need to have a closer first (on a phone only right now), but we may need to hop through all the samples to find the start of the dive.<br>
<br>
Larger attachments are fine if they are helpful. Try to compress them to keep size as small as possible.<br><br></span><div class="gmail_quote"><span class="">On September 6, 2015 2:00:14 AM CEST, Giorgio Marzano <<a href="mailto:marzano.giorgio@gmail.com" target="_blank">marzano.giorgio@gmail.com</a>> wrote:</span><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div class="h5">
<div dir="ltr"><div class="gmail_extra">Again on the Mares Smart Apnea topic. </div><div class="gmail_extra"><br></div><div class="gmail_extra">I think I have found a problem on the current SW implementation and I need some advice. Sorry for the long message.</div><div class="gmail_extra"><br></div><div class="gmail_extra"><br></div><div class="gmail_extra">I have dumped my DC logbook, and some cross checking between the code and the expected results from the mares SW. </div><div class="gmail_extra"><br></div><div class="gmail_extra">I think I have found some problem in the code. </div><div class="gmail_extra">In the function "mares_iconhd_extract_dives" it seems to me that the code points to the very end of the buffer, then it starts crawling back to the beginning of the last immersion:</div><div class="gmail_extra"></div><div class="gmail_extra"><br></div><div class="gmail_extra">offset = layout->rb_profile_end - layout->rb_profile_begin;</div><div class="gmail_extra"><br></div><div class="gmail_extra"><span style="white-space:pre-wrap"> </span><br></div><div class="gmail_extra"><div class="gmail_extra">unsigned int nbytes = 4 + headersize + nsamples * samplesize;</div><div class="gmail_extra"><span style="white-space:pre-wrap"> ...</span></div><div class="gmail_extra"><span style="white-space:pre-wrap"> </span>// Move to the start of the dive.</div><div class="gmail_extra"><span style="white-space:pre-wrap"> </span>offset -= nbytes;</div></div><div class="gmail_extra"> </div><div class="gmail_extra">...but it seems that on the Smart Apnea there is not a constant samplesize: one immersion is a variable length (nsamples) sequence of dives , each one having one header (dive time, surface time, temperature, ...) and a stream of "dive time" depth measurements.</div><div class="gmail_extra"><br></div><div class="gmail_extra"><div class="gmail_extra"><br>If this is true, the current approach
can't work, as long as it is no longer possible to compute "nbytes". </div><div class="gmail_extra"><br></div><div class="gmail_extra">Am I wrong? </div><div class="gmail_extra"><br></div><div class="gmail_extra">Is there any reason to start from the end and not from the beginning (the "end of profile ring buffer" eop) and then move forward? I am getting familiar with the memory layout of the DC but still have many many doubts about the library code and architecture. </div><div class="gmail_extra"><br></div><div class="gmail_extra">Any help would be very appreciated. I can provide the annotated dump, but I am not sure what the mailing list netiquette says about big attachments. </div><div class="gmail_extra"><br></div><div class="gmail_extra">Thank you in advance</div><div class="gmail_extra"><br></div><div class="gmail_extra">Giorgio</div></div><div class="gmail_extra"><br></div><div class="gmail_extra"><br></div><div class="gmail_extra">EXAMPLE:</div><div class="gmail_extra"><br></div><div class="gmail_extra"><div class="gmail_extra">*** start immersion 2015 08 31 10.08</div><div class="gmail_extra"><br></div><div class="gmail_extra">18 25 : LEN (in bytes)</div><div class="gmail_extra">00 00 : ??</div><div class="gmail_extra">*** sample 1 ***</div><div class="gmail_extra">0c 00 : maxdepth(1.2) sample 1</div><div class="gmail_extra">13 00 : dive time (19 secs)</div><div class="gmail_extra">00 00 : surface time (0)</div><div class="gmail_extra">fc 00 ??</div><div class="gmail_extra">fc 00 ??</div><div class="gmail_extra">04 00 ??</div><div class="gmail_extra">17 00 ??</div><div class="gmail_extra">0b 00 depth //19 depth measurements: 1 per second</div><div class="gmail_extra">0c 00 depth </div><div class="gmail_extra">0b 00 depth </div><div class="gmail_extra">0b 00 depth </div><div class="gmail_extra">0b 00 depth </div><div class="gmail_extra">0b 00 depth </div><div class="gmail_extra">0b 00 depth </div><div class="gmail_extra">0c 00 depth </div><div class="gmail_extra">0c 00 depth </div><div class="gmail_extra">0b 00 depth </div><div class="gmail_extra">0b 00 depth </div><div class="gmail_extra">0b 00 depth </div><div class="gmail_extra">0b 00 depth </div><div class="gmail_extra">0b 00 depth </div><div class="gmail_extra">0b 00 depth </div><div class="gmail_extra">0c 00 depth </div><div class="gmail_extra">0b 00 depth </div><div class="gmail_extra">0b 00 depth </div><div class="gmail_extra">09 00 depth</div><div class="gmail_extra"><br></div><div class="gmail_extra">**** sample 2 ***</div><div class="gmail_extra">11 00 maxdepth (1.2) </div><div class="gmail_extra">2d 00 divetime</div><div class="gmail_extra">3c 00 surftime</div><div class="gmail_extra">fc 00 ??</div><div class="gmail_extra">fc 00 ??</div><div class="gmail_extra">05 00 ??</div><div class="gmail_extra">...</div></div><div class="gmail_extra"><br></div></div>
<p style="margin-top:2.5em;margin-bottom:1em;border-bottom:1px solid #000"></p></div></div><span class=""><pre><hr><br>devel mailing list<br><a href="mailto:devel@libdivecomputer.org" target="_blank">devel@libdivecomputer.org</a><br><a href="http://libdivecomputer.org/cgi-bin/mailman/listinfo/devel" target="_blank">http://libdivecomputer.org/cgi-bin/mailman/listinfo/devel</a><br></pre></span></blockquote></div></div></blockquote></div><br></div>