X-Git-Url: https://sigrok.org/gitweb/?p=sigrok-cli.git;a=blobdiff_plain;f=sigrok-cli.c;h=a37b19d515890f4fd94b81d60e00ed4dba7dbd8a;hp=a194a5cb9c3ec9c4a7a8c854b5c52331ef4dc8ac;hb=630293b49d7645f2525ac5addad37c1f9315d2ce;hpb=4e0db44dcd411cb282f64714aa7f0521d2ed00ea;ds=sidebyside diff --git a/sigrok-cli.c b/sigrok-cli.c index a194a5c..a37b19d 100644 --- a/sigrok-cli.c +++ b/sigrok-cli.c @@ -1,5 +1,5 @@ /* - * This file is part of the sigrok project. + * This file is part of the sigrok-cli project. * * Copyright (C) 2012 Bert Vermeulen * @@ -271,26 +271,39 @@ static void print_dev_line(const struct sr_dev_inst *sdi) { struct sr_probe *probe; GSList *l; + GString *s; + GVariant *gvar; + s = g_string_sized_new(128); + g_string_assign(s, sdi->driver->name); + if (sr_config_get(sdi->driver, SR_CONF_CONN, &gvar, sdi) == SR_OK) { + g_string_append(s, ":conn="); + g_string_append(s, g_variant_get_string(gvar, NULL)); + g_variant_unref(gvar); + } + g_string_append(s, " - "); if (sdi->vendor && sdi->vendor[0]) - printf("%s ", sdi->vendor); + g_string_append_printf(s, "%s ", sdi->vendor); if (sdi->model && sdi->model[0]) - printf("%s ", sdi->model); + g_string_append_printf(s, "%s ", sdi->model); if (sdi->version && sdi->version[0]) - printf("%s ", sdi->version); + g_string_append_printf(s, "%s ", sdi->version); if (sdi->probes) { if (g_slist_length(sdi->probes) == 1) { probe = sdi->probes->data; - printf("with 1 probe: %s", probe->name); + g_string_append_printf(s, "with 1 probe: %s", probe->name); } else { - printf("with %d probes:", g_slist_length(sdi->probes)); + g_string_append_printf(s, "with %d probes:", g_slist_length(sdi->probes)); for (l = sdi->probes; l; l = l->next) { probe = l->data; - printf(" %s", probe->name); + g_string_append_printf(s, " %s", probe->name); } } } - printf("\n"); + g_string_append_printf(s, "\n"); + printf("%s", s->str); + g_string_free(s, TRUE); + } static void show_dev_list(void) @@ -644,7 +657,7 @@ static GArray *get_enabled_logic_probes(const struct sr_dev_inst *sdi) } static void datafeed_in(const struct sr_dev_inst *sdi, - const struct sr_datafeed_packet *packet) + const struct sr_datafeed_packet *packet, void *cb_data) { const struct sr_datafeed_meta *meta; const struct sr_datafeed_logic *logic; @@ -663,6 +676,8 @@ static void datafeed_in(const struct sr_dev_inst *sdi, uint64_t samplerate, output_len, filter_out_len; uint8_t *output_buf, *filter_out; + (void) cb_data; + /* If the first packet to come in isn't a header, don't even try. */ if (packet->type != SR_DF_HEADER && o == NULL) return; @@ -1392,7 +1407,7 @@ static void load_input_file_format(void) return; sr_session_new(); - sr_session_datafeed_callback_add(datafeed_in); + sr_session_datafeed_callback_add(datafeed_in, NULL); if (sr_session_dev_add(in->sdi) != SR_OK) { g_critical("Failed to use device."); sr_session_destroy(); @@ -1412,7 +1427,7 @@ static void load_input_file(void) if (sr_session_load(opt_input_file) == SR_OK) { /* sigrok session file */ - sr_session_datafeed_callback_add(datafeed_in); + sr_session_datafeed_callback_add(datafeed_in, NULL); sr_session_start(); sr_session_run(); sr_session_stop(); @@ -1591,7 +1606,7 @@ static void run_session(void) sdi = devices->data; sr_session_new(); - sr_session_datafeed_callback_add(datafeed_in); + sr_session_datafeed_callback_add(datafeed_in, NULL); if (sr_session_dev_add(sdi) != SR_OK) { g_critical("Failed to use device.");