From 76eadc0a61c3da1182d61236ccc81f0ffb25694e Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Tue, 24 Nov 2015 16:55:18 +0800 Subject: [PATCH] devices/thorlabs_tcube: remove unnecessary {read,write}_exactly functions --- artiq/devices/thorlabs_tcube/driver.py | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) 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("