# Build C++ processing block that adds a preamble

**URL:** <https://www.ruby-forum.com/t/build-c-processing-block-that-adds-a-preamble/242714>\
**Category:** GNU Radio\
**Created:** [July 20, 2015, 11:00am UTC](https://www.ruby-forum.com/t/build-c-processing-block-that-adds-a-preamble/242714 "2015-07-20T11:00:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![gabri187](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/e9bcb4/32.png) [@gabri187](https://www.ruby-forum.com/u/gabri187)\
**Post date:** [July 20, 2015, 11:00am UTC](https://www.ruby-forum.com/t/build-c-processing-block-that-adds-a-preamble/242714/1 "2015-07-20T11:00:45Z")

</div>

Hello, I am trying to build my own block. The block should operate as  
follows:

- The block receive the sequence of the input stream.
- The block divides the input sequence in blocks of d\_pkt\_len elements,  
a predefined value of packet length (unsigned int d\_pkt\_len), and attach  
to the beginning of the sequence a word of specified length of samples  
(unsigned int d\_sync\_word\_len).
- In this example the word is set to be just 0’s for simplicity.  
d\_pkt\_len and d\_sync\_word\_len are meant to be input parameters in the  
final block.

For instance, if input is (1,1,1,1,1,1) and d\_pkt\_len=6,  
d\_sync\_word\_len=4, the output should be (0,0,0,0,1,1,1,1,1,1).  
If input is (1,1,1,1,1,1) and d\_pkt\_len=3, d\_sync\_word\_len=4, the output  
should be (0,0,0,0,1,1,1,0,0,0,0,1,1,1).

This was a bit confusing for me when it came to code forecast function,  
since, the output number of items really depends on the input and the  
parameter d\_pkt\_len. I used set\_output\_multiple().

The issue is, I built the block, and one of the tests failed. Giving me  
the following error:

> > build$ ctest -V -R  
> > UpdateCTestConfiguration from  
> > :/home/comlab/Desktop/Gabri/mimo/gr-sync/build/DartConfiguration.tcl  
> > UpdateCTestConfiguration from  
> > :/home/comlab/Desktop/Gabri/mimo/gr-sync/build/DartConfiguration.tcl  
> > Test project /home/comlab/Desktop/Gabri/mimo/gr-sync/build  
> > Constructing a list of tests  
> > Done constructing a list of tests  
> > Checking test dependency graph…  
> > Checking test dependency graph end  
> > test 1  
> > Start 1: test\_sync

1: Test command: /bin/sh  
“/home/comlab/Desktop/Gabri/mimo/gr-sync/build/lib/test\_sync\_test.sh”  
1: Test timeout computed to be: 9.99988e+06  
1:  
1:  
1/2 Test #1: test\_sync … Passed 0.00 sec  
test 2  
Start 2: qa\_sync\_ff

# 2: Test command: /bin/sh “/home/comlab/Desktop/Gabri/mimo/gr-sync/build/python/qa\_sync\_ff\_test.sh” 2: Test timeout computed to be: 9.99988e+06 2: thread[thread-per-block[1]: \<block sync\_ff (0)\>]: pmt\_dict\_keys: wrong\_type : # 2: thread[thread-per-block[1]: \<block sync\_ff (1)\>]: pmt\_dict\_keys: wrong\_type : # 2: F 2:

## 2: FAIL: test\_001\_t ( **main**.qa\_sync\_ff) 2:

## 2: Traceback (most recent call last): 2: File “/home/comlab/Desktop/Gabri/mimo/gr-sync/python/qa\_sync\_ff.py”, line 47, in test\_001\_t 2: self.assertFloatTuplesAlmostEqual(expected\_result, result\_data, 6) 2: File “/usr/local/lib/python2.7/dist-packages/gnuradio/gr\_unittest.py”, line 88, in assertFloatTuplesAlmostEqual 2: self.assertEqual (len(a), len(b)) 2: AssertionError: 10 != 0 2: 2:

2: Ran 1 test in 0.264s  
2:  
2: FAILED (failures=1)  
2/2 Test #2: qa\_sync\_ff …\*\*\*Failed 0.43 sec

50% tests passed, 1 tests failed out of 2

Total Test time (real) = 0.43 sec

The following tests FAILED:  
2 - qa\_sync\_ff (Failed)  
Errors while running CTest

I was trying to get some info from this, but I wasn’t able so far. In  
addition I tried to make the xml file just to try it in  
GNURadio-Companion but It gave me error, I guess it has to be with the  
test error. If anyone is able to help me or give me some tip to fix that  
it would be very nice. I have spent so much time in this simple block. I  
attach the sync\_ff\_impl.cc, sync\_ff\_impl.c and qa\_sync\_ff.py files.

Thanks in advance.
