Pass the sample struct by reference

Because the sample struct is passed by value, the size of the structure
can't be changed without also changing the function signature and
breaking backwards compatibility. This prevents adding new fields in the
future, to support some new features.

When passing the sample struct by reference using a pointer, the size of
the pointer does always remains the same.
This commit is contained in:
Jef Driesen 2022-07-27 19:37:22 +02:00
parent becb8bd36e
commit 4e24b3a277
40 changed files with 326 additions and 326 deletions

View File

@ -31,7 +31,7 @@
.Ft "typedef void" .Ft "typedef void"
.Fo "(*dc_sample_callback_t)" .Fo "(*dc_sample_callback_t)"
.Fa "dc_sample_type_t type" .Fa "dc_sample_type_t type"
.Fa "dc_sample_value_t value" .Fa "const dc_sample_value_t *value"
.Fa "void *userdata" .Fa "void *userdata"
.Fc .Fc
.Ft dc_status_t .Ft dc_status_t

View File

@ -90,7 +90,7 @@ convert_volume (double value, dctool_units_t units)
} }
static void static void
sample_cb (dc_sample_type_t type, dc_sample_value_t value, void *userdata) sample_cb (dc_sample_type_t type, const dc_sample_value_t *value, void *userdata)
{ {
static const char *events[] = { static const char *events[] = {
"none", "deco", "rbt", "ascent", "ceiling", "workload", "transmitter", "none", "deco", "rbt", "ascent", "ceiling", "workload", "transmitter",
@ -108,8 +108,8 @@ sample_cb (dc_sample_type_t type, dc_sample_value_t value, void *userdata)
switch (type) { switch (type) {
case DC_SAMPLE_TIME: case DC_SAMPLE_TIME:
seconds = value.time / 1000; seconds = value->time / 1000;
milliseconds = value.time % 1000; milliseconds = value->time % 1000;
if (sampledata->nsamples++) if (sampledata->nsamples++)
fprintf (sampledata->ostream, "</sample>\n"); fprintf (sampledata->ostream, "</sample>\n");
fprintf (sampledata->ostream, "<sample>\n"); fprintf (sampledata->ostream, "<sample>\n");
@ -121,63 +121,63 @@ sample_cb (dc_sample_type_t type, dc_sample_value_t value, void *userdata)
break; break;
case DC_SAMPLE_DEPTH: case DC_SAMPLE_DEPTH:
fprintf (sampledata->ostream, " <depth>%.2f</depth>\n", fprintf (sampledata->ostream, " <depth>%.2f</depth>\n",
convert_depth(value.depth, sampledata->units)); convert_depth(value->depth, sampledata->units));
break; break;
case DC_SAMPLE_PRESSURE: case DC_SAMPLE_PRESSURE:
fprintf (sampledata->ostream, " <pressure tank=\"%u\">%.2f</pressure>\n", fprintf (sampledata->ostream, " <pressure tank=\"%u\">%.2f</pressure>\n",
value.pressure.tank, value->pressure.tank,
convert_pressure(value.pressure.value, sampledata->units)); convert_pressure(value->pressure.value, sampledata->units));
break; break;
case DC_SAMPLE_TEMPERATURE: case DC_SAMPLE_TEMPERATURE:
fprintf (sampledata->ostream, " <temperature>%.2f</temperature>\n", fprintf (sampledata->ostream, " <temperature>%.2f</temperature>\n",
convert_temperature(value.temperature, sampledata->units)); convert_temperature(value->temperature, sampledata->units));
break; break;
case DC_SAMPLE_EVENT: case DC_SAMPLE_EVENT:
if (value.event.type != SAMPLE_EVENT_GASCHANGE && value.event.type != SAMPLE_EVENT_GASCHANGE2) { if (value->event.type != SAMPLE_EVENT_GASCHANGE && value->event.type != SAMPLE_EVENT_GASCHANGE2) {
fprintf (sampledata->ostream, " <event type=\"%u\" time=\"%u\" flags=\"%u\" value=\"%u\">%s</event>\n", fprintf (sampledata->ostream, " <event type=\"%u\" time=\"%u\" flags=\"%u\" value=\"%u\">%s</event>\n",
value.event.type, value.event.time, value.event.flags, value.event.value, events[value.event.type]); value->event.type, value->event.time, value->event.flags, value->event.value, events[value->event.type]);
} }
break; break;
case DC_SAMPLE_RBT: case DC_SAMPLE_RBT:
fprintf (sampledata->ostream, " <rbt>%u</rbt>\n", value.rbt); fprintf (sampledata->ostream, " <rbt>%u</rbt>\n", value->rbt);
break; break;
case DC_SAMPLE_HEARTBEAT: case DC_SAMPLE_HEARTBEAT:
fprintf (sampledata->ostream, " <heartbeat>%u</heartbeat>\n", value.heartbeat); fprintf (sampledata->ostream, " <heartbeat>%u</heartbeat>\n", value->heartbeat);
break; break;
case DC_SAMPLE_BEARING: case DC_SAMPLE_BEARING:
fprintf (sampledata->ostream, " <bearing>%u</bearing>\n", value.bearing); fprintf (sampledata->ostream, " <bearing>%u</bearing>\n", value->bearing);
break; break;
case DC_SAMPLE_VENDOR: case DC_SAMPLE_VENDOR:
fprintf (sampledata->ostream, " <vendor type=\"%u\" size=\"%u\">", value.vendor.type, value.vendor.size); fprintf (sampledata->ostream, " <vendor type=\"%u\" size=\"%u\">", value->vendor.type, value->vendor.size);
for (unsigned int i = 0; i < value.vendor.size; ++i) for (unsigned int i = 0; i < value->vendor.size; ++i)
fprintf (sampledata->ostream, "%02X", ((const unsigned char *) value.vendor.data)[i]); fprintf (sampledata->ostream, "%02X", ((const unsigned char *) value->vendor.data)[i]);
fprintf (sampledata->ostream, "</vendor>\n"); fprintf (sampledata->ostream, "</vendor>\n");
break; break;
case DC_SAMPLE_SETPOINT: case DC_SAMPLE_SETPOINT:
fprintf (sampledata->ostream, " <setpoint>%.2f</setpoint>\n", value.setpoint); fprintf (sampledata->ostream, " <setpoint>%.2f</setpoint>\n", value->setpoint);
break; break;
case DC_SAMPLE_PPO2: case DC_SAMPLE_PPO2:
if (value.ppo2.sensor != DC_SENSOR_NONE) { if (value->ppo2.sensor != DC_SENSOR_NONE) {
fprintf (sampledata->ostream, " <ppo2 sensor=\"%u\">%.2f</ppo2>\n", value.ppo2.sensor, value.ppo2.value); fprintf (sampledata->ostream, " <ppo2 sensor=\"%u\">%.2f</ppo2>\n", value->ppo2.sensor, value->ppo2.value);
} else { } else {
fprintf (sampledata->ostream, " <ppo2>%.2f</ppo2>\n", value.ppo2.value); fprintf (sampledata->ostream, " <ppo2>%.2f</ppo2>\n", value->ppo2.value);
} }
break; break;
case DC_SAMPLE_CNS: case DC_SAMPLE_CNS:
fprintf (sampledata->ostream, " <cns>%.1f</cns>\n", value.cns * 100.0); fprintf (sampledata->ostream, " <cns>%.1f</cns>\n", value->cns * 100.0);
break; break;
case DC_SAMPLE_DECO: case DC_SAMPLE_DECO:
fprintf (sampledata->ostream, " <deco time=\"%u\" depth=\"%.2f\">%s</deco>\n", fprintf (sampledata->ostream, " <deco time=\"%u\" depth=\"%.2f\">%s</deco>\n",
value.deco.time, value->deco.time,
convert_depth(value.deco.depth, sampledata->units), convert_depth(value->deco.depth, sampledata->units),
decostop[value.deco.type]); decostop[value->deco.type]);
if (value.deco.tts) { if (value->deco.tts) {
fprintf (sampledata->ostream, " <tts>%u</tts>\n", fprintf (sampledata->ostream, " <tts>%u</tts>\n",
value.deco.tts); value->deco.tts);
} }
break; break;
case DC_SAMPLE_GASMIX: case DC_SAMPLE_GASMIX:
fprintf (sampledata->ostream, " <gasmix>%u</gasmix>\n", value.gasmix); fprintf (sampledata->ostream, " <gasmix>%u</gasmix>\n", value->gasmix);
break; break;
default: default:
break; break;

View File

@ -273,7 +273,7 @@ typedef union dc_sample_value_t {
typedef struct dc_parser_t dc_parser_t; typedef struct dc_parser_t dc_parser_t;
typedef void (*dc_sample_callback_t) (dc_sample_type_t type, dc_sample_value_t value, void *userdata); typedef void (*dc_sample_callback_t) (dc_sample_type_t type, const dc_sample_value_t *value, void *userdata);
dc_status_t dc_status_t
dc_parser_new (dc_parser_t **parser, dc_device_t *device); dc_parser_new (dc_parser_t **parser, dc_device_t *device);

View File

@ -279,18 +279,18 @@ atomics_cobalt_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback
// Time (seconds). // Time (seconds).
time += interval; time += interval;
sample.time = time * 1000; sample.time = time * 1000;
if (callback) callback (DC_SAMPLE_TIME, sample, userdata); if (callback) callback (DC_SAMPLE_TIME, &sample, userdata);
// Depth (1/1000 bar). // Depth (1/1000 bar).
unsigned int depth = array_uint16_le (data + offset + 0); unsigned int depth = array_uint16_le (data + offset + 0);
sample.depth = (signed int)(depth - atmospheric) * (BAR / 1000.0) / parser->hydrostatic; sample.depth = (signed int)(depth - atmospheric) * (BAR / 1000.0) / parser->hydrostatic;
if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); if (callback) callback (DC_SAMPLE_DEPTH, &sample, userdata);
// Pressure (1 psi). // Pressure (1 psi).
unsigned int pressure = array_uint16_le (data + offset + 2); unsigned int pressure = array_uint16_le (data + offset + 2);
sample.pressure.tank = tank; sample.pressure.tank = tank;
sample.pressure.value = pressure * PSI / BAR; sample.pressure.value = pressure * PSI / BAR;
if (callback) callback (DC_SAMPLE_PRESSURE, sample, userdata); if (callback) callback (DC_SAMPLE_PRESSURE, &sample, userdata);
// Current gas mix // Current gas mix
unsigned int gasmix = data[offset + 4]; unsigned int gasmix = data[offset + 4];
@ -306,14 +306,14 @@ atomics_cobalt_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback
return DC_STATUS_DATAFORMAT; return DC_STATUS_DATAFORMAT;
} }
sample.gasmix = idx; sample.gasmix = idx;
if (callback) callback (DC_SAMPLE_GASMIX, sample, userdata); if (callback) callback (DC_SAMPLE_GASMIX, &sample, userdata);
gasmix_previous = gasmix; gasmix_previous = gasmix;
} }
// Temperature (1 °F). // Temperature (1 °F).
unsigned int temperature = data[offset + 8]; unsigned int temperature = data[offset + 8];
sample.temperature = (temperature - 32.0) * (5.0 / 9.0); sample.temperature = (temperature - 32.0) * (5.0 / 9.0);
if (callback) callback (DC_SAMPLE_TEMPERATURE, sample, userdata); if (callback) callback (DC_SAMPLE_TEMPERATURE, &sample, userdata);
// violation status // violation status
sample.event.type = 0; sample.event.type = 0;
@ -323,15 +323,15 @@ atomics_cobalt_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback
unsigned int violation = data[offset + 11]; unsigned int violation = data[offset + 11];
if (violation & 0x01) { if (violation & 0x01) {
sample.event.type = SAMPLE_EVENT_ASCENT; sample.event.type = SAMPLE_EVENT_ASCENT;
if (callback) callback (DC_SAMPLE_EVENT, sample, userdata); if (callback) callback (DC_SAMPLE_EVENT, &sample, userdata);
} }
if (violation & 0x04) { if (violation & 0x04) {
sample.event.type = SAMPLE_EVENT_CEILING; sample.event.type = SAMPLE_EVENT_CEILING;
if (callback) callback (DC_SAMPLE_EVENT, sample, userdata); if (callback) callback (DC_SAMPLE_EVENT, &sample, userdata);
} }
if (violation & 0x08) { if (violation & 0x08) {
sample.event.type = SAMPLE_EVENT_PO2; sample.event.type = SAMPLE_EVENT_PO2;
if (callback) callback (DC_SAMPLE_EVENT, sample, userdata); if (callback) callback (DC_SAMPLE_EVENT, &sample, userdata);
} }
// NDL & deco // NDL & deco
@ -347,7 +347,7 @@ atomics_cobalt_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback
sample.deco.time = ndl; sample.deco.time = ndl;
sample.deco.depth = 0.0; sample.deco.depth = 0.0;
sample.deco.tts = 0; sample.deco.tts = 0;
if (callback) callback (DC_SAMPLE_DECO, sample, userdata); if (callback) callback (DC_SAMPLE_DECO, &sample, userdata);
offset += SZ_SEGMENT; offset += SZ_SEGMENT;
} }

View File

@ -242,14 +242,14 @@ citizen_aqualand_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callba
// Time // Time
time += interval; time += interval;
sample.time = time * 1000; sample.time = time * 1000;
if (callback) callback (DC_SAMPLE_TIME, sample, userdata); if (callback) callback (DC_SAMPLE_TIME, &sample, userdata);
// Depth // Depth
if (metric) if (metric)
sample.depth = depth / 10.0; sample.depth = depth / 10.0;
else else
sample.depth = depth * FEET; sample.depth = depth * FEET;
if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); if (callback) callback (DC_SAMPLE_DEPTH, &sample, userdata);
// Temperature // Temperature
if (time % 300 == 0) { if (time % 300 == 0) {
@ -260,7 +260,7 @@ citizen_aqualand_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callba
sample.temperature = temperature / 10.0; sample.temperature = temperature / 10.0;
else else
sample.temperature = (temperature - 32.0) * (5.0 / 9.0); sample.temperature = (temperature - 32.0) * (5.0 / 9.0);
if (callback) callback (DC_SAMPLE_TEMPERATURE, sample, userdata); if (callback) callback (DC_SAMPLE_TEMPERATURE, &sample, userdata);
} }
} }
} }

View File

