serialcli.py 文件源码

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

项目:CANbit 作者: whaleygeek 项目源码 文件源码
def read(self, size=1):
        """Read size bytes from the serial port. If a timeout is set it may
           return less characters as requested. With no timeout it will block
           until the requested number of bytes is read."""
        if not self._port_handle: raise portNotOpenError
        # must use single byte reads as this is the only way to read
        # without applying encodings
        data = bytearray()
        while size:
            try:
                data.append(self._port_handle.ReadByte())
            except System.TimeoutException, e:
                break
            else:
                size -= 1
        return bytes(data)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号