diff --git a/msvc/libdivecomputer.vcproj b/msvc/libdivecomputer.vcproj
index bc24629..0afe446 100644
--- a/msvc/libdivecomputer.vcproj
+++ b/msvc/libdivecomputer.vcproj
@@ -236,6 +236,10 @@
RelativePath="..\src\oceanic_veo250.c"
>
+
+
diff --git a/src/Makefile.am b/src/Makefile.am
index d361056..fa1ffad 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -66,7 +66,7 @@ libdivecomputer_la_SOURCES = \
oceanic.h \
oceanic_common.h oceanic_common.c \
oceanic_atom2.h oceanic_atom2.c oceanic_atom2_parser.c \
- oceanic_veo250.h oceanic_veo250.c \
+ oceanic_veo250.h oceanic_veo250.c oceanic_veo250_parser.c \
oceanic_vtpro.h oceanic_vtpro.c \
mares.h \
mares_common.h mares_common.c \
diff --git a/src/libdivecomputer.symbols b/src/libdivecomputer.symbols
index a6af5ad..c167fd2 100644
--- a/src/libdivecomputer.symbols
+++ b/src/libdivecomputer.symbols
@@ -29,6 +29,7 @@ suunto_solution_parser_create
suunto_spyder_parser_create
suunto_d9_parser_create
mares_nemo_parser_create
+oceanic_veo250_parser_create
oceanic_atom2_parser_create
device_close
diff --git a/src/oceanic_veo250.h b/src/oceanic_veo250.h
index 7c1a279..1bd47d6 100644
--- a/src/oceanic_veo250.h
+++ b/src/oceanic_veo250.h
@@ -27,6 +27,7 @@ extern "C" {
#endif /* __cplusplus */
#include "device.h"
+#include "parser.h"
#define OCEANIC_VEO250_MEMORY_SIZE 0x8000
#define OCEANIC_VEO250_PACKET_SIZE 0x10
@@ -37,6 +38,9 @@ oceanic_veo250_device_open (device_t **device, const char* name);
device_status_t
oceanic_veo250_device_keepalive (device_t *device);
+parser_status_t
+oceanic_veo250_parser_create (parser_t **parser);
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
diff --git a/src/oceanic_veo250_parser.c b/src/oceanic_veo250_parser.c
new file mode 100644
index 0000000..bc6c868
--- /dev/null
+++ b/src/oceanic_veo250_parser.c
@@ -0,0 +1,168 @@
+/*
+ * libdivecomputer
+ *
+ * Copyright (C) 2009 Jef Driesen
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ */
+
+#include
+#include
+
+#include "oceanic_veo250.h"
+#include "parser-private.h"
+#include "array.h"
+#include "units.h"
+#include "utils.h"
+
+typedef struct oceanic_veo250_parser_t oceanic_veo250_parser_t;
+
+struct oceanic_veo250_parser_t {
+ parser_t base;
+};
+
+static parser_status_t oceanic_veo250_parser_set_data (parser_t *abstract, const unsigned char *data, unsigned int size);
+static parser_status_t oceanic_veo250_parser_samples_foreach (parser_t *abstract, sample_callback_t callback, void *userdata);
+static parser_status_t oceanic_veo250_parser_destroy (parser_t *abstract);
+
+static const parser_backend_t oceanic_veo250_parser_backend = {
+ PARSER_TYPE_OCEANIC_VEO250,
+ oceanic_veo250_parser_set_data, /* set_data */
+ oceanic_veo250_parser_samples_foreach, /* samples_foreach */
+ oceanic_veo250_parser_destroy /* destroy */
+};
+
+
+static int
+parser_is_oceanic_veo250 (parser_t *abstract)
+{
+ if (abstract == NULL)
+ return 0;
+
+ return abstract->backend == &oceanic_veo250_parser_backend;
+}
+
+
+parser_status_t
+oceanic_veo250_parser_create (parser_t **out)
+{
+ if (out == NULL)
+ return PARSER_STATUS_ERROR;
+
+ // Allocate memory.
+ oceanic_veo250_parser_t *parser = (oceanic_veo250_parser_t *) malloc (sizeof (oceanic_veo250_parser_t));
+ if (parser == NULL) {
+ WARNING ("Failed to allocate memory.");
+ return PARSER_STATUS_MEMORY;
+ }
+
+ // Initialize the base class.
+ parser_init (&parser->base, &oceanic_veo250_parser_backend);
+
+ *out = (parser_t*) parser;
+
+ return PARSER_STATUS_SUCCESS;
+}
+
+
+static parser_status_t
+oceanic_veo250_parser_destroy (parser_t *abstract)
+{
+ if (! parser_is_oceanic_veo250 (abstract))
+ return PARSER_STATUS_TYPE_MISMATCH;
+
+ // Free memory.
+ free (abstract);
+
+ return PARSER_STATUS_SUCCESS;
+}
+
+
+static parser_status_t
+oceanic_veo250_parser_set_data (parser_t *abstract, const unsigned char *data, unsigned int size)
+{
+ if (! parser_is_oceanic_veo250 (abstract))
+ return PARSER_STATUS_TYPE_MISMATCH;
+
+ return PARSER_STATUS_SUCCESS;
+}
+
+
+static parser_status_t
+oceanic_veo250_parser_samples_foreach (parser_t *abstract, sample_callback_t callback, void *userdata)
+{
+ if (! parser_is_oceanic_veo250 (abstract))
+ return PARSER_STATUS_TYPE_MISMATCH;
+
+ const unsigned char *data = abstract->data;
+ unsigned int size = abstract->size;
+
+ if (size < 7 * OCEANIC_VEO250_PACKET_SIZE / 2)
+ return PARSER_STATUS_ERROR;
+
+ unsigned int time = 0;
+ unsigned int interval = 0;
+ switch (data[0x27] & 0x03) {
+ case 0:
+ interval = 2;
+ break;
+ case 1:
+ interval = 15;
+ break;
+ case 2:
+ interval = 30;
+ break;
+ case 3:
+ interval = 60;
+ break;
+ }
+
+ unsigned int offset = 5 * OCEANIC_VEO250_PACKET_SIZE / 2;
+ while (offset + OCEANIC_VEO250_PACKET_SIZE / 2 <= size - OCEANIC_VEO250_PACKET_SIZE) {
+ parser_sample_value_t sample = {0};
+
+ // Ignore empty samples.
+ if (array_isequal (data + offset, OCEANIC_VEO250_PACKET_SIZE / 2, 0x00)) {
+ offset += OCEANIC_VEO250_PACKET_SIZE / 2;
+ continue;
+ }
+
+ // Time.
+ time += interval;
+ sample.time = time;
+ if (callback) callback (SAMPLE_TYPE_TIME, sample, userdata);
+
+ // Vendor specific data
+ sample.vendor.type = SAMPLE_VENDOR_OCEANIC_VEO250;
+ sample.vendor.size = OCEANIC_VEO250_PACKET_SIZE / 2;
+ sample.vendor.data = data + offset;
+ if (callback) callback (SAMPLE_TYPE_VENDOR, sample, userdata);
+
+ // Depth (ft)
+ unsigned int depth = data[offset + 2];
+ sample.depth = depth * FEET;
+ if (callback) callback (SAMPLE_TYPE_DEPTH, sample, userdata);
+
+ // Temperature (°F)
+ unsigned int temperature = data[offset + 7];
+ sample.temperature = (temperature - 32.0) * (5.0 / 9.0);
+ if (callback) callback (SAMPLE_TYPE_TEMPERATURE, sample, userdata);
+
+ offset += OCEANIC_VEO250_PACKET_SIZE / 2;
+ }
+
+ return PARSER_STATUS_SUCCESS;
+}
diff --git a/src/parser.h b/src/parser.h
index 2afa45f..f16355f 100644
--- a/src/parser.h
+++ b/src/parser.h
@@ -38,6 +38,7 @@ typedef enum parser_type_t {
PARSER_TYPE_UWATEC_MEMOMOUSE,
PARSER_TYPE_UWATEC_SMART,
PARSER_TYPE_MARES_NEMO,
+ PARSER_TYPE_OCEANIC_VEO250,
PARSER_TYPE_OCEANIC_ATOM2
} parser_type_t;
@@ -98,6 +99,7 @@ typedef enum parser_sample_vendor_t {
SAMPLE_VENDOR_NONE,
SAMPLE_VENDOR_UWATEC_ALADIN,
SAMPLE_VENDOR_UWATEC_SMART,
+ SAMPLE_VENDOR_OCEANIC_VEO250,
SAMPLE_VENDOR_OCEANIC_ATOM2
} parser_sample_vendor_t;