]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/tondaj-sl-814/protocol.c
Fix a few "variable set but not used" compiler warnings.
[libsigrok.git] / src / hardware / tondaj-sl-814 / protocol.c
index a3696b69e79eb1b5e394f6e4dc35d708b8e693b4..d400758a81d221d6e4982c1c693a87477d178200 100644 (file)
@@ -34,7 +34,7 @@ enum {
 };
 
 static void parse_packet(const uint8_t *buf, float *floatval,
-                        struct sr_datafeed_analog *analog)
+                        struct sr_datafeed_analog_old *analog)
 {
        gboolean is_a, is_fast;
        uint16_t intval;
@@ -89,12 +89,12 @@ static void parse_packet(const uint8_t *buf, float *floatval,
 static void decode_packet(struct sr_dev_inst *sdi)
 {
        struct sr_datafeed_packet packet;
-       struct sr_datafeed_analog analog;
+       struct sr_datafeed_analog_old analog;
        struct dev_context *devc;
        float floatval;
 
        devc = sdi->priv;
-       memset(&analog, 0, sizeof(struct sr_datafeed_analog));
+       memset(&analog, 0, sizeof(struct sr_datafeed_analog_old));
 
        parse_packet(devc->buf, &floatval, &analog);
 
@@ -102,11 +102,11 @@ static void decode_packet(struct sr_dev_inst *sdi)
        analog.channels = sdi->channels;
        analog.num_samples = 1;
        analog.data = &floatval;
-       packet.type = SR_DF_ANALOG;
+       packet.type = SR_DF_ANALOG_OLD;
        packet.payload = &analog;
-       sr_session_send(devc->cb_data, &packet);
+       sr_session_send(sdi, &packet);
 
-       devc->num_samples++;
+       sr_sw_limits_update_samples_read(&devc->limits, 1);
 }
 
 SR_PRIV int tondaj_sl_814_receive_data(int fd, int revents, void *cb_data)
@@ -134,7 +134,8 @@ SR_PRIV int tondaj_sl_814_receive_data(int fd, int revents, void *cb_data)
                buf[2] = 0x0d;
                sr_spew("Sending init command: %02x %02x %02x.",
                        buf[0], buf[1], buf[2]);
-               if ((ret = serial_write_blocking(serial, buf, 3, 0)) < 0) {
+               if ((ret = serial_write_blocking(serial, buf, 3,
+                               serial_timeout(serial, 3))) < 0) {
                        sr_err("Error sending init command: %d.", ret);
                        return FALSE;
                }
@@ -160,7 +161,8 @@ SR_PRIV int tondaj_sl_814_receive_data(int fd, int revents, void *cb_data)
                buf[2] = 0x0d;
                sr_spew("Sending data request command: %02x %02x %02x.",
                        buf[0], buf[1], buf[2]);
-               if ((ret = serial_write_blocking(serial, buf, 3, 0)) < 0) {
+               if ((ret = serial_write_blocking(serial, buf, 3,
+                               serial_timeout(serial, 3))) < 0) {
                        sr_err("Error sending request command: %d.", ret);
                        return FALSE;
                }
@@ -199,11 +201,8 @@ SR_PRIV int tondaj_sl_814_receive_data(int fd, int revents, void *cb_data)
                return FALSE;
        }
 
-       /* Stop acquisition if we acquired enough samples. */
-       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);
-       }
+       if (sr_sw_limits_check(&devc->limits))
+               sdi->driver->dev_acquisition_stop(sdi);
 
        return TRUE;
 }