0

this is what i am getting when i execute the following code.

Traceback (most recent call last):
 File "usrp.py",line 100 in <module>
  tb.set_freq(i)
 File "usrp.py",line 77 in set_freq
  self.wxgui_fftsink2_0.set_baseband_freq(self.freq)
 File "usr/local/lib/python2.7/dist-packages/gnuradio/wxgui/common.py",line 131 in set
 def set(value): controller[key]=value
 File "usr/local/lib/python2.7/dist-packages/gnuradio/wxgui/pubsub.py",line 44 in _setitem_
  elif self._proxies[key] is not None:
AttributeError: 'fft_window' object has no attribute '_proxies'

i have seen this kind of error in cyclic dependency.i have earlier solved cyclic dependency by just importing the package instead of using from keyword.i had tried import gnuradio in ths case but of no use.Following is the code on which i am working on.it would be great help if this could be resolved.i haven't come across this kind of an error.

#!/usr/bin/env python
##################################################
# Gnuradio Python Flow Graph
# Title: Usrp
# Generated: Sat Feb 21 11:26:17 2015
##################################################
#################################################

# Gnuradio Python Flow Graph
# Title: Usrp
# Generated: Sat Feb 21 11:26:17 2015
##################################################
from gnuradio import analog
from gnuradio import blocks
from gnuradio import eng_notation
from gnuradio import gr
from gnuradio import wxgui
from gnuradio.eng_option import eng_option
from gnuradio.fft import window
from gnuradio.filter import firdes
from gnuradio.wxgui import fftsink2
from grc_gnuradio import wxgui as grc_wxgui
from optparse import OptionParser
import wx,time,random

class usrp(grc_wxgui.top_block_gui):
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Usrp")
        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 32000
        self.freq = freq = 900e6
        ##################################################
        # Blocks
        ##################################################
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
            self.GetWin(),
            baseband_freq=freq,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=samp_rate
            fft_size=1024,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title="FFT Plot",
            peak_hold=False,
        )
        self.Add(self.wxgui_fftsink2_0.win)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True)
        self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_SIN_WAVE, 100e3,1, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.wxgui_fftsink2_0, 0))


    def get_samp_rate(self):
        return self.samp_rate


    def set_samp_rate(self, samp_rate):
        self.samp_rate = samp_rate
        self.wxgui_fftsink2_0.set_sample_rate(self.samp_rate)
        self.analog_sig_source_x_0.set_sampling_freq(self.samp_rate)
        self.blocks_throttle_0.set_sample_rate(self.samp_rate)


    def get_freq(self):
        return self.freq


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


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()"
    parser = OptionParser(option_class=eng_option, usage="%prog: [options]")
    (options, args) = parser.parse_args()
    tb = usrp()
    def t_range(beg,end,incr):
        while beg<=end:
            yield beg
            beg+=incr
    j=2
    for i in t_range(910e6,1010e6,10e6):
        tb.set_freq(i)
        #time.sleep(j)
        tb.Start(True)
        time.sleep(j)
        tb.Wait()
Marcus Müller
  • 34,677
  • 4
  • 53
  • 94
nit710
  • 174
  • 1
  • 2
  • 12

1 Answers1

0

This is most likely not a cyclic dependency issue.

I'm however a bit concerned about that error. You see, pubsub's __init__ generates a _proxies attribute, so if a class is a subclass of pubsub, it should have _proxies; if it's not, it shouldn't see that call.

class pubsub(dict):
    def __init__(self):
        self._publishers = { }
        self._subscribers = { }
        self._proxies = { }
    ....

So, interestingly, your script works for me (after fixing a missing , in line 45), which might indicate you're mixing sources of different GNU Radio versions: WXGUI FFT

As a solution, I recommend making sure you're really using one version of GNU Radio, preferably the latest, and installed from source (debian's packages are rather up-to-date, too, thanks to Maitland), which can happen automagically using PyBOMBS.

Marcus Müller
  • 34,677
  • 4
  • 53
  • 94
  • Sir,thank you so much for replying.But what I actually want to achieve is to hop frequencies at each iteration of the for loop ranging from 910e6 to 1010e6. I am getting the same output as you got which is actually the plot for only the first iteration(i.e 910MHz). The FFT plot comes to a halt after the first iteration without getting ahead.I am getting the mentioned error in the questioin after i close the FFT plot window. – nit710 Mar 03 '15 at 17:57