@ -315,7 +315,7 @@ cochran_commander_handle_event (cochran_commander_parser_t *parser, unsigned cha
sample.event.time = 0; sample.event.time = 0;
sample.event.value = 0; sample.event.value = 0;
sample.event.flags = event->flag; sample.event.flags = event->flag;
if (callback) callback (DC_SAMPLE_EVENT, sample, userdata); if (callback) callback (DC_SAMPLE_EVENT, &sample, userdata);
} }
} }
@ -580,16 +580,16 @@ cochran_commander_parser_samples_foreach_tm (dc_parser_t *abstract, dc_sample_ca
unsigned int depth = samples[1]; // Half feet unsigned int depth = samples[1]; // Half feet
last_sample_time = sample.time = time * 1000; last_sample_time = sample.time = time * 1000;
if (callback) callback (DC_SAMPLE_TIME, sample, userdata); if (callback) callback (DC_SAMPLE_TIME, &sample, userdata);
sample.depth = (depth / 2.0) * FEET; sample.depth = (depth / 2.0) * FEET;
if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); if (callback) callback (DC_SAMPLE_DEPTH, &sample, userdata);
sample.temperature = (temp / 2.0 - 32.0) / 1.8; sample.temperature = (temp / 2.0 - 32.0) / 1.8;
if (callback) callback (DC_SAMPLE_TEMPERATURE, sample, userdata); if (callback) callback (DC_SAMPLE_TEMPERATURE, &sample, userdata);
sample.gasmix = 0; sample.gasmix = 0;
if (callback) callback(DC_SAMPLE_GASMIX, sample, userdata); if (callback) callback(DC_SAMPLE_GASMIX, &sample, userdata);
while (offset < size) { while (offset < size) {
const unsigned char *s = samples + offset; const unsigned char *s = samples + offset;
@ -598,7 +598,7 @@ cochran_commander_parser_samples_foreach_tm (dc_parser_t *abstract, dc_sample_ca
if (last_sample_time != sample.time) { if (last_sample_time != sample.time) {
// We haven't issued this time yet. // We haven't issued this time yet.
last_sample_time = sample.time; last_sample_time = sample.time;
if (callback) callback (DC_SAMPLE_TIME, sample, userdata); if (callback) callback (DC_SAMPLE_TIME, &sample, userdata);
} }
if (*s & 0x80) { if (*s & 0x80) {
@ -617,7 +617,7 @@ cochran_commander_parser_samples_foreach_tm (dc_parser_t *abstract, dc_sample_ca
sample.deco.time = 60; // We don't know the duration sample.deco.time = 60; // We don't know the duration
sample.deco.depth = deco_ceiling * FEET; sample.deco.depth = deco_ceiling * FEET;
sample.deco.tts = 0; sample.deco.tts = 0;
if (callback) callback(DC_SAMPLE_DECO, sample, userdata); if (callback) callback(DC_SAMPLE_DECO, &sample, userdata);
break; break;
case 0xAD: // Increment ceiling (shallower) case 0xAD: // Increment ceiling (shallower)
deco_ceiling -= 10; // feet deco_ceiling -= 10; // feet
@ -626,7 +626,7 @@ cochran_commander_parser_samples_foreach_tm (dc_parser_t *abstract, dc_sample_ca
sample.deco.depth = deco_ceiling * FEET; sample.deco.depth = deco_ceiling * FEET;
sample.deco.time = 60; // We don't know the duration sample.deco.time = 60; // We don't know the duration
sample.deco.tts = 0; sample.deco.tts = 0;
if (callback) callback(DC_SAMPLE_DECO, sample, userdata); if (callback) callback(DC_SAMPLE_DECO, &sample, userdata);
break; break;
default: default:
cochran_commander_handle_event(parser, s[0], callback, userdata); cochran_commander_handle_event(parser, s[0], callback, userdata);
@ -639,7 +639,7 @@ cochran_commander_parser_samples_foreach_tm (dc_parser_t *abstract, dc_sample_ca
else else
temp += (*s & 0x0f); temp += (*s & 0x0f);
sample.temperature = (temp / 2.0 - 32.0) / 1.8; sample.temperature = (temp / 2.0 - 32.0) / 1.8;
if (callback) callback (DC_SAMPLE_TEMPERATURE, sample, userdata); if (callback) callback (DC_SAMPLE_TEMPERATURE, &sample, userdata);
} }
offset++; offset++;
@ -653,7 +653,7 @@ cochran_commander_parser_samples_foreach_tm (dc_parser_t *abstract, dc_sample_ca
depth += s[0] & 0x3f; depth += s[0] & 0x3f;
sample.depth = (depth / 2.0) * FEET; sample.depth = (depth / 2.0) * FEET;
if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); if (callback) callback (DC_SAMPLE_DEPTH, &sample, userdata);
offset++; offset++;
time += sample_interval; time += sample_interval;
@ -718,16 +718,16 @@ cochran_commander_parser_samples_foreach_emc (dc_parser_t *abstract, dc_sample_c
} }
last_sample_time = sample.time = time * 1000; last_sample_time = sample.time = time * 1000;
if (callback) callback (DC_SAMPLE_TIME, sample, userdata); if (callback) callback (DC_SAMPLE_TIME, &sample, userdata);
sample.depth = start_depth * FEET; sample.depth = start_depth * FEET;
if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); if (callback) callback (DC_SAMPLE_DEPTH, &sample, userdata);
sample.temperature = (data[layout->start_temp] - 32.0) / 1.8; sample.temperature = (data[layout->start_temp] - 32.0) / 1.8;
if (callback) callback (DC_SAMPLE_TEMPERATURE, sample, userdata); if (callback) callback (DC_SAMPLE_TEMPERATURE, &sample, userdata);
sample.gasmix = 0; sample.gasmix = 0;
if (callback) callback(DC_SAMPLE_GASMIX, sample, userdata); if (callback) callback(DC_SAMPLE_GASMIX, &sample, userdata);
unsigned int last_gasmix = sample.gasmix; unsigned int last_gasmix = sample.gasmix;
while (offset < size) { while (offset < size) {
@ -737,7 +737,7 @@ cochran_commander_parser_samples_foreach_emc (dc_parser_t *abstract, dc_sample_c
if (last_sample_time != sample.time) { if (last_sample_time != sample.time) {
// We haven't issued this time yet. // We haven't issued this time yet.
last_sample_time = sample.time; last_sample_time = sample.time;
if (callback) callback (DC_SAMPLE_TIME, sample, userdata); if (callback) callback (DC_SAMPLE_TIME, &sample, userdata);
} }
// If corrupt_dive end before offset // If corrupt_dive end before offset
@ -778,7 +778,7 @@ cochran_commander_parser_samples_foreach_emc (dc_parser_t *abstract, dc_sample_c
sample.deco.time = (array_uint16_le(s + 3) + 1) * 60; sample.deco.time = (array_uint16_le(s + 3) + 1) * 60;
sample.deco.depth = deco_ceiling * FEET; sample.deco.depth = deco_ceiling * FEET;
sample.deco.tts = 0; sample.deco.tts = 0;
if (callback) callback(DC_SAMPLE_DECO, sample, userdata); if (callback) callback(DC_SAMPLE_DECO, &sample, userdata);
break; break;
case 0xAD: // Increment ceiling (shallower) case 0xAD: // Increment ceiling (shallower)
deco_ceiling -= 10; // feet deco_ceiling -= 10; // feet
@ -787,7 +787,7 @@ cochran_commander_parser_samples_foreach_emc (dc_parser_t *abstract, dc_sample_c
sample.deco.depth = deco_ceiling * FEET; sample.deco.depth = deco_ceiling * FEET;
sample.deco.time = (array_uint16_le(s + 3) + 1) * 60; sample.deco.time = (array_uint16_le(s + 3) + 1) * 60;
sample.deco.tts = 0; sample.deco.tts = 0;
if (callback) callback(DC_SAMPLE_DECO, sample, userdata); if (callback) callback(DC_SAMPLE_DECO, &sample, userdata);
break; break;
case 0xC0: // Switched to FO2 21% mode (surface) case 0xC0: // Switched to FO2 21% mode (surface)
// Event seen upon surfacing // Event seen upon surfacing
@ -796,14 +796,14 @@ cochran_commander_parser_samples_foreach_emc (dc_parser_t *abstract, dc_sample_c
case 0xEF: // Switched to gas blend 2 case 0xEF: // Switched to gas blend 2
if (last_gasmix != 1) { if (last_gasmix != 1) {
sample.gasmix = 1; sample.gasmix = 1;
if (callback) callback(DC_SAMPLE_GASMIX, sample, userdata); if (callback) callback(DC_SAMPLE_GASMIX, &sample, userdata);
last_gasmix = sample.gasmix; last_gasmix = sample.gasmix;
} }
break; break;
case 0xF3: // Switched to gas blend 1 case 0xF3: // Switched to gas blend 1
if (last_gasmix != 0) { if (last_gasmix != 0) {
sample.gasmix = 0; sample.gasmix = 0;
if (callback) callback(DC_SAMPLE_GASMIX, sample, userdata); if (callback) callback(DC_SAMPLE_GASMIX, &sample, userdata);
last_gasmix = sample.gasmix; last_gasmix = sample.gasmix;
} }
break; break;
@ -823,7 +823,7 @@ cochran_commander_parser_samples_foreach_emc (dc_parser_t *abstract, dc_sample_c
depth += (s[0] & 0x3f); depth += (s[0] & 0x3f);
sample.depth = (start_depth + depth / 4.0) * FEET; sample.depth = (start_depth + depth / 4.0) * FEET;
if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); if (callback) callback (DC_SAMPLE_DEPTH, &sample, userdata);
// Ascent rate is logged in the 0th sample, temp in the 1st, repeat. // Ascent rate is logged in the 0th sample, temp in the 1st, repeat.
if (time % 2 == 0) { if (time % 2 == 0) {
@ -839,7 +839,7 @@ cochran_commander_parser_samples_foreach_emc (dc_parser_t *abstract, dc_sample_c
double temperature = s[1] / 2.0 + 20.0; double temperature = s[1] / 2.0 + 20.0;
sample.temperature = (temperature - 32.0) / 1.8; sample.temperature = (temperature - 32.0) / 1.8;
if (callback) callback (DC_SAMPLE_TEMPERATURE, sample, userdata); if (callback) callback (DC_SAMPLE_TEMPERATURE, &sample, userdata);
} }
// Cochran EMC models store NDL and deco stop time // Cochran EMC models store NDL and deco stop time
@ -861,7 +861,7 @@ cochran_commander_parser_samples_foreach_emc (dc_parser_t *abstract, dc_sample_c
sample.deco.time = deco_time * 60; sample.deco.time = deco_time * 60;
sample.deco.depth = 0; sample.deco.depth = 0;
sample.deco.tts = 0; sample.deco.tts = 0;
if (callback) callback (DC_SAMPLE_DECO, sample, userdata); if (callback) callback (DC_SAMPLE_DECO, &sample, userdata);
} }
break; break;
case 23: case 23:
@ -872,7 +872,7 @@ cochran_commander_parser_samples_foreach_emc (dc_parser_t *abstract, dc_sample_c
sample.deco.depth = deco_ceiling * FEET; sample.deco.depth = deco_ceiling * FEET;
sample.deco.time = deco_time * 60; sample.deco.time = deco_time * 60;
sample.deco.tts = 0; sample.deco.tts = 0;
if (callback) callback (DC_SAMPLE_DECO, sample, userdata); if (callback) callback (DC_SAMPLE_DECO, &sample, userdata);
} }
break; break;
} }

View File

@ -203,12 +203,12 @@ cressi_edy_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t c
// Time (seconds). // Time (seconds).
time += interval; time += interval;
sample.time = time * 1000; sample.time = time * 1000;
if (callback) callback (DC_SAMPLE_TIME, sample, userdata); if (callback) callback (DC_SAMPLE_TIME, &sample, userdata);
// Depth (1/10 m). // Depth (1/10 m).
unsigned int depth = bcd2dec (data[offset + 0] & 0x0F) * 100 + bcd2dec (data[offset + 1]); unsigned int depth = bcd2dec (data[offset + 0] & 0x0F) * 100 + bcd2dec (data[offset + 1]);
sample.depth = depth / 10.0; sample.depth = depth / 10.0;
if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); if (callback) callback (DC_SAMPLE_DEPTH, &sample, userdata);
// Current gasmix // Current gasmix
if (ngasmixes) { if (ngasmixes) {
@ -221,7 +221,7 @@ cressi_edy_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t c
} }
if (idx != gasmix) { if (idx != gasmix) {
sample.gasmix = idx; sample.gasmix = idx;
if (callback) callback (DC_SAMPLE_GASMIX, sample, userdata); if (callback) callback (DC_SAMPLE_GASMIX, &sample, userdata);
gasmix = idx; gasmix = idx;
} }
} }

View File

@ -331,24 +331,24 @@ cressi_goa_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t c
if (complete) { if (complete) {
// Time (seconds). // Time (seconds).
sample.time = time * 1000; sample.time = time * 1000;
if (callback) callback (DC_SAMPLE_TIME, sample, userdata); if (callback) callback (DC_SAMPLE_TIME, &sample, userdata);
// Temperature (1/10 °C). // Temperature (1/10 °C).
if (have_temperature) { if (have_temperature) {
sample.temperature = temperature / 10.0; sample.temperature = temperature / 10.0;
if (callback) callback (DC_SAMPLE_TEMPERATURE, sample, userdata); if (callback) callback (DC_SAMPLE_TEMPERATURE, &sample, userdata);
have_temperature = 0; have_temperature = 0;
} }
// Depth (1/10 m). // Depth (1/10 m).
sample.depth = depth / 10.0; sample.depth = depth / 10.0;
if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); if (callback) callback (DC_SAMPLE_DEPTH, &sample, userdata);
// Gas change // Gas change
if (divemode == SCUBA || divemode == NITROX) { if (divemode == SCUBA || divemode == NITROX) {
if (gasmix != gasmix_previous) { if (gasmix != gasmix_previous) {
sample.gasmix = gasmix; sample.gasmix = gasmix;
if (callback) callback (DC_SAMPLE_GASMIX, sample, userdata); if (callback) callback (DC_SAMPLE_GASMIX, &sample, userdata);
gasmix_previous = gasmix; gasmix_previous = gasmix;
} }
} }

View File

@ -198,11 +198,11 @@ cressi_leonardo_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callbac
// Time (seconds). // Time (seconds).
time += surftime; time += surftime;
sample.time = time * 1000; sample.time = time * 1000;
if (callback) callback (DC_SAMPLE_TIME, sample, userdata); if (callback) callback (DC_SAMPLE_TIME, &sample, userdata);
// Depth (1/10 m). // Depth (1/10 m).
sample.depth = 0.0; sample.depth = 0.0;
if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); if (callback) callback (DC_SAMPLE_DEPTH, &sample, userdata);
offset += 4; offset += 4;
} else { } else {
@ -213,16 +213,16 @@ cressi_leonardo_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callbac
// Time (seconds). // Time (seconds).
time += interval; time += interval;
sample.time = time * 1000; sample.time = time * 1000;
if (callback) callback (DC_SAMPLE_TIME, sample, userdata); if (callback) callback (DC_SAMPLE_TIME, &sample, userdata);
// Depth (1/10 m). // Depth (1/10 m).
sample.depth = depth / 10.0; sample.depth = depth / 10.0;
if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); if (callback) callback (DC_SAMPLE_DEPTH, &sample, userdata);
// Gas change. // Gas change.
if (gasmix != gasmix_previous) { if (gasmix != gasmix_previous) {
sample.gasmix = gasmix; sample.gasmix = gasmix;
if (callback) callback (DC_SAMPLE_GASMIX, sample, userdata); if (callback) callback (DC_SAMPLE_GASMIX, &sample, userdata);
gasmix_previous = gasmix; gasmix_previous = gasmix;
} }
@ -232,7 +232,7 @@ cressi_leonardo_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callbac
sample.event.time = 0; sample.event.time = 0;
sample.event.flags = 0; sample.event.flags = 0;
sample.event.value = ascent; sample.event.value = ascent;
if (callback) callback (DC_SAMPLE_EVENT, sample, userdata); if (callback) callback (DC_SAMPLE_EVENT, &sample, userdata);
} }
offset += 2; offset += 2;

View File

@ -206,13 +206,13 @@ deepblu_cosmiq_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback
time += interval; time += interval;
sample.time = time * 1000; sample.time = time * 1000;
if (callback) callback (DC_SAMPLE_TIME, sample, userdata); if (callback) callback (DC_SAMPLE_TIME, &sample, userdata);
sample.depth = (signed int) (depth - atmospheric) * (BAR / 1000.0) / parser->hydrostatic; sample.depth = (signed int) (depth - atmospheric) * (BAR / 1000.0) / parser->hydrostatic;
if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); if (callback) callback (DC_SAMPLE_DEPTH, &sample, userdata);
sample.temperature = temperature / 10.0; sample.temperature = temperature / 10.0;
if (callback) callback (DC_SAMPLE_TEMPERATURE, sample, userdata); if (callback) callback (DC_SAMPLE_TEMPERATURE, &sample, userdata);
} }
return DC_STATUS_SUCCESS; return DC_STATUS_SUCCESS;

View File

@ -425,10 +425,10 @@ deepsix_excursion_parser_samples_foreach_v0 (dc_parser_t *abstract, dc_sample_ca
if (type == TEMPERATURE) { if (type == TEMPERATURE) {
time += interval; time += interval;
sample.time = time * 1000; sample.time = time * 1000;
if (callback) callback(DC_SAMPLE_TIME, sample, userdata); if (callback) callback(DC_SAMPLE_TIME, &sample, userdata);
sample.depth = pressure_to_depth(depth, atmospheric, DENSITY); sample.depth = pressure_to_depth(depth, atmospheric, DENSITY);
if (callback) callback(DC_SAMPLE_DEPTH, sample, userdata); if (callback) callback(DC_SAMPLE_DEPTH, &sample, userdata);
} }
if (type == ALARM) { if (type == ALARM) {
@ -441,11 +441,11 @@ deepsix_excursion_parser_samples_foreach_v0 (dc_parser_t *abstract, dc_sample_ca
length = 8; length = 8;
} else if (temperature >= 10) { } else if (temperature >= 10) {
sample.temperature = temperature / 10.0; sample.temperature = temperature / 10.0;
if (callback) callback(DC_SAMPLE_TEMPERATURE, sample, userdata); if (callback) callback(DC_SAMPLE_TEMPERATURE, &sample, userdata);
} }
} else { } else {
sample.temperature = temperature / 10.0; sample.temperature = temperature / 10.0;
if (callback) callback(DC_SAMPLE_TEMPERATURE, sample, userdata); if (callback) callback(DC_SAMPLE_TEMPERATURE, &sample, userdata);
} }
} else if (type == DECO) { } else if (type == DECO) {
unsigned int deco = array_uint16_le(data + offset + 4); unsigned int deco = array_uint16_le(data + offset + 4);
@ -455,7 +455,7 @@ deepsix_excursion_parser_samples_foreach_v0 (dc_parser_t *abstract, dc_sample_ca
} else if (type == CNS) { } else if (type == CNS) {
unsigned int cns = array_uint16_le(data + offset + 4); unsigned int cns = array_uint16_le(data + offset + 4);
sample.cns = cns / 100.0; sample.cns = cns / 100.0;
if (callback) callback(DC_SAMPLE_CNS, sample, userdata); if (callback) callback(DC_SAMPLE_CNS, &sample, userdata);
} }
offset += length; offset += length;
@ -593,11 +593,11 @@ deepsix_excursion_parser_samples_foreach_v1 (dc_parser_t *abstract, dc_sample_ca
// Time (seconds). // Time (seconds).
time += samplerate; time += samplerate;
sample.time = time * 1000; sample.time = time * 1000;
if (callback) callback (DC_SAMPLE_TIME, sample, userdata); if (callback) callback (DC_SAMPLE_TIME, &sample, userdata);
unsigned int depth = array_uint16_le (data + offset); unsigned int depth = array_uint16_le (data + offset);
sample.depth = pressure_to_depth(depth, atmospheric, density); sample.depth = pressure_to_depth(depth, atmospheric, density);
if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); if (callback) callback (DC_SAMPLE_DEPTH, &sample, userdata);
offset += 2; offset += 2;
// event info // event info
@ -665,7 +665,7 @@ deepsix_excursion_parser_samples_foreach_v1 (dc_parser_t *abstract, dc_sample_ca
break; break;
} }
if (sample.event.type != SAMPLE_EVENT_NONE) { if (sample.event.type != SAMPLE_EVENT_NONE) {
if (callback) callback (DC_SAMPLE_EVENT, sample, userdata); if (callback) callback (DC_SAMPLE_EVENT, &sample, userdata);
} }
} }
break; break;
@ -687,7 +687,7 @@ deepsix_excursion_parser_samples_foreach_v1 (dc_parser_t *abstract, dc_sample_ca
} }
sample.gasmix = mix_idx; sample.gasmix = mix_idx;
if (callback) callback(DC_SAMPLE_GASMIX, sample, userdata); if (callback) callback(DC_SAMPLE_GASMIX, &sample, userdata);
break; break;
case EVENT_SAMPLES_MISSED: case EVENT_SAMPLES_MISSED:
count = array_uint16_le(data + offset + event_offset); count = array_uint16_le(data + offset + event_offset);
@ -728,12 +728,12 @@ deepsix_excursion_parser_samples_foreach_v1 (dc_parser_t *abstract, dc_sample_ca
case SAMPLE_TEMPERATURE: case SAMPLE_TEMPERATURE:
value = array_uint16_le(data + offset); value = array_uint16_le(data + offset);
sample.temperature = value / 10.0; sample.temperature = value / 10.0;
if (callback) callback(DC_SAMPLE_TEMPERATURE, sample, userdata); if (callback) callback(DC_SAMPLE_TEMPERATURE, &sample, userdata);
break; break;
case SAMPLE_CNS: case SAMPLE_CNS:
value = array_uint16_le(data + offset); value = array_uint16_le(data + offset);
sample.cns = value / 10000.0; sample.cns = value / 10000.0;
if (callback) callback (DC_SAMPLE_CNS, sample, userdata); if (callback) callback (DC_SAMPLE_CNS, &sample, userdata);
break; break;
case SAMPLE_DECO_NDL: case SAMPLE_DECO_NDL:
deco_flags = data[offset]; deco_flags = data[offset];
@ -753,7 +753,7 @@ deepsix_excursion_parser_samples_foreach_v1 (dc_parser_t *abstract, dc_sample_ca
sample.deco.depth = 0; sample.deco.depth = 0;
sample.deco.time = deco_ndl_tts; sample.deco.time = deco_ndl_tts;
} }
if (callback) callback (DC_SAMPLE_DECO, sample, userdata); if (callback) callback (DC_SAMPLE_DECO, &sample, userdata);
break; break;
default: default:
break; break;

