]> sigrok.org Git - libsigrok.git/commitdiff
atten-pps3xxx: Convert to SR_DF_ANALOG.
authorUwe Hermann <redacted>
Sat, 14 May 2016 15:18:44 +0000 (17:18 +0200)
committerUwe Hermann <redacted>
Thu, 16 Jun 2016 13:05:02 +0000 (15:05 +0200)
src/hardware/atten-pps3xxx/protocol.c

index 72b4a03ec5d4d9dc82e7777af14baf77627db97f..0d65f8696138f577570f3ed893c863ef58f311da 100644 (file)
@@ -37,37 +37,43 @@ static void handle_packet(const struct sr_dev_inst *sdi)
 {
        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;
        float value, data[MAX_CHANNELS];
        int offset, i;
 
        devc = sdi->priv;
        dump_packet("received", devc->packet);
-       packet.type = SR_DF_ANALOG_OLD;
+
+       sr_analog_init(&analog, &encoding, &meaning, &spec, 0);
+
+       packet.type = SR_DF_ANALOG;
        packet.payload = &analog;
-       analog.channels = sdi->channels;
+       analog.meaning->channels = sdi->channels;
        analog.num_samples = 1;
 
-       analog.mq = SR_MQ_VOLTAGE;
-       analog.unit = SR_UNIT_VOLT;
-       analog.mqflags = SR_MQFLAG_DC;
+       analog.meaning->mq = SR_MQ_VOLTAGE;
+       analog.meaning->unit = SR_UNIT_VOLT;
+       analog.meaning->mqflags = SR_MQFLAG_DC;
        analog.data = data;
        for (i = 0; i < devc->model->num_channels; i++) {
                offset = 2 + i * 4;
                value = ((devc->packet[offset] << 8) + devc->packet[offset + 1]) / 100.0;
-               analog.data[i] = value;
+               ((float *)analog.data)[i] = value;
                devc->config[i].output_voltage_last = value;
        }
        sr_session_send(sdi, &packet);
 
-       analog.mq = SR_MQ_CURRENT;
-       analog.unit = SR_UNIT_AMPERE;
-       analog.mqflags = 0;
+       analog.meaning->mq = SR_MQ_CURRENT;
+       analog.meaning->unit = SR_UNIT_AMPERE;
+       analog.meaning->mqflags = 0;
        analog.data = data;
        for (i = 0; i < devc->model->num_channels; i++) {
                offset = 4 + i * 4;
                value = ((devc->packet[offset] << 8) + devc->packet[offset + 1]) / 1000.0;
-               analog.data[i] = value;
+               ((float *)analog.data)[i] = value;
                devc->config[i].output_current_last = value;
        }
        sr_session_send(sdi, &packet);