discuss-gnuradio
[Top][All Lists]
Advanced

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

Re: [Discuss-gnuradio] cannot make new signal processing block


From: Martin Braun (CEL)
Subject: Re: [Discuss-gnuradio] cannot make new signal processing block
Date: Tue, 16 Oct 2012 13:19:30 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

On Tue, Oct 16, 2012 at 03:14:31AM -0700, nexy_sm wrote:
> Do you mean some kind of tutorial or what?
> 
> Well, that means that my test don't work, since you said that make install
> isn't necesary.
> 
> So, let's start again, what might be a problem?

That's still impossible to tell from what you've written.
I've just checked that gr_modtool and the tutorial are correct.

Here's what I did:

1) Create an out-of-tree module

~/tmp % gr_modtool.py create test
Module directory is "./gr-test".
Creating directory...
Copying howto example...
Unpacking...
Replacing occurences of 'howto' to 'test'... Done.
Use 'gr_modtool add' to add a new block to this currently empty module.

2) Then, I add a sync-block:

~/tmp% cd gr-test
tmp/gr-test % gr_modtool.py add -t sync square_ff
Operating in directory .
GNU Radio module name identified: test
Code is of type: sync
Block/code identifier: square_ff
Enter valid argument list, including default arguments: 
Add Python QA code? [Y/n] 
Add C++ QA code? [Y/n] n
Traversing lib...
Adding file 'square_ff_impl.h'...
Adding file 'square_ff_impl.cc'...
Adding file 'square_ff.h'...
Traversing swig...
Editing swig/test_swig.i...
Traversing python...
Adding file 'qa_square_ff.py'...
Editing python/CMakeLists.txt...
Traversing grc...
Adding file 'test_square_ff.xml'...
Editing grc/CMakeLists.txt...

3) Next, I edit the work() function of the block (this only needs one
line to be changed) to look like this:
Before this is done, the 'make' command won't work!

{
        const float *in = (const float *) input_items[0];
        float *out = (float *) output_items[0];

        for (int i = 0; i < noutput_items; i++) {
                out[i] = in[i] * in[i];
        }

        // Tell runtime system how many output items we produced.
        return noutput_items;
}

4) Finally, I edit the file python/qa_square_ff.py such that the test case 
contains this:
Before this is done, the 'make test' or 'ctest' commands won't work!

    def test_001_t (self):
        test_data = (1, 2, 3, 4)
        correct_res = (1, 4, 9, 16)
        sink = gr.vector_sink_f()
        self.tb.connect(gr.vector_source_f(test_data), test.square_ff(), sink)
        self.tb.run()
        self.assertEqual(sink.data(), correct_res)


Then, I go to the build directory and invoke the make process:

gr-test/build % cmake .. # Output omitted
gr-test/build % make # Output omitted
gr-test/build % make test
Running tests...
Test project /home/braun/tmp/gr-test/build
    Start 1: test_test
1/2 Test #1: test_test ........................   Passed    0.02 sec
    Start 2: qa_square_ff
2/2 Test #2: qa_square_ff .....................   Passed    0.23 sec

100% tests passed, 0 tests failed out of 2



The End.

This entire process took me less than 10 minutes. If you're taking
longer, you're wasting time.

Other notes:
* I never installed
* The only editing necessary was three lines in the work() function and the
  test case in qa_square_ff


So go through your module once again, start from scratch and it will
work.

MB

-- 
Karlsruhe Institute of Technology (KIT)
Communications Engineering Lab (CEL)

Dipl.-Ing. Martin Braun
Research Associate

Kaiserstraße 12
Building 05.01
76131 Karlsruhe

Phone: +49 721 608-43790
Fax: +49 721 608-46071
www.cel.kit.edu

KIT -- University of the State of Baden-Württemberg and
National Laboratory of the Helmholtz Association

Attachment: pgp7RPMXAwUsh.pgp
Description: PGP signature


reply via email to

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