aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSoeren Apel <soeren@apelpie.net>2017-02-26 21:01:26 +0100
committerUwe Hermann <uwe@hermann-uwe.de>2017-03-08 01:10:39 +0100
commit90230cfa7f7ae62b21169fa2156f54e2902e7ad1 (patch)
tree0229a5520b4ad49c3371e4ac52db2bdfa92cca5d
parent9a17c23bc9810206eae7741bc4b35bc4d78999d3 (diff)
lecroy-xstream: Fix capabilities listing in config_list()
This fixes bug #913.
-rw-r--r--src/hardware/lecroy-xstream/api.c54
-rw-r--r--src/hardware/lecroy-xstream/protocol.c23
-rw-r--r--src/hardware/lecroy-xstream/protocol.h6
3 files changed, 44 insertions, 39 deletions
diff --git a/src/hardware/lecroy-xstream/api.c b/src/hardware/lecroy-xstream/api.c
index d859681..25c1148 100644
--- a/src/hardware/lecroy-xstream/api.c
+++ b/src/hardware/lecroy-xstream/api.c
@@ -32,6 +32,26 @@ static const uint32_t scanopts[] = {
SR_CONF_CONN,
};
+static const uint32_t drvopts[] = {
+ SR_CONF_OSCILLOSCOPE,
+};
+
+static const uint32_t devopts[] = {
+ SR_CONF_LIMIT_FRAMES | SR_CONF_GET | SR_CONF_SET,
+ SR_CONF_TRIGGER_SOURCE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
+ SR_CONF_TIMEBASE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
+ SR_CONF_NUM_HDIV | SR_CONF_GET,
+ SR_CONF_TRIGGER_SLOPE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
+ SR_CONF_HORIZ_TRIGGERPOS | SR_CONF_GET | SR_CONF_SET,
+ SR_CONF_SAMPLERATE | SR_CONF_GET,
+};
+
+static const uint32_t analog_devopts[] = {
+ SR_CONF_NUM_VDIV | SR_CONF_GET,
+ SR_CONF_COUPLING | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
+ SR_CONF_VDIV | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
+};
+
static int check_manufacturer(const char *manufacturer)
{
unsigned int i;
@@ -402,24 +422,38 @@ static int config_list(uint32_t key, GVariant **data,
(void)cg;
- if (sdi) {
- devc = sdi->priv;
- model = devc->model_config;
+ /* SR_CONF_SCAN_OPTIONS is always valid, regardless of sdi or channel group. */
+ if (key == SR_CONF_SCAN_OPTIONS) {
+ *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
+ scanopts, ARRAY_SIZE(scanopts), sizeof(uint32_t));
+ return SR_OK;
}
- switch (key) {
- case SR_CONF_SCAN_OPTIONS:
+ /* If sdi is NULL, nothing except SR_CONF_DEVICE_OPTIONS can be provided. */
+ if (key == SR_CONF_DEVICE_OPTIONS && !sdi) {
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
- scanopts, ARRAY_SIZE(scanopts), sizeof(uint32_t));
- break;
+ drvopts, ARRAY_SIZE(drvopts), sizeof(uint32_t));
+ return SR_OK;
+ }
+
+ /* Every other option requires a valid device instance. */
+ if (!sdi)
+ return SR_ERR_ARG;
+
+ devc = sdi->priv;
+ model = devc->model_config;
+
+ switch (key) {
case SR_CONF_DEVICE_OPTIONS:
if (!cg) {
+ /* If cg is NULL, only the SR_CONF_DEVICE_OPTIONS that are not
+ * specific to a channel group must be returned. */
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
- model->devopts, model->num_devopts, sizeof(uint32_t));
- break;
+ devopts, ARRAY_SIZE(devopts), sizeof(uint32_t));
+ return SR_OK;
}
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
- model->analog_devopts, model->num_analog_devopts,
+ analog_devopts, ARRAY_SIZE(analog_devopts),
sizeof(uint32_t));
break;
case SR_CONF_COUPLING:
diff --git a/src/hardware/lecroy-xstream/protocol.c b/src/hardware/lecroy-xstream/protocol.c
index 7369108..ec7e958 100644
--- a/src/hardware/lecroy-xstream/protocol.c
+++ b/src/hardware/lecroy-xstream/protocol.c
@@ -74,23 +74,6 @@ struct lecroy_wavedesc {
};
} __attribute__((packed));
-static const uint32_t devopts[] = {
- SR_CONF_OSCILLOSCOPE,
- SR_CONF_LIMIT_FRAMES | SR_CONF_GET | SR_CONF_SET,
- SR_CONF_TRIGGER_SOURCE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
- SR_CONF_TIMEBASE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
- SR_CONF_NUM_HDIV | SR_CONF_GET,
- SR_CONF_TRIGGER_SLOPE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
- SR_CONF_HORIZ_TRIGGERPOS | SR_CONF_GET | SR_CONF_SET,
- SR_CONF_SAMPLERATE | SR_CONF_GET,
-};
-
-static const uint32_t analog_devopts[] = {
- SR_CONF_NUM_VDIV | SR_CONF_GET,
- SR_CONF_COUPLING | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
- SR_CONF_VDIV | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
-};
-
static const char *coupling_options[] = {
"A1M", // AC with 1 MOhm termination
"D50", // DC with 50 Ohm termination
@@ -200,12 +183,6 @@ static const struct scope_config scope_models[] = {
.analog_channels = 4,
.analog_names = &scope_analog_channel_names,
- .devopts = &devopts,
- .num_devopts = ARRAY_SIZE(devopts),
-
- .analog_devopts = &analog_devopts,
- .num_analog_devopts = ARRAY_SIZE(analog_devopts),
-
.coupling_options = &coupling_options,
.trigger_sources = &trigger_sources,
.trigger_slopes = &scope_trigger_slopes,
diff --git a/src/hardware/lecroy-xstream/protocol.h b/src/hardware/lecroy-xstream/protocol.h
index 3cec929..0200c19 100644
--- a/src/hardware/lecroy-xstream/protocol.h
+++ b/src/hardware/lecroy-xstream/protocol.h
@@ -38,12 +38,6 @@ struct scope_config {
const char *(*analog_names)[];
- const uint32_t (*devopts)[];
- const uint8_t num_devopts;
-
- const uint32_t (*analog_devopts)[];
- const uint8_t num_analog_devopts;
-
const char *(*coupling_options)[];
const uint8_t num_coupling_options;