]> sigrok.org Git - libsigrok.git/commitdiff
demo: Don't generate analog output data for disabled channels
authorGerhard Sittig <redacted>
Sat, 17 Jun 2017 18:33:12 +0000 (20:33 +0200)
committerUwe Hermann <redacted>
Fri, 23 Jun 2017 17:33:24 +0000 (19:33 +0200)
Skip the emission of session datafeed packets for disabled analog
channels.

Implementation detail: Allow for quick lookup of the channel that is
associated with an analog generator, as the data generation routines
only pass generator references in later calls.

This fixes part of bug #923 (which initially is about unexpected
logic data while analog channels were affected in similar ways).

src/hardware/demo/api.c
src/hardware/demo/protocol.c
src/hardware/demo/protocol.h

index 17890f3f1f22e059cc5bcbe5465f9d79169e614a..645ef5f2317744a3f019cb033528c5a9306266fe 100644 (file)
@@ -157,6 +157,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
 
                        /* Every channel gets a generator struct. */
                        ag = g_malloc(sizeof(struct analog_gen));
+                       ag->ch = ch;
                        ag->amplitude = DEFAULT_ANALOG_AMPLITUDE;
                        sr_analog_init(&ag->packet, &ag->encoding, &ag->meaning, &ag->spec, 2);
                        ag->packet.meaning->channels = cg->channels;
index 94ce4ff21e2d6e3b23b35de68bf0812ba708d37b..9c4ada3b66fdc7bc1283476cc062123c0e43071f 100644 (file)
@@ -343,6 +343,9 @@ static void send_analog_packet(struct analog_gen *ag,
        int ag_pattern_pos;
        unsigned int i;
 
+       if (!ag->ch || !ag->ch->enabled)
+               return;
+
        devc = sdi->priv;
        packet.type = SR_DF_ANALOG;
        packet.payload = &ag->packet;
index 5d78c5e7ad3266ed89b3b5acc856de2f01865f88..8f8868fab07eca45535e57d1f455f1699500e6d3 100644 (file)
@@ -118,6 +118,7 @@ static const char *analog_pattern_str[] = {
 };
 
 struct analog_gen {
+       struct sr_channel *ch;
        int pattern;
        float amplitude;
        float pattern_data[ANALOG_BUFSIZE];