From 0a6fcd9fa08c931a0f09cb1704b44a00d8e15c9c Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Sat, 8 Aug 2015 21:24:23 +0800 Subject: [PATCH] Revert "comm_generic: cleanup" This reverts commit be55487d2da3c0cd6c08a6cbae712965e061c7e8. --- artiq/coredevice/comm_generic.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/artiq/coredevice/comm_generic.py b/artiq/coredevice/comm_generic.py index 4ac2598df..88fee184b 100644 --- a/artiq/coredevice/comm_generic.py +++ b/artiq/coredevice/comm_generic.py @@ -108,7 +108,10 @@ class CommGeneric: if ty != _D2HMsgType.IDENT_REPLY: raise IOError("Incorrect reply from device: {}".format(ty)) (reply, ) = struct.unpack("B", self.read(1)) - runtime_id = self.read(4).decode() + runtime_id = chr(reply) + for i in range(3): + (reply, ) = struct.unpack("B", self.read(1)) + runtime_id += chr(reply) if runtime_id != "AROR": raise UnsupportedDevice("Unsupported runtime ID: {}" .format(runtime_id)) @@ -235,11 +238,9 @@ class CommGeneric: length, ty = self._read_header() if ty != _D2HMsgType.LOG_REPLY: raise IOError("Incorrect request from device: "+str(ty)) - log = self.read(length - 9).decode() - try: - idx = log.index("\x00") - except ValueError: - pass - else: - log = log[:idx] - return log + r = "" + for i in range(length - 9): + c = struct.unpack("B", self.read(1))[0] + if c: + r += chr(c) + return r