View File

@ -266,12 +266,12 @@ diverite_nitekq_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callbac
// Time (seconds). // Time (seconds).
time += interval; time += interval;
sample.time = time * 1000; sample.time = time * 1000;
if (callback) callback (DC_SAMPLE_TIME, sample, userdata); if (callback) callback (DC_SAMPLE_TIME, &sample, userdata);
// Gas change // Gas change
if (gasmix != gasmix_previous) { if (gasmix != gasmix_previous) {
sample.gasmix = gasmix; sample.gasmix = gasmix;
if (callback) callback (DC_SAMPLE_GASMIX, sample, userdata); if (callback) callback (DC_SAMPLE_GASMIX, &sample, userdata);
gasmix_previous = gasmix; gasmix_previous = gasmix;
} }
@ -283,7 +283,7 @@ diverite_nitekq_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callbac
sample.depth = depth / 10.0; sample.depth = depth / 10.0;
else else
sample.depth = depth * FEET / 10.0; sample.depth = depth * FEET / 10.0;
if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); if (callback) callback (DC_SAMPLE_DEPTH, &sample, userdata);
offset += 2; offset += 2;
if (type == 3) { if (type == 3) {
@ -296,7 +296,7 @@ diverite_nitekq_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callbac
unsigned int ppo2 = data[offset]; unsigned int ppo2 = data[offset];
sample.ppo2.sensor = DC_SENSOR_NONE; sample.ppo2.sensor = DC_SENSOR_NONE;
sample.ppo2.value = ppo2 / 100.0; sample.ppo2.value = ppo2 / 100.0;
if (callback) callback (DC_SAMPLE_PPO2, sample, userdata); if (callback) callback (DC_SAMPLE_PPO2, &sample, userdata);
offset++; offset++;
} }
} else { } else {

View File

@ -933,14 +933,14 @@ divesoft_freedom_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callba
} }
time = timestamp; time = timestamp;
sample.time = time * 1000; sample.time = time * 1000;
if (callback) callback(DC_SAMPLE_TIME, sample, userdata); if (callback) callback(DC_SAMPLE_TIME, &sample, userdata);
} }
// Initial diluent. // Initial diluent.
if (!initial) { if (!initial) {
if (parser->diluent != UNDEFINED) { if (parser->diluent != UNDEFINED) {
sample.gasmix = parser->diluent; sample.gasmix = parser->diluent;
if (callback) callback(DC_SAMPLE_GASMIX, sample, userdata); if (callback) callback(DC_SAMPLE_GASMIX, &sample, userdata);
} }
initial = 1; initial = 1;
} }
@ -951,19 +951,19 @@ divesoft_freedom_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callba
unsigned int ppo2 = array_uint16_le (data + offset + 6); unsigned int ppo2 = array_uint16_le (data + offset + 6);
sample.depth = depth / 100.0; sample.depth = depth / 100.0;
if (callback) callback(DC_SAMPLE_DEPTH, sample, userdata); if (callback) callback(DC_SAMPLE_DEPTH, &sample, userdata);
if (ppo2) { if (ppo2) {
sample.ppo2.sensor = DC_SENSOR_NONE; sample.ppo2.sensor = DC_SENSOR_NONE;
sample.ppo2.value = ppo2 * 10.0 / BAR; sample.ppo2.value = ppo2 * 10.0 / BAR;
if (callback) callback(DC_SAMPLE_PPO2, sample, userdata); if (callback) callback(DC_SAMPLE_PPO2, &sample, userdata);
} }
if (id == POINT_2) { if (id == POINT_2) {
unsigned int orientation = array_uint32_le (data + offset + 8); unsigned int orientation = array_uint32_le (data + offset + 8);
unsigned int heading = orientation & 0x1FF; unsigned int heading = orientation & 0x1FF;
sample.bearing = heading; sample.bearing = heading;
if (callback) callback (DC_SAMPLE_BEARING, sample, userdata); if (callback) callback (DC_SAMPLE_BEARING, &sample, userdata);
} else if (id == POINT_1 || id == POINT_1_OLD) { } else if (id == POINT_1 || id == POINT_1_OLD) {
unsigned int misc = array_uint32_le (data + offset + 8); unsigned int misc = array_uint32_le (data + offset + 8);
unsigned int ceiling = array_uint16_le (data + offset + 12); unsigned int ceiling = array_uint16_le (data + offset + 12);
@ -974,7 +974,7 @@ divesoft_freedom_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callba
// Temperature // Temperature
sample.temperature = (signed int) signextend (temp, 10) / 10.0; sample.temperature = (signed int) signextend (temp, 10) / 10.0;
if (callback) callback(DC_SAMPLE_TEMPERATURE, sample, userdata); if (callback) callback(DC_SAMPLE_TEMPERATURE, &sample, userdata);
// Deco / NDL // Deco / NDL
if (ceiling) { if (ceiling) {
@ -987,12 +987,12 @@ divesoft_freedom_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callba
sample.deco.depth = 0.0; sample.deco.depth = 0.0;
} }
sample.deco.tts = tts * 60; sample.deco.tts = tts * 60;
if (callback) callback(DC_SAMPLE_DECO, sample, userdata); if (callback) callback(DC_SAMPLE_DECO, &sample, userdata);
// Setpoint // Setpoint
if (setpoint) { if (setpoint) {
sample.setpoint = setpoint / 100.0; sample.setpoint = setpoint / 100.0;
if (callback) callback(DC_SAMPLE_SETPOINT, sample, userdata); if (callback) callback(DC_SAMPLE_SETPOINT, &sample, userdata);
} }
} }
} else if ((type >= LREC_MANIPULATION && type <= LREC_ACTIVITY) || type == LREC_INFO) { } else if ((type >= LREC_MANIPULATION && type <= LREC_ACTIVITY) || type == LREC_INFO) {
@ -1004,7 +1004,7 @@ divesoft_freedom_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callba
sample.event.time = 0; sample.event.time = 0;
sample.event.flags = 0; sample.event.flags = 0;
sample.event.value = 0; sample.event.value = 0;
if (callback) callback(DC_SAMPLE_EVENT, sample, userdata); if (callback) callback(DC_SAMPLE_EVENT, &sample, userdata);
} else if (event == EVENT_MIX_CHANGED || event == EVENT_DILUENT || event == EVENT_CHANGE_MODE) { } else if (event == EVENT_MIX_CHANGED || event == EVENT_DILUENT || event == EVENT_CHANGE_MODE) {
unsigned int o2 = data[offset + 6]; unsigned int o2 = data[offset + 6];
unsigned int he = data[offset + 7]; unsigned int he = data[offset + 7];
@ -1024,13 +1024,13 @@ divesoft_freedom_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callba
return DC_STATUS_DATAFORMAT; return DC_STATUS_DATAFORMAT;
} }
sample.gasmix = idx; sample.gasmix = idx;
if (callback) callback(DC_SAMPLE_GASMIX, sample, userdata); if (callback) callback(DC_SAMPLE_GASMIX, &sample, userdata);
} else if (event == EVENT_CNS) { } else if (event == EVENT_CNS) {
sample.cns = array_uint16_le (data + offset + 6) / 100.0; sample.cns = array_uint16_le (data + offset + 6) / 100.0;
if (callback) callback(DC_SAMPLE_CNS, sample, userdata); if (callback) callback(DC_SAMPLE_CNS, &sample, userdata);
} else if (event == EVENT_SETPOINT_MANUAL || event == EVENT_SETPOINT_AUTO) { } else if (event == EVENT_SETPOINT_MANUAL || event == EVENT_SETPOINT_AUTO) {
sample.setpoint = data[6] / 100.0; sample.setpoint = data[6] / 100.0;
if (callback) callback(DC_SAMPLE_SETPOINT, sample, userdata); if (callback) callback(DC_SAMPLE_SETPOINT, &sample, userdata);
} }
} else if (type == LREC_MEASURE) { } else if (type == LREC_MEASURE) {
// Measurement record. // Measurement record.
@ -1048,7 +1048,7 @@ divesoft_freedom_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callba
sample.pressure.tank = idx; sample.pressure.tank = idx;
sample.pressure.value = pressure * 2.0; sample.pressure.value = pressure * 2.0;
if (callback) callback(DC_SAMPLE_PRESSURE, sample, userdata); if (callback) callback(DC_SAMPLE_PRESSURE, &sample, userdata);
} }
} else if (id == MEASURE_ID_OXYGEN) { } else if (id == MEASURE_ID_OXYGEN) {
for (unsigned int i = 0; i < NSENSORS; ++i) { for (unsigned int i = 0; i < NSENSORS; ++i) {
@ -1057,7 +1057,7 @@ divesoft_freedom_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callba
continue; continue;
sample.ppo2.sensor = i; sample.ppo2.sensor = i;
sample.ppo2.value = ppo2 * 10.0 / BAR; sample.ppo2.value = ppo2 * 10.0 / BAR;
if (callback) callback(DC_SAMPLE_PPO2, sample, userdata); if (callback) callback(DC_SAMPLE_PPO2, &sample, userdata);
} }
} else if (id == MEASURE_ID_OXYGEN_MV) { } else if (id == MEASURE_ID_OXYGEN_MV) {
for (unsigned int i = 0; i < NSENSORS; ++i) { for (unsigned int i = 0; i < NSENSORS; ++i) {
@ -1068,7 +1068,7 @@ divesoft_freedom_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callba
continue; continue;
sample.ppo2.sensor = i; sample.ppo2.sensor = i;
sample.ppo2.value = value / 100.0 * parser->calibration[i] / BAR; sample.ppo2.value = value / 100.0 * parser->calibration[i] / BAR;
if (callback) callback(DC_SAMPLE_PPO2, sample, userdata); if (callback) callback(DC_SAMPLE_PPO2, &sample, userdata);
} }
} }
} else if (type == LREC_STATE) { } else if (type == LREC_STATE) {

View File

@ -477,19 +477,19 @@ divesystem_idive_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callba
} }
time = timestamp; time = timestamp;
sample.time = timestamp * 1000; sample.time = timestamp * 1000;
if (callback) callback (DC_SAMPLE_TIME, sample, userdata); if (callback) callback (DC_SAMPLE_TIME, &sample, userdata);
// Depth (1/10 m). // Depth (1/10 m).
unsigned int depth = array_uint16_le (data + offset + 6); unsigned int depth = array_uint16_le (data + offset + 6);
if (maxdepth < depth) if (maxdepth < depth)
maxdepth = depth; maxdepth = depth;
sample.depth = depth / 10.0; sample.depth = depth / 10.0;
if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); if (callback) callback (DC_SAMPLE_DEPTH, &sample, userdata);
// Temperature (Celsius). // Temperature (Celsius).
signed int temperature = (signed short) array_uint16_le (data + offset + 8); signed int temperature = (signed short) array_uint16_le (data + offset + 8);
sample.temperature = temperature / 10.0; sample.temperature = temperature / 10.0;
if (callback) callback (DC_SAMPLE_TEMPERATURE, sample, userdata); if (callback) callback (DC_SAMPLE_TEMPERATURE, &sample, userdata);
// Dive mode // Dive mode
unsigned int mode = data[offset + 18]; unsigned int mode = data[offset + 18];
@ -523,7 +523,7 @@ divesystem_idive_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callba
if (mode == SCR || mode == CCR) { if (mode == SCR || mode == CCR) {
unsigned int setpoint = array_uint16_le (data + offset + 19); unsigned int setpoint = array_uint16_le (data + offset + 19);
sample.setpoint = setpoint / 1000.0; sample.setpoint = setpoint / 1000.0;
if (callback) callback (DC_SAMPLE_SETPOINT, sample, userdata); if (callback) callback (DC_SAMPLE_SETPOINT, &sample, userdata);
} }
// Gaschange. // Gaschange.
@ -550,7 +550,7 @@ divesystem_idive_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callba
} }
sample.gasmix = i; sample.gasmix = i;
if (callback) callback (DC_SAMPLE_GASMIX, sample, userdata); if (callback) callback (DC_SAMPLE_GASMIX, &sample, userdata);
o2_previous = o2; o2_previous = o2;
he_previous = he; he_previous = he;
} }
@ -576,12 +576,12 @@ divesystem_idive_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callba
sample.deco.time = tts; sample.deco.time = tts;
sample.deco.tts = 0; sample.deco.tts = 0;
} }
if (callback) callback (DC_SAMPLE_DECO, sample, userdata); if (callback) callback (DC_SAMPLE_DECO, &sample, userdata);
// CNS // CNS
unsigned int cns = array_uint16_le (data + offset + 29); unsigned int cns = array_uint16_le (data + offset + 29);
sample.cns = cns / 100.0; sample.cns = cns / 100.0;
if (callback) callback (DC_SAMPLE_CNS, sample, userdata); if (callback) callback (DC_SAMPLE_CNS, &sample, userdata);
// Tank Pressure // Tank Pressure
if (samplesize == SZ_SAMPLE_IX3M_APOS4) { if (samplesize == SZ_SAMPLE_IX3M_APOS4) {
@ -602,7 +602,7 @@ divesystem_idive_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callba
sample.event.time = 0; sample.event.time = 0;
sample.event.flags = 0; sample.event.flags = 0;
sample.event.value = 0; sample.event.value = 0;
if (callback) callback (DC_SAMPLE_EVENT, sample, userdata); if (callback) callback (DC_SAMPLE_EVENT, &sample, userdata);
} else { } else {
// Get the index of the tank. // Get the index of the tank.
if (id != tank_previous) { if (id != tank_previous) {
@ -632,7 +632,7 @@ divesystem_idive_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callba
if (tank_idx < ntanks) { if (tank_idx < ntanks) {
sample.pressure.tank = tank_idx; sample.pressure.tank = tank_idx;
sample.pressure.value = pressure; sample.pressure.value = pressure;
if (callback) callback (DC_SAMPLE_PRESSURE, sample, userdata); if (callback) callback (DC_SAMPLE_PRESSURE, &sample, userdata);
tank[tank_idx].endpressure = pressure; tank[tank_idx].endpressure = pressure;
} }
} }

View File

@ -836,30 +836,30 @@ hw_ostc_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t call
// Time (seconds). // Time (seconds).
time += samplerate; time += samplerate;
sample.time = time * 1000; sample.time = time * 1000;
if (callback) callback (DC_SAMPLE_TIME, sample, userdata); if (callback) callback (DC_SAMPLE_TIME, &sample, userdata);
// Initial gas mix. // Initial gas mix.
if (time == samplerate && parser->initial != UNDEFINED) { if (time == samplerate && parser->initial != UNDEFINED) {
sample.gasmix = parser->initial; sample.gasmix = parser->initial;
if (callback) callback (DC_SAMPLE_GASMIX, sample, userdata); if (callback) callback (DC_SAMPLE_GASMIX, &sample, userdata);
} }
// Initial setpoint (mbar). // Initial setpoint (mbar).
if (time == samplerate && parser->initial_setpoint != UNDEFINED) { if (time == samplerate && parser->initial_setpoint != UNDEFINED) {
sample.setpoint = parser->initial_setpoint / 100.0; sample.setpoint = parser->initial_setpoint / 100.0;
if (callback) callback (DC_SAMPLE_SETPOINT, sample, userdata); if (callback) callback (DC_SAMPLE_SETPOINT, &sample, userdata);
} }
// Initial CNS (%). // Initial CNS (%).
if (time == samplerate && parser->initial_cns != UNDEFINED) { if (time == samplerate && parser->initial_cns != UNDEFINED) {
sample.cns = parser->initial_cns / 100.0; sample.cns = parser->initial_cns / 100.0;
if (callback) callback (DC_SAMPLE_CNS, sample, userdata); if (callback) callback (DC_SAMPLE_CNS, &sample, userdata);
} }
// Depth (1/100 m). // Depth (1/100 m).
unsigned int depth = array_uint16_le (data + offset); unsigned int depth = array_uint16_le (data + offset);
sample.depth = depth / 100.0; sample.depth = depth / 100.0;
if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); if (callback) callback (DC_SAMPLE_DEPTH, &sample, userdata);
offset += 2; offset += 2;
// Extended sample info. // Extended sample info.
@ -918,7 +918,7 @@ hw_ostc_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t call
break; break;
} }
if (sample.event.type && callback) if (sample.event.type && callback)
callback (DC_SAMPLE_EVENT, sample, userdata); callback (DC_SAMPLE_EVENT, &sample, userdata);
// Manual Gas Set & Change // Manual Gas Set & Change
if (events & 0x10) { if (events & 0x10) {
@ -943,7 +943,7 @@ hw_ostc_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t call
} }
sample.gasmix = idx; sample.gasmix = idx;
if (callback) callback (DC_SAMPLE_GASMIX, sample, userdata); if (callback) callback (DC_SAMPLE_GASMIX, &sample, userdata);
offset += 2; offset += 2;
length -= 2; length -= 2;
} }
@ -965,7 +965,7 @@ hw_ostc_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t call
} }
idx--; /* Convert to a zero based index. */ idx--; /* Convert to a zero based index. */
sample.gasmix = idx; sample.gasmix = idx;
if (callback) callback (DC_SAMPLE_GASMIX, sample, userdata); if (callback) callback (DC_SAMPLE_GASMIX, &sample, userdata);
tank = idx; tank = idx;
offset++; offset++;
length--; length--;
@ -979,7 +979,7 @@ hw_ostc_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t call
return DC_STATUS_DATAFORMAT; return DC_STATUS_DATAFORMAT;
} }
sample.setpoint = data[offset] / 100.0; sample.setpoint = data[offset] / 100.0;
if (callback) callback (DC_SAMPLE_SETPOINT, sample, userdata); if (callback) callback (DC_SAMPLE_SETPOINT, &sample, userdata);
offset++; offset++;
length--; length--;
} }
@ -1008,7 +1008,7 @@ hw_ostc_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t call
} }
sample.gasmix = idx; sample.gasmix = idx;
if (callback) callback (DC_SAMPLE_GASMIX, sample, userdata); if (callback) callback (DC_SAMPLE_GASMIX, &sample, userdata);
offset += 2; offset += 2;
length -= 2; length -= 2;
} }
@ -1040,7 +1040,7 @@ hw_ostc_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t call
case TEMPERATURE: case TEMPERATURE:
value = array_uint16_le (data + offset); value = array_uint16_le (data + offset);
sample.temperature = value / 10.0; sample.temperature = value / 10.0;
if (callback) callback (DC_SAMPLE_TEMPERATURE, sample, userdata); if (callback) callback (DC_SAMPLE_TEMPERATURE, &sample, userdata);
break; break;
case DECO: case DECO:
// Due to a firmware bug, the deco/ndl info is incorrect for // Due to a firmware bug, the deco/ndl info is incorrect for
@ -1056,7 +1056,7 @@ hw_ostc_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t call
} }
sample.deco.time = data[offset + 1] * 60; sample.deco.time = data[offset + 1] * 60;
sample.deco.tts = 0; sample.deco.tts = 0;
if (callback) callback (DC_SAMPLE_DECO, sample, userdata); if (callback) callback (DC_SAMPLE_DECO, &sample, userdata);
break; break;
case PPO2: case PPO2:
for (unsigned int j = 0; j < 3; ++j) { for (unsigned int j = 0; j < 3; ++j) {
@ -1072,7 +1072,7 @@ hw_ostc_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t call
for (unsigned int j = 0; j < 3; ++j) { for (unsigned int j = 0; j < 3; ++j) {
sample.ppo2.sensor = i; sample.ppo2.sensor = i;
sample.ppo2.value = ppo2[j] / 100.0; sample.ppo2.value = ppo2[j] / 100.0;
if (callback) callback (DC_SAMPLE_PPO2, sample, userdata); if (callback) callback (DC_SAMPLE_PPO2, &sample, userdata);
} }
} }
break; break;
@ -1081,7 +1081,7 @@ hw_ostc_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t call
sample.cns = array_uint16_le (data + offset) / 100.0; sample.cns = array_uint16_le (data + offset) / 100.0;
else else
sample.cns = data[offset] / 100.0; sample.cns = data[offset] / 100.0;
if (callback) callback (DC_SAMPLE_CNS, sample, userdata); if (callback) callback (DC_SAMPLE_CNS, &sample, userdata);
break; break;
case TANK: case TANK:
value = array_uint16_le (data + offset); value = array_uint16_le (data + offset);
@ -1094,7 +1094,7 @@ hw_ostc_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t call
(firmware >= OSTC3FW(10,40) && firmware <= OSTC3FW(10,50))) { (firmware >= OSTC3FW(10,40) && firmware <= OSTC3FW(10,50))) {
sample.pressure.value /= 10.0; sample.pressure.value /= 10.0;
} }
if (callback) callback (DC_SAMPLE_PRESSURE, sample, userdata); if (callback) callback (DC_SAMPLE_PRESSURE, &sample, userdata);
} }
break; break;
default: // Not yet used. default: // Not yet used.
@ -1114,7 +1114,7 @@ hw_ostc_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t call
return DC_STATUS_DATAFORMAT; return DC_STATUS_DATAFORMAT;
} }
sample.setpoint = data[offset] / 100.0; sample.setpoint = data[offset] / 100.0;
if (callback) callback (DC_SAMPLE_SETPOINT, sample, userdata); if (callback) callback (DC_SAMPLE_SETPOINT, &sample, userdata);
offset++; offset++;
length--; length--;
} }
@ -1143,7 +1143,7 @@ hw_ostc_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t call
} }
sample.gasmix = idx; sample.gasmix = idx;
if (callback) callback (DC_SAMPLE_GASMIX, sample, userdata); if (callback) callback (DC_SAMPLE_GASMIX, &sample, userdata);
offset += 2; offset += 2;
length -= 2; length -= 2;
} }

