From: Gerhard Sittig Date: Thu, 11 Apr 2019 18:12:44 +0000 (+0200) Subject: add --dont-scan (-D) command line option X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=b20ea789170c7bb52c54b23c0167992bceb9a330;p=sigrok-cli.git add --dont-scan (-D) command line option Introduce the -D or --dont-scan command line option. This avoids automatic driver scans, and exclusively uses what -d specifies. Some device drivers use non-standard protocol features since their supported devices don't support the corresponding standard mechanisms. Which can confuse conforming devices. In these situations it can be desirable to not scan automatically for available devices, instead do nothing until callers will specify the -d option. This change is motivated by but does not resolve bugs #1155 and #1373. --- diff --git a/device.c b/device.c index a159ff0..19192ec 100644 --- a/device.c +++ b/device.c @@ -35,12 +35,16 @@ GSList *device_scan(void) int i; if (opt_drv) { + /* Caller specified driver. Use it. Only this one. */ if (!parse_driver(opt_drv, &driver, &drvopts)) return NULL; devices = sr_driver_scan(driver, drvopts); g_slist_free_full(drvopts, (GDestroyNotify)free_drvopts); + } else if (opt_dont_scan) { + /* No -d choice, and -D "don't scan" requested. Do nothing. */ + devices = NULL; } else { - /* No driver specified, let them all scan on their own. */ + /* No driver specified. Scan all available drivers. */ devices = NULL; drivers = sr_driver_list(sr_ctx); for (i = 0; drivers[i]; i++) { diff --git a/doc/sigrok-cli.1 b/doc/sigrok-cli.1 index 54fb285..e5562c1 100644 --- a/doc/sigrok-cli.1 +++ b/doc/sigrok-cli.1 @@ -59,6 +59,11 @@ USB \fBbus.address\fP example: .sp .RB " $ " "sigrok\-cli \-\-driver=uni\-t\-ut61e:conn=4.6" " [...]" .TP +.B "\-D, \-\-dont\-scan" +Do not automatically scan for device drivers in the absence of a +.BR "\-d " ( "\-\-driver" ) +specification. +.TP .BR "\-c, \-\-config " A colon-separated list of device options, where each option takes the form .BR key=value . diff --git a/options.c b/options.c index af6a7fe..3ec4414 100644 --- a/options.c +++ b/options.c @@ -26,6 +26,7 @@ gboolean opt_list_supported = FALSE; gboolean opt_list_supported_wiki = FALSE; gint opt_loglevel = SR_LOG_WARN; /* Show errors+warnings by default. */ gboolean opt_scan_devs = FALSE; +gboolean opt_dont_scan = FALSE; gboolean opt_wait_trigger = FALSE; gchar *opt_input_file = NULL; gchar *opt_output_file = NULL; @@ -143,6 +144,8 @@ static const GOptionEntry optargs[] = { #endif {"scan", 0, 0, G_OPTION_ARG_NONE, &opt_scan_devs, "Scan for devices", NULL}, + {"dont-scan", 'D', 0, G_OPTION_ARG_NONE, &opt_dont_scan, + "Don't auto-scan (use -d spec only)", NULL}, {"show", 0, 0, G_OPTION_ARG_NONE, &opt_show, "Show device/format/decoder details", NULL}, {"time", 0, 0, G_OPTION_ARG_CALLBACK, &check_opt_time, diff --git a/sigrok-cli.h b/sigrok-cli.h index c71586a..12a1462 100644 --- a/sigrok-cli.h +++ b/sigrok-cli.h @@ -99,6 +99,7 @@ extern gboolean opt_list_supported; extern gboolean opt_list_supported_wiki; extern gint opt_loglevel; extern gboolean opt_scan_devs; +extern gboolean opt_dont_scan; extern gboolean opt_wait_trigger; extern gchar *opt_input_file; extern gchar *opt_output_file;