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];