]> sigrok.org Git - libsigrok.git/commitdiff
rigol-ds1xx2: Better error reporting when probe groups are required
authorBert Vermeulen <redacted>
Sun, 3 Nov 2013 13:13:59 +0000 (14:13 +0100)
committerUwe Hermann <redacted>
Fri, 8 Nov 2013 00:03:19 +0000 (01:03 +0100)
hardware/rigol-ds1xx2/api.c

index 2df009dd7e56fca39f45572667aace20cf0a41b9..9d93b301c09e78d0c8b5b5f961c2aa6afb3c1850 100644 (file)
@@ -393,11 +393,24 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi,
        if (!sdi || !(devc = sdi->priv))
                return SR_ERR_ARG;
 
+       /* If a probe group is specified, it must be a valid one. */
+       if (probe_group) {
+               if (probe_group != &devc->analog_groups[0]
+                               && probe_group != &devc->analog_groups[1]) {
+                       sr_err("Invalid probe group specified.");
+                       return SR_ERR;
+               }
+       }
+
        switch (id) {
        case SR_CONF_NUM_TIMEBASE:
                *data = g_variant_new_int32(NUM_TIMEBASE);
                break;
        case SR_CONF_NUM_VDIV:
+               if (!probe_group) {
+                       sr_err("No probe group specified.");
+                       return SR_ERR_PROBE_GROUP;
+               }
                for (i = 0; i < 2; i++) {
                        if (probe_group == &devc->analog_groups[i]) {
                                *data = g_variant_new_int32(NUM_VDIV);
@@ -428,6 +441,15 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi,
        if (sdi->status != SR_ST_ACTIVE)
                return SR_ERR_DEV_CLOSED;
 
+       /* If a probe group is specified, it must be a valid one. */
+       if (probe_group) {
+               if (probe_group != &devc->analog_groups[0]
+                               && probe_group != &devc->analog_groups[1]) {
+                       sr_err("Invalid probe group specified.");
+                       return SR_ERR;
+               }
+       }
+
        ret = SR_OK;
        switch (id) {
        case SR_CONF_LIMIT_FRAMES:
@@ -485,6 +507,10 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi,
                        ret = SR_ERR_ARG;
                break;
        case SR_CONF_VDIV:
+               if (!probe_group) {
+                       sr_err("No probe group specified.");
+                       return SR_ERR_PROBE_GROUP;
+               }
                g_variant_get(data, "(tt)", &p, &q);
                for (i = 0; i < 2; i++) {
                        if (probe_group == &devc->analog_groups[i]) {
@@ -549,9 +575,22 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi,
        if (!sdi || !(devc = sdi->priv))
                return SR_ERR_ARG;
 
+       /* If a probe group is specified, it must be a valid one. */
+       if (probe_group) {
+               if (probe_group != &devc->analog_groups[0]
+                               && probe_group != &devc->analog_groups[1]) {
+                       sr_err("Invalid probe group specified.");
+                       return SR_ERR;
+               }
+       }
+
        switch (key) {
                break;
        case SR_CONF_DEVICE_OPTIONS:
+               if (!probe_group) {
+                       sr_err("No probe group specified.");
+                       return SR_ERR_PROBE_GROUP;
+               }
                if (probe_group == &devc->digital_group) {
                        *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
                                NULL, 0, sizeof(int32_t));
@@ -572,6 +611,9 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi,
                                *data = g_variant_new_strv(coupling, ARRAY_SIZE(coupling));
                                return SR_OK;
                        }
+               if (!probe_group) {
+                       sr_err("No probe group specified.");
+                       return SR_ERR_PROBE_GROUP;
                }
                return SR_ERR_NA;
        case SR_CONF_VDIV:
@@ -582,6 +624,9 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi,
                                *data = g_variant_new_tuple(rational, 2);
                                return SR_OK;
                        }
+               if (!probe_group) {
+                       sr_err("No probe group specified.");
+                       return SR_ERR_PROBE_GROUP;
                }
                return SR_ERR_NA;
        case SR_CONF_TIMEBASE: