diff options
author | Tom Rondeau <trondeau@vt.edu> | 2012-08-14 20:07:00 -0400 |
---|---|---|
committer | Tom Rondeau <trondeau@vt.edu> | 2012-08-14 20:07:00 -0400 |
commit | 0298cf616a3635bfda4e8f58eae7b23af901c36b (patch) | |
tree | fb10ec466c21c97e94d5092015dd3f030dd925ce /gr-digital/include | |
parent | 29a019d2761f8001f2c132968c67b060a0ba24bc (diff) |
digital: converted framer blocks to new style.
Diffstat (limited to 'gr-digital/include')
-rw-r--r-- | gr-digital/include/digital/CMakeLists.txt | 10 | ||||
-rw-r--r-- | gr-digital/include/digital/crc32.h (renamed from gr-digital/include/digital_crc32.h) | 44 | ||||
-rw-r--r-- | gr-digital/include/digital/framer_sink_1.h | 65 | ||||
-rw-r--r-- | gr-digital/include/digital/simple_framer.h | 57 | ||||
-rw-r--r-- | gr-digital/include/digital/simple_framer_sync.h | 57 | ||||
-rw-r--r-- | gr-digital/include/digital_framer_sink_1.h | 107 | ||||
-rw-r--r-- | gr-digital/include/digital_simple_framer.h | 66 | ||||
-rw-r--r-- | gr-digital/include/digital_simple_framer_sync.h | 51 |
8 files changed, 209 insertions, 248 deletions
diff --git a/gr-digital/include/digital/CMakeLists.txt b/gr-digital/include/digital/CMakeLists.txt index 83d0dfc557..abb1380a5d 100644 --- a/gr-digital/include/digital/CMakeLists.txt +++ b/gr-digital/include/digital/CMakeLists.txt @@ -76,26 +76,27 @@ add_custom_target(digital_generated_includes DEPENDS install(FILES ${digital_generated_includes} api.h + constellation.h + crc32.h glfsr.h mpsk_snr_est.h + simple_framer_sync.h additive_scrambler_bb.h binary_slicer_fb.h clock_recovery_mm_cc.h clock_recovery_mm_ff.h cma_equalizer_cc.h # cpmmod_bc.h - constellation.h constellation_receiver_cb.h constellation_decoder_cb.h correlate_access_code_bb.h correlate_access_code_tag_bb.h costas_loop_cc.h -# crc32.h descrambler_bb.h diff_decoder_bb.h diff_encoder_bb.h diff_phasor_cc.h -# framer_sink_1.h + framer_sink_1.h fll_band_edge_cc.h glfsr_source_b.h glfsr_source_f.h @@ -119,8 +120,7 @@ install(FILES probe_density_b.h probe_mpsk_snr_est_c.h scrambler_bb.h -# simple_framer.h -# simple_framer_sync.h + simple_framer.h DESTINATION ${GR_INCLUDE_DIR}/gnuradio/digital COMPONENT "digital_devel" ) diff --git a/gr-digital/include/digital_crc32.h b/gr-digital/include/digital/crc32.h index ec4a0df5b0..b84dd6832d 100644 --- a/gr-digital/include/digital_crc32.h +++ b/gr-digital/include/digital/crc32.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2005,2011 Free Software Foundation, Inc. + * Copyright 2005,2011,2012 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -23,29 +23,35 @@ #ifndef INCLUDED_DIGITAL_CRC32_H #define INCLUDED_DIGITAL_CRC32_H -#include <digital_api.h> +#include <digital/api.h> #include <string> #include <gr_types.h> -/*! - * \brief update running CRC-32 - * \ingroup digital - * - * Update a running CRC with the bytes buf[0..len-1] The CRC should be - * initialized to all 1's, and the transmitted value is the 1's - * complement of the final running CRC. The resulting CRC should be - * transmitted in big endian order. - */ -DIGITAL_API unsigned int -digital_update_crc32(unsigned int crc, const unsigned char *buf, size_t len); +namespace gr { + namespace digital { + + /*! + * \brief update running CRC-32 + * \ingroup digital + * + * Update a running CRC with the bytes buf[0..len-1] The CRC + * should be initialized to all 1's, and the transmitted value is + * the 1's complement of the final running CRC. The resulting CRC + * should be transmitted in big endian order. + */ + DIGITAL_API unsigned int + update_crc32(unsigned int crc, const unsigned char *buf, size_t len); + + DIGITAL_API unsigned int + update_crc32(unsigned int crc, const std::string buf); -DIGITAL_API unsigned int -digital_update_crc32(unsigned int crc, const std::string buf); + DIGITAL_API unsigned int + crc32(const unsigned char *buf, size_t len); -DIGITAL_API unsigned int -digital_crc32(const unsigned char *buf, size_t len); + DIGITAL_API unsigned int + crc32(const std::string buf); -DIGITAL_API unsigned int -digital_crc32(const std::string buf); + } /* namespace digital */ +} /* namespace gr */ #endif /* INCLUDED_CRC32_H */ diff --git a/gr-digital/include/digital/framer_sink_1.h b/gr-digital/include/digital/framer_sink_1.h new file mode 100644 index 0000000000..7998238bbb --- /dev/null +++ b/gr-digital/include/digital/framer_sink_1.h @@ -0,0 +1,65 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,2006,2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_GR_FRAMER_SINK_1_H +#define INCLUDED_GR_FRAMER_SINK_1_H + +#include <digital/api.h> +#include <gr_sync_block.h> +#include <gr_msg_queue.h> + +namespace gr { + namespace digital { + + /*! + * \brief Given a stream of bits and access_code flags, assemble packets. + * \ingroup sink_blk + * + * input: stream of bytes from digital_correlate_access_code_bb + * output: none. Pushes assembled packet into target queue + * + * The framer expects a fixed length header of 2 16-bit shorts + * containing the payload length, followed by the payload. If the + * 2 16-bit shorts are not identical, this packet is + * ignored. Better algs are welcome. + * + * The input data consists of bytes that have two bits used. Bit + * 0, the LSB, contains the data bit. Bit 1 if set, indicates that + * the corresponding bit is the the first bit of the packet. That + * is, this bit is the first one after the access code. + */ + class DIGITAL_API framer_sink_1 : virtual public gr_sync_block + { + public: + // gr::digital::framer_sink_1::sptr + typedef boost::shared_ptr<framer_sink_1> sptr; + + /*! + * Make a framer_sink_1 block. + */ + static sptr make(gr_msg_queue_sptr target_queue); + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_FRAMER_SINK_1_H */ diff --git a/gr-digital/include/digital/simple_framer.h b/gr-digital/include/digital/simple_framer.h new file mode 100644 index 0000000000..d388ffb7a9 --- /dev/null +++ b/gr-digital/include/digital/simple_framer.h @@ -0,0 +1,57 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_GR_SIMPLE_FRAMER_H +#define INCLUDED_GR_SIMPLE_FRAMER_H + +#include <digital/api.h> +#include <gr_block.h> + +namespace gr { + namespace digital { + + /*! + * \brief add sync field, seq number and command field to payload + * \ingroup sync_blk + * + * Takes in enough samples to create a full output frame. The + * frame is prepended with the GRSF_SYNC (defind in + * digital_simple_framer_sync.h) and an 8-bit sequence number. + */ + class DIGITAL_API simple_framer : virtual public gr_block + { + public: + // gr::digital::simple_framer::sptr + typedef boost::shared_ptr<simple_framer> sptr; + + /*! + * Make a simple_framer block. + * + * \param payload_bytesize The size of the payload in bytes. + */ + static sptr make(int payload_bytesize); + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_SIMPLE_FRAMER_H */ diff --git a/gr-digital/include/digital/simple_framer_sync.h b/gr-digital/include/digital/simple_framer_sync.h new file mode 100644 index 0000000000..5dd2b82c3c --- /dev/null +++ b/gr-digital/include/digital/simple_framer_sync.h @@ -0,0 +1,57 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2005,2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_GR_SIMPLE_FRAMER_SYNC_H +#define INCLUDED_GR_SIMPLE_FRAMER_SYNC_H + +namespace gr { + namespace digital { + + /*! + * \brief Here are a couple of maximum length sequences + * (m-sequences) that were generated by the the "mseq" + * matlab/octave code downloaded from: <a + * href="http://www.mathworks.com/matlabcentral/fileexchange/990">http://www.mathworks.com/matlabcentral/fileexchange/990</a> + * + * <pre> + * 31-bit m-sequence: + * 0110100100001010111011000111110 + * 0x690AEC76 (padded on right with a zero) + * + * 63-bit m-sequence: + * 101011001101110110100100111000101111001010001100001000001111110 + * 0xACDDA4E2F28C20FC (padded on right with a zero) + * </pre> + */ + + static const unsigned long long GRSF_SYNC = 0xacdda4e2f28c20fcULL; + + static const int GRSF_BITS_PER_BYTE = 8; + static const int GRSF_SYNC_OVERHEAD = sizeof(GRSF_SYNC); + static const int GRSF_PAYLOAD_OVERHEAD = 1; // 1 byte seqno + static const int GRSF_TAIL_PAD = 1; // one byte trailing padding + static const int GRSF_OVERHEAD = GRSF_SYNC_OVERHEAD + GRSF_PAYLOAD_OVERHEAD + GRSF_TAIL_PAD; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_SIMPLE_FRAMER_SYNC_H */ diff --git a/gr-digital/include/digital_framer_sink_1.h b/gr-digital/include/digital_framer_sink_1.h deleted file mode 100644 index 51d872d874..0000000000 --- a/gr-digital/include/digital_framer_sink_1.h +++ /dev/null @@ -1,107 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2006,2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_FRAMER_SINK_1_H -#define INCLUDED_GR_FRAMER_SINK_1_H - -#include <digital_api.h> -#include <gr_sync_block.h> -#include <gr_msg_queue.h> - -class digital_framer_sink_1; -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); - -/*! - * \brief Given a stream of bits and access_code flags, assemble packets. - * \ingroup sink_blk - * - * input: stream of bytes from digital_correlate_access_code_bb - * output: none. Pushes assembled packet into target queue - * - * The framer expects a fixed length header of 2 16-bit shorts - * containing the payload length, followed by the payload. If the - * 2 16-bit shorts are not identical, this packet is ignored. Better - * algs are welcome. - * - * The input data consists of bytes that have two bits used. - * Bit 0, the LSB, contains the data bit. - * Bit 1 if set, indicates that the corresponding bit is the - * the first bit of the packet. That is, this bit is the first - * one after the access code. - */ -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); - - private: - enum state_t {STATE_SYNC_SEARCH, STATE_HAVE_SYNC, STATE_HAVE_HEADER}; - - static const int MAX_PKT_LEN = 4096; - static const int HEADERBITLEN = 32; - - gr_msg_queue_sptr d_target_queue; // where to send the packet when received - state_t d_state; - unsigned int d_header; // header bits - int d_headerbitlen_cnt; // how many so far - - unsigned char d_packet[MAX_PKT_LEN]; // assembled payload - unsigned char d_packet_byte; // byte being assembled - int d_packet_byte_index; // which bit of d_packet_byte we're working on - int d_packetlen; // length of packet - int d_packet_whitener_offset; // offset into whitener string to use - int d_packetlen_cnt; // how many so far - - protected: - digital_framer_sink_1(gr_msg_queue_sptr target_queue); - - void enter_search(); - void enter_have_sync(); - void enter_have_header(int payload_len, int whitener_offset); - - bool header_ok() - { - // confirm that two copies of header info are identical - return ((d_header >> 16) ^ (d_header & 0xffff)) == 0; - } - - void header_payload(int *len, int *offset) - { - // header consists of two 16-bit shorts in network byte order - // payload length is lower 12 bits - // whitener offset is upper 4 bits - *len = (d_header >> 16) & 0x0fff; - *offset = (d_header >> 28) & 0x000f; - } - - public: - ~digital_framer_sink_1(); - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_FRAMER_SINK_1_H */ diff --git a/gr-digital/include/digital_simple_framer.h b/gr-digital/include/digital_simple_framer.h deleted file mode 100644 index b622ae5dd4..0000000000 --- a/gr-digital/include/digital_simple_framer.h +++ /dev/null @@ -1,66 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_SIMPLE_FRAMER_H -#define INCLUDED_GR_SIMPLE_FRAMER_H - -#include <digital_api.h> -#include <gr_block.h> - -class digital_simple_framer; -typedef boost::shared_ptr<digital_simple_framer> digital_simple_framer_sptr; - -DIGITAL_API digital_simple_framer_sptr digital_make_simple_framer(int payload_bytesize); - -/*! - * \brief add sync field, seq number and command field to payload - * \ingroup sync_blk - * - * Takes in enough samples to create a full output frame. The frame is - * prepended with the GRSF_SYNC (defind in - * digital_simple_framer_sync.h) and an 8-bit sequence number. - * - * \param payload_bytesize The size of the payload in bytes. - */ -class DIGITAL_API digital_simple_framer : public gr_block -{ - int d_seqno; - int d_payload_bytesize; - int d_input_block_size; // bytes - int d_output_block_size; // bytes - - friend DIGITAL_API digital_simple_framer_sptr - digital_make_simple_framer(int payload_bytesize); - digital_simple_framer(int payload_bytesize); - - public: - void forecast(int noutput_items, - gr_vector_int &ninput_items_required); - - int general_work(int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - - -#endif /* INCLUDED_GR_SIMPLE_FRAMER_H */ diff --git a/gr-digital/include/digital_simple_framer_sync.h b/gr-digital/include/digital_simple_framer_sync.h deleted file mode 100644 index 4120035827..0000000000 --- a/gr-digital/include/digital_simple_framer_sync.h +++ /dev/null @@ -1,51 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2005,2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_SIMPLE_FRAMER_SYNC_H -#define INCLUDED_GR_SIMPLE_FRAMER_SYNC_H - -/*! - * \brief Here are a couple of maximum length sequences (m-sequences) - * that were generated by the the "mseq" matlab/octave code downloaded - * from: <a href="http://www.mathworks.com/matlabcentral/fileexchange/990">http://www.mathworks.com/matlabcentral/fileexchange/990</a> - * - * <pre> - * 31-bit m-sequence: - * 0110100100001010111011000111110 - * 0x690AEC76 (padded on right with a zero) - * - * 63-bit m-sequence: - * 101011001101110110100100111000101111001010001100001000001111110 - * 0xACDDA4E2F28C20FC (padded on right with a zero) - * </pre> - */ - -static const unsigned long long GRSF_SYNC = 0xacdda4e2f28c20fcULL; - -static const int GRSF_BITS_PER_BYTE = 8; -static const int GRSF_SYNC_OVERHEAD = sizeof(GRSF_SYNC); -static const int GRSF_PAYLOAD_OVERHEAD = 1; // 1 byte seqno -static const int GRSF_TAIL_PAD = 1; // one byte trailing padding -static const int GRSF_OVERHEAD = GRSF_SYNC_OVERHEAD + GRSF_PAYLOAD_OVERHEAD + GRSF_TAIL_PAD; - - -#endif /* INCLUDED_GR_SIMPLE_FRAMER_SYNC_H */ |