discuss-gnuradio
[Top][All Lists]
Advanced

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

Re: [Discuss-gnuradio] writin oscope on python


From: Josh Blum
Subject: Re: [Discuss-gnuradio] writin oscope on python
Date: Sun, 11 Jul 2010 09:50:04 -0700
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.10) Gecko/20100527 Thunderbird/3.0.5

I recommend making this application with the gnuradio companion and then you can inspect/modify/learn-from the generated python code.

http://gnuradio.org/redmine/wiki/gnuradio/GNURadioCompanion

-Josh

see below

|
|
v

On 07/11/2010 05:33 AM, mehmet kabasakal wrote:
Hi everyone,

I want to see a simple cosine signal on oscope by writing a pyhton code.
I am using scopesink2.scope_sink_c tool. The code is below:

and I got this error message:
address@hidden Desktop]# python mehmet_rx.py
Traceback (most recent call last):
   File "mehmet_rx.py", line 99, in<module>
     my_top_block().run()
   File "mehmet_rx.py", line 87, in __init__
     num_inputs=0,
   File "/usr/lib/python2.6/site-packages/gnuradio/wxgui/scopesink_gl.py",
line 144, in __init__
     msg_key=MSG_KEY,
   File "/usr/lib/python2.6/site-packages/gnuradio/wxgui/scope_window.py",
line 430, in __init__
     wx.Panel.__init__(self, parent, style=wx.SIMPLE_BORDER)
   File "/usr/lib/python2.6/site-packages/wx-2.8-gtk2-unicode/wx/_windows.py",
line 68, in __init__
     _windows_.Panel_swiginit(self,_windows_.new_Panel(*args, **kwargs))
TypeError: in method 'new_Panel', expected argument 1 of type 'wxWindow *'


The python code:

from gnuradio import gr, usrp
from gnuradio.wxgui import stdgui2, scopesink2, fftsink2, form
import wx

class my_top_block(gr.top_block):

     def __init__(self):
         gr.top_block.__init__(self)

        sample_rate = 320000
         ampl = 1000
        decimation = 200
        frequency = 1700000000  
        gain = 1000


        #create the usrp source
        #0 represents the USRP number (in case you have multiple USRPs)
        u = usrp.source_c(0)

        #Set the decimation
        u.set_decim_rate(decimation)

        #Automatically choose the sub device
        #(this can be done manually, see below)
        subdev_spec = usrp.pick_rx_subdevice(u)

        #Set the mux
        u.set_mux(usrp.determine_rx_mux_value(u, subdev_spec))

        #get the sub-device
        subdev = usrp.selected_subdev(u, subdev_spec)

        #Select receive antenna ('TX/RX' or 'RX2'): flex boards only!
        subdev.select_rx_antenna('TX/RX')

        #Set the gain
        subdev.set_gain(gain)

        #Tune the center frequency
        u.tune(0, subdev, frequency)

        self.wxgui_scopesink2_0 = scopesink2.scope_sink_c(
                        self,

self is a gr.top_block not a wx panel

                        title="Scope Plot",
                        sample_rate=320000,
                        v_scale=0,
                        t_scale=0,
                        ac_couple=False,
                        xy_mode=False,
                        num_inputs=1,
                )

        self.connect((u, 0), (self.wxgui_scopesink2_0, 0))

if __name__ == '__main__':
     try:
        my_top_block().run()
     except KeyboardInterrupt:
        pass

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



reply via email to

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