diff --git a/artiq/devices/thorlabs_tcube/driver.py b/artiq/devices/thorlabs_tcube/driver.py index a8314a0cb..72ea27907 100644 --- a/artiq/devices/thorlabs_tcube/driver.py +++ b/artiq/devices/thorlabs_tcube/driver.py @@ -113,22 +113,6 @@ class MGMSG(Enum): PZ_GET_TPZ_IOSETTINGS = 0x07D6 -def _write_exactly(f, data): - remaining = len(data) - pos = 0 - while remaining: - written = f.write(data[pos:]) - remaining -= written - pos += written - - -def _read_exactly(f, n): - r = bytes() - while len(r) < n: - r += f.read(n - len(r)) - return r - - class Direction: def __init__(self, direction): if direction not in (1, 2): @@ -179,15 +163,15 @@ class Message: self.param1, self.param2, self.dest, self.src) def send(self, port): - _write_exactly(port, self.pack()) + port.write(self.pack()) @classmethod def recv(cls, port): - (header, ) = st.unpack("6s", _read_exactly(port, 6)) + (header, ) = st.unpack("6s", port.read(6)) data = b"" if header[4] & 0x80: (length, ) = st.unpack("