X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fdemo%2Fprotocol.c;h=37417f734f21e2164a43c9296185a2c4a4879b54;hb=f55bea7626d8bfa3a3d0bbff1e9f6ac98a6aadc5;hp=38943e43044b2a842e83652299d217ce296e2d3b;hpb=d2f7c417fdd96a13d8fd86350d2fc13db16f626c;p=libsigrok.git diff --git a/src/hardware/demo/protocol.c b/src/hardware/demo/protocol.c index 38943e43..37417f73 100644 --- a/src/hardware/demo/protocol.c +++ b/src/hardware/demo/protocol.c @@ -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; @@ -384,7 +383,6 @@ static void send_analog_packet(struct analog_gen *ag, ag->packet.data = ag->pattern_data + ag_pattern_pos; ag->packet.num_samples = sending_now; sr_session_send(sdi, &packet); - sr_dbg("DBG: %s() sending now: %lu", __func__, (unsigned long)sending_now); /* Whichever channel group gets there first. */ *analog_sent = MAX(*analog_sent, sending_now); @@ -461,14 +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; - sr_dbg("DBG: %s() samples_todo before adjustment: %lu", __func__, (unsigned long)samples_todo); + + 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; } - sr_dbg("DBG: %s() samples_todo after adjustment: %lu", __func__, (unsigned long)samples_todo); + /* 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. @@ -507,10 +508,8 @@ SR_PRIV int demo_prepare_data(int fd, int revents, void *cb_data) send_analog_packet(value, sdi, &analog_sent, devc->sent_samples + analog_done, samples_todo - analog_done); - sr_dbg("DBG: %s() analog_sent: %lu", __func__, (unsigned long)analog_sent); } analog_done += analog_sent; - sr_dbg("DBG: %s() analog_done: %lu", __func__, (unsigned long)analog_done); } } /* At this point, both logic_done and analog_done should be @@ -540,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;