View File

@ -548,28 +548,28 @@ liquivision_lynx_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callba
// Time (seconds). // Time (seconds).
time += interval; time += interval;
sample.time = time * 1000; sample.time = time * 1000;
if (callback) callback (DC_SAMPLE_TIME, sample, userdata); if (callback) callback (DC_SAMPLE_TIME, &sample, userdata);
// Depth (1/100 m). // Depth (1/100 m).
sample.depth = value / 100.0; sample.depth = value / 100.0;
if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); if (callback) callback (DC_SAMPLE_DEPTH, &sample, userdata);
// Temperature (1/10 °C). // Temperature (1/10 °C).
int temperature = (signed short) array_uint16_le (data + offset); int temperature = (signed short) array_uint16_le (data + offset);
sample.temperature = temperature / 10.0; sample.temperature = temperature / 10.0;
if (callback) callback (DC_SAMPLE_TEMPERATURE, sample, userdata); if (callback) callback (DC_SAMPLE_TEMPERATURE, &sample, userdata);
// Gas mix // Gas mix
if (have_gasmix) { if (have_gasmix) {
sample.gasmix = gasmix_idx; sample.gasmix = gasmix_idx;
if (callback) callback (DC_SAMPLE_GASMIX, sample, userdata); if (callback) callback (DC_SAMPLE_GASMIX, &sample, userdata);
have_gasmix = 0; have_gasmix = 0;
} }
// Setpoint (1/10 bar). // Setpoint (1/10 bar).
if (have_setpoint) { if (have_setpoint) {
sample.setpoint = setpoint / 10.0; sample.setpoint = setpoint / 10.0;
if (callback) callback (DC_SAMPLE_SETPOINT, sample, userdata); if (callback) callback (DC_SAMPLE_SETPOINT, &sample, userdata);
have_setpoint = 0; have_setpoint = 0;
} }
@ -579,7 +579,7 @@ liquivision_lynx_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callba
if (have_pressure & (1 << i)) { if (have_pressure & (1 << i)) {
sample.pressure.tank = i; sample.pressure.tank = i;
sample.pressure.value = pressure[i] / 100.0; sample.pressure.value = pressure[i] / 100.0;
if (callback) callback (DC_SAMPLE_PRESSURE, sample, userdata); if (callback) callback (DC_SAMPLE_PRESSURE, &sample, userdata);
} }
} }
have_pressure = 0; have_pressure = 0;
@ -596,7 +596,7 @@ liquivision_lynx_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callba
} }
sample.deco.time = 0; sample.deco.time = 0;
sample.deco.tts = 0; sample.deco.tts = 0;
if (callback) callback (DC_SAMPLE_DECO, sample, userdata); if (callback) callback (DC_SAMPLE_DECO, &sample, userdata);
have_deco = 0; have_deco = 0;
} }

View File

@ -245,16 +245,16 @@ mares_darwin_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t
// Surface Time (seconds). // Surface Time (seconds).
time += 20; time += 20;
sample.time = time * 1000; sample.time = time * 1000;
if (callback) callback (DC_SAMPLE_TIME, sample, userdata); if (callback) callback (DC_SAMPLE_TIME, &sample, userdata);
// Depth (1/10 m). // Depth (1/10 m).
sample.depth = depth / 10.0; sample.depth = depth / 10.0;
if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); if (callback) callback (DC_SAMPLE_DEPTH, &sample, userdata);
// Gas change. // Gas change.
if (gasmix != gasmix_previous) { if (gasmix != gasmix_previous) {
sample.gasmix = gasmix; sample.gasmix = gasmix;
if (callback) callback (DC_SAMPLE_GASMIX, sample, userdata); if (callback) callback (DC_SAMPLE_GASMIX, &sample, userdata);
gasmix_previous = gasmix; gasmix_previous = gasmix;
} }
@ -264,7 +264,7 @@ mares_darwin_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t
sample.event.time = 0; sample.event.time = 0;
sample.event.flags = 0; sample.event.flags = 0;
sample.event.value = ascent; sample.event.value = ascent;
if (callback) callback (DC_SAMPLE_EVENT, sample, userdata); if (callback) callback (DC_SAMPLE_EVENT, &sample, userdata);
} }
// Deco violation // Deco violation
@ -273,7 +273,7 @@ mares_darwin_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t
sample.event.time = 0; sample.event.time = 0;
sample.event.flags = 0; sample.event.flags = 0;
sample.event.value = 0; sample.event.value = 0;
if (callback) callback (DC_SAMPLE_EVENT, sample, userdata); if (callback) callback (DC_SAMPLE_EVENT, &sample, userdata);
} }
// Deco stop // Deco stop
@ -285,7 +285,7 @@ mares_darwin_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t
sample.deco.time = 0; sample.deco.time = 0;
sample.deco.depth = 0.0; sample.deco.depth = 0.0;
sample.deco.tts = 0; sample.deco.tts = 0;
if (callback) callback (DC_SAMPLE_DECO, sample, userdata); if (callback) callback (DC_SAMPLE_DECO, &sample, userdata);
if (parser->samplesize == 3) { if (parser->samplesize == 3) {
unsigned int type = (time / 20 + 2) % 3; unsigned int type = (time / 20 + 2) % 3;
@ -294,7 +294,7 @@ mares_darwin_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t
pressure -= abstract->data[offset + 2]; pressure -= abstract->data[offset + 2];
sample.pressure.tank = 0; sample.pressure.tank = 0;
sample.pressure.value = pressure; sample.pressure.value = pressure;
if (callback) callback (DC_SAMPLE_PRESSURE, sample, userdata); if (callback) callback (DC_SAMPLE_PRESSURE, &sample, userdata);
} }
} }

View File

@ -1017,11 +1017,11 @@ mares_iconhd_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t
// Surface Time (seconds). // Surface Time (seconds).
time += surftime * 1000; time += surftime * 1000;
sample.time = time; sample.time = time;
if (callback) callback (DC_SAMPLE_TIME, sample, userdata); if (callback) callback (DC_SAMPLE_TIME, &sample, userdata);
// Surface Depth (0 m). // Surface Depth (0 m).
sample.depth = 0.0; sample.depth = 0.0;
if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); if (callback) callback (DC_SAMPLE_DEPTH, &sample, userdata);
offset += parser->samplesize; offset += parser->samplesize;
nsamples++; nsamples++;
@ -1031,12 +1031,12 @@ mares_iconhd_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t
// Time (seconds). // Time (seconds).
time += parser->interval; time += parser->interval;
sample.time = time; sample.time = time;
if (callback) callback (DC_SAMPLE_TIME, sample, userdata); if (callback) callback (DC_SAMPLE_TIME, &sample, userdata);
// Depth (1/10 m). // Depth (1/10 m).
unsigned int depth = array_uint16_le (data + offset); unsigned int depth = array_uint16_le (data + offset);
sample.depth = depth / 10.0; sample.depth = depth / 10.0;
if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); if (callback) callback (DC_SAMPLE_DEPTH, &sample, userdata);
offset += 2; offset += 2;
} }
@ -1048,20 +1048,20 @@ mares_iconhd_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t
// Surface Time (seconds). // Surface Time (seconds).
time += surftime * 1000; time += surftime * 1000;
sample.time = time; sample.time = time;
if (callback) callback (DC_SAMPLE_TIME, sample, userdata); if (callback) callback (DC_SAMPLE_TIME, &sample, userdata);
// Surface Depth (0 m). // Surface Depth (0 m).
sample.depth = 0.0; sample.depth = 0.0;
if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); if (callback) callback (DC_SAMPLE_DEPTH, &sample, userdata);
// Dive Time (seconds). // Dive Time (seconds).
time += divetime * 1000; time += divetime * 1000;
sample.time = time; sample.time = time;
if (callback) callback (DC_SAMPLE_TIME, sample, userdata); if (callback) callback (DC_SAMPLE_TIME, &sample, userdata);
// Maximum Depth (1/10 m). // Maximum Depth (1/10 m).
sample.depth = maxdepth / 10.0; sample.depth = maxdepth / 10.0;
if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); if (callback) callback (DC_SAMPLE_DEPTH, &sample, userdata);
offset += parser->samplesize; offset += parser->samplesize;
nsamples++; nsamples++;
@ -1119,15 +1119,15 @@ mares_iconhd_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t
// Time (seconds). // Time (seconds).
time += parser->interval; time += parser->interval;
sample.time = time; sample.time = time;
if (callback) callback (DC_SAMPLE_TIME, sample, userdata); if (callback) callback (DC_SAMPLE_TIME, &sample, userdata);
// Depth (1/10 m). // Depth (1/10 m).
sample.depth = depth / 10.0; sample.depth = depth / 10.0;
if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); if (callback) callback (DC_SAMPLE_DEPTH, &sample, userdata);
// Temperature (1/10 °C). // Temperature (1/10 °C).
sample.temperature = temperature / 10.0; sample.temperature = temperature / 10.0;
if (callback) callback (DC_SAMPLE_TEMPERATURE, sample, userdata); if (callback) callback (DC_SAMPLE_TEMPERATURE, &sample, userdata);
// Current gas mix // Current gas mix
if (parser->ngasmixes > 0) { if (parser->ngasmixes > 0) {
@ -1137,7 +1137,7 @@ mares_iconhd_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t
} }
if (gasmix != gasmix_previous) { if (gasmix != gasmix_previous) {
sample.gasmix = gasmix; sample.gasmix = gasmix;
if (callback) callback (DC_SAMPLE_GASMIX, sample, userdata); if (callback) callback (DC_SAMPLE_GASMIX, &sample, userdata);
gasmix_previous = gasmix; gasmix_previous = gasmix;
} }
} }
@ -1148,7 +1148,7 @@ mares_iconhd_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t
sample.event.time = 0; sample.event.time = 0;
sample.event.flags = 0; sample.event.flags = 0;
sample.event.value = bookmark; sample.event.value = bookmark;
if (callback) callback (DC_SAMPLE_EVENT, sample, userdata); if (callback) callback (DC_SAMPLE_EVENT, &sample, userdata);
} }
if (parser->model == GENIUS || parser->model == HORIZON) { if (parser->model == GENIUS || parser->model == HORIZON) {
@ -1162,7 +1162,7 @@ mares_iconhd_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t
} }
sample.deco.time = decotime * 60; sample.deco.time = decotime * 60;
sample.deco.tts = tts; sample.deco.tts = tts;
if (callback) callback (DC_SAMPLE_DECO, sample, userdata); if (callback) callback (DC_SAMPLE_DECO, &sample, userdata);
// Alarms // Alarms
for (unsigned int v = alarms, i = 0; v; v >>= 1, ++i) { for (unsigned int v = alarms, i = 0; v; v >>= 1, ++i) {
@ -1188,7 +1188,7 @@ mares_iconhd_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t
sample.event.time = 0; sample.event.time = 0;
sample.event.flags = 0; sample.event.flags = 0;
sample.event.value = 0; sample.event.value = 0;
if (callback) callback (DC_SAMPLE_EVENT, sample, userdata); if (callback) callback (DC_SAMPLE_EVENT, &sample, userdata);
} }
} }
} }
@ -1209,7 +1209,7 @@ mares_iconhd_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t
if (gasmix < parser->ntanks) { if (gasmix < parser->ntanks) {
sample.pressure.tank = gasmix; sample.pressure.tank = gasmix;
sample.pressure.value = pressure / 100.0; sample.pressure.value = pressure / 100.0;
if (callback) callback (DC_SAMPLE_PRESSURE, sample, userdata); if (callback) callback (DC_SAMPLE_PRESSURE, &sample, userdata);
} else if (pressure != 0) { } else if (pressure != 0) {
WARNING (abstract->context, "Invalid tank with non-zero pressure."); WARNING (abstract->context, "Invalid tank with non-zero pressure.");
} }

