# Creation of a block (PSDU 29 octets) using message passing technique

**URL:** <https://www.ruby-forum.com/t/creation-of-a-block-psdu-29-octets-using-message-passing-technique/223018>\
**Category:** GNU Radio\
**Created:** [September 19, 2012, 7:12am UTC](https://www.ruby-forum.com/t/creation-of-a-block-psdu-29-octets-using-message-passing-technique/223018 "2012-09-19T07:12:21Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [September 19, 2012, 7:12am UTC](https://www.ruby-forum.com/t/creation-of-a-block-psdu-29-octets-using-message-passing-technique/223018/1 "2012-09-19T07:12:21Z")

</div>

Hi,

I’m trying to use “message passing” technique in order to create a block  
that generates 29 Octets. Currently, I’m using a block that generates 29  
Octets and then use tag streaming. In the .cc file, IO signature looks  
like:

gr\_sync\_block (“st1\_pktsrc\_dummy\_b”,  
gr\_make\_io\_signature (0, 0, 0),  
gr\_make\_io\_signature (MIN\_OUT, MAX\_OUT, sizeof (unsigned  
char)))

While, the stream tags looks like this:

add\_item\_tag(0, tag\_pos,  
d\_burst\_start\_key,  
pmt\_sob,  
d\_my\_unique\_id)

Now, I want to change this approach to message passing as it is  
explained  
here:  
[Blocks Coding Guide · guruofquality/grextras Wiki · GitHub](https://github.com/guruofquality/grextras/wiki/Blocks-Coding-Guide).  
So, I changed the lines indicated above, for the following:

: gr\_sync\_block (“test\_temporal”,  
gr\_make\_io\_signature(0, 0, 0),  
gr\_make\_io\_signature(0, 0, 0),  
msg\_signature(false, 1))

and I am passing the message as follows:

this-\>post\_msg(0, tag\_pos,  
d\_burst\_start\_key,  
pmt\_sob,  
d\_my\_unique\_id);

However, when I compile my code after these changes, it complains about  
the  
class ‘asrp\_test\_temporal’ does not have any field named block (see the  
errors attached below).  
’  
asrp\_test\_temporal.cc:113:5: error: class ‘asrp\_test\_temporal’ does not  
have any field named ‘block’  
asrp\_test\_temporal.cc:120:42: error: ‘msg\_signature’ was not declared in  
this scope  
asrp\_test\_temporal.cc:120:42: note: suggested alternative:  
/usr/local/include/gnuradio/block.h:58:22: note:  
‘gnuradio::msg\_signature’

So, I would like to ask you:

1. Do I need to use the IO signature for message passing?, because in  
the  
example provide in the  
[Blocks Coding Guide · guruofquality/grextras Wiki · GitHub](https://github.com/guruofquality/grextras/wiki/Blocks-Coding-Guide) only  
uses msg\_signature, but not gr\_make\_io\_signature (0, 0, 0).

I would really appreciate your help, sorry for the punctuation or  
grammar  
mistake, English is my second language. Please let me know if you need  
more  
information, I will be happy to provide it.

Regards,

Jose

---

<div class="post-metadata">

**Author:** ![Jose\_TSDiaz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/848f3c/32.png) [@Jose\_TSDiaz](https://www.ruby-forum.com/u/Jose_TSDiaz)\
**Post date:** [September 19, 2012, 8:04am UTC](https://www.ruby-forum.com/t/creation-of-a-block-psdu-29-octets-using-message-passing-technique/223018/2 "2012-09-19T08:04:56Z")

</div>

On 09/19/2012 01:11 AM, Jose T. Diaz wrote:

> While, the stream tags looks like this:  
> : gr\_sync\_block (“test\_temporal”,  
> gr\_make\_io\_signature(0, 0, 0),  
> gr\_make\_io\_signature(0, 0, 0),  
> msg\_signature(false, 1))

Careful here, check the coding guide,  
you need to #include \<gnuradio/block.h\>  
and inherit from gnuradio::block

-josh

---

<div class="post-metadata">

**Author:** ![Jose\_TSDiaz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/848f3c/32.png) [@Jose\_TSDiaz](https://www.ruby-forum.com/u/Jose_TSDiaz)\
**Post date:** [September 20, 2012, 1:43am UTC](https://www.ruby-forum.com/t/creation-of-a-block-psdu-29-octets-using-message-passing-technique/223018/3 "2012-09-20T01:43:18Z")

</div>

Hi Josh,

I modified in my .h file:

#include \<gnuradio/block.h\>

and also, I inherit from gnu radio as follows:

//\* This uses the preferred technique: subclassing gr\_sync\_block.  
//class asrp\_test\_temporal : public gr\_sync\_block  
class asrp\_test\_temporal : public gnuradio::block // \<–Here, I added  
the inherit  
{  
private:  
// Definition

Then, in the .cc file I wrote:

: gnuradio::block (“test\_temporal”,  
gr\_make\_io\_signature(0, 0, 0),  
gr\_make\_io\_signature(0, 0, 0),  
msg\_signature(false, 1))

When I compile again, the complain is different. It displays:

asrp\_test\_temporal.cc:75:26: error: cannot allocate an object of  
abstract  
type ‘asrp\_test\_temporal’  
./asrp\_test\_temporal.h:99:7: note: because the following virtual  
functions are pure within ‘asrp\_test\_temporal’:  
/usr/local/include/gnuradio/block.h:236:17: note: virtual int  
gnuradio::block::work(const InputItems&, const OutputItems&)  
make[2]: \*\*\* [asrp\_test\_temporal.lo] Error 1

According to the instruction in block coding:  
[Blocks Coding Guide · guruofquality/grextras Wiki · GitHub](https://github.com/guruofquality/grextras/wiki/Blocks-Coding-Guide), I  
only  
need to write the msg\_signature(#input,#output), but I decided to use  
the  
gr\_make\_io\_signature anyway, because I am reading the code for the  
example  
of “socket\_to\_blob.cc”.

1. Do I need to use gr\_make\_io\_signature or just msg\_signature is  
enough?.

Many thanks for your kind help,

Regards,

Jose.

---

<div class="post-metadata">

**Author:** ![Jose\_TSDiaz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/848f3c/32.png) [@Jose\_TSDiaz](https://www.ruby-forum.com/u/Jose_TSDiaz)\
**Post date:** [September 20, 2012, 3:17am UTC](https://www.ruby-forum.com/t/creation-of-a-block-psdu-29-octets-using-message-passing-technique/223018/4 "2012-09-20T03:17:57Z")

</div>

On 09/19/2012 07:42 PM, Jose T. Diaz wrote:

> class asrp\_test\_temporal : public gnuradio::block // \<–Here, I added  
> msg\_signature(false, 1))  
> make[2]: \*\*\* [asrp\_test\_temporal.lo] Error 1

Double check the error, it just wants you to create a work method with  
the given definition. The signature stuff looks just fine.

-josh

---

<div class="post-metadata">

**Author:** ![Jose\_TSDiaz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/848f3c/32.png) [@Jose\_TSDiaz](https://www.ruby-forum.com/u/Jose_TSDiaz)\
**Post date:** [September 20, 2012, 9:29am UTC](https://www.ruby-forum.com/t/creation-of-a-block-psdu-29-octets-using-message-passing-technique/223018/5 "2012-09-20T09:29:36Z")

</div>

Hi Josh,

I checked the code again. I am almost there, at this stage I don’t get  
any  
error using gnuradio::block in my .cc file (see below):

: gnuradio::block (“test\_temporal”,  
gr\_make\_io\_signature (0, 0, 0), //This is a source - no inputs  
gr\_make\_io\_signature(0, 0, 0),  
msg\_signature(false, 1))

and I changed the work function in the following way:

int asrp\_test\_temporal::work (const InputItems &input\_items,  
const OutputItems  
&output\_items)

However, when I compile this block, I am getting some errors with the  
swig  
file, which points out that my defined class has no member named  
‘detail’  
and ‘set\_detail’. The errors is shown below:

asrp\_swig.cc: In function ‘PyObject\*  
\_wrap\_asrp\_test\_temporal\_sptr\_detail(PyObject\*, PyObject\*)’:  
asrp\_swig.cc:8800:25: error: ‘class asrp\_test\_temporal’ has no member  
named  
‘detail’  
asrp\_swig.cc: In function ‘PyObject\*  
\_wrap\_asrp\_test\_temporal\_sptr\_set\_detail(PyObject\*, PyObject\*,  
PyObject\*)’:  
asrp\_swig.cc:8852:16: error: ‘class asrp\_test\_temporal’ has no member  
named  
‘set\_detail’

Do you have any suggestion in this case?.

Best Regards,

Jose.

---

<div class="post-metadata">

**Author:** ![Jose\_TSDiaz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/848f3c/32.png) [@Jose\_TSDiaz](https://www.ruby-forum.com/u/Jose_TSDiaz)\
**Post date:** [September 20, 2012, 9:58am UTC](https://www.ruby-forum.com/t/creation-of-a-block-psdu-29-octets-using-message-passing-technique/223018/6 "2012-09-20T09:58:50Z")

</div>

Hi Josh,

In order to add more information, I checked the the file asrp\_swig.cc,  
which generates the error (line 8800) and I have the following:

SWIGINTERN PyObject \*\_wrap\_asrp\_test\_temporal\_sptr\_detail(PyObject  
\*SWIGUNUSEDPARM(self), PyObject \*args) {  
PyObject \*resultobj = 0;  
boost::shared\_ptr\< asrp\_test\_temporal \> \*arg1 = (boost::shared\_ptr\<  
asrp\_test\_temporal \> \*) 0 ;  
void \*argp1 = 0 ;  
int res1 = 0 ;  
PyObject \* obj0 = 0 ;  
gr\_block\_detail\_sptr result;

if(!PyArg\_UnpackTuple(args,(char  
\*)“asrp\_test\_temporal\_sptr\_detail”,1,1,&obj0)) SWIG\_fail;  
res1 = SWIG\_ConvertPtr(obj0,  
&argp1,SWIGTYPE\_p\_boost\_\_shared\_ptrT\_asrp\_test\_temporal\_t, 0 | 0 );  
if (!SWIG\_IsOK(res1)) {  
SWIG\_exception\_fail(SWIG\_ArgError(res1), “in method '”  
“asrp\_test\_temporal\_sptr\_detail” “', argument " “1"” of type '”  
“boost::shared\_ptr\< asrp\_test\_temporal \> const \*”“'”);  
}  
arg1 = reinterpret\_cast\< boost::shared\_ptr\< asrp\_test\_temporal \> \*

> (argp1);  
> {  
> try {  
> result = (\*arg1)-\>detail();  
> }  
> catch(std::exception &e) {  
> SWIG\_exception(SWIG\_RuntimeError, e.what());  
> }  
> catch(…) {  
> SWIG\_exception(SWIG\_RuntimeError, “Unknown exception”);  
> }

This files has the line “wrap\_asrp\_test\_temporal\_sptr\_detail”. Also,  
inside  
the file block.h there is not “detail” parameter. I was using before in  
my  
block “gr\_sync\_block” and I did not get any error, I think because the  
file  
“gr\_sync\_block.h” does have a “detail” parameter. Is this right?, is  
this  
error due to this “detail” parameter missing?, how can I overcome/solve  
this issue?.

Many thanks for your help,

Jose

On Thu, Sep 20, 2012 at 4:58 PM, Jose T. Diaz  
\<[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![Jose\_TSDiaz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/848f3c/32.png) [@Jose\_TSDiaz](https://www.ruby-forum.com/u/Jose_TSDiaz)\
**Post date:** [September 20, 2012, 10:08pm UTC](https://www.ruby-forum.com/t/creation-of-a-block-psdu-29-octets-using-message-passing-technique/223018/7 "2012-09-20T22:08:10Z")

</div>

On 09/20/2012 03:28 AM, Jose T. Diaz wrote:

> and I changed the work function in the following way:  
> asrp\_swig.cc:8800:25: error: ‘class asrp\_test\_temporal’ has no member named  
> ‘detail’  
> asrp\_swig.cc: In function ‘PyObject\*  
> \_wrap\_asrp\_test\_temporal\_sptr\_set\_detail(PyObject\*, PyObject\*, PyObject\*)’:  
> asrp\_swig.cc:8852:16: error: ‘class asrp\_test\_temporal’ has no member named  
> ‘set\_detail’

Looks like swig is trying to understand the boost shared pointer stuff.  
I usually never see this so you might be missing an include in the .i  
file.

Make sure you have %include\<gnuradio.i\> and %include\<extras\_swig.i\>

-josh

---

<div class="post-metadata">

**Author:** ![Jose\_TSDiaz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/848f3c/32.png) [@Jose\_TSDiaz](https://www.ruby-forum.com/u/Jose_TSDiaz)\
**Post date:** [September 21, 2012, 6:47am UTC](https://www.ruby-forum.com/t/creation-of-a-block-psdu-29-octets-using-message-passing-technique/223018/8 "2012-09-21T06:47:41Z")

</div>

Hi Josh,

I’ve been playing around with this block and indeed it was missing in  
the  
.i file \<extras\_swig.i\>. I included as:

%include “extras\_swig.i” //add on 21 Sept  
%include “extras\_blobs.i” //add on 21 Sept \<-- I added this line  
also

Also, I tried to change other parameters, but the problem still there.  
The  
error is:

asrp\_swig.cc: In function ‘PyObject\*  
\_wrap\_asrp\_test\_temporal\_sptr\_detail(PyObject\*, PyObject\*)’:  
asrp\_swig.cc:8800:25: error: ‘class asrp\_test\_temporal’ has no member  
named  
‘detail’  
asrp\_swig.cc: In function ‘PyObject\*  
\_wrap\_asrp\_test\_temporal\_sptr\_set\_detail(PyObject\*, PyObject\*,  
PyObject\*)’:  
asrp\_swig.cc:8852:16: error: ‘class asrp\_test\_temporal’ has no member  
named  
‘set\_detail’

I thought that I could remove the lines 8800 and 8852 in asrp\_swig.cc  
for  
the variables that is complaining about (detail and set\_detail).  
However,  
it does not compile anymore if I tried this option.

Thanks for your help,

Regards,

Jose.
