Hi everyone,

I'm creating a custom header format *'header_format_cognitive*' derived
from *'header_format_default*'. I'm adding extra info to the default
header, very similar to the way the child class *'header_format_counter*'
adds bits/symbol to the default. I'm creating my class as an OOT module
named *'cognitiveSDR'*.

I'm running into what appears to be a common issue, with people previously
creating spin-offs of *packet_header_default*, including gr-ieee-802.11.
https://www.mail-archive.com/discuss-gnuradio@gnu.org/msg50789.html
http://gnuradio.4.n7.nabble.com/Trouble-with-SWIG-for-packet-formatter-default-child-class-td52446.html

I was able to compile, install and import my module in GRC, but once I try
to create the class using a variable with
"cognitiveSDR.header_format_cognitive(..........)", I get the message:



*"Value "cognitiveSDR.header_format_cognitive(..........)" cannot be
evaluated: 'module' object has no attribute 'header_format_cognitive'"*
To give some context, normally when creating a standard header format
object using a GRC variable I call *"digital.header_format_counter(preamble_b,
3, Const_PLD.bits_per_symbol())"*

*Steps taken so far:*
1. Created my new module *cognitiveSDR* with gr_modtool
2. Added *header_format_cognitive* (c++) using gr_modtool as type 'noblock'
3. Fleshed out the .cc and .h files using a combination of
*header_format_counter*, *header_format_crc* and my own functions
4. Made sure to *#include <gnuradio/digital/header_format_default.h>* in
the header file
5. Used *digital::header_format_default* as the parent class in the class
declaration since it's now in separate namespace to 'digital'
6. Modified *set(GR_REQUIRED_COMPONENTS RUNTIME DIGITAL)* in CMakeLists.txt
6. Modified the SWIG file as shown below

Are there any modifications that I should make to the default
CMakeLists.txt file generated for the module or additional changes to the
SWIG file in order to make my class accessible inside GRC? I assume the
parent and child classes are linking up properly since cmake, make and
install succeed.

Thanks for you help! Cheers.
Justin

*cognitiveSDR_swig.i*
*-------------------------------------------------------------------------------------------------------------------*
/* -*- c++ -*- */

#define COGNITIVESDR_API
#define DIGITAL_API

%include "gnuradio.i"            // the common stuff

//load generated python docstrings
%include "cognitiveSDR_swig_doc.i"

%{
#include "cognitiveSDR/header_format_cognitive.h"
%}

%include "gnuradio/digital/header_format_base.h"
%include "gnuradio/digital/header_format_default.h"

%include "cognitiveSDR/header_format_cognitive.h"

%template(header_format_cognitive_sptr)
boost::shared_ptr<gr::cognitiveSDR::header_format_cognitive>;
%pythoncode %{
header_format_cognitive_sptr.__repr__ = lambda self:
"<header_format_cognitive>"
header_format_cognitive = header_format_cognitive .make;
%}
_______________________________________________
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio

Reply via email to