]> sigrok.org Git - libsigrok.git/commitdiff
serial-dmm: Convert to SR_DF_ANALOG.
authorUwe Hermann <redacted>
Sat, 28 May 2016 15:46:47 +0000 (17:46 +0200)
committerUwe Hermann <redacted>
Fri, 17 Jun 2016 13:13:11 +0000 (15:13 +0200)
src/hardware/serial-dmm/protocol.c
src/hardware/serial-dmm/protocol.h

index 3ea85be5461bc014938c4c37955fd72990ea3792..9c626a8a118fc14cc1e0cd58a7c4ec14090a30e8 100644 (file)
@@ -44,7 +44,10 @@ static void handle_packet(const uint8_t *buf, struct sr_dev_inst *sdi,
        struct dmm_info *dmm;
        float floatval;
        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;
        struct dev_context *devc;
 
        dmm = (struct dmm_info *)sdi->driver;
@@ -52,11 +55,11 @@ static void handle_packet(const uint8_t *buf, struct sr_dev_inst *sdi,
        log_dmm_packet(buf);
        devc = sdi->priv;
 
-       memset(&analog, 0, sizeof(struct sr_datafeed_analog_old));
+       sr_analog_init(&analog, &encoding, &meaning, &spec, 0);
 
-       analog.channels = sdi->channels;
+       analog.meaning->channels = sdi->channels;
        analog.num_samples = 1;
-       analog.mq = -1;
+       analog.meaning->mq = 0;
 
        dmm->packet_parse(buf, &floatval, &analog, info);
        analog.data = &floatval;
@@ -65,9 +68,9 @@ static void handle_packet(const uint8_t *buf, struct sr_dev_inst *sdi,
        if (dmm->dmm_details)
                dmm->dmm_details(&analog, info);
 
-       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->limits, 1);
index 8c21f9d975847dcce16cde3eb5866cef45b70edb..f8ecbb42b92174a93a27587fd976cec886ee03bd 100644 (file)
@@ -47,9 +47,9 @@ struct dmm_info {
        gboolean (*packet_valid)(const uint8_t *);
        /** Packet parsing function. */
        int (*packet_parse)(const uint8_t *, float *,
-                           struct sr_datafeed_analog_old *, void *);
+                           struct sr_datafeed_analog *, void *);
        /** */
-       void (*dmm_details)(struct sr_datafeed_analog_old *, void *);
+       void (*dmm_details)(struct sr_datafeed_analog *, void *);
        /** Size of chipset info struct. */
        gsize info_size;
 };