summaryrefslogtreecommitdiff
path: root/gr-digital/lib/digital_ofdm_insert_preamble.cc
diff options
context:
space:
mode:
authorTom Rondeau2012-06-07 16:43:28 -0400
committerTom Rondeau2012-06-07 16:43:28 -0400
commitbfd0dfe00f107e00c0517790247fe723136a4c87 (patch)
treed0d97cf850dd5d157f74b2088e07728c55366b23 /gr-digital/lib/digital_ofdm_insert_preamble.cc
parent4f9556dc48da8d408994cb3aa84c7dfd716b34dc (diff)
parent9dc190127f3cc6f4688feaac514a0b887c531740 (diff)
downloadgnuradio-bfd0dfe00f107e00c0517790247fe723136a4c87.tar.gz
gnuradio-bfd0dfe00f107e00c0517790247fe723136a4c87.tar.bz2
gnuradio-bfd0dfe00f107e00c0517790247fe723136a4c87.zip
Merge branch 'master-mods'
Diffstat (limited to 'gr-digital/lib/digital_ofdm_insert_preamble.cc')
-rw-r--r--gr-digital/lib/digital_ofdm_insert_preamble.cc31
1 files changed, 19 insertions, 12 deletions
diff --git a/gr-digital/lib/digital_ofdm_insert_preamble.cc b/gr-digital/lib/digital_ofdm_insert_preamble.cc
index a46133643..e0449b50b 100644
--- a/gr-digital/lib/digital_ofdm_insert_preamble.cc
+++ b/gr-digital/lib/digital_ofdm_insert_preamble.cc
@@ -41,7 +41,7 @@ digital_ofdm_insert_preamble::digital_ofdm_insert_preamble
(int fft_length,
const std::vector<std::vector<gr_complex> > &preamble)
: gr_block("ofdm_insert_preamble",
- gr_make_io_signature2(2, 2,
+ gr_make_io_signature2(1, 2,
sizeof(gr_complex)*fft_length,
sizeof(char)),
gr_make_io_signature2(1, 2,
@@ -54,8 +54,8 @@ digital_ofdm_insert_preamble::digital_ofdm_insert_preamble
d_pending_flag(0)
{
// sanity check preamble symbols
- for (size_t i = 0; i < d_preamble.size(); i++){
- if (d_preamble[i].size() != (size_t) d_fft_length)
+ for(size_t i = 0; i < d_preamble.size(); i++) {
+ if(d_preamble[i].size() != (size_t) d_fft_length)
throw std::invalid_argument("digital_ofdm_insert_preamble: invalid length for preamble symbol");
}
@@ -67,15 +67,22 @@ digital_ofdm_insert_preamble::~digital_ofdm_insert_preamble()
{
}
+void digital_ofdm_insert_preamble::forecast (int noutput_items, gr_vector_int &ninput_items_required)
+{
+ ninput_items_required[0] = noutput_items;
+}
+
int
-digital_ofdm_insert_preamble::general_work (int noutput_items,
- gr_vector_int &ninput_items_v,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
+digital_ofdm_insert_preamble::general_work(int noutput_items,
+ gr_vector_int &ninput_items_v,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
{
- int ninput_items = std::min(ninput_items_v[0], ninput_items_v[1]);
+ int ninput_items = ninput_items_v.size()==2?std::min(ninput_items_v[0], ninput_items_v[1]):ninput_items_v[0];
const gr_complex *in_sym = (const gr_complex *) input_items[0];
- const unsigned char *in_flag = (const unsigned char *) input_items[1];
+ const unsigned char *in_flag = 0;
+ if (input_items.size() == 2)
+ in_flag = (const unsigned char *) input_items[1];
gr_complex *out_sym = (gr_complex *) output_items[0];
unsigned char *out_flag = 0;
@@ -97,14 +104,14 @@ digital_ofdm_insert_preamble::general_work (int noutput_items,
while (no < noutput_items && ni < ninput_items){
switch(d_state){
case ST_IDLE:
- if (in_flag[ni] & 0x1) // this is first symbol of new payload
+ if (in_flag && in_flag[ni] & 0x1) // this is first symbol of new payload
enter_preamble();
else
ni++; // eat one input symbol
break;
case ST_PREAMBLE:
- assert(in_flag[ni] & 0x1);
+ assert(!in_flag || in_flag[ni] & 0x1);
if (d_nsymbols_output >= (int) d_preamble.size()){
// we've output all the preamble
enter_first_payload();
@@ -133,7 +140,7 @@ digital_ofdm_insert_preamble::general_work (int noutput_items,
break;
case ST_PAYLOAD:
- if (in_flag[ni] & 0x1){ // this is first symbol of a new payload
+ if (in_flag && in_flag[ni] & 0x1){ // this is first symbol of a new payload
enter_preamble();
break;
}