Skip to content

Commit

Permalink
Fix issues with reading back iobuf
Browse files Browse the repository at this point in the history
  • Loading branch information
rowleya committed Mar 1, 2023
1 parent 73acb07 commit 28c243b
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion spinnman/processes/read_iobuf_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@
_ONE_WORD = struct.Struct("<I")
_FIRST_IOBUF = struct.Struct("<I8xI")

# The maximum value allowed in ASCII
_MAX_ASCII = 127

# What to replace junk characters with (?)
_REPLACE_VALUE = 63


class ReadIOBufProcess(AbstractMultiConnectionProcess):
""" A process for reading IOBUF memory (mostly log messages) from a\
Expand Down Expand Up @@ -174,5 +180,12 @@ def read_iobuf(self, iobuf_size, core_subsets):
for p in core_subset.processor_ids:
iobuf = ""
for item in self._iobuf[x, y, p].values():
iobuf += item.decode(_ENCODING)
try:
value = item.decode(_ENCODING)
iobuf += value
except UnicodeDecodeError:
for i in range(len(item)):
if item[i] > _MAX_ASCII:
item[i] = _REPLACE_VALUE
iobuf += item.decode(_ENCODING)
yield IOBuffer(x, y, p, iobuf)

0 comments on commit 28c243b

Please sign in to comment.