]> sigrok.org Git - libsigrok.git/commitdiff
sigma: Fix bugs in receive_data callback.
authorHåvard Espeland <redacted>
Sun, 22 Apr 2012 11:05:10 +0000 (13:05 +0200)
committerHåvard Espeland <redacted>
Sun, 22 Apr 2012 12:59:10 +0000 (14:59 +0200)
- Poll data position on Sigma for every iteration.
- Return TRUE when no data ready.

hardware/asix-sigma/asix-sigma.c

index 342b2a4da2a57775a2d0ba77f12bcaa49d37d0a9..f3a973647635ad181df7bf50c5c6685277d4fa93 100644 (file)
@@ -1023,10 +1023,13 @@ static int receive_data(int fd, int revents, void *cb_data)
        (void)fd;
        (void)revents;
 
+       /* Get the current position. */
+       sigma_read_pos(&ctx->state.stoppos, &ctx->state.triggerpos, ctx);
+
        numchunks = (ctx->state.stoppos + 511) / 512;
 
        if (ctx->state.state == SIGMA_IDLE)
-               return FALSE;
+               return TRUE;
 
        if (ctx->state.state == SIGMA_CAPTURE) {
                /* Check if the timer has expired, or memory is full. */
@@ -1035,11 +1038,11 @@ static int receive_data(int fd, int revents, void *cb_data)
                        (tv.tv_usec - ctx->start_tv.tv_usec) / 1000;
 
                if (running_msec < ctx->limit_msec && numchunks < 32767)
-                       return FALSE;
+                       return TRUE; /* While capturing... */
+               else {
 
                hw_dev_acquisition_stop(sdi->index, sdi);
 
-               return FALSE;
        } else if (ctx->state.state == SIGMA_DOWNLOAD) {
                if (ctx->state.chunks_downloaded >= numchunks) {
                        /* End of samples. */