浏览代码

added field check

subDesTagesMitExtraKaese 3 年之前
父节点
当前提交
cd3f002132
共有 1 个文件被更改,包括 2 次插入2 次删除
  1. 2 2
      raspberry-pi/connection.py

+ 2 - 2
raspberry-pi/connection.py

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