Browse Source

added field check

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

+ 2 - 2
raspberry-pi/connection.py

@@ -75,7 +75,7 @@ class SerialConnection:
 class ArduinoSlave(SerialConnection):
 class ArduinoSlave(SerialConnection):
   def __init__(self):
   def __init__(self):
     super().__init__()
     super().__init__()
-    self.sensorData = [0] * 12
+    self.sensorData = [0] * 13
     self._recvCbs = []
     self._recvCbs = []
     self._t = None
     self._t = None
 
 
@@ -130,7 +130,7 @@ class ArduinoSlave(SerialConnection):
       if data:
       if data:
         data = str(data, "ASCII")
         data = str(data, "ASCII")
         vals = data.split('\t')
         vals = data.split('\t')
-        if vals[0] == "DATA:":
+        if vals[0] == "DATA:" and len(vals) >= 13:
           self.sensorData = vals[1:]
           self.sensorData = vals[1:]
           for cb in self._recvCbs:
           for cb in self._recvCbs:
             cb(self.sensorData)
             cb(self.sensorData)