From: Bert Vermeulen Date: Sun, 23 Aug 2015 21:21:14 +0000 (+0200) Subject: Support SR_T_MQ. X-Git-Tag: sigrok-cli-0.6.0~19 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=84b39e3e488c4897df5afb5ffeca21ef30c71fba;p=sigrok-cli.git Support SR_T_MQ. --- diff --git a/session.c b/session.c index 6e10178..1d98877 100644 --- 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 / 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 957560f..b786016 100644 --- 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;