]> sigrok.org Git - sigrok-meter.git/blobdiff - sigrok-meter
Allow saving the log messages to a file.
[sigrok-meter.git] / sigrok-meter
index 884ad2d08781a187db2f83f67615484166061ca8..c991fad0e5fdf3dfddac710d0e557ead8b641a4b 100755 (executable)
@@ -24,17 +24,18 @@ import argparse
 import sigrok.core as sr
 import sys
 import textwrap
+import signal
 
 default_drivers = [('demo:analog_channels=4', 'samplerate=4')]
-default_loglevel = 2
 
 def parse_cli():
     parser = argparse.ArgumentParser(
         description='Simple sigrok GUI for multimeters and dataloggers.',
         epilog=textwrap.dedent('''\
-            The DRIVER string is the same as for sigrok-cli(1). The nth
-            CONFIG is applied to the nth DRIVER. If there are more drivers
-            than configs, the remaining drivers use the default configuration.
+            The DRIVER string is the same as for sigrok-cli(1). Multiple
+            DRIVER and CONFIG items can be supplied. The nth CONFIG is applied
+            to the nth DRIVER. If there are more drivers than configs, the
+            remaining drivers use the default configuration.
 
             Examples:
 
@@ -44,6 +45,10 @@ def parse_cli():
 
               %(prog)s --driver demo:analog_channels=1 \\
                        --config samplerate=10
+
+              %(prog)s --driver voltcraft-k204:conn=/dev/ttyUSB0 \\
+                       --driver uni-t-ut61d:conn=1a86.e008 \\
+                       --driver uni-t-ut61e-ser:conn=/dev/ttyUSB1
         '''),
         formatter_class=argparse.RawDescriptionHelpFormatter)
 
@@ -57,7 +62,7 @@ def parse_cli():
         help='Specify device configuration options')
     parser.add_argument('-l', '--loglevel',
         type=int,
-        default=default_loglevel,
+        default=None,
         help='Set loglevel (5 is most verbose)')
     parser.add_argument('--pyside',
         action='store_true',
@@ -82,6 +87,8 @@ def parse_cli():
     return args
 
 if __name__ == '__main__':
+    signal.signal(signal.SIGINT, signal.SIG_DFL)
+
     args = parse_cli()
 
     import qtcompat
@@ -90,14 +97,23 @@ if __name__ == '__main__':
     QtGui = qtcompat.QtGui
     import mainwindow
 
+    app = QtGui.QApplication([])
+
+    # Initialize modules that need a QApplication to exist.
+    import settings
+    settings.init()
+    import icons
+    icons.load_icons()
+
     context = sr.Context_create()
-    try:
-        loglevel = sr.LogLevel.get(args.loglevel)
-        context.log_level = loglevel
-    except:
-        sys.exit('Error: invalid log level.')
 
-    app = QtGui.QApplication([])
+    if args.loglevel != None:
+        try:
+            loglevel = sr.LogLevel.get(args.loglevel)
+            settings.logging.level.setValue(loglevel)
+        except:
+            sys.exit('Error: invalid log level.')
+
     s = mainwindow.MainWindow(context, args.drivers)
     s.show()