Explorar o código

fixed serial parsing exception

subDesTagesMitExtraKaese %!s(int64=3) %!d(string=hai) anos
pai
achega
e1e2f5ad56
Modificáronse 1 ficheiros con 3 adicións e 3 borrados
  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: