# HDLC framer

**URL:** <https://www.ruby-forum.com/t/hdlc-framer/234852>\
**Category:** GNU Radio\
**Created:** [December 2, 2014, 10:49am UTC](https://www.ruby-forum.com/t/hdlc-framer/234852 "2014-12-02T10:49:23Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![alcina](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a587f6/32.png) [@alcina](https://www.ruby-forum.com/u/alcina)\
**Post date:** [December 2, 2014, 10:49am UTC](https://www.ruby-forum.com/t/hdlc-framer/234852/1 "2014-12-02T10:49:23Z")

</div>

Hi,  
I read in the documentation that HDLC framer takes in PMT binary blobs  
and outputs HDLC frames as unpacked bits.I don’t undestand what are the  
PMT binary blobs.How can I put in an HDLC frame a “Hello World” message?  
ThanksDaniel

---

<div class="post-metadata">

**Author:** ![danielb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c57346/32.png) [@danielb](https://www.ruby-forum.com/u/danielb)\
**Post date:** [December 3, 2014, 9:55am UTC](https://www.ruby-forum.com/t/hdlc-framer/234852/2 "2014-12-03T09:55:55Z")

</div>

Hi Daniel,

PMT is short for “polymorphic type” [1].  
GNU Radio uses PMTs for stream tags and, more importantly here, for  
asynchronous message ports.  
So the idea is that you have a source of messages[2], sending your  
data to the HDLC framer, which frames it and generates output items.  
If you want some illustrated guide through these concept, I’d  
recommend the new guided tutorials on [gnuradio.org](http://gnuradio.org)[3] numbers 1 through  
5.

Greetings, and happy hacking,  
Marcus

[1] [http://gnuradio.org/doc/doxygen/page\_pmt.html](http://gnuradio.org/doc/doxygen/page_pmt.html)  
[2] [http://gnuradio.org/doc/doxygen/page\_msg\_passing.html](http://gnuradio.org/doc/doxygen/page_msg_passing.html)  
[3] [http://gnuradio.org/redmine/projects/gnuradio/wiki/Guided\_Tutorials](http://gnuradio.org/redmine/projects/gnuradio/wiki/Guided_Tutorials)

---

<div class="post-metadata">

**Author:** ![danielb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c57346/32.png) [@danielb](https://www.ruby-forum.com/u/danielb)\
**Post date:** [December 4, 2014, 11:53am UTC](https://www.ruby-forum.com/t/hdlc-framer/234852/3 "2014-12-04T11:53:22Z")

</div>

Thank you Marcus,  
I try the following:  
MessageStrobe(“Hello World”) ----\> HDCL framer ----\>HDLC deframer ----\>  
Message Debug  
and I get the following error message:thread[thread-per-block[2]: \<block  
hdlc\_framer\_pb (1)\>]: pmt\_car: wrong\_type : Hello World!  
What did I do wrong?  
Daniel

```
 On Wednesday, December 3, 2014 10:55 AM, Marcus Müller 

```

[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

Hi Daniel,

PMT is short for “polymorphic type” [1].  
GNU Radio uses PMTs for stream tags and, more importantly here, for  
asynchronous message ports.  
So the idea is that you have a source of messages[2], sending your  
data to the HDLC framer, which frames it and generates output items.  
If you want some illustrated guide through these concept, I’d  
recommend the new guided tutorials on [gnuradio.org](http://gnuradio.org)[3] numbers 1 through  
5.

Greetings, and happy hacking,  
Marcus

[1] [http://gnuradio.org/doc/doxygen/page\_pmt.html](http://gnuradio.org/doc/doxygen/page_pmt.html)  
[2] [http://gnuradio.org/doc/doxygen/page\_msg\_passing.html](http://gnuradio.org/doc/doxygen/page_msg_passing.html)  
[3] [http://gnuradio.org/redmine/projects/gnuradio/wiki/Guided\_Tutorials](http://gnuradio.org/redmine/projects/gnuradio/wiki/Guided_Tutorials)

---

<div class="post-metadata">

**Author:** ![danielb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c57346/32.png) [@danielb](https://www.ruby-forum.com/u/danielb)\
**Post date:** [December 4, 2014, 6:02pm UTC](https://www.ruby-forum.com/t/hdlc-framer/234852/4 "2014-12-04T18:02:58Z")

</div>

I wrote the HDLC framer to use PMT blobs (specifically, PMT pairs with a  
length field and a blob) because it seemed that was the convention we  
were  
settling upon in GR to handle binary messages. I’m unaware if there was  
any  
formal specification or agreement to this format.

To clarify, the missing feature is just dealing with blobs that aren’t a  
multiple of 8 bits in length. To do so would probably require changing  
the  
length field to represent nbits instead of nbytes, and using a padding  
convention (msbit or lsbit) to determine which bits in the last byte of  
the  
blob should be included.

I haven’t seen too many (len%8) HDLC frames out there so I never got  
down  
to putting that in there. The deframer would also have to be modified,  
specifically crc\_ccitt().

–n

On Thu, Dec 4, 2014 at 8:25 AM, Marcus Müller [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![danielb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c57346/32.png) [@danielb](https://www.ruby-forum.com/u/danielb)\
**Post date:** [December 4, 2014, 5:27pm UTC](https://www.ruby-forum.com/t/hdlc-framer/234852/5 "2014-12-04T17:27:21Z")

</div>

Hi Daniel,  
the HDLC framer can only deal with messages containing PMTs that are  
“blobs”, ie. u8vectors.  
In fact, that’s a missing feature:  
pmt::pmt\_t len(pmt::car(msg)); //TODO for non-mult-8 nbits  
pmt::pmt\_t blob(pmt::cdr(msg));  
if(!pmt::is\_blob(blob))  
throw std::runtime\_error(“HDLC framer: PMT must be blob”);

Instead of making a pmt.intern(“String”), you will need to have a  
u8vector. It’s a bit ugly to generate that in single line:

pmt.pmt\_to\_python.numpy\_to\_uvector(numpy.array([ord© for c in “Hello  
World”], numpy.uint8))

you might need to add an “import block” that does an “import numpy”.

Greetings,  
Marcus

---

<div class="post-metadata">

**Author:** ![danielb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c57346/32.png) [@danielb](https://www.ruby-forum.com/u/danielb)\
**Post date:** [December 5, 2014, 11:15am UTC](https://www.ruby-forum.com/t/hdlc-framer/234852/6 "2014-12-05T11:15:40Z")

</div>

Thank you, Nick, for clarification!  
Yes, I was kind of messing that up.

I’ve done little PMT work – is there a convenient way to “reinterpret”  
the payload of any PMT as u8v/blob?

Greetings,  
Marcus
