Skip to content

Commit 4bb82a9

Browse files
committed
Parse streamid only if not b''
Resolve xdf-modules#61
1 parent ed661d3 commit 4bb82a9

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

pyxdf/pyxdf.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -256,11 +256,16 @@ def load_xdf(filename,
256256
# read [Tag]
257257
tag = struct.unpack('<H', f.read(2))[0]
258258
log_str = ' Read tag: {} at {} bytes, length={}'.format(tag, f.tell(), chunklen)
259+
StreamId = None
259260
if tag in [2, 3, 4, 6]:
260-
StreamId = struct.unpack('<I', f.read(4))[0]
261-
log_str += ', StreamId={}'.format(StreamId)
262-
else:
263-
StreamId = None
261+
_streamid = f.read(4)
262+
try:
263+
StreamId = struct.unpack("<I", _streamid)[0]
264+
log_str += ", StreamId={}".format(StreamId)
265+
except struct.error:
266+
StreamId = "StreamId missing"
267+
log_str += ", StreamId was missing"
268+
264269

265270
logger.debug(log_str)
266271

0 commit comments

Comments
 (0)