]> Pileus Git - ~andy/csm213a-hw/blobdiff - vis/device.py
Save control options
[~andy/csm213a-hw] / vis / device.py
index ba4678709df6b8872c022b805e9f490b5c79171d..24860bac33c430cd2aef444208d9bdd2dad08700 100644 (file)
@@ -32,6 +32,7 @@ class Device:
                                bytesize = self.config.databits, \
                                stopbits = self.config.stopbits, \
                                timeout  = 0)
+                       self.serial.flushInput()
                except Exception as ex:
                        return str(ex)
 
@@ -46,10 +47,13 @@ class Device:
                        return False
                return True
 
+       def control(self):
+               pass
+
        def process(self):
                items = []
                count = 0
-               limit = 100
+               limit = 1000
                if not self.running():
                        return items
                while self.serial.readable():
@@ -69,7 +73,7 @@ class Device:
                        else:
                                self.inbuf.append(char)
                        if count > limit:
-                               print("Eror: exceeded read limit")
+                               print("Error: exceeded read limit")
                                break
                        count += 1
                return items
@@ -94,9 +98,9 @@ class Device:
                        state.acc[1]   = float(acc_m.group(2))
                        state.acc[2]   = float(acc_m.group(3))
                if mag_m:              
-                       state.acc[0]   = float(mag_m.group(1))
-                       state.acc[1]   = float(mag_m.group(2))
-                       state.acc[2]   = float(mag_m.group(3))
+                       state.mag[0]   = float(mag_m.group(1))
+                       state.mag[1]   = float(mag_m.group(2))
+                       state.mag[2]   = float(mag_m.group(3))
                if lgt_m:
                        state.light[0] = float(lgt_m.group(1))
                if tch_m: