Skip to content

Commit

Permalink
comm_generic: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sbourdeauducq committed Aug 7, 2015
1 parent 54a568c commit be55487
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions artiq/coredevice/comm_generic.py
Expand Up @@ -108,10 +108,7 @@ def check_ident(self):
if ty != _D2HMsgType.IDENT_REPLY:
raise IOError("Incorrect reply from device: {}".format(ty))
(reply, ) = struct.unpack("B", self.read(1))
runtime_id = chr(reply)
for i in range(3):
(reply, ) = struct.unpack("B", self.read(1))
runtime_id += chr(reply)
runtime_id = self.read(4).decode()
if runtime_id != "AROR":
raise UnsupportedDevice("Unsupported runtime ID: {}"
.format(runtime_id))
Expand Down Expand Up @@ -238,9 +235,11 @@ def get_log(self):
length, ty = self._read_header()
if ty != _D2HMsgType.LOG_REPLY:
raise IOError("Incorrect request from device: "+str(ty))
r = ""
for i in range(length - 9):
c = struct.unpack("B", self.read(1))[0]
if c:
r += chr(c)
return r
log = self.read(length - 9).decode()
try:
idx = log.index("\x00")
except ValueError:
pass
else:
log = log[:idx]
return log

0 comments on commit be55487

Please sign in to comment.