Revert "Shearwater: correctly handle the different models"
This reverts commit 8ea8cebb4e6c3d86b9ceb2291caa077dabd2a3f7. Well intended, but as Jef points out it breaks download from older Shearwater dive computers in certain situations. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
fb0d0b269e
commit
8cf5209d31
@ -51,6 +51,7 @@
|
||||
#include "zeagle_n2ition3.h"
|
||||
#include "atomics_cobalt.h"
|
||||
#include "shearwater_petrel.h"
|
||||
#include "shearwater_predator.h"
|
||||
#include "diverite_nitekq.h"
|
||||
#include "citizen_aqualand.h"
|
||||
#include "divesystem_idive.h"
|
||||
@ -149,8 +150,10 @@ dc_parser_new_internal (dc_parser_t **out, dc_context_t *context, dc_family_t fa
|
||||
rc = atomics_cobalt_parser_create (&parser, context);
|
||||
break;
|
||||
case DC_FAMILY_SHEARWATER_PREDATOR:
|
||||
rc = shearwater_predator_parser_create (&parser, context, model, serial);
|
||||
break;
|
||||
case DC_FAMILY_SHEARWATER_PETREL:
|
||||
rc = shearwater_common_parser_create (&parser, context, model, serial);
|
||||
rc = shearwater_petrel_parser_create (&parser, context, model, serial);
|
||||
break;
|
||||
case DC_FAMILY_DIVERITE_NITEKQ:
|
||||
rc = diverite_nitekq_parser_create (&parser, context);
|
||||
|
||||
@ -34,7 +34,7 @@ dc_status_t
|
||||
shearwater_petrel_device_open (dc_device_t **device, dc_context_t *context, const char *name);
|
||||
|
||||
dc_status_t
|
||||
shearwater_common_parser_create (dc_parser_t **out, dc_context_t *context, unsigned int model, unsigned int serial);
|
||||
shearwater_petrel_parser_create (dc_parser_t **parser, dc_context_t *context, unsigned int model, unsigned int serial);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@ -33,6 +33,9 @@ extern "C" {
|
||||
dc_status_t
|
||||
shearwater_predator_device_open (dc_device_t **device, dc_context_t *context, const char *name);
|
||||
|
||||
dc_status_t
|
||||
shearwater_predator_parser_create (dc_parser_t **parser, dc_context_t *context, unsigned int model, unsigned int serial);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
@ -32,7 +32,6 @@
|
||||
|
||||
#include "shearwater_predator.h"
|
||||
#include "shearwater_petrel.h"
|
||||
#include "shearwater_common.h"
|
||||
#include "context-private.h"
|
||||
#include "parser-private.h"
|
||||
#include "array.h"
|
||||
@ -57,11 +56,15 @@
|
||||
#define NGASMIXES 10
|
||||
#define MAXSTRINGS 32
|
||||
|
||||
#define PREDATOR 2
|
||||
#define PETREL 3
|
||||
|
||||
typedef struct shearwater_predator_parser_t shearwater_predator_parser_t;
|
||||
|
||||
struct shearwater_predator_parser_t {
|
||||
dc_parser_t base;
|
||||
unsigned int model;
|
||||
unsigned int petrel;
|
||||
unsigned int samplesize;
|
||||
// Cached fields.
|
||||
unsigned int cached;
|
||||
@ -120,8 +123,8 @@ shearwater_predator_find_gasmix (shearwater_predator_parser_t *parser, unsigned
|
||||
}
|
||||
|
||||
|
||||
dc_status_t
|
||||
shearwater_common_parser_create (dc_parser_t **out, dc_context_t *context, unsigned int model, unsigned int serial)
|
||||
static dc_status_t
|
||||
shearwater_common_parser_create (dc_parser_t **out, dc_context_t *context, unsigned int model, unsigned int serial, unsigned int petrel)
|
||||
{
|
||||
shearwater_predator_parser_t *parser = NULL;
|
||||
const dc_parser_vtable_t *vtable = NULL;
|
||||
@ -130,7 +133,7 @@ shearwater_common_parser_create (dc_parser_t **out, dc_context_t *context, unsig
|
||||
if (out == NULL)
|
||||
return DC_STATUS_INVALIDARGS;
|
||||
|
||||
if (model != PREDATOR) {
|
||||
if (petrel) {
|
||||
vtable = &shearwater_petrel_parser_vtable;
|
||||
samplesize = SZ_SAMPLE_PETREL;
|
||||
} else {
|
||||
@ -147,6 +150,7 @@ shearwater_common_parser_create (dc_parser_t **out, dc_context_t *context, unsig
|
||||
|
||||
// Set the default values.
|
||||
parser->model = model;
|
||||
parser->petrel = petrel;
|
||||
parser->samplesize = samplesize;
|
||||
parser->serial = serial;
|
||||
|
||||
@ -172,6 +176,20 @@ shearwater_common_parser_create (dc_parser_t **out, dc_context_t *context, unsig
|
||||
}
|
||||
|
||||
|
||||
dc_status_t
|
||||
shearwater_predator_parser_create (dc_parser_t **out, dc_context_t *context, unsigned int model, unsigned int serial)
|
||||
{
|
||||
return shearwater_common_parser_create (out, context, model, serial, 0);
|
||||
}
|
||||
|
||||
|
||||
dc_status_t
|
||||
shearwater_petrel_parser_create (dc_parser_t **out, dc_context_t *context, unsigned int model, unsigned int serial)
|
||||
{
|
||||
return shearwater_common_parser_create (out, context, model, serial, 1);
|
||||
}
|
||||
|
||||
|
||||
static dc_status_t
|
||||
shearwater_predator_parser_set_data (dc_parser_t *abstract, const unsigned char *data, unsigned int size)
|
||||
{
|
||||
@ -385,7 +403,7 @@ shearwater_predator_parser_cache (shearwater_predator_parser_t *parser)
|
||||
memset(parser->strings, 0, sizeof(parser->strings));
|
||||
|
||||
// Adjust the footersize for the final block.
|
||||
if (parser->model > PREDATOR || array_uint16_be (data + size - footersize) == 0xFFFD) {
|
||||
if (parser->petrel || array_uint16_be (data + size - footersize) == 0xFFFD) {
|
||||
footersize += SZ_BLOCK;
|
||||
if (size < headersize + footersize) {
|
||||
ERROR (abstract->context, "Invalid data length.");
|
||||
@ -667,7 +685,7 @@ shearwater_predator_parser_samples_foreach (dc_parser_t *abstract, dc_sample_cal
|
||||
}
|
||||
|
||||
// Setpoint
|
||||
if (parser->model > PREDATOR) {
|
||||
if (parser->petrel) {
|
||||
sample.setpoint = data[offset + 18] / 100.0;
|
||||
} else {
|
||||
if (status & SETPOINT_HIGH) {
|
||||
@ -680,7 +698,7 @@ shearwater_predator_parser_samples_foreach (dc_parser_t *abstract, dc_sample_cal
|
||||
}
|
||||
|
||||
// CNS
|
||||
if (parser->model > PREDATOR) {
|
||||
if (parser->petrel) {
|
||||
sample.cns = data[offset + 22] / 100.0;
|
||||
if (callback) callback (DC_SAMPLE_CNS, sample, userdata);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user