transport.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:bitpay-brick 作者: javgh 项目源码 文件源码
def read(self, timeout):
        if self.tty is not None:
            self.tty.timeout = max(timeout / 1000.0, 0.05)
            frame = bytearray(self.tty.read(6))
            if frame is None or len(frame) == 0:
                raise IOError(errno.ETIMEDOUT, os.strerror(errno.ETIMEDOUT))
            if frame.startswith("\x00\x00\xff\x00\xff\x00"):
                return frame
            LEN = frame[3]
            if LEN == 0xFF:
                frame += self.tty.read(3)
                LEN = frame[5]<<8 | frame[6]
            frame += self.tty.read(LEN + 1)
            log.debug("<<< " + str(frame).encode("hex"))
            return frame
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号