X-Git-Url: https://sigrok.org/gitweb/?p=sigrok-cli.git;a=blobdiff_plain;f=decode.c;h=0b7d9ee49e200cf6b8fa4010f9f869cdbe209772;hp=bc36a843546281648e68f11883c39b9389af0cb8;hb=6df458b71ace93941780153b79b348d4fd99493d;hpb=20fb52e08416238c60392b410f69856cc7d98650 diff --git a/decode.c b/decode.c index bc36a84..0b7d9ee 100644 --- a/decode.c +++ b/decode.c @@ -179,7 +179,7 @@ int register_pds(const char *opt_pds, char *opt_pd_annotations) g_strdup(di->inst_id), GINT_TO_POINTER(-1)); /* Remap the probes if needed. */ - if (srd_inst_probe_set_all(di, probes) != SRD_OK) { + if (srd_inst_probe_set_all(di, probes, (g_hash_table_size(probes) + 7) / 8) != SRD_OK) { ret = 1; break; } @@ -331,7 +331,7 @@ int setup_pd_binary(char *opt_pd_binary) GSList *l; struct srd_decoder *dec; int bin_class; - char **pds, **pdtok, **keyval, *bin_name; + char **pds, **pdtok, **keyval, **bin_name; pd_binary_visible = g_hash_table_new_full(g_str_hash, g_int_equal, g_free, NULL); @@ -350,7 +350,7 @@ int setup_pd_binary(char *opt_pd_binary) if (g_strv_length(keyval) == 2) { for (l = dec->binary; l; l = l->next, bin_class++) { bin_name = l->data; - if (!canon_cmp(bin_name, keyval[1])) + if (!strcmp(bin_name[0], keyval[1])) /* Found it. */ break; } @@ -360,7 +360,7 @@ int setup_pd_binary(char *opt_pd_binary) return 1; } g_debug("cli: Showing protocol decoder %s binary class " - "%d (%s).", keyval[0], bin_class, bin_name); + "%d (%s).", keyval[0], bin_class, bin_name[0]); } else { /* No class specified: output all of them. */ bin_class = -1; @@ -377,9 +377,11 @@ int setup_pd_binary(char *opt_pd_binary) void show_pd_annotations(struct srd_proto_data *pdata, void *cb_data) { + struct srd_decoder *dec; struct srd_proto_data_annotation *pda; gpointer ann_format; - int format; + int format, i; + char **ann_descr; /* 'cb_data' is not used in this specific callback. */ (void)cb_data; @@ -393,16 +395,29 @@ void show_pd_annotations(struct srd_proto_data *pdata, void *cb_data) return; format = GPOINTER_TO_INT(ann_format); + dec = pdata->pdo->di->decoder; pda = pdata->data; if (format != -1 && pda->ann_format != format) /* We don't want this particular format from the PD. */ return; - if (opt_loglevel > SR_LOG_WARN) - printf("%"PRIu64"-%"PRIu64" ", pdata->start_sample, pdata->end_sample); - printf("%s: ", pdata->pdo->proto_id); - /* Show only the longest annotation. */ - printf("\"%s\" ", pda->ann_text[0]); + if (opt_loglevel <= SR_LOG_WARN) { + /* Show only the longest annotation. */ + printf("%s", pda->ann_text[0]); + } else if (opt_loglevel >= SR_LOG_INFO) { + /* Sample numbers and quotes around the longest annotation. */ + printf("%"PRIu64"-%"PRIu64"", pdata->start_sample, pdata->end_sample); + if (opt_loglevel == SR_LOG_INFO) { + printf(" \"%s\"", pda->ann_text[0]); + } else { + /* Protocol decoder id, annotation class, + * all annotation strings. */ + ann_descr = g_slist_nth_data(dec->annotations, pda->ann_format); + printf(" %s: %s:", pdata->pdo->proto_id, ann_descr[0]); + for (i = 0; pda->ann_text[i]; i++) + printf(" \"%s\"", pda->ann_text[i]); + } + } printf("\n"); fflush(stdout); }