Browse Source

fixed serial parsing exception

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

+ 3 - 3
raspberry-pi/connection.py

@@ -134,9 +134,9 @@ class ArduinoSlave(SerialConnection):
   def _readSensors(self):
     while True:
       data = super().readline()
-      if data:
-        data = str(data, "ASCII")
-        vals = data.split('\t')
+      if data and len(data) > 2:
+        data = str(data, encoding="ASCII", errors="ignore")
+        vals = data[:-2].split('\t')
         if vals[0] == "DATA:" and len(vals) >= 13:
           self.sensorData = vals[1:]
           for cb in self._recvCbs: