Skip to content

Commit 2a5e9bd

Browse files
author
Brendan Whitfield
committed
replaced retry with higher timeout
1 parent a709860 commit 2a5e9bd

1 file changed

Lines changed: 3 additions & 10 deletions

File tree

obd/elm327.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def __init__(self, portname, baudrate, protocol):
117117
parity = serial.PARITY_NONE, \
118118
stopbits = 1, \
119119
bytesize = 8,
120-
timeout = 3) # seconds
120+
timeout = 10) # seconds
121121
logger.info("Serial port successfully opened on " + self.port_name())
122122

123123
except serial.SerialException as e:
@@ -429,7 +429,6 @@ def __read(self):
429429
logger.info("cannot perform __read() when unconnected")
430430
return ""
431431

432-
attempts = 2
433432
buffer = bytearray()
434433

435434
while True:
@@ -438,14 +437,8 @@ def __read(self):
438437

439438
# if nothing was recieved
440439
if not data:
441-
442-
if attempts <= 0:
443-
logger.warning("Failed to read port, giving up")
444-
break
445-
446-
logger.info("Failed to read port, trying again...")
447-
attempts -= 1
448-
continue
440+
logger.warning("Failed to read port")
441+
break
449442

450443
buffer.extend(data)
451444

0 commit comments

Comments
 (0)