]> sigrok.org Git - pulseview.git/commitdiff
main: introduce -D cmdline option, don't auto-scan for devices
authorGerhard Sittig <redacted>
Wed, 24 Jan 2018 20:11:50 +0000 (21:11 +0100)
committerUwe Hermann <redacted>
Fri, 26 Jan 2018 16:35:31 +0000 (17:35 +0100)
Add a -D command line option which skips auto-detection of devices upon
startup. This can speedup program startup for setups with known devices,
and allows to skip the scan for troubled drivers which might break the
startup phase.

This -D option can be combined with -d specs, either presence or absence
of -d is acceptable when -D is specified. Users still can interactively
scan for and use devices after program startup.

This resolves bug #1116.

main.cpp
pv/devicemanager.cpp
pv/devicemanager.hpp

index 0f9aec2f7adc6316a1dd05d26b3417b12df454df..cd7e65d3cbbffa6d7a8ec949e02134c74af64c97 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -68,6 +68,7 @@ void usage()
                "  -V, --version                   Show release version\n"
                "  -l, --loglevel                  Set libsigrok/libsigrokdecode loglevel\n"
                "  -d, --driver                    Specify the device driver to use\n"
                "  -V, --version                   Show release version\n"
                "  -l, --loglevel                  Set libsigrok/libsigrokdecode loglevel\n"
                "  -d, --driver                    Specify the device driver to use\n"
+               "  -D, --no-scan                   Don't auto-scan for devices, use -d spec only\n"
                "  -i, --input-file                Load input from file\n"
                "  -I, --input-format              Input format\n"
                "  -c, --clean                     Don't restore previous sessions on startup\n"
                "  -i, --input-file                Load input from file\n"
                "  -I, --input-format              Input format\n"
                "  -c, --clean                     Don't restore previous sessions on startup\n"
@@ -80,6 +81,7 @@ int main(int argc, char *argv[])
        shared_ptr<sigrok::Context> context;
        string open_file, open_file_format, driver;
        bool restore_sessions = true;
        shared_ptr<sigrok::Context> context;
        string open_file, open_file_format, driver;
        bool restore_sessions = true;
+       bool do_scan = true;
 
        Application a(argc, argv);
 
 
        Application a(argc, argv);
 
@@ -103,7 +105,7 @@ int main(int argc, char *argv[])
                };
 
                const int c = getopt_long(argc, argv,
                };
 
                const int c = getopt_long(argc, argv,
-                       "l:Vhc?d:i:I:", long_options, nullptr);
+                       "l:Vhc?d:Di:I:", long_options, nullptr);
                if (c == -1)
                        break;
 
                if (c == -1)
                        break;
 
@@ -143,6 +145,10 @@ int main(int argc, char *argv[])
                        driver = optarg;
                        break;
 
                        driver = optarg;
                        break;
 
+               case 'D':
+                       do_scan = false;
+                       break;
+
                case 'i':
                        open_file = optarg;
                        break;
                case 'i':
                        open_file = optarg;
                        break;
@@ -187,7 +193,7 @@ int main(int argc, char *argv[])
 
                try {
                        // Create the device manager, initialise the drivers
 
                try {
                        // Create the device manager, initialise the drivers
-                       pv::DeviceManager device_manager(context, driver);
+                       pv::DeviceManager device_manager(context, driver, do_scan);
 
                        // Initialise the main window
                        pv::MainWindow w(device_manager);
 
                        // Initialise the main window
                        pv::MainWindow w(device_manager);
index ccd3716a7509ff342827b9b8eaac30c4f3bcd403..5920486a9d6d8df54f7bb8dc8135bc38ff1620a8 100644 (file)
@@ -56,7 +56,8 @@ using sigrok::Driver;
 
 namespace pv {
 
 
 namespace pv {
 
-DeviceManager::DeviceManager(shared_ptr<Context> context, std::string driver) :
+DeviceManager::DeviceManager(shared_ptr<Context> context,
+       std::string driver, bool do_scan) :
        context_(context)
 {
        unique_ptr<QProgressDialog> progress(new QProgressDialog("",
        context_(context)
 {
        unique_ptr<QProgressDialog> progress(new QProgressDialog("",
@@ -84,6 +85,8 @@ DeviceManager::DeviceManager(shared_ptr<Context> context, std::string driver) :
         * best effort auto detection.
         */
        for (auto entry : context->drivers()) {
         * best effort auto detection.
         */
        for (auto entry : context->drivers()) {
+               if (!do_scan)
+                       break;
                progress->setLabelText(QObject::tr("Scanning for %1...")
                        .arg(QString::fromStdString(entry.first)));
 
                progress->setLabelText(QObject::tr("Scanning for %1...")
                        .arg(QString::fromStdString(entry.first)));
 
index 2c9343001211409e8e836d95c9d5d623417ebcd2..92ed7dea5f85329567ca525ca2e955285df69212 100644 (file)
@@ -58,7 +58,8 @@ class Session;
 class DeviceManager
 {
 public:
 class DeviceManager
 {
 public:
-       DeviceManager(shared_ptr<sigrok::Context> context, std::string driver);
+       DeviceManager(shared_ptr<sigrok::Context> context,
+               std::string driver, bool do_scan);
 
        ~DeviceManager() = default;
 
 
        ~DeviceManager() = default;