X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=decode.c;h=2e831f74ee1985a735e3da027a933ea2d3328bca;hb=e45889373bd907f0b760aab531787d87bf2bf691;hp=add16f744815e3c7fa6211af2a94590006beb3e1;hpb=3dfbfbc82fe09a1fa57daff87c3aadadae3773a1;p=sigrok-cli.git
diff --git a/decode.c b/decode.c
index add16f7..2e831f7 100644
--- a/decode.c
+++ b/decode.c
@@ -17,6 +17,8 @@
* along with this program. If not, see .
*/
+#include
+#include
#include "sigrok-cli.h"
#include "config.h"
#include
@@ -28,8 +30,6 @@ static GHashTable *pd_binary_visible = NULL;
static GHashTable *pd_channel_maps = NULL;
extern struct srd_session *srd_sess;
-extern gint opt_loglevel;
-
static int opts_to_gvar(struct srd_decoder *dec, GHashTable *hash,
GHashTable **options)
@@ -142,7 +142,11 @@ int register_pds(const char *opt_pds, char *opt_pd_annotations)
ret = 1;
break;
}
- dec = srd_decoder_get_by_id(pd_name);
+ if (!(dec = srd_decoder_get_by_id(pd_name))) {
+ g_critical("Failed to get decoder %s by id.", pd_name);
+ ret = 1;
+ break;
+ }
/* Convert decoder option and channel values to GVariant. */
if (!opts_to_gvar(dec, pd_opthash, &options)) {
@@ -246,9 +250,13 @@ static void map_pd_inst_channels(void *key, void *value, void *user_data)
void map_pd_channels(struct sr_dev_inst *sdi)
{
+ GSList *channels;
+
+ channels = sr_dev_inst_channels_get(sdi);
+
if (pd_channel_maps) {
g_hash_table_foreach(pd_channel_maps, &map_pd_inst_channels,
- sdi->channels);
+ channels);
g_hash_table_destroy(pd_channel_maps);
pd_channel_maps = NULL;
}
@@ -461,7 +469,7 @@ void show_pd_annotations(struct srd_proto_data *pdata, void *cb_data)
show = FALSE;
for (l = ann_list; l; l = l->next) {
if (GPOINTER_TO_INT(l->data) == -1
- || GPOINTER_TO_INT(l->data) == pda->ann_format) {
+ || GPOINTER_TO_INT(l->data) == pda->ann_class) {
show = TRUE;
break;
}
@@ -480,7 +488,7 @@ void show_pd_annotations(struct srd_proto_data *pdata, void *cb_data)
} else {
/* Protocol decoder id, annotation class,
* all annotation strings. */
- ann_descr = g_slist_nth_data(dec->annotations, pda->ann_format);
+ ann_descr = g_slist_nth_data(dec->annotations, pda->ann_class);
printf(" %s: %s:", pdata->pdo->proto_id, ann_descr[0]);
for (i = 0; pda->ann_text[i]; i++)
printf(" \"%s\"", pda->ann_text[i]);