The program stops unpredictedly

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.

On Tue, Aug 2, 2011 at 4:55 PM, Minhoo K. [email protected] wrote:

Hi all,
I can’t find out why this program stops running.

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.

You don’t need to stop the flow graph when you are just changing
frequency. You only really need to stop it if you are disconnecting
and reconnecting blocks; changing parameters can be done online.

You said it stops running, but I’m not sure how it stops running? Does
it work for a bit and then stop, or does it never produce anything at
all?

Tom

Tom,
Thank you for your help first of all.
I actually need the file_source to be replayed, meaning not just
repeated
over and over, after the frequency is changed. I also have to make sure
that the file_source is played just once for each frequency change.
Would
that still not require a stop?
Also, what do you mean by changing the parameters online? does that
mean
while usrp is running?

It does work for a bit then it stops very unpredictedly, and the time it
keeps working is very inconsistent, like I had a case where it stopped
running after like 20 while loops, and there was also a case that it
kept
running for like 30 seconds.

Thanks for the help.

Tom R. wrote:

while loop in the main that just keeps the signal running.
as


View this message in context:
http://old.nabble.com/the-program-stops-unpredictedly-tp32181366p32186451.html
Sent from the GnuRadio mailing list archive at Nabble.com.

On Wed, Aug 3, 2011 at 9:49 AM, Minhoo K. [email protected] wrote:

Tom,
Thank you for your help first of all.
I actually need the file_source to be replayed, meaning not just repeated
over and over, after the frequency is changed. I also have to make sure
that the file_source is played just once for each frequency change. Would
that still not require a stop?

You can still use the seek function to set the pointer to the
beginning of the file whenever you want.

There is a transient after changing frequencies, though, that you will
have to think about. So just be aware that you should give some time
for the system to settle. In this case, stopping the system might be
the best thing for you to do.

Also, what do you mean by changing the parameters online? does that mean
while usrp is running?

Yes, that’s what I meant. A lot of parameters can be changed without
stopping the flow graph. Mostly, stopping the flow graph is meant for
restructuring the graph, but in your case, you might want to play with
it to avoid the frequency settling issues. Let us know what you find
out.

It does work for a bit then it stops very unpredictedly, and the time it
keeps working is very inconsistent, like I had a case where it stopped
running after like 20 while loops, and there was also a case that it kept
running for like 30 seconds.

That’s odd. Have you found anything more out about this? No reason
that should be happening.

Tom

Hi,

I’m using UCLA ZigBee Phy by thomas schmid:

Now i try to ignore every second entry of the variable d_shift_reg in
the file ucla_ieee802_15_4_packet_sink.cc.

Does anyone have an idea how i could implement something like that?

best regards and thank you for any answers,
Bjorn