]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/mic-985xx/protocol.c
Build: Include <config.h> first in all source files
[libsigrok.git] / src / hardware / mic-985xx / protocol.c
index 6243db15ba5e5a4fe73e1af22d63809a835d347c..9e3d9863b3bbc1aa16392c920e8c6b68a041e448 100644 (file)
@@ -18,6 +18,7 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
+#include <config.h>
 #include "protocol.h"
 
 static int mic_send(struct sr_serial_dev_inst *serial, const char *cmd)
@@ -93,7 +94,10 @@ static int handle_packet(const uint8_t *buf, struct sr_dev_inst *sdi, int idx)
 {
        float temperature, humidity;
        struct sr_datafeed_packet packet;
-       struct sr_datafeed_analog analog;
+       struct sr_datafeed_analog2 analog;
+       struct sr_analog_encoding encoding;
+       struct sr_analog_meaning meaning;
+       struct sr_analog_spec spec;
        struct dev_context *devc;
        GSList *l;
        int ret;
@@ -108,20 +112,19 @@ static int handle_packet(const uint8_t *buf, struct sr_dev_inst *sdi, int idx)
                return SR_ERR;
        }
 
-       /* Clear 'analog', otherwise it'll contain random garbage. */
-       memset(&analog, 0, sizeof(struct sr_datafeed_analog));
+       sr_analog_init(&analog, &encoding, &meaning, &spec, 3);
 
        /* Common values for both channels. */
-       packet.type = SR_DF_ANALOG;
+       packet.type = SR_DF_ANALOG2;
        packet.payload = &analog;
        analog.num_samples = 1;
 
        /* Temperature. */
        l = g_slist_copy(sdi->channels);
        l = g_slist_remove_link(l, g_slist_nth(l, 1));
-       analog.channels = l;
-       analog.mq = SR_MQ_TEMPERATURE;
-       analog.unit = SR_UNIT_CELSIUS; /* TODO: Use C/F correctly. */
+       meaning.channels = l;
+       meaning.mq = SR_MQ_TEMPERATURE;
+       meaning.unit = SR_UNIT_CELSIUS; /* TODO: Use C/F correctly. */
        analog.data = &temperature;
        sr_session_send(devc->cb_data, &packet);
        g_slist_free(l);
@@ -130,9 +133,9 @@ static int handle_packet(const uint8_t *buf, struct sr_dev_inst *sdi, int idx)
        if (mic_devs[idx].has_humidity) {
                l = g_slist_copy(sdi->channels);
                l = g_slist_remove_link(l, g_slist_nth(l, 0));
-               analog.channels = l;
-               analog.mq = SR_MQ_RELATIVE_HUMIDITY;
-               analog.unit = SR_UNIT_PERCENTAGE;
+               meaning.channels = l;
+               meaning.mq = SR_MQ_RELATIVE_HUMIDITY;
+               meaning.unit = SR_UNIT_PERCENTAGE;
                analog.data = &humidity;
                sr_session_send(devc->cb_data, &packet);
                g_slist_free(l);