Ejemplo n.º 1
0
def ds1307slave(board):
    server = cpboard.Server(board, ds1307slave_func, out=sys.stdout)
    server.start((0x68, ))
    time.sleep(1)
    yield server
    server.stop()
    sys.stderr.write('slave: Slave stopped:\n')
Ejemplo n.º 2
0
def request_slave(request, board):
    tout = request.config.option.smbus_timeout
    server = cpboard.Server(board, request_slave_func, out=sys.stdout)
    server.start(tout, (0x40, ), request.param)
    time.sleep(1)
    yield server
    server.stop()
Ejemplo n.º 3
0
def test_server_stopped(board):
    server = cpboard.Server(board, board_test_server_stopped, out=sys.stdout)
    server.start()
    time.sleep(0.5)
    with pytest.raises(RuntimeError) as exc_info:
        server.check()
    assert 'stopped' in exc_info.value.args[0]
    assert 'ENTER' in server.output
Ejemplo n.º 4
0
def test_server(board):
    server = cpboard.Server(board, board_test_server, out=sys.stdout)
    server.start(23, b=17)
    time.sleep(0.5)
    out = server.check()
    assert 'ENTER 23 17 .' in out
    server.stop()
    assert 'EXIT' not in server.output
Ejemplo n.º 5
0
def start_check_host_connect(board, pin, val):
    server = cpboard.Server(board, check_host_connect_func, out=sys.stdout)
    server.start(pin, val)
    time.sleep(1)
    try:
        server.check()
    except Exception:
        return None
    return server
Ejemplo n.º 6
0
def slave(request, board):
    tout = request.config.option.smbus_timeout
    server = cpboard.Server(board, slave_func, out=sys.stdout)
    print("slave: Start slave: %r" % (request.param, ))
    server.start(tout, request.param)
    time.sleep(1)

    yield server

    print('slave: Back from yield')
    server.stop()
    sys.stderr.write('slave: Slave stopped:\n')
Ejemplo n.º 7
0
def test_server_raises(board, stop):
    server = cpboard.Server(board, board_test_server_raises, out=sys.stdout)
    server.start()
    time.sleep(0.5)
    out = server.check()
    assert 'ENTER' in out
    time.sleep(3)
    with pytest.raises(ValueError) as exc_info:
        if stop:
            server.stop()
        else:
            server.check()
    assert exc_info.value.args[0] == 'Oh no'
Ejemplo n.º 8
0
def mcp23008slave(request, board, digital_connect, host_connect):
    tout = request.config.option.smbus_timeout
    server = cpboard.Server(board, mcp23008slave_func, out=sys.stdout)
    pins = digital_connect
    if not pins:
        pins = [None, None]
    pins += ['D13']  # Red led

    intpin = host_connect[1] if host_connect else None

    server.start(tout, address, pins, intpin)
    time.sleep(1)
    yield server
    server.stop()
Ejemplo n.º 9
0
def at24slave(board):
    server = cpboard.Server(board, at24slave_func, out=sys.stdout)
    server.start(address)
    time.sleep(1)
    yield server
    server.stop()
Ejemplo n.º 10
0
def ds1307slave(board):
    server = cpboard.Server(board, ds1307slave_func, out=sys.stdout)
    server.start()
    time.sleep(1)
    yield server
    server.stop()