mirror of
https://github.com/enjoy-digital/litex.git
synced 2025-01-04 09:52:26 -05:00
tools/remote/etherbone/EtherboneIPC/receive_packet: Return 0 in case of TimeoutError.
This commit is contained in:
parent
e3dcfbde60
commit
eec7733008
1 changed files with 28 additions and 21 deletions
|
@ -401,24 +401,31 @@ class EtherboneIPC:
|
||||||
def receive_packet(self, socket, addr_size):
|
def receive_packet(self, socket, addr_size):
|
||||||
assert addr_size in [1, 2, 4, 8]
|
assert addr_size in [1, 2, 4, 8]
|
||||||
header_length = etherbone_packet_header_length + etherbone_record_header_length
|
header_length = etherbone_packet_header_length + etherbone_record_header_length
|
||||||
packet = bytes()
|
packet = bytes()
|
||||||
while len(packet) < header_length:
|
try:
|
||||||
chunk = socket.recv(header_length - len(packet))
|
while len(packet) < header_length:
|
||||||
if len(chunk) == 0:
|
chunk = socket.recv(header_length - len(packet))
|
||||||
return 0
|
if len(chunk) == 0:
|
||||||
else:
|
return 0
|
||||||
packet += chunk
|
else:
|
||||||
wcount, rcount = struct.unpack(">BB", packet[header_length-2:])
|
packet += chunk
|
||||||
counts = wcount + rcount
|
|
||||||
packet_size = header_length
|
wcount, rcount = struct.unpack(">BB", packet[header_length - 2:])
|
||||||
if wcount != 0:
|
counts = wcount + rcount
|
||||||
packet_size += 4 * (wcount ) + addr_size
|
packet_size = header_length
|
||||||
if rcount != 0:
|
if wcount != 0:
|
||||||
packet_size += (rcount + 1 ) * addr_size
|
packet_size += 4 * (wcount) + addr_size
|
||||||
while len(packet) < packet_size:
|
if rcount != 0:
|
||||||
chunk = socket.recv(packet_size - len(packet))
|
packet_size += (rcount + 1) * addr_size
|
||||||
if len(chunk) == 0:
|
|
||||||
return 0
|
while len(packet) < packet_size:
|
||||||
else:
|
chunk = socket.recv(packet_size - len(packet))
|
||||||
packet += chunk
|
if len(chunk) == 0:
|
||||||
return packet
|
return 0
|
||||||
|
else:
|
||||||
|
packet += chunk
|
||||||
|
|
||||||
|
return packet
|
||||||
|
|
||||||
|
except TimeoutError:
|
||||||
|
return 0
|
Loading…
Reference in a new issue