[PATCH] Add deco model info strings to hw parser
Anton Lundin
glance at acc.umu.se
Tue Jan 20 23:42:00 PST 2015
Signed-off-by: Anton Lundin <glance at acc.umu.se>
---
This patch is ment for the Subsurface-testing branch of libdivecomputer.
src/hw_ostc_parser.c | 41 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
diff --git a/src/hw_ostc_parser.c b/src/hw_ostc_parser.c
index 800dac4..5e8cc3d 100644
--- a/src/hw_ostc_parser.c
+++ b/src/hw_ostc_parser.c
@@ -56,6 +56,9 @@
#define OSTC3_GAUGE 2
#define OSTC3_APNEA 3
+#define OSTC3_ZHL16 0
+#define OSTC3_ZHL16_GF 1
+
#define UNSUPPORTED 0xFFFFFFFF
typedef struct hw_ostc_parser_t hw_ostc_parser_t;
@@ -84,6 +87,9 @@ typedef struct hw_ostc_layout_t {
unsigned int battery;
unsigned int desat;
unsigned int fw_version;
+ unsigned int deco_info1;
+ unsigned int deco_info2;
+ unsigned int decomode;
} hw_ostc_layout_t;
typedef struct hw_ostc_gasmix_t {
@@ -118,6 +124,9 @@ static const hw_ostc_layout_t hw_ostc_layout_ostc = {
34, /* battery volt after dive */
17, /* desat */
32, /* fw_version */
+ 49, /* deco_info1 */
+ 50, /* deco_info1 */
+ 51, /* decomode */
};
static const hw_ostc_layout_t hw_ostc_layout_frog = {
@@ -132,6 +141,9 @@ static const hw_ostc_layout_t hw_ostc_layout_frog = {
34, /* battery volt after dive */
23, /* desat */
32, /* fw_version */
+ 49, /* deco_info1 */
+ 50, /* deco_info2 */
+ 51, /* decomode */
};
static const hw_ostc_layout_t hw_ostc_layout_ostc3 = {
@@ -146,6 +158,9 @@ static const hw_ostc_layout_t hw_ostc_layout_ostc3 = {
50, /* battery volt after dive */
26, /* desat */
48, /* fw_version */
+ 77, /* deco_info1 */
+ 78, /* deco_info2 */
+ 79, /* decomode */
};
dc_status_t
@@ -449,6 +464,32 @@ hw_ostc_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsigned
string->desc = "Serial";
snprintf(buf, BUFLEN, "%u", parser->serial);
break;
+ case 4: /* Deco model */
+ string->desc = "Deco model";
+ if ((version == 0x23 && data[layout->decomode] == OSTC3_ZHL16) ||
+ (version == 0x22 && data[layout->decomode] == FROG_ZHL16) ||
+ (version == 0x21 && (data[layout->decomode] == OSTC_ZHL16_OC || data[layout->decomode] == OSTC_ZHL16_CC)))
+ strncpy(buf, "ZH-L16", BUFLEN);
+ if ((version == 0x23 && data[layout->decomode] == OSTC3_ZHL16_GF) ||
+ (version == 0x22 && data[layout->decomode] == FROG_ZHL16_GF) ||
+ (version == 0x21 && (data[layout->decomode] == OSTC_ZHL16_OC_GF || data[layout->decomode] == OSTC_ZHL16_CC_GF)))
+ strncpy(buf, "ZH-L16-GF", BUFLEN);
+ else
+ return DC_STATUS_DATAFORMAT;
+ break;
+ case 5: /* Deco model info */
+ string->desc = "Deco model info";
+ if ((version == 0x23 && data[layout->decomode] == OSTC3_ZHL16) ||
+ (version == 0x22 && data[layout->decomode] == FROG_ZHL16) ||
+ (version == 0x21 && (data[layout->decomode] == OSTC_ZHL16_OC || data[layout->decomode] == OSTC_ZHL16_CC)))
+ snprintf(buf, BUFLEN, "Saturation %u, Desaturation %u", layout->deco_info1, layout->deco_info2);
+ if ((version == 0x23 && data[layout->decomode] == OSTC3_ZHL16_GF) ||
+ (version == 0x22 && data[layout->decomode] == FROG_ZHL16_GF) ||
+ (version == 0x21 && (data[layout->decomode] == OSTC_ZHL16_OC_GF || data[layout->decomode] == OSTC_ZHL16_CC_GF)))
+ snprintf(buf, BUFLEN, "GF %u/%u", data[layout->deco_info1], data[layout->deco_info2]);
+ else
+ return DC_STATUS_DATAFORMAT;
+ break;
default:
return DC_STATUS_UNSUPPORTED;
}
--
2.1.0
More information about the subsurface
mailing list