def wait_for_boot():
    deadline = time.monotonic() + BOOT_TIMEOUT

    def handle_serial_port_hanging():
        fatal(
            'DRWATSON HAS DETECTED A PROBLEM WITH CONNECTED HARDWARE AND NEEDS TO TERMINATE.\n'
            'A serial port operation has timed out. This usually indicates a problem with the connected '
            'hardware or its drivers. Please disconnect all USB devices currently connected to this computer, '
            "then connect them back and restart Drwatson. If you're using a virtual machine, please reboot it.",
            use_abort=True)

    with BackgroundDelay(BOOT_TIMEOUT * 5, handle_serial_port_hanging):
        with open_serial_port(DEBUGGER_PORT_CLI_GLOB,
                              timeout=BOOT_TIMEOUT) as p:
            try:
                for line in p:
                    if b'Zubax GNSS' in line:
                        return
                    logger.info('Debug UART output: %s', line)
                    if time.monotonic() > deadline:
                        break
            except IOError:
                logging.info('Boot error', exc_info=True)
            finally:
                p.flushInput()

    warning(
        "The board did not report to CLI with a correct boot message, but we're going "
        "to continue anyway. Possible reasons for this warning:\n"
        '1. The board could not boot properly (however it was flashed successfully).\n'
        '2. The debug connector is not soldered properly.\n'
        '3. The serial port is open by another application.\n'
        '4. Either USB-UART adapter or VM are malfunctioning. Try to re-connect the '
        'adapter (disconnect from USB and from the board!) or reboot the VM.')
예제 #2
0
def wait_for_boot():
    deadline = time.monotonic() + BOOT_TIMEOUT

    def handle_serial_port_hanging():
        fatal('DRWATSON HAS DETECTED A PROBLEM WITH THE CONNECTED HARDWARE AND NEEDS TO TERMINATE.\n'
              'A serial port operation has timed out. This usually indicates a problem with the connected '
              'hardware or its drivers. Please disconnect all USB devices currently connected to this computer, '
              "then connect them back and restart DrWatson. If you're using a virtual machine, please reboot it.",
              use_abort=True)

    with BackgroundDelay(BOOT_TIMEOUT * 5, handle_serial_port_hanging):
        with open_serial_port(DEBUGGER_PORT_CLI_GLOB, timeout=BOOT_TIMEOUT) as p:
            try:
                for line in p:
                    if b'zubax gnss' in line.lower() and b'bootloader' not in line.lower():
                        logging.info('Boot detected, waiting a few seconds...')
                        time.sleep(4)
                        return
                    logger.info('Debug UART output: %s', line)
                    if time.monotonic() > deadline:
                        break
            except serial.serialutil.SerialException:
                raise
            except IOError:
                logging.info('Boot error', exc_info=True)
            finally:
                p.flushInput()

    warning("The device did not emit a correct boot message via CLI, but we're going "
            "to continue anyway. Possible reasons for this warning:\n"
            '1. The device could not boot properly (however it was flashed successfully).\n'
            '2. The debug connector is not soldered properly.\n'
            '3. The serial port is opened by another application.\n'
            '4. Either the USB-UART adapter or the VM are malfunctioning. Try reconnecting '
            'the adapter (disconnect from USB and from the device!) or reboot the VM.')
def wait_for_boot():
    deadline = time.monotonic() + BOOT_TIMEOUT

    def handle_serial_port_hanging():
        fatal(
            "DRWATSON HAS DETECTED A PROBLEM WITH CONNECTED HARDWARE AND NEEDS TO TERMINATE.\n"
            "A serial port operation has timed out. This usually indicates a problem with the connected "
            "hardware or its drivers. Please disconnect all USB devices currently connected to this computer, "
            "then connect them back and restart Drwatson. If you're using a virtual machine, please reboot it.",
            use_abort=True,
        )

    with BackgroundDelay(BOOT_TIMEOUT * 5, handle_serial_port_hanging):
        with open_serial_port(DEBUGGER_PORT_CLI_GLOB, timeout=BOOT_TIMEOUT) as p:
            try:
                for line in p:
                    if b"Zubax GNSS" in line:
                        return
                    logger.info("Debug UART output: %s", line)
                    if time.monotonic() > deadline:
                        break
            except IOError:
                logging.info("Boot error", exc_info=True)
            finally:
                p.flushInput()

    warning(
        "The board did not report to CLI with a correct boot message, but we're going "
        "to continue anyway. Possible reasons for this warning:\n"
        "1. The board could not boot properly (however it was flashed successfully).\n"
        "2. The debug connector is not soldered properly.\n"
        "3. The serial port is open by another application.\n"
        "4. Either USB-UART adapter or VM are malfunctioning. Try to re-connect the "
        "adapter (disconnect from USB and from the board!) or reboot the VM."
    )