# Unpack k bits block with a new created block

**URL:** <https://www.ruby-forum.com/t/unpack-k-bits-block-with-a-new-created-block/242345>\
**Category:** GNU Radio\
**Created:** [June 17, 2015, 5:33am UTC](https://www.ruby-forum.com/t/unpack-k-bits-block-with-a-new-created-block/242345 "2015-06-17T05:33:18Z")\
**Posts on this page:** 4\
**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:** [June 17, 2015, 5:33am UTC](https://www.ruby-forum.com/t/unpack-k-bits-block-with-a-new-created-block/242345/1 "2015-06-17T05:33:18Z")

</div>

HI

I’m using the unpack k bits block (which is located at the output of a  
vector source), before the new block that I’m trying to create. I would  
want  
to save all the bits at the output of the unpacked k bits block, in a  
vector  
(inside the block), so I can manipulate them individually. Is it  
possible? I  
thought each bit at the unpack\_k\_bit block’s output would be one of the  
input\_items in my block, Is this right?  
I tried to do that defining a new integer type vector inside the block  
and  
save there all the input\_items[i] and then use that vector in my code.  
But  
it is giving me this error: invalid conversion from ‘const void\*’ to  
‘int’  
[-fpermissive]

I don’t know if I can do something like this.

Thank you very much.

David

–  
View this message in context:  
[http://gnuradio.4.n7.nabble.com/unpack-k-bits-block-with-a-new-created-block-tp54234.html](http://gnuradio.4.n7.nabble.com/unpack-k-bits-block-with-a-new-created-block-tp54234.html)  
Sent from the GnuRadio mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![dcardona](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a698b9/32.png) [@dcardona](https://www.ruby-forum.com/u/dcardona)\
**Post date:** [June 17, 2015, 9:23am UTC](https://www.ruby-forum.com/t/unpack-k-bits-block-with-a-new-created-block/242345/2 "2015-06-17T09:23:28Z")

</div>

Hey David,

you should be able to store your bits in a vector.  
First of all, unpack\_k\_bits will yield bytes with the LSB carrying the  
actual bit. All the others should be ‘0’.

Next, the error you get points in another direction. One of the  
parameters ‘work’ gets is a vector with void pointers. It’s up to you  
to deal with them correctly. Most block’s work functions start with  
converting those void pointers to the actual data type they’re  
supposed to deal with.  
e.g. const float\* in = (const float\*) input\_items[0];

in your case the compiler complains that you don’t do a conversion to  
int. Be aware that ‘unpack\_k\_bits’ deals with char. Thus casting your  
input buffer to int, will cause some unindented beaviour.

from ‘pack\_k\_bits’  
const unsigned char \*in = (const unsigned char \*)input\_items[0];  
and then do something like  
vec[i] = (int) in[i];  
in a loop.

Cheers  
Johannes

On 17.06.2015 05:09, dcardona wrote:

> and then use that vector in my code. But it is giving me this
> 
> – View this message in context:

[http://gnuradio.4.n7.nabble.com/unpack-k-bits-block-with-a-new-created-block-tp54234.html](http://gnuradio.4.n7.nabble.com/unpack-k-bits-block-with-a-new-created-block-tp54234.html)

> 

Sent from the GnuRadio mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![dcardona](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a698b9/32.png) [@dcardona](https://www.ruby-forum.com/u/dcardona)\
**Post date:** [June 18, 2015, 12:36am UTC](https://www.ruby-forum.com/t/unpack-k-bits-block-with-a-new-created-block/242345/3 "2015-06-18T00:36:00Z")

</div>

Hello Johannes.

Thank you for answering me.  
I did what told me and it didn’t give that error, but when i connect my  
block’s output to a qtgui\_time\_sink, I don’t see anything.

I put the loop you told me below the “// Do \<+signal processing+\>” part,  
Is  
it there or in the constructor?

Thank you very much.

David

–  
View this message in context:  
[http://gnuradio.4.n7.nabble.com/unpack-k-bits-block-with-a-new-created-block-tp54234p54255.html](http://gnuradio.4.n7.nabble.com/unpack-k-bits-block-with-a-new-created-block-tp54234p54255.html)  
Sent from the GnuRadio mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![dcardona](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a698b9/32.png) [@dcardona](https://www.ruby-forum.com/u/dcardona)\
**Post date:** [June 18, 2015, 9:34am UTC](https://www.ruby-forum.com/t/unpack-k-bits-block-with-a-new-created-block/242345/4 "2015-06-18T09:34:36Z")

</div>

-----BEGIN PGP SIGNED MESSAGE-----  
Hash: SHA1

Hey David,

I suggest you read the tutorial [1]. It explains the various parts of  
a block in great detail.

[1] [https://gnuradio.org/redmine/projects/gnuradio/wiki/OutOfTreeModules](https://gnuradio.org/redmine/projects/gnuradio/wiki/OutOfTreeModules)

On 18.06.2015 00:12, dcardona wrote:

> David
> 
> – View this message in context:  
> [http://gnuradio.4.n7.nabble.com/unpack-k-bits-block-with-a-new-created](http://gnuradio.4.n7.nabble.com/unpack-k-bits-block-with-a-new-created)

- -block-tp54234p54255.html

> 

Sent from the GnuRadio mailing list archive at [Nabble.com](http://Nabble.com).

> \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ Discuss-gnuradio  
> mailing list [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [Discuss-gnuradio Info Page](https://lists.gnu.org/mailman/listinfo/discuss-gnuradio)

-----BEGIN PGP SIGNATURE-----  
Version: GnuPG v2.0.22 (GNU/Linux)

iQIcBAEBAgAGBQJVgnQYAAoJEO7fmkDsqywMHxQQALfS8Ancv2h6wr69EbzBV+Up  
dw0ghWNgVpNirfyMD4ijIfi8O+bPtHO/Xf9Dpy7XvkI9poIyhkrHLDCFDyNVTk+a  
KE20ewiH5sIXpJh+mBHxRDFLPIl2UQiy92i5Y0blnpHFv1iff0n/18gkbKHsizny  
WKvkmOAdmeecC6/NmYzG/zuzHDHVaJovaHypvux/AMWmxGhnzh22MugKDQJZSMi2  
XCtX8hJeEtSLzCx/RDfvtzsjLwMXIrMW6p4F+wCttXqorLOij0KY8ntMDFC6H13a  
1nLd6FUH1+7bSnFqy8bb5XiZFmX5StXeDu0WfHGgs8DSlz6g1UTmFdXdylPMwNHv  
2VWoLK03L8p4MYiYkqwP9Z3tDOyMH285MQo7DFywuML1R/RaGB1AangaeXDnx8V2  
L4K1qzU7moJrjsUobIK74LA/pJFpp3WyaSrSFR7mCkN24Uq2xDjauGbm4Ek5j5Jd  
/EKuP0nBjMUyNQhZI0qdnfEd8Q6HEri7mIIyancBSJRbgCllQ2svMnTr6xxesVuF  
uRH+r4A5W0rDK3PDEeWFz+dRmtdWvtMoVLnaRg/S+VwAYsgpClLizXw16p6DLeaP  
HkMZydbTrAc4dF1VnaNxuN4dYuf378CitMfOYsdNY2JgQ08KEDei86y5aykctS28  
w4rOIO1A+UgLQcZM0Evm  
=eBZl  
-----END PGP SIGNATURE-----
