Support serial number as DC_FIELD_STRING on atom2 backend
This has been verified with a few of the models, it needs much more testing to make sure this is generally correct. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
ebe6704747
commit
f459155b54
@ -43,7 +43,7 @@ dc_status_t
|
|||||||
oceanic_atom2_device_keepalive (dc_device_t *device);
|
oceanic_atom2_device_keepalive (dc_device_t *device);
|
||||||
|
|
||||||
dc_status_t
|
dc_status_t
|
||||||
oceanic_atom2_parser_create (dc_parser_t **parser, dc_context_t *context, unsigned int model);
|
oceanic_atom2_parser_create (dc_parser_t **parser, dc_context_t *context, unsigned int model, unsigned int serial);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,6 +20,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include <libdivecomputer/oceanic_atom2.h>
|
#include <libdivecomputer/oceanic_atom2.h>
|
||||||
#include <libdivecomputer/units.h>
|
#include <libdivecomputer/units.h>
|
||||||
@ -86,6 +88,7 @@ struct oceanic_atom2_parser_t {
|
|||||||
unsigned int model;
|
unsigned int model;
|
||||||
unsigned int headersize;
|
unsigned int headersize;
|
||||||
unsigned int footersize;
|
unsigned int footersize;
|
||||||
|
unsigned int serial;
|
||||||
// Cached fields.
|
// Cached fields.
|
||||||
unsigned int cached;
|
unsigned int cached;
|
||||||
unsigned int divetime;
|
unsigned int divetime;
|
||||||
@ -109,7 +112,7 @@ static const dc_parser_vtable_t oceanic_atom2_parser_vtable = {
|
|||||||
|
|
||||||
|
|
||||||
dc_status_t
|
dc_status_t
|
||||||
oceanic_atom2_parser_create (dc_parser_t **out, dc_context_t *context, unsigned int model)
|
oceanic_atom2_parser_create (dc_parser_t **out, dc_context_t *context, unsigned int model, unsigned int serial)
|
||||||
{
|
{
|
||||||
if (out == NULL)
|
if (out == NULL)
|
||||||
return DC_STATUS_INVALIDARGS;
|
return DC_STATUS_INVALIDARGS;
|
||||||
@ -151,6 +154,7 @@ oceanic_atom2_parser_create (dc_parser_t **out, dc_context_t *context, unsigned
|
|||||||
parser->headersize = 5 * PAGESIZE;
|
parser->headersize = 5 * PAGESIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
parser->serial = serial;
|
||||||
parser->cached = 0;
|
parser->cached = 0;
|
||||||
parser->divetime = 0;
|
parser->divetime = 0;
|
||||||
parser->maxdepth = 0.0;
|
parser->maxdepth = 0.0;
|
||||||
@ -318,6 +322,7 @@ oceanic_atom2_parser_get_datetime (dc_parser_t *abstract, dc_datetime_t *datetim
|
|||||||
return DC_STATUS_SUCCESS;
|
return DC_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define BUF_LEN 16
|
||||||
|
|
||||||
static dc_status_t
|
static dc_status_t
|
||||||
oceanic_atom2_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsigned int flags, void *value)
|
oceanic_atom2_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsigned int flags, void *value)
|
||||||
@ -366,9 +371,11 @@ oceanic_atom2_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, uns
|
|||||||
|
|
||||||
dc_gasmix_t *gasmix = (dc_gasmix_t *) value;
|
dc_gasmix_t *gasmix = (dc_gasmix_t *) value;
|
||||||
dc_salinity_t *water = (dc_salinity_t *) value;
|
dc_salinity_t *water = (dc_salinity_t *) value;
|
||||||
|
dc_field_string_t *string = (dc_field_string_t *) value;
|
||||||
|
|
||||||
unsigned int oxygen = 0;
|
unsigned int oxygen = 0;
|
||||||
unsigned int helium = 0;
|
unsigned int helium = 0;
|
||||||
|
char buf[BUF_LEN];
|
||||||
|
|
||||||
if (value) {
|
if (value) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
@ -452,6 +459,17 @@ oceanic_atom2_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, uns
|
|||||||
return DC_STATUS_DATAFORMAT;
|
return DC_STATUS_DATAFORMAT;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case DC_FIELD_STRING:
|
||||||
|
switch(flags) {
|
||||||
|
case 0: /* Serial */
|
||||||
|
string->desc = "Serial";
|
||||||
|
snprintf(buf, BUF_LEN, "%06u", parser->serial);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return DC_STATUS_UNSUPPORTED;
|
||||||
|
}
|
||||||
|
string->value = strdup(buf);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return DC_STATUS_UNSUPPORTED;
|
return DC_STATUS_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -98,7 +98,7 @@ dc_parser_new (dc_parser_t **out, dc_device_t *device)
|
|||||||
if (device->devinfo.model == REACTPROWHITE)
|
if (device->devinfo.model == REACTPROWHITE)
|
||||||
rc = oceanic_veo250_parser_create (&parser, context, device->devinfo.model);
|
rc = oceanic_veo250_parser_create (&parser, context, device->devinfo.model);
|
||||||
else
|
else
|
||||||
rc = oceanic_atom2_parser_create (&parser, context, device->devinfo.model);
|
rc = oceanic_atom2_parser_create (&parser, context, device->devinfo.model, device->devinfo.serial);
|
||||||
break;
|
break;
|
||||||
case DC_FAMILY_MARES_NEMO:
|
case DC_FAMILY_MARES_NEMO:
|
||||||
case DC_FAMILY_MARES_PUCK:
|
case DC_FAMILY_MARES_PUCK:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user