Browse Source

changed serial open order

subDesTagesMitExtraKaese 3 years ago
parent
commit
d0c351edca
1 changed files with 4 additions and 6 deletions
  1. 4 6
      raspberry-pi/sensors/connection.py

+ 4 - 6
raspberry-pi/sensors/connection.py

@@ -44,9 +44,9 @@ class SerialConnection:
       except serial.SerialException:
       except serial.SerialException:
         self._ser = None
         self._ser = None
     else:
     else:
+      time.sleep(10)
       self.open()
       self.open()
-      if not self._ser:
-        time.sleep(10)
+      return None
           
           
   def read(self, n=64):
   def read(self, n=64):
     if self._ser:
     if self._ser:
@@ -56,9 +56,8 @@ class SerialConnection:
         self._ser = None
         self._ser = None
         return None
         return None
     else:
     else:
+      time.sleep(10)
       self.open()
       self.open()
-      if not self._ser:
-        time.sleep(10)
       return None
       return None
 
 
   def readline(self):
   def readline(self):
@@ -69,9 +68,8 @@ class SerialConnection:
         self._ser = None
         self._ser = None
         return None
         return None
     else:
     else:
+      time.sleep(10)
       self.open()
       self.open()
-      if not self._ser:
-        time.sleep(10)
       return None
       return None
 
 
   def isConnected(self):
   def isConnected(self):