class DirectConnection: def __init__(self, requestHandler): self.requestHandler = requestHandler self.open = True self.config = {} def configure(self, config: dict) -> None: self.config = config def close(self) -> None: self.open = False def send(self, request: str, responseExpected=True) -> str: return self.requestHandler(request) def checkConfiguration(self) -> None: assert self.config.get("baudrate") == 115200 assert self.config.get("bytesize") == 8 assert self.config.get("stopbits") == 1 assert self.config.get("parity") == "N"