From fdd2c4b059d3040602abacb2af3eb56a4902bcac Mon Sep 17 00:00:00 2001 From: Nikolay Khabarov <2xl@mail.ru> Date: Sun, 9 Jul 2017 03:18:00 +0300 Subject: [PATCH] fix ads111x --- cnc/sensors/ads111x.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cnc/sensors/ads111x.py b/cnc/sensors/ads111x.py index f30db55..e04a7d1 100644 --- a/cnc/sensors/ads111x.py +++ b/cnc/sensors/ads111x.py @@ -30,7 +30,7 @@ class __I2CDev(object): os.write(self._dev, data) def read(self, n): - os.read(self._dev, n) + return os.read(self._dev, n) i2c = __I2CDev() @@ -59,13 +59,13 @@ def measure(channel): i2c.write(data) # wait for conversion while True: - i2c.write(data, struct.pack("B", 0x01)) - if struct.unpack(">H", i2c.read(data, 2))[0] & 0x8000 != 0: + i2c.write(struct.pack("B", 0x01)) + if struct.unpack(">H", i2c.read(2))[0] & 0x8000 != 0: break time.sleep(0.0001) # read result - i2c.write(data, struct.pack("B", 0x00)) # conversion register - v = struct.unpack(">h", i2c.read(data, 2))[0] + i2c.write(struct.pack("B", 0x00)) # conversion register + v = struct.unpack(">h", i2c.read(2))[0] lock.release() return v / 8000.0 # / 32768.0 * 4.096 according to specified range