mirror of https://github.com/m-labs/artiq.git
lda: filter reports when waiting for command response
This commit is contained in:
parent
075e540032
commit
81ab801fe4
|
@ -175,8 +175,6 @@ class Lda:
|
||||||
self.write(command, len(data), data)
|
self.write(command, len(data), data)
|
||||||
|
|
||||||
def get(self, command, length, timeout=1000):
|
def get(self, command, length, timeout=1000):
|
||||||
# FIXME: this can collide with the status reports that the
|
|
||||||
# device sends out by itself
|
|
||||||
"""Sends a GET command to read back some value of the Lab Brick device.
|
"""Sends a GET command to read back some value of the Lab Brick device.
|
||||||
|
|
||||||
:param int command: Command ID, most significant bit must be cleared.
|
:param int command: Command ID, most significant bit must be cleared.
|
||||||
|
@ -187,12 +185,14 @@ class Lda:
|
||||||
|
|
||||||
"""
|
"""
|
||||||
assert not command & 0x80
|
assert not command & 0x80
|
||||||
|
status = None
|
||||||
self.write(command, length)
|
self.write(command, length)
|
||||||
buf = ctypes.create_string_buffer(8)
|
buf = ctypes.create_string_buffer(8)
|
||||||
|
while status != command:
|
||||||
res = self._check_error(hidapi.hid_read_timeout(self._dev,
|
res = self._check_error(hidapi.hid_read_timeout(self._dev,
|
||||||
buf, len(buf), timeout))
|
buf, len(buf), timeout))
|
||||||
assert res == len(buf), res
|
assert res == len(buf), res
|
||||||
command, length, data = struct.unpack("BB6s", buf.raw)
|
status, length, data = struct.unpack("BB6s", buf.raw)
|
||||||
data = data[:length]
|
data = data[:length]
|
||||||
logger.info("%s %s %r", command, length, data)
|
logger.info("%s %s %r", command, length, data)
|
||||||
return data
|
return data
|
||||||
|
|
Loading…
Reference in New Issue