]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/demo/protocol.c
Demo: Implement multi-frame development feature
[libsigrok.git] / src / hardware / demo / protocol.c
index 8b89d3548f8ce0fd3fb88ccb25c38733fc6deb1d..37417f734f21e2164a43c9296185a2c4a4879b54 100644 (file)
@@ -273,9 +273,8 @@ static void logic_generator(struct sr_dev_inst *sdi, uint64_t size)
                break;
        case PATTERN_INC:
                for (i = 0; i < size; i++) {
-                       for (j = 0; j < devc->logic_unitsize; j++) {
+                       for (j = 0; j < devc->logic_unitsize; j++)
                                devc->logic_data[i + j] = devc->step;
-                       }
                        devc->step++;
                }
                break;
@@ -460,12 +459,17 @@ SR_PRIV int demo_prepare_data(int fd, int revents, void *cb_data)
        /* How many samples are outstanding since the last round? */
        samples_todo = (todo_us * devc->cur_samplerate + G_USEC_PER_SEC - 1)
                        / G_USEC_PER_SEC;
+
+       if (SAMPLES_PER_FRAME > 0)
+               samples_todo = SAMPLES_PER_FRAME;
+
        if (devc->limit_samples > 0) {
                if (devc->limit_samples < devc->sent_samples)
                        samples_todo = 0;
                else if (devc->limit_samples - devc->sent_samples < samples_todo)
                        samples_todo = devc->limit_samples - devc->sent_samples;
        }
+
        /* Calculate the actual time covered by this run back from the sample
         * count, rounded towards zero. This avoids getting stuck on a too-low
         * time delta with no samples being sent due to round-off.
@@ -535,6 +539,11 @@ SR_PRIV int demo_prepare_data(int fd, int revents, void *cb_data)
                }
                sr_dbg("Requested number of samples reached.");
                sr_dev_acquisition_stop(sdi);
+       } else {
+               if (SAMPLES_PER_FRAME > 0) {
+                       std_session_send_frame_end(sdi);
+                       std_session_send_frame_begin(sdi);
+               }
        }
 
        return G_SOURCE_CONTINUE;