示例#1
0
    def flush(self, forced=False):
        prev_queue = self.need_flush
        self.need_flush = 0

        if len(self.queue) < max(5, prev_queue) and not forced:
            logging.debug("[hmi] flushing ignored")
            return

        # F**K!
        logging.warn("[hmi] flushing queue as workaround now: %d in queue",
                     len(self.queue))
        self.sp.sp.flush()
        self.sp.sp.flushInput()
        self.sp.sp.flushOutput()
        self.sp.close()
        self.sp = None

        while len(self.queue) > 1:
            msg, callback, datatype = self.queue.pop(0)

            if any(msg.startswith(resp) for resp in Protocol.RESPONSES):
                if callback is not None:
                    callback(process_resp(None, datatype))
            else:
                if callback is not None:
                    callback("-1003")

        self.reinit_cb()
示例#2
0
文件: host.py 项目: alercunha/mod-ui
        def check_response(resp):
            logging.info("[host] received <- %s" % repr(resp))
            if not resp.startswith("resp"):
                logging.error("[host] protocol error: %s" % ProtocolError(resp)) # TODO: proper error handling

            r = resp.replace("resp ", "").replace("\0", "").strip()
            callback(process_resp(r, datatype))
            self.process_queue()
示例#3
0
        def check_response(resp):
            resp = resp.decode("utf-8", errors="ignore")

            logging.info("[host] received <- %s" % repr(resp))
            if not resp.startswith("resp"):
                logging.error(
                    "[host] protocol error: %s" %
                    ProtocolError(resp))  # TODO: proper error handling

            r = resp.replace("resp ", "").replace("\0", "").strip()
            callback(process_resp(r, datatype))
            self.process_queue()
示例#4
0
文件: host_carla.py 项目: x42/mod-ui
    def process_write_queue(self):
        try:
            msg, callback, datatype = self._queue.pop(0)
            logging.info("[host] popped from queue: %s" % msg)
        except IndexError:
            self._idle = True
            return

        if self.writesock is None:
            self.process_write_queue()
            return

        self._idle = False
        logging.info("[host] sending -> %s" % msg)

        print(msg)
        ret = self.send_carla_msg(msg)

        if callback is not None:
            callback(process_resp(ret, datatype))

        self.process_write_queue()