]> sigrok.org Git - libsigrok.git/commitdiff
input/saleae: improve L2D undersampling, do provide sample data
authorGerhard Sittig <redacted>
Wed, 2 Sep 2020 15:59:47 +0000 (17:59 +0200)
committerGerhard Sittig <redacted>
Wed, 2 Sep 2020 17:52:44 +0000 (19:52 +0200)
The Saleae Logic exported files (Logic2 digital format) don't contain a
samplerate, so users need to specify the value. For values smaller than
the samplerate that was used during the capture undersampling will take
place. An implementation detail of the input module could result in
incorrect timing of sample values in the session feed. In extreme cases
none of the periods between signal edges qualified for submission. In
that case no sample data was sent to the sigrok session at all.

  $ sigrok-cli -i digital_1.bin -I saleae:samplerate=1000

Keep the very timestamp at hand when the last sample data was submitted.
Only advance that timestamp when more sample data was sent. This avoids
the accumulation of timing errors for undersampling scenarios, and does
forward undersampled input data when the user provided sample period has
passed.

This fixes bug #1600.

src/input/saleae.c

index cc954e627203fe4bec9dab7d82354ce70465b81b..697392edafdfab889f13c91f8679746fd2b01ab6 100644 (file)
@@ -813,11 +813,13 @@ static int parse_next_item(struct sr_input *in,
                diff_time /= inc->logic_state.l2d.sample_period;
                diff_time += 0.5;
                count = (uint64_t)diff_time;
                diff_time /= inc->logic_state.l2d.sample_period;
                diff_time += 0.5;
                count = (uint64_t)diff_time;
-               digital = inc->feed.last.digital;
-               rc = addto_feed_buffer_logic(in, digital, count);
-               if (rc)
-                       return rc;
-               inc->feed.last.time = next_time;
+               if (count) {
+                       digital = inc->feed.last.digital;
+                       rc = addto_feed_buffer_logic(in, digital, count);
+                       if (rc)
+                               return rc;
+                       inc->feed.last.time = next_time;
+               }
                inc->feed.last.digital = 1 - inc->feed.last.digital;
                return SR_OK;
        case STAGE_L2A_FIRST_VALUE:
                inc->feed.last.digital = 1 - inc->feed.last.digital;
                return SR_OK;
        case STAGE_L2A_FIRST_VALUE: