How to implement a block derived from gr_block

I created a block from gr_sync_block and later found
that it does not work properly since gr_sync_*
requires that the input and output rate are
synchronous, e.g. having 1:1, 1:N, N:1 fixed ratio.
However, my block has varying input and output rates
which implies I need to derive it from gr_block. My
question is, what is the procedure to convert a block
from gr_sync_block to gr_block? I tried making the
changes, but got errors and ‘make’ time. The main
different I see is: 1) use gr_block instead of
gr_sync_block, 2) use general_work() instead of
work().

Am I missing anything?

Thanks,

George B.
[email protected]

On Tue, Apr 10, 2007 at 12:17:25AM -0700, George B. wrote:

gr_sync_block, 2) use general_work() instead of
work().

Am I missing anything?

Thanks,

George B.
[email protected]

You’ll need: consume_each and forecast.

See http://www.gnu.org/software/gnuradio/doc/howto-write-a-block.html

Eric

Eric,

I get make errors when I converted from gr_sync_block
to gr_block. I also used general_work() instead of
work(). The error has to do something with virtual
and pure in C++. Do you know what is going on or how
I can fix it?

/usr/local/include/gnuradio/gr_block.h:113: warning:
‘virtual int gr_block::general_work(int,
gr_vector_int&, gr_vector_const_void_star&,
gr_vector_void_star&)’ was hidden
mycode_manchester_decode_bb.h:54: warning: by ‘int
mycode_manchester_decode_bb::general_work(int,
gr_vector_const_void_star&, gr_vector_void_star&)’
if /bin/sh …/…/libtool --tag=CXX --mode=compile g++
-DHAVE_CONFIG_H -I. -I. -I…/… -DOMNITHREAD_POSIX=1
-pthread -I/usr/local/include/gnuradio
-I/usr/include/python2.4 -g -O2 -Wall
-Woverloaded-virtual -pthread -MT mycode_slicer_fb.lo
-MD -MP -MF “.deps/mycode_slicer_fb.Tpo” -c -o
mycode_slicer_fb.lo mycode_slicer_fb.cc;
then mv -f “.deps/mycode_slicer_fb.Tpo”
“.deps/mycode_slicer_fb.Plo”; else rm -f
“.deps/mycode_slicer_fb.Tpo”; exit 1; fi
g++ -DHAVE_CONFIG_H -I. -I. -I…/…
-DOMNITHREAD_POSIX=1 -pthread
-I/usr/local/include/gnuradio -I/usr/include/python2.4
-g -O2 -Wall -Woverloaded-virtual -pthread -MT
mycode_slicer_fb.lo -MD -MP -MF
.deps/mycode_slicer_fb.Tpo -c mycode_slicer_fb.cc
-fPIC -DPIC -o .libs/mycode_slicer_fb.o
if /bin/sh …/…/libtool --tag=CXX --mode=compile g++
-DHAVE_CONFIG_H -I. -I. -I…/… -DOMNITHREAD_POSIX=1
-pthread -I/usr/local/include/gnuradio
-I/usr/include/python2.4 -g -O2 -Wall
-Woverloaded-virtual -pthread -MT
mycode_manchester_decode_bb.lo -MD -MP -MF
“.deps/mycode_manchester_decode_bb.Tpo” -c -o
mycode_manchester_decode_bb.lo
mycode_manchester_decode_bb.cc;
then mv -f
“.deps/mycode_manchester_decode_bb.Tpo”
“.deps/mycode_manchester_decode_bb.Plo”; else rm -f
“.deps/mycode_manchester_decode_bb.Tpo”; exit 1; fi
g++ -DHAVE_CONFIG_H -I. -I. -I…/…
-DOMNITHREAD_POSIX=1 -pthread
-I/usr/local/include/gnuradio -I/usr/include/python2.4
-g -O2 -Wall -Woverloaded-virtual -pthread -MT
mycode_manchester_decode_bb.lo -MD -MP -MF
.deps/mycode_manchester_decode_bb.Tpo -c
mycode_manchester_decode_bb.cc -fPIC -DPIC -o
.libs/mycode_manchester_decode_bb.o
/usr/local/include/gnuradio/gr_block.h:113: warning:
‘virtual int gr_block::general_work(int,
gr_vector_int&, gr_vector_const_void_star&,
gr_vector_void_star&)’ was hidden
./mycode_manchester_decode_bb.h:54: warning: by ‘int
mycode_manchester_decode_bb::general_work(int,
gr_vector_const_void_star&, gr_vector_void_star&)’
mycode_manchester_decode_bb.cc: In function
‘mycode_manchester_decode_bb_sptr
mycode_make_manchester_decode_bb()’:
mycode_manchester_decode_bb.cc:13: error: cannot
allocate an object of abstract type
‘mycode_manchester_decode_bb’
./mycode_manchester_decode_bb.h:37: note: because
the following virtual functions are pure within
‘mycode_manchester_decode_bb’:
/usr/local/include/gnuradio/gr_block.h:113: note:
virtual int gr_block::general_work(int,
gr_vector_int&, gr_vector_const_void_star&,
gr_vector_void_star&)
mycode_manchester_decode_bb.cc: In constructor
‘mycode_manchester_decode_bb::mycode_manchester_decode_bb()’:
mycode_manchester_decode_bb.cc:33: warning: unused
variable ‘d_last_bit’
mycode_manchester_decode_bb.cc:34: warning: unused
variable ‘d_get_symbol_now’
mycode_manchester_decode_bb.cc:35: warning: unused
variable ‘d_out_bit’
mycode_manchester_decode_bb.cc:36: warning: unused
variable ‘debug_ctr1’
make[4]: *** [mycode_manchester_decode_bb.lo] Error 1
make[4]: Leaving directory
/home/gbarrinu/gnuradio_dl/gnuradio/gnuradio/gr-mycode/src/lib' make[3]: *** [all] Error 2 make[3]: Leaving directory /home/gbarrinu/gnuradio_dl/gnuradio/gnuradio/gr-mycode/src/lib’
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory
/home/gbarrinu/gnuradio_dl/gnuradio/gnuradio/gr-mycode/src' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory /home/gbarrinu/gnuradio_dl/gnuradio/gnuradio/gr-mycode’
make: *** [all] Error 2
[gbarrinu@localhost gr-mycode]$

Thanks,
— Eric B. [email protected] wrote:

which implies I need to derive it from gr_block.
Am I missing anything?
See

http://www.gnu.org/software/gnuradio/doc/howto-write-a-block.html

Eric

George B.
[email protected]

Eric,

Please disregard my last email. I found the problem.
The work() has 3 arguments passed in and
general_work() has 4 arguments. When I made the
corrections, the ‘make’ worked fine.

Thanks,

— George B. [email protected] wrote:

/usr/local/include/gnuradio/gr_block.h:113: warning:
-I/usr/include/python2.4 -g -O2 -Wall
-I/usr/include/python2.4
mycode_manchester_decode_bb.lo -MD -MP -MF
-I/usr/include/python2.4
'int
‘mycode_manchester_decode_bb’:
/usr/local/include/gnuradio/gr_block.h:113: note:

virtual int gr_block::general_work(int,
gr_vector_int&, gr_vector_const_void_star&,
gr_vector_void_star&)
mycode_manchester_decode_bb.cc: In constructor

‘mycode_manchester_decode_bb::mycode_manchester_decode_bb()’:

make[4]: Leaving directory

`/home/gbarrinu/gnuradio_dl/gnuradio/gnuradio/gr-mycode/src/lib’

make[3]: *** [all] Error 2
make[3]: Leaving directory

`/home/gbarrinu/gnuradio_dl/gnuradio/gnuradio/gr-mycode/src/lib’

make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory

`/home/gbarrinu/gnuradio_dl/gnuradio/gnuradio/gr-mycode/src’

make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory

`/home/gbarrinu/gnuradio_dl/gnuradio/gnuradio/gr-mycode’

that it does not work properly since gr_sync_*
from gr_sync_block to gr_block? I tried making

George B.
[email protected]

You’ll need: consume_each and forecast.

See

http://www.gnu.org/software/gnuradio/doc/howto-write-a-block.html


Discuss-gnuradio mailing list
[email protected]

http://lists.gnu.org/mailman/listinfo/discuss-gnuradio

George B.
[email protected]