# -*- coding: utf-8 -*-
#
# SPDX-License-Identifier: GPL-3.0
#
# GNU Radio Python Flow Graph
# Title: Pyephem FSPL v1.0
# Author: spacerfvm
# GNU Radio version: 3.10.1.1
from packaging.version import Version as StrictVersion
if __name__ == '__main__':
import ctypes
import sys
if sys.platform.startswith('linux'):
try:
x11 = ctypes.cdll.LoadLibrary('libX11.so')
x11.XInitThreads()
except:
print("Warning: failed to XInitThreads()")
from PyQt5 import Qt
from gnuradio import eng_notation
from gnuradio import qtgui
from gnuradio.filter import firdes
import sip
from gnuradio import analog
from gnuradio import blocks
from gnuradio import gr
from gnuradio.fft import window
import sys
import signal
from argparse import ArgumentParser
from gnuradio.eng_arg import eng_float, intx
import pyephemfspltest_epy_block_0 as epy_block_0 # embedded python block
import time
import threading
from gnuradio import qtgui
class pyephemfspltest(gr.top_block, Qt.QWidget):
def __init__(self):
gr.top_block.__init__(self, "Pyephem FSPL v1.0", catch_exceptions=True)
Qt.QWidget.__init__(self)
self.setWindowTitle("Pyephem FSPL v1.0")
qtgui.util.check_set_qss()
try:
self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
except:
pass
self.top_scroll_layout = Qt.QVBoxLayout()
self.setLayout(self.top_scroll_layout)
self.top_scroll = Qt.QScrollArea()
self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
self.top_scroll_layout.addWidget(self.top_scroll)
self.top_scroll.setWidgetResizable(True)
self.top_widget = Qt.QWidget()
self.top_scroll.setWidget(self.top_widget)
self.top_layout = Qt.QVBoxLayout(self.top_widget)
self.top_grid_layout = Qt.QGridLayout()
self.top_layout.addLayout(self.top_grid_layout)
self.settings = Qt.QSettings("GNU Radio", "pyephemfspltest")
try:
if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"):
self.restoreGeometry(self.settings.value("geometry").toByteArray())
else:
self.restoreGeometry(self.settings.value("geometry"))
except:
pass
##################################################
# Variables
##################################################
self.fspl_test = fspl_test = 0
self.variable_qtgui_label_1 = variable_qtgui_label_1 = fspl_test
self.samp_rate = samp_rate = 32000
self.atten_test = atten_test = -1.0/(10.0**(fspl_test/20.0))
self.TLE_LINE_2 = TLE_LINE_2 = "2 25544 51.6433 79.0852 0005185 353.3514 119.8705 15.49577743364510"
self.TLE_LINE_1 = TLE_LINE_1 = "1 25544U 98067A 22292.82819656 .00008231 00000-0 15426-3 0 9997"
self.Radio_1 = Radio_1 = 100e6
self.Name_of_satellite = Name_of_satellite = "ISS (ZARYA)"
##################################################
# Blocks
##################################################
self.fspl = blocks.probe_signal_f()
self._variable_qtgui_label_1_tool_bar = Qt.QToolBar(self)
if None:
self._variable_qtgui_label_1_formatter = None
else:
self._variable_qtgui_label_1_formatter = lambda x: eng_notation.num_to_str(x)
self._variable_qtgui_label_1_tool_bar.addWidget(Qt.QLabel("Uplink FSPL (dB) = "))
self._variable_qtgui_label_1_label = Qt.QLabel(str(self._variable_qtgui_label_1_formatter(self.variable_qtgui_label_1)))
self._variable_qtgui_label_1_tool_bar.addWidget(self._variable_qtgui_label_1_label)
self.top_grid_layout.addWidget(self._variable_qtgui_label_1_tool_bar, 3, 0, 1, 1)
for r in range(3, 4):
self.top_grid_layout.setRowStretch(r, 1)
for c in range(0, 1):
self.top_grid_layout.setColumnStretch(c, 1)
self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
1024, #size
window.WIN_BLACKMAN_hARRIS, #wintype
0, #fc
samp_rate, #bw
"", #name
1,
None # parent
)
self.qtgui_freq_sink_x_0.set_update_time(0.10)
self.qtgui_freq_sink_x_0.set_y_axis(-140, 10)
self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "")
self.qtgui_freq_sink_x_0.enable_autoscale(True)
self.qtgui_freq_sink_x_0.enable_grid(True)
self.qtgui_freq_sink_x_0.set_fft_average(1.0)
self.qtgui_freq_sink_x_0.enable_axis_labels(True)
self.qtgui_freq_sink_x_0.enable_control_panel(False)
self.qtgui_freq_sink_x_0.set_fft_window_normalized(False)
labels = ['Source', 'Source with Atten', '', '', '',
'', '', '', '', '']
widths = [1, 1, 1, 1, 1,
1, 1, 1, 1, 1]
colors = ["blue", "red", "green", "black", "cyan",
"magenta", "yellow", "dark red", "dark green", "dark blue"]
alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
1.0, 1.0, 1.0, 1.0, 1.0]
for i in range(1):
if len(labels[i]) == 0:
self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i))
else:
self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])
self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.qwidget(), Qt.QWidget)
self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win)
def _fspl_test_probe():
while True:
val = self.fspl.level()
try:
try:
self.doc.add_next_tick_callback(functools.partial(self.set_fspl_test,val))
except AttributeError:
self.set_fspl_test(val)
except AttributeError:
pass
time.sleep(1.0 / (10))
_fspl_test_thread = threading.Thread(target=_fspl_test_probe)
_fspl_test_thread.daemon = True
_fspl_test_thread.start()
self.epy_block_0 = epy_block_0.blk(Event='None', frequency=Radio_1, tle_line_1=Name_of_satellite, tle_line_2=TLE_LINE_1, tle_line_3=TLE_LINE_2)
self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True)
self.blocks_multiply_const_vxx_0 = blocks.multiply_const_cc(atten_test)
self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 1000, 1, 0, 0)
##################################################
# Connections
##################################################
self.connect((self.analog_sig_source_x_0, 0), (self.blocks_throttle_0, 0))
self.connect((self.blocks_multiply_const_vxx_0, 0), (self.qtgui_freq_sink_x_0, 0))
self.connect((self.blocks_throttle_0, 0), (self.blocks_multiply_const_vxx_0, 0))
self.connect((self.epy_block_0, 0), (self.fspl, 0))
def closeEvent(self, event):
self.settings = Qt.QSettings("GNU Radio", "pyephemfspltest")
self.settings.setValue("geometry", self.saveGeometry())
self.stop()
self.wait()
event.accept()
def get_fspl_test(self):
return self.fspl_test
def set_fspl_test(self, fspl_test):
self.fspl_test = fspl_test
self.set_atten_test(-1.0/(10.0**(self.fspl_test/20.0)))
self.set_variable_qtgui_label_1(self.fspl_test)
def get_variable_qtgui_label_1(self):
return self.variable_qtgui_label_1
def set_variable_qtgui_label_1(self, variable_qtgui_label_1):
self.variable_qtgui_label_1 = variable_qtgui_label_1
Qt.QMetaObject.invokeMethod(self._variable_qtgui_label_1_label, "setText", Qt.Q_ARG("QString", str(self._variable_qtgui_label_1_formatter(self.variable_qtgui_label_1))))
def get_samp_rate(self):
return self.samp_rate
def set_samp_rate(self, samp_rate):
self.samp_rate = samp_rate
self.analog_sig_source_x_0.set_sampling_freq(self.samp_rate)
self.blocks_throttle_0.set_sample_rate(self.samp_rate)
self.qtgui_freq_sink_x_0.set_frequency_range(0, self.samp_rate)
def get_atten_test(self):
return self.atten_test
def set_atten_test(self, atten_test):
self.atten_test = atten_test
self.blocks_multiply_const_vxx_0.set_k(self.atten_test)
def get_TLE_LINE_2(self):
return self.TLE_LINE_2
def set_TLE_LINE_2(self, TLE_LINE_2):
self.TLE_LINE_2 = TLE_LINE_2
self.epy_block_0.tle_line_3 = self.TLE_LINE_2
def get_TLE_LINE_1(self):
return self.TLE_LINE_1
def set_TLE_LINE_1(self, TLE_LINE_1):
self.TLE_LINE_1 = TLE_LINE_1
self.epy_block_0.tle_line_2 = self.TLE_LINE_1
def get_Radio_1(self):
return self.Radio_1
def set_Radio_1(self, Radio_1):
self.Radio_1 = Radio_1
self.epy_block_0.frequency = self.Radio_1
def get_Name_of_satellite(self):
return self.Name_of_satellite
def set_Name_of_satellite(self, Name_of_satellite):
self.Name_of_satellite = Name_of_satellite
self.epy_block_0.tle_line_1 = self.Name_of_satellite
def main(top_block_cls=pyephemfspltest, options=None):
if StrictVersion("4.5.0") <= StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"):
style = gr.prefs().get_string('qtgui', 'style', 'raster')
Qt.QApplication.setGraphicsSystem(style)
qapp = Qt.QApplication(sys.argv)
tb = top_block_cls()
tb.start()
tb.show()
def sig_handler(sig=None, frame=None):
tb.stop()
tb.wait()
Qt.QApplication.quit()
signal.signal(signal.SIGINT, sig_handler)
signal.signal(signal.SIGTERM, sig_handler)
timer = Qt.QTimer()
timer.start(500)
timer.timeout.connect(lambda: None)
qapp.exec_()
if __name__ == '__main__':
main()
Hi Jose - I can run your script for hours without any issues on both GR 3.8 and 3.10.
Have you tried setting
export QT_QPA_PLATFORM=wayland
as indicated in the first error message - to see if the script runs longer then 10 minutes?
My guess is if you eliminate the first exception the other exceptions will disappear.
Are you working from the console of a linux machine - or are you working from the console of a Windows machine - and then connecting to the a Linux machine by some method?
-- Cinaed
On Tue, Nov 22, 2022 at 10:23 PM Jose Ruvalcaba <joruvalc@gmail.com> wrote:
Hello,
I've been noticing an issue popping out everytime I stop running my flowgraph and I was wondering if someone had some insight on it. I have a flowgraph where a signal source is connected to a probe signal block. This block is constantly updating values and are being displayed using the QT GUI Label block. However, after running my flowgraph for about 10 minutes I get the following error:
Executing: /usr/bin/python3 -u /home/spacerfvm/Documents/GNURadio_3.10_flowgraphs/func_probe_test.py
Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.
Exception in thread Thread-1 (_amp_probe):
Traceback (most recent call last):
File "/home/spacerfvm/Documents/GNURadio_3.10_flowgraphs/func_probe_test.py", line 150, in _amp_probe
self.doc.add_next_tick_callback(functools.partial(self.set_amp,val))
File "/usr/lib/python3/dist-packages/gnuradio/gr/hier_block2.py", line 88, in __getattr__
return getattr(self._impl, name)
AttributeError: 'gnuradio.gr.gr_python.top_block_pb' object has no attribute 'doc'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
self.run()
File "/usr/lib/python3.10/threading.py", line 953, in run
self._target(*self._args, **self._kwargs)
File "/home/spacerfvm/Documents/GNURadio_3.10_flowgraphs/func_probe_test.py", line 152, in _amp_probe
self.set_amp(val)
File "/home/spacerfvm/Documents/GNURadio_3.10_flowgraphs/func_probe_test.py", line 182, in set_amp
self.set_variable_qtgui_label_0(self.amp)
File "/home/spacerfvm/Documents/GNURadio_3.10_flowgraphs/func_probe_test.py", line 189, in set_variable_qtgui_label_0
Qt.QMetaObject.invokeMethod(self._variable_qtgui_label_0_label, "setText", Qt.Q_ARG("QString", str(self._variable_qtgui_label_0_formatter(self.variable_qtgui_label_0))))
RuntimeError: wrapped C/C++ object of type QLabel has been deleted
It seems that my issue is related to the QT GUI Label block because when I remove it and add say QT GUI Number sink, this issue doesn't appear.
Has anyone experienced this issue? If so, would anyone be able to steer me in the direction to fix it? I am currently running on Ubuntu 22.04 and am running GNU RADIO 3.10.1.1 which I installed using sudo apt-get install. I've also attached the flowgraph I am talking about.
Thanks,
Jose Ruvalcaba
No comments:
Post a Comment