|
From 30f59ddc72c66720a66112723ecd78fe7b5a04a6 Mon Sep 17 00:00:00 2001 |
|
From: "Peter A. Bigot" <[email protected]> |
|
Date: Wed, 3 Jan 2018 13:18:08 -0600 |
|
Subject: [PATCH] ui/ppk_plotter: fix starvation on Linux |
|
|
|
Problem identification and general approach as in devzone topic below. |
|
Using a condvar made more sense to me, and this seems to work. |
|
|
|
See: https://devzone.nordicsemi.com/question/162707/ppk-v11-hangs-on-linux-bug-report/ |
|
--- |
|
ui/ppk_plotter.py | 8 ++++++++ |
|
1 file changed, 8 insertions(+) |
|
|
|
diff --git a/ui/ppk_plotter.py b/ui/ppk_plotter.py |
|
index bc36f72..d2ca15b 100644 |
|
--- a/ui/ppk_plotter.py |
|
+++ b/ui/ppk_plotter.py |
|
@@ -77,6 +77,7 @@ class ppk_plotter(): |
|
self.alive = True
|
|
self.logfile_name = 'ppk_avg.csv'
|
|
self.started_log = False
|
|
+ self.update_condvar = threading.Condition();
|
|
self.log_stopped = False
|
|
self.update_log = False
|
|
|
|
@@ -269,7 +270,10 @@ class ppk_plotter(): |
|
except Exception as e:
|
|
print(str(e))
|
|
# Just set update log after every sample
|
|
+ self.update_condvar.acquire();
|
|
self.update_log = True
|
|
+ self.update_condvar.notify()
|
|
+ self.update_condvar.release()
|
|
|
|
else:
|
|
# Trigger data received as raw adc float, with range flag prepended
|
|
@@ -314,6 +318,9 @@ class ppk_plotter(): |
|
def do_logging(self):
|
|
ts = 0
|
|
while(self.alive):
|
|
+ self.update_condvar.acquire()
|
|
+ while not (self.update_log or self.log_stopped):
|
|
+ self.update_condvar.wait()
|
|
try:
|
|
if(self.update_log and not self.log_stopped):
|
|
ts += self.plotdata.avg_interval
|
|
@@ -331,6 +338,7 @@ class ppk_plotter(): |
|
pass
|
|
except Exception as e:
|
|
print(str(e))
|
|
+ self.update_condvar.release()
|
|
|
|
def medfilt(self, x, k):
|
|
"""Apply a length-k median filter to a 1D array x.
|
|
-- |
|
2.7.4 |
|
|