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.
This commit is contained in:
Uwe Hermann 2012-12-26 01:29:27 +01:00
parent 7869340103
commit 35e199da50
6 changed files with 12 additions and 19 deletions

View 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;

View 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;

View 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;
}

View 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;
}

View 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;

View 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);
}