X-Git-Url: https://sigrok.org/gitweb/?p=sigrok-cli.git;a=blobdiff_plain;f=sigrok-cli.c;h=dda4343f16292b8a4fb6f6b74609491976986082;hp=06aa053b83793495afebfcb0b9f3f9ad8ac9dad4;hb=2358775c24a4c10dd55b2e0c12c24d6690b23daf;hpb=548b7ddc8144ca0430f852c89ae4f2e61ab487d7 diff --git a/sigrok-cli.c b/sigrok-cli.c index 06aa053..dda4343 100644 --- a/sigrok-cli.c +++ b/sigrok-cli.c @@ -93,6 +93,7 @@ static void show_version(void) int i; printf("sigrok-cli %s\n\n", VERSION); + printf("Supported hardware drivers:\n"); plugins = sr_hwplugins_list(); for (p = plugins; p; p = p->next) { @@ -113,24 +114,24 @@ static void show_version(void) printf(" %-20s %s\n", outputs[i]->id, outputs[i]->description); printf("\n"); - /* TODO: Error handling. */ - srd_init(NULL); - - printf("Supported protocol decoders:\n"); - for (l = srd_list_decoders(); l; l = l->next) { - dec = l->data; - printf(" %-20s %s\n", dec->id, dec->longname); + if (srd_init(NULL) == SRD_OK) { + printf("Supported protocol decoders:\n"); + srd_decoders_load_all(); + for (l = srd_decoders_list(); l; l = l->next) { + dec = l->data; + printf(" %-20s %s\n", dec->id, dec->longname); + } + srd_exit(); } printf("\n"); - srd_exit(); } static void print_device_line(const struct sr_device *device) { const struct sr_device_instance *sdi; - sr_dev_get_info(device, SR_DI_INSTANCE, (const void **)&sdi); + sr_dev_info_get(device, SR_DI_INSTANCE, (const void **)&sdi); if (sdi->vendor && sdi->vendor[0]) printf("%s ", sdi->vendor); @@ -189,7 +190,7 @@ static void show_device_detail(void) print_device_line(device); - if (sr_dev_get_info(device, SR_DI_TRIGGER_TYPES, + if (sr_dev_info_get(device, SR_DI_TRIGGER_TYPES, (const void **)&charopts) == SR_OK) { printf("Supported triggers: "); while (*charopts) { @@ -202,7 +203,7 @@ static void show_device_detail(void) title = "Supported options:\n"; capabilities = device->plugin->get_capabilities(); for (cap = 0; capabilities[cap]; cap++) { - if (!(hwo = sr_find_hwcap_option(capabilities[cap]))) + if (!(hwo = sr_hwplugins_hwcap_get(capabilities[cap]))) continue; if (title) { @@ -212,7 +213,7 @@ static void show_device_detail(void) if (hwo->capability == SR_HWCAP_PATTERN_MODE) { printf(" %s", hwo->shortname); - if (sr_dev_get_info(device, SR_DI_PATTERNMODES, + if (sr_dev_info_get(device, SR_DI_PATTERNMODES, (const void **)&stropts) == SR_OK) { printf(" - supported modes:\n"); for (i = 0; stropts[i]; i++) @@ -223,7 +224,7 @@ static void show_device_detail(void) } else if (hwo->capability == SR_HWCAP_SAMPLERATE) { printf(" %s", hwo->shortname); /* Supported samplerates */ - if (sr_dev_get_info(device, SR_DI_SAMPLERATES, + if (sr_dev_info_get(device, SR_DI_SAMPLERATES, (const void **)&samplerates) != SR_OK) { printf("\n"); continue; @@ -265,7 +266,7 @@ static void show_pd_detail(void) pdtokens = g_strsplit(opt_pds, ",", -1); for (pdtok = pdtokens; *pdtok; pdtok++) { - if (!(dec = srd_get_decoder_by_id(*pdtok))) { + if (!(dec = srd_decoder_get_by_id(*pdtok))) { printf("Protocol decoder %s not found.", *pdtok); return; } @@ -484,8 +485,12 @@ static int register_pds(struct sr_device *device, const char *pdstring) pd_name = g_strdup(g_hash_table_lookup(pd_opthash, "sigrok_key")); g_hash_table_remove(pd_opthash, "sigrok_key"); + if (srd_decoder_load(pd_name) != SRD_OK) { + fprintf(stderr, "Failed to load protocol decoder %s\n", pd_name); + goto err_out; + } if (!(di = srd_inst_new(pd_name, pd_opthash))) { - fprintf(stderr, "Failed to instantiate PD %s\n", pd_name); + fprintf(stderr, "Failed to instantiate protocol decoder %s\n", pd_name); goto err_out; } g_datalist_set_data(&pd_ann_visible, di->inst_id, pd_name); @@ -494,7 +499,7 @@ static int register_pds(struct sr_device *device, const char *pdstring) * is the probe name as specified in the decoder class, and the * value is the probe number i.e. the order in which the PD's * incoming samples are arranged. */ - if (srd_inst_set_probes(di, pd_opthash) != SRD_OK) + if (srd_inst_probes_set(di, pd_opthash) != SRD_OK) goto err_out; g_hash_table_destroy(pd_opthash); pd_opthash = NULL; @@ -782,7 +787,7 @@ static void run_session(void) { struct sr_device *device; GHashTable *devargs; - int num_devices, max_probes, *capabilities, i; + int num_devices, max_probes, i; uint64_t time_msec; char **probelist, *devspec; @@ -832,8 +837,7 @@ static void run_session(void) return; if (opt_continuous) { - capabilities = device->plugin->get_capabilities(); - if (!sr_has_hwcap(capabilities, SR_HWCAP_CONTINUOUS)) { + if (!sr_hwplugin_has_hwcap(device->plugin, SR_HWCAP_CONTINUOUS)) { printf("This device does not support continuous sampling."); sr_session_destroy(); return; @@ -865,8 +869,7 @@ static void run_session(void) return; } - capabilities = device->plugin->get_capabilities(); - if (sr_has_hwcap(capabilities, SR_HWCAP_LIMIT_MSEC)) { + if (sr_hwplugin_has_hwcap(device->plugin, SR_HWCAP_LIMIT_MSEC)) { if (device->plugin->set_configuration(device->plugin_index, SR_HWCAP_LIMIT_MSEC, &time_msec) != SR_OK) { printf("Failed to configure time limit.\n"); @@ -882,7 +885,7 @@ static void run_session(void) if (sr_dev_has_hwcap(device, SR_HWCAP_SAMPLERATE)) { const uint64_t *samplerate; - sr_dev_get_info(device, SR_DI_CUR_SAMPLERATE, + sr_dev_info_get(device, SR_DI_CUR_SAMPLERATE, (const void **)&samplerate); limit_samples = (*samplerate) * time_msec / (uint64_t)1000; }