View File

@ -385,16 +385,16 @@ mares_nemo_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t c
// Time (seconds). // Time (seconds).
time += 20; time += 20;
sample.time = time * 1000; sample.time = time * 1000;
if (callback) callback (DC_SAMPLE_TIME, sample, userdata); if (callback) callback (DC_SAMPLE_TIME, &sample, userdata);
// Depth (1/10 m). // Depth (1/10 m).
sample.depth = depth / 10.0; sample.depth = depth / 10.0;
if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); if (callback) callback (DC_SAMPLE_DEPTH, &sample, userdata);
// Gas change. // Gas change.
if (gasmix != gasmix_previous) { if (gasmix != gasmix_previous) {
sample.gasmix = gasmix; sample.gasmix = gasmix;
if (callback) callback (DC_SAMPLE_GASMIX, sample, userdata); if (callback) callback (DC_SAMPLE_GASMIX, &sample, userdata);
gasmix_previous = gasmix; gasmix_previous = gasmix;
} }
@ -404,7 +404,7 @@ mares_nemo_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t c
sample.event.time = 0; sample.event.time = 0;
sample.event.flags = 0; sample.event.flags = 0;
sample.event.value = ascent; sample.event.value = ascent;
if (callback) callback (DC_SAMPLE_EVENT, sample, userdata); if (callback) callback (DC_SAMPLE_EVENT, &sample, userdata);
} }
// Deco violation // Deco violation
@ -413,7 +413,7 @@ mares_nemo_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t c
sample.event.time = 0; sample.event.time = 0;
sample.event.flags = 0; sample.event.flags = 0;
sample.event.value = 0; sample.event.value = 0;
if (callback) callback (DC_SAMPLE_EVENT, sample, userdata); if (callback) callback (DC_SAMPLE_EVENT, &sample, userdata);
} }
// Deco stop // Deco stop
@ -425,20 +425,20 @@ mares_nemo_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t c
sample.deco.time = 0; sample.deco.time = 0;
sample.deco.depth = 0.0; sample.deco.depth = 0.0;
sample.deco.tts = 0; sample.deco.tts = 0;
if (callback) callback (DC_SAMPLE_DECO, sample, userdata); if (callback) callback (DC_SAMPLE_DECO, &sample, userdata);
// Pressure (1 bar). // Pressure (1 bar).
if (parser->sample_size == 3) { if (parser->sample_size == 3) {
sample.pressure.tank = 0; sample.pressure.tank = 0;
sample.pressure.value = data[idx + 2]; sample.pressure.value = data[idx + 2];
if (callback) callback (DC_SAMPLE_PRESSURE, sample, userdata); if (callback) callback (DC_SAMPLE_PRESSURE, &sample, userdata);
} else if (parser->sample_size == 5) { } else if (parser->sample_size == 5) {
unsigned int type = (time / 20) % 3; unsigned int type = (time / 20) % 3;
if (type == 0) { if (type == 0) {
pressure -= data[idx + 2] * 100; pressure -= data[idx + 2] * 100;
sample.pressure.tank = 0; sample.pressure.tank = 0;
sample.pressure.value = pressure / 100.0; sample.pressure.value = pressure / 100.0;
if (callback) callback (DC_SAMPLE_PRESSURE, sample, userdata); if (callback) callback (DC_SAMPLE_PRESSURE, &sample, userdata);
} }
} }
} }
@ -463,11 +463,11 @@ mares_nemo_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t c
// Surface Time (seconds). // Surface Time (seconds).
time += surftime; time += surftime;
sample.time = time * 1000; sample.time = time * 1000;
if (callback) callback (DC_SAMPLE_TIME, sample, userdata); if (callback) callback (DC_SAMPLE_TIME, &sample, userdata);
// Surface Depth (0 m). // Surface Depth (0 m).
sample.depth = 0.0; sample.depth = 0.0;
if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); if (callback) callback (DC_SAMPLE_DEPTH, &sample, userdata);
if (profiles) { if (profiles) {
// Get the freedive sample interval for this model. // Get the freedive sample interval for this model.
@ -504,11 +504,11 @@ mares_nemo_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t c
if (time > maxtime) if (time > maxtime)
time = maxtime; // Adjust the last sample. time = maxtime; // Adjust the last sample.
sample.time = time * 1000; sample.time = time * 1000;
if (callback) callback (DC_SAMPLE_TIME, sample, userdata); if (callback) callback (DC_SAMPLE_TIME, &sample, userdata);
// Depth (1/10 m). // Depth (1/10 m).
sample.depth = depth / 10.0; sample.depth = depth / 10.0;
if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); if (callback) callback (DC_SAMPLE_DEPTH, &sample, userdata);
} }
// Verify that the number of samples in the profile data // Verify that the number of samples in the profile data
@ -523,11 +523,11 @@ mares_nemo_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t c
// Dive Time (seconds). // Dive Time (seconds).
time += divetime; time += divetime;
sample.time = time * 1000; sample.time = time * 1000;
if (callback) callback (DC_SAMPLE_TIME, sample, userdata); if (callback) callback (DC_SAMPLE_TIME, &sample, userdata);
// Maximum Depth (1/10 m). // Maximum Depth (1/10 m).
sample.depth = maxdepth / 10.0; sample.depth = maxdepth / 10.0;
if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); if (callback) callback (DC_SAMPLE_DEPTH, &sample, userdata);
} }
} }
} }

View File

@ -271,13 +271,13 @@ mclean_extreme_parser_samples_foreach(dc_parser_t *abstract, dc_sample_callback_
time += interval; time += interval;
sample.time = time * 1000; sample.time = time * 1000;
if (callback) callback(DC_SAMPLE_TIME, sample, userdata); if (callback) callback(DC_SAMPLE_TIME, &sample, userdata);
sample.depth = 0.1 * depth; sample.depth = 0.1 * depth;
if (callback) callback(DC_SAMPLE_DEPTH, sample, userdata); if (callback) callback(DC_SAMPLE_DEPTH, &sample, userdata);
sample.temperature = temperature; sample.temperature = temperature;
if (callback) callback(DC_SAMPLE_TEMPERATURE, sample, userdata); if (callback) callback(DC_SAMPLE_TEMPERATURE, &sample, userdata);
if (gasmix_id != gasmix_previous) { if (gasmix_id != gasmix_previous) {
// Find the gasmix in the list. // Find the gasmix in the list.
@ -299,13 +299,13 @@ mclean_extreme_parser_samples_foreach(dc_parser_t *abstract, dc_sample_callback_
} }
sample.gasmix = idx; sample.gasmix = idx;
if (callback) callback(DC_SAMPLE_GASMIX, sample, userdata); if (callback) callback(DC_SAMPLE_GASMIX, &sample, userdata);
gasmix_previous = gasmix_id; gasmix_previous = gasmix_id;
} }
if (ccr) { if (ccr) {
sample.setpoint = 0.01 * setpoint; sample.setpoint = 0.01 * setpoint;
if (callback) callback(DC_SAMPLE_SETPOINT, sample, userdata); if (callback) callback(DC_SAMPLE_SETPOINT, &sample, userdata);
} }
offset += SZ_SAMPLE; offset += SZ_SAMPLE;

View File

@ -587,7 +587,7 @@ oceanic_atom2_parser_vendor (oceanic_atom2_parser_t *parser, const unsigned char
sample.vendor.type = SAMPLE_VENDOR_OCEANIC_ATOM2; sample.vendor.type = SAMPLE_VENDOR_OCEANIC_ATOM2;
sample.vendor.size = length; sample.vendor.size = length;
sample.vendor.data = data + offset; sample.vendor.data = data + offset;
if (callback) callback (DC_SAMPLE_VENDOR, sample, userdata); if (callback) callback (DC_SAMPLE_VENDOR, &sample, userdata);
offset += length; offset += length;
} }
@ -751,7 +751,7 @@ oceanic_atom2_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_
// Time // Time
time += interval; time += interval;
sample.time = time; sample.time = time;
if (callback) callback (DC_SAMPLE_TIME, sample, userdata); if (callback) callback (DC_SAMPLE_TIME, &sample, userdata);
// Vendor specific data // Vendor specific data
if (i == 0) { if (i == 0) {
@ -763,7 +763,7 @@ oceanic_atom2_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_
// Depth // Depth
sample.depth = 0.0; sample.depth = 0.0;
if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); if (callback) callback (DC_SAMPLE_DEPTH, &sample, userdata);
complete = 1; complete = 1;
} }
@ -788,7 +788,7 @@ oceanic_atom2_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_
time += interval; time += interval;
} }
sample.time = time; sample.time = time;
if (callback) callback (DC_SAMPLE_TIME, sample, userdata); if (callback) callback (DC_SAMPLE_TIME, &sample, userdata);
// Vendor specific data // Vendor specific data
oceanic_atom2_parser_vendor (parser, oceanic_atom2_parser_vendor (parser,
@ -850,7 +850,7 @@ oceanic_atom2_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_
temperature += (data[offset + 7] & 0x0C) >> 2; temperature += (data[offset + 7] & 0x0C) >> 2;
} }
sample.temperature = (temperature - 32.0) * (5.0 / 9.0); sample.temperature = (temperature - 32.0) * (5.0 / 9.0);
if (callback) callback (DC_SAMPLE_TEMPERATURE, sample, userdata); if (callback) callback (DC_SAMPLE_TEMPERATURE, &sample, userdata);
} }
// Tank Pressure (psi) // Tank Pressure (psi)
@ -878,7 +878,7 @@ oceanic_atom2_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_
pressure -= data[offset + 1]; pressure -= data[offset + 1];
sample.pressure.tank = tank; sample.pressure.tank = tank;
sample.pressure.value = pressure * PSI / BAR; sample.pressure.value = pressure * PSI / BAR;
if (callback) callback (DC_SAMPLE_PRESSURE, sample, userdata); if (callback) callback (DC_SAMPLE_PRESSURE, &sample, userdata);
} }
// Depth (1/16 ft) // Depth (1/16 ft)
@ -901,7 +901,7 @@ oceanic_atom2_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_
else else
depth = (data[offset + 2] + (data[offset + 3] << 8)) & 0x0FFF; depth = (data[offset + 2] + (data[offset + 3] << 8)) & 0x0FFF;
sample.depth = depth / 16.0 * FEET; sample.depth = depth / 16.0 * FEET;
if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); if (callback) callback (DC_SAMPLE_DEPTH, &sample, userdata);
// Gas mix // Gas mix
unsigned int have_gasmix = 0; unsigned int have_gasmix = 0;
@ -916,7 +916,7 @@ oceanic_atom2_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_
return DC_STATUS_DATAFORMAT; return DC_STATUS_DATAFORMAT;
} }
sample.gasmix = gasmix - 1; sample.gasmix = gasmix - 1;
if (callback) callback (DC_SAMPLE_GASMIX, sample, userdata); if (callback) callback (DC_SAMPLE_GASMIX, &sample, userdata);
gasmix_previous = gasmix; gasmix_previous = gasmix;
} }
@ -966,7 +966,7 @@ oceanic_atom2_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_
} }
sample.deco.time = decotime * 60; sample.deco.time = decotime * 60;
sample.deco.tts = 0; sample.deco.tts = 0;
if (callback) callback (DC_SAMPLE_DECO, sample, userdata); if (callback) callback (DC_SAMPLE_DECO, &sample, userdata);
} }
unsigned int have_rbt = 0; unsigned int have_rbt = 0;
@ -989,7 +989,7 @@ oceanic_atom2_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_
} }
if (have_rbt) { if (have_rbt) {
sample.rbt = rbt; sample.rbt = rbt;
if (callback) callback (DC_SAMPLE_RBT, sample, userdata); if (callback) callback (DC_SAMPLE_RBT, &sample, userdata);
} }
// Bookmarks // Bookmarks
@ -1004,7 +1004,7 @@ oceanic_atom2_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_
sample.event.time = 0; sample.event.time = 0;
sample.event.flags = 0; sample.event.flags = 0;
sample.event.value = 0; sample.event.value = 0;
if (callback) callback (DC_SAMPLE_EVENT, sample, userdata); if (callback) callback (DC_SAMPLE_EVENT, &sample, userdata);
} }
count++; count++;

View File

@ -232,18 +232,18 @@ oceanic_veo250_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback
// Time. // Time.
time += interval; time += interval;
sample.time = time * 1000; sample.time = time * 1000;
if (callback) callback (DC_SAMPLE_TIME, sample, userdata); if (callback) callback (DC_SAMPLE_TIME, &sample, userdata);
// Vendor specific data // Vendor specific data
sample.vendor.type = SAMPLE_VENDOR_OCEANIC_VEO250; sample.vendor.type = SAMPLE_VENDOR_OCEANIC_VEO250;
sample.vendor.size = PAGESIZE / 2; sample.vendor.size = PAGESIZE / 2;
sample.vendor.data = data + offset; sample.vendor.data = data + offset;
if (callback) callback (DC_SAMPLE_VENDOR, sample, userdata); if (callback) callback (DC_SAMPLE_VENDOR, &sample, userdata);
// Depth (ft) // Depth (ft)
unsigned int depth = data[offset + 2]; unsigned int depth = data[offset + 2];
sample.depth = depth * FEET; sample.depth = depth * FEET;
if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); if (callback) callback (DC_SAMPLE_DEPTH, &sample, userdata);
// Temperature (°F) // Temperature (°F)
unsigned int temperature; unsigned int temperature;
@ -254,7 +254,7 @@ oceanic_veo250_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback
temperature = data[offset + 7]; temperature = data[offset + 7];
} }
sample.temperature = (temperature - 32.0) * (5.0 / 9.0); sample.temperature = (temperature - 32.0) * (5.0 / 9.0);
if (callback) callback (DC_SAMPLE_TEMPERATURE, sample, userdata); if (callback) callback (DC_SAMPLE_TEMPERATURE, &sample, userdata);
// NDL / Deco // NDL / Deco
unsigned int have_deco = 0; unsigned int have_deco = 0;
@ -279,7 +279,7 @@ oceanic_veo250_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback
} }
sample.deco.time = decotime * 60; sample.deco.time = decotime * 60;
sample.deco.tts = 0; sample.deco.tts = 0;
if (callback) callback (DC_SAMPLE_DECO, sample, userdata); if (callback) callback (DC_SAMPLE_DECO, &sample, userdata);
} }
offset += PAGESIZE / 2; offset += PAGESIZE / 2;

View File

@ -334,13 +334,13 @@ oceanic_vtpro_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_
else else
time = timestamp * 60 + (i + 1) * 60.0 / count + 0.5; time = timestamp * 60 + (i + 1) * 60.0 / count + 0.5;
sample.time = time * 1000; sample.time = time * 1000;
if (callback) callback (DC_SAMPLE_TIME, sample, userdata); if (callback) callback (DC_SAMPLE_TIME, &sample, userdata);
// Vendor specific data // Vendor specific data
sample.vendor.type = SAMPLE_VENDOR_OCEANIC_VTPRO; sample.vendor.type = SAMPLE_VENDOR_OCEANIC_VTPRO;
sample.vendor.size = PAGESIZE / 2; sample.vendor.size = PAGESIZE / 2;
sample.vendor.data = data + offset; sample.vendor.data = data + offset;
if (callback) callback (DC_SAMPLE_VENDOR, sample, userdata); if (callback) callback (DC_SAMPLE_VENDOR, &sample, userdata);
// Depth (ft) // Depth (ft)
unsigned int depth = 0; unsigned int depth = 0;
@ -350,7 +350,7 @@ oceanic_vtpro_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_
depth = data[offset + 3]; depth = data[offset + 3];
} }
sample.depth = depth * FEET; sample.depth = depth * FEET;
if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); if (callback) callback (DC_SAMPLE_DEPTH, &sample, userdata);
// Temperature (°F) // Temperature (°F)
unsigned int temperature = 0; unsigned int temperature = 0;
@ -360,7 +360,7 @@ oceanic_vtpro_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_
temperature = data[offset + 6]; temperature = data[offset + 6];
} }
sample.temperature = (temperature - 32.0) * (5.0 / 9.0); sample.temperature = (temperature - 32.0) * (5.0 / 9.0);
if (callback) callback (DC_SAMPLE_TEMPERATURE, sample, userdata); if (callback) callback (DC_SAMPLE_TEMPERATURE, &sample, userdata);
// NDL / Deco // NDL / Deco
if (parser->model != AERIS500AI) { if (parser->model != AERIS500AI) {
@ -375,7 +375,7 @@ oceanic_vtpro_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_
} }
sample.deco.time = decotime * 60; sample.deco.time = decotime * 60;
sample.deco.tts = 0; sample.deco.tts = 0;
if (callback) callback (DC_SAMPLE_DECO, sample, userdata); if (callback) callback (DC_SAMPLE_DECO, &sample, userdata);
} }
offset += PAGESIZE / 2; offset += PAGESIZE / 2;

