From 9dc1433bdfff8612d0bfd26c54ffe1c8e585ce45 Mon Sep 17 00:00:00 2001 From: Michael Lass Date: Tue, 21 Mar 2017 22:05:56 +0100 Subject: [PATCH] Check bincount in data coming from backend The backend may return fewer data points than expected. This can e.g. be observed for the hackrf_sweep backend on high system load. Currently this leads to an error when trying to insert the data into the HistoryBuffer and causes the application to crash: ValueError: cannot copy sequence with size 24750 to array axis with dimension 25000 As a workaround, just ignore data in this case. --- qspectrumanalyzer/data.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/qspectrumanalyzer/data.py b/qspectrumanalyzer/data.py index bb0c385..446e903 100644 --- a/qspectrumanalyzer/data.py +++ b/qspectrumanalyzer/data.py @@ -105,6 +105,10 @@ class DataStorage(QtCore.QObject): def update(self, data): """Update data storage""" + if self.y is not None and len(data["y"]) != len(self.y): + print("{:d} bins coming from backend, expected {:d}".format(len(data["y"]), len(self.y))) + return + self.average_counter += 1 if self.x is None: