]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/mic-985xx/protocol.c
dev_acquisition_{start,stop}(): Drop duplicate 'cb_data' parameter.
[libsigrok.git] / src / hardware / mic-985xx / protocol.c
index 9e3d9863b3bbc1aa16392c920e8c6b68a041e448..151b7c837af7cbf8f021c5c900c0e2fea0848f62 100644 (file)
@@ -25,7 +25,8 @@ static int mic_send(struct sr_serial_dev_inst *serial, const char *cmd)
 {
        int ret;
 
-       if ((ret = serial_write_blocking(serial, cmd, strlen(cmd), 0)) < 0) {
+       if ((ret = serial_write_blocking(serial, cmd, strlen(cmd),
+                       serial_timeout(serial, strlen(cmd)))) < 0) {
                sr_err("Error sending '%s' command: %d.", cmd, ret);
                return SR_ERR;
        }
@@ -94,7 +95,7 @@ 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_analog2 analog;
+       struct sr_datafeed_analog analog;
        struct sr_analog_encoding encoding;
        struct sr_analog_meaning meaning;
        struct sr_analog_spec spec;
@@ -115,7 +116,7 @@ static int handle_packet(const uint8_t *buf, struct sr_dev_inst *sdi, int idx)
        sr_analog_init(&analog, &encoding, &meaning, &spec, 3);
 
        /* Common values for both channels. */
-       packet.type = SR_DF_ANALOG2;
+       packet.type = SR_DF_ANALOG;
        packet.payload = &analog;
        analog.num_samples = 1;
 
@@ -126,7 +127,7 @@ static int handle_packet(const uint8_t *buf, struct sr_dev_inst *sdi, int idx)
        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);
+       sr_session_send(sdi, &packet);
        g_slist_free(l);
 
        /* Humidity. */
@@ -137,7 +138,7 @@ static int handle_packet(const uint8_t *buf, struct sr_dev_inst *sdi, int idx)
                meaning.mq = SR_MQ_RELATIVE_HUMIDITY;
                meaning.unit = SR_UNIT_PERCENTAGE;
                analog.data = &humidity;
-               sr_session_send(devc->cb_data, &packet);
+               sr_session_send(sdi, &packet);
                g_slist_free(l);
        }
 
@@ -212,7 +213,7 @@ static int receive_data(int fd, int revents, int idx, void *cb_data)
 
        if (devc->limit_samples && devc->num_samples >= devc->limit_samples) {
                sr_info("Requested number of samples reached.");
-               sdi->driver->dev_acquisition_stop(sdi, cb_data);
+               sdi->driver->dev_acquisition_stop(sdi);
                return TRUE;
        }
 
@@ -220,7 +221,7 @@ static int receive_data(int fd, int revents, int idx, void *cb_data)
                t = (g_get_monotonic_time() - devc->starttime) / 1000;
                if (t > (int64_t)devc->limit_msec) {
                        sr_info("Requested time limit reached.");
-                       sdi->driver->dev_acquisition_stop(sdi, cb_data);
+                       sdi->driver->dev_acquisition_stop(sdi);
                        return TRUE;
                }
        }