From 3ba04ab16116979c026e05c0e2920c2bdf58167b Mon Sep 17 00:00:00 2001
From: Christopher Stone <cedstone@lithoi.org.uk>
Date: Fri, 9 Mar 2018 17:23:37 +0000
Subject: [PATCH] Fixed a few bugs in pollserial, and created an artificial analogue of it for testing

---
 robots/little_john/telemetry/code/monitor/version1/main.py | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/robots/little_john/telemetry/code/monitor/version1/main.py b/robots/little_john/telemetry/code/monitor/version1/main.py
index 3eff5df..e91b7d9 100755
--- a/robots/little_john/telemetry/code/monitor/version1/main.py
+++ b/robots/little_john/telemetry/code/monitor/version1/main.py
@@ -8,7 +8,7 @@
 # This code is incomplete, and is missing core features
 
 #import math
-#import time
+import time
 #import serial
 
 import pyglet
@@ -57,6 +57,7 @@ class Series:
         self.ylimits = (0, 255)
         self.data = []
         self.points = points
+        
     def addpoint(self, point):
         """Add a point to the dataset, and remove the oldest, if necessary"""
         self.data.append(point)
@@ -177,10 +178,19 @@ def pollSerial(elapsed):
         values = datafeed.readline().strip().split(b", ")
     else:
         values = datafeed.readline().strip()
-        values = str(values).split(", ")
+        values = values.split(b', ')
+    for n, value in enumerate(values):
+        values[n] = float(value)
+    logging.info("Recieved data: " + str(values))
+    testseries.addpoint(values)
+    
+def fakePollSerial(elapsed):
+    """This function immitates the behaviour of pollSerial, for testing purposes"""
+    values = [time.time(), time.time()%10]
+    logging.info("Generated test data: " + str(values))
     testseries.addpoint(values)
 
 # Pyglet looks after the main event loop, but this ensures that data keeps being read in
-pyglet.clock.schedule_interval(pollSerial, 0.1)
+pyglet.clock.schedule_interval(fakePollSerial, 0.1)
 
 pyglet.app.run()
--
libgit2 0.21.2