Suunto DM5 Imports broken

Dirk Hohndel dirk at hohndel.org
Thu Jun 7 08:25:14 PDT 2018


Miika is the wunderkind-slash-madman who maintains our importers and deals with the XSLT...

/D

> On Jun 7, 2018, at 1:58 AM, Rainer Mohr <mail at divelogs.de> wrote:
> 
> Gentlemen,
> 
> Just noticed, that the Suunto DM5 Import is very broken as it can't parse the profile data from recent and semi-recent DM5 files properly.
> Suunto has once again changed their data structures in the profile part of DM5. Noticed after quite a few broken profiles popped up on divelogs.de
> Now the 'SampleBlob' can contain not only blocks of 16, 23 and 26 Bytes, but new: 30 Bytes (detectable by first Byte being '5')
> 
> Here is my PHP code for handling the profile parts from the SQLite Data, hope someone can translate this into what you need, as I would be useless at doing so:
> 
> <?php
> // $databaserow contains the data from one dive, queried from the database
> $data = $databaserow['SampleBlob'];
> $samples = Array();
> 
> // Depending on first Byte: Samples are in blocks of 23 or 16 or 26 or 30 bytes
> if (ord($data[0])==3) { // 23 Bytes per sample
>     $data = substr($data,1,strlen($data));
>     for($i = 0; $i < strlen($data)/23; ++$i) {
>         $s = unpack("f",$data[$i*23+2].$data[$i*23+3].$data[$i*23+4].$data[$i*23+5]);
>         if ($s[1] < 200) $samples[] = round($s[1],1);
>     }
> } elseif (ord($data[0])==4) { // 26 Bytes per sample
>     $data = substr($data,1,strlen($data));
>     for($i = 0; $i < strlen($data)/26; ++$i) {
>         $s = unpack("f",$data[$i*26+2].$data[$i*26+3].$data[$i*26+4].$data[$i*26+5]);
>         if ($s[1] < 200) $samples[] = round($s[1],1);
>     }
> } elseif (ord($data[0])==5) { // 30 Bytes per sample
>     $data = substr($data,1,strlen($data));
>     for($i = 0; $i < strlen($data)/30; ++$i) {
>         $s = unpack("f",$data[$i*30+2].$data[$i*30+3].$data[$i*30+4].$data[$i*30+5]);
>         if ($s[1] < 200) $samples[] = round($s[1],1);
>     }
> } else { // 16 Bytes per sample
>     for($i = 0; $i < strlen($data)/16; ++$i) {
>         $s = unpack("f",$data[$i*16+3].$data[$i*16+4].$data[$i*16+5].$data[$i*16+6]);
>         if ($s[1] < 200) $samples[] = round($s[1],1);
>     }
> }
> 
> // in case Dives from imported DM4 are available
> if (count($samples)==0) {
>     $data = $databaserow['ProfileBlob'];
>     for($i = 0; $i < strlen($data)/4; ++$i) {
>         $s = unpack("f",$data[$i*4].$data[$i*4+1].$data[$i*4+2].$data[$i*4+3]);
>         if ($s[1] < 200) $samples[] = round($s[1],1);
>     }
> }
> ?>
> 
> Rainer
> 
> 
> _______________________________________________
> subsurface mailing list
> subsurface at subsurface-divelog.org
> http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface



More information about the subsurface mailing list