File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99import argparse
1010import time
1111import logging
12+ import sys
1213
1314from openxc .formats .json import JsonFormatter
1415from .common import device_options , configure_logging , select_device
@@ -31,11 +32,14 @@ def parse_options():
3132
3233
3334def main ():
34- configure_logging (logging .DEBUG )
35- arguments = parse_options ()
36-
37- source_class , source_kwargs = select_device (arguments )
38- source = source_class (callback = receive , ** source_kwargs )
39- source .start ()
40- # TODO test this, I'd prefer it to the sleep loop
41- source .join ()
35+ try :
36+ configure_logging (logging .DEBUG )
37+ arguments = parse_options ()
38+ source_class , source_kwargs = select_device (arguments )
39+ source = source_class (callback = receive , ** source_kwargs )
40+ source .start ()
41+ # TODO test this, I'd prefer it to the sleep loop
42+ while (True ):
43+ source .join (0.1 )
44+ except KeyboardInterrupt :
45+ sys .exit (0 )
Original file line number Diff line number Diff line change 66module are internal only.
77"""
88
9-
9+ import sys
1010import argparse
1111from collections import defaultdict
1212
@@ -98,11 +98,14 @@ def parse_options():
9898
9999
100100def main ():
101- configure_logging ()
102- arguments = parse_options ()
103-
104- controller_class , controller_kwargs = select_device (arguments )
105- controller = controller_class (** controller_kwargs )
106- controller .start ()
107-
108- scan (controller , arguments .bus , arguments .message_id )
101+ try :
102+ configure_logging ()
103+ arguments = parse_options ()
104+
105+ controller_class , controller_kwargs = select_device (arguments )
106+ controller = controller_class (** controller_kwargs )
107+ controller .start ()
108+ while (True ):
109+ scan (controller , arguments .bus , arguments .message_id )
110+ except KeyboardInterrupt :
111+ sys .exit (0 )
You can’t perform that action at this time.
0 commit comments