Reading Metadata file header from Octave

Did someone write an Octave/matlab code to read the metadata saved using
“File Meta Sink” block in GRC, set in detached mode?

I am using GRC 3.7.1. I obtain an header file 342 byte in size. I am
interested in extract from the file the rx_rate and rx_time.

In the file “file_meta_sink_impl.cc” I read the following, where I don’t
know how bytes are used for METADATA_VERSION data.

  d_header = pmt::make_dict();
  d_header = pmt::dict_add(d_header, pmt::mp("version"),

pmt::mp(METADATA_VERSION));
d_header = pmt::dict_add(d_header, pmt::mp(“rx_rate”),
pmt::mp(samp_rate));
d_header = pmt::dict_add(d_header, pmt::mp(“rx_time”), timestamp);
d_header = pmt::dict_add(d_header, pmt::mp(“size”),
pmt::from_long(d_itemsize));
d_header = pmt::dict_add(d_header, pmt::mp(“type”),
pmt::from_long(type));
d_header = pmt::dict_add(d_header, pmt::mp(“cplx”), complex ?
pmt::PMT_T : pmt::PMT_F);
d_header = pmt::dict_add(d_header, pmt::mp(“strt”),
pmt::from_uint64(METADATA_HEADER_SIZE+d_extra_size));
d_header = pmt::dict_add(d_header, mp(“bytes”),
pmt::from_uint64(0));

Best regards

Piero

I have been able to locate, inside the metadata header file, only the
rx_rate, the rx_freq but not the rx_time couple.

For rx_rate I used the following Octave instructions:

f = fopen (filename, ‘rb’);

dummy=fread(f,50,‘uint8’); % to skip first 50 bytes

rx_rate = fread (f, 1, ‘double’,‘b’) % data are in big-endian order

Any suggestion on how to locate rx_time touple ???

Regards

Piero, I0KPT

Here you can find attached the header file I am trying to read.

Regards

Piero, I0KPT

I finally got the solution.

Here is a function that extracts the data I needed from metadata header
file.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function v = read_header_binary (filename)

f = fopen (filename, ‘rb’);

dummy=fread(f,50,‘uint8’,‘b’); % skip first bytes

rx_rate = fread (f, 1, ‘double’,18,‘b’)
rx_time_a = fread (f, 1, ‘uint64’,1,‘b’) % seconds
rx_time_b = fread (f, 1, ‘double’,69,‘b’) % fraction of seconds
rx_freq = fread (f, 1, ‘double’,‘b’)

fclose (f);

v=[rx_time_a, rx_time_b, rx_rate, rx_freq];

end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Regards

Piero, I0KPT