From: Uwe Hermann Date: Wed, 26 Dec 2012 00:29:27 +0000 (+0100) Subject: Fix limit_samples check in various drivers. X-Git-Tag: dsupstream~405 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=35e199da505f5b8fadffa58875aaca70a8fde4f2;p=libsigrok.git Fix limit_samples check in various drivers. 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. --- diff --git a/hardware/agilent-dmm/sched.c b/hardware/agilent-dmm/sched.c index 339dbac6..67c2a1b6 100644 --- a/hardware/agilent-dmm/sched.c +++ b/hardware/agilent-dmm/sched.c @@ -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; diff --git a/hardware/alsa/protocol.c b/hardware/alsa/protocol.c index ff6a3f85..61b03cab 100644 --- a/hardware/alsa/protocol.c +++ b/hardware/alsa/protocol.c @@ -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; diff --git a/hardware/demo/demo.c b/hardware/demo/demo.c index 7238d84e..b02e668c 100644 --- a/hardware/demo/demo.c +++ b/hardware/demo/demo.c @@ -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; } diff --git a/hardware/serial-dmm/protocol.c b/hardware/serial-dmm/protocol.c index 9524f2bd..19b35538 100644 --- a/hardware/serial-dmm/protocol.c +++ b/hardware/serial-dmm/protocol.c @@ -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; } diff --git a/hardware/tondaj-sl-814/protocol.c b/hardware/tondaj-sl-814/protocol.c index 57472520..e20351ac 100644 --- a/hardware/tondaj-sl-814/protocol.c +++ b/hardware/tondaj-sl-814/protocol.c @@ -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; diff --git a/hardware/uni-t-dmm/protocol.c b/hardware/uni-t-dmm/protocol.c index a4b69403..55f573af 100644 --- a/hardware/uni-t-dmm/protocol.c +++ b/hardware/uni-t-dmm/protocol.c @@ -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); }