X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=main.c;h=db2bdc016df58f86eef252345f02b667b6c3316d;hb=c9c30f53c4c639d73cadc7c58c28a69090b41261;hp=e699d2f0e6d905b5ab06775c9c65f30bb54c7267;hpb=c83f755098b3c5d10b3ad022c0f4e934edc94148;p=sigrok-cli.git diff --git a/main.c b/main.c index e699d2f..db2bdc0 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."); @@ -132,19 +136,38 @@ static void get_option(void) return; } - cg = select_channel_group(sdi); + cg = lookup_channel_group(sdi); if (!(ci = sr_key_info_name_get(SR_KEY_CONFIG, opt_get))) g_critical("Unknown option '%s'", opt_get); - if ((devargs = parse_generic_arg(opt_config, FALSE))) + if ((devargs = parse_generic_arg(opt_config, FALSE, NULL))) 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); @@ -163,7 +186,7 @@ static void set_options(void) return; } - if (!(devargs = parse_generic_arg(opt_config, FALSE))) + if (!(devargs = parse_generic_arg(opt_config, FALSE, NULL))) return; if (!(devices = device_scan())) { @@ -201,6 +224,11 @@ int main(int argc, char **argv) goto done; #ifdef HAVE_SRD + if (opt_pd_binary && !opt_pds) { + g_critical("Option -B will not take effect in the absence of -P."); + goto done; + } + /* Set the loglevel (amount of messages to output) for libsigrokdecode. */ if (srd_log_loglevel_set(opt_loglevel) != SRD_OK) goto done; @@ -214,13 +242,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; @@ -238,11 +266,18 @@ int main(int argc, char **argv) show_pd_annotations, NULL) != SRD_OK) goto done; } + show_pd_prepare(); } #endif 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,17 +293,21 @@ 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(); #ifdef HAVE_SRD + if (opt_pds) + show_pd_close(); if (opt_pds) srd_exit(); #endif