forked from M-Labs/artiq
analyzer: avoid copy of analyzer dump
This commit is contained in:
parent
81106f3567
commit
f98982c96d
|
@ -181,25 +181,25 @@ class AnalyzerProxyReceiver:
|
||||||
async def _receive_cr(self):
|
async def _receive_cr(self):
|
||||||
try:
|
try:
|
||||||
while True:
|
while True:
|
||||||
endian_byte = await self.reader.read(1)
|
data = bytearray()
|
||||||
if endian_byte == b"E":
|
data.extend(await self.reader.read(1))
|
||||||
endian = '>'
|
if len(data) == 0:
|
||||||
elif endian_byte == b"e":
|
|
||||||
endian = '<'
|
|
||||||
elif endian_byte == b"":
|
|
||||||
# EOF reached, connection lost
|
# EOF reached, connection lost
|
||||||
return
|
return
|
||||||
|
if data[0] == ord("E"):
|
||||||
|
endian = '>'
|
||||||
|
elif data[0] == ord("e"):
|
||||||
|
endian = '<'
|
||||||
else:
|
else:
|
||||||
raise ValueError
|
raise ValueError
|
||||||
payload_length_word = await self.reader.readexactly(4)
|
data.extend(await self.reader.readexactly(4))
|
||||||
payload_length = struct.unpack(endian + "I", payload_length_word)[0]
|
payload_length = struct.unpack(endian + "I", data[1:5])[0]
|
||||||
if payload_length > 10 * 512 * 1024:
|
if payload_length > 10 * 512 * 1024:
|
||||||
# 10x buffer size of firmware
|
# 10x buffer size of firmware
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
# The remaining header length is 11 bytes.
|
# The remaining header length is 11 bytes.
|
||||||
remaining_data = await self.reader.readexactly(payload_length + 11)
|
data.extend(await self.reader.readexactly(payload_length + 11))
|
||||||
data = endian_byte + payload_length_word + remaining_data
|
|
||||||
self.receive_cb(data)
|
self.receive_cb(data)
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.error("analyzer receiver connection terminating with exception", exc_info=True)
|
logger.error("analyzer receiver connection terminating with exception", exc_info=True)
|
||||||
|
|
Loading…
Reference in New Issue