discuss-gnuradio
[Top][All Lists]
Advanced

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

[Discuss-gnuradio] output is all 0 in howto_square_ff::general_work()


From: zzw.1012
Subject: [Discuss-gnuradio] output is all 0 in howto_square_ff::general_work()
Date: Sat, 22 May 2010 14:19:38 +0800 (CST)

Hi,
        I am studying how to write a signal processing block , since I find it's a good way to understand the gnuradio's numerous code and I wok well too .
    when I add printf information as followed:
 
    int howto_suquare_ff :: general_work ( int noutput_items,
                                                            gr_vector_int &ninput_items,
                                                            gr_vector_const_void_star &input_items,
                                                            gr_vector_void_star &output_items)
{
    const float *in = (const float *) input_items[0];
    float *out = (float *) output_items[0];

    printf ("noutput_items = %d\n", noutput_items);

    for (int i = 0; i < noutput_items; i++)
    {
        printf ("input_items[%d] = %d\n", i, in[i]);
        out[i] = in[i] * in[i];
        printf ("output_items[%d] = %d\n", i, out[i]);
    }
}
In the file of qa_howto.py:
def test_001_square_ff (self):
        src_data = (-3, 4, -5.5, 2, 3)
        expected_result = (9, 16, 30.25, 4, 9)
        src = "" (src_data)
        sqr = howto.square_ff ()
        dst = gr.vector_sink_f ()
        self.tb.connect (src, sqr)
        self.tb.connect (sqr, dst)
        self.tb.run ()
        #test
        print "============"
        print dst.data()
 
result :noutput_items  = 4
input_items[0] = 0
output_items[0] = 0
input_items[1] = 0
output_items[1] = 0
input_items[2] = 0
output_items[2] = 0
input_items[3] = 0
output_items[3] = 0
==============
(9.0, 16.0, 30.25, 4.0, 9.0)
Question:
Why the  result of input_items[0] is 0 instead of -3 ?
Why the result of output_items[0] is 0 instead of 9.0,while the result is right in qa_howto.py?
There are 5 output: 9.0, 16.0, 30.25, 4.0, 9.0. But, why noutput_items = 4 ?
thanks
best wishes!



网易为中小企业免费提供企业邮箱(自主域名)

reply via email to

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