From 00c2705786aeb82064121618cf64d87aa8a376ac Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Sun, 7 Aug 2016 21:29:06 +0200 Subject: [PATCH] Add the serial number encoding to the layout. At the moment, the encoding of the serial number is tied to the global pointer mode. To support devices where this is no longer the case, a new entry for the serial number encoding is added. --- src/oceanic_atom2.c | 54 +++++++++++++++++++++++++++++--------------- src/oceanic_common.c | 2 +- src/oceanic_common.h | 1 + src/oceanic_veo250.c | 3 ++- src/oceanic_vtpro.c | 9 +++++--- 5 files changed, 46 insertions(+), 23 deletions(-) diff --git a/src/oceanic_atom2.c b/src/oceanic_atom2.c index 323b0ec..d8d328a 100644 --- a/src/oceanic_atom2.c +++ b/src/oceanic_atom2.c @@ -195,7 +195,8 @@ static const oceanic_common_layout_t aeris_f10_layout = { 0x0D80, /* rb_profile_begin */ 0x10000, /* rb_profile_end */ 0, /* pt_mode_global */ - 2 /* pt_mode_logbook */ + 2, /* pt_mode_logbook */ + 0, /* pt_mode_serial */ }; static const oceanic_common_layout_t aeris_f11_layout = { @@ -208,7 +209,8 @@ static const oceanic_common_layout_t aeris_f11_layout = { 0x0D80, /* rb_profile_begin */ 0x20000, /* rb_profile_end */ 0, /* pt_mode_global */ - 3 /* pt_mode_logbook */ + 3, /* pt_mode_logbook */ + 0, /* pt_mode_serial */ }; static const oceanic_common_layout_t oceanic_default_layout = { @@ -221,7 +223,8 @@ static const oceanic_common_layout_t oceanic_default_layout = { 0x0A40, /* rb_profile_begin */ 0x10000, /* rb_profile_end */ 0, /* pt_mode_global */ - 0 /* pt_mode_logbook */ + 0, /* pt_mode_logbook */ + 0, /* pt_mode_serial */ }; static const oceanic_common_layout_t oceanic_atom1_layout = { @@ -234,7 +237,8 @@ static const oceanic_common_layout_t oceanic_atom1_layout = { 0x0440, /* rb_profile_begin */ 0x8000, /* rb_profile_end */ 0, /* pt_mode_global */ - 0 /* pt_mode_logbook */ + 0, /* pt_mode_logbook */ + 0, /* pt_mode_serial */ }; static const oceanic_common_layout_t oceanic_atom2a_layout = { @@ -247,7 +251,8 @@ static const oceanic_common_layout_t oceanic_atom2a_layout = { 0x0A40, /* rb_profile_begin */ 0xFE00, /* rb_profile_end */ 0, /* pt_mode_global */ - 0 /* pt_mode_logbook */ + 0, /* pt_mode_logbook */ + 0, /* pt_mode_serial */ }; static const oceanic_common_layout_t oceanic_atom2b_layout = { @@ -260,7 +265,8 @@ static const oceanic_common_layout_t oceanic_atom2b_layout = { 0x0A40, /* rb_profile_begin */ 0xFE00, /* rb_profile_end */ 0, /* pt_mode_global */ - 0 /* pt_mode_logbook */ + 0, /* pt_mode_logbook */ + 0, /* pt_mode_serial */ }; static const oceanic_common_layout_t oceanic_atom2c_layout = { @@ -273,7 +279,8 @@ static const oceanic_common_layout_t oceanic_atom2c_layout = { 0x0A40, /* rb_profile_begin */ 0xFFF0, /* rb_profile_end */ 0, /* pt_mode_global */ - 0 /* pt_mode_logbook */ + 0, /* pt_mode_logbook */ + 0, /* pt_mode_serial */ }; static const oceanic_common_layout_t oceanic_proplus3_layout = { @@ -286,7 +293,8 @@ static const oceanic_common_layout_t oceanic_proplus3_layout = { 0x0A40, /* rb_profile_begin */ 0xFE00, /* rb_profile_end */ 0, /* pt_mode_global */ - 0 /* pt_mode_logbook */ + 0, /* pt_mode_logbook */ + 0, /* pt_mode_serial */ }; static const oceanic_common_layout_t tusa_zenair_layout = { @@ -299,7 +307,8 @@ static const oceanic_common_layout_t tusa_zenair_layout = { 0x0A40, /* rb_profile_begin */ 0xFE00, /* rb_profile_end */ 0, /* pt_mode_global */ - 1 /* pt_mode_logbook */ + 1, /* pt_mode_logbook */ + 0, /* pt_mode_serial */ }; static const oceanic_common_layout_t oceanic_oc1_layout = { @@ -312,7 +321,8 @@ static const oceanic_common_layout_t oceanic_oc1_layout = { 0x0A40, /* rb_profile_begin */ 0x1FE00, /* rb_profile_end */ 0, /* pt_mode_global */ - 1 /* pt_mode_logbook */ + 1, /* pt_mode_logbook */ + 0, /* pt_mode_serial */ }; static const oceanic_common_layout_t oceanic_oci_layout = { @@ -325,7 +335,8 @@ static const oceanic_common_layout_t oceanic_oci_layout = { 0x1400, /* rb_profile_begin */ 0x1FE00, /* rb_profile_end */ 0, /* pt_mode_global */ - 1 /* pt_mode_logbook */ + 1, /* pt_mode_logbook */ + 0, /* pt_mode_serial */ }; static const oceanic_common_layout_t oceanic_atom3_layout = { @@ -338,7 +349,8 @@ static const oceanic_common_layout_t oceanic_atom3_layout = { 0x0A40, /* rb_profile_begin */ 0x1FE00, /* rb_profile_end */ 0, /* pt_mode_global */ - 1 /* pt_mode_logbook */ + 1, /* pt_mode_logbook */ + 0, /* pt_mode_serial */ }; static const oceanic_common_layout_t oceanic_vt4_layout = { @@ -351,7 +363,8 @@ static const oceanic_common_layout_t oceanic_vt4_layout = { 0x0A40, /* rb_profile_begin */ 0x1FE00, /* rb_profile_end */ 0, /* pt_mode_global */ - 1 /* pt_mode_logbook */ + 1, /* pt_mode_logbook */ + 0, /* pt_mode_serial */ }; static const oceanic_common_layout_t hollis_tx1_layout = { @@ -364,7 +377,8 @@ static const oceanic_common_layout_t hollis_tx1_layout = { 0x1000, /* rb_profile_begin */ 0x40000, /* rb_profile_end */ 0, /* pt_mode_global */ - 1 /* pt_mode_logbook */ + 1, /* pt_mode_logbook */ + 0, /* pt_mode_serial */ }; static const oceanic_common_layout_t oceanic_veo1_layout = { @@ -377,7 +391,8 @@ static const oceanic_common_layout_t oceanic_veo1_layout = { 0x0400, /* rb_profile_begin */ 0x0400, /* rb_profile_end */ 0, /* pt_mode_global */ - 0 /* pt_mode_logbook */ + 0, /* pt_mode_logbook */ + 0, /* pt_mode_serial */ }; static const oceanic_common_layout_t oceanic_reactpro_layout = { @@ -390,7 +405,8 @@ static const oceanic_common_layout_t oceanic_reactpro_layout = { 0x0600, /* rb_profile_begin */ 0xFFF0, /* rb_profile_end */ 1, /* pt_mode_global */ - 1 /* pt_mode_logbook */ + 1, /* pt_mode_logbook */ + 1, /* pt_mode_serial */ }; static const oceanic_common_layout_t aeris_a300cs_layout = { @@ -403,7 +419,8 @@ static const oceanic_common_layout_t aeris_a300cs_layout = { 0x1000, /* rb_profile_begin */ 0x3FE00, /* rb_profile_end */ 0, /* pt_mode_global */ - 1 /* pt_mode_logbook */ + 1, /* pt_mode_logbook */ + 0, /* pt_mode_serial */ }; static const oceanic_common_layout_t aqualung_i450t_layout = { @@ -416,7 +433,8 @@ static const oceanic_common_layout_t aqualung_i450t_layout = { 0x1400, /* rb_profile_begin */ 0x3FE00, /* rb_profile_end */ 0, /* pt_mode_global */ - 1 /* pt_mode_logbook */ + 1, /* pt_mode_logbook */ + 0, /* pt_mode_serial */ }; static dc_status_t diff --git a/src/oceanic_common.c b/src/oceanic_common.c index 64e0867..b4bc1c7 100644 --- a/src/oceanic_common.c +++ b/src/oceanic_common.c @@ -644,7 +644,7 @@ oceanic_common_device_foreach (dc_device_t *abstract, dc_dive_callback_t callbac dc_event_devinfo_t devinfo; devinfo.model = array_uint16_be (id + 8); devinfo.firmware = 0; - if (layout->pt_mode_global == 0) + if (layout->pt_mode_serial == 0) devinfo.serial = bcd2dec (id[10]) * 10000 + bcd2dec (id[11]) * 100 + bcd2dec (id[12]); else devinfo.serial = id[11] * 10000 + id[12] * 100 + id[13]; diff --git a/src/oceanic_common.h b/src/oceanic_common.h index 7c88e54..1b8ed08 100644 --- a/src/oceanic_common.h +++ b/src/oceanic_common.h @@ -55,6 +55,7 @@ typedef struct oceanic_common_layout_t { // 12-bit values or two 16-bit values with each 4 bits padding). unsigned int pt_mode_global; unsigned int pt_mode_logbook; + unsigned int pt_mode_serial; } oceanic_common_layout_t; typedef struct oceanic_common_device_t { diff --git a/src/oceanic_veo250.c b/src/oceanic_veo250.c index 2ffa0fd..d91f1be 100644 --- a/src/oceanic_veo250.c +++ b/src/oceanic_veo250.c @@ -83,7 +83,8 @@ static const oceanic_common_layout_t oceanic_veo250_layout = { 0x0600, /* rb_profile_begin */ 0x8000, /* rb_profile_end */ 1, /* pt_mode_global */ - 1 /* pt_mode_logbook */ + 1, /* pt_mode_logbook */ + 1, /* pt_mode_serial */ }; diff --git a/src/oceanic_vtpro.c b/src/oceanic_vtpro.c index f0ea4ba..1fe5cde 100644 --- a/src/oceanic_vtpro.c +++ b/src/oceanic_vtpro.c @@ -98,7 +98,8 @@ static const oceanic_common_layout_t oceanic_vtpro_layout = { 0x0440, /* rb_profile_begin */ 0x8000, /* rb_profile_end */ 0, /* pt_mode_global */ - 0 /* pt_mode_logbook */ + 0, /* pt_mode_logbook */ + 0, /* pt_mode_serial */ }; static const oceanic_common_layout_t oceanic_wisdom_layout = { @@ -111,7 +112,8 @@ static const oceanic_common_layout_t oceanic_wisdom_layout = { 0x05D0, /* rb_profile_begin */ 0x8000, /* rb_profile_end */ 0, /* pt_mode_global */ - 0 /* pt_mode_logbook */ + 0, /* pt_mode_logbook */ + 0, /* pt_mode_serial */ }; static const oceanic_common_layout_t aeris_500ai_layout = { @@ -124,7 +126,8 @@ static const oceanic_common_layout_t aeris_500ai_layout = { 0x00200, /* rb_profile_begin */ 0x20000, /* rb_profile_end */ 0, /* pt_mode_global */ - 1 /* pt_mode_logbook */ + 1, /* pt_mode_logbook */ + 0, /* pt_mode_serial */ }; static dc_status_t