[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Discuss-gnuradio] the program stops unpredictedly
From: |
Minhoo Kim |
Subject: |
[Discuss-gnuradio] the program stops unpredictedly |
Date: |
Tue, 2 Aug 2011 13:55:15 -0700 (PDT) |
Hi all,
I can't find out why this program stops running.
class my_top_block(gr.top_block):
def __init__(self):
gr.top_block.__init__(self)
self.sample_rate=1e6
self.usrp_rate=128e6
self.tx_freq = 2.48e9
self.tx_amplitude = 10
self._tx_subdev_spec = (1,0)
self.gain = None
self.subdev_spec = (0,0)
self.freq = self.tx_freq
print self.tx_amplitude
self.interp = int(self.usrp_rate // (self.sample_rate))
src = gr.sig_source_c (self.sample_rate,gr.GR_SQR_WAVE,10000,2,-1)
#fmtx = blks2.nbfm_tx (self.sample_rate/10, self.sample_rate, tau=75e-6,
max_dev=1.50e5)
# Local oscillator
self.lo = gr.sig_source_c (self.sample_rate, # sample rate
gr.GR_COS_WAVE, # waveform type
5e5, #frequency
3000, # amplitude
0) # DC Offset
mixer = gr.multiply_cc()
#self.disconnect_all()
print ' disconnect'
self.connect (src, (mixer, 0))
self.connect (self.lo, (mixer, 1))
self.sourcedat =
gr.file_source(gr.sizeof_gr_complex,"datasource_five.dat",False)
#nullsink = gr.null_sink(gr.sizeof_gr_complex)
burst = gr.multiply_cc()
self.connect(mixer,(burst,0))
self.connect(self.sourcedat,(burst,1))
self.listen = burst
gain = gr.multiply_const_cc (10.0)
self.connect(self.listen,gain)
self._setup_usrp()
self.connect(gain,self.u)
print 'all connection'
def _setup_usrp(self):
self.u= usrp.sink_c(0)
self.u.set_interp_rate(self.interp)
if self.subdev_spec is None:
self.subdev_spec = usrp.pick_tx_subdevice(self.u)
self.subdev = usrp.selected_subdev(self.u, self.subdev_spec)
self.u.set_mux(0xba98)
tr = self.u.tune(self.subdev.which(), self.subdev, self.freq)
if not (tr):
print "Failed to tune to center frequency!"
else:
print "Center frequency"
self.subdev.set_gain(self.subdev.gain_range()[1])
self.subdev.set_enable(True)
if __name__ == '__main__':
test_signal = my_top_block()
try:
test_signal.start()
start_flag = 1
while start_flag == 1:
test_signal.lock()
#print 'should play'
time.sleep(0.01)
test_signal.unlock()
#
#test_signal.wait()
#print 'stopped'
#rdfreq = random.uniform(-40,40)*1e6
rdtime = random.randint(0,2) * 5212
print rdtime
#test_signal.u.set_tx_freq(0,rdfreq)
test_signal.sourcedat.seek(0,gr.SEEK_SET)
except KeyboardInterrupt:
pass
Sorry if the code is long.
In short, the top block just creates a signal, then there is an infinite
while loop in the main that just keeps the signal running.
I need the infinite loop so I can retune the center frequency every time the
program passes through the loop.
I made a null_sink block to check if the problem is within creating the
signal part, and infinite loop never stopped so i assume the top block is
ok.
I also tried with start(), stop(), and wait() in the main loop instead of
lock and unlock, which still caused the unpredicted stop.
I also had other trials, which I forgot about.
There are also consistent underruns, which I am not really worried about, as
long as the underrun does not cause the stop of the program, since I am not
transmitting any meaningful message.
Thanks a lot.
--
View this message in context:
http://old.nabble.com/the-program-stops-unpredictedly-tp32181366p32181366.html
Sent from the GnuRadio mailing list archive at Nabble.com.
- [Discuss-gnuradio] the program stops unpredictedly,
Minhoo Kim <=