コード例 #1
0
ファイル: run_test.py プロジェクト: larsks/avr-mbot-backoff
def run_test(f_cpu, mcu, timeout, gdb, testfile):
    avr = Avr(mcu=mcu, f_cpu=f_cpu)
    fw = Firmware(testfile)
    avr.load_firmware(fw)

    if gdb:
        avr.gdb_port = 1234
        avr_gdb_init(avr.backend)
        avr.state = cpu_Stopped

    t_start = time.time()
    while not avr.peek(GPIOR0) & TEST_COMPLETE:
        if timeout and time.time() - t_start > timeout:
            raise click.ClickException('Timeout')
        avr.step(100)

    if avr.uart.buffer:
        print(''.join(avr.uart.buffer))

    sys.exit(0 if avr.peek(GPIOR0) & TEST_SUCCESS else 1)