diff options
-rw-r--r-- | gr-digital/include/digital_framer_sink_1.h | 6 | ||||
-rw-r--r-- | gr-digital/lib/digital_framer_sink_1.cc | 40 | ||||
-rw-r--r-- | gr-digital/swig/digital_framer_sink_1.i | 3 |
3 files changed, 48 insertions, 1 deletions
diff --git a/gr-digital/include/digital_framer_sink_1.h b/gr-digital/include/digital_framer_sink_1.h index bb82bf5a7..f1f431af7 100644 --- a/gr-digital/include/digital_framer_sink_1.h +++ b/gr-digital/include/digital_framer_sink_1.h @@ -33,6 +33,9 @@ typedef boost::shared_ptr<digital_framer_sink_1> digital_framer_sink_1_sptr; DIGITAL_API digital_framer_sink_1_sptr digital_make_framer_sink_1(gr_msg_queue_sptr target_queue); +DIGITAL_API digital_framer_sink_1_sptr +digital_make_framer_sink_1(void); + /*! * \brief Given a stream of bits and access_code flags, assemble packets. * \ingroup sink_blk @@ -56,6 +59,9 @@ class DIGITAL_API digital_framer_sink_1 : public gr_sync_block friend DIGITAL_API digital_framer_sink_1_sptr digital_make_framer_sink_1(gr_msg_queue_sptr target_queue); + friend DIGITAL_API digital_framer_sink_1_sptr + digital_make_framer_sink_1(void); + private: enum state_t {STATE_SYNC_SEARCH, STATE_HAVE_SYNC, STATE_HAVE_HEADER}; diff --git a/gr-digital/lib/digital_framer_sink_1.cc b/gr-digital/lib/digital_framer_sink_1.cc index ba1c5bd50..913640114 100644 --- a/gr-digital/lib/digital_framer_sink_1.cc +++ b/gr-digital/lib/digital_framer_sink_1.cc @@ -74,6 +74,11 @@ digital_make_framer_sink_1(gr_msg_queue_sptr target_queue) return gnuradio::get_initial_sptr(new digital_framer_sink_1(target_queue)); } +digital_framer_sink_1_sptr +digital_make_framer_sink_1(void) +{ + return gnuradio::get_initial_sptr(new digital_framer_sink_1(gr_msg_queue_sptr())); +} digital_framer_sink_1::digital_framer_sink_1(gr_msg_queue_sptr target_queue) : gr_sync_block ("framer_sink_1", @@ -81,6 +86,11 @@ digital_framer_sink_1::digital_framer_sink_1(gr_msg_queue_sptr target_queue) gr_make_io_signature (0, 0, 0)), d_target_queue(target_queue) { + if (!d_target_queue) + { + this->output_config(0).reserve_items = 4096; //max pkt frame possible + this->output_config(0).item_size = 1; + } enter_search(); } @@ -135,6 +145,10 @@ digital_framer_sink_1::work (int noutput_items, enter_have_header(payload_len, whitener_offset); if (d_packetlen == 0){ // check for zero-length payload + + if (d_target_queue) + { + // build a zero-length message // NOTE: passing header field as arg1 is not scalable gr_message_sptr msg = @@ -143,6 +157,14 @@ digital_framer_sink_1::work (int noutput_items, d_target_queue->insert_tail(msg); // send it msg.reset(); // free it up + } + else + { + gras::PacketMsg msg; + msg.info = PMC_M(d_packet_whitener_offset); + this->post_output_msg(0, PMC_M(msg)); + } + enter_search(); } } @@ -165,6 +187,9 @@ digital_framer_sink_1::work (int noutput_items, if (d_packetlen_cnt == d_packetlen){ // packet is filled + if (d_target_queue) + { + // build a message // NOTE: passing header field as arg1 is not scalable gr_message_sptr msg = @@ -174,6 +199,17 @@ digital_framer_sink_1::work (int noutput_items, d_target_queue->insert_tail(msg); // send it msg.reset(); // free it up + } + else + { + gras::PacketMsg msg; + msg.info = PMC_M(d_packet_whitener_offset); + msg.buff = this->get_output_buffer(0); + memcpy(msg.buff.get(), d_packet, d_packetlen_cnt); + msg.buff.length = d_packetlen_cnt; + this->post_output_msg(0, PMC_M(msg)); + } + enter_search(); break; } @@ -188,5 +224,7 @@ digital_framer_sink_1::work (int noutput_items, } // while - return noutput_items; + this->consume(0, noutput_items); + return 0; + //return noutput_items; } diff --git a/gr-digital/swig/digital_framer_sink_1.i b/gr-digital/swig/digital_framer_sink_1.i index a5c56560d..b6e1e03b7 100644 --- a/gr-digital/swig/digital_framer_sink_1.i +++ b/gr-digital/swig/digital_framer_sink_1.i @@ -25,6 +25,9 @@ GR_SWIG_BLOCK_MAGIC(digital,framer_sink_1); digital_framer_sink_1_sptr digital_make_framer_sink_1(gr_msg_queue_sptr target_queue); +digital_framer_sink_1_sptr +digital_make_framer_sink_1(void); + class digital_framer_sink_1 : public gr_sync_block { }; |