"run_session()" will exit if you have no real device attached, and trying to use demo driver

$ ./cli/sigrok -d demo --samples 100
$ No devices found.
$

That's not the correct behaviour, because we might use "demo" driver. The problem is here:

540         device_scan();
541         num_devices = num_real_devices();
542
543         if (num_devices == 0) {
544                 g_warning("No devices found.");
545                 return;
546         }
547


I'm not sure to understand, why we make the distinction between demo driver and real drivers.

The attached patch fixes the bug by considering demo as a real driver.


Olivier


--
Olivier Fauchon
www.oflabs.com
diff --git a/cli/parsers.c b/cli/parsers.c
index a239700..fa43409 100644
--- a/cli/parsers.c
+++ b/cli/parsers.c
@@ -203,7 +203,7 @@ struct device *parse_devicestring(char *devicestring)
 {
 	struct device *device, *d;
 	GSList *devices, *l;
-	int num_devices, device_num, device_cnt;;
+	int num_dev, device_num, device_cnt;;
 	char *tmp;
 
 	if (!devicestring)
@@ -211,8 +211,8 @@ struct device *parse_devicestring(char *devicestring)
 
 	device_num = strtol(devicestring, &tmp, 10);
 	if (tmp != devicestring) {
-		num_devices = num_real_devices();
-		if (device_num < 0 || device_num >= num_devices)
+		num_dev = num_devices();
+		if (device_num < 0 || device_num >= num_dev)
 			return NULL;
 	}
 
diff --git a/cli/sigrok-cli.c b/cli/sigrok-cli.c
index a2fe455..df0f3b7 100644
--- a/cli/sigrok-cli.c
+++ b/cli/sigrok-cli.c
@@ -506,7 +506,7 @@ void load_file(void)
 }
 
 
-int num_real_devices(void)
+int num_devices(void)
 {
 	struct device *device;
 	GSList *devices, *l;
@@ -516,8 +516,7 @@ int num_real_devices(void)
 	devices = device_list();
 	for (l = devices; l; l = l->next) {
 		device = l->data;
-		if (!strstr(device->plugin->name, "demo"))
-			num_devices++;
+		num_devices++;
 	}
 
 	return num_devices;
@@ -528,7 +527,7 @@ void run_session(void)
 	struct device *device;
 	struct probe *probe;
 	GPollFD *fds;
-	int num_devices, max_probes, *capabilities, ret, found, i, j;
+	int num_dev, max_probes, *capabilities, ret, found, i, j;
 	unsigned int time_msec;
 	uint64_t tmp_u64;
 	char **probelist, *val;
@@ -538,19 +537,19 @@ void run_session(void)
 		register_pds(NULL, opt_pds);
 
 	device_scan();
-	num_devices = num_real_devices();
+	num_dev = num_devices();
 
-	if (num_devices == 0) {
+	if (num_dev == 0) {
 		g_warning("No devices found.");
 		return;
 	}
 
 	if (!opt_device) {
-		if (num_devices == 1)
+		if (num_dev == 1)
 			/* No device specified, but there is only one. */
 			device = parse_devicestring("0");
 		else {
-			g_warning("%d devices found, please select one.", num_devices);
+			g_warning("%d devices found, please select one.", num_dev);
 			return;
 		}
 	} else {
diff --git a/cli/sigrok-cli.h b/cli/sigrok-cli.h
index aa06fdd..5acdfe1 100644
--- a/cli/sigrok-cli.h
+++ b/cli/sigrok-cli.h
@@ -22,7 +22,7 @@
 #define SIGROK_CLI_H_
 
 /* sigrok-cli.c */
-int num_real_devices(void);
+int num_devices(void);
 
 /* parsers.c */
 char **parse_probestring(int max_probes, char *probestring);
------------------------------------------------------------------------------
Gaining the trust of online customers is vital for the success of any company
that requires sensitive data to be transmitted over the Web.   Learn how to 
best implement a security strategy that keeps consumers' information secure 
and instills the confidence they need to proceed with transactions.
http://p.sf.net/sfu/oracle-sfdevnl 
_______________________________________________
sigrok-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sigrok-devel

Reply via email to