discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Discuss-gnuradio] the dreaded AttributeError: 'module' object has n


From: Ron Economos
Subject: Re: [Discuss-gnuradio] the dreaded AttributeError: 'module' object has no attribute...
Date: Sat, 12 Nov 2016 09:51:31 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0

This can also happen if the OOT isn't linked properly. That is, some necessary library is missing.

Ron

On 11/12/2016 09:42 AM, Tom Early wrote:

Yes Nicolas, thanks. I did do that.

I have still been working on it and still haven't solved it.


On 11/12/2016 11:10 AM, Nicolas Cuervo wrote:
Hi Tom,

Did you, after you install your OOT module, run the following in your terminal?:

    sudo ldconfig

Cheers,

- Nicolas

On Fri, Nov 11, 2016 at 9:43 PM, Tom Early <address@hidden> wrote:
Sorry, me again.

Recently did a fresh install of ubuntu 16.10 and did a apt install of gnuradio.

A few days ago you helped me get my OOT blocks properly installed on my own tree by added square brackets around my <category> value.

However there are now problems when I run:

  File "/home/tom/grc-flow/top_block.py", line 147, in __init__
    self.ambe3000_dstar_encode_sb_0 = ambe3000.dstar_encode_sb('/dev/ttyUSB0', 230400)
AttributeError: 'module' object has no attribute 'dstar_encode_sb'

I'm having trouble finding useful info googling on this error message. I have spend several days following various threads, including rebuilding another, identical OOT from scratch with gr_modtool.

My OOT is at https://github.com/ac2ie/gr-ambe3000 . (This OOT worked fine with ubuntu 16.04.)

Here is top_block.py:

#!/usr/bin/env python2
# -*- coding: utf-8 -*-
##################################################
# GNU Radio Python Flow Graph
# Title: Dstar Transmitter
# Author: Thomas Early AC2IE
# Description: Uses NWDigitalRadio DV3000U
# Generated: Fri Nov 11 15:20:49 2016
##################################################

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 blocks
from gnuradio import digital
from gnuradio import eng_notation
from gnuradio import filter
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 ambe3000
import sip
import sys
import time


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

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

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 32000
        self.samples_per_symbol = samples_per_symbol = 100

        self.lpf_taps = lpf_taps = firdes.low_pass(32767, samp_rate, 3500, 350, firdes.WIN_HAMMING, 6.76)

        self.baud_rate = baud_rate = 4800

        ##################################################
        # Blocks
        ##################################################
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
self.uhd_usrp_sink_0.set_samp_rate(baud_rate*samples_per_symbol)
        self.uhd_usrp_sink_0.set_center_freq(146550000, 0)
        self.uhd_usrp_sink_0.set_gain(20, 0)
        self.uhd_usrp_sink_0.set_antenna('TX/RX', 0)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_c(
            1024, #size
            baud_rate*samples_per_symbol, #samp_rate
            "", #name
            1 #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)

        self.qtgui_time_sink_x_0.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_0.enable_tags(-1, True)
self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
        self.qtgui_time_sink_x_0.enable_autoscale(True)
        self.qtgui_time_sink_x_0.enable_grid(False)
        self.qtgui_time_sink_x_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0.enable_control_panel(False)

        if not True:
          self.qtgui_time_sink_x_0.disable_legend()

        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "blue"]
        styles = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1,
                   -1, -1, -1, -1, -1]
        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(2*1):
            if len(labels[i]) == 0:
                if(i % 2 == 0):
                    self.qtgui_time_sink_x_0.set_line_label(i, "Re{{Data {0}}}".format(i/2))
                else:
                    self.qtgui_time_sink_x_0.set_line_label(i, "Im{{Data {0}}}".format(i/2))
            else:
                self.qtgui_time_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.fir_filter_xxx_0 = filter.fir_filter_fsf(4, (lpf_taps))
        self.fir_filter_xxx_0.declare_sample_delay(0)
        self.digital_gmsk_mod_0 = digital.gmsk_mod(
            samples_per_symbol=samples_per_symbol,
            bt=0.35,
            verbose=False,
            log=False,
        )
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_float*1, '/home/tom/fl32k.audio', False)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_char*1, 24)
        self.ambe3000_dstar_encode_sb_0 = ambe3000.dstar_encode_sb('/dev/ttyUSB0', 230400)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.ambe3000_dstar_encode_sb_0, 0), (self.blocks_delay_0, 0))
        self.connect((self.blocks_delay_0, 0), (self.digital_gmsk_mod_0, 0))
        self.connect((self.blocks_file_source_0, 0), (self.fir_filter_xxx_0, 0))
        self.connect((self.digital_gmsk_mod_0, 0), (self.qtgui_time_sink_x_0, 0))
        self.connect((self.digital_gmsk_mod_0, 0), (self.uhd_usrp_sink_0, 0))
        self.connect((self.fir_filter_xxx_0, 0), (self.ambe3000_dstar_encode_sb_0, 0))

    def closeEvent(self, event):
        self.settings = Qt.QSettings("GNU Radio", "top_block")
        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

    def get_samples_per_symbol(self):
        return self.samples_per_symbol

    def set_samples_per_symbol(self, samples_per_symbol):
        self.samples_per_symbol = samples_per_symbol
self.uhd_usrp_sink_0.set_samp_rate(self.baud_rate*self.samples_per_symbol)
self.qtgui_time_sink_x_0.set_samp_rate(self.baud_rate*self.samples_per_symbol)

    def get_lpf_taps(self):
        return self.lpf_taps

    def set_lpf_taps(self, lpf_taps):
        self.lpf_taps = lpf_taps
        self.fir_filter_xxx_0.set_taps((self.lpf_taps))

    def get_baud_rate(self):
        return self.baud_rate

    def set_baud_rate(self, baud_rate):
        self.baud_rate = baud_rate
self.uhd_usrp_sink_0.set_samp_rate(self.baud_rate*self.samples_per_symbol)
self.qtgui_time_sink_x_0.set_samp_rate(self.baud_rate*self.samples_per_symbol)


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


_______________________________________________


reply via email to

[Prev in Thread] Current Thread [Next in Thread]