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:
[root@mehmet Desktop]# python mehmet_rx.py
Traceback (most recent call last):
File “mehmet_rx.py”, line 99, in
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,
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