]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/asix-sigma/api.c
asix-sigma: download sample data upon user initiated stop, too
[libsigrok.git] / src / hardware / asix-sigma / api.c
index 042793a8961c8e52c5ee7d1acb094a01ab1c91f9..8e1a490aa345ee6e91ea8a968236d0899c2ad8cf 100644 (file)
@@ -363,9 +363,20 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
        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;
 }