Tuesday, November 14, 2017

[Discuss-gnuradio] Help in adding new block to existing OOT module

/* -*- c++ -*- */
/*
* Copyright 2017 <+YOU OR YOUR COMPANY+>.
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include <gnuradio/io_signature.h>
#include "test_block_cf_impl.h"
#include <volk/volk.h>

namespace gr {
namespace ieee802_11 {

test_block_cf::sptr
test_block_cf::make(size_t vlen)
{
return gnuradio::get_initial_sptr
(new test_block_cf_impl(vlen));
}

/*
* The private constructor
*/
test_block_cf_impl::test_block_cf_impl(size_t vlen)
: gr::sync_block("test_block_cf",
gr::io_signature::make(1, 1, sizeof(gr_complex)*vlen),
gr::io_signature::make(1, 1, sizeof(float)))
{}

/*
* Our virtual destructor.
*/
test_block_cf_impl::~test_block_cf_impl()
{
}

int
test_block_cf_impl::work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
const gr_complex *in = (const gr_complex *) input_items[0];
float *out = (float *) output_items[0];

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

} /* namespace ieee802-11 */
} /* namespace gr */

/* -*- c++ -*- */
/*
* Copyright 2017 <+YOU OR YOUR COMPANY+>.
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/

#ifndef INCLUDED_IEEE802-11_TEST_BLOCK_CF_IMPL_H
#define INCLUDED_IEEE802-11_TEST_BLOCK_CF_IMPL_H

#include <ieee802-11/test_block_cf.h>

namespace gr {
namespace ieee802_11 {

class test_block_cf_impl : public test_block_cf
{
private:
size_t d_vlen;

public:
test_block_cf_impl(size_t vlen);
~test_block_cf_impl();

// Where all the action really happens
int work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items);
};

} // namespace ieee802-11
} // namespace gr

#endif /* INCLUDED_IEEE802-11_TEST_BLOCK_CF_IMPL_H */

/* -*- c++ -*- */
/*
* Copyright 2017 <+YOU OR YOUR COMPANY+>.
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/


#ifndef INCLUDED_IEEE802-11_TEST_BLOCK_CF_H
#define INCLUDED_IEEE802-11_TEST_BLOCK_CF_H

#include <ieee802-11/api.h>
#include <gnuradio/sync_block.h>

namespace gr {
namespace ieee802_11 {

/*!
* \brief <+description of block+>
* \ingroup ieee802-11
*
*/
class IEEE802_11_API test_block_cf : virtual public gr::sync_block
{
public:
typedef boost::shared_ptr<test_block_cf> sptr;

/*!
* \brief Return a shared_ptr to a new instance of ieee802-11::test_block_cf.
*
* To avoid accidental use of raw pointers, ieee802-11::test_block_cf's
* constructor is in a private implementation
* class. ieee802-11::test_block_cf::make is the public interface for
* creating new instances.
*/
static sptr make(size_t vlen);
};

} // namespace ieee802-11
} // namespace gr

#endif /* INCLUDED_IEEE802-11_TEST_BLOCK_CF_H */

Hi,

I went inside the folder 

>> cd gr-ieee-80211

Added a new block test_block_cf to existing module gr-ieee-80211

>> gr_modtool add test_block_cf

It added test_block_cf_impl.cc and test_block_cf_impl.h in /lib and 
test_block_cf.h in /include/ieee802_11

Now I did the usual stuff in my work function, also copied  

test_block_cf.h from /include/ieee802_11 to /prefix/include/ieee802-11/gnuradio/ieee802_11
to make it a public header file. Seems gr_modtool does not want to do this for me. 

I also noticed that by default my namespace was ieee802-11 which is different from ieee802_11 used by the author. Hence I changed ieee802-11 to ieee802_11 in all my files which were generated by gr_modtool. 

Following to this I did following inside build directory of gr-ieee-80211

>> cmake -DENABLE_DOXYGEN=ON -DCMAKE_INSTALL_PREFIX=../ ../
>> make 

Make throws errors as below which is related to inheritance I guess. 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
john@john-Precision-5510:~/radio/default/src/gr-ieee-80211/build$ make
[  2%] Built target ieee802_11_generated_includes
[  4%] Built target ieee802_11_generated_sources
[  6%] Building CXX object lib/CMakeFiles/gnuradio-ieee802_11.dir/test_block_cf_impl.cc.o
In file included from /home/john/radio/default/src/gr-ieee-80211/lib/test_block_cf_impl.cc:26:0:
/home/john/radio/default/src/gr-ieee-80211/lib/test_block_cf_impl.h:21:25: warning: extra tokens at end of #ifndef directive
 #ifndef INCLUDED_IEEE802-11_TEST_BLOCK_CF_IMPL_H
                         ^
/home/john/radio/default/src/gr-ieee-80211/lib/test_block_cf_impl.h:22:25: warning: ISO C++11 requires whitespace after the macro name
 #define INCLUDED_IEEE802-11_TEST_BLOCK_CF_IMPL_H
                         ^
In file included from /home/john/radio/default/src/gr-ieee-80211/lib/test_block_cf_impl.h:24:0,
                 from /home/john/radio/default/src/gr-ieee-80211/lib/test_block_cf_impl.cc:26:
/home/john/radio/default/src/gr-ieee-80211/include/ieee802-11/test_block_cf.h:22:25: warning: extra tokens at end of #ifndef directive
 #ifndef INCLUDED_IEEE802-11_TEST_BLOCK_CF_H
                         ^
In file included from /home/john/radio/default/src/gr-ieee-80211/lib/test_block_cf_impl.cc:26:0:
/home/john/radio/default/src/gr-ieee-80211/lib/test_block_cf_impl.h:30:5: error: expected class-name before '{' token
     {
     ^
/home/john/radio/default/src/gr-ieee-80211/lib/test_block_cf_impl.cc:31:5: error: 'test_block_cf' does not name a type
     test_block_cf::sptr
     ^
/home/john/radio/default/src/gr-ieee-80211/lib/test_block_cf_impl.cc: In constructor 'gr::ieee802_11::test_block_cf_impl::test_block_cf_impl(size_t)':
/home/john/radio/default/src/gr-ieee-80211/lib/test_block_cf_impl.cc:42:23: error: expected class-name before '(' token
       : gr::sync_block("test_block_cf",
                       ^
/home/john/radio/default/src/gr-ieee-80211/lib/test_block_cf_impl.cc:42:23: error: expected '{' before '(' token
/home/john/radio/default/src/gr-ieee-80211/lib/test_block_cf_impl.cc: At global scope:
/home/john/radio/default/src/gr-ieee-80211/lib/test_block_cf_impl.cc:42:24: error: expected unqualified-id before string constant
       : gr::sync_block("test_block_cf",
                        ^
/home/john/radio/default/src/gr-ieee-80211/lib/test_block_cf_impl.cc:42:24: error: expected ')' before string constant
lib/CMakeFiles/gnuradio-ieee802_11.dir/build.make:560: recipe for target 'lib/CMakeFiles/gnuradio-ieee802_11.dir/test_block_cf_impl.cc.o' failed
make[2]: *** [lib/CMakeFiles/gnuradio-ieee802_11.dir/test_block_cf_impl.cc.o] Error 1
CMakeFiles/Makefile2:200: recipe for target 'lib/CMakeFiles/gnuradio-ieee802_11.dir/all' failed
make[1]: *** [lib/CMakeFiles/gnuradio-ieee802_11.dir/all] Error 2
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2
john@john-Precision-5510:~/radio/default/src/gr-ieee-80211/build$ 



No comments:

Post a Comment