From 7885b25e012d7ba022c72298866f7d1034643165 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20Elio=20Petten=C3=B2?= Date: Thu, 15 Jun 2017 22:19:57 +0100 Subject: hiddevice: default to no timeout, like before. This restores the original behaviour, that seems to be necessary for the FreeStyle devices. --- glucometerutils/support/hiddevice.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/glucometerutils/support/hiddevice.py b/glucometerutils/support/hiddevice.py index a1af95a..86203ba 100644 --- a/glucometerutils/support/hiddevice.py +++ b/glucometerutils/support/hiddevice.py @@ -33,14 +33,14 @@ class HidDevice(object): Optional parameters available: - TIMEOUT_MS: (int, default: 1000) the read timeout in milliseconds, used - for hidapi reads only. + TIMEOUT_MS: (int, default: NOne) the read timeout in milliseconds, used + for hidapi reads only. If -1, hidapi will be provided no timeout. """ USB_VENDOR_ID = None USB_PRODUCT_ID = None - TIMEOUT_MS = 1000 + TIMEOUT_MS = None def __init__(self, device): if None in (self.USB_VENDOR_ID, self.USB_PRODUCT_ID) and not device: @@ -85,7 +85,7 @@ class HidDevice(object): This is important as it handles the one incompatible interface between hidraw devices and hidapi handles. """ - if self.handle_mode_ == 'hidraw': - return self.handle_.read(size) + if self.handle_mode_ == 'hidraw' or self.TIMEOUT_MS is None: + return bytes(self.handle_.read(size)) else: return bytes(self.handle_.read(size, timeout_ms=self.TIMEOUT_MS)) -- cgit v1.2.3