From 098b229bc6ba048fabca06afd37f3bdab5f1640e Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Mon, 1 Feb 2010 13:34:52 +0000 Subject: [PATCH] Rename the Suunto Spyder parser as the Eon parser. Both devices have an almost identical data format. Renaming the parser backend makes it more consistent with the corresponding device backend. --- msvc/libdivecomputer.vcproj | 8 ++-- src/Makefile.am | 4 +- src/libdivecomputer.symbols | 2 +- src/parser.h | 2 +- src/suunto_eon.h | 8 +++- ...to_spyder_parser.c => suunto_eon_parser.c} | 44 +++++++++---------- src/suunto_vyper.h | 3 -- 7 files changed, 36 insertions(+), 35 deletions(-) rename src/{suunto_spyder_parser.c => suunto_eon_parser.c} (67%) diff --git a/msvc/libdivecomputer.vcproj b/msvc/libdivecomputer.vcproj index 6b8065c..1d62dae 100644 --- a/msvc/libdivecomputer.vcproj +++ b/msvc/libdivecomputer.vcproj @@ -304,6 +304,10 @@ RelativePath="..\src\suunto_eon.c" > + + @@ -312,10 +316,6 @@ RelativePath="..\src\suunto_solution_parser.c" > - - diff --git a/src/Makefile.am b/src/Makefile.am index 2842fb0..b8d6720 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -52,8 +52,8 @@ libdivecomputer_la_SOURCES = \ suunto_common.h suunto_common.c \ suunto_common2.h suunto_common2.c \ suunto_solution.h suunto_solution.c suunto_solution_parser.c \ - suunto_eon.h suunto_eon.c \ - suunto_vyper.h suunto_vyper.c suunto_vyper_parser.c suunto_spyder_parser.c \ + suunto_eon.h suunto_eon.c suunto_eon_parser.c \ + suunto_vyper.h suunto_vyper.c suunto_vyper_parser.c \ suunto_vyper2.h suunto_vyper2.c \ suunto_d9.h suunto_d9.c suunto_d9_parser.c \ reefnet.h \ diff --git a/src/libdivecomputer.symbols b/src/libdivecomputer.symbols index 43b3eb1..0df2290 100644 --- a/src/libdivecomputer.symbols +++ b/src/libdivecomputer.symbols @@ -26,7 +26,7 @@ uwatec_smart_parser_create #endif suunto_vyper_parser_create suunto_solution_parser_create -suunto_spyder_parser_create +suunto_eon_parser_create suunto_d9_parser_create mares_nemo_parser_create oceanic_vtpro_parser_create diff --git a/src/parser.h b/src/parser.h index f841586..3be1356 100644 --- a/src/parser.h +++ b/src/parser.h @@ -29,7 +29,7 @@ extern "C" { typedef enum parser_type_t { PARSER_TYPE_NULL = 0, PARSER_TYPE_SUUNTO_SOLUTION, - PARSER_TYPE_SUUNTO_SPYDER, + PARSER_TYPE_SUUNTO_EON, PARSER_TYPE_SUUNTO_VYPER, PARSER_TYPE_SUUNTO_D9, PARSER_TYPE_REEFNET_SENSUS, diff --git a/src/suunto_eon.h b/src/suunto_eon.h index 57ef690..3e1519b 100644 --- a/src/suunto_eon.h +++ b/src/suunto_eon.h @@ -22,12 +22,13 @@ #ifndef SUUNTO_EON_H #define SUUNTO_EON_H +#include "device.h" +#include "parser.h" + #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ -#include "device.h" - #define SUUNTO_EON_MEMORY_SIZE 0x900 device_status_t @@ -42,6 +43,9 @@ suunto_eon_device_write_interval (device_t *device, unsigned char interval); device_status_t suunto_eon_extract_dives (device_t *device, const unsigned char data[], unsigned int size, dive_callback_t callback, void *userdata); +parser_status_t +suunto_eon_parser_create (parser_t **parser); + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/src/suunto_spyder_parser.c b/src/suunto_eon_parser.c similarity index 67% rename from src/suunto_spyder_parser.c rename to src/suunto_eon_parser.c index f6dde6b..dc3a6a3 100644 --- a/src/suunto_spyder_parser.c +++ b/src/suunto_eon_parser.c @@ -22,54 +22,54 @@ #include #include -#include "suunto_vyper.h" +#include "suunto_eon.h" #include "parser-private.h" #include "units.h" #include "utils.h" -typedef struct suunto_spyder_parser_t suunto_spyder_parser_t; +typedef struct suunto_eon_parser_t suunto_eon_parser_t; -struct suunto_spyder_parser_t { +struct suunto_eon_parser_t { parser_t base; }; -static parser_status_t suunto_spyder_parser_set_data (parser_t *abstract, const unsigned char *data, unsigned int size); -static parser_status_t suunto_spyder_parser_samples_foreach (parser_t *abstract, sample_callback_t callback, void *userdata); -static parser_status_t suunto_spyder_parser_destroy (parser_t *abstract); +static parser_status_t suunto_eon_parser_set_data (parser_t *abstract, const unsigned char *data, unsigned int size); +static parser_status_t suunto_eon_parser_samples_foreach (parser_t *abstract, sample_callback_t callback, void *userdata); +static parser_status_t suunto_eon_parser_destroy (parser_t *abstract); -static const parser_backend_t suunto_spyder_parser_backend = { - PARSER_TYPE_SUUNTO_SPYDER, - suunto_spyder_parser_set_data, /* set_data */ - suunto_spyder_parser_samples_foreach, /* samples_foreach */ - suunto_spyder_parser_destroy /* destroy */ +static const parser_backend_t suunto_eon_parser_backend = { + PARSER_TYPE_SUUNTO_EON, + suunto_eon_parser_set_data, /* set_data */ + suunto_eon_parser_samples_foreach, /* samples_foreach */ + suunto_eon_parser_destroy /* destroy */ }; static int -parser_is_suunto_spyder (parser_t *abstract) +parser_is_suunto_eon (parser_t *abstract) { if (abstract == NULL) return 0; - return abstract->backend == &suunto_spyder_parser_backend; + return abstract->backend == &suunto_eon_parser_backend; } parser_status_t -suunto_spyder_parser_create (parser_t **out) +suunto_eon_parser_create (parser_t **out) { if (out == NULL) return PARSER_STATUS_ERROR; // Allocate memory. - suunto_spyder_parser_t *parser = (suunto_spyder_parser_t *) malloc (sizeof (suunto_spyder_parser_t)); + suunto_eon_parser_t *parser = (suunto_eon_parser_t *) malloc (sizeof (suunto_eon_parser_t)); if (parser == NULL) { WARNING ("Failed to allocate memory."); return PARSER_STATUS_MEMORY; } // Initialize the base class. - parser_init (&parser->base, &suunto_spyder_parser_backend); + parser_init (&parser->base, &suunto_eon_parser_backend); *out = (parser_t*) parser; @@ -78,9 +78,9 @@ suunto_spyder_parser_create (parser_t **out) static parser_status_t -suunto_spyder_parser_destroy (parser_t *abstract) +suunto_eon_parser_destroy (parser_t *abstract) { - if (! parser_is_suunto_spyder (abstract)) + if (! parser_is_suunto_eon (abstract)) return PARSER_STATUS_TYPE_MISMATCH; // Free memory. @@ -91,9 +91,9 @@ suunto_spyder_parser_destroy (parser_t *abstract) static parser_status_t -suunto_spyder_parser_set_data (parser_t *abstract, const unsigned char *data, unsigned int size) +suunto_eon_parser_set_data (parser_t *abstract, const unsigned char *data, unsigned int size) { - if (! parser_is_suunto_spyder (abstract)) + if (! parser_is_suunto_eon (abstract)) return PARSER_STATUS_TYPE_MISMATCH; return PARSER_STATUS_SUCCESS; @@ -101,9 +101,9 @@ suunto_spyder_parser_set_data (parser_t *abstract, const unsigned char *data, un static parser_status_t -suunto_spyder_parser_samples_foreach (parser_t *abstract, sample_callback_t callback, void *userdata) +suunto_eon_parser_samples_foreach (parser_t *abstract, sample_callback_t callback, void *userdata) { - if (! parser_is_suunto_spyder (abstract)) + if (! parser_is_suunto_eon (abstract)) return PARSER_STATUS_TYPE_MISMATCH; const unsigned char *data = abstract->data; diff --git a/src/suunto_vyper.h b/src/suunto_vyper.h index c21c25f..bd2062f 100644 --- a/src/suunto_vyper.h +++ b/src/suunto_vyper.h @@ -47,9 +47,6 @@ suunto_vyper_extract_dives (device_t *device, const unsigned char data[], unsign parser_status_t suunto_vyper_parser_create (parser_t **parser); -parser_status_t -suunto_spyder_parser_create (parser_t **parser); - #ifdef __cplusplus } #endif /* __cplusplus */