예제 #1
0
def main(transport_logical_preset, application_preset):
    """Run echo test."""
    connection = connect_serial_retry(baudrate=115200, timeout=0.05)
    if connection is None:
        logger.fatal('Failed to establish serial connection!')
        return

    handlers = {
        'echo': LoggingHandler(b'echo', name='Echo'),
        'copy': LoggingHandler(b'copy', name='Copy'),
        'reply': LoggingHandler(b'reply', name='Reply'),
        'prefix': LoggingHandler(b'prefix', name='Prefix'),
        'blink': LoggingHandler(b'blink', name='Blink'),
        'ping-pong': PingPongHandler()
    }

    protocol = AutomaticStack(make_preset_stack(
        transport_logical=transport_logical_preset, application=application_preset
    ), list(handlers.values()), ReceiveLoggerLink())
    stack = PollingSerialAdapter(connection, protocol)
    logger.info(stack)

    time.sleep(1.0)
    run_once(run_console, stack, receive_once_blocking, handlers)
    logger.info('Quitting!')
예제 #2
0
def main(transport_logical_preset,
         application_preset,
         report_interval=None,
         limit=None):
    """Run loopback test."""
    connection = connect_serial_retry(baudrate=115200, timeout=0)
    if connection is None:
        logger.fatal('Failed to establish serial connection!')
        return

    protocol = make_preset_stack(transport_logical=transport_logical_preset,
                                 application=application_preset)
    stack = ThreadedSerialAdapter(
        connection, make_threading_stack(protocol_stack=protocol))
    logger.info(stack)

    (data, data_kwargs) = make_send_data(application_preset)
    time.sleep(1.0)
    run_echo(stack,
             receive_blocking,
             send_data,
             data,
             expected_data_kwargs=data_kwargs,
             report_interval=report_interval,
             limit=limit)
    logger.info('Quitting!')
예제 #3
0
def main(transport_logical_preset, application_preset):
    """Run receive test.."""
    connection = connect_serial_retry(baudrate=115200, timeout=1.0)
    if connection is None:
        logger.fatal('Failed to establish serial connection!')
        return

    protocol = make_preset_stack(transport_logical=transport_logical_preset,
                                 application=application_preset)
    logger.info(protocol)

    run_once(run_read, connection, protocol, receive_blocking)
    logger.info('Quitting!')
예제 #4
0
def main(transport_logical_preset, application_preset):
    """List the ports."""
    connection = connect_serial_retry(baudrate=115200, timeout=1.0)
    if connection is None:
        logger.fatal('Failed to establish serial connection!')
        return

    protocol = make_preset_stack(transport_logical=transport_logical_preset,
                                 application=application_preset)
    stack = PollingSerialAdapter(connection, protocol)
    logger.info(stack)

    run_once(run_read, stack, receive_blocking)
    logger.info('Quitting!')
예제 #5
0
def main(transport_logical_preset, application_preset):
    """Run echo test."""
    connection = connect_serial_retry(baudrate=115200, timeout=0.05)
    if connection is None:
        logger.fatal('Failed to establish serial connection!')
        return

    protocol = AutomaticStack(
        make_preset_stack(transport_logical=transport_logical_preset,
                          application=application_preset), ReceiveLoggerLink())
    stack = ThreadedSerialAdapter(
        connection, make_threading_stack(protocol_stack=protocol))
    logger.info(stack)

    time.sleep(1.0)
    run_once(run_console, stack, send_data, application_preset)
    logger.info('Quitting!')
예제 #6
0
def main():
    """Run read test."""
    connection = connect_serial_retry(baudrate=115200, timeout=None)
    read = b''
    while True:
        try:
            read += connection.read_until(b'\0')
            if len(read) > 1:
                logger.info(read)
                read = b''
        except SerialException:
            logging.error('Serial device disconnected!')
            return
        except (KeyboardInterrupt, EOFError):
            print()
            logger.info('Quitting!')
            return
예제 #7
0
def main():
    """List the ports."""
    connection = connect_serial_retry(baudrate=115200, timeout=1.0)
    read = b''
    while True:
        try:
            write = input('Write: ')
            if not write:
                raise EOFError
            write = write.encode('ascii') + b'\0'
            connection.write(write)
            read += connection.read_until(b'\0')
            if len(read) > 1:
                print(read)
                read = b''
        except (KeyboardInterrupt, EOFError):
            print()
            print('Quitting!')
            return
예제 #8
0
def main(transport_logical_preset, application_preset):
    """Run echo test."""
    connection = connect_serial_retry(baudrate=115200, timeout=1.0)
    if connection is None:
        logger.fatal('Failed to establish serial connection!')
        return

    protocol = make_preset_stack(
        transport_logical=transport_logical_preset, application=application_preset
    )
    stack = PollingSerialAdapter(connection, protocol)
    logger.info(stack)

    (data, data_kwargs) = make_send_data(application_preset)
    time.sleep(1.0)
    run_once(
        run_echo, stack, receive_blocking, send_data,
        data, expected_data_kwargs=data_kwargs
    )
    logger.info('Quitting!')