Garbage from USRP from second run

Dear ALL:

Thanks to Don I got to install gnuradio on XP+MSYS.

Earlier last year I wrote the following program to receive streams from
2
daughter boards on a USRP
.

It works fine except that I need to restart my USRP before every reading
(I
get to disconnect power and connect again).

This is because I get garbage at the start of the stream.

Is this because the buffer does not clear?

How do I fix the problem. Help much appreciated!


#bring in blocks from the main gnu radio package
from gnuradio import gr, gru, eng_notation, optfir
from gnuradio import audio
from gnuradio import usrp
from gnuradio import blks2
from gnuradio.eng_option import eng_option
from optparse import OptionParser
from usrpm import usrp_dbid
import sys
import math

def build_graph():

#create the top block
tb=gr.top_block()
decim_rate=16

#creat the USRP source
tb.src_usrp=usrp.source_c(0,decim_rate,fpga_filename=“std_2rxhb_2tx.rbf”)
#set MUX
#tb.src_usrp.set_mux(usrp.determine_rx_mux_value(tb.src_usrp,
subdev_spec))
tb.src_usrp.set_mux(gru.hexint(0x00002301))
#set number of channels
tb.src_usrp.set_nchannels(2)

#create a signal sink
tb.sink_file = gr.file_sink(gr.sizeof_gr_complex,
‘matlab/test_files/zz207.dat’)
tb.sink_file1 = gr.file_sink(gr.sizeof_gr_complex,
‘matlab/test_files/zz208.dat’)

#create counter
tb.count=gr.head(gr.sizeof_gr_complex, int(4000))

#create deinterleaver
tb.di=gr.deinterleave(gr.sizeof_gr_complex)

#connect the source to the deinterleaver
tb.connect(tb.src_usrp,tb.count,tb.di)
tb.connect((tb.di,0),tb.sink_file)
tb.connect((tb.di,1),tb.sink_file1)

#automatically choose the sub device
#subdev_spec = usrp.pick_rx_subdevice(tb.src_usrp)
subdev_spec1 = (0,0)
subdev_spec2 = (1,0)

#get the sub-device
tb.subdev1 = usrp.selected_subdev(tb.src_usrp, subdev_spec1)
tb.subdev2 = usrp.selected_subdev(tb.src_usrp, subdev_spec2)

#Set the gain
g2=tb.subdev2.gain_range()
gain2=float(g2[0]+g2[1])/2

g1=tb.subdev1.gain_range()
gain1=float(g1[0]+g1[1])/2
#gain=
tb.subdev2.set_gain(gain2)
tb.subdev1.set_gain(gain1)

#Tune the center frequency
freq1=float(911e6)
freq2=float(911e6)
tb.src_usrp.tune(0, tb.subdev1, freq1)
tb.src_usrp.tune(1, tb.subdev2, freq2)
return tb

if name == ‘main’:
tb = build_graph ()
tb.run()


Regards.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs