]> sigrok.org Git - sigrok-cli.git/blobdiff - sigrok-cli.c
srd/cli/qt:s/decoders/decoder/ for consistency.
[sigrok-cli.git] / sigrok-cli.c
index de173b76587b3127d998c28787840d8a8118c8a8..a2db18f9b1703eaffb52fafc7410b8839d5eb47f 100644 (file)
@@ -58,7 +58,7 @@ static gchar *opt_triggers = NULL;
 static gchar *opt_pds = NULL;
 static gchar *opt_pd_stack = NULL;
 static gchar *opt_input_format = NULL;
-static gchar *opt_format = NULL;
+static gchar *opt_output_format = NULL;
 static gchar *opt_time = NULL;
 static gchar *opt_samples = NULL;
 static gchar *opt_continuous = NULL;
@@ -76,7 +76,7 @@ static GOptionEntry optargs[] = {
        {"protocol-decoders", 'a', 0, G_OPTION_ARG_STRING, &opt_pds, "Protocol decoder sequence", NULL},
        {"protocol-decoder-stack", 's', 0, G_OPTION_ARG_STRING, &opt_pd_stack, "Protocol decoder stack", NULL},
        {"input-format", 'I', 0, G_OPTION_ARG_STRING, &opt_input_format, "Input format", NULL},
-       {"format", 'f', 0, G_OPTION_ARG_STRING, &opt_format, "Output format", NULL},
+       {"output-format", 'O', 0, G_OPTION_ARG_STRING, &opt_output_format, "Output format", NULL},
        {"time", 0, 0, G_OPTION_ARG_STRING, &opt_time, "How long to sample (ms)", NULL},
        {"samples", 0, 0, G_OPTION_ARG_STRING, &opt_samples, "Number of samples to acquire", NULL},
        {"continuous", 0, 0, G_OPTION_ARG_NONE, &opt_continuous, "Sample continuously", NULL},
@@ -85,8 +85,8 @@ static GOptionEntry optargs[] = {
 
 static void show_version(void)
 {
-       GSList *plugins, *p, *l;
-       struct sr_dev_plugin *plugin;
+       GSList *l;
+       struct sr_dev_driver **drivers;
        struct sr_input_format **inputs;
        struct sr_output_format **outputs;
        struct srd_decoder *dec;
@@ -95,10 +95,9 @@ static void show_version(void)
        printf("sigrok-cli %s\n\n", VERSION);
 
        printf("Supported hardware drivers:\n");
-       plugins = sr_hw_list();
-       for (p = plugins; p; p = p->next) {
-               plugin = p->data;
-               printf("  %-20s %s\n", plugin->name, plugin->longname);
+       drivers = sr_driver_list();
+       for (i = 0; drivers[i]; i++) {
+               printf("  %-20s %s\n", drivers[i]->name, drivers[i]->longname);
        }
        printf("\n");
 
@@ -116,8 +115,8 @@ static void show_version(void)
 
        if (srd_init(NULL) == SRD_OK) {
                printf("Supported protocol decoders:\n");
-               srd_decoders_load_all();
-               for (l = srd_decoders_list(); l; l = l->next) {
+               srd_decoder_load_all();
+               for (l = srd_decoder_list(); l; l = l->next) {
                        dec = l->data;
                        printf("  %-20s %s\n", dec->id, dec->longname);
                }
@@ -201,7 +200,7 @@ static void show_dev_detail(void)
        }
 
        title = "Supported options:\n";
-       hwcaps = dev->plugin->hwcap_get_all();
+       hwcaps = dev->driver->hwcap_get_all();
        for (cap = 0; hwcaps[cap]; cap++) {
                if (!(hwo = sr_hw_hwcap_get(hwcaps[cap])))
                        continue;
@@ -249,7 +248,7 @@ static void show_dev_detail(void)
                        } else {
                                printf(" - supported samplerates:\n");
                                for (i = 0; samplerates->list[i]; i++) {
-                                       printf("      %7s\n", sr_samplerate_string(samplerates->list[i]));
+                                       printf("      %s\n", sr_samplerate_string(samplerates->list[i]));
                                }
                        }
                } else {
@@ -352,7 +351,7 @@ static void datafeed_in(struct sr_dev *dev, struct sr_datafeed_packet *packet)
                                }
                        } else {
                                /* saving to a file in whatever format was set
-                                * with --format, so all we need is a filehandle */
+                                * with -O, so all we need is a filehandle */
                                outfile = g_fopen(opt_output_file, "wb");
                        }
                }
@@ -515,13 +514,13 @@ err_out:
        return 0;
 }
 
-void show_pd_annotation(struct srd_proto_data *pdata, void *user_data)
+void show_pd_annotation(struct srd_proto_data *pdata, void *cb_data)
 {
        int i;
        char **annotations;
 
-       /* 'user_data' is not used in this specific callback. */
-       (void)user_data;
+       /* 'cb_data' is not used in this specific callback. */
+       (void)cb_data;
 
        if (pdata->ann_format != 0) {
                /* CLI only shows the default annotation format. */
@@ -564,7 +563,7 @@ static int select_probes(struct sr_dev *dev)
 
        for (i = 0; i < max_probes; i++) {
                if (probelist[i]) {
-                       sr_dev_probe_name(dev, i + 1, probelist[i]);
+                       sr_dev_probe_name_set(dev, i + 1, probelist[i]);
                        g_free(probelist[i]);
                } else {
                        probe = sr_dev_probe_find(dev, i + 1);
@@ -747,11 +746,11 @@ static int set_dev_options(struct sr_dev *dev, GHashTable *args)
                                ret = sr_parse_sizestring(value, &tmp_u64);
                                if (ret != SR_OK)
                                        break;
-                               ret = dev->plugin->config_set(dev->plugin_index,
+                               ret = dev->driver->dev_config_set(dev->driver_index,
                                        sr_hwcap_options[i].hwcap, &tmp_u64);
                                break;
                        case SR_T_CHAR:
-                               ret = dev->plugin->config_set(dev->plugin_index,
+                               ret = dev->driver->dev_config_set(dev->driver_index,
                                        sr_hwcap_options[i].hwcap, value);
                                break;
                        case SR_T_BOOL:
@@ -759,7 +758,7 @@ static int set_dev_options(struct sr_dev *dev, GHashTable *args)
                                        tmp_bool = TRUE;
                                else 
                                        tmp_bool = sr_parse_boolstring(value);
-                               ret = dev->plugin->config_set(dev->plugin_index,
+                               ret = dev->driver->dev_config_set(dev->driver_index,
                                                sr_hwcap_options[i].hwcap, 
                                                GINT_TO_POINTER(tmp_bool));
                                break;
@@ -837,7 +836,7 @@ static void run_session(void)
             return;
 
        if (opt_continuous) {
-               if (!sr_hw_has_hwcap(dev->plugin, SR_HWCAP_CONTINUOUS)) {
+               if (!sr_driver_hwcap_exists(dev->driver, SR_HWCAP_CONTINUOUS)) {
                        printf("This device does not support continuous sampling.");
                        sr_session_destroy();
                        return;
@@ -869,8 +868,8 @@ static void run_session(void)
                        return;
                }
 
-               if (sr_hw_has_hwcap(dev->plugin, SR_HWCAP_LIMIT_MSEC)) {
-                       if (dev->plugin->config_set(dev->plugin_index,
+               if (sr_driver_hwcap_exists(dev->driver, SR_HWCAP_LIMIT_MSEC)) {
+                       if (dev->driver->dev_config_set(dev->driver_index,
                            SR_HWCAP_LIMIT_MSEC, &time_msec) != SR_OK) {
                                printf("Failed to configure time limit.\n");
                                sr_session_destroy();
@@ -895,7 +894,7 @@ static void run_session(void)
                                return;
                        }
 
-                       if (dev->plugin->config_set(dev->plugin_index,
+                       if (dev->driver->dev_config_set(dev->driver_index,
                            SR_HWCAP_LIMIT_SAMPLES, &limit_samples) != SR_OK) {
                                printf("Failed to configure time-based sample limit.\n");
                                sr_session_destroy();
@@ -906,7 +905,7 @@ static void run_session(void)
 
        if (opt_samples) {
                if ((sr_parse_sizestring(opt_samples, &limit_samples) != SR_OK)
-                       || (dev->plugin->config_set(dev->plugin_index,
+                       || (dev->driver->dev_config_set(dev->driver_index,
                            SR_HWCAP_LIMIT_SAMPLES, &limit_samples) != SR_OK)) {
                        printf("Failed to configure sample limit.\n");
                        sr_session_destroy();
@@ -914,7 +913,7 @@ static void run_session(void)
                }
        }
 
-       if (dev->plugin->config_set(dev->plugin_index,
+       if (dev->driver->dev_config_set(dev->driver_index,
                  SR_HWCAP_PROBECONFIG, (char *)dev->probes) != SR_OK) {
                printf("Failed to configure probes.\n");
                sr_session_destroy();
@@ -944,11 +943,11 @@ static void run_session(void)
 }
 
 static void logger(const gchar *log_domain, GLogLevelFlags log_level,
-                  const gchar *message, gpointer user_data)
+                  const gchar *message, gpointer cb_data)
 {
        /* Avoid compiler warnings. */
        (void)log_domain;
-       (void)user_data;
+       (void)cb_data;
 
        /*
         * All messages, warnings, errors etc. go to stderr (not stdout) in
@@ -1053,14 +1052,14 @@ int main(int argc, char **argv)
                g_strfreev(pds);
        }
 
-       if (!opt_format) {
-               opt_format = DEFAULT_OUTPUT_FORMAT;
+       if (!opt_output_format) {
+               opt_output_format = DEFAULT_OUTPUT_FORMAT;
                /* we'll need to remember this so when saving to a file
                 * later, sigrok session format will be used.
                 */
                default_output_format = TRUE;
        }
-       fmtargs = parse_generic_arg(opt_format);
+       fmtargs = parse_generic_arg(opt_output_format);
        fmtspec = g_hash_table_lookup(fmtargs, "sigrok_key");
        if (!fmtspec) {
                printf("Invalid output format.\n");
@@ -1082,7 +1081,7 @@ int main(int argc, char **argv)
                break;
        }
        if (!output_format) {
-               printf("invalid output format %s\n", opt_format);
+               printf("invalid output format %s\n", opt_output_format);
                return 1;
        }