mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Added support for older Cochran models that have configurable sample intervals.
Corrected problem where dive profiles would include post dive surface interval samples. Added detection for corrupt dives. Signed-off-by: John Van Ostrand <john@vanostrand.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
c6bc88b50d
commit
f604089ae3
2 changed files with 36 additions and 33 deletions
|
@ -258,14 +258,10 @@ static void cochran_parse_header(const unsigned char *decode, unsigned mod,
|
||||||
static int cochran_predive_event_bytes(unsigned char code)
|
static int cochran_predive_event_bytes(unsigned char code)
|
||||||
{
|
{
|
||||||
int x = 0;
|
int x = 0;
|
||||||
int gem_event_bytes[15][2] = {{0x00, 10}, {0x02, 17}, {0x08, 18},
|
|
||||||
{0x09, 18}, {0x0c, 18}, {0x0d, 18},
|
|
||||||
{0x0e, 18},
|
|
||||||
{-1, 0}};
|
|
||||||
int cmdr_event_bytes[15][2] = {{0x00, 16}, {0x01, 20}, {0x02, 17},
|
int cmdr_event_bytes[15][2] = {{0x00, 16}, {0x01, 20}, {0x02, 17},
|
||||||
{0x03, 16}, {0x06, 18}, {0x07, 18},
|
{0x03, 16}, {0x06, 18}, {0x07, 18},
|
||||||
{0x08, 18}, {0x09, 18}, {0x0a, 18},
|
{0x08, 18}, {0x09, 18}, {0x0a, 18},
|
||||||
{0x0b, 20}, {0x0c, 18}, {0x0d, 18},
|
{0x0b, 18}, {0x0c, 18}, {0x0d, 18},
|
||||||
{0x0e, 18}, {0x10, 20},
|
{0x0e, 18}, {0x10, 20},
|
||||||
{-1, 0}};
|
{-1, 0}};
|
||||||
int emc_event_bytes[15][2] = {{0x00, 18}, {0x01, 22}, {0x02, 19},
|
int emc_event_bytes[15][2] = {{0x00, 18}, {0x01, 22}, {0x02, 19},
|
||||||
|
@ -276,10 +272,6 @@ static int cochran_predive_event_bytes(unsigned char code)
|
||||||
|
|
||||||
switch (config.type) {
|
switch (config.type) {
|
||||||
case TYPE_GEMINI:
|
case TYPE_GEMINI:
|
||||||
while (gem_event_bytes[x][0] != code && gem_event_bytes[x][0] != -1)
|
|
||||||
x++;
|
|
||||||
return gem_event_bytes[x][1];
|
|
||||||
break;
|
|
||||||
case TYPE_COMMANDER:
|
case TYPE_COMMANDER:
|
||||||
while (cmdr_event_bytes[x][0] != code && cmdr_event_bytes[x][0] != -1)
|
while (cmdr_event_bytes[x][0] != code && cmdr_event_bytes[x][0] != -1)
|
||||||
x++;
|
x++;
|
||||||
|
@ -479,22 +471,20 @@ static void cochran_parse_samples(struct dive *dive, const unsigned char *log,
|
||||||
|
|
||||||
// Skip past pre-dive events
|
// Skip past pre-dive events
|
||||||
unsigned int x = 0;
|
unsigned int x = 0;
|
||||||
if (samples[x] != 0x40) {
|
unsigned int c;
|
||||||
unsigned int c;
|
while (x < size && (samples[x] & 0x80) == 0 && samples[x] != 0x40) {
|
||||||
while ((samples[x] & 0x80) == 0 && samples[x] != 0x40 && x < size) {
|
c = cochran_predive_event_bytes(samples[x]) + 1;
|
||||||
c = cochran_predive_event_bytes(samples[x]) + 1;
|
//#ifdef COCHRAN_DEBUG
|
||||||
#ifdef COCHRAN_DEBUG
|
printf("Predive event: ", samples[x]);
|
||||||
printf("Predive event: ", samples[x]);
|
for (int y = 0; y < c && x + y < size; y++) printf("%02x ", samples[x + y]);
|
||||||
for (int y = 0; y < c; y++) printf("%02x ", samples[x + y]);
|
putchar('\n');
|
||||||
putchar('\n');
|
//#endif
|
||||||
#endif
|
|
||||||
x += c;
|
x += c;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now process samples
|
// Now process samples
|
||||||
offset = x;
|
offset = x;
|
||||||
while (offset < size) {
|
while (offset + config.sample_size < size) {
|
||||||
s = samples + offset;
|
s = samples + offset;
|
||||||
|
|
||||||
// Start with an empty sample
|
// Start with an empty sample
|
||||||
|
@ -556,21 +546,25 @@ static void cochran_parse_samples(struct dive *dive, const unsigned char *log,
|
||||||
// Get NDL and deco information
|
// Get NDL and deco information
|
||||||
switch (seconds % 24) {
|
switch (seconds % 24) {
|
||||||
case 20:
|
case 20:
|
||||||
if (in_deco) {
|
if (offset + 5 < size) {
|
||||||
// Fist stop time
|
if (in_deco) {
|
||||||
//first_deco_time = (s[2] + s[5] * 256 + 1) * 60; // seconds
|
// Fist stop time
|
||||||
ndl = 0;
|
//first_deco_time = (s[2] + s[5] * 256 + 1) * 60; // seconds
|
||||||
} else {
|
ndl = 0;
|
||||||
// NDL
|
} else {
|
||||||
ndl = (s[2] + s[5] * 256 + 1) * 60; // seconds
|
// NDL
|
||||||
deco_time = 0;
|
ndl = (s[2] + s[5] * 256 + 1) * 60; // seconds
|
||||||
|
deco_time = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 22:
|
case 22:
|
||||||
if (in_deco) {
|
if (offset + 5 < size) {
|
||||||
// Total stop time
|
if (in_deco) {
|
||||||
deco_time = (s[2] + s[5] * 256 + 1) * 60; // seconds
|
// Total stop time
|
||||||
ndl = 0;
|
deco_time = (s[2] + s[5] * 256 + 1) * 60; // seconds
|
||||||
|
ndl = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -634,6 +628,13 @@ static void cochran_parse_dive(const unsigned char *decode, unsigned mod,
|
||||||
* scrambled, but there seems to be size differences in the data,
|
* scrambled, but there seems to be size differences in the data,
|
||||||
* so this just descrambles part of it:
|
* so this just descrambles part of it:
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
if (size < 0x4914 + config.logbook_size) {
|
||||||
|
// Analyst calls this a "Corrupt Beginning Summary"
|
||||||
|
free(buf);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Decode log entry (512 bytes + random prefix)
|
// Decode log entry (512 bytes + random prefix)
|
||||||
partial_decode(0x48ff, 0x4914 + config.logbook_size, decode,
|
partial_decode(0x48ff, 0x4914 + config.logbook_size, decode,
|
||||||
0, mod, in, size, buf);
|
0, mod, in, size, buf);
|
||||||
|
|
|
@ -5,8 +5,9 @@
|
||||||
#define CMD_DAY 2
|
#define CMD_DAY 2
|
||||||
#define CMD_MON 5
|
#define CMD_MON 5
|
||||||
#define CMD_YEAR 4
|
#define CMD_YEAR 4
|
||||||
#define CME_START_OFFSET 6 // 4 bytes
|
#define CMD_START_OFFSET 6 // 4 bytes
|
||||||
#define CMD_WATER_CONDUCTIVITY 25 // 1 byte, 0=low, 2=high
|
#define CMD_WATER_CONDUCTIVITY 25 // 1 byte, 0=low, 2=high
|
||||||
|
#define CMD_PREDIVE_OFFSET 30
|
||||||
#define CMD_START_SGC 42 // 2 bytes
|
#define CMD_START_SGC 42 // 2 bytes
|
||||||
#define CMD_START_TEMP 45 // 1 byte, F
|
#define CMD_START_TEMP 45 // 1 byte, F
|
||||||
#define CMD_START_DEPTH 56 // 2 bytes, /4=ft
|
#define CMD_START_DEPTH 56 // 2 bytes, /4=ft
|
||||||
|
@ -30,6 +31,7 @@
|
||||||
#define EMC_YEAR 5
|
#define EMC_YEAR 5
|
||||||
#define EMC_START_OFFSET 6 // 4 bytes
|
#define EMC_START_OFFSET 6 // 4 bytes
|
||||||
#define EMC_WATER_CONDUCTIVITY 24 // 1 byte bits 0:1, 0=low, 2=high
|
#define EMC_WATER_CONDUCTIVITY 24 // 1 byte bits 0:1, 0=low, 2=high
|
||||||
|
#define EMC_PREDIVE_OFFSET 30
|
||||||
#define EMC_START_DEPTH 42 // 2 byte, /256=ft
|
#define EMC_START_DEPTH 42 // 2 byte, /256=ft
|
||||||
#define EMC_START_TEMP 55 // 1 byte, F
|
#define EMC_START_TEMP 55 // 1 byte, F
|
||||||
#define EMC_SIT 84 // 2 bytes, minutes, LE
|
#define EMC_SIT 84 // 2 bytes, minutes, LE
|
||||||
|
|
Loading…
Add table
Reference in a new issue