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')
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()
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
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
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
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')
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'
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()
def at24slave(board): server = cpboard.Server(board, at24slave_func, out=sys.stdout) server.start(address) time.sleep(1) yield server server.stop()
def ds1307slave(board): server = cpboard.Server(board, ds1307slave_func, out=sys.stdout) server.start() time.sleep(1) yield server server.stop()