From: Linus Torvalds <[email protected]>
Date: Mon, 20 Jun 2016 22:04:27 -0700
Subject: [PATCH 1/2] Suunto EON Steel: add descriptor debugging output

.. every time I look for a new feature I add debug code to print out all
the descriptors.  So let's just do it once and for all.

Signed-off-by: Linus Torvalds <[email protected]>
---

This literally just dumps out the EON Steel type descriptor information 
that we have parsed to the logfile. So you end up with something like

  ..
  DEBUG: Descriptor 39: 'sml.DeviceLog.Samples.Sample.Events.SetPoint.PO2', 
size 4 bytes
  DEBUG:     format 'uint32'
  ..

in the debug logs for each data descriptor.

 src/suunto_eonsteel_parser.c | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/src/suunto_eonsteel_parser.c b/src/suunto_eonsteel_parser.c
index 276eaa247363..bc40f491890f 100644
--- a/src/suunto_eonsteel_parser.c
+++ b/src/suunto_eonsteel_parser.c
@@ -101,6 +101,7 @@ static const struct {
        const char *name;
        enum eon_sample type;
 } type_translation[] = {
+       { "+Time",                              ES_dtime },
        { "Depth",                              ES_depth },
        { "Temperature",                        ES_temp },
        { "NoDecTime",                          ES_ndl },
@@ -158,6 +159,16 @@ static enum eon_sample 
lookup_descriptor_type(suunto_eonsteel_parser_t *eon, str
        return ES_none;
 }
 
+static const char *desc_type_name(enum eon_sample type)
+{
+       int i;
+       for (i = 0; i < C_ARRAY_SIZE(type_translation); i++) {
+               if (type == type_translation[i].type)
+                       return type_translation[i].name;
+       }
+       return "Unknown";
+}
+
 static int lookup_descriptor_size(suunto_eonsteel_parser_t *eon, struct 
type_desc *desc)
 {
        const char *format = desc->format;
@@ -1286,6 +1297,31 @@ static void 
initialize_field_caches(suunto_eonsteel_parser_t *eon)
        eon->cache.divetime /= 1000;
 }
 
+static void show_descriptor(suunto_eonsteel_parser_t *eon, int nr, struct 
type_desc *desc)
+{
+       int i;
+
+       if (!desc->desc)
+               return;
+       DEBUG(eon->base.context, "Descriptor %d: '%s', size %d bytes", nr, 
desc->desc, desc->size);
+       if (desc->format)
+               DEBUG(eon->base.context, "    format '%s'", desc->format);
+       if (desc->mod)
+               DEBUG(eon->base.context, "    mod '%s'", desc->mod);
+       for (i = 0; i < EON_MAX_GROUP; i++) {
+               enum eon_sample type = desc->type[i];
+               if (!type)
+                       continue;
+               DEBUG(eon->base.context, "    %d: %d (%s)", i, type, 
desc_type_name(type));
+       }
+}
+
+static void show_all_descriptors(suunto_eonsteel_parser_t *eon)
+{
+       for (unsigned int i = 0; i < MAXTYPE; ++i)
+               show_descriptor(eon, i, eon->type_desc+i);
+}
+
 static dc_status_t
 suunto_eonsteel_parser_set_data(dc_parser_t *parser, const unsigned char 
*data, unsigned int size)
 {
@@ -1294,6 +1330,7 @@ suunto_eonsteel_parser_set_data(dc_parser_t *parser, 
const unsigned char *data,
        desc_free(eon->type_desc, MAXTYPE);
        memset(eon->type_desc, 0, sizeof(eon->type_desc));
        initialize_field_caches(eon);
+       show_all_descriptors(eon);
        return DC_STATUS_SUCCESS;
 }
 
-- 
2.9.0.rc1.20.g6326f19

_______________________________________________
subsurface mailing list
[email protected]
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to