|
@@ -43,25 +43,35 @@ class SerialConnection:
|
|
|
return self._ser.write(bytes)
|
|
|
except serial.SerialException:
|
|
|
self._ser = None
|
|
|
- if not self._ser:
|
|
|
+ else:
|
|
|
self.open()
|
|
|
if not self._ser:
|
|
|
- time.sleep(30)
|
|
|
+ time.sleep(10)
|
|
|
|
|
|
def read(self, n=64):
|
|
|
if self._ser:
|
|
|
try:
|
|
|
- if self._ser.in_waiting:
|
|
|
- return self._ser.read(n)
|
|
|
+ return self._ser.read(n)
|
|
|
except serial.SerialException:
|
|
|
self._ser = None
|
|
|
- if not self._ser:
|
|
|
+ return None
|
|
|
+ else:
|
|
|
self.open()
|
|
|
+ if not self._ser:
|
|
|
+ time.sleep(10)
|
|
|
+ return None
|
|
|
|
|
|
def readline(self):
|
|
|
if self._ser:
|
|
|
- return self._ser.readline()
|
|
|
+ try:
|
|
|
+ return self._ser.readline()
|
|
|
+ except serial.SerialException:
|
|
|
+ self._ser = None
|
|
|
+ return None
|
|
|
else:
|
|
|
+ self.open()
|
|
|
+ if not self._ser:
|
|
|
+ time.sleep(10)
|
|
|
return None
|
|
|
|
|
|
def isConnected(self):
|