Make it work
This commit is contained in:
parent
a3ce184f5e
commit
1538f37132
@ -301,12 +301,15 @@ class HackRFSweepThread(RtlPowerBaseThread):
|
|||||||
"overhang": overhang,
|
"overhang": overhang,
|
||||||
"single_shot": single_shot
|
"single_shot": single_shot
|
||||||
}
|
}
|
||||||
|
self.fft_size = 64
|
||||||
self.freqs = [self.get_hop_freq(hop) for hop in range(hops)]
|
self.freqs = [self.get_hop_freq(hop) for hop in range(hops)]
|
||||||
self.freqs_crop = [(f[0] + crop_freq, f[1] - crop_freq) for f in self.freqs]
|
self.freqs_crop = [(f[0] + crop_freq, f[1] - crop_freq) for f in self.freqs]
|
||||||
self.databuffer = {"timestamp": [], "x": [], "y": []}
|
self.databuffer = {"timestamp": [], "x": [], "y": []}
|
||||||
self.databuffer_hop = {"timestamp": [], "x": [], "y": []}
|
self.databuffer_hop = {"timestamp": [], "x": [], "y": []}
|
||||||
self.hop = 0
|
self.hop = 0
|
||||||
self.prev_line = ""
|
self.prev_line = ""
|
||||||
|
self.prev_freq = 0
|
||||||
|
self.skip = True
|
||||||
|
|
||||||
print("hackrf_sweep params:")
|
print("hackrf_sweep params:")
|
||||||
pprint.pprint(self.params)
|
pprint.pprint(self.params)
|
||||||
@ -329,10 +332,28 @@ class HackRFSweepThread(RtlPowerBaseThread):
|
|||||||
self.process = subprocess.Popen(cmdline, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL,
|
self.process = subprocess.Popen(cmdline, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL,
|
||||||
universal_newlines=False)
|
universal_newlines=False)
|
||||||
|
|
||||||
|
def filter_nan(self, num):
|
||||||
|
if np.isnan(num) or np.isinf(num) or np.isneginf(num):
|
||||||
|
return -80
|
||||||
|
return num
|
||||||
|
|
||||||
def parse_output(self, buf):
|
def parse_output(self, buf):
|
||||||
"""Parse one buf of output from hackrf_sweep"""
|
"""Parse one buf of output from hackrf_sweep"""
|
||||||
data = np.fromstring(buf, dtype='<f4')
|
data = np.fromstring(buf, dtype='<f4')
|
||||||
print("Got buffer for {}MHz".format(data[0]))
|
centre_freq = data[0] * 1e6
|
||||||
|
|
||||||
|
if centre_freq != self.prev_freq:
|
||||||
|
if centre_freq < self.prev_freq:
|
||||||
|
# Skip first run through in case it was incomplete
|
||||||
|
# otherwise the data_storage array sizes are setup incorrectly and mismatch later
|
||||||
|
if not self.skip:
|
||||||
|
self.data_storage.update(self.databuffer)
|
||||||
|
self.skip = False
|
||||||
|
self.databuffer = {"timestamp": [], "x": [], "y": []}
|
||||||
|
|
||||||
|
self.databuffer["x"] += [centre_freq + i * 20e6 / self.fft_size for i in range(int(-self.fft_size/2), int(self.fft_size/2))]
|
||||||
|
self.databuffer["y"] += [self.filter_nan(x) for x in data[1:]]
|
||||||
|
self.prev_freq = centre_freq
|
||||||
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
@ -342,7 +363,7 @@ class HackRFSweepThread(RtlPowerBaseThread):
|
|||||||
self.rtlPowerStarted.emit()
|
self.rtlPowerStarted.emit()
|
||||||
|
|
||||||
while self.alive:
|
while self.alive:
|
||||||
buf = self.process.stdout.read(4*(1+32))
|
buf = self.process.stdout.read(4*(1+self.fft_size))
|
||||||
if buf:
|
if buf:
|
||||||
self.parse_output(buf)
|
self.parse_output(buf)
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@
|
|||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="__main__.py" line="465"/>
|
<location filename="__main__.py" line="468"/>
|
||||||
<source>QSpectrumAnalyzer {}</source>
|
<source>QSpectrumAnalyzer {}</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
@ -176,12 +176,12 @@
|
|||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="__main__.py" line="298"/>
|
<location filename="__main__.py" line="301"/>
|
||||||
<source>N/A</source>
|
<source>N/A</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="__main__.py" line="465"/>
|
<location filename="__main__.py" line="468"/>
|
||||||
<source>About - QSpectrumAnalyzer</source>
|
<source>About - QSpectrumAnalyzer</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
@ -206,7 +206,7 @@
|
|||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="__main__.py" line="298"/>
|
<location filename="__main__.py" line="301"/>
|
||||||
<source>Frequency hops: {} | Sweep time: {:.2f} s | FPS: {:.2f}</source>
|
<source>Frequency hops: {} | Sweep time: {:.2f} s | FPS: {:.2f}</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
@ -189,10 +189,10 @@
|
|||||||
<number>3</number>
|
<number>3</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="minimum">
|
<property name="minimum">
|
||||||
<double>24.000000000000000</double>
|
<double>1.000000000000000</double>
|
||||||
</property>
|
</property>
|
||||||
<property name="maximum">
|
<property name="maximum">
|
||||||
<double>1766.000000000000000</double>
|
<double>6000.000000000000000</double>
|
||||||
</property>
|
</property>
|
||||||
<property name="value">
|
<property name="value">
|
||||||
<double>87.000000000000000</double>
|
<double>87.000000000000000</double>
|
||||||
@ -227,10 +227,10 @@
|
|||||||
<number>3</number>
|
<number>3</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="minimum">
|
<property name="minimum">
|
||||||
<double>24.000000000000000</double>
|
<double>1.000000000000000</double>
|
||||||
</property>
|
</property>
|
||||||
<property name="maximum">
|
<property name="maximum">
|
||||||
<double>1766.000000000000000</double>
|
<double>6000.000000000000000</double>
|
||||||
</property>
|
</property>
|
||||||
<property name="value">
|
<property name="value">
|
||||||
<double>108.000000000000000</double>
|
<double>108.000000000000000</double>
|
||||||
|
@ -116,9 +116,9 @@ class Ui_QSpectrumAnalyzerMainWindow(object):
|
|||||||
self.startFreqSpinBox.setSizePolicy(sizePolicy)
|
self.startFreqSpinBox.setSizePolicy(sizePolicy)
|
||||||
self.startFreqSpinBox.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
|
self.startFreqSpinBox.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
|
||||||
self.startFreqSpinBox.setDecimals(3)
|
self.startFreqSpinBox.setDecimals(3)
|
||||||
self.startFreqSpinBox.setMinimum(24.0)
|
self.startFreqSpinBox.setMinimum(1.0)
|
||||||
self.startFreqSpinBox.setMaximum(1766.0)
|
self.startFreqSpinBox.setMaximum(6000.0)
|
||||||
self.startFreqSpinBox.setProperty("value", 87.0)
|
self.startFreqSpinBox.setProperty("value", 2390.0)
|
||||||
self.startFreqSpinBox.setObjectName(_fromUtf8("startFreqSpinBox"))
|
self.startFreqSpinBox.setObjectName(_fromUtf8("startFreqSpinBox"))
|
||||||
self.formLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.startFreqSpinBox)
|
self.formLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.startFreqSpinBox)
|
||||||
self.label_3 = QtGui.QLabel(self.frequencyDockWidgetContents)
|
self.label_3 = QtGui.QLabel(self.frequencyDockWidgetContents)
|
||||||
@ -132,9 +132,9 @@ class Ui_QSpectrumAnalyzerMainWindow(object):
|
|||||||
self.stopFreqSpinBox.setSizePolicy(sizePolicy)
|
self.stopFreqSpinBox.setSizePolicy(sizePolicy)
|
||||||
self.stopFreqSpinBox.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
|
self.stopFreqSpinBox.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
|
||||||
self.stopFreqSpinBox.setDecimals(3)
|
self.stopFreqSpinBox.setDecimals(3)
|
||||||
self.stopFreqSpinBox.setMinimum(24.0)
|
self.stopFreqSpinBox.setMinimum(1.0)
|
||||||
self.stopFreqSpinBox.setMaximum(1766.0)
|
self.stopFreqSpinBox.setMaximum(6000.0)
|
||||||
self.stopFreqSpinBox.setProperty("value", 108.0)
|
self.stopFreqSpinBox.setProperty("value", 2510.0)
|
||||||
self.stopFreqSpinBox.setObjectName(_fromUtf8("stopFreqSpinBox"))
|
self.stopFreqSpinBox.setObjectName(_fromUtf8("stopFreqSpinBox"))
|
||||||
self.formLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.stopFreqSpinBox)
|
self.formLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.stopFreqSpinBox)
|
||||||
self.label = QtGui.QLabel(self.frequencyDockWidgetContents)
|
self.label = QtGui.QLabel(self.frequencyDockWidgetContents)
|
||||||
|
Loading…
Reference in New Issue
Block a user