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
+20 -10
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, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
60, 61, 62, 63}; 60, 61, 62, 63};
qam64.set(cvec(QAM64_D, 64), ivec(qam64_bits, 64)); 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, 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")); pmt::string_to_symbol("ofdm_start"));
if(tags.size()) { 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; pmt::pmt_t tuple = tags[0].value;
int len_data = pmt::to_uint64(pmt::car(tuple)); int len_data = pmt::to_uint64(pmt::car(tuple));
int encoding = pmt::to_uint64(pmt::cdr(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); ofdm = ofdm_param((Encoding)encoding);
tx = tx_param(ofdm, len_data); tx = tx_param(ofdm, len_data);
copied = 0; // sanity check, more than MAX_NUM_SYM may indicate garbage
if(tx.n_sym < MAX_NUM_SYM) {
// this frame is garbage copied = 0;
if(tx.n_sym > 100) { dout << "Decode MAC: frame start -- len " << len_data
// FIXME: make this nicer, this way garbage frames are skipped << " symbols " << tx.n_sym << " encoding "
copied = tx.n_sym + 1; << 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) { 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)); std::memcpy(sym + (copied * 48), in, 48 * sizeof(gr_complex));
copied++; copied++;
@@ -110,6 +117,7 @@ int general_work (int noutput_items, gr_vector_int& ninput_items,
decode(); decode();
in += 48; in += 48;
i++; i++;
d_frame_complete = true;
break; break;
} }
} }
@@ -300,12 +308,14 @@ private:
double deinter[1000 * 48]; double deinter[1000 * 48];
char out_bits[40000]; char out_bits[40000];
char out_bytes[40000]; char out_bytes[40000];
bvec decoded_bits; bvec decoded_bits;
bool d_debug; bool d_debug;
bool d_log; bool d_log;
tx_param tx; tx_param tx;
ofdm_param ofdm; ofdm_param ofdm;
int copied; int copied;
bool d_frame_complete;
Modulator<std::complex<double> > bpsk; Modulator<std::complex<double> > bpsk;
Modulator<std::complex<double> > qpsk; 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 // ############ INSERT MAC STUFF
tx_param tx(d_ofdm, psdu_length); tx_param tx(d_ofdm, psdu_length);
if(tx.n_sym > 120) { if(tx.n_sym > MAX_NUM_SYM) {
std::cout << "packet too large" <<std::endl; std::cout << "packet too large, maximum number of symbols is " << MAX_NUM_SYM << std::endl;
return 0; return 0;
} }
+2
View File
@@ -23,6 +23,8 @@
#include <cinttypes> #include <cinttypes>
#include <iostream> #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 #define dout d_debug && std::cout
#if defined(HAVE_LOG4CPP) && defined(ENABLE_GR_LOG) #if defined(HAVE_LOG4CPP) && defined(ENABLE_GR_LOG)