View File

@ -251,18 +251,18 @@ oceans_s1_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t ca
for (unsigned int i = 0; i < nsamples; ++i) { for (unsigned int i = 0; i < nsamples; ++i) {
time += interval; time += interval;
sample.time = time * 1000; sample.time = time * 1000;
if (callback) callback (DC_SAMPLE_TIME, sample, userdata); if (callback) callback (DC_SAMPLE_TIME, &sample, userdata);
sample.depth = 0; sample.depth = 0;
if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); if (callback) callback (DC_SAMPLE_DEPTH, &sample, userdata);
} }
time += interval; time += interval;
sample.time = time * 1000; sample.time = time * 1000;
if (callback) callback (DC_SAMPLE_TIME, sample, userdata); if (callback) callback (DC_SAMPLE_TIME, &sample, userdata);
sample.depth = depth / 100.0; sample.depth = depth / 100.0;
if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); if (callback) callback (DC_SAMPLE_DEPTH, &sample, userdata);
} else if (strncmp(line, "enddive", 7) == 0) { } else if (strncmp(line, "enddive", 7) == 0) {
if (sscanf(line, "enddive %u,%u", &maxdepth, &divetime) != 2) { if (sscanf(line, "enddive %u,%u", &maxdepth, &divetime) != 2) {
ERROR (parser->base.context, "Failed to parse the line '%s'.", line); ERROR (parser->base.context, "Failed to parse the line '%s'.", line);
@ -282,13 +282,13 @@ oceans_s1_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t ca
time += interval; time += interval;
sample.time = time * 1000; sample.time = time * 1000;
if (callback) callback (DC_SAMPLE_TIME, sample, userdata); if (callback) callback (DC_SAMPLE_TIME, &sample, userdata);
sample.depth = depth / 100.0; sample.depth = depth / 100.0;
if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); if (callback) callback (DC_SAMPLE_DEPTH, &sample, userdata);
sample.temperature = temperature; sample.temperature = temperature;
if (callback) callback (DC_SAMPLE_TEMPERATURE, sample, userdata); if (callback) callback (DC_SAMPLE_TEMPERATURE, &sample, userdata);
if (events & EVENT_DECO_STOP) { if (events & EVENT_DECO_STOP) {
sample.deco.type = DC_DECO_DECOSTOP; sample.deco.type = DC_DECO_DECOSTOP;
@ -300,7 +300,7 @@ oceans_s1_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t ca
sample.deco.depth = 0.0; sample.deco.depth = 0.0;
sample.deco.time = 0; sample.deco.time = 0;
sample.deco.tts = 0; sample.deco.tts = 0;
if (callback) callback (DC_SAMPLE_DECO, sample, userdata); if (callback) callback (DC_SAMPLE_DECO, &sample, userdata);
} }
} }

View File

@ -84,7 +84,7 @@ typedef struct sample_statistics_t {
#define SAMPLE_STATISTICS_INITIALIZER {0, 0.0} #define SAMPLE_STATISTICS_INITIALIZER {0, 0.0}
void void
sample_statistics_cb (dc_sample_type_t type, dc_sample_value_t value, void *userdata); sample_statistics_cb (dc_sample_type_t type, const dc_sample_value_t *value, void *userdata);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -393,17 +393,17 @@ dc_parser_destroy (dc_parser_t *parser)
void void
sample_statistics_cb (dc_sample_type_t type, dc_sample_value_t value, void *userdata) sample_statistics_cb (dc_sample_type_t type, const dc_sample_value_t *value, void *userdata)
{ {
sample_statistics_t *statistics = (sample_statistics_t *) userdata; sample_statistics_t *statistics = (sample_statistics_t *) userdata;
switch (type) { switch (type) {
case DC_SAMPLE_TIME: case DC_SAMPLE_TIME:
statistics->divetime = value.time / 1000; statistics->divetime = value->time / 1000;
break; break;
case DC_SAMPLE_DEPTH: case DC_SAMPLE_DEPTH:
if (statistics->maxdepth < value.depth) if (statistics->maxdepth < value->depth)
statistics->maxdepth = value.depth; statistics->maxdepth = value->depth;
break; break;
default: default:
break; break;

View File

@ -280,12 +280,12 @@ reefnet_sensus_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback
// Time (seconds) // Time (seconds)
time += interval; time += interval;
sample.time = time * 1000; sample.time = time * 1000;
if (callback) callback (DC_SAMPLE_TIME, sample, userdata); if (callback) callback (DC_SAMPLE_TIME, &sample, userdata);
// Depth (adjusted feet of seawater). // Depth (adjusted feet of seawater).
unsigned int depth = data[offset++]; unsigned int depth = data[offset++];
sample.depth = ((depth + 33.0 - (double) SAMPLE_DEPTH_ADJUST) * FSW - parser->atmospheric) / parser->hydrostatic; sample.depth = ((depth + 33.0 - (double) SAMPLE_DEPTH_ADJUST) * FSW - parser->atmospheric) / parser->hydrostatic;
if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); if (callback) callback (DC_SAMPLE_DEPTH, &sample, userdata);
// Temperature (degrees Fahrenheit) // Temperature (degrees Fahrenheit)
if ((nsamples % 6) == 0) { if ((nsamples % 6) == 0) {
@ -293,7 +293,7 @@ reefnet_sensus_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback
return DC_STATUS_DATAFORMAT; return DC_STATUS_DATAFORMAT;
unsigned int temperature = data[offset++]; unsigned int temperature = data[offset++];
sample.temperature = (temperature - 32.0) * (5.0 / 9.0); sample.temperature = (temperature - 32.0) * (5.0 / 9.0);
if (callback) callback (DC_SAMPLE_TEMPERATURE, sample, userdata); if (callback) callback (DC_SAMPLE_TEMPERATURE, &sample, userdata);
} }
// Current sample is complete. // Current sample is complete.

View File

@ -279,15 +279,15 @@ reefnet_sensuspro_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callb
// Time (seconds) // Time (seconds)
time += interval; time += interval;
sample.time = time * 1000; sample.time = time * 1000;
if (callback) callback (DC_SAMPLE_TIME, sample, userdata); if (callback) callback (DC_SAMPLE_TIME, &sample, userdata);
// Temperature (°F) // Temperature (°F)
sample.temperature = (temperature - 32.0) * (5.0 / 9.0); sample.temperature = (temperature - 32.0) * (5.0 / 9.0);
if (callback) callback (DC_SAMPLE_TEMPERATURE, sample, userdata); if (callback) callback (DC_SAMPLE_TEMPERATURE, &sample, userdata);
// Depth (absolute pressure in fsw) // Depth (absolute pressure in fsw)
sample.depth = (depth * FSW - parser->atmospheric) / parser->hydrostatic; sample.depth = (depth * FSW - parser->atmospheric) / parser->hydrostatic;
if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); if (callback) callback (DC_SAMPLE_DEPTH, &sample, userdata);
offset += 2; offset += 2;
} }

View File

@ -276,17 +276,17 @@ reefnet_sensusultra_parser_samples_foreach (dc_parser_t *abstract, dc_sample_cal
// Time (seconds) // Time (seconds)
time += interval; time += interval;
sample.time = time * 1000; sample.time = time * 1000;
if (callback) callback (DC_SAMPLE_TIME, sample, userdata); if (callback) callback (DC_SAMPLE_TIME, &sample, userdata);
// Temperature (0.01 °K) // Temperature (0.01 °K)
unsigned int temperature = array_uint16_le (data + offset); unsigned int temperature = array_uint16_le (data + offset);
sample.temperature = temperature / 100.0 - 273.15; sample.temperature = temperature / 100.0 - 273.15;
if (callback) callback (DC_SAMPLE_TEMPERATURE, sample, userdata); if (callback) callback (DC_SAMPLE_TEMPERATURE, &sample, userdata);
// Depth (absolute pressure in millibar) // Depth (absolute pressure in millibar)
unsigned int depth = array_uint16_le (data + offset + 2); unsigned int depth = array_uint16_le (data + offset + 2);
sample.depth = (depth * BAR / 1000.0 - parser->atmospheric) / parser->hydrostatic; sample.depth = (depth * BAR / 1000.0 - parser->atmospheric) / parser->hydrostatic;
if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); if (callback) callback (DC_SAMPLE_DEPTH, &sample, userdata);
offset += 4; offset += 4;
} }

View File

@ -333,15 +333,15 @@ seac_screen_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t
} }
time = timestamp; time = timestamp;
sample.time = time * 1000; sample.time = time * 1000;
if (callback) callback (DC_SAMPLE_TIME, sample, userdata); if (callback) callback (DC_SAMPLE_TIME, &sample, userdata);
// Depth (1/100 m). // Depth (1/100 m).
sample.depth = depth / 100.0; sample.depth = depth / 100.0;
if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); if (callback) callback (DC_SAMPLE_DEPTH, &sample, userdata);
// Temperature (1/100 °C). // Temperature (1/100 °C).
sample.temperature = temperature / 100.0; sample.temperature = temperature / 100.0;
if (callback) callback (DC_SAMPLE_TEMPERATURE, sample, userdata); if (callback) callback (DC_SAMPLE_TEMPERATURE, &sample, userdata);
// Gas mix // Gas mix
if (o2 != o2_previous) { if (o2 != o2_previous) {
@ -364,7 +364,7 @@ seac_screen_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t
} }
sample.gasmix = idx; sample.gasmix = idx;
if (callback) callback(DC_SAMPLE_GASMIX, sample, userdata); if (callback) callback(DC_SAMPLE_GASMIX, &sample, userdata);
o2_previous = o2; o2_previous = o2;
} }
@ -379,11 +379,11 @@ seac_screen_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t
sample.deco.depth = 0; sample.deco.depth = 0;
} }
sample.deco.tts = 0; sample.deco.tts = 0;
if (callback) callback (DC_SAMPLE_DECO, sample, userdata); if (callback) callback (DC_SAMPLE_DECO, &sample, userdata);
// CNS // CNS
sample.cns = cns / 100.0; sample.cns = cns / 100.0;
if (callback) callback (DC_SAMPLE_CNS, sample, userdata); if (callback) callback (DC_SAMPLE_CNS, &sample, userdata);
// Deco model // Deco model
if (gf_low == 0 && gf_high == 0) { if (gf_low == 0 && gf_high == 0) {

View File

@ -912,7 +912,7 @@ shearwater_predator_parser_samples_foreach (dc_parser_t *abstract, dc_sample_cal
// Time (seconds). // Time (seconds).
time += interval; time += interval;
sample.time = time; sample.time = time;
if (callback) callback (DC_SAMPLE_TIME, sample, userdata); if (callback) callback (DC_SAMPLE_TIME, &sample, userdata);
// Depth (1/10 m or ft). // Depth (1/10 m or ft).
unsigned int depth = array_uint16_be (data + pnf + offset); unsigned int depth = array_uint16_be (data + pnf + offset);
@ -920,7 +920,7 @@ shearwater_predator_parser_samples_foreach (dc_parser_t *abstract, dc_sample_cal
sample.depth = depth * FEET / 10.0; sample.depth = depth * FEET / 10.0;
else else
sample.depth = depth / 10.0; sample.depth = depth / 10.0;
if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); if (callback) callback (DC_SAMPLE_DEPTH, &sample, userdata);
// Temperature (°C or °F). // Temperature (°C or °F).
int temperature = (signed char) data[offset + pnf + 13]; int temperature = (signed char) data[offset + pnf + 13];
@ -935,7 +935,7 @@ shearwater_predator_parser_samples_foreach (dc_parser_t *abstract, dc_sample_cal
sample.temperature = (temperature - 32.0) * (5.0 / 9.0); sample.temperature = (temperature - 32.0) * (5.0 / 9.0);
else else
sample.temperature = temperature; sample.temperature = temperature;
if (callback) callback (DC_SAMPLE_TEMPERATURE, sample, userdata); if (callback) callback (DC_SAMPLE_TEMPERATURE, &sample, userdata);
// Status flags. // Status flags.
unsigned int status = data[offset + pnf + 11]; unsigned int status = data[offset + pnf + 11];
@ -946,19 +946,19 @@ shearwater_predator_parser_samples_foreach (dc_parser_t *abstract, dc_sample_cal
if ((status & PPO2_EXTERNAL) == 0) { if ((status & PPO2_EXTERNAL) == 0) {
sample.ppo2.sensor = DC_SENSOR_NONE; sample.ppo2.sensor = DC_SENSOR_NONE;
sample.ppo2.value = data[offset + pnf + 6] / 100.0; sample.ppo2.value = data[offset + pnf + 6] / 100.0;
if (callback) callback (DC_SAMPLE_PPO2, sample, userdata); if (callback) callback (DC_SAMPLE_PPO2, &sample, userdata);
sample.ppo2.sensor = 0; sample.ppo2.sensor = 0;
sample.ppo2.value = data[offset + pnf + 12] * parser->calibration[0]; sample.ppo2.value = data[offset + pnf + 12] * parser->calibration[0];
if (callback && (parser->calibrated & 0x01)) callback (DC_SAMPLE_PPO2, sample, userdata); if (callback && (parser->calibrated & 0x01)) callback (DC_SAMPLE_PPO2, &sample, userdata);
sample.ppo2.sensor = 1; sample.ppo2.sensor = 1;
sample.ppo2.value = data[offset + pnf + 14] * parser->calibration[1]; sample.ppo2.value = data[offset + pnf + 14] * parser->calibration[1];
if (callback && (parser->calibrated & 0x02)) callback (DC_SAMPLE_PPO2, sample, userdata); if (callback && (parser->calibrated & 0x02)) callback (DC_SAMPLE_PPO2, &sample, userdata);
sample.ppo2.sensor = 2; sample.ppo2.sensor = 2;
sample.ppo2.value = data[offset + pnf + 15] * parser->calibration[2]; sample.ppo2.value = data[offset + pnf + 15] * parser->calibration[2];
if (callback && (parser->calibrated & 0x04)) callback (DC_SAMPLE_PPO2, sample, userdata); if (callback && (parser->calibrated & 0x04)) callback (DC_SAMPLE_PPO2, &sample, userdata);
} }
// Setpoint // Setpoint
@ -972,13 +972,13 @@ shearwater_predator_parser_samples_foreach (dc_parser_t *abstract, dc_sample_cal
sample.setpoint = data[17] / 100.0; sample.setpoint = data[17] / 100.0;
} }
} }
if (callback) callback (DC_SAMPLE_SETPOINT, sample, userdata); if (callback) callback (DC_SAMPLE_SETPOINT, &sample, userdata);
} }
// CNS // CNS
if (parser->petrel) { if (parser->petrel) {
sample.cns = data[offset + pnf + 22] / 100.0; sample.cns = data[offset + pnf + 22] / 100.0;
if (callback) callback (DC_SAMPLE_CNS, sample, userdata); if (callback) callback (DC_SAMPLE_CNS, &sample, userdata);
} }
// Gaschange. // Gaschange.
@ -993,7 +993,7 @@ shearwater_predator_parser_samples_foreach (dc_parser_t *abstract, dc_sample_cal
} }
sample.gasmix = idx; sample.gasmix = idx;
if (callback) callback (DC_SAMPLE_GASMIX, sample, userdata); if (callback) callback (DC_SAMPLE_GASMIX, &sample, userdata);
o2_previous = o2; o2_previous = o2;
he_previous = he; he_previous = he;
dil_previous = ccr; dil_previous = ccr;
@ -1013,7 +1013,7 @@ shearwater_predator_parser_samples_foreach (dc_parser_t *abstract, dc_sample_cal
} }
sample.deco.time = data[offset + pnf + 9] * 60; sample.deco.time = data[offset + pnf + 9] * 60;
sample.deco.tts = array_uint16_be (data + offset + pnf + 4) * 60; sample.deco.tts = array_uint16_be (data + offset + pnf + 4) * 60;
if (callback) callback (DC_SAMPLE_DECO, sample, userdata); if (callback) callback (DC_SAMPLE_DECO, &sample, userdata);
// for logversion 7 and newer (introduced for Perdix AI) // for logversion 7 and newer (introduced for Perdix AI)
// detect tank pressure // detect tank pressure
@ -1035,7 +1035,7 @@ shearwater_predator_parser_samples_foreach (dc_parser_t *abstract, dc_sample_cal
pressure &= 0x0FFF; pressure &= 0x0FFF;
sample.pressure.tank = parser->tankidx[id]; sample.pressure.tank = parser->tankidx[id];
sample.pressure.value = pressure * 2 * PSI / BAR; sample.pressure.value = pressure * 2 * PSI / BAR;
if (callback) callback (DC_SAMPLE_PRESSURE, sample, userdata); if (callback) callback (DC_SAMPLE_PRESSURE, &sample, userdata);
} }
} }
@ -1048,7 +1048,7 @@ shearwater_predator_parser_samples_foreach (dc_parser_t *abstract, dc_sample_cal
// 0xFB Tank size or max pressure havent been set up // 0xFB Tank size or max pressure havent been set up
if (data[offset + pnf + 21] < 0xF0) { if (data[offset + pnf + 21] < 0xF0) {
sample.rbt = data[offset + pnf + 21]; sample.rbt = data[offset + pnf + 21];
if (callback) callback (DC_SAMPLE_RBT, sample, userdata); if (callback) callback (DC_SAMPLE_RBT, &sample, userdata);
} }
} }
} else if (type == LOG_RECORD_DIVE_SAMPLE_EXT) { } else if (type == LOG_RECORD_DIVE_SAMPLE_EXT) {
@ -1061,7 +1061,7 @@ shearwater_predator_parser_samples_foreach (dc_parser_t *abstract, dc_sample_cal
pressure &= 0x0FFF; pressure &= 0x0FFF;
sample.pressure.tank = parser->tankidx[id]; sample.pressure.tank = parser->tankidx[id];
sample.pressure.value = pressure * 2 * PSI / BAR; sample.pressure.value = pressure * 2 * PSI / BAR;
if (callback) callback (DC_SAMPLE_PRESSURE, sample, userdata); if (callback) callback (DC_SAMPLE_PRESSURE, &sample, userdata);
} }
} }
} }
@ -1073,7 +1073,7 @@ shearwater_predator_parser_samples_foreach (dc_parser_t *abstract, dc_sample_cal
if (pressure) { if (pressure) {
sample.pressure.tank = parser->tankidx[id]; sample.pressure.tank = parser->tankidx[id];
sample.pressure.value = pressure * 2 * PSI / BAR; sample.pressure.value = pressure * 2 * PSI / BAR;
if (callback) callback (DC_SAMPLE_PRESSURE, sample, userdata); if (callback) callback (DC_SAMPLE_PRESSURE, &sample, userdata);
} }
} }
} }
@ -1092,17 +1092,17 @@ shearwater_predator_parser_samples_foreach (dc_parser_t *abstract, dc_sample_cal
// Time (seconds). // Time (seconds).
time += interval; time += interval;
sample.time = time; sample.time = time;
if (callback) callback (DC_SAMPLE_TIME, sample, userdata); if (callback) callback (DC_SAMPLE_TIME, &sample, userdata);
// Depth (absolute pressure in millibar) // Depth (absolute pressure in millibar)
unsigned int depth = array_uint16_be (data + idx + 1); unsigned int depth = array_uint16_be (data + idx + 1);
sample.depth = (signed int)(depth - parser->atmospheric) * (BAR / 1000.0) / (parser->density * GRAVITY); sample.depth = (signed int)(depth - parser->atmospheric) * (BAR / 1000.0) / (parser->density * GRAVITY);
if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); if (callback) callback (DC_SAMPLE_DEPTH, &sample, userdata);
// Temperature (1/10 °C). // Temperature (1/10 °C).
int temperature = (signed short) array_uint16_be (data + idx + 3); int temperature = (signed short) array_uint16_be (data + idx + 3);
sample.temperature = temperature / 10.0; sample.temperature = temperature / 10.0;
if (callback) callback (DC_SAMPLE_TEMPERATURE, sample, userdata); if (callback) callback (DC_SAMPLE_TEMPERATURE, &sample, userdata);
} }
} else if (type == LOG_RECORD_INFO_EVENT) { } else if (type == LOG_RECORD_INFO_EVENT) {
unsigned int event = data[offset + 1]; unsigned int event = data[offset + 1];
@ -1114,7 +1114,7 @@ shearwater_predator_parser_samples_foreach (dc_parser_t *abstract, dc_sample_cal
// Compass heading // Compass heading
if (w1 != 0xFFFFFFFF) { if (w1 != 0xFFFFFFFF) {
sample.bearing = w1; sample.bearing = w1;
if (callback) callback (DC_SAMPLE_BEARING, sample, userdata); if (callback) callback (DC_SAMPLE_BEARING, &sample, userdata);
} }
// Tag // Tag
@ -1122,7 +1122,7 @@ shearwater_predator_parser_samples_foreach (dc_parser_t *abstract, dc_sample_cal
sample.event.time = 0; sample.event.time = 0;
sample.event.flags = 0; sample.event.flags = 0;
sample.event.value = w2; sample.event.value = w2;
if (callback) callback (DC_SAMPLE_EVENT, sample, userdata); if (callback) callback (DC_SAMPLE_EVENT, &sample, userdata);
} }
} }

