From 228d1b1bcc2e029dd2fd4ae5c6684a4cf0af763d Mon Sep 17 00:00:00 2001 From: Anton Ottosson Date: Fri, 9 Jul 2021 21:54:38 +0200 Subject: [PATCH] Add beta and csi to decode_mac PDU output. Also changed to using `std::vector` type because it was becoming more and more inconvenient to use c-style arrays. --- lib/decode_mac.cc | 7 ++++++- lib/equalizer/base.cc | 9 ++++----- lib/equalizer/base.h | 2 +- lib/frame_equalizer_impl.cc | 5 ++++- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/lib/decode_mac.cc b/lib/decode_mac.cc index c23ddc2..ad646a7 100644 --- a/lib/decode_mac.cc +++ b/lib/decode_mac.cc @@ -76,7 +76,8 @@ int general_work (int noutput_items, gr_vector_int& ninput_items, d_snr = pmt::to_double(pmt::dict_ref(dict, pmt::mp("snr"), pmt::from_double(0))); d_nom_freq = pmt::to_double(pmt::dict_ref(dict, pmt::mp("freq"), pmt::from_double(0))); d_freq_offset = pmt::to_double(pmt::dict_ref(dict, pmt::mp("freq_offset"), pmt::from_double(0))); - + d_beta = pmt::to_double(pmt::dict_ref(dict, pmt::mp("beta"), pmt::from_double(0))); + d_csi = pmt::c32vector_elements(pmt::dict_ref(dict, pmt::mp("csi"), pmt::make_c32vector(52, 0))); ofdm_param ofdm = ofdm_param((Encoding)encoding); frame_param frame = frame_param(ofdm, len_data); @@ -149,6 +150,8 @@ void decode() { dict = pmt::dict_add(dict, pmt::mp("snr"), pmt::from_double(d_snr)); dict = pmt::dict_add(dict, pmt::mp("nomfreq"), pmt::from_double(d_nom_freq)); dict = pmt::dict_add(dict, pmt::mp("freqofs"), pmt::from_double(d_freq_offset)); + dict = pmt::dict_add(dict, pmt::mp("beta"), pmt::from_double(d_beta)); + dict = pmt::dict_add(dict, pmt::mp("csi"), pmt::init_c32vector(52, d_csi)); dict = pmt::dict_add(dict, pmt::mp("dlt"), pmt::from_long(LINKTYPE_IEEE802_11)); message_port_pub(pmt::mp("out"), pmt::cons(dict, blob)); } @@ -230,6 +233,8 @@ private: double d_snr; // dB double d_nom_freq; // nominal frequency, Hz double d_freq_offset; // frequency offset, Hz + double d_beta; + std::vector d_csi; viterbi_decoder d_decoder; uint8_t d_rx_symbols[48 * MAX_SYM]; diff --git a/lib/equalizer/base.cc b/lib/equalizer/base.cc index 313f7c1..ab1f8cb 100644 --- a/lib/equalizer/base.cc +++ b/lib/equalizer/base.cc @@ -41,15 +41,14 @@ const gr_complex base::POLARITY[127] = { -1,-1,-1,-1,-1, 1,-1, 1, 1,-1, 1,-1, 1, 1, 1,-1, -1, 1,-1,-1,-1, 1, 1, 1,-1,-1,-1,-1,-1,-1,-1 }; -const gr_complex* base::get_csi() { - static gr_complex csi[52]; - int j = 0; +std::vector base::get_csi() { + std::vector csi; + csi.reserve(52); for (int i = 0; i < 64; i++) { if ((i == 32) || (i < 6) || (i > 58)) { continue; } - csi[j] = d_H[i]; - j++; + csi.push_back(d_H[i]); } return csi; } diff --git a/lib/equalizer/base.h b/lib/equalizer/base.h index ae187bb..3e5689a 100644 --- a/lib/equalizer/base.h +++ b/lib/equalizer/base.h @@ -33,7 +33,7 @@ public: static const gr_complex POLARITY[127]; - const gr_complex* get_csi(); + std::vector get_csi(); protected: static const gr_complex LONG[64]; diff --git a/lib/frame_equalizer_impl.cc b/lib/frame_equalizer_impl.cc index fbd91a8..84f6996 100644 --- a/lib/frame_equalizer_impl.cc +++ b/lib/frame_equalizer_impl.cc @@ -218,7 +218,10 @@ frame_equalizer_impl::general_work (int noutput_items, 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)); dict = pmt::dict_add(dict, pmt::mp("beta"), pmt::from_double(beta)); - dict = pmt::dict_add(dict, pmt::mp("csi"), pmt::init_c32vector(52, d_equalizer->get_csi())); + + std::vector csi = d_equalizer->get_csi(); + dict = pmt::dict_add(dict, pmt::mp("csi"), pmt::init_c32vector(csi.size(), csi)); + add_item_tag(0, nitems_written(0) + o, pmt::string_to_symbol("wifi_start"), dict,