From f2ab263b6fc9c24adc88fb55f2c210dd88e9345a Mon Sep 17 00:00:00 2001 From: Tim O'Shea Date: Sat, 7 Jan 2012 17:52:31 -0500 Subject: Block Modifications: digital.mpsk_receiver_cc: Set reasonable default parameter values for GRC definition digital.ofdm_insert_preamble: Expose enter_preamble() as public, to allow external state changes Cleanup of incorrect forecast behavior Make the flag port optional, incase external preamble triggers are preferred to in-band gr_vector_source: added set_data( data ) and rewind() public methods gr_head: added set_length(int) method to modify head length New Blocks Added: gr_keep_m_in_n: Allows periodic extraction of M items instead of 1 (in keep_1_in_n) gr_pack_k_bits: Complementary block fo gr_unpack_k_bits gr_vector_insert_x: Complement to the gr_head block, inserts a vector into a stream then becomes a pass through --- gr-digital/lib/digital_ofdm_insert_preamble.cc | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'gr-digital/lib/digital_ofdm_insert_preamble.cc') diff --git a/gr-digital/lib/digital_ofdm_insert_preamble.cc b/gr-digital/lib/digital_ofdm_insert_preamble.cc index a46133643..d94425f31 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 > &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, @@ -67,15 +67,21 @@ 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) { - 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 +103,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 +139,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; } -- cgit