View File

@ -185,20 +185,20 @@ sporasub_sp2_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t
// Time (seconds) // Time (seconds)
time += interval; time += interval;
sample.time = time * 1000; sample.time = time * 1000;
if (callback) callback (DC_SAMPLE_TIME, sample, userdata); if (callback) callback (DC_SAMPLE_TIME, &sample, userdata);
// Depth (1/100 m) // Depth (1/100 m)
sample.depth = depth / 100.0; sample.depth = depth / 100.0;
if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); if (callback) callback (DC_SAMPLE_DEPTH, &sample, userdata);
// Temperature (1/10 °C) // Temperature (1/10 °C)
sample.temperature = temperature / 10.0 - 20.0; sample.temperature = temperature / 10.0 - 20.0;
if (callback) callback (DC_SAMPLE_TEMPERATURE, sample, userdata); if (callback) callback (DC_SAMPLE_TEMPERATURE, &sample, userdata);
// Heartrate // Heartrate
if (heartrate) { if (heartrate) {
sample.heartbeat = heartrate; sample.heartbeat = heartrate;
if (callback) callback (DC_SAMPLE_HEARTBEAT, sample, userdata); if (callback) callback (DC_SAMPLE_HEARTBEAT, &sample, userdata);
} }
offset += SZ_SAMPLE; offset += SZ_SAMPLE;

View File

@ -523,7 +523,7 @@ suunto_d9_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t ca
// Time (seconds). // Time (seconds).
sample.time = time * 1000; sample.time = time * 1000;
if (callback) callback (DC_SAMPLE_TIME, sample, userdata); if (callback) callback (DC_SAMPLE_TIME, &sample, userdata);
// Sample data. // Sample data.
for (unsigned int i = 0; i < nparams; ++i) { for (unsigned int i = 0; i < nparams; ++i) {
@ -538,19 +538,19 @@ suunto_d9_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t ca
case 0x64: // Depth case 0x64: // Depth
value = array_uint16_le (data + offset); value = array_uint16_le (data + offset);
sample.depth = value / (double) info[i].divisor; sample.depth = value / (double) info[i].divisor;
if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); if (callback) callback (DC_SAMPLE_DEPTH, &sample, userdata);
break; break;
case 0x68: // Pressure case 0x68: // Pressure
value = array_uint16_le (data + offset); value = array_uint16_le (data + offset);
if (value != 0xFFFF) { if (value != 0xFFFF) {
sample.pressure.tank = 0; sample.pressure.tank = 0;
sample.pressure.value = value / (double) info[i].divisor; sample.pressure.value = value / (double) info[i].divisor;
if (callback) callback (DC_SAMPLE_PRESSURE, sample, userdata); if (callback) callback (DC_SAMPLE_PRESSURE, &sample, userdata);
} }
break; break;
case 0x74: // Temperature case 0x74: // Temperature
sample.temperature = (signed char) data[offset] / (double) info[i].divisor; sample.temperature = (signed char) data[offset] / (double) info[i].divisor;
if (callback) callback (DC_SAMPLE_TEMPERATURE, sample, userdata); if (callback) callback (DC_SAMPLE_TEMPERATURE, &sample, userdata);
break; break;
default: // Unknown sample type default: // Unknown sample type
ERROR (abstract->context, "Unknown sample type 0x%02x.", info[i].type); ERROR (abstract->context, "Unknown sample type 0x%02x.", info[i].type);
@ -568,7 +568,7 @@ suunto_d9_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t ca
return DC_STATUS_DATAFORMAT; return DC_STATUS_DATAFORMAT;
} }
sample.gasmix = parser->gasmix; sample.gasmix = parser->gasmix;
if (callback) callback (DC_SAMPLE_GASMIX, sample, userdata); if (callback) callback (DC_SAMPLE_GASMIX, &sample, userdata);
} }
// Events // Events
@ -608,7 +608,7 @@ suunto_d9_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t ca
seconds = data[offset + 1]; seconds = data[offset + 1];
sample.event.type = SAMPLE_EVENT_SURFACE; sample.event.type = SAMPLE_EVENT_SURFACE;
sample.event.time = seconds; sample.event.time = seconds;
if (callback) callback (DC_SAMPLE_EVENT, sample, userdata); if (callback) callback (DC_SAMPLE_EVENT, &sample, userdata);
offset += 2; offset += 2;
break; break;
case 0x03: // Event case 0x03: // Event
@ -714,7 +714,7 @@ suunto_d9_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t ca
sample.event.flags = SAMPLE_FLAGS_BEGIN; sample.event.flags = SAMPLE_FLAGS_BEGIN;
sample.event.time = seconds; sample.event.time = seconds;
if (sample.event.type != SAMPLE_EVENT_NONE) { if (sample.event.type != SAMPLE_EVENT_NONE) {
if (callback) callback (DC_SAMPLE_EVENT, sample, userdata); if (callback) callback (DC_SAMPLE_EVENT, &sample, userdata);
} }
offset += 2; offset += 2;
break; break;
@ -734,7 +734,7 @@ suunto_d9_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t ca
sample.event.value = heading / 2; sample.event.value = heading / 2;
} }
sample.event.time = seconds; sample.event.time = seconds;
if (callback) callback (DC_SAMPLE_EVENT, sample, userdata); if (callback) callback (DC_SAMPLE_EVENT, &sample, userdata);
offset += 4; offset += 4;
break; break;
case 0x05: // Gas Change case 0x05: // Gas Change
@ -750,7 +750,7 @@ suunto_d9_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t ca
return DC_STATUS_DATAFORMAT; return DC_STATUS_DATAFORMAT;
} }
sample.gasmix = idx; sample.gasmix = idx;
if (callback) callback (DC_SAMPLE_GASMIX, sample, userdata); if (callback) callback (DC_SAMPLE_GASMIX, &sample, userdata);
offset += 2; offset += 2;
break; break;
case 0x06: // Gas Change case 0x06: // Gas Change
@ -784,10 +784,10 @@ suunto_d9_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t ca
return DC_STATUS_DATAFORMAT; return DC_STATUS_DATAFORMAT;
} }
sample.gasmix = idx; sample.gasmix = idx;
if (callback) callback (DC_SAMPLE_GASMIX, sample, userdata); if (callback) callback (DC_SAMPLE_GASMIX, &sample, userdata);
if (type & 0x80) { if (type & 0x80) {
sample.setpoint = ppo2 / 10.0; sample.setpoint = ppo2 / 10.0;
if (callback) callback (DC_SAMPLE_SETPOINT, sample, userdata); if (callback) callback (DC_SAMPLE_SETPOINT, &sample, userdata);
} }
offset += length; offset += length;
break; break;
@ -813,7 +813,7 @@ suunto_d9_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t ca
sample.deco.time = 0; sample.deco.time = 0;
sample.deco.depth = 0.0; sample.deco.depth = 0.0;
sample.deco.tts = 0; sample.deco.tts = 0;
if (callback) callback (DC_SAMPLE_DECO, sample, userdata); if (callback) callback (DC_SAMPLE_DECO, &sample, userdata);
time += interval_sample; time += interval_sample;
nsamples++; nsamples++;

View File

@ -275,15 +275,15 @@ suunto_eon_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t c
// Time // Time
sample.time = 0; sample.time = 0;
if (callback) callback (DC_SAMPLE_TIME, sample, userdata); if (callback) callback (DC_SAMPLE_TIME, &sample, userdata);
// Depth (0 ft) // Depth (0 ft)
sample.depth = 0; sample.depth = 0;
if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); if (callback) callback (DC_SAMPLE_DEPTH, &sample, userdata);
// Initial gas mix. // Initial gas mix.
sample.gasmix = 0; sample.gasmix = 0;
if (callback) callback (DC_SAMPLE_GASMIX, sample, userdata); if (callback) callback (DC_SAMPLE_GASMIX, &sample, userdata);
unsigned int depth = 0; unsigned int depth = 0;
unsigned int time = 0; unsigned int time = 0;
@ -297,7 +297,7 @@ suunto_eon_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t c
// Time (seconds). // Time (seconds).
time += interval; time += interval;
sample.time = time * 1000; sample.time = time * 1000;
if (callback) callback (DC_SAMPLE_TIME, sample, userdata); if (callback) callback (DC_SAMPLE_TIME, &sample, userdata);
complete = 0; complete = 0;
} }
@ -307,7 +307,7 @@ suunto_eon_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t c
// Depth (ft). // Depth (ft).
sample.depth = depth * FEET; sample.depth = depth * FEET;
if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); if (callback) callback (DC_SAMPLE_DEPTH, &sample, userdata);
complete = 1; complete = 1;
} else { } else {
@ -335,7 +335,7 @@ suunto_eon_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t c
} }
if (sample.event.type != SAMPLE_EVENT_NONE) { if (sample.event.type != SAMPLE_EVENT_NONE) {
if (callback) callback (DC_SAMPLE_EVENT, sample, userdata); if (callback) callback (DC_SAMPLE_EVENT, &sample, userdata);
} }
} }
} }
@ -344,12 +344,12 @@ suunto_eon_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t c
if (complete) { if (complete) {
time += interval; time += interval;
sample.time = time * 1000; sample.time = time * 1000;
if (callback) callback (DC_SAMPLE_TIME, sample, userdata); if (callback) callback (DC_SAMPLE_TIME, &sample, userdata);
} }
// Depth (0 ft) // Depth (0 ft)
sample.depth = 0; sample.depth = 0;
if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); if (callback) callback (DC_SAMPLE_DEPTH, &sample, userdata);
return DC_STATUS_SUCCESS; return DC_STATUS_SUCCESS;
} }

View File

