Patch: Mares M1 data format

Björn Spruck bjoern at spruck.net
Tue Mar 27 17:54:48 UTC 2012


--- /tmp/tmpo7eqew-meld/src/mares_darwin_parser.c
+++ /home/bjoern/Dokumente/libdivecomputer/src/mares_darwin_parser.c
@@ -185,21 +185,60 @@
 
     unsigned int time = 0;
 
-    unsigned int pressure = array_uint16_be (abstract->data + 0x17);
+    int temperature = abstract->data [10] ;// in M1 this is temp in °C
+    unsigned int pressure = array_uint16_be (abstract->data + 0x17);   
 
     unsigned int offset = parser->headersize;
     while (offset + parser->samplesize <= abstract->size) {
             parser_sample_value_t sample = {0};
+
+            unsigned int value = array_uint16_le (abstract->data + offset);
+            unsigned int depth = value & 0x07FF;
+            unsigned int ascent = (value & 0xE000) >> 13;/// ascent 0-5
seen, (6&7 not possible from display)
+            ///bool violation = (value & 0x1000);/// this is a guess,
to be verified!!!
+            unsigned int deco = (value & 0x0800)!=0; /// boolean
 
             // Surface Time (seconds).
             time += 20;
             sample.time = time;
             if (callback) callback (SAMPLE_TYPE_TIME, sample, userdata);
 
+            if( temperature!=-1){ 
+              sample.temperature=temperature;
+              if (callback) callback (SAMPLE_TYPE_TEMPERATURE, sample,
userdata);
+              temperature=-1;
+            }
+
             // Depth (1/10 m).
-            unsigned int depth = array_uint16_le (abstract->data +
offset) & 0x07FF;
             sample.depth = depth / 10.0;
             if (callback) callback (SAMPLE_TYPE_DEPTH, sample, userdata);
+           
+            // Ascent rate
+            if (ascent>0) {
+                sample.event.type = SAMPLE_EVENT_ASCENT;
+                sample.event.time = 0;
+                sample.event.flags = 0;
+                sample.event.value = ascent;
+                if (callback) callback (SAMPLE_TYPE_EVENT, sample,
userdata);
+            }
+
+            // Deco violation?
+//            if (violation) {
+//                sample.event.type = SAMPLE_EVENT_CEILING;
+//                sample.event.time = 0;
+//                sample.event.flags = 0;
+//                sample.event.value = 0;
+//                if (callback) callback (SAMPLE_TYPE_EVENT, sample,
userdata);
+//            }
+
+            // Deco stop
+            if (deco) {
+                sample.event.type = SAMPLE_EVENT_DECOSTOP;
+                sample.event.time = 0;
+                sample.event.flags = 0;
+                sample.event.value = 0;
+                if (callback) callback (SAMPLE_TYPE_EVENT, sample,
userdata);
+            }
 
             if (parser->samplesize == 3) {
                 unsigned int type = (time / 20 + 2) % 3;





More information about the Devel mailing list