brymen-dmm: Convert to SR_DF_ANALOG.
This commit is contained in:
parent
a46f869b64
commit
1653c4309a
|
@ -192,7 +192,7 @@ static void parse_flags(const uint8_t *buf, struct brymen_flags *info)
|
||||||
}
|
}
|
||||||
|
|
||||||
SR_PRIV int brymen_parse(const uint8_t *buf, float *floatval,
|
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_flags flags;
|
||||||
struct brymen_header *hdr;
|
struct brymen_header *hdr;
|
||||||
|
@ -204,7 +204,7 @@ SR_PRIV int brymen_parse(const uint8_t *buf, float *floatval,
|
||||||
hdr = (void *)buf;
|
hdr = (void *)buf;
|
||||||
bfunc = (uint8_t *)(buf + sizeof(struct brymen_header));
|
bfunc = (uint8_t *)(buf + sizeof(struct brymen_header));
|
||||||
|
|
||||||
analog->mqflags = 0;
|
analog->meaning->mqflags = 0;
|
||||||
|
|
||||||
/* Give some debug info about the package. */
|
/* Give some debug info about the package. */
|
||||||
asciilen = hdr->len - 4;
|
asciilen = hdr->len - 4;
|
||||||
|
@ -218,43 +218,43 @@ SR_PRIV int brymen_parse(const uint8_t *buf, float *floatval,
|
||||||
return SR_ERR;
|
return SR_ERR;
|
||||||
|
|
||||||
if (flags.is_volt) {
|
if (flags.is_volt) {
|
||||||
analog->mq = SR_MQ_VOLTAGE;
|
analog->meaning->mq = SR_MQ_VOLTAGE;
|
||||||
analog->unit = SR_UNIT_VOLT;
|
analog->meaning->unit = SR_UNIT_VOLT;
|
||||||
}
|
}
|
||||||
if (flags.is_amp) {
|
if (flags.is_amp) {
|
||||||
analog->mq = SR_MQ_CURRENT;
|
analog->meaning->mq = SR_MQ_CURRENT;
|
||||||
analog->unit = SR_UNIT_AMPERE;
|
analog->meaning->unit = SR_UNIT_AMPERE;
|
||||||
}
|
}
|
||||||
if (flags.is_ohm) {
|
if (flags.is_ohm) {
|
||||||
if (flags.is_beep)
|
if (flags.is_beep)
|
||||||
analog->mq = SR_MQ_CONTINUITY;
|
analog->meaning->mq = SR_MQ_CONTINUITY;
|
||||||
else
|
else
|
||||||
analog->mq = SR_MQ_RESISTANCE;
|
analog->meaning->mq = SR_MQ_RESISTANCE;
|
||||||
analog->unit = SR_UNIT_OHM;
|
analog->meaning->unit = SR_UNIT_OHM;
|
||||||
}
|
}
|
||||||
if (flags.is_hertz) {
|
if (flags.is_hertz) {
|
||||||
analog->mq = SR_MQ_FREQUENCY;
|
analog->meaning->mq = SR_MQ_FREQUENCY;
|
||||||
analog->unit = SR_UNIT_HERTZ;
|
analog->meaning->unit = SR_UNIT_HERTZ;
|
||||||
}
|
}
|
||||||
if (flags.is_duty_cycle) {
|
if (flags.is_duty_cycle) {
|
||||||
analog->mq = SR_MQ_DUTY_CYCLE;
|
analog->meaning->mq = SR_MQ_DUTY_CYCLE;
|
||||||
analog->unit = SR_UNIT_PERCENTAGE;
|
analog->meaning->unit = SR_UNIT_PERCENTAGE;
|
||||||
}
|
}
|
||||||
if (flags.is_capacitance) {
|
if (flags.is_capacitance) {
|
||||||
analog->mq = SR_MQ_CAPACITANCE;
|
analog->meaning->mq = SR_MQ_CAPACITANCE;
|
||||||
analog->unit = SR_UNIT_FARAD;
|
analog->meaning->unit = SR_UNIT_FARAD;
|
||||||
}
|
}
|
||||||
if (flags.is_fahrenheit) {
|
if (flags.is_fahrenheit) {
|
||||||
analog->mq = SR_MQ_TEMPERATURE;
|
analog->meaning->mq = SR_MQ_TEMPERATURE;
|
||||||
analog->unit = SR_UNIT_FAHRENHEIT;
|
analog->meaning->unit = SR_UNIT_FAHRENHEIT;
|
||||||
}
|
}
|
||||||
if (flags.is_celsius) {
|
if (flags.is_celsius) {
|
||||||
analog->mq = SR_MQ_TEMPERATURE;
|
analog->meaning->mq = SR_MQ_TEMPERATURE;
|
||||||
analog->unit = SR_UNIT_CELSIUS;
|
analog->meaning->unit = SR_UNIT_CELSIUS;
|
||||||
}
|
}
|
||||||
if (flags.is_capacitance) {
|
if (flags.is_capacitance) {
|
||||||
analog->mq = SR_MQ_CAPACITANCE;
|
analog->meaning->mq = SR_MQ_CAPACITANCE;
|
||||||
analog->unit = SR_UNIT_FARAD;
|
analog->meaning->unit = SR_UNIT_FARAD;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -265,8 +265,8 @@ SR_PRIV int brymen_parse(const uint8_t *buf, float *floatval,
|
||||||
* identify the value as ohm, not dBmW.
|
* identify the value as ohm, not dBmW.
|
||||||
*/
|
*/
|
||||||
if (flags.is_decibel && !flags.is_ohm) {
|
if (flags.is_decibel && !flags.is_ohm) {
|
||||||
analog->mq = SR_MQ_POWER;
|
analog->meaning->mq = SR_MQ_POWER;
|
||||||
analog->unit = SR_UNIT_DECIBEL_MW;
|
analog->meaning->unit = SR_UNIT_DECIBEL_MW;
|
||||||
/*
|
/*
|
||||||
* For some reason, dBm measurements are sent by the multimeter
|
* For some reason, dBm measurements are sent by the multimeter
|
||||||
* with a value three orders of magnitude smaller than the
|
* with a value three orders of magnitude smaller than the
|
||||||
|
@ -276,12 +276,12 @@ SR_PRIV int brymen_parse(const uint8_t *buf, float *floatval,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags.is_diode)
|
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. */
|
/* We can have both AC+DC in a single measurement. */
|
||||||
if (flags.is_ac)
|
if (flags.is_ac)
|
||||||
analog->mqflags |= SR_MQFLAG_AC;
|
analog->meaning->mqflags |= SR_MQFLAG_AC;
|
||||||
if (flags.is_dc)
|
if (flags.is_dc)
|
||||||
analog->mqflags |= SR_MQFLAG_DC;
|
analog->meaning->mqflags |= SR_MQFLAG_DC;
|
||||||
|
|
||||||
if (flags.is_low_batt)
|
if (flags.is_low_batt)
|
||||||
sr_info("Low battery!");
|
sr_info("Low battery!");
|
||||||
|
|
|
@ -25,22 +25,27 @@ static void handle_packet(const uint8_t *buf, struct sr_dev_inst *sdi)
|
||||||
float floatval;
|
float floatval;
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
struct sr_datafeed_packet packet;
|
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;
|
devc = sdi->priv;
|
||||||
|
|
||||||
|
sr_analog_init(&analog, &encoding, &meaning, &spec, 0);
|
||||||
|
|
||||||
analog.num_samples = 1;
|
analog.num_samples = 1;
|
||||||
analog.mq = -1;
|
analog.meaning->mq = 0;
|
||||||
|
|
||||||
if (brymen_parse(buf, &floatval, &analog, NULL) != SR_OK)
|
if (brymen_parse(buf, &floatval, &analog, NULL) != SR_OK)
|
||||||
return;
|
return;
|
||||||
analog.data = &floatval;
|
analog.data = &floatval;
|
||||||
|
|
||||||
analog.channels = sdi->channels;
|
analog.meaning->channels = sdi->channels;
|
||||||
|
|
||||||
if (analog.mq != -1) {
|
if (analog.meaning->mq != 0) {
|
||||||
/* Got a measurement. */
|
/* Got a measurement. */
|
||||||
packet.type = SR_DF_ANALOG_OLD;
|
packet.type = SR_DF_ANALOG;
|
||||||
packet.payload = &analog;
|
packet.payload = &analog;
|
||||||
sr_session_send(sdi, &packet);
|
sr_session_send(sdi, &packet);
|
||||||
sr_sw_limits_update_samples_read(&devc->sw_limits, 1);
|
sr_sw_limits_update_samples_read(&devc->sw_limits, 1);
|
||||||
|
|
|
@ -64,7 +64,7 @@ SR_PRIV int brymen_packet_length(const uint8_t *buf, int *len);
|
||||||
SR_PRIV gboolean brymen_packet_is_valid(const uint8_t *buf);
|
SR_PRIV gboolean brymen_packet_is_valid(const uint8_t *buf);
|
||||||
|
|
||||||
SR_PRIV int brymen_parse(const uint8_t *buf, float *floatval,
|
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);
|
||||||
|
|
||||||
SR_PRIV int brymen_stream_detect(struct sr_serial_dev_inst *serial,
|
SR_PRIV int brymen_stream_detect(struct sr_serial_dev_inst *serial,
|
||||||
uint8_t *buf, size_t *buflen,
|
uint8_t *buf, size_t *buflen,
|
||||||
|
|
Loading…
Reference in New Issue