Support SR_T_MQ.
authorBert Vermeulen <bert@biot.com>
Sun, 23 Aug 2015 21:21:14 +0000 (23:21 +0200)
committerBert Vermeulen <bert@biot.com>
Mon, 31 Aug 2015 16:07:16 +0000 (18:07 +0200)
session.c
show.c

index 6e101784606dc4d168a824be891f48413ceffb33..1d98877801a429e3f0b437f976f7958f68871056 100644 (file)
--- a/session.c
+++ b/session.c
@@ -358,7 +358,7 @@ int opt_to_gvar(char *key, char *value, struct sr_config *src)
        double tmp_double, dlow, dhigh;
        uint64_t tmp_u64, p, q, low, high, mqflags;
        uint32_t mq;
-       GVariant *rational[2], *range[2], *gvar, *gtup[2];
+       GVariant *rational[2], *range[2], *gtup[2];
        GVariantBuilder *vbl;
        gboolean tmp_bool;
        gchar **keyval;
@@ -453,7 +453,7 @@ int opt_to_gvar(char *key, char *value, struct sr_config *src)
                        g_strfreev(keyval);
                }
                break;
-       case SR_T_MQLIST:
+       case SR_T_MQ:
                /*
                  Argument is MQ id e.g. ("voltage") optionally followed by one
                  or more /<mqflag> e.g. "/ac".
@@ -475,12 +475,9 @@ int opt_to_gvar(char *key, char *value, struct sr_config *src)
                }
                g_strfreev(keyval);
                if (ret != -1) {
-                       vbl = g_variant_builder_new(G_VARIANT_TYPE_ARRAY);
                        gtup[0] = g_variant_new_uint32(mq);
                        gtup[1] = g_variant_new_uint64(mqflags);
-                       gvar = g_variant_new_tuple(gtup, 2);
-                       g_variant_builder_add_value(vbl, gvar);
-                       src->data = g_variant_builder_end(vbl);
+                       src->data = g_variant_new_tuple(gtup, 2);
                }
                break;
        default:
diff --git a/show.c b/show.c
index 957560f333a48637ce85f2306afbf7f7b6a8a801..b786016afdb4ab01c417d78b106cbaaa9d4dec4b 100644 (file)
--- a/show.c
+++ b/show.c
@@ -267,7 +267,7 @@ void show_dev_detail(void)
        struct sr_channel *ch;
        struct sr_channel_group *channel_group, *cg;
        GSList *devices, *cgl, *chl, *channel_groups;
-       GVariant *gvar_opts, *gvar_dict, *gvar_list, *gvar, *element;
+       GVariant *gvar_opts, *gvar_dict, *gvar_list, *gvar;
        gsize num_opts, num_elements;
        double dlow, dhigh, dcur_low, dcur_high;
        const uint64_t *uint64, p, q, low, high;
@@ -626,15 +626,13 @@ void show_dev_detail(void)
                        }
                        g_variant_unref(gvar_list);
 
-               } else if (srci->datatype == SR_T_MQLIST) {
+               } else if (srci->datatype == SR_T_MQ) {
                        printf("    %s: ", srci->id);
                        if (maybe_config_get(driver, sdi, channel_group, key,
                                        &gvar) == SR_OK
-                                       && g_variant_is_of_type(gvar, G_VARIANT_TYPE_ARRAY)
-                                       && g_variant_n_children(gvar) == 1) {
-                               element = g_variant_get_child_value(gvar, 0);
-                               g_variant_get(element, "(ut)", &cur_mq, &cur_mqflags);
-                               g_variant_unref(element);
+                                       && g_variant_is_of_type(gvar, G_VARIANT_TYPE_TUPLE)
+                                       && g_variant_n_children(gvar) == 2) {
+                               g_variant_get(gvar, "(ut)", &cur_mq, &cur_mqflags);
                                g_variant_unref(gvar);
                        } else
                                cur_mq = cur_mqflags = 0;