summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDiego Elio Pettenò <flameeyes@flameeyes.eu>2018-12-09 16:14:45 +0100
committerDiego Elio Pettenò <flameeyes@flameeyes.eu>2018-12-09 16:14:45 +0100
commit6532d19a83f5f5e86ddcc9537b051da147986624 (patch)
tree4345c6278d1048768c722f40c34f89ab733a64ef
parentTravis: make dist xenial for python 3.7 support (diff)
downloadglucometerutils-6532d19a83f5f5e86ddcc9537b051da147986624.tar
glucometerutils-6532d19a83f5f5e86ddcc9537b051da147986624.tar.gz
glucometerutils-6532d19a83f5f5e86ddcc9537b051da147986624.tar.bz2
glucometerutils-6532d19a83f5f5e86ddcc9537b051da147986624.tar.lz
glucometerutils-6532d19a83f5f5e86ddcc9537b051da147986624.tar.xz
glucometerutils-6532d19a83f5f5e86ddcc9537b051da147986624.tar.zst
glucometerutils-6532d19a83f5f5e86ddcc9537b051da147986624.zip
-rw-r--r--glucometerutils/drivers/sdcodefree.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/glucometerutils/drivers/sdcodefree.py b/glucometerutils/drivers/sdcodefree.py
index 4636d2a..1eba6e6 100644
--- a/glucometerutils/drivers/sdcodefree.py
+++ b/glucometerutils/drivers/sdcodefree.py
@@ -99,13 +99,16 @@ class Device(serial.SerialDevice):
return pkt.message
def wait_and_ready(self):
- challenge = self.serial_.read(1)
- # The first packet read may have a prefixed zero, it might be a bug in
- # the cp210x driver or device, but discard it if found.
- if challenge == b'\0':
- logging.debug('spurious null byte received')
- challege = self.serial_.read(1)
+ challenge = b'\0'
+ while challenge == b'\0':
+ challenge = self.serial_.read(1)
+
+ # The first packet read may have a prefixed zero, it might be a bug
+ # in the cp210x driver or device, but discard it if found.
+ if challenge == b'\0':
+ logging.debug('spurious null byte received')
+ continue
if challenge != b'\x53':
raise exceptions.ConnectionFailed(
message='Unexpected starting bytes %r' % challenge)