From 2829f7ebf9902170bf653d67dbe412a0a4f140cf Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Tue, 12 Jul 2016 19:54:58 +0200 Subject: [PATCH] Add an ostc3 specific function with the model number. To be able to pass the OSTC 3 model number to the parser, and preserve backwards compatibility, we need a new function. The new function should also be used for the Frog, by passing zero as the model number. Using the hw_ostc_parser_create() function with the hwos parameter set to one, is now deprecated but will remain supported for backwards compatibility. --- include/libdivecomputer/hw_ostc3.h | 3 +++ src/hw_ostc_parser.c | 16 +++++++++++++++- src/libdivecomputer.symbols | 1 + src/parser.c | 2 +- 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/include/libdivecomputer/hw_ostc3.h b/include/libdivecomputer/hw_ostc3.h index c60dc63..56244ed 100644 --- a/include/libdivecomputer/hw_ostc3.h +++ b/include/libdivecomputer/hw_ostc3.h @@ -64,6 +64,9 @@ hw_ostc3_device_config_reset (dc_device_t *abstract); dc_status_t hw_ostc3_device_fwupdate (dc_device_t *abstract, const char *filename); +dc_status_t +hw_ostc3_parser_create (dc_parser_t **out, dc_context_t *context, unsigned int model); + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/src/hw_ostc_parser.c b/src/hw_ostc_parser.c index 357fbdc..e2dbd64 100644 --- a/src/hw_ostc_parser.c +++ b/src/hw_ostc_parser.c @@ -84,6 +84,7 @@ typedef struct hw_ostc_gasmix_t { typedef struct hw_ostc_parser_t { dc_parser_t base; unsigned int hwos; + unsigned int model; // Cached fields. unsigned int cached; unsigned int version; @@ -267,7 +268,7 @@ hw_ostc_parser_cache (hw_ostc_parser_t *parser) } dc_status_t -hw_ostc_parser_create (dc_parser_t **out, dc_context_t *context, unsigned int hwos) +hw_ostc_parser_create_internal (dc_parser_t **out, dc_context_t *context, unsigned int hwos, unsigned int model) { hw_ostc_parser_t *parser = NULL; @@ -283,6 +284,7 @@ hw_ostc_parser_create (dc_parser_t **out, dc_context_t *context, unsigned int hw // Set the default values. parser->hwos = hwos; + parser->model = model; parser->cached = 0; parser->version = 0; parser->header = 0; @@ -301,6 +303,18 @@ hw_ostc_parser_create (dc_parser_t **out, dc_context_t *context, unsigned int hw } +dc_status_t +hw_ostc_parser_create (dc_parser_t **out, dc_context_t *context, unsigned int hwos) +{ + return hw_ostc_parser_create_internal (out, context, hwos, 0); +} + +dc_status_t +hw_ostc3_parser_create (dc_parser_t **out, dc_context_t *context, unsigned int model) +{ + return hw_ostc_parser_create_internal (out, context, 1, model); +} + static dc_status_t hw_ostc_parser_set_data (dc_parser_t *abstract, const unsigned char *data, unsigned int size) { diff --git a/src/libdivecomputer.symbols b/src/libdivecomputer.symbols index 8f83c9b..347db27 100644 --- a/src/libdivecomputer.symbols +++ b/src/libdivecomputer.symbols @@ -63,6 +63,7 @@ oceanic_vtpro_parser_create2 oceanic_veo250_parser_create oceanic_atom2_parser_create hw_ostc_parser_create +hw_ostc3_parser_create cressi_edy_parser_create cressi_leonardo_parser_create atomics_cobalt_parser_create diff --git a/src/parser.c b/src/parser.c index 505270e..bb3eb7a 100644 --- a/src/parser.c +++ b/src/parser.c @@ -116,7 +116,7 @@ dc_parser_new_internal (dc_parser_t **out, dc_context_t *context, dc_family_t fa break; case DC_FAMILY_HW_FROG: case DC_FAMILY_HW_OSTC3: - rc = hw_ostc_parser_create (&parser, context, 1); + rc = hw_ostc3_parser_create (&parser, context, model); break; case DC_FAMILY_CRESSI_EDY: case DC_FAMILY_ZEAGLE_N2ITION3: