Add support for setpoint, ppO2 and CNS
So far only OSTC and Shearwater Predator are supported. For the OSTC we support CNS and setpoint changes in the samples (the current hardware doesn't actually support ppO2 sensors and for the older hw that does I don't have the correct encoding information). For the Predator we support only the "average ppO2 during the sample". The Predator also gives us a CNS value at the end of the dive - I don't quite know yet how to deliver that back to the consumer. Possibly as CNS value in the very last sample? That would at least be consistent. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
f5b5e41181
commit
f2a656246d
@ -39,7 +39,10 @@ typedef enum dc_sample_type_t {
|
||||
DC_SAMPLE_RBT,
|
||||
DC_SAMPLE_HEARTBEAT,
|
||||
DC_SAMPLE_BEARING,
|
||||
DC_SAMPLE_VENDOR
|
||||
DC_SAMPLE_VENDOR,
|
||||
DC_SAMPLE_SETPOINT,
|
||||
DC_SAMPLE_PPO2,
|
||||
DC_SAMPLE_CNS
|
||||
} dc_sample_type_t;
|
||||
|
||||
typedef enum dc_field_type_t {
|
||||
@ -141,6 +144,9 @@ typedef union dc_sample_value_t {
|
||||
unsigned int size;
|
||||
const void *data;
|
||||
} vendor;
|
||||
double setpoint;
|
||||
double ppo2;
|
||||
double cns;
|
||||
} dc_sample_value_t;
|
||||
|
||||
typedef struct dc_parser_t dc_parser_t;
|
||||
|
||||
@ -302,6 +302,10 @@ hw_ostc_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t call
|
||||
if (info[i].size != 2)
|
||||
return DC_STATUS_DATAFORMAT;
|
||||
break;
|
||||
case 5: // CNS
|
||||
if (info[i].size != 1)
|
||||
return DC_STATUS_DATAFORMAT;
|
||||
break;
|
||||
default: // Not yet used.
|
||||
break;
|
||||
}
|
||||
@ -419,6 +423,11 @@ hw_ostc_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t call
|
||||
sample.event.time = 0;
|
||||
sample.event.flags = 0;
|
||||
if (callback) callback (DC_SAMPLE_EVENT, sample, userdata);
|
||||
break;
|
||||
case 5: // CNS
|
||||
sample.cns = data[offset] / 100.0;
|
||||
if (callback) callback (DC_SAMPLE_CNS, sample, userdata);
|
||||
break;
|
||||
default: // Not yet used.
|
||||
break;
|
||||
}
|
||||
@ -429,6 +438,10 @@ hw_ostc_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t call
|
||||
|
||||
// SetPoint Change
|
||||
if (events & 0x40) {
|
||||
if (offset + 1 > size)
|
||||
return DC_STATUS_DATAFORMAT;
|
||||
sample.setpoint = data[offset] / 100.0;
|
||||
if (callback) callback (DC_SAMPLE_SETPOINT, sample, userdata);
|
||||
offset++;
|
||||
}
|
||||
}
|
||||
|
||||
@ -231,6 +231,10 @@ shearwater_predator_parser_samples_foreach (dc_parser_t *abstract, dc_sample_cal
|
||||
sample.temperature = temperature;
|
||||
if (callback) callback (DC_SAMPLE_TEMPERATURE, sample, userdata);
|
||||
|
||||
// PPO2
|
||||
sample.ppo2 = data[offset + 6] / 100.0;
|
||||
if (callback) callback (DC_SAMPLE_PPO2, sample, userdata);
|
||||
|
||||
// Gaschange.
|
||||
unsigned int o2 = data[offset + 7];
|
||||
unsigned int he = data[offset + 8];
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user