Add DC_FIELD_STRING support to Shearwater Petrel parser
Just support a few of the most useful values. There are several more we could and should add. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
4377bf7f2d
commit
feb1d9d391
@ -20,6 +20,12 @@
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
#include <libdivecomputer/shearwater_predator.h>
|
||||
#include <libdivecomputer/shearwater_petrel.h>
|
||||
@ -173,6 +179,8 @@ shearwater_predator_parser_get_datetime (dc_parser_t *abstract, dc_datetime_t *d
|
||||
}
|
||||
|
||||
|
||||
#define BUFLEN 16
|
||||
|
||||
static dc_status_t
|
||||
shearwater_predator_parser_cache (shearwater_predator_parser_t *parser)
|
||||
{
|
||||
@ -239,7 +247,9 @@ shearwater_predator_parser_get_field (dc_parser_t *abstract, dc_field_type_t typ
|
||||
|
||||
dc_gasmix_t *gasmix = (dc_gasmix_t *) value;
|
||||
dc_salinity_t *water = (dc_salinity_t *) value;
|
||||
dc_field_string_t *string = (dc_field_string_t *) value;
|
||||
unsigned int density = 0;
|
||||
char buf[BUFLEN];
|
||||
|
||||
if (value) {
|
||||
switch (type) {
|
||||
@ -271,6 +281,16 @@ shearwater_predator_parser_get_field (dc_parser_t *abstract, dc_field_type_t typ
|
||||
case DC_FIELD_ATMOSPHERIC:
|
||||
*((double *) value) = array_uint16_be (data + 47) / 1000.0;
|
||||
break;
|
||||
case DC_FIELD_STRING:
|
||||
switch(flags) {
|
||||
case 0: // Battery
|
||||
string->desc = "Battery at end";
|
||||
snprintf(buf, BUFLEN, "%.1f", data[9] / 10.0);
|
||||
default:
|
||||
return DC_STATUS_UNSUPPORTED;
|
||||
}
|
||||
string->value = strdup(buf);
|
||||
break;
|
||||
default:
|
||||
return DC_STATUS_UNSUPPORTED;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user