convert metadata to dict

This commit is contained in:
Bastian Bloessl
2016-08-31 08:43:00 +02:00
parent bef6e3d962
commit 88e17d6176
2 changed files with 14 additions and 13 deletions
+6 -6
View File
@@ -70,12 +70,12 @@ int general_work (int noutput_items, gr_vector_int& ninput_items,
} }
d_frame_complete = false; d_frame_complete = false;
pmt::pmt_t tuple = tags[0].value; pmt::pmt_t dict = tags[0].value;
int len_data = pmt::to_uint64(pmt::tuple_ref(tuple, 0)); int len_data = pmt::to_uint64(pmt::dict_ref(dict, pmt::mp("frame_bytes"), pmt::from_uint64(MAX_PSDU_SIZE+1)));
int encoding = pmt::to_uint64(pmt::tuple_ref(tuple, 1)); int encoding = pmt::to_uint64(pmt::dict_ref(dict, pmt::mp("encoding"), pmt::from_uint64(0)));
d_snr = pmt::to_double(pmt::tuple_ref(tuple, 2)); d_snr = pmt::to_double(pmt::dict_ref(dict, pmt::mp("snr"), pmt::from_double(0)));
d_nom_freq = pmt::to_double(pmt::tuple_ref(tuple, 3)); d_nom_freq = pmt::to_double(pmt::dict_ref(dict, pmt::mp("freq"), pmt::from_double(0)));
d_freq_offset = pmt::to_double(pmt::tuple_ref(tuple, 4)); d_freq_offset = pmt::to_double(pmt::dict_ref(dict, pmt::mp("freq_offset"), pmt::from_double(0)));
ofdm_param ofdm = ofdm_param((Encoding)encoding); ofdm_param ofdm = ofdm_param((Encoding)encoding);
frame_param frame = frame_param(ofdm, len_data); frame_param frame = frame_param(ofdm, len_data);
+8 -7
View File
@@ -209,15 +209,16 @@ frame_equalizer_impl::general_work (int noutput_items,
if(decode_signal_field(out + o * 48)) { if(decode_signal_field(out + o * 48)) {
// TODO: it would better to use pmt::dict instead of raw list of numbers pmt::pmt_t dict = pmt::make_dict();
dict = pmt::dict_add(dict, pmt::mp("frame_bytes"), pmt::from_uint64(d_frame_bytes));
dict = pmt::dict_add(dict, pmt::mp("encoding"), pmt::from_uint64(d_frame_encoding));
dict = pmt::dict_add(dict, pmt::mp("snr"), pmt::from_double(d_equalizer->get_snr()));
dict = pmt::dict_add(dict, pmt::mp("freq"), pmt::from_double(d_freq));
dict = pmt::dict_add(dict, pmt::mp("freq_offset"), pmt::from_double(d_freq_offset_from_synclong));
add_item_tag(0, nitems_written(0) + o, add_item_tag(0, nitems_written(0) + o,
pmt::string_to_symbol("wifi_start"), pmt::string_to_symbol("wifi_start"),
pmt::make_tuple(pmt::from_uint64(d_frame_bytes), dict,
pmt::from_uint64(d_frame_encoding), pmt::string_to_symbol(alias()));
pmt::from_double(d_equalizer->get_snr()),
pmt::from_double(d_freq), // nominal frequency
pmt::from_double(d_freq_offset_from_synclong)),
pmt::string_to_symbol(name()));
} }
} }