From f374ae415c7c94f4889535c83c65f0aa770cc221 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Fri, 10 Apr 2015 11:19:21 +0200 Subject: [PATCH] add variable to define maximum number of symbols and frame complete indication --- lib/ofdm_decode_mac.cc | 30 ++++++++++++++++++++---------- lib/ofdm_mapper.cc | 4 ++-- lib/utils.h | 2 ++ 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/lib/ofdm_decode_mac.cc b/lib/ofdm_decode_mac.cc index 8f2a21a..22fb428 100644 --- a/lib/ofdm_decode_mac.cc +++ b/lib/ofdm_decode_mac.cc @@ -61,6 +61,7 @@ ofdm_decode_mac_impl(bool log, bool debug) : block("ofdm_decode_mac", 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63}; qam64.set(cvec(QAM64_D, 64), ivec(qam64_bits, 64)); + d_frame_complete = true; } int general_work (int noutput_items, gr_vector_int& ninput_items, @@ -82,6 +83,12 @@ int general_work (int noutput_items, gr_vector_int& ninput_items, pmt::string_to_symbol("ofdm_start")); if(tags.size()) { + if (d_frame_complete == false) { + dout << "Warning: starting to receive new frame before old frame was complete" << std::endl; + dout << "Already copied " << copied << " out of " << tx.n_sym << " symbols of last frame" << std::endl; + } + d_frame_complete = false; + pmt::pmt_t tuple = tags[0].value; int len_data = pmt::to_uint64(pmt::car(tuple)); int encoding = pmt::to_uint64(pmt::cdr(tuple)); @@ -89,19 +96,19 @@ int general_work (int noutput_items, gr_vector_int& ninput_items, ofdm = ofdm_param((Encoding)encoding); tx = tx_param(ofdm, len_data); - copied = 0; - - // this frame is garbage - if(tx.n_sym > 100) { - // FIXME: make this nicer, this way garbage frames are skipped - copied = tx.n_sym + 1; + // sanity check, more than MAX_NUM_SYM may indicate garbage + if(tx.n_sym < MAX_NUM_SYM) { + copied = 0; + dout << "Decode MAC: frame start -- len " << len_data + << " symbols " << tx.n_sym << " encoding " + << encoding << std::endl; + } else { + dout << "Dropping frame with " << tx.n_sym << " symbols, maximum number of symbols is " << MAX_NUM_SYM << std::endl; } - dout << "Decode MAC: frame start -- len " << len_data - << " symbols " << tx.n_sym << " encoding " - << encoding << std::endl; } if(copied < tx.n_sym) { + dout << "copy one symbol, copied " << copied << " out of " << tx.n_sym << std::endl; std::memcpy(sym + (copied * 48), in, 48 * sizeof(gr_complex)); copied++; @@ -110,6 +117,7 @@ int general_work (int noutput_items, gr_vector_int& ninput_items, decode(); in += 48; i++; + d_frame_complete = true; break; } } @@ -300,12 +308,14 @@ private: double deinter[1000 * 48]; char out_bits[40000]; char out_bytes[40000]; - bvec decoded_bits; + bvec decoded_bits; bool d_debug; bool d_log; + tx_param tx; ofdm_param ofdm; int copied; + bool d_frame_complete; Modulator > bpsk; Modulator > qpsk; diff --git a/lib/ofdm_mapper.cc b/lib/ofdm_mapper.cc index ebf0175..a721086 100644 --- a/lib/ofdm_mapper.cc +++ b/lib/ofdm_mapper.cc @@ -82,8 +82,8 @@ int general_work(int noutput, gr_vector_int& ninput_items, // ############ INSERT MAC STUFF tx_param tx(d_ofdm, psdu_length); - if(tx.n_sym > 120) { - std::cout << "packet too large" < MAX_NUM_SYM) { + std::cout << "packet too large, maximum number of symbols is " << MAX_NUM_SYM << std::endl; return 0; } diff --git a/lib/utils.h b/lib/utils.h index 69269ae..5bd1eb7 100644 --- a/lib/utils.h +++ b/lib/utils.h @@ -23,6 +23,8 @@ #include #include +#define MAX_NUM_SYM 520 // this should be enough to transmit 1500B user payload with BPSK 1/2 + #define dout d_debug && std::cout #if defined(HAVE_LOG4CPP) && defined(ENABLE_GR_LOG)