X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=main.cpp;h=1e214e03f97df04c1f694b971ca25df0a36cc3eb;hp=8f495419fee7467de77c4074c32927ce658de919;hb=30677c1392b54604b01558cf29b44572731659fc;hpb=419ec4e11ee29e27566d1c0c17741fcad85dbdf6 diff --git a/main.cpp b/main.cpp index 8f495419..1e214e03 100644 --- 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" + " -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" @@ -80,6 +81,7 @@ int main(int argc, char *argv[]) shared_ptr context; string open_file, open_file_format, driver; bool restore_sessions = true; + bool do_scan = true; Application a(argc, argv); @@ -103,7 +105,7 @@ int main(int argc, char *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; @@ -121,6 +123,10 @@ int main(int argc, char *argv[]) case 'l': { const int loglevel = atoi(optarg); + if (loglevel < 0 || loglevel > 5) { + qDebug() << "ERROR: invalid log level spec."; + break; + } context->set_log_level(sigrok::LogLevel::get(loglevel)); #ifdef ENABLE_DECODE @@ -139,6 +145,10 @@ int main(int argc, char *argv[]) driver = optarg; break; + case 'D': + do_scan = false; + break; + case 'i': open_file = optarg; break; @@ -183,7 +193,7 @@ int main(int argc, char *argv[]) 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); @@ -216,7 +226,7 @@ int main(int argc, char *argv[]) // Run the application ret = a.exec(); - } catch (exception e) { + } catch (exception& e) { qDebug() << e.what(); }