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 <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Linus Torvalds 2016-06-20 22:04:27 -07:00 committed by Dirk Hohndel
parent 26b027cad8
commit 341b7c2dad

View File

@ -101,6 +101,7 @@ static const struct {
const char *name; const char *name;
enum eon_sample type; enum eon_sample type;
} type_translation[] = { } type_translation[] = {
{ "+Time", ES_dtime },
{ "Depth", ES_depth }, { "Depth", ES_depth },
{ "Temperature", ES_temp }, { "Temperature", ES_temp },
{ "NoDecTime", ES_ndl }, { "NoDecTime", ES_ndl },
@ -158,6 +159,16 @@ static enum eon_sample lookup_descriptor_type(suunto_eonsteel_parser_t *eon, str
return ES_none; 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) static int lookup_descriptor_size(suunto_eonsteel_parser_t *eon, struct type_desc *desc)
{ {
const char *format = desc->format; const char *format = desc->format;
@ -1286,6 +1297,31 @@ static void initialize_field_caches(suunto_eonsteel_parser_t *eon)
eon->cache.divetime /= 1000; 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 static dc_status_t
suunto_eonsteel_parser_set_data(dc_parser_t *parser, const unsigned char *data, unsigned int size) 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); desc_free(eon->type_desc, MAXTYPE);
memset(eon->type_desc, 0, sizeof(eon->type_desc)); memset(eon->type_desc, 0, sizeof(eon->type_desc));
initialize_field_caches(eon); initialize_field_caches(eon);
show_all_descriptors(eon);
return DC_STATUS_SUCCESS; return DC_STATUS_SUCCESS;
} }