From: Frank Stettner Date: Wed, 20 Feb 2019 17:58:13 +0000 (+0100) Subject: demo: Set an initial mq, mq flag and digits to the analog package. X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=8430c9b62e83faa606e7abff635d83433b237e17;p=libsigrok.git demo: Set an initial mq, mq flag and digits to the analog package. Without a measured quantity in packet.meaning->mq the C++ binding function sigrok::Analog::mq() throws an exception and there is no way to check if there is any measured quantity set in the analog package. --- diff --git a/src/hardware/demo/api.c b/src/hardware/demo/api.c index 7d3e0887..52f30d4f 100644 --- a/src/hardware/demo/api.c +++ b/src/hardware/demo/api.c @@ -28,11 +28,13 @@ #include "libsigrok-internal.h" #include "protocol.h" -#define DEFAULT_NUM_LOGIC_CHANNELS 8 -#define DEFAULT_LOGIC_PATTERN PATTERN_SIGROK +#define DEFAULT_NUM_LOGIC_CHANNELS 8 +#define DEFAULT_LOGIC_PATTERN PATTERN_SIGROK -#define DEFAULT_NUM_ANALOG_CHANNELS 4 -#define DEFAULT_ANALOG_AMPLITUDE 10 +#define DEFAULT_NUM_ANALOG_CHANNELS 4 +#define DEFAULT_ANALOG_ENCODING_DIGITS 4 +#define DEFAULT_ANALOG_SPEC_DIGITS 4 +#define DEFAULT_ANALOG_AMPLITUDE 10 /* Note: No spaces allowed because of sigrok-cli. */ static const char *logic_pattern_str[] = { @@ -185,9 +187,11 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) ag->amplitude = DEFAULT_ANALOG_AMPLITUDE; sr_analog_init(&ag->packet, &ag->encoding, &ag->meaning, &ag->spec, 2); ag->packet.meaning->channels = cg->channels; - ag->packet.meaning->mq = 0; - ag->packet.meaning->mqflags = 0; + ag->packet.meaning->mq = SR_MQ_VOLTAGE; + ag->packet.meaning->mqflags = SR_MQFLAG_DC; ag->packet.meaning->unit = SR_UNIT_VOLT; + ag->packet.encoding->digits = DEFAULT_ANALOG_ENCODING_DIGITS; + ag->packet.spec->spec_digits = DEFAULT_ANALOG_SPEC_DIGITS; ag->packet.data = ag->pattern_data; ag->pattern = pattern; ag->avg_val = 0.0f;