# Parsing extra metadata

**URL:** <https://www.ruby-forum.com/t/parsing-extra-metadata/231623>\
**Category:** GNU Radio\
**Created:** [August 19, 2014, 10:15pm UTC](https://www.ruby-forum.com/t/parsing-extra-metadata/231623 "2014-08-19T22:15:01Z")\
**Posts on this page:** 4\
**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:** [August 19, 2014, 10:15pm UTC](https://www.ruby-forum.com/t/parsing-extra-metadata/231623/1 "2014-08-19T22:15:01Z")

</div>

Hello,

I am trying to add some extra information to the standard metadata  
file header.

Following the information posted on  
[http://gnuradio.org/doc/doxygen/page\_metadata.html](http://gnuradio.org/doc/doxygen/page_metadata.html) , I am able to write  
and read the standard metadata. I have attempted to add extra  
metadata with the following lines in my flowgraph:

```
            # add some extra meta data
key = pmt.pmt_intern("dummy")
val = pmt.pmt_from_long(77)
extras = pmt.pmt_make_dict()
extras = pmt.pmt_dict_add(extras, key, val)
extras_str = pmt.pmt_serialize_str(extras)

            nItems = 1024*size
self.blocks_file_meta_sink_0 = 

```

blocks.file\_meta\_sink(gr.sizeof\_float\*1,“./meta\_test.dat”,  
samp\_rate, 1, blocks.GR\_FILE\_FLOAT, False, nItems, extras\_str,  
True)  
self.blocks\_file\_meta\_sink\_0.set\_unbuffered(False)

I think that the writing is going OK, since the length of the header  
increases by a reasonable amount and a Unix hexdump indicates that the  
“dummy” data is present. However, I am stuck when it comes to getting  
at the extra data using the parse\_file\_metadata functions. In  
particular, when I try to read the data using:

```
    cHeader = c[0:185] # character array read from file
pmt_dict = pmt.pmt_deserialize_str(cHeader)
p = parse_file_metadata.parse_header(pmt_dict,False)
p_extra = parse_file_metadata.parse_extra_dict(pmt_dict,info,True)

```

The first parse\_file\_metadata line successfully provides the standard  
metadata, but the second parse\_file\_metadata does not provide the extra  
“dummy” data. I suspect that it has to do with my poor understanding  
of what should go in the info argument.

Any help would be greatly appreciated.

Sincerely,  
Dan Marlow

---

<div class="post-metadata">

**Author:** ![danmcb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/13edae/32.png) [@danmcb](https://www.ruby-forum.com/u/danmcb)\
**Post date:** [August 22, 2014, 12:05am UTC](https://www.ruby-forum.com/t/parsing-extra-metadata/231623/2 "2014-08-22T00:05:00Z")

</div>

On Tue, Aug 19, 2014 at 3:13 PM, Daniel M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> ```
> # add some extra meta data
> 
> ```
> 
> self.blocks\_file\_meta\_sink\_0.set\_unbuffered(False)  
> p\_extra = parse\_file\_metadata.parse\_extra\_dict(pmt\_dict,info,True)

Dan,

What happens when you run gr\_read\_metadata on the file that’s created?  
Does  
that show your extra header info?

Tom

---

<div class="post-metadata">

**Author:** ![danmcb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/13edae/32.png) [@danmcb](https://www.ruby-forum.com/u/danmcb)\
**Post date:** [August 22, 2014, 12:17am UTC](https://www.ruby-forum.com/t/parsing-extra-metadata/231623/3 "2014-08-22T00:17:47Z")

</div>

Hi Tom,

Thanks for looking at this. The answer is “yes,” as can be seen from  
the output below. The rx\_freq field is not something that I added.  
I did add the “dumm” field, however.

Sincerely,  
Dan Marlow

marlow@phy-gr2:~/pulsar/DAQ$ gr\_read\_file\_metadata meta\_test.dat.hdr  
HEADER 0  
Version Number: 0  
Sample Rate: 4000000.00 sps  
Seconds: 0.184295  
Item size: 4  
Data Type: float (5)  
Complex? False  
Header Length: 189 bytes  
Extra Length: 40  
Extra Header? True  
Size of Data: 65536 bytes  
16384 items

Extra Header:  
rx\_freq:  
1.2e+09  
dumm:  
1408561917746092

---

<div class="post-metadata">

**Author:** ![danmcb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/13edae/32.png) [@danmcb](https://www.ruby-forum.com/u/danmcb)\
**Post date:** [August 22, 2014, 1:19am UTC](https://www.ruby-forum.com/t/parsing-extra-metadata/231623/4 "2014-08-22T01:19:53Z")

</div>

On Thu, Aug 21, 2014 at 6:16 PM, Daniel M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> HEADER 0  
> 16384 items
> 
> Extra Header:  
> rx\_freq:  
> 1.2e+09  
> dumm:  
> 1408561917746092

Ok, so that’s good. Looks like the basic concept is working fine, then.  
The  
rx\_freq field is coming from the USRP. The UHD sends tags with  
information  
about the settings, which get stored in the metadata files. If you  
change  
the frequency, it’ll generate another tag for you.

It looks like you should look into the gr\_read\_file\_meatadata app to see  
how it’s using the parse\_metadata. That might clue you into what’s going  
wrong in your project.

Tom
