def _connect(self):
        info = {}

        self._link.connect()

        cmd = {"cmd": "get_version"}
        self._send_cmd(cmd)

        try:
            header, _ = self._recv_frame()
        except links.LinkError as e:
            raise ClientError("no response from server") from e

        log.debug("connected and got a response")

        if header["status"] != "ok":
            raise ClientError("server error while connecting")

        msg = header["message"].lower()
        log.info("version msg: {}".format(msg))

        startstr = "server version v"
        if not msg.startswith(startstr):
            log.warning("server version unknown")
            return info

        server_version_str = msg[len(startstr):].strip()
        info.update(decode_version_str(server_version_str))

        self._send_cmd({"cmd": "get_board_sensor_count"})
        header, _ = self._recv_frame()
        info["board_sensor_count"] = int(header["message"])

        return info
Beispiel #2
0
def decode_version_buffer(version: bytearray) -> dict:
    try:
        version_str = version.decode("ascii").strip()
        assert len(version_str) > 1
        assert version_str.startswith("v")
        version_str = version_str[1:]
    except (UnicodeDecodeError, AssertionError):
        return {}

    return decode_version_str(version_str)
Beispiel #3
0
 def _connect(self):
     info = {}
     info.update(decode_version_str(SDK_VERSION))
     info["mock"] = True
     return info