From d3de4bf9bd4bc82b324aacfe077aeceba11e0817 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Fri, 30 Nov 2012 07:10:49 +0100 Subject: [PATCH] Update the example application for the new fields. Update the example application to support the new salinity and atmosperic pressure fields. Because the new fields are not supported by all backends, they are only included in the output when available. --- examples/universal.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/examples/universal.c b/examples/universal.c index c0f28ee..34427f9 100644 --- a/examples/universal.c +++ b/examples/universal.c @@ -375,6 +375,36 @@ doparse (FILE *fp, dc_device_t *device, const unsigned char data[], unsigned int gasmix.nitrogen * 100.0); } + // Parse the salinity. + message ("Parsing the salinity.\n"); + dc_salinity_t salinity = {DC_WATER_FRESH, 0.0}; + rc = dc_parser_get_field (parser, DC_FIELD_SALINITY, 0, &salinity); + if (rc != DC_STATUS_SUCCESS && rc != DC_STATUS_UNSUPPORTED) { + WARNING ("Error parsing the salinity."); + dc_parser_destroy (parser); + return rc; + } + + if (rc != DC_STATUS_UNSUPPORTED) { + fprintf (fp, "%.1f\n", + salinity.type, salinity.density); + } + + // Parse the atmospheric pressure. + message ("Parsing the atmospheric pressure.\n"); + double atmospheric = 0.0; + rc = dc_parser_get_field (parser, DC_FIELD_ATMOSPHERIC, 0, &atmospheric); + if (rc != DC_STATUS_SUCCESS && rc != DC_STATUS_UNSUPPORTED) { + WARNING ("Error parsing the atmospheric pressure."); + dc_parser_destroy (parser); + return rc; + } + + if (rc != DC_STATUS_UNSUPPORTED) { + fprintf (fp, "%.5f\n", + atmospheric); + } + // Initialize the sample data. sample_data_t sampledata = {0}; sampledata.nsamples = 0;