# Reading info from pmt\_blob

**URL:** <https://www.ruby-forum.com/t/reading-info-from-pmt-blob/234580>\
**Category:** GNU Radio\
**Created:** [March 14, 2015, 10:30pm UTC](https://www.ruby-forum.com/t/reading-info-from-pmt-blob/234580 "2015-03-14T22:30:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![addis\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c4cdca/32.png) [@addis\_a](https://www.ruby-forum.com/u/addis_a)\
**Post date:** [March 14, 2015, 10:30pm UTC](https://www.ruby-forum.com/t/reading-info-from-pmt-blob/234580/1 "2015-03-14T22:30:47Z")

</div>

Hello all,

I’m new in GNURadio and right now I am understanding a little bit on how  
the pmt work and how can it be read.

For that I’m taking this project as a base:  
[GitHub - bastibl/gr-ieee802-15-4: IEEE 802.15.4 ZigBee Transceiver](https://github.com/bastibl/gr-ieee802-15-4), working on the MAC layer  
(modifying mac.cc and mac.h so far) and from here I want to extract the  
sequence number of a frame that I am receiving from the physical layer.  
When simulating, I see how the frame is created for Tx, as it can be  
read  
clear as an output. Appart from other info, it includes the sequence  
number  
of the frame and that is my main interest right now. However, in the Rx  
part, I dont see it as bytes or as hexadecimal values, as it comes in a  
coding that I’m missing where it comes from and how it is encoded. I  
tried  
something like:

pmt::pmt\_t received\_frame = pmt::make\_blob(pmt::blob\_data(pmt::cdr(msg))  
,  
data\_len )

where msg is what I am receiving. However on the output I see my message  
in  
the payload (not encoded = just as It can be written on the message  
strobe)  
and a long header which I dont understand so far. I dont see a  
similarity  
with the same frame from when it was sent and, therefore, I have not  
managed how to retreive its sequence number.

Any help on how to decode this blob and also how to access to a certain  
part of the frame only (in order to retreive the sequence number) would  
be  
appreciated.

Thanks in advance!  
Nicolás Cuervo

---

<div class="post-metadata">

**Author:** ![budu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/b5e925/32.png) [@budu](https://www.ruby-forum.com/u/budu)\
**Post date:** [March 15, 2015, 8:29am UTC](https://www.ruby-forum.com/t/reading-info-from-pmt-blob/234580/2 "2015-03-15T08:29:37Z")

</div>

Hi,

> On 14 Mar 2015, at 22:29, Nicolas Cuervo B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> wrote:
> 
> Hello all,
> 
> I’m new in GNURadio and right now I am understanding a little bit on how the pmt  
> work and how can it be read.
> 
> For that I’m taking this project as a base:  
> [GitHub - bastibl/gr-ieee802-15-4: IEEE 802.15.4 ZigBee Transceiver · GitHub](https://github.com/bastibl/gr-ieee802-15-4), working on the MAC layer (modifying  
> mac.cc and mac.h so far) and from here I want to extract the sequence number of a  
> frame that I am receiving from the physical layer. When simulating, I see how the  
> frame is created for Tx, as it can be read clear as an output. Appart from other  
> info, it includes the sequence number of the frame and that is my main interest  
> right now. However, in the Rx part, I dont see it as bytes or as hexadecimal  
> values, as it comes in a coding that I’m missing where it comes from and how it is  
> encoded. I tried something like:
> 
> pmt::pmt\_t received\_frame = pmt::make\_blob(pmt::blob\_data(pmt::cdr(msg)) ,  
> data\_len )

this looks like a complicated way to duplicate the blob (i.e. the char  
buffer) in the tuple. Something like this is done in the MAC block to  
extract the data payload from the buffer received from the PHY. The  
headers (9 byte) and the CRC (2 byte) are removed from the blob on the  
data is passed to the app layer.

> <https://github.com/bastibl/gr-ieee802-15-4/blob/maint-3.10/lib/mac.cc#L77>

size\_t data\_len = pmt::blob\_length(blob);  
pmt::pmt\_t mac\_payload = pmt::make\_blob((char\*)pmt::blob\_data(blob) + 9  
, data\_len - 9 - 2);

I think what you want to do is interpreting the blob (i.e. casting it to  
a struct) with something like

struct _mac\_header = (struct mac\_header_)(pmt::blob\_data(blob));

cout \<\< “seq number: “ \<\< mac\_header-\> seq\_number \<\< endl;

Best,  
Bastian
