The demo driver always outputs from the beginning of the generated pattern. This
is problematic if we don't output a whole period.

Deffer the sending of analog data until we have enough for a whole period.

BugLink: http://sigrok.org/bugzilla/show_bug.cgi?id=297
---
 hardware/demo/demo.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/hardware/demo/demo.c b/hardware/demo/demo.c
index 433f352..1615eb5 100644
--- a/hardware/demo/demo.c
+++ b/hardware/demo/demo.c
@@ -641,7 +641,14 @@ static int prepare_data(int fd, int revents, void *cb_data)
 
        /* Of those, how many do we still have to send? */
        logic_todo = MIN(expected_samplenum, devc->limit_samples) - 
devc->logic_counter;
-       analog_todo = MIN(expected_samplenum, devc->limit_samples) - 
devc->analog_counter;
+
+       if (expected_samplenum > devc->limit_samples) {
+               analog_todo = devc->limit_samples - devc->analog_counter;
+       } else {
+               analog_todo = expected_samplenum - devc->analog_counter;
+               while (analog_todo  % ANALOG_SAMPLES_PER_PERIOD != 0)
+                       analog_todo--;
+       }
 
        while (logic_todo || analog_todo) {
                /* Logic */
@@ -668,11 +675,6 @@ static int prepare_data(int fd, int revents, void *cb_data)
                                packet.type = SR_DF_ANALOG;
                                packet.payload = &ag->packet;
 
-                               /* FIXME we should make sure we output a whole
-                                * period of data before we send out again the
-                                * beginning of our buffer. A ring buffer would
-                                * help here as well */
-
                                analog_samples = MIN(analog_todo, 
ag->num_samples);
                                /* Whichever probe group gets there first. */
                                sending_now = MAX(sending_now, analog_samples);
-- 
1.8.5.3


------------------------------------------------------------------------------
CenturyLink Cloud: The Leader in Enterprise Cloud Services.
Learn Why More Businesses Are Choosing CenturyLink Cloud For
Critical Workloads, Development Environments & Everything In Between.
Get a Quote or Start a Free Trial Today.
http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
_______________________________________________
sigrok-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sigrok-devel

Reply via email to