]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/asix-sigma/protocol.c
asix-sigma: download sample data upon user initiated stop, too
[libsigrok.git] / src / hardware / asix-sigma / protocol.c
index e2c34e5c9169699df381d5b8fecbbab3e8685849..94fd8de044356a9a999b9a32cea11cd8c998f3ae 100644 (file)
@@ -1017,6 +1017,7 @@ static int download_capture(struct sr_dev_inst *sdi)
                return FALSE;
 
        sr_info("Downloading sample data.");
+       devc->state.state = SIGMA_DOWNLOAD;
 
        /*
         * Ask the hardware to stop data acquisition. Reception of the
@@ -1097,13 +1098,13 @@ static int download_capture(struct sr_dev_inst *sdi)
 
                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;
 }
 
@@ -1146,6 +1147,14 @@ SR_PRIV int sigma_receive_data(int fd, int revents, void *cb_data)
        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);