subrascasse

Sub Rascasse: an iPhone dive log for Subsurface cloud storage, with a pure-Swift git client (GPL-2.0)
git clone https://git.schurger.org/subrascasse.git
Log | Files | Refs | README | LICENSE

oceanic_common.h (7183B)


      1 /*
      2  * libdivecomputer
      3  *
      4  * Copyright (C) 2009 Jef Driesen
      5  *
      6  * This library is free software; you can redistribute it and/or
      7  * modify it under the terms of the GNU Lesser General Public
      8  * License as published by the Free Software Foundation; either
      9  * version 2.1 of the License, or (at your option) any later version.
     10  *
     11  * This library is distributed in the hope that it will be useful,
     12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     14  * Lesser General Public License for more details.
     15  *
     16  * You should have received a copy of the GNU Lesser General Public
     17  * License along with this library; if not, write to the Free Software
     18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
     19  * MA 02110-1301 USA
     20  */
     21 
     22 #ifndef OCEANIC_COMMON_H
     23 #define OCEANIC_COMMON_H
     24 
     25 #include "device-private.h"
     26 
     27 #ifdef __cplusplus
     28 extern "C" {
     29 #endif /* __cplusplus */
     30 
     31 // vtpro
     32 #define AERIS500AI    0x4151
     33 #define VERSAPRO      0x4155
     34 #define ATMOS2        0x4158
     35 #define PROPLUS2      0x4159
     36 #define ATMOSAI       0x4244
     37 #define VTPRO         0x4245
     38 #define WISDOM        0x4246
     39 #define ELITE         0x424F
     40 
     41 // veo250
     42 #define REACTPRO      0x4247
     43 #define VEO200        0x424B
     44 #define VEO250        0x424C
     45 #define XP5           0x4251
     46 #define VEO180        0x4252
     47 #define XR2           0x4255
     48 #define INSIGHT       0x425A
     49 #define DG02          0x4352
     50 
     51 // atom2
     52 #define ATOM1         0x4250
     53 #define EPICA         0x4257
     54 #define VT3           0x4258
     55 #define T3A           0x4259
     56 #define ATOM2         0x4342
     57 #define GEO           0x4344
     58 #define MANTA         0x4345
     59 #define XR1NX         0x4346
     60 #define DATAMASK      0x4347
     61 #define COMPUMASK     0x4348
     62 #define F10A          0x434D
     63 #define OC1A          0x434E
     64 #define WISDOM2       0x4350
     65 #define INSIGHT2      0x4353
     66 #define REACTPROWHITE 0x4354
     67 #define ELEMENT2      0x4357
     68 #define VEO10         0x4358
     69 #define VEO20         0x4359
     70 #define VEO30         0x435A
     71 #define ZEN           0x4441
     72 #define ZENAIR        0x4442
     73 #define ATMOSAI2      0x4443
     74 #define PROPLUS21     0x4444
     75 #define GEO20         0x4446
     76 #define VT4           0x4447
     77 #define OC1B          0x4449
     78 #define VOYAGER2G     0x444B
     79 #define ATOM3         0x444C
     80 #define DG03          0x444D
     81 #define OCS           0x4450
     82 #define OC1C          0x4451
     83 #define VT41          0x4452
     84 #define EPICB         0x4453
     85 #define T3B           0x4455
     86 #define ATOM31        0x4456
     87 #define A300AI        0x4457
     88 #define WISDOM3       0x4458
     89 #define A300          0x445A
     90 #define TX1           0x4542
     91 #define MUNDIAL2      0x4543
     92 #define AMPHOS        0x4545
     93 #define AMPHOSAIR     0x4546
     94 #define PROPLUS3      0x4548
     95 #define F11A          0x4549
     96 #define OCI           0x454B
     97 #define A300CS        0x454C
     98 #define TALIS         0x454E
     99 #define MUNDIAL3      0x4550
    100 #define PROPLUSX      0x4552
    101 #define F10B          0x4553
    102 #define F11B          0x4554
    103 #define XPAIR         0x4555
    104 #define VISION        0x4556
    105 #define VTX           0x4557
    106 #define I300          0x4559
    107 #define I750TC        0x455A
    108 #define I450T         0x4641
    109 #define I550          0x4642
    110 #define I200          0x4646
    111 #define SAGE          0x4647
    112 #define I300C         0x4648
    113 #define I200C         0x4649
    114 #define I100          0x464E
    115 #define I770R         0x4651
    116 #define I550C         0x4652
    117 #define GEO40         0x4653
    118 #define VEO40         0x4654
    119 #define WISDOM4       0x4655
    120 #define PROPLUS4      0x4656
    121 #define AMPHOS2       0x4657
    122 #define AMPHOSAIR2    0x4658
    123 #define BEACON        0x4742
    124 #define I470TC        0x4743
    125 #define I100V2        0x4745
    126 #define I200CV2       0x4749
    127 #define GEOAIR        0x474B
    128 
    129 // i330r
    130 #define DSX           0x4741
    131 #define I330R         0x4744
    132 #define I330R_C       0x474D
    133 
    134 #define PAGESIZE 0x10
    135 #define FPMAXSIZE 0x200
    136 
    137 #define OCEANIC_COMMON_MATCH(version,patterns,firmware) \
    138 	oceanic_common_match ((version), (patterns), \
    139 	sizeof (patterns) / sizeof *(patterns), (firmware))
    140 
    141 typedef struct oceanic_common_layout_t {
    142 	// Memory size.
    143 	unsigned int memsize;
    144 	unsigned int highmem;
    145 	// Device info.
    146 	unsigned int cf_devinfo;
    147 	// Ringbuffer pointers.
    148 	unsigned int cf_pointers;
    149 	// Logbook ringbuffer.
    150 	unsigned int rb_logbook_begin;
    151 	unsigned int rb_logbook_end;
    152 	unsigned int rb_logbook_entry_size;
    153 	unsigned int rb_logbook_direction;
    154 	// Profile ringbuffer
    155 	unsigned int rb_profile_begin;
    156 	unsigned int rb_profile_end;
    157 	// The pointer mode indicates how the global ringbuffer pointers
    158 	// should be interpreted (a first/last or a begin/end pair), and
    159 	// how the profile pointers are stored in each logbook entry (two
    160 	// 12-bit values or two 16-bit values with each 4 bits padding).
    161 	unsigned int pt_mode_global;
    162 	unsigned int pt_mode_logbook;
    163 	unsigned int pt_mode_serial;
    164 } oceanic_common_layout_t;
    165 
    166 typedef struct oceanic_common_device_t {
    167 	dc_device_t base;
    168 	unsigned int firmware;
    169 	unsigned char version[PAGESIZE];
    170 	unsigned char fingerprint[FPMAXSIZE];
    171 	unsigned int model;
    172 	const oceanic_common_layout_t *layout;
    173 	unsigned int multipage;
    174 } oceanic_common_device_t;
    175 
    176 typedef struct oceanic_common_device_vtable_t {
    177 	dc_device_vtable_t base;
    178 	dc_status_t (*devinfo) (dc_device_t *device, dc_event_progress_t *progress);
    179 	dc_status_t (*pointers) (dc_device_t *device, dc_event_progress_t *progress, unsigned int *rb_logbook_begin, unsigned int *rb_logbook_end, unsigned int *rb_profile_begin, unsigned int *rb_profile_end);
    180 	dc_status_t (*logbook) (dc_device_t *device, dc_event_progress_t *progress, dc_buffer_t *logbook, unsigned int begin, unsigned int end);
    181 	dc_status_t (*profile) (dc_device_t *device, dc_event_progress_t *progress, dc_buffer_t *logbook, dc_dive_callback_t callback, void *userdata);
    182 } oceanic_common_device_vtable_t;
    183 
    184 typedef struct oceanic_common_version_t {
    185 	unsigned char pattern[PAGESIZE + 1];
    186 	unsigned int firmware;
    187 	unsigned int model;
    188 	const oceanic_common_layout_t *layout;
    189 } oceanic_common_version_t;
    190 
    191 const oceanic_common_version_t *
    192 oceanic_common_match (const unsigned char *version, const oceanic_common_version_t patterns[], size_t n, unsigned int *firmware);
    193 
    194 void
    195 oceanic_common_device_init (oceanic_common_device_t *device);
    196 
    197 dc_status_t
    198 oceanic_common_device_devinfo (dc_device_t *device, dc_event_progress_t *progress);
    199 
    200 dc_status_t
    201 oceanic_common_device_pointers (dc_device_t *device, dc_event_progress_t *progress,
    202 	unsigned int *rb_logbook_begin, unsigned int *rb_logbook_end,
    203 	unsigned int *rb_profile_begin, unsigned int *rb_profile_end);
    204 
    205 dc_status_t
    206 oceanic_common_device_logbook (dc_device_t *device, dc_event_progress_t *progress, dc_buffer_t *logbook, unsigned int begin, unsigned int end);
    207 
    208 dc_status_t
    209 oceanic_common_device_profile (dc_device_t *device, dc_event_progress_t *progress, dc_buffer_t *logbook, dc_dive_callback_t callback, void *userdata);
    210 
    211 dc_status_t
    212 oceanic_common_device_set_fingerprint (dc_device_t *device, const unsigned char data[], unsigned int size);
    213 
    214 dc_status_t
    215 oceanic_common_device_dump (dc_device_t *abstract, dc_buffer_t *buffer);
    216 
    217 dc_status_t
    218 oceanic_common_device_foreach (dc_device_t *device, dc_dive_callback_t callback, void *userdata);
    219 
    220 #ifdef __cplusplus
    221 }
    222 #endif /* __cplusplus */
    223 #endif /* OCEANIC_COMMON_H */