add variable to define maximum number of symbols and frame complete indication

This commit is contained in:
Andre Puschmann
2015-04-10 11:19:21 +02:00
committed by Bastian Bloessl
parent dbfb65e5ab
commit f374ae415c
3 changed files with 24 additions and 12 deletions
+16 -6
View File
@@ -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);
// sanity check, more than MAX_NUM_SYM may indicate garbage
if(tx.n_sym < MAX_NUM_SYM) {
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;
}
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;
}
}
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;
}
}
@@ -303,9 +311,11 @@ private:
bvec decoded_bits;
bool d_debug;
bool d_log;
tx_param tx;
ofdm_param ofdm;
int copied;
bool d_frame_complete;
Modulator<std::complex<double> > bpsk;
Modulator<std::complex<double> > qpsk;
+2 -2
View File
@@ -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" <<std::endl;
if(tx.n_sym > MAX_NUM_SYM) {
std::cout << "packet too large, maximum number of symbols is " << MAX_NUM_SYM << std::endl;
return 0;
}
+2
View File
@@ -23,6 +23,8 @@
#include <cinttypes>
#include <iostream>
#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)