]> sigrok.org Git - libsigrok.git/commitdiff
Fix limit_samples check in various drivers.
authorUwe Hermann <redacted>
Wed, 26 Dec 2012 00:29:27 +0000 (01:29 +0100)
committerUwe Hermann <redacted>
Wed, 26 Dec 2012 01:11:00 +0000 (02:11 +0100)
Check whether a sample limit was actually set (> 0) before checking if
that sample limit is reached. This also fixes continuous acquisition mode
for drivers which have that.

hardware/agilent-dmm/sched.c
hardware/alsa/protocol.c
hardware/demo/demo.c
hardware/serial-dmm/protocol.c
hardware/tondaj-sl-814/protocol.c
hardware/uni-t-dmm/protocol.c

index 339dbac6aaf11e6a995c276c663d15fafc018cba..67c2a1b66330d01f29a7edc2c927ff192065216e 100644 (file)
@@ -119,7 +119,7 @@ SR_PRIV int agdmm_receive_data(int fd, int revents, void *cb_data)
 
        dispatch(sdi);
 
-       if (devc->num_samples >= devc->limit_samples)
+       if (devc->limit_samples && devc->num_samples >= devc->limit_samples)
                sdi->driver->dev_acquisition_stop(sdi, cb_data);
 
        return TRUE;
index ff6a3f85560b2ada21daf8a1231852b5e055506c..61b03cab757fd07ce745af587487accf526292ab 100644 (file)
@@ -83,11 +83,9 @@ SR_PRIV int alsa_receive_data(int fd, int revents, void *cb_data)
        devc->num_samples += count;
 
        /* Stop acquisition if we acquired enough samples. */
-       if (devc->limit_samples > 0) {
-               if (devc->num_samples >= devc->limit_samples) {
-                       sr_info("Requested number of samples reached.");
-                       sdi->driver->dev_acquisition_stop(sdi, 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);
        }
 
        return TRUE;
index 7238d84e04e6518a402a929fd43993a80c181afe..b02e668c01b020327a08b024c30c3e9fe4b81f94 100644 (file)
@@ -382,11 +382,8 @@ static int receive_data(int fd, int revents, void *cb_data)
                devc->samples_counter += sending_now;
        }
 
-
-       if (devc->samples_counter >= limit_samples) {
-               sr_spew("We sent a total of %" PRIu64 " samples.",
-                       devc->samples_counter);
-               /* Make sure we don't receive more packets. */
+       if (limit_samples && devc->samples_counter >= limit_samples) {
+               sr_info("Requested number of samples reached.");
                hw_dev_acquisition_stop(NULL, cb_data);
                return TRUE;
        }
index 9524f2bd92dbfee13a591584f67bd36d9956b994..19b355386cc7bd7471933d6ca7009d124a73a655 100644 (file)
@@ -179,7 +179,7 @@ static int receive_data(int fd, int revents, int dmm, void *info, void *cb_data)
        }
 
        if (devc->limit_samples && devc->num_samples >= devc->limit_samples) {
-               sr_info("Requested number of samples reached, stopping.");
+               sr_info("Requested number of samples reached.");
                sdi->driver->dev_acquisition_stop(sdi, cb_data);
                return TRUE;
        }
@@ -187,7 +187,7 @@ static int receive_data(int fd, int revents, int dmm, void *info, void *cb_data)
        if (devc->limit_msec) {
                time = (g_get_monotonic_time() - devc->starttime) / 1000;
                if (time > (int64_t)devc->limit_msec) {
-                       sr_info("Requested time limit reached, stopping.");
+                       sr_info("Requested time limit reached.");
                        sdi->driver->dev_acquisition_stop(sdi, cb_data);
                        return TRUE;
                }
index 57472520aa30313fbf33d9ec96423a5660581864..e20351ac940f32e6a75636b71a666fb0f2142288 100644 (file)
@@ -194,11 +194,9 @@ int tondaj_sl_814_receive_data(int fd, int revents, void *cb_data)
        }
 
        /* Stop acquisition if we acquired enough samples. */
-       if (devc->limit_samples > 0) {
-               if (devc->num_samples >= devc->limit_samples) {
-                       sr_info("Requested number of samples reached.");
-                       sdi->driver->dev_acquisition_stop(sdi, 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);
        }
 
        return TRUE;
index a4b69403f878e5c625295a04ce08fd3d72d0d513..55f573afdcb0e18e1216cf0c391016396f77bc21 100644 (file)
@@ -264,7 +264,7 @@ static int uni_t_dmm_receive_data(int fd, int revents, int dmm, void *cb_data)
        }
 
        /* Abort acquisition if we acquired enough samples. */
-       if (devc->num_samples >= devc->limit_samples && devc->limit_samples > 0) {
+       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);
        }