X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fvictor-dmm%2Fprotocol.c;h=13a9befa2322f636b7b7d4c3b3b194d048d91a60;hb=0f33aaef545e7289a02dc8115b282b24bb16fc27;hp=6af51419326694c6241c349b850bb5c04a70a393;hpb=155b680da482cea2381becb73c51cfb838bff31e;p=libsigrok.git
diff --git a/src/hardware/victor-dmm/protocol.c b/src/hardware/victor-dmm/protocol.c
index 6af51419..13a9befa 100644
--- a/src/hardware/victor-dmm/protocol.c
+++ b/src/hardware/victor-dmm/protocol.c
@@ -17,10 +17,11 @@
* along with this program. If not, see .
*/
+#include
#include
#include
#include
-#include "libsigrok.h"
+#include
#include "libsigrok-internal.h"
#include "protocol.h"
@@ -44,6 +45,9 @@ static void decode_buf(struct sr_dev_inst *sdi, unsigned char *data)
{
struct sr_datafeed_packet packet;
struct sr_datafeed_analog analog;
+ struct sr_analog_encoding encoding;
+ struct sr_analog_meaning meaning;
+ struct sr_analog_spec spec;
struct dev_context *devc;
long factor, ivalue;
uint8_t digits[4];
@@ -164,52 +168,53 @@ static void decode_buf(struct sr_dev_inst *sdi, unsigned char *data)
if (minus)
fvalue = -fvalue;
- memset(&analog, 0, sizeof(struct sr_datafeed_analog));
+ sr_analog_init(&analog, &encoding, &meaning, &spec, 4);
/* Measurement mode */
- analog.mq = -1;
+ meaning.channels = sdi->channels;
+ meaning.mq = 0;
switch (data[3]) {
case 0x00:
if (is_duty) {
- analog.mq = SR_MQ_DUTY_CYCLE;
- analog.unit = SR_UNIT_PERCENTAGE;
+ meaning.mq = SR_MQ_DUTY_CYCLE;
+ meaning.unit = SR_UNIT_PERCENTAGE;
} else
sr_dbg("Unknown measurement mode: %.2x.", data[3]);
break;
case 0x01:
if (is_diode) {
- analog.mq = SR_MQ_VOLTAGE;
- analog.unit = SR_UNIT_VOLT;
- analog.mqflags |= SR_MQFLAG_DIODE;
+ meaning.mq = SR_MQ_VOLTAGE;
+ meaning.unit = SR_UNIT_VOLT;
+ meaning.mqflags |= SR_MQFLAG_DIODE;
if (ivalue < 0)
fvalue = NAN;
} else {
if (ivalue < 0)
break;
- analog.mq = SR_MQ_VOLTAGE;
- analog.unit = SR_UNIT_VOLT;
+ meaning.mq = SR_MQ_VOLTAGE;
+ meaning.unit = SR_UNIT_VOLT;
if (is_ac)
- analog.mqflags |= SR_MQFLAG_AC;
+ meaning.mqflags |= SR_MQFLAG_AC;
if (is_dc)
- analog.mqflags |= SR_MQFLAG_DC;
+ meaning.mqflags |= SR_MQFLAG_DC;
}
break;
case 0x02:
- analog.mq = SR_MQ_CURRENT;
- analog.unit = SR_UNIT_AMPERE;
+ meaning.mq = SR_MQ_CURRENT;
+ meaning.unit = SR_UNIT_AMPERE;
if (is_ac)
- analog.mqflags |= SR_MQFLAG_AC;
+ meaning.mqflags |= SR_MQFLAG_AC;
if (is_dc)
- analog.mqflags |= SR_MQFLAG_DC;
+ meaning.mqflags |= SR_MQFLAG_DC;
break;
case 0x04:
if (is_continuity) {
- analog.mq = SR_MQ_CONTINUITY;
- analog.unit = SR_UNIT_BOOLEAN;
+ meaning.mq = SR_MQ_CONTINUITY;
+ meaning.unit = SR_UNIT_BOOLEAN;
fvalue = ivalue < 0 ? 0.0 : 1.0;
} else {
- analog.mq = SR_MQ_RESISTANCE;
- analog.unit = SR_UNIT_OHM;
+ meaning.mq = SR_MQ_RESISTANCE;
+ meaning.unit = SR_UNIT_OHM;
if (ivalue < 0)
fvalue = INFINITY;
}
@@ -219,47 +224,47 @@ static void decode_buf(struct sr_dev_inst *sdi, unsigned char *data)
sr_dbg("Unknown measurement mode: 0x%.2x.", data[3]);
break;
case 0x10:
- analog.mq = SR_MQ_FREQUENCY;
- analog.unit = SR_UNIT_HERTZ;
+ meaning.mq = SR_MQ_FREQUENCY;
+ meaning.unit = SR_UNIT_HERTZ;
break;
case 0x20:
- analog.mq = SR_MQ_CAPACITANCE;
- analog.unit = SR_UNIT_FARAD;
+ meaning.mq = SR_MQ_CAPACITANCE;
+ meaning.unit = SR_UNIT_FARAD;
break;
case 0x40:
- analog.mq = SR_MQ_TEMPERATURE;
- analog.unit = SR_UNIT_CELSIUS;
+ meaning.mq = SR_MQ_TEMPERATURE;
+ meaning.unit = SR_UNIT_CELSIUS;
break;
case 0x80:
- analog.mq = SR_MQ_TEMPERATURE;
- analog.unit = SR_UNIT_FAHRENHEIT;
+ meaning.mq = SR_MQ_TEMPERATURE;
+ meaning.unit = SR_UNIT_FAHRENHEIT;
break;
default:
sr_dbg("Unknown/invalid measurement mode: 0x%.2x.", data[3]);
break;
}
- if (analog.mq == -1)
+ if (meaning.mq == 0)
return;
if (is_auto)
- analog.mqflags |= SR_MQFLAG_AUTORANGE;
+ meaning.mqflags |= SR_MQFLAG_AUTORANGE;
if (is_hold)
- analog.mqflags |= SR_MQFLAG_HOLD;
+ meaning.mqflags |= SR_MQFLAG_HOLD;
if (is_max)
- analog.mqflags |= SR_MQFLAG_MAX;
+ meaning.mqflags |= SR_MQFLAG_MAX;
if (is_min)
- analog.mqflags |= SR_MQFLAG_MIN;
+ meaning.mqflags |= SR_MQFLAG_MIN;
if (is_relative)
- analog.mqflags |= SR_MQFLAG_RELATIVE;
+ meaning.mqflags |= SR_MQFLAG_RELATIVE;
- analog.channels = sdi->channels;
- analog.num_samples = 1;
analog.data = &fvalue;
+ analog.num_samples = 1;
+
packet.type = SR_DF_ANALOG;
packet.payload = &analog;
- sr_session_send(devc->cb_data, &packet);
+ sr_session_send(sdi, &packet);
- devc->num_samples++;
+ sr_sw_limits_update_samples_read(&devc->limits, 1);
}
SR_PRIV int victor_dmm_receive_data(struct sr_dev_inst *sdi, unsigned char *buf)