@ -476,7 +476,7 @@ static void sample_time(struct sample_data *info, unsigned short time_delta)
info->time += time_delta; info->time += time_delta;
sample.time = info->time; sample.time = info->time;
if (info->callback) info->callback(DC_SAMPLE_TIME, sample, info->userdata); if (info->callback) info->callback(DC_SAMPLE_TIME, &sample, info->userdata);
} }
static void sample_depth(struct sample_data *info, unsigned short depth) static void sample_depth(struct sample_data *info, unsigned short depth)
@ -487,7 +487,7 @@ static void sample_depth(struct sample_data *info, unsigned short depth)
return; return;
sample.depth = depth / 100.0; sample.depth = depth / 100.0;
if (info->callback) info->callback(DC_SAMPLE_DEPTH, sample, info->userdata); if (info->callback) info->callback(DC_SAMPLE_DEPTH, &sample, info->userdata);
} }
static void sample_temp(struct sample_data *info, short temp) static void sample_temp(struct sample_data *info, short temp)
@ -498,7 +498,7 @@ static void sample_temp(struct sample_data *info, short temp)
return; return;
sample.temperature = temp / 10.0; sample.temperature = temp / 10.0;
if (info->callback) info->callback(DC_SAMPLE_TEMPERATURE, sample, info->userdata); if (info->callback) info->callback(DC_SAMPLE_TEMPERATURE, &sample, info->userdata);
} }
static void sample_ndl(struct sample_data *info, short ndl) static void sample_ndl(struct sample_data *info, short ndl)
@ -512,7 +512,7 @@ static void sample_ndl(struct sample_data *info, short ndl)
sample.deco.type = DC_DECO_NDL; sample.deco.type = DC_DECO_NDL;
sample.deco.time = ndl; sample.deco.time = ndl;
sample.deco.tts = 0; sample.deco.tts = 0;
if (info->callback) info->callback(DC_SAMPLE_DECO, sample, info->userdata); if (info->callback) info->callback(DC_SAMPLE_DECO, &sample, info->userdata);
} }
static void sample_tts(struct sample_data *info, unsigned short tts) static void sample_tts(struct sample_data *info, unsigned short tts)
@ -536,7 +536,7 @@ static void sample_heading(struct sample_data *info, unsigned short heading)
sample.event.type = SAMPLE_EVENT_HEADING; sample.event.type = SAMPLE_EVENT_HEADING;
sample.event.value = heading; sample.event.value = heading;
if (info->callback) info->callback(DC_SAMPLE_EVENT, sample, info->userdata); if (info->callback) info->callback(DC_SAMPLE_EVENT, &sample, info->userdata);
} }
static void sample_abspressure(struct sample_data *info, unsigned short pressure) static void sample_abspressure(struct sample_data *info, unsigned short pressure)
@ -551,7 +551,7 @@ static void sample_gastime(struct sample_data *info, short gastime)
return; return;
sample.rbt = gastime / 60; sample.rbt = gastime / 60;
if (info->callback) info->callback (DC_SAMPLE_RBT, sample, info->userdata); if (info->callback) info->callback (DC_SAMPLE_RBT, &sample, info->userdata);
} }
/* /*
@ -579,7 +579,7 @@ static void sample_pressure(struct sample_data *info, unsigned short pressure)
sample.pressure.tank = info->gasnr-1; sample.pressure.tank = info->gasnr-1;
sample.pressure.value = pressure / 100.0; sample.pressure.value = pressure / 100.0;
if (info->callback) info->callback(DC_SAMPLE_PRESSURE, sample, info->userdata); if (info->callback) info->callback(DC_SAMPLE_PRESSURE, &sample, info->userdata);
} }
static void sample_bookmark_event(struct sample_data *info, unsigned short idx) static void sample_bookmark_event(struct sample_data *info, unsigned short idx)
@ -589,7 +589,7 @@ static void sample_bookmark_event(struct sample_data *info, unsigned short idx)
sample.event.type = SAMPLE_EVENT_BOOKMARK; sample.event.type = SAMPLE_EVENT_BOOKMARK;
sample.event.value = idx; sample.event.value = idx;
if (info->callback) info->callback(DC_SAMPLE_EVENT, sample, info->userdata); if (info->callback) info->callback(DC_SAMPLE_EVENT, &sample, info->userdata);
} }
static void sample_gas_switch_event(struct sample_data *info, unsigned short idx) static void sample_gas_switch_event(struct sample_data *info, unsigned short idx)
@ -601,7 +601,7 @@ static void sample_gas_switch_event(struct sample_data *info, unsigned short idx
return; return;
sample.gasmix = idx - 1; sample.gasmix = idx - 1;
if (info->callback) info->callback(DC_SAMPLE_GASMIX, sample, info->userdata); if (info->callback) info->callback(DC_SAMPLE_GASMIX, &sample, info->userdata);
} }
/* /*
@ -701,7 +701,7 @@ static void sample_event_state_value(const struct type_desc *desc, struct sample
return; return;
sample.event.flags = value ? SAMPLE_FLAGS_BEGIN : SAMPLE_FLAGS_END; sample.event.flags = value ? SAMPLE_FLAGS_BEGIN : SAMPLE_FLAGS_END;
if (info->callback) info->callback(DC_SAMPLE_EVENT, sample, info->userdata); if (info->callback) info->callback(DC_SAMPLE_EVENT, &sample, info->userdata);
} }
static void sample_event_notify_type(const struct type_desc *desc, struct sample_data *info, unsigned char type) static void sample_event_notify_type(const struct type_desc *desc, struct sample_data *info, unsigned char type)
@ -743,7 +743,7 @@ static void sample_event_notify_value(const struct type_desc *desc, struct sampl
return; return;
sample.event.flags = value ? SAMPLE_FLAGS_BEGIN : SAMPLE_FLAGS_END; sample.event.flags = value ? SAMPLE_FLAGS_BEGIN : SAMPLE_FLAGS_END;
if (info->callback) info->callback(DC_SAMPLE_EVENT, sample, info->userdata); if (info->callback) info->callback(DC_SAMPLE_EVENT, &sample, info->userdata);
} }
@ -783,7 +783,7 @@ static void sample_event_warning_value(const struct type_desc *desc, struct samp
return; return;
sample.event.flags = value ? SAMPLE_FLAGS_BEGIN : SAMPLE_FLAGS_END; sample.event.flags = value ? SAMPLE_FLAGS_BEGIN : SAMPLE_FLAGS_END;
if (info->callback) info->callback(DC_SAMPLE_EVENT, sample, info->userdata); if (info->callback) info->callback(DC_SAMPLE_EVENT, &sample, info->userdata);
} }
static void sample_event_alarm_type(const struct type_desc *desc, struct sample_data *info, unsigned char type) static void sample_event_alarm_type(const struct type_desc *desc, struct sample_data *info, unsigned char type)
@ -816,7 +816,7 @@ static void sample_event_alarm_value(const struct type_desc *desc, struct sample
return; return;
sample.event.flags = value ? SAMPLE_FLAGS_BEGIN : SAMPLE_FLAGS_END; sample.event.flags = value ? SAMPLE_FLAGS_BEGIN : SAMPLE_FLAGS_END;
if (info->callback) info->callback(DC_SAMPLE_EVENT, sample, info->userdata); if (info->callback) info->callback(DC_SAMPLE_EVENT, &sample, info->userdata);
} }
// enum:0=Low,1=High,2=Custom // enum:0=Low,1=High,2=Custom
@ -842,7 +842,7 @@ static void sample_setpoint_type(const struct type_desc *desc, struct sample_dat
return; return;
} }
if (info->callback) info->callback(DC_SAMPLE_SETPOINT, sample, info->userdata); if (info->callback) info->callback(DC_SAMPLE_SETPOINT, &sample, info->userdata);
free(type); free(type);
} }
@ -1001,7 +1001,7 @@ static int traverse_samples(unsigned short type, const struct type_desc *desc, c
sample.deco.time = 0; sample.deco.time = 0;
sample.deco.depth = info->ceiling; sample.deco.depth = info->ceiling;
sample.deco.tts = info->tts; sample.deco.tts = info->tts;
if (info->callback) info->callback(DC_SAMPLE_DECO, sample, info->userdata); if (info->callback) info->callback(DC_SAMPLE_DECO, &sample, info->userdata);
} }
// Warn if there are left-over bytes for something we did use part of // Warn if there are left-over bytes for something we did use part of

View File

@ -185,7 +185,7 @@ suunto_solution_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callbac
// Time (minutes). // Time (minutes).
time += 3 * 60; time += 3 * 60;
sample.time = time * 1000; sample.time = time * 1000;
if (callback) callback (DC_SAMPLE_TIME, sample, userdata); if (callback) callback (DC_SAMPLE_TIME, &sample, userdata);
// Depth (ft). // Depth (ft).
depth += (signed char) value; depth += (signed char) value;
@ -198,12 +198,12 @@ suunto_solution_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callbac
depth += (signed char) data[offset++]; depth += (signed char) data[offset++];
} }
sample.depth = depth * FEET; sample.depth = depth * FEET;
if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); if (callback) callback (DC_SAMPLE_DEPTH, &sample, userdata);
// Gas change. // Gas change.
if (gasmix != gasmix_previous) { if (gasmix != gasmix_previous) {
sample.gasmix = gasmix; sample.gasmix = gasmix;
if (callback) callback (DC_SAMPLE_GASMIX, sample, userdata); if (callback) callback (DC_SAMPLE_GASMIX, &sample, userdata);
gasmix_previous = gasmix; gasmix_previous = gasmix;
} }
} else { } else {
@ -228,7 +228,7 @@ suunto_solution_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callbac
} }
if (sample.event.type != SAMPLE_EVENT_NONE) { if (sample.event.type != SAMPLE_EVENT_NONE) {
if (callback) callback (DC_SAMPLE_EVENT, sample, userdata); if (callback) callback (DC_SAMPLE_EVENT, &sample, userdata);
} }
} }
} }

View File

@ -332,16 +332,16 @@ suunto_vyper_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t
// Time // Time
sample.time = 0; sample.time = 0;
if (callback) callback (DC_SAMPLE_TIME, sample, userdata); if (callback) callback (DC_SAMPLE_TIME, &sample, userdata);
// Depth (0 ft) // Depth (0 ft)
sample.depth = 0; sample.depth = 0;
if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); if (callback) callback (DC_SAMPLE_DEPTH, &sample, userdata);
// Initial gas mix // Initial gas mix
if (!gauge) { if (!gauge) {
sample.gasmix = 0; sample.gasmix = 0;
if (callback) callback (DC_SAMPLE_GASMIX, sample, userdata); if (callback) callback (DC_SAMPLE_GASMIX, &sample, userdata);
} }
unsigned int depth = 0; unsigned int depth = 0;
@ -356,7 +356,7 @@ suunto_vyper_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t
// Time (seconds). // Time (seconds).
time += interval; time += interval;
sample.time = time * 1000; sample.time = time * 1000;
if (callback) callback (DC_SAMPLE_TIME, sample, userdata); if (callback) callback (DC_SAMPLE_TIME, &sample, userdata);
complete = 0; complete = 0;
} }
@ -366,7 +366,7 @@ suunto_vyper_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t
// Depth (ft). // Depth (ft).
sample.depth = depth * FEET; sample.depth = depth * FEET;
if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); if (callback) callback (DC_SAMPLE_DEPTH, &sample, userdata);
complete = 1; complete = 1;
} else { } else {
@ -410,7 +410,7 @@ suunto_vyper_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t
} }
sample.gasmix = idx; sample.gasmix = idx;
if (callback) callback (DC_SAMPLE_GASMIX, sample, userdata); if (callback) callback (DC_SAMPLE_GASMIX, &sample, userdata);
sample.event.type = SAMPLE_EVENT_NONE; sample.event.type = SAMPLE_EVENT_NONE;
break; break;
default: // Unknown default: // Unknown
@ -419,7 +419,7 @@ suunto_vyper_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t
} }
if (sample.event.type != SAMPLE_EVENT_NONE) { if (sample.event.type != SAMPLE_EVENT_NONE) {
if (callback) callback (DC_SAMPLE_EVENT, sample, userdata); if (callback) callback (DC_SAMPLE_EVENT, &sample, userdata);
} }
} }
} }
@ -428,12 +428,12 @@ suunto_vyper_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t
if (complete) { if (complete) {
time += interval; time += interval;
sample.time = time * 1000; sample.time = time * 1000;
if (callback) callback (DC_SAMPLE_TIME, sample, userdata); if (callback) callback (DC_SAMPLE_TIME, &sample, userdata);
} }
// Depth (0 ft) // Depth (0 ft)
sample.depth = 0; sample.depth = 0;
if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); if (callback) callback (DC_SAMPLE_DEPTH, &sample, userdata);
return DC_STATUS_SUCCESS; return DC_STATUS_SUCCESS;
} }

View File

@ -160,28 +160,28 @@ tecdiving_divecomputereu_parser_samples_foreach (dc_parser_t *abstract, dc_sampl
// Time (seconds). // Time (seconds).
time += interval; time += interval;
sample.time = time * 1000; sample.time = time * 1000;
if (callback) callback (DC_SAMPLE_TIME, sample, userdata); if (callback) callback (DC_SAMPLE_TIME, &sample, userdata);
// Depth (1/10 m). // Depth (1/10 m).
unsigned int depth = array_uint16_be (data + offset + 2); unsigned int depth = array_uint16_be (data + offset + 2);
sample.depth = depth / 10.0; sample.depth = depth / 10.0;
if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); if (callback) callback (DC_SAMPLE_DEPTH, &sample, userdata);
// Temperature (Celsius). // Temperature (Celsius).
signed int temperature = (signed char) data[offset]; signed int temperature = (signed char) data[offset];
sample.temperature = temperature; sample.temperature = temperature;
if (callback) callback (DC_SAMPLE_TEMPERATURE, sample, userdata); if (callback) callback (DC_SAMPLE_TEMPERATURE, &sample, userdata);
// ppO2 // ppO2
unsigned int ppo2 = data[offset + 1]; unsigned int ppo2 = data[offset + 1];
sample.ppo2.sensor = DC_SENSOR_NONE; sample.ppo2.sensor = DC_SENSOR_NONE;
sample.ppo2.value = ppo2 / 10.0; sample.ppo2.value = ppo2 / 10.0;
if (callback) callback (DC_SAMPLE_PPO2, sample, userdata); if (callback) callback (DC_SAMPLE_PPO2, &sample, userdata);
// Setpoint // Setpoint
unsigned int setpoint = data[offset + 4]; unsigned int setpoint = data[offset + 4];
sample.setpoint = setpoint / 10.0; sample.setpoint = setpoint / 10.0;
if (callback) callback (DC_SAMPLE_SETPOINT, sample, userdata); if (callback) callback (DC_SAMPLE_SETPOINT, &sample, userdata);
offset += 8; offset += 8;
} }

View File

@ -253,16 +253,16 @@ uwatec_memomouse_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callba
// Time (seconds) // Time (seconds)
sample.time = time * 1000; sample.time = time * 1000;
if (callback) callback (DC_SAMPLE_TIME, sample, userdata); if (callback) callback (DC_SAMPLE_TIME, &sample, userdata);
// Depth (meters) // Depth (meters)
sample.depth = depth * 10.0 / 64.0; sample.depth = depth * 10.0 / 64.0;
if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); if (callback) callback (DC_SAMPLE_DEPTH, &sample, userdata);
// Gas change. // Gas change.
if (gasmix != gasmix_previous) { if (gasmix != gasmix_previous) {
sample.gasmix = gasmix; sample.gasmix = gasmix;
if (callback) callback (DC_SAMPLE_GASMIX, sample, userdata); if (callback) callback (DC_SAMPLE_GASMIX, &sample, userdata);
gasmix_previous = gasmix; gasmix_previous = gasmix;
} }
@ -275,7 +275,7 @@ uwatec_memomouse_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callba
sample.deco.time = 0; sample.deco.time = 0;
sample.deco.depth = 0.0; sample.deco.depth = 0.0;
sample.deco.tts = 0; sample.deco.tts = 0;
if (callback) callback (DC_SAMPLE_DECO, sample, userdata); if (callback) callback (DC_SAMPLE_DECO, &sample, userdata);
// Warnings // Warnings
for (unsigned int i = 0; i < 6; ++i) { for (unsigned int i = 0; i < 6; ++i) {
@ -304,7 +304,7 @@ uwatec_memomouse_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callba
break; break;
} }
if (sample.event.type != SAMPLE_EVENT_NONE) { if (sample.event.type != SAMPLE_EVENT_NONE) {
if (callback) callback (DC_SAMPLE_EVENT, sample, userdata); if (callback) callback (DC_SAMPLE_EVENT, &sample, userdata);
} }
} }
} }
@ -328,7 +328,7 @@ uwatec_memomouse_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callba
offset++; offset++;
} }
if (callback) callback (DC_SAMPLE_VENDOR, sample, userdata); if (callback) callback (DC_SAMPLE_VENDOR, &sample, userdata);
} }
time += 20; time += 20;

View File

@ -1165,7 +1165,7 @@ uwatec_smart_parse (uwatec_smart_parser_t *parser, dc_sample_callback_t callback
while (complete) { while (complete) {
sample.time = time * 1000; sample.time = time * 1000;
if (callback) callback (DC_SAMPLE_TIME, sample, userdata); if (callback) callback (DC_SAMPLE_TIME, &sample, userdata);
if (parser->ngasmixes && gasmix != gasmix_previous) { if (parser->ngasmixes && gasmix != gasmix_previous) {
idx = uwatec_smart_find_gasmix (parser, gasmix); idx = uwatec_smart_find_gasmix (parser, gasmix);
@ -1174,13 +1174,13 @@ uwatec_smart_parse (uwatec_smart_parser_t *parser, dc_sample_callback_t callback
return DC_STATUS_DATAFORMAT; return DC_STATUS_DATAFORMAT;
} }
sample.gasmix = idx; sample.gasmix = idx;
if (callback) callback (DC_SAMPLE_GASMIX, sample, userdata); if (callback) callback (DC_SAMPLE_GASMIX, &sample, userdata);
gasmix_previous = gasmix; gasmix_previous = gasmix;
} }
if (have_temperature) { if (have_temperature) {
sample.temperature = temperature / 2.5; sample.temperature = temperature / 2.5;
if (callback) callback (DC_SAMPLE_TEMPERATURE, sample, userdata); if (callback) callback (DC_SAMPLE_TEMPERATURE, &sample, userdata);
} }
if (bookmark) { if (bookmark) {
@ -1188,12 +1188,12 @@ uwatec_smart_parse (uwatec_smart_parser_t *parser, dc_sample_callback_t callback
sample.event.time = 0; sample.event.time = 0;
sample.event.flags = 0; sample.event.flags = 0;
sample.event.value = 0; sample.event.value = 0;
if (callback) callback (DC_SAMPLE_EVENT, sample, userdata); if (callback) callback (DC_SAMPLE_EVENT, &sample, userdata);
} }
if (have_rbt || have_pressure) { if (have_rbt || have_pressure) {
sample.rbt = rbt; sample.rbt = rbt;
if (callback) callback (DC_SAMPLE_RBT, sample, userdata); if (callback) callback (DC_SAMPLE_RBT, &sample, userdata);
} }
if (have_pressure) { if (have_pressure) {
@ -1201,24 +1201,24 @@ uwatec_smart_parse (uwatec_smart_parser_t *parser, dc_sample_callback_t callback
if (idx < parser->ntanks) { if (idx < parser->ntanks) {
sample.pressure.tank = idx; sample.pressure.tank = idx;
sample.pressure.value = pressure / 4.0; sample.pressure.value = pressure / 4.0;
if (callback) callback (DC_SAMPLE_PRESSURE, sample, userdata); if (callback) callback (DC_SAMPLE_PRESSURE, &sample, userdata);
} }
} }
if (have_heartrate) { if (have_heartrate) {
sample.heartbeat = heartrate; sample.heartbeat = heartrate;
if (callback) callback (DC_SAMPLE_HEARTBEAT, sample, userdata); if (callback) callback (DC_SAMPLE_HEARTBEAT, &sample, userdata);
} }
if (have_bearing) { if (have_bearing) {
sample.bearing = bearing; sample.bearing = bearing;
if (callback) callback (DC_SAMPLE_BEARING, sample, userdata); if (callback) callback (DC_SAMPLE_BEARING, &sample, userdata);
have_bearing = 0; have_bearing = 0;
} }
if (have_depth) { if (have_depth) {
sample.depth = (signed int)(depth - depth_calibration) * (2.0 * BAR / 1000.0) / (density * 10.0); sample.depth = (signed int)(depth - depth_calibration) * (2.0 * BAR / 1000.0) / (density * 10.0);
if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); if (callback) callback (DC_SAMPLE_DEPTH, &sample, userdata);
} }
time += interval; time += interval;