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 = gr.vector_source_f (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!
_______________________________________________
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
http://lists.gnu.org/mailman/listinfo/discuss-gnuradio

Reply via email to