|
21 | 21 | parser.add_argument("--debug", action='store_true', help="enable debugging")
|
22 | 22 | parser.add_argument("--dsdl", help="path to custom DSDL")
|
23 | 23 | parser.add_argument("--signing-passphrase", help="MAVLink2 signing passphrase", default=None)
|
| 24 | +parser.add_argument("--interface", help="skip the setup dialog by setting the device to connect to") |
| 25 | +parser.add_argument("--baudrate", help="set the baudrate", type=int, default=115200) |
| 26 | +parser.add_argument("--bitrate", help="set the bitrate of the CAN Bus", type=int, default=1000000) |
| 27 | +parser.add_argument("--bus", help="set the CAN Bus number", type=int, default=1) |
| 28 | +parser.add_argument("--filtered", action='store_true', help="enable filtering of DroneCAN traffic") |
| 29 | +parser.add_argument("--target-system", help="set the targetted system", type=int, default=0) |
24 | 30 |
|
25 | 31 | args = parser.parse_args()
|
26 | 32 |
|
|
60 | 66 | #
|
61 | 67 | # Importing other stuff once the logging has been configured
|
62 | 68 | #
|
| 69 | +from serial import SerialException |
| 70 | + |
63 | 71 | import dronecan
|
64 | 72 |
|
65 | 73 | from PyQt5.QtWidgets import QApplication, QMainWindow, QWidget, QVBoxLayout, QSplitter, QAction
|
@@ -578,7 +586,18 @@ def main():
|
578 | 586 | while True:
|
579 | 587 | # Asking the user to specify which interface to work with
|
580 | 588 | try:
|
581 |
| - iface, iface_kwargs, dsdl_directory = run_setup_window(get_app_icon(), args.dsdl) |
| 589 | + if args.interface is not None: |
| 590 | + iface = args.interface |
| 591 | + iface_kwargs = {} |
| 592 | + iface_kwargs['baudrate'] = int(args.baudrate) |
| 593 | + iface_kwargs['bitrate'] = int(args.bitrate) |
| 594 | + iface_kwargs['bus_number'] = int(args.bus) |
| 595 | + iface_kwargs['filtered'] = bool(args.filtered) |
| 596 | + iface_kwargs['mavlink_target_system'] = int(args.target_system) |
| 597 | + iface_kwargs['mavlink_signing_key'] = str(args.signing_passphrase if args.signing_passphrase is not None else '') |
| 598 | + dsdl_directory = args.dsdl |
| 599 | + else: |
| 600 | + iface, iface_kwargs, dsdl_directory = run_setup_window(get_app_icon(), args.dsdl, args.baudrate, args.bitrate, args.bus, args.filtered, args.target_system, args.signing_passphrase) |
582 | 601 | if not iface:
|
583 | 602 | sys.exit(0)
|
584 | 603 | except Exception as ex:
|
@@ -624,6 +643,13 @@ def main():
|
624 | 643 | # allow unrecognized messages on startup:
|
625 | 644 | logger.warning('DroneCAN Transfer Error occurred on startup', exc_info=True)
|
626 | 645 | break
|
| 646 | + except SerialException as ex: |
| 647 | + logger.error('DroneCAN node init failed', exc_info=True) |
| 648 | + show_error('Error', 'Could not find serial port', ex, blocking=True) |
| 649 | + |
| 650 | + # The serial port had a fault, so reset args and the interface and return to the setup window |
| 651 | + args.interface = None |
| 652 | + iface = None |
627 | 653 | except Exception as ex:
|
628 | 654 | logger.error('DroneCAN node init failed', exc_info=True)
|
629 | 655 | show_error('Fatal error', 'Could not initialize DroneCAN node', ex, blocking=True)
|
|
0 commit comments