From ba96b3092df958befad27cb5b6f0ebd2d39caf68 Mon Sep 17 00:00:00 2001 From: Nick Shore Date: Tue, 28 Jan 2020 08:17:28 +0100 Subject: [PATCH 1/5] Fix the vtpro datetime parsing For the BCD encoded day field (range 1-31), two bits are sufficient to represent the upper digit (range 0-3). The purpose of the highest bit is unknown, but it's certainly not part of the day field, and needs to be masked off. --- src/oceanic_vtpro_parser.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/oceanic_vtpro_parser.c b/src/oceanic_vtpro_parser.c index 894b626..d09b2f9 100644 --- a/src/oceanic_vtpro_parser.c +++ b/src/oceanic_vtpro_parser.c @@ -129,7 +129,7 @@ oceanic_vtpro_parser_get_datetime (dc_parser_t *abstract, dc_datetime_t *datetim else datetime->year = bcd2dec (((p[32 + 3] & 0xC0) >> 2) + ((p[32 + 2] & 0xF0) >> 4)) + 2000; datetime->month = (p[4] & 0xF0) >> 4; - datetime->day = bcd2dec (p[3]); + datetime->day = bcd2dec (p[3] & 0x7F); datetime->hour = bcd2dec (p[1] & 0x7F); pm = p[1] & 0x80; } From 4a60f89f4ab017a95c13d7cb073d507b23264d70 Mon Sep 17 00:00:00 2001 From: Janice McLaughlin Date: Tue, 4 Feb 2020 08:17:19 +0100 Subject: [PATCH 2/5] Add support for the Sherwood Wisdom 4 --- src/descriptor.c | 2 ++ src/oceanic_atom2.c | 1 + src/oceanic_atom2_parser.c | 17 ++++++++++++----- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/descriptor.c b/src/descriptor.c index 3734df5..a81f3e3 100644 --- a/src/descriptor.c +++ b/src/descriptor.c @@ -244,6 +244,7 @@ static const dc_descriptor_t g_descriptors[] = { {"Aqualung", "i550C", DC_FAMILY_OCEANIC_ATOM2, 0x4652, DC_TRANSPORT_SERIAL | DC_TRANSPORT_BLE, dc_filter_oceanic}, {"Oceanic", "Geo 4.0", DC_FAMILY_OCEANIC_ATOM2, 0x4653, DC_TRANSPORT_SERIAL | DC_TRANSPORT_BLE, dc_filter_oceanic}, {"Oceanic", "Veo 4.0", DC_FAMILY_OCEANIC_ATOM2, 0x4654, DC_TRANSPORT_SERIAL | DC_TRANSPORT_BLE, dc_filter_oceanic}, + {"Sherwood", "Wisdom 4", DC_FAMILY_OCEANIC_ATOM2, 0x4655, DC_TRANSPORT_SERIAL | DC_TRANSPORT_BLE, dc_filter_oceanic}, {"Oceanic", "Pro Plus 4", DC_FAMILY_OCEANIC_ATOM2, 0x4656, DC_TRANSPORT_SERIAL | DC_TRANSPORT_BLE, dc_filter_oceanic}, /* Mares Nemo */ {"Mares", "Nemo", DC_FAMILY_MARES_NEMO, 0, DC_TRANSPORT_SERIAL, NULL}, @@ -615,6 +616,7 @@ static int dc_filter_oceanic (dc_transport_t transport, const void *userdata) 0x4652, // Aqualung i550C 0x4653, // Oceanic Geo 4.0 0x4654, // Oceanic Veo 4.0 + 0x4655, // Sherwood Wisdom 4 0x4656, // Oceanic Pro Plus 4 }; diff --git a/src/oceanic_atom2.c b/src/oceanic_atom2.c index c892486..0ed9a0d 100644 --- a/src/oceanic_atom2.c +++ b/src/oceanic_atom2.c @@ -174,6 +174,7 @@ static const oceanic_common_version_t oceanic_oc1_version[] = { {"OCSWATCH \0\0 1024"}, {"AQUAI550 \0\0 1024"}, {"AQUA550C \0\0 1024"}, + {"WISDOM04 \0\0 1024"}, }; static const oceanic_common_version_t oceanic_oci_version[] = { diff --git a/src/oceanic_atom2_parser.c b/src/oceanic_atom2_parser.c index 1f4f852..74f73cf 100644 --- a/src/oceanic_atom2_parser.c +++ b/src/oceanic_atom2_parser.c @@ -94,6 +94,7 @@ #define I550C 0x4652 #define GEO40 0x4653 #define VEO40 0x4654 +#define WISDOM4 0x4655 #define PROPLUS4 0x4656 #define NORMAL 0 @@ -190,7 +191,7 @@ oceanic_atom2_parser_create (dc_parser_t **out, dc_context_t *context, unsigned parser->headersize = 5 * PAGESIZE; } else if (model == PROPLUSX) { parser->headersize = 3 * PAGESIZE; - } else if (model == I550C) { + } else if (model == I550C || model == WISDOM4) { parser->headersize = 5 * PAGESIZE / 2; } @@ -269,6 +270,7 @@ oceanic_atom2_parser_get_datetime (dc_parser_t *abstract, dc_datetime_t *datetim case I550C: case VISION: case XPAIR: + case WISDOM4: datetime->year = ((p[5] & 0xE0) >> 5) + ((p[7] & 0xE0) >> 2) + 2000; datetime->month = (p[3] & 0x0F); datetime->day = ((p[0] & 0x80) >> 3) + ((p[3] & 0xF0) >> 4); @@ -481,6 +483,9 @@ oceanic_atom2_parser_cache (oceanic_atom2_parser_t *parser) o2_offset = 0x30; ngasmixes = 4; o2_step = 2; + } else if (parser->model == WISDOM4) { + o2_offset = header + 4; + ngasmixes = 1; } else { o2_offset = header + 4; ngasmixes = 3; @@ -907,7 +912,7 @@ oceanic_atom2_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_ unsigned int sign; if (parser->model == DG03 || parser->model == PROPLUS3 || parser->model == I550 || parser->model == I550C || - parser->model == PROPLUS4) + parser->model == PROPLUS4 || parser->model == WISDOM4) sign = (~data[offset + 5] & 0x04) >> 2; else if (parser->model == VOYAGER2G || parser->model == AMPHOS || parser->model == AMPHOSAIR || parser->model == ZENAIR) @@ -940,7 +945,8 @@ oceanic_atom2_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_ parser->model == DG03 || parser->model == PROPLUS3 || parser->model == AMPHOSAIR || parser->model == I550 || parser->model == VISION || parser->model == XPAIR || - parser->model == I550C || parser->model == PROPLUS4) + parser->model == I550C || parser->model == PROPLUS4 || + parser->model == WISDOM4) pressure = (((data[offset + 0] & 0x03) << 8) + data[offset + 1]) * 5; else if (parser->model == TX1 || parser->model == A300CS || parser->model == VTX || parser->model == I750TC || @@ -1009,7 +1015,7 @@ oceanic_atom2_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_ have_deco = 1; } else if (parser->model == ATOM31 || parser->model == VISION || parser->model == XPAIR || parser->model == I550 || - parser->model == I550C) { + parser->model == I550C || parser->model == WISDOM4) { decostop = (data[offset + 5] & 0xF0) >> 4; decotime = array_uint16_le(data + offset + 4) & 0x03FF; have_deco = 1; @@ -1047,7 +1053,8 @@ oceanic_atom2_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_ rbt = array_uint16_le(data + offset + 8) & 0x01FF; have_rbt = 1; } else if (parser->model == VISION || parser->model == XPAIR || - parser->model == I550 || parser->model == I550C) { + parser->model == I550 || parser->model == I550C || + parser->model == WISDOM4) { rbt = array_uint16_le(data + offset + 6) & 0x03FF; have_rbt = 1; } From a01b9bc9b9829abd396a885ae842cb15cdbb580c Mon Sep 17 00:00:00 2001 From: Janice McLaughlin Date: Tue, 4 Feb 2020 08:18:55 +0100 Subject: [PATCH 3/5] Add support for the Scubapro A1 --- src/descriptor.c | 2 ++ src/uwatec_smart_parser.c | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/descriptor.c b/src/descriptor.c index a81f3e3..74d0f8a 100644 --- a/src/descriptor.c +++ b/src/descriptor.c @@ -151,6 +151,7 @@ static const dc_descriptor_t g_descriptors[] = { {"Scubapro", "Mantis", DC_FAMILY_UWATEC_SMART, 0x20, DC_TRANSPORT_SERIAL, NULL}, {"Scubapro", "Aladin Square", DC_FAMILY_UWATEC_SMART, 0x22, DC_TRANSPORT_USBHID, dc_filter_uwatec}, {"Scubapro", "Chromis", DC_FAMILY_UWATEC_SMART, 0x24, DC_TRANSPORT_SERIAL, NULL}, + {"Scubapro", "Aladin A1", DC_FAMILY_UWATEC_SMART, 0x25, DC_TRANSPORT_BLE, dc_filter_uwatec}, {"Scubapro", "Mantis 2", DC_FAMILY_UWATEC_SMART, 0x26, DC_TRANSPORT_SERIAL, NULL}, {"Scubapro", "G2", DC_FAMILY_UWATEC_SMART, 0x32, DC_TRANSPORT_USBHID | DC_TRANSPORT_BLE, dc_filter_uwatec}, {"Scubapro", "G2 Console", DC_FAMILY_UWATEC_SMART, 0x32, DC_TRANSPORT_USBHID | DC_TRANSPORT_BLE, dc_filter_uwatec}, @@ -493,6 +494,7 @@ static int dc_filter_uwatec (dc_transport_t transport, const void *userdata) "G2", "Aladin", "HUD", + "A1", }; if (transport == DC_TRANSPORT_IRDA) { diff --git a/src/uwatec_smart_parser.c b/src/uwatec_smart_parser.c index 44b1e45..5974dbe 100644 --- a/src/uwatec_smart_parser.c +++ b/src/uwatec_smart_parser.c @@ -48,6 +48,7 @@ #define MERIDIAN 0x20 #define ALADINSQUARE 0x22 #define CHROMIS 0x24 +#define ALADINA1 0x25 #define MANTIS2 0x26 #define G2 0x32 #define G2HUD 0x42 @@ -530,7 +531,8 @@ uwatec_smart_parser_cache (uwatec_smart_parser_t *parser) parser->model == ALADIN2G || parser->model == MERIDIAN || parser->model == CHROMIS || parser->model == MANTIS2 || parser->model == G2 || parser->model == ALADINSPORTMATRIX || - parser->model == ALADINSQUARE || parser->model == G2HUD) { + parser->model == ALADINSQUARE || parser->model == G2HUD || + parser->model == ALADINA1) { unsigned int offset = header->tankpressure + 2 * i; endpressure = array_uint16_le(data + offset); beginpressure = array_uint16_le(data + offset + 2 * header->ngases); @@ -623,6 +625,7 @@ uwatec_smart_parser_create (dc_parser_t **out, dc_context_t *context, unsigned i case G2: case G2HUD: case ALADINSPORTMATRIX: + case ALADINA1: parser->headersize = 84; parser->header = &uwatec_smart_trimix_header; parser->samples = uwatec_smart_galileo_samples; @@ -965,7 +968,8 @@ uwatec_smart_parse (uwatec_smart_parser_t *parser, dc_sample_callback_t callback parser->model == ALADIN2G || parser->model == MERIDIAN || parser->model == CHROMIS || parser->model == MANTIS2 || parser->model == G2 || parser->model == ALADINSPORTMATRIX || - parser->model == ALADINSQUARE || parser->model == G2HUD) { + parser->model == ALADINSQUARE || parser->model == G2HUD || + parser->model == ALADINA1) { // Uwatec Galileo id = uwatec_galileo_identify (data[offset]); } else { From 59d9791446c8b2dd728960876b05f7f108445e7e Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Mon, 10 Feb 2020 22:52:55 +0100 Subject: [PATCH 4/5] Limit the depth value to 11 bits The depth value is encoded with only 11 bits instead of 12 bits. The extra bit contains the gas mix index. This resulted in wrong depths, with values larger than 204.8m. --- src/cressi_goa_parser.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cressi_goa_parser.c b/src/cressi_goa_parser.c index cc99d2c..bd89a54 100644 --- a/src/cressi_goa_parser.c +++ b/src/cressi_goa_parser.c @@ -190,7 +190,7 @@ cressi_goa_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t c if (type == DEPTH) { // Depth (1/10 m). - unsigned int depth = value & 0x0FFF; + unsigned int depth = value & 0x07FF; sample.depth = depth / 10.0; if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); complete = 1; From 5dc7e54596448be828ea695e5e999cd620d1bc60 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Mon, 10 Feb 2020 22:53:27 +0100 Subject: [PATCH 5/5] Implement the gas mix sample The current gas mix index is stored in the 11th bit of the sample value. --- src/cressi_goa_parser.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/cressi_goa_parser.c b/src/cressi_goa_parser.c index bd89a54..d7599dc 100644 --- a/src/cressi_goa_parser.c +++ b/src/cressi_goa_parser.c @@ -170,6 +170,7 @@ cressi_goa_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t c unsigned int time = 0; unsigned int interval = 5; unsigned int complete = 1; + unsigned int gasmix_previous = 0xFFFFFFFF; unsigned int offset = SZ_HEADER; while (offset + 2 <= size) { @@ -193,6 +194,15 @@ cressi_goa_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t c unsigned int depth = value & 0x07FF; sample.depth = depth / 10.0; if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); + + // Gas change. + unsigned int gasmix = (value & 0x0800) >> 11; + if (gasmix != gasmix_previous) { + sample.gasmix = gasmix; + if (callback) callback (DC_SAMPLE_GASMIX, sample, userdata); + gasmix_previous = gasmix; + } + complete = 1; } else if (type == TEMPERATURE) { // Temperature (1/10 °C).