我试图将bytearray
写入ctypes结构的ctypes c_uint8
缓冲区
class RpRes(LittleEndianStructure):
_pack_ = 1
_fields_ = [
("count", c_uint16),
("buf", c_uint8 * 512)
]
def read_func(req):
res = RpRes()
buf = os.read(req.fd, req.count)
res.buf.from_buffer(buf)
res.count = len(buf)
return res
res.buf.from_buffer(buf)
给出以下错误:
AttributeError: 'c_ubyte_Array_512' object has no attribute 'from_buffer'
如何做到这一点
这对我有用
相关问题 更多 >
编程相关推荐