Printer.py 文件源码

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

项目:OpenFL 作者: Formlabs 项目源码 文件源码
def poll(self, bufsize=1024):
        """ Returns the next received packet as a tuple (command, payload)
            If there are no packets pending, returns None
        """
        # Attempt to load data from USB and push it into the incoming buffer
        while not self.incoming:
            try:
                raw = self._read(bufsize)
            except usb.core.USBError as e:
                # The only acceptable USB errors are timeout errors
                # (when the device hasn't sent us any new data)
                if e.errno != errno.ETIMEDOUT:
                    raise e
                break
            else:
                self._process_raw(raw)

        # Return the oldest packet or None
        return self.incoming.pop(0) if self.incoming else None
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号