forked from M-Labs/artiq
1
0
Fork 0

device/thorlabs_tcube: fix port read

This commit is contained in:
Sebastien Bourdeauducq 2016-03-29 14:39:55 +08:00
parent 50888865e7
commit 3c09577ed0
1 changed files with 2 additions and 2 deletions

View File

@ -193,12 +193,12 @@ class _Tcube:
await self.port.write(message.pack()) await self.port.write(message.pack())
async def recv(self): async def recv(self):
header = await self.port.read(6) header = await self.port.read_exactly(6)
logger.debug("received header: %s", header) logger.debug("received header: %s", header)
data = b"" data = b""
if header[4] & 0x80: if header[4] & 0x80:
(length, ) = st.unpack("<H", header[2:4]) (length, ) = st.unpack("<H", header[2:4])
data = await self.port.read(length) data = await self.port.read_exactly(length)
r = Message.unpack(header + data) r = Message.unpack(header + data)
logger.debug("receiving: %s", r) logger.debug("receiving: %s", r)
return r return r