From b9657e454550bc3b4266d76e87fd8e3fbc074c28 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sat, 8 Nov 2014 17:10:14 -0800 Subject: [PATCH] Atomics Cobalt: use the new DC string fields Not a lot of fields, but give the serial number in the proper format, and other version information (Software version and bootloader version). And the Nofly time that the dive computer reports. Signed-off-by: Dirk Hohndel Signed-off-by: Linus Torvalds --- src/atomics_cobalt_parser.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/atomics_cobalt_parser.c b/src/atomics_cobalt_parser.c index 438eb39..7d30ca3 100644 --- a/src/atomics_cobalt_parser.c +++ b/src/atomics_cobalt_parser.c @@ -20,6 +20,12 @@ */ #include +#include +#include + +#ifdef _MSC_VER +#define snprintf _snprintf +#endif #include @@ -129,6 +135,9 @@ atomics_cobalt_parser_get_datetime (dc_parser_t *abstract, dc_datetime_t *dateti } +#define BUFLEN 16 + + static dc_status_t atomics_cobalt_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsigned int flags, void *value) { @@ -143,6 +152,9 @@ atomics_cobalt_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, un dc_tank_t *tank = (dc_tank_t *) value; double atmospheric = 0.0; + char buf[BUFLEN]; + dc_field_string_t *string = (dc_field_string_t *) value; + if (parser->atmospheric) atmospheric = parser->atmospheric; else @@ -208,6 +220,29 @@ atomics_cobalt_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, un return DC_STATUS_DATAFORMAT; } break; + case DC_FIELD_STRING: + switch(flags) { + case 0: // Serialnr + string->desc = "Serial"; + snprintf(buf, BUFLEN, "%c%c%c%c-%c%c%c%c", p[4], p[5], p[6], p[7], p[8], p[9], p[10], p[11]); + break; + case 1: // Program Version + string->desc = "Program Version"; + snprintf(buf, BUFLEN, "%.2f", array_uint16_le(p + 30) / 100.0); + break; + case 2: // Boot Version + string->desc = "Boot Version"; + snprintf(buf, BUFLEN, "%.2f", array_uint16_le(p + 32) / 100.0); + break; + case 3: // Nofly + string->desc = "NoFly Time"; + snprintf(buf, BUFLEN, "%0u:%02u", p[0x52], p[0x53]); + break; + default: + return DC_STATUS_UNSUPPORTED; + } + string->value = strdup(buf); + break; default: return DC_STATUS_UNSUPPORTED; }