X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=main.c;h=c2f39d84ff601fec51236cf261f723016bd2e552;hb=e8a9eb8d33617a5210a1c10d1855a8482bd85080;hp=e699d2f0e6d905b5ab06775c9c65f30bb54c7267;hpb=c83f755098b3c5d10b3ad022c0f4e934edc94148;p=sigrok-cli.git diff --git a/main.c b/main.c index e699d2f..c2f39d8 100644 --- a/main.c +++ b/main.c @@ -117,6 +117,10 @@ static void get_option(void) int ret; char *s; struct sr_dev_driver *driver; + const struct sr_key_info *srci, *srmqi, *srmqfi; + uint32_t mq; + uint64_t mask, mqflags; + unsigned int j; if (!(devices = device_scan())) { g_critical("No devices found."); @@ -138,13 +142,32 @@ static void get_option(void) if ((devargs = parse_generic_arg(opt_config, FALSE))) set_dev_options(sdi, devargs); - else devargs = NULL; + else + devargs = NULL; if ((ret = maybe_config_get(driver, sdi, cg, ci->key, &gvar)) != SR_OK) g_critical("Failed to get '%s': %s", opt_get, sr_strerror(ret)); - s = g_variant_print(gvar, FALSE); - printf("%s\n", s); - g_free(s); + srci = sr_key_info_get(SR_KEY_CONFIG, ci->key); + if (srci && srci->datatype == SR_T_MQ) { + g_variant_get(gvar, "(ut)", &mq, &mqflags); + if ((srmqi = sr_key_info_get(SR_KEY_MQ, mq))) + printf("%s", srmqi->id); + else + printf("%d", mq); + for (j = 0, mask = 1; j < 32; j++, mask <<= 1) { + if (!(mqflags & mask)) + continue; + if ((srmqfi = sr_key_info_get(SR_KEY_MQFLAGS, mqflags & mask))) + printf("/%s", srmqfi->id); + else + printf("/%" PRIu64, mqflags & mask); + } + printf("\n"); + } else { + s = g_variant_print(gvar, FALSE); + printf("%s\n", s); + g_free(s); + } g_variant_unref(gvar); sr_dev_close(sdi); @@ -214,13 +237,13 @@ int main(int argc, char **argv) } if (register_pds(opt_pds, opt_pd_annotations) != 0) goto done; - if (setup_pd_stack(opt_pds, opt_pd_annotations) != 0) - goto done; /* Only one output type is ever shown. */ if (opt_pd_binary) { if (setup_pd_binary(opt_pd_binary) != 0) goto done; + if (setup_binary_stdout() != 0) + goto done; if (srd_pd_output_callback_add(srd_sess, SRD_OUTPUT_BINARY, show_pd_binary, NULL) != SRD_OK) goto done; @@ -243,6 +266,12 @@ int main(int argc, char **argv) if (opt_version) show_version(); + else if (opt_list_supported) + show_supported(); + else if (opt_list_supported_wiki) + show_supported_wiki(); + else if (opt_input_file && opt_show) + load_input_file(TRUE); else if (opt_input_format && opt_show) show_input(); else if (opt_output_format && opt_show) @@ -258,13 +287,15 @@ int main(int argc, char **argv) else if (opt_show) show_dev_detail(); else if (opt_input_file) - load_input_file(); + load_input_file(FALSE); else if (opt_get) get_option(); else if (opt_set) set_options(); else if (opt_samples || opt_time || opt_frames || opt_continuous) run_session(); + else if (opt_list_serial) + show_serial_ports(); else show_help();