summaryrefslogtreecommitdiffstats
path: root/lab_control/connection/direct_connection.py
blob: 8df1e42141c67d1ea285b6141a2ca25196f96edb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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"