... here we are.

Thanks,
Ruedi

Am 10.08.2017 um 18:28 schrieb Marcus Müller:
Huh, odd, that looks like it should, and that runs just well on my
3.7.12 (don't remember there being a related bug fix since 11); soooooo,
I'll need to read that couple lines of code in Python that your GRC
generates (and mine doesn't). Can you also share your
/tmp/resampler_demo.py ?

Thanks!
Marcus


On 08/10/2017 06:21 PM, Ruediger Bauernschmitt wrote:
Dear Marcus,

attached the flow graph as captured. Thanks for your help!

Best Regards,

Ruedi


Am 10.08.2017 um 18:08 schrieb Marcus Müller:
Dear Ruedi,

That's pretty interesting; could you use GRC's screen capture
functionality to share what the flow graph looks like on your machine? I
sense GNU Radio bugs!

Best regards,
Marcus

On 08/10/2017 05:54 PM, Ruediger Bauernschmitt wrote:
Hello,

I'm using gnuradio-companion 3.7.11.1 installed using apt-get on
Ubuntu 14.04.5 LTS running on a Lenovo T60.

The dialtone example works fine but once I'm using the frequency sink
like e.g. in the resampler_demo.grc I get the following Runtime Error:

Generating: '/tmp/resampler_demo.py'

Executing: /usr/bin/python2 -u /tmp/resampler_demo.py

Traceback (most recent call last):
    File "/tmp/resampler_demo.py", line 284, in <module>
      main()
    File "/tmp/resampler_demo.py", line 272, in main
      tb = top_block_cls()
    File "/tmp/resampler_demo.py", line 104, in __init__
      1 #number of inputs
    File
"/usr/local/lib/python2.7/dist-packages/gnuradio/qtgui/qtgui_swig.py",
line 1371, in make
      return _qtgui_swig.freq_sink_c_make(*args, **kwargs)
RuntimeError: std::exception

Any ideas?

Best wishes,

Ruedi


_______________________________________________
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio

#!/usr/bin/env python2
# -*- coding: utf-8 -*-
##################################################
# GNU Radio Python Flow Graph
# Title: Resampler Demo
# Generated: Thu Aug 10 17:17:28 2017
##################################################

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 PyQt4 import Qt
from gnuradio import analog
from gnuradio import blocks
from gnuradio import eng_notation
from gnuradio import gr
from gnuradio import qtgui
from gnuradio.eng_option import eng_option
from gnuradio.filter import firdes
from gnuradio.filter import pfb
from optparse import OptionParser
import math
import sip
import sys
from gnuradio import qtgui


class resampler_demo(gr.top_block, Qt.QWidget):

    def __init__(self):
        gr.top_block.__init__(self, "Resampler Demo")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Resampler Demo")
        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", "resampler_demo")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.nphases = nphases = 32
        self.frac_bw = frac_bw = .45
        self.samp_rate = samp_rate = 44100
        self.rs_taps = rs_taps = firdes.low_pass(nphases, nphases, frac_bw, 0.5-frac_bw)
        self.new_rate = new_rate = 48000

        ##################################################
        # Blocks
        ##################################################
        self._samp_rate_tool_bar = Qt.QToolBar(self)

        if None:
          self._samp_rate_formatter = None
        else:
          self._samp_rate_formatter = lambda x: eng_notation.num_to_str(x)

        self._samp_rate_tool_bar.addWidget(Qt.QLabel('Sampling Rate'+": "))
        self._samp_rate_label = Qt.QLabel(str(self._samp_rate_formatter(self.samp_rate)))
        self._samp_rate_tool_bar.addWidget(self._samp_rate_label)
        self.top_grid_layout.addWidget(self._samp_rate_tool_bar, 0,0,1,1)

        self._new_rate_tool_bar = Qt.QToolBar(self)

        if None:
          self._new_rate_formatter = None
        else:
          self._new_rate_formatter = lambda x: eng_notation.num_to_str(x)

        self._new_rate_tool_bar.addWidget(Qt.QLabel('Resampling Rate'+": "))
        self._new_rate_label = Qt.QLabel(str(self._new_rate_formatter(self.new_rate)))
        self._new_rate_tool_bar.addWidget(self._new_rate_label)
        self.top_grid_layout.addWidget(self._new_rate_tool_bar, 0,1,1,1)

        self.throttle = blocks.throttle(gr.sizeof_float*1, samp_rate,True)
        self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c(
        	1024, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	new_rate, #bw
        	'Resampled Spectrum', #name
        	1 #number of inputs
        )
        self.qtgui_freq_sink_x_0_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "")
        self.qtgui_freq_sink_x_0_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0_0.enable_grid(False)
        self.qtgui_freq_sink_x_0_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0_0.enable_control_panel(False)

        if not False:
          self.qtgui_freq_sink_x_0_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
          self.qtgui_freq_sink_x_0_0.set_plot_pos_half(not True)

        labels = ['Resampled Spectrum', 'Resampled Spectrum', '', '', '',
                  '', '', '', '', '']
        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 xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_0_win, 2,0,1,3)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
        	1024, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	samp_rate, #bw
        	'Original Spectrum', #name
        	1 #number of inputs
        )
        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(False)
        self.qtgui_freq_sink_x_0.enable_grid(False)
        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)

        if not False:
          self.qtgui_freq_sink_x_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
          self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)

        labels = ['Original Spectrum', 'Resampled Spectrum', '', '', '',
                  '', '', '', '', '']
        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 xrange(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.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 1,0,1,3)
        self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf(
        	  float(new_rate)/samp_rate,
                  taps=(rs_taps),
        	  flt_size=nphases)
        self.pfb_arb_resampler_xxx_0.declare_sample_delay(0)

        self._frac_bw_tool_bar = Qt.QToolBar(self)

        if lambda x: "%0.2f"%x:
          self._frac_bw_formatter = lambda x: "%0.2f"%x
        else:
          self._frac_bw_formatter = lambda x: eng_notation.num_to_str(x)

        self._frac_bw_tool_bar.addWidget(Qt.QLabel('Fractional Bandwidth'+": "))
        self._frac_bw_label = Qt.QLabel(str(self._frac_bw_formatter(self.frac_bw)))
        self._frac_bw_tool_bar.addWidget(self._frac_bw_label)
        self.top_grid_layout.addWidget(self._frac_bw_tool_bar, 0,2,1,1)

        self.analog_sig_source_x_0 = analog.sig_source_f(samp_rate, analog.GR_TRI_WAVE, 0.05, 2, 0)
        self.analog_frequency_modulator_fc_0 = analog.frequency_modulator_fc(math.pi)
        self.adder = blocks.add_const_vff((-1.0, ))

        ##################################################
        # Connections
        ##################################################
        self.connect((self.adder, 0), (self.throttle, 0))
        self.connect((self.analog_frequency_modulator_fc_0, 0), (self.pfb_arb_resampler_xxx_0, 0))
        self.connect((self.analog_frequency_modulator_fc_0, 0), (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.analog_sig_source_x_0, 0), (self.adder, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.qtgui_freq_sink_x_0_0, 0))
        self.connect((self.throttle, 0), (self.analog_frequency_modulator_fc_0, 0))

    def closeEvent(self, event):
        self.settings = Qt.QSettings("GNU Radio", "resampler_demo")
        self.settings.setValue("geometry", self.saveGeometry())
        event.accept()

    def get_nphases(self):
        return self.nphases

    def set_nphases(self, nphases):
        self.nphases = nphases
        self.set_rs_taps(firdes.low_pass(self.nphases, self.nphases, self.frac_bw, 0.5-self.frac_bw))

    def get_frac_bw(self):
        return self.frac_bw

    def set_frac_bw(self, frac_bw):
        self.frac_bw = frac_bw
        self.set_rs_taps(firdes.low_pass(self.nphases, self.nphases, self.frac_bw, 0.5-self.frac_bw))
        Qt.QMetaObject.invokeMethod(self._frac_bw_label, "setText", Qt.Q_ARG("QString", self.frac_bw))

    def get_samp_rate(self):
        return self.samp_rate

    def set_samp_rate(self, samp_rate):
        self.samp_rate = samp_rate
        Qt.QMetaObject.invokeMethod(self._samp_rate_label, "setText", Qt.Q_ARG("QString", self.samp_rate))
        self.throttle.set_sample_rate(self.samp_rate)
        self.qtgui_freq_sink_x_0.set_frequency_range(0, self.samp_rate)
        self.pfb_arb_resampler_xxx_0.set_rate(float(self.new_rate)/self.samp_rate)
        self.analog_sig_source_x_0.set_sampling_freq(self.samp_rate)

    def get_rs_taps(self):
        return self.rs_taps

    def set_rs_taps(self, rs_taps):
        self.rs_taps = rs_taps
        self.pfb_arb_resampler_xxx_0.set_taps((self.rs_taps))

    def get_new_rate(self):
        return self.new_rate

    def set_new_rate(self, new_rate):
        self.new_rate = new_rate
        Qt.QMetaObject.invokeMethod(self._new_rate_label, "setText", Qt.Q_ARG("QString", self.new_rate))
        self.qtgui_freq_sink_x_0_0.set_frequency_range(0, self.new_rate)
        self.pfb_arb_resampler_xxx_0.set_rate(float(self.new_rate)/self.samp_rate)


def main(top_block_cls=resampler_demo, options=None):

    from distutils.version import StrictVersion
    if StrictVersion(Qt.qVersion()) >= StrictVersion("4.5.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 quitting():
        tb.stop()
        tb.wait()
    qapp.connect(qapp, Qt.SIGNAL("aboutToQuit()"), quitting)
    qapp.exec_()


if __name__ == '__main__':
    main()
_______________________________________________
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio

Reply via email to