]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/manson-hcs-3xxx/protocol.c
device.c: Whitespace/cosmetics and typo fixes.
[libsigrok.git] / src / hardware / manson-hcs-3xxx / protocol.c
index 5fa53d29ab38d0f5233c085e8c5ec23b3197f1cd..04e18a5fee96297f706f0af7ff8fec428db78479 100644 (file)
@@ -123,28 +123,34 @@ static void send_sample(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;
 
        devc = sdi->priv;
 
-       packet.type = SR_DF_ANALOG_OLD;
+       sr_analog_init(&analog, &encoding, &meaning, &spec, 2);
+
+       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 = &devc->voltage;
        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 = &devc->current;
        sr_session_send(sdi, &packet);
 
-       devc->num_samples++;
+
+       sr_sw_limits_update_samples_read(&devc->limits, 1);
 }
 
 static int parse_reply(struct sr_dev_inst *sdi)
@@ -206,7 +212,7 @@ SR_PRIV int hcs_receive_data(int fd, int revents, void *cb_data)
        struct sr_dev_inst *sdi;
        struct dev_context *devc;
        struct sr_serial_dev_inst *serial;
-       int64_t t, elapsed_us;
+       uint64_t elapsed_us;
 
        (void)fd;
 
@@ -225,21 +231,11 @@ SR_PRIV int hcs_receive_data(int fd, int revents, void *cb_data)
                /* Timeout. */
        }
 
-       if (devc->limit_samples && (devc->num_samples >= devc->limit_samples)) {
-               sr_info("Requested number of samples reached.");
+       if (sr_sw_limits_check(&devc->limits)) {
                sdi->driver->dev_acquisition_stop(sdi);
                return TRUE;
        }
 
-       if (devc->limit_msec) {
-               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);
-                       return TRUE;
-               }
-       }
-
        /* Request next packet, if required. */
        if (sdi->status == SR_ST_ACTIVE) {
                if (devc->reply_pending) {