# Error when calling method of base class block

**URL:** <https://www.ruby-forum.com/t/error-when-calling-method-of-base-class-block/241823>\
**Category:** GNU Radio\
**Created:** [May 4, 2015, 2:14pm UTC](https://www.ruby-forum.com/t/error-when-calling-method-of-base-class-block/241823 "2015-05-04T14:14:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Detlef\_R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/58f4c7/32.png) [@Detlef\_R](https://www.ruby-forum.com/u/Detlef_R)\
**Post date:** [May 4, 2015, 2:14pm UTC](https://www.ruby-forum.com/t/error-when-calling-method-of-base-class-block/241823/1 "2015-05-04T14:14:46Z")

</div>

Hi all guys,

I am making a file sink block with limited number of elements allowed to  
be  
written in a file. I coded my block in the same way as it was done in  
file\_sink block found in blocks module. Namely, I derived my block from  
file\_sink\_base and gr\_sync\_block, and so on, the rest is copied from the  
existing block and finally the work function is slightly changed.  
Unfortunately I am not able to call methods inherited from  
file\_sink\_base  
class. I believe it is swig issue but don’t know how to make it. The  
error  
that I get when calling close() method inside my test:

# 1: Test timeout computed to be: 9.99988e+06 1: thread[thread-per-block[1]: \<gr\_block file\_sink\_lim\_b (2)\>]: gr\_block\_detail::n\_output\_items 1: thread[thread-per-block[1]: \<gr\_block file\_sink\_lim\_b (5)\>]: gr\_block\_detail::n\_output\_items 1: E 1:

## 1: ERROR: test\_001\_t ( **main**.qa\_file\_sink\_lim\_b) 1:

1: Traceback (most recent call last):  
1: File  
“/home/savi\_ne/work/gnuradio/gr-TPMS/python/qa\_file\_sink\_lim\_b.py”, line  
44, in test\_001\_t  
1: self.dst.close()  
1: AttributeError: ‘file\_sink\_lim\_b\_sptr’ object has no attribute  
‘close’  
1:

I use gnuradio 3.6.5.1 version.

---

<div class="post-metadata">

**Author:** ![Nemanja\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/7bcc69/32.png) [@Nemanja\_S](https://www.ruby-forum.com/u/Nemanja_S)\
**Post date:** [May 4, 2015, 6:42pm UTC](https://www.ruby-forum.com/t/error-when-calling-method-of-base-class-block/241823/2 "2015-05-04T18:42:56Z")

</div>

What do your swig file changes look like?

M

---

<div class="post-metadata">

**Author:** ![Nemanja\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/7bcc69/32.png) [@Nemanja\_S](https://www.ruby-forum.com/u/Nemanja_S)\
**Post date:** [May 5, 2015, 11:30am UTC](https://www.ruby-forum.com/t/error-when-calling-method-of-base-class-block/241823/3 "2015-05-05T11:30:04Z")

</div>

Hello,

well after a lot of digging in the mailing list I added this into my  
swig.i  
file:

%include “gnuradio/blocks/file\_sink\_base.h”

and I also added this into my CMakeLists.txt:

set(GR\_REQUIRED\_COMPONENTS BLOCKS)

It turned out that only first change is required.

Best and hope that this will help somebody in the future.

Nemanja
