When the acquisition was stopped before a configured limit was reached,
no sample data was retrieved. This is because the api.c stop routine did
unregister the receive callback.
Pass the stop request to the receive routine instead when stop is called
while the acquisition is still running. Have sample data downloaded very
much like it's done for reached limits, and existing logic will run the
stop routine again after state was advanced to "idle".
Extend the 'state' tracking while we are here, mark sample download as
well (that was omitted in the previous implementation). Though the
omission was non-fatal. Move the release of 'dram_line' to some earlier
location (as soon as the resource is not needed any longer), before some
rather complex calls to other routines will execute.
Reported-By: Michael Kaplan <redacted>
struct dev_context *devc;
devc = sdi->priv;
struct dev_context *devc;
devc = sdi->priv;
- devc->state.state = SIGMA_IDLE;
- sr_session_source_remove(sdi->session, -1);
+ /*
+ * When acquisition is currently running, keep the receive
+ * routine registered and have it stop the acquisition upon the
+ * next invocation. Else unregister the receive routine here
+ * already. The detour is required to have sample data retrieved
+ * for forced acquisition stops.
+ */
+ if (devc->state.state == SIGMA_CAPTURE) {
+ devc->state.state = SIGMA_STOPPING;
+ } else {
+ devc->state.state = SIGMA_IDLE;
+ sr_session_source_remove(sdi->session, -1);
+ }
return FALSE;
sr_info("Downloading sample data.");
return FALSE;
sr_info("Downloading sample data.");
+ devc->state.state = SIGMA_DOWNLOAD;
/*
* Ask the hardware to stop data acquisition. Reception of the
/*
* Ask the hardware to stop data acquisition. Reception of the
dl_lines_done += dl_lines_curr;
}
dl_lines_done += dl_lines_curr;
}
std_session_send_df_end(sdi);
std_session_send_df_end(sdi);
+ devc->state.state = SIGMA_IDLE;
sr_dev_acquisition_stop(sdi);
sr_dev_acquisition_stop(sdi);
if (devc->state.state == SIGMA_IDLE)
return TRUE;
if (devc->state.state == SIGMA_IDLE)
return TRUE;
+ /*
+ * When the application has requested to stop the acquisition,
+ * then immediately start downloading sample data. Otherwise
+ * keep checking configured limits which will terminate the
+ * acquisition and initiate download.
+ */
+ if (devc->state.state == SIGMA_STOPPING)
+ return download_capture(sdi);
if (devc->state.state == SIGMA_CAPTURE)
return sigma_capture_mode(sdi);
if (devc->state.state == SIGMA_CAPTURE)
return sigma_capture_mode(sdi);
SIGMA_UNINITIALIZED = 0,
SIGMA_IDLE,
SIGMA_CAPTURE,
SIGMA_UNINITIALIZED = 0,
SIGMA_IDLE,
SIGMA_CAPTURE,
uint16_t lastts;
uint16_t lastsample;
};
uint16_t lastts;
uint16_t lastsample;
};