From: Gerhard Sittig Date: Sat, 17 Jun 2017 18:33:12 +0000 (+0200) Subject: demo: Don't generate analog output data for disabled channels X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=01f2adb07a66a4e8e8a6102c7f6bb905007d606a;p=libsigrok.git demo: Don't generate analog output data for disabled channels 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). --- diff --git a/src/hardware/demo/api.c b/src/hardware/demo/api.c index 17890f3f..645ef5f2 100644 --- a/src/hardware/demo/api.c +++ b/src/hardware/demo/api.c @@ -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; diff --git a/src/hardware/demo/protocol.c b/src/hardware/demo/protocol.c index 94ce4ff2..9c4ada3b 100644 --- a/src/hardware/demo/protocol.c +++ b/src/hardware/demo/protocol.c @@ -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; diff --git a/src/hardware/demo/protocol.h b/src/hardware/demo/protocol.h index 5d78c5e7..8f8868fa 100644 --- a/src/hardware/demo/protocol.h +++ b/src/hardware/demo/protocol.h @@ -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];