}
SR_PRIV int brymen_parse(const uint8_t *buf, float *floatval,
- struct sr_datafeed_analog_old *analog, void *info)
+ struct sr_datafeed_analog *analog, void *info)
{
struct brymen_flags flags;
struct brymen_header *hdr;
hdr = (void *)buf;
bfunc = (uint8_t *)(buf + sizeof(struct brymen_header));
- analog->mqflags = 0;
+ analog->meaning->mqflags = 0;
/* Give some debug info about the package. */
asciilen = hdr->len - 4;
return SR_ERR;
if (flags.is_volt) {
- analog->mq = SR_MQ_VOLTAGE;
- analog->unit = SR_UNIT_VOLT;
+ analog->meaning->mq = SR_MQ_VOLTAGE;
+ analog->meaning->unit = SR_UNIT_VOLT;
}
if (flags.is_amp) {
- analog->mq = SR_MQ_CURRENT;
- analog->unit = SR_UNIT_AMPERE;
+ analog->meaning->mq = SR_MQ_CURRENT;
+ analog->meaning->unit = SR_UNIT_AMPERE;
}
if (flags.is_ohm) {
if (flags.is_beep)
- analog->mq = SR_MQ_CONTINUITY;
+ analog->meaning->mq = SR_MQ_CONTINUITY;
else
- analog->mq = SR_MQ_RESISTANCE;
- analog->unit = SR_UNIT_OHM;
+ analog->meaning->mq = SR_MQ_RESISTANCE;
+ analog->meaning->unit = SR_UNIT_OHM;
}
if (flags.is_hertz) {
- analog->mq = SR_MQ_FREQUENCY;
- analog->unit = SR_UNIT_HERTZ;
+ analog->meaning->mq = SR_MQ_FREQUENCY;
+ analog->meaning->unit = SR_UNIT_HERTZ;
}
if (flags.is_duty_cycle) {
- analog->mq = SR_MQ_DUTY_CYCLE;
- analog->unit = SR_UNIT_PERCENTAGE;
+ analog->meaning->mq = SR_MQ_DUTY_CYCLE;
+ analog->meaning->unit = SR_UNIT_PERCENTAGE;
}
if (flags.is_capacitance) {
- analog->mq = SR_MQ_CAPACITANCE;
- analog->unit = SR_UNIT_FARAD;
+ analog->meaning->mq = SR_MQ_CAPACITANCE;
+ analog->meaning->unit = SR_UNIT_FARAD;
}
if (flags.is_fahrenheit) {
- analog->mq = SR_MQ_TEMPERATURE;
- analog->unit = SR_UNIT_FAHRENHEIT;
+ analog->meaning->mq = SR_MQ_TEMPERATURE;
+ analog->meaning->unit = SR_UNIT_FAHRENHEIT;
}
if (flags.is_celsius) {
- analog->mq = SR_MQ_TEMPERATURE;
- analog->unit = SR_UNIT_CELSIUS;
+ analog->meaning->mq = SR_MQ_TEMPERATURE;
+ analog->meaning->unit = SR_UNIT_CELSIUS;
}
if (flags.is_capacitance) {
- analog->mq = SR_MQ_CAPACITANCE;
- analog->unit = SR_UNIT_FARAD;
+ analog->meaning->mq = SR_MQ_CAPACITANCE;
+ analog->meaning->unit = SR_UNIT_FARAD;
}
/*
* identify the value as ohm, not dBmW.
*/
if (flags.is_decibel && !flags.is_ohm) {
- analog->mq = SR_MQ_POWER;
- analog->unit = SR_UNIT_DECIBEL_MW;
+ analog->meaning->mq = SR_MQ_POWER;
+ analog->meaning->unit = SR_UNIT_DECIBEL_MW;
/*
* For some reason, dBm measurements are sent by the multimeter
* with a value three orders of magnitude smaller than the
}
if (flags.is_diode)
- analog->mqflags |= SR_MQFLAG_DIODE;
+ analog->meaning->mqflags |= SR_MQFLAG_DIODE;
/* We can have both AC+DC in a single measurement. */
if (flags.is_ac)
- analog->mqflags |= SR_MQFLAG_AC;
+ analog->meaning->mqflags |= SR_MQFLAG_AC;
if (flags.is_dc)
- analog->mqflags |= SR_MQFLAG_DC;
+ analog->meaning->mqflags |= SR_MQFLAG_DC;
if (flags.is_low_batt)
sr_info("Low battery!");
float floatval;
struct dev_context *devc;
struct sr_datafeed_packet packet;
- struct sr_datafeed_analog_old analog;
+ struct sr_datafeed_analog analog;
+ struct sr_analog_encoding encoding;
+ struct sr_analog_meaning meaning;
+ struct sr_analog_spec spec;
devc = sdi->priv;
+ sr_analog_init(&analog, &encoding, &meaning, &spec, 0);
+
analog.num_samples = 1;
- analog.mq = -1;
+ analog.meaning->mq = 0;
if (brymen_parse(buf, &floatval, &analog, NULL) != SR_OK)
return;
analog.data = &floatval;
- analog.channels = sdi->channels;
+ analog.meaning->channels = sdi->channels;
- if (analog.mq != -1) {
+ if (analog.meaning->mq != 0) {
/* Got a measurement. */
- packet.type = SR_DF_ANALOG_OLD;
+ packet.type = SR_DF_ANALOG;
packet.payload = &analog;
sr_session_send(sdi, &packet);
sr_sw_limits_update_samples_read(&devc->sw_limits, 1);