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

index 1a3c75dc591954cbd4a4dfeec3ad0b917063fabc..80b799d9e9dd1c08cf0590fa055af97729b957b6 100644 (file)
@@ -33,30 +33,36 @@ static void send_data(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;
        int i;
        float data[MAX_CHANNELS];
 
        devc = sdi->priv;
-       packet.type = SR_DF_ANALOG_OLD;
+       packet.type = SR_DF_ANALOG;
        packet.payload = &analog;
-       analog.channels = sdi->channels;
-       analog.num_samples = 1;
 
-       analog.mq = SR_MQ_VOLTAGE;
-       analog.unit = SR_UNIT_VOLT;
-       analog.mqflags = SR_MQFLAG_DC;
+       sr_analog_init(&analog, &encoding, &meaning, &spec, 0);
+
+       analog.meaning->channels = sdi->channels;
+       analog.num_samples = 1;
+       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++)
-               analog.data[i] = devc->channel_status[i].output_voltage_last; /* Value always 3.3 or 5 for channel 3, if present! */
+               ((float *)analog.data)[i] = devc->channel_status[i].output_voltage_last; /* Value always 3.3 or 5 for channel 3, if present! */
        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++)
-               analog.data[i] = devc->channel_status[i].output_current_last; /* Value always 0 for channel 3, if present! */
+               ((float *)analog.data)[i] = devc->channel_status[i].output_current_last; /* Value always 0 for channel 3, if present! */
        sr_session_send(sdi, &packet);
 
        sr_sw_limits_update_samples_read(&devc->limits, 1);