tools/cpboard.py: update pyserial usage to match 3.x version
This commit is contained in:
parent
660081ece2
commit
cf9da59829
@ -73,8 +73,8 @@ class REPL:
|
|||||||
return self.board.serial
|
return self.board.serial
|
||||||
|
|
||||||
def read(self):
|
def read(self):
|
||||||
if self.serial.inWaiting():
|
if self.serial.in_waiting:
|
||||||
data = self.serial.read(self.serial.inWaiting())
|
data = self.serial.read(self.serial.in_waiting)
|
||||||
else:
|
else:
|
||||||
data = b''
|
data = b''
|
||||||
self.session += data
|
self.session += data
|
||||||
@ -86,7 +86,7 @@ class REPL:
|
|||||||
while True:
|
while True:
|
||||||
if data.endswith(ending):
|
if data.endswith(ending):
|
||||||
break
|
break
|
||||||
elif self.serial.inWaiting() > 0:
|
elif self.serial.in_waiting > 0:
|
||||||
new_data = self.serial.read(1)
|
new_data = self.serial.read(1)
|
||||||
data += new_data
|
data += new_data
|
||||||
self.session += new_data
|
self.session += new_data
|
||||||
@ -401,7 +401,10 @@ class CPboard:
|
|||||||
delayed = False
|
delayed = False
|
||||||
for attempt in range(wait + 1):
|
for attempt in range(wait + 1):
|
||||||
try:
|
try:
|
||||||
self.serial = serial.Serial(self.device, baudrate=self.baudrate, timeout=self.timeout, write_timeout=self.timeout, interCharTimeout=1)
|
self.serial = serial.Serial(self.device, baudrate=self.baudrate,
|
||||||
|
timeout=self.timeout,
|
||||||
|
inter_byte_timeout=10,
|
||||||
|
write_timeout=self.timeout)
|
||||||
break
|
break
|
||||||
except (OSError, IOError): # Py2 and Py3 have different errors
|
except (OSError, IOError): # Py2 and Py3 have different errors
|
||||||
if wait == 0:
|
if wait == 0:
|
||||||
|
Loading…
Reference in New Issue
Block a user