[USRP-users] Error in RFNoC grc with OOT module

Avila, Jose A jaavila5 at miners.utep.edu
Wed Oct 4 17:02:09 EDT 2017


Hello we are developing an OOT module following the tutorial, but similar to siggen, but are currently encountering an error that comes up with


./testtwochannel.py

The error that comes up is the following

  File "./testtwochannel.py", line 97
    self.siggen2ch_twochannelsiggen_0 = Template error: siggen2ch.twochannelsiggen(
                                                     ^
SyntaxError: invalid syntax

The file in question is the following:


#!/usr/bin/env python2
# -*- coding: utf-8 -*-
##################################################
# GNU Radio Python Flow Graph
# Title: Testtwochannel
# Generated: Wed Oct  4 14:35:59 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 eng_notation
from gnuradio import gr
from gnuradio import qtgui
from gnuradio import uhd
from gnuradio.eng_option import eng_option
from gnuradio.filter import firdes
from optparse import OptionParser
import SimpleXMLRPCServer
import ettus
import siggen2ch
import sip
import sys
import threading
from gnuradio import qtgui


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

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

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 10e6
        self.waveform = waveform = "SINE_WAVE"
        self.ip_addr = ip_addr = "192.168.10.100"
        self.gain = gain = 1.0
        self.freq = freq = samp_rate/10
        self.enable = enable = False
        self.device3 = device3 = ettus.device3(uhd.device_addr_t( ",".join(('type=e3x0', "")) ))
        self.ampl_q = ampl_q = 1
        self.ampl_i = ampl_i = 1

        ##################################################
        # Blocks
        ##################################################
        self.xmlrpc_server_0 = SimpleXMLRPCServer.SimpleXMLRPCServer(('0.0.0.0', 8080), allow_none=True)
        self.xmlrpc_server_0.register_instance(self)
        self.xmlrpc_server_0_thread = threading.Thread(target=self.xmlrpc_server_0.serve_forever)
        self.xmlrpc_server_0_thread.daemon = True
        self.xmlrpc_server_0_thread.start()
        self.uhd_rfnoc_streamer_fifo_0 = ettus.rfnoc_generic(
            self.device3,
            uhd.stream_args( # TX Stream Args
                cpu_format="fc32",
                otw_format="sc16",
                args="gr_vlen={0},{1}".format(1, "" if 1 == 1 else "spp={0}".format(1)),
            ),
            uhd.stream_args( # RX Stream Args
                cpu_format="fc32",
                otw_format="sc16",
                args="gr_vlen={0},{1}".format(1, "" if 1 == 1 else "spp={0}".format(1)),
            ),
            "FIFO", -1, -1,
        )
        self.siggen2ch_twochannelsiggen_0 = Template error: siggen2ch.twochannelsiggen(
                  self.device3,
                  uhd.stream_args( # TX Stream Args
                        cpu_format="fc32",
                        otw_format="sc16",
                        args="gr_vlen={0},{1}".format(${grvlen}, "" if $grvlen == 1 else "spp={0}".format($grvlen)),
                  ),
                  uhd.stream_args( # RX Stream Args
                        cpu_format="fc32",
                        otw_format="sc16",
                        args="gr_vlen={0},{1}".format(${grvlen}, "" if $grvlen == 1 else "spp={0}".format($grvlen)),
                  ),
                  $block_index,
                  $device_index
          )
          self.$(id).set_arg("spp",  $spp)
          self.$(id).set_arg("frequency1", ((2*$frequency1)/$samp_rate))
          self.$(id).set_arg("cartesian1", $cartesian1)
          self.$(id).set_arg("frequency2", ((2*$frequency2)/$samp_rate))
          self.$(id).set_arg("cartesian2", $cartesian2)
          self.$(id).set_arg("gain", $gain)
          self.$(id).set_arg("enable", $enable)

            cannot find 'samp_rate'
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            1024, #size
            firdes.WIN_BLACKMAN_hARRIS, #wintype
            0, #fc
            samp_rate, #bw
            "", #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 True:
          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 = ['', '', '', '', '',
                  '', '', '', '', '']
        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_layout.addWidget(self._qtgui_freq_sink_x_0_win)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.uhd_rfnoc_streamer_fifo_0, 0), (self.qtgui_freq_sink_x_0, 0))
        self.device3.connect(self.siggen2ch_twochannelsiggen_0.get_block_id(), 0, self.uhd_rfnoc_streamer_fifo_0.get_block_id(), 0)

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

    def get_samp_rate(self):
        return self.samp_rate

    def set_samp_rate(self, samp_rate):
        self.samp_rate = samp_rate
        self.siggen2ch_twochannelsiggen_0.Template error: set_arg("frequency1", ((2*$frequency1)/$self.samp_rate))
            cannot find 'samp_rate'
        self.siggen2ch_twochannelsiggen_0.Template error: set_arg("frequency2", ((2*$frequency2)/$self.samp_rate))
            cannot find 'samp_rate'
        self.qtgui_freq_sink_x_0.set_frequency_range(0, self.samp_rate)
        self.set_freq(self.samp_rate/10)

    def get_waveform(self):
        return self.waveform

    def set_waveform(self, waveform):
        self.waveform = waveform

    def get_ip_addr(self):
        return self.ip_addr

    def set_ip_addr(self, ip_addr):
        self.ip_addr = ip_addr

    def get_gain(self):
        return self.gain

    def set_gain(self, gain):
        self.gain = gain

    def get_freq(self):
        return self.freq

    def set_freq(self, freq):
        self.freq = freq

    def get_enable(self):
        return self.enable

    def set_enable(self, enable):
        self.enable = enable

    def get_device3(self):
        return self.device3

    def set_device3(self, device3):
        self.device3 = device3

    def get_ampl_q(self):
        return self.ampl_q

    def set_ampl_q(self, ampl_q):
        self.ampl_q = ampl_q

    def get_ampl_i(self):
        return self.ampl_i

    def set_ampl_i(self, ampl_i):
        self.ampl_i = ampl_i


def main(top_block_cls=testtwochannel, 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()


Thank you


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ettus.com/pipermail/usrp-users_lists.ettus.com/attachments/20171004/00ada53d/attachment-0002.html>


More information about the USRP-users mailing list