Browse Source

Allow external reporting of friendly names for DATAQ hardware

Neal Wilson 11 years ago
parent
commit
ec89aacaf4
1 changed files with 16 additions and 5 deletions
  1. 16
    5
      src/dataqsdk.w

+ 16
- 5
src/dataqsdk.w View File

@@ -31,6 +31,7 @@ class DataqSdkDevice : public QObject
31 31
 		Q_INVOKABLE void setClockRate(double Hz);
32 32
 		Q_INVOKABLE void start();
33 33
 		QStringList detectPorts();
34
+		QStringList detectHardware(); // Friendly names
34 35
 };
35 36
 
36 37
 @ The |DataqSdkDevice| class has as a private member an instance of a class
@@ -425,7 +426,7 @@ useful to have a way to report the ports where supported hardware has been
425 426
 detected. This is also used for automatic detection.
426 427
 
427 428
 @<DataqSdkDevice implementation@>=
428
-QStringList DataqSdkDevice::detectPorts()
429
+QStringList DataqSdkDevice::detectHardware()
429 430
 {
430 431
 	QSettings deviceLookup("HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\services\\usbser\\Enum",
431 432
 	             QSettings::NativeFormat);
@@ -444,10 +445,20 @@ QStringList DataqSdkDevice::detectPorts()
444 445
 	{
445 446
 		QString deviceKey = QString("HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Enum\\USB\\VID_0683&PID_1450\\%1").arg(device);
446 447
 		QSettings deviceEntry(deviceKey, QSettings::NativeFormat);
447
-		QString friendlyName = deviceEntry.value("FriendlyName").toString();
448
-		friendlyName.remove(0, friendlyName.indexOf("COM"));
449
-		friendlyName.chop(1);
450
-		portList.append(friendlyName);
448
+		portList.append(deviceEntry.value("FriendlyName").toString());
449
+	}
450
+	return portList;
451
+}
452
+
453
+QStringList DataqSdkDevice::detectPorts()
454
+{
455
+	QStringList friendlyNames = detectHardware();
456
+	QStringList portList;
457
+	foreach(QString name, friendlyNames)
458
+	{
459
+		name.remove(0, name.indexOf("COM"));
460
+		name.chop(1);
461
+		portList.append(name);
451 462
 	}
452 463
 	return portList;
453 464
 }

Loading…
Cancel
Save