discuss-gnuradio
[Top][All Lists]
Advanced

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

Re: [Discuss-gnuradio] problems with python blocks [attn: jblum]


From: Paul Miller
Subject: Re: [Discuss-gnuradio] problems with python blocks [attn: jblum]
Date: Mon, 12 Dec 2011 20:10:42 -0500
User-agent: Mutt/1.5.21 (2010-09-15)

On Wed, Dec 7, 2011 at 2:03 PM, Josh Blum <address@hidden> wrote:
> I cant say yet as to why, but at least its reproducible.

I spent a few hours source diving today and gdb-stepping.  I
could not figure it out, but I did find that it's broken in every
minor release after 2.0.1 (2.0.2, 3 and 4).

I finally gave up and just left 2.0.1 installed.  Now I can at
least work in my cool block.  But my boring test block still
doesn't work.  It nolonger sagfaults, which is nice, but it seems
to loop forever.  I've been pouring over the docs (such as they
are) and I can't see any obvious reason why it should loop
infinitely like it does.  I noticed none of your QA uses
basic_block.  I'd give up and use sync_block, but I expect you
want to know about these problems.

On the other hand, I still find it rather likely I'm just doing
something wrong.  The verbosity code long cuts are due to the
fact that I've been debugging for a while, but this is what I'm
seeing infinitely loop right now:



class gr_norm(gr.basic_block):
    def __init__(self):
        gr.basic_block.__init__(self, name="normalizer", 
in_sig=[numpy.complex64], out_sig=[numpy.complex64])

    def general_work(self, input_items, output_items):

        # buffer references
        in0 = input_items[0]
        out = output_items[0]

        print "here %d" % len( in0 )

        x = 0
        for i in in0:
            print 'i: %s' % i

            # process data
            mag = math.sqrt( i.real ** 2 + i.imag ** 2 )

            if abs(mag)<0.000001:
                mag=0.000001 # avoid divide by 0

            out[x] = i / mag;
            x = x + 1

        #self.consume_each(len(out))
        self.consume(0, x)

        return x





using this qa... 

    def test_001_gr_norm(self):
        src_data = [ -10, 10, -10j, 10j ]
        expected_result = [ -1, 1, -1j, 1j ]

        src = gr.vector_source_c(src_data, False)
        nor = gr_norm()
        dst = gr.vector_sink_c()

        tb = gr.top_block()
        tb.connect(src, nor)
        tb.connect(nor, dst)
        tb.run()

        result_data = dst.data()

        self.assertFloatTuplesAlmostEqual(expected_result, result_data, 6)


-- 
If riding in an airplane is flying, then riding in a boat is swimming.
116 jumps, 48.6 minutes of freefall, 92.9 freefall miles.




reply via email to

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