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 SR_OK;
}
return FALSE;
sr_info("Downloading sample data.");
+ devc->state.state = SIGMA_DOWNLOAD;
/*
* Ask the hardware to stop data acquisition. Reception of the
dl_lines_done += dl_lines_curr;
}
+ g_free(dram_line);
std_session_send_df_end(sdi);
+ devc->state.state = SIGMA_IDLE;
sr_dev_acquisition_stop(sdi);
- g_free(dram_line);
-
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);