]> sigrok.org Git - libsigrok.git/commitdiff
brymen-dmm: Convert to SR_DF_ANALOG.
authorUwe Hermann <redacted>
Sat, 14 May 2016 15:30:10 +0000 (17:30 +0200)
committerUwe Hermann <redacted>
Thu, 16 Jun 2016 13:05:03 +0000 (15:05 +0200)
src/hardware/brymen-dmm/parser.c
src/hardware/brymen-dmm/protocol.c
src/hardware/brymen-dmm/protocol.h

index aaa2c3f48f5295ba1be973c50d2114ea6d6a2041..a5e8333a6a004e3f3eda0d489a2bd0abc2695378 100644 (file)
@@ -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,
-               struct sr_datafeed_analog_old *analog, void *info)
+               struct sr_datafeed_analog *analog, void *info)
 {
        struct brymen_flags flags;
        struct brymen_header *hdr;
@@ -204,7 +204,7 @@ SR_PRIV int brymen_parse(const uint8_t *buf, float *floatval,
        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;
@@ -218,43 +218,43 @@ SR_PRIV int brymen_parse(const uint8_t *buf, float *floatval,
                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;
        }
 
        /*
@@ -265,8 +265,8 @@ SR_PRIV int brymen_parse(const uint8_t *buf, float *floatval,
         * 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
@@ -276,12 +276,12 @@ SR_PRIV int brymen_parse(const uint8_t *buf, float *floatval,
        }
 
        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!");
index 3e1b84c421834030b777fe1b9fd7ee347bbd5e2f..4cd61ad694f52cd8eee326402d7c1ac9c92f8314 100644 (file)
@@ -25,22 +25,27 @@ static void handle_packet(const uint8_t *buf, struct sr_dev_inst *sdi)
        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);
index be26cb965dc628a2b3dcd64cd5bd4d7080becc72..7e02180ec1de3e31005150da0da185a70602f14e 100644 (file)
@@ -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 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,
                                 uint8_t *buf, size_t *buflen,