summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt35
-rw-r--r--cmake/Modules/FindLog4cpp.cmake53
-rw-r--r--cmake/Modules/GrMiscUtils.cmake42
-rw-r--r--cmake/Modules/GrVersion.cmake8
-rw-r--r--config.h.in37
-rw-r--r--docs/doxygen/other/extra_pages.dox2
-rw-r--r--docs/doxygen/other/logger.dox205
-rw-r--r--docs/doxygen/other/main_page.dox1
-rw-r--r--gnuradio-core/CMakeLists.txt21
-rw-r--r--gnuradio-core/gnuradio-core.conf14
-rw-r--r--gnuradio-core/gnuradio-core.conf.in31
-rw-r--r--gnuradio-core/gr_log_default.xml64
-rw-r--r--gnuradio-core/src/lib/CMakeLists.txt31
-rw-r--r--gnuradio-core/src/lib/filter/gr_fir_sysconfig_x86.cc24
-rw-r--r--gnuradio-core/src/lib/gengen/gr_vector_sink_X.cc.t11
-rw-r--r--gnuradio-core/src/lib/gengen/gr_vector_sink_X.h.t2
-rw-r--r--gnuradio-core/src/lib/gengen/gr_vector_sink_X.i.t1
-rw-r--r--gnuradio-core/src/lib/gengen/gr_vector_source_X.cc.t67
-rw-r--r--gnuradio-core/src/lib/gengen/gr_vector_source_X.h.t11
-rw-r--r--gnuradio-core/src/lib/gengen/gr_vector_source_X.i.t6
-rw-r--r--gnuradio-core/src/lib/gnuradio-core.rc.in55
-rw-r--r--gnuradio-core/src/lib/io/gr_message_sink.cc70
-rw-r--r--gnuradio-core/src/lib/io/gr_message_sink.h27
-rw-r--r--gnuradio-core/src/lib/io/gr_message_sink.i7
-rw-r--r--gnuradio-core/src/lib/io/gr_message_source.cc45
-rw-r--r--gnuradio-core/src/lib/io/gr_message_source.h12
-rw-r--r--gnuradio-core/src/lib/io/gr_message_source.i4
-rw-r--r--gnuradio-core/src/lib/io/gr_pdu.h13
-rw-r--r--gnuradio-core/src/lib/io/gr_pdu_to_tagged_stream.cc8
-rw-r--r--gnuradio-core/src/lib/io/gr_tagged_stream_to_pdu.cc8
-rw-r--r--gnuradio-core/src/lib/runtime/CMakeLists.txt8
-rw-r--r--gnuradio-core/src/lib/runtime/gr_block.cc49
-rw-r--r--gnuradio-core/src/lib/runtime/gr_block.h6
-rw-r--r--gnuradio-core/src/lib/runtime/gr_logger.cc204
-rw-r--r--gnuradio-core/src/lib/runtime/gr_logger.h564
-rw-r--r--gnuradio-core/src/lib/runtime/gr_logger.i109
-rw-r--r--gnuradio-core/src/lib/runtime/gr_tagged_stream_block.cc144
-rw-r--r--gnuradio-core/src/lib/runtime/gr_tagged_stream_block.h138
-rw-r--r--gnuradio-core/src/lib/runtime/gr_tagged_stream_block.i30
-rw-r--r--gnuradio-core/src/lib/runtime/qa_gr_logger.cc52
-rw-r--r--gnuradio-core/src/lib/runtime/qa_gr_logger.h42
-rw-r--r--gnuradio-core/src/lib/runtime/qa_runtime.cc2
-rw-r--r--gnuradio-core/src/lib/runtime/runtime.i4
-rw-r--r--gnuradio-core/src/lib/swig/CMakeLists.txt12
-rw-r--r--gnuradio-core/src/lib/swig/gnuradio.i5
-rw-r--r--gnuradio-core/src/lib/swig/gnuradio_swig_bug_workaround.h1
-rw-r--r--gnuradio-core/src/python/gnuradio/gr/qa_message_tags.py26
-rw-r--r--gnuradio-core/src/tests/CMakeLists.txt3
-rw-r--r--gr-analog/grc/analog_plateau_detector_fb.xml26
-rw-r--r--gr-analog/include/analog/CMakeLists.txt3
-rw-r--r--gr-analog/include/analog/plateau_detector_fb.h71
-rw-r--r--gr-analog/lib/CMakeLists.txt18
-rw-r--r--gr-analog/lib/gnuradio-analog.rc.in55
-rw-r--r--gr-analog/lib/plateau_detector_fb_impl.cc82
-rw-r--r--gr-analog/lib/plateau_detector_fb_impl.h50
-rw-r--r--gr-analog/python/CMakeLists.txt1
-rwxr-xr-xgr-analog/python/qa_plateau_detector_fb.py46
-rw-r--r--gr-analog/swig/analog_swig.i3
-rw-r--r--gr-atsc/src/lib/CMakeLists.txt20
-rw-r--r--gr-atsc/src/lib/gnuradio-atsc.rc.in55
-rw-r--r--gr-audio/lib/CMakeLists.txt21
-rw-r--r--gr-audio/lib/gnuradio-audio.rc.in55
-rw-r--r--gr-blocks/CMakeLists.txt5
-rw-r--r--gr-blocks/grc/blocks_argmax_xx.xml61
-rw-r--r--gr-blocks/grc/blocks_block_tree.xml64
-rw-r--r--gr-blocks/grc/blocks_burst_tagger.xml87
-rw-r--r--gr-blocks/grc/blocks_copy.xml75
-rw-r--r--gr-blocks/grc/blocks_endian_swap.xml41
-rw-r--r--gr-blocks/grc/blocks_file_descriptor_sink.xml59
-rw-r--r--gr-blocks/grc/blocks_file_descriptor_source.xml73
-rw-r--r--gr-blocks/grc/blocks_file_sink.xml78
-rw-r--r--gr-blocks/grc/blocks_head.xml65
-rw-r--r--gr-blocks/grc/blocks_max_xx.xml58
-rw-r--r--gr-blocks/grc/blocks_message_burst_source.xml58
-rw-r--r--gr-blocks/grc/blocks_message_debug.xml27
-rw-r--r--gr-blocks/grc/blocks_message_sink.xml72
-rw-r--r--gr-blocks/grc/blocks_message_source.xml58
-rw-r--r--gr-blocks/grc/blocks_message_strobe.xml35
-rw-r--r--gr-blocks/grc/blocks_moving_average_xx.xml68
-rw-r--r--gr-blocks/grc/blocks_mute_xx.xml61
-rw-r--r--gr-blocks/grc/blocks_nop.xml68
-rw-r--r--gr-blocks/grc/blocks_null_sink.xml54
-rw-r--r--gr-blocks/grc/blocks_null_source.xml54
-rw-r--r--gr-blocks/grc/blocks_pack_k_bits_bb.xml30
-rw-r--r--gr-blocks/grc/blocks_pdu_to_tagged_stream.xml40
-rw-r--r--gr-blocks/grc/blocks_peak_detector_xb.xml68
-rw-r--r--gr-blocks/grc/blocks_plateau_detector_fb.xml26
-rw-r--r--gr-blocks/grc/blocks_probe_rate.xml66
-rw-r--r--gr-blocks/grc/blocks_probe_signal_vx.xml59
-rw-r--r--gr-blocks/grc/blocks_probe_signal_x.xml51
-rw-r--r--gr-blocks/grc/blocks_repack_bits_bb.xml46
-rw-r--r--gr-blocks/grc/blocks_sample_and_hold_xx.xml49
-rw-r--r--gr-blocks/grc/blocks_skiphead.xml65
-rw-r--r--gr-blocks/grc/blocks_socket_pdu.xml62
-rw-r--r--gr-blocks/grc/blocks_tag_debug.xml82
-rw-r--r--gr-blocks/grc/blocks_tagged_file_sink.xml60
-rw-r--r--gr-blocks/grc/blocks_tagged_stream_mux.xml65
-rw-r--r--gr-blocks/grc/blocks_tagged_stream_to_pdu.xml40
-rw-r--r--gr-blocks/grc/blocks_tuntap_pdu.xml34
-rw-r--r--gr-blocks/grc/blocks_udp_sink.xml77
-rw-r--r--gr-blocks/grc/blocks_udp_source.xml79
-rw-r--r--gr-blocks/grc/blocks_unpack_k_bits_bb.xml25
-rw-r--r--gr-blocks/grc/blocks_vco_f.xml35
-rw-r--r--gr-blocks/grc/blocks_vector_insert_x.xml80
-rw-r--r--gr-blocks/grc/blocks_vector_sink_x.xml54
-rw-r--r--gr-blocks/grc/blocks_vector_source_x.xml85
-rw-r--r--gr-blocks/grc/blocks_wavfile_sink.xml43
-rw-r--r--gr-blocks/grc/blocks_wavfile_source.xml44
-rw-r--r--gr-blocks/include/blocks/CMakeLists.txt60
-rw-r--r--gr-blocks/include/blocks/annotator_1to1.h60
-rw-r--r--gr-blocks/include/blocks/annotator_alltoall.h61
-rw-r--r--gr-blocks/include/blocks/annotator_raw.h57
-rw-r--r--gr-blocks/include/blocks/argmax_XX.h.t60
-rw-r--r--gr-blocks/include/blocks/bin_statistics_f.h76
-rw-r--r--gr-blocks/include/blocks/burst_tagger.h74
-rw-r--r--gr-blocks/include/blocks/check_lfsr_32k_s.h56
-rw-r--r--gr-blocks/include/blocks/control_loop.h233
-rw-r--r--gr-blocks/include/blocks/copy.h54
-rw-r--r--gr-blocks/include/blocks/endian_swap.h50
-rw-r--r--gr-blocks/include/blocks/file_descriptor_sink.h54
-rw-r--r--gr-blocks/include/blocks/file_descriptor_source.h61
-rw-r--r--gr-blocks/include/blocks/file_sink.h55
-rw-r--r--gr-blocks/include/blocks/file_sink_base.h80
-rw-r--r--gr-blocks/include/blocks/head.h55
-rw-r--r--gr-blocks/include/blocks/lfsr_15_1_0.h69
-rw-r--r--gr-blocks/include/blocks/lfsr_32k.h90
-rw-r--r--gr-blocks/include/blocks/lfsr_32k_source_s.h55
-rw-r--r--gr-blocks/include/blocks/max_XX.h.t58
-rw-r--r--gr-blocks/include/blocks/message_burst_source.h52
-rw-r--r--gr-blocks/include/blocks/message_debug.h85
-rw-r--r--gr-blocks/include/blocks/message_sink.h49
-rw-r--r--gr-blocks/include/blocks/message_source.h52
-rw-r--r--gr-blocks/include/blocks/message_strobe.h81
-rw-r--r--gr-blocks/include/blocks/moving_average_XX.h.t84
-rw-r--r--gr-blocks/include/blocks/mute_XX.h.t54
-rw-r--r--gr-blocks/include/blocks/nop.h56
-rw-r--r--gr-blocks/include/blocks/null_sink.h55
-rw-r--r--gr-blocks/include/blocks/null_source.h53
-rw-r--r--gr-blocks/include/blocks/pack_k_bits_bb.h53
-rw-r--r--gr-blocks/include/blocks/pdu.h48
-rw-r--r--gr-blocks/include/blocks/pdu_to_tagged_stream.h53
-rw-r--r--gr-blocks/include/blocks/peak_detector_XX.h.t117
-rw-r--r--gr-blocks/include/blocks/plateau_detector_fb.h71
-rw-r--r--gr-blocks/include/blocks/probe_rate.h60
-rw-r--r--gr-blocks/include/blocks/probe_signal_X.h.t52
-rw-r--r--gr-blocks/include/blocks/probe_signal_vX.h.t53
-rw-r--r--gr-blocks/include/blocks/repack_bits_bb.h65
-rw-r--r--gr-blocks/include/blocks/rotator.h63
-rw-r--r--gr-blocks/include/blocks/sample_and_hold_XX.h.t53
-rw-r--r--gr-blocks/include/blocks/skiphead.h53
-rw-r--r--gr-blocks/include/blocks/socket_pdu.h55
-rw-r--r--gr-blocks/include/blocks/tag_debug.h80
-rw-r--r--gr-blocks/include/blocks/tagged_file_sink.h65
-rw-r--r--gr-blocks/include/blocks/tagged_stream_mux.h61
-rw-r--r--gr-blocks/include/blocks/tagged_stream_to_pdu.h53
-rw-r--r--gr-blocks/include/blocks/tuntap_pdu.h53
-rw-r--r--gr-blocks/include/blocks/udp_sink.h81
-rw-r--r--gr-blocks/include/blocks/udp_source.h84
-rw-r--r--gr-blocks/include/blocks/unpack_k_bits_bb.h52
-rw-r--r--gr-blocks/include/blocks/vco_f.h57
-rw-r--r--gr-blocks/include/blocks/vector_insert_X.h.t54
-rw-r--r--gr-blocks/include/blocks/vector_map.h71
-rw-r--r--gr-blocks/include/blocks/vector_sink_X.h.t54
-rw-r--r--gr-blocks/include/blocks/vector_source_X.h.t56
-rw-r--r--gr-blocks/include/blocks/wavfile.h101
-rw-r--r--gr-blocks/include/blocks/wavfile_sink.h87
-rw-r--r--gr-blocks/include/blocks/wavfile_source.h70
-rw-r--r--gr-blocks/lib/CMakeLists.txt108
-rw-r--r--gr-blocks/lib/ConfigChecks.cmake2
-rw-r--r--gr-blocks/lib/add_XX_impl.h.t1
-rw-r--r--gr-blocks/lib/annotator_1to1_impl.cc113
-rw-r--r--gr-blocks/lib/annotator_1to1_impl.h56
-rw-r--r--gr-blocks/lib/annotator_alltoall_impl.cc117
-rw-r--r--gr-blocks/lib/annotator_alltoall_impl.h56
-rw-r--r--gr-blocks/lib/annotator_raw_impl.cc112
-rw-r--r--gr-blocks/lib/annotator_raw_impl.h54
-rw-r--r--gr-blocks/lib/argmax_XX_impl.cc.t86
-rw-r--r--gr-blocks/lib/argmax_XX_impl.h.t50
-rw-r--r--gr-blocks/lib/bin_statistics_f_impl.cc178
-rw-r--r--gr-blocks/lib/bin_statistics_f_impl.h82
-rw-r--r--gr-blocks/lib/burst_tagger_impl.cc116
-rw-r--r--gr-blocks/lib/burst_tagger_impl.h59
-rw-r--r--gr-blocks/lib/check_lfsr_32k_s_impl.cc179
-rw-r--r--gr-blocks/lib/check_lfsr_32k_s_impl.h94
-rw-r--r--gr-blocks/lib/control_loop.cc214
-rw-r--r--gr-blocks/lib/copy_impl.cc91
-rw-r--r--gr-blocks/lib/copy_impl.h56
-rw-r--r--gr-blocks/lib/endian_swap_impl.cc110
-rw-r--r--gr-blocks/lib/endian_swap_impl.h48
-rw-r--r--gr-blocks/lib/file_descriptor_sink_impl.cc94
-rw-r--r--gr-blocks/lib/file_descriptor_sink_impl.h49
-rw-r--r--gr-blocks/lib/file_descriptor_source_impl.cc156
-rw-r--r--gr-blocks/lib/file_descriptor_source_impl.h58
-rw-r--r--gr-blocks/lib/file_sink_base.cc131
-rw-r--r--gr-blocks/lib/file_sink_impl.cc90
-rw-r--r--gr-blocks/lib/file_sink_impl.h48
-rwxr-xr-xgr-blocks/lib/gen_sine_table.py77
-rw-r--r--gr-blocks/lib/gnuradio-blocks.rc.in54
-rw-r--r--gr-blocks/lib/head_impl.cc75
-rw-r--r--gr-blocks/lib/head_impl.h52
-rw-r--r--gr-blocks/lib/lfsr_32k_source_s_impl.cc79
-rw-r--r--gr-blocks/lib/lfsr_32k_source_s_impl.h52
-rw-r--r--gr-blocks/lib/max_XX_impl.cc.t81
-rw-r--r--gr-blocks/lib/max_XX_impl.h.t50
-rw-r--r--gr-blocks/lib/message_burst_source_impl.cc149
-rw-r--r--gr-blocks/lib/message_burst_source_impl.h58
-rw-r--r--gr-blocks/lib/message_debug_impl.cc120
-rw-r--r--gr-blocks/lib/message_debug_impl.h89
-rw-r--r--gr-blocks/lib/message_sink_impl.cc83
-rw-r--r--gr-blocks/lib/message_sink_impl.h50
-rw-r--r--gr-blocks/lib/message_source_impl.cc127
-rw-r--r--gr-blocks/lib/message_source_impl.h56
-rw-r--r--gr-blocks/lib/message_strobe_impl.cc85
-rw-r--r--gr-blocks/lib/message_strobe_impl.h54
-rw-r--r--gr-blocks/lib/moving_average_XX_impl.cc.t114
-rw-r--r--gr-blocks/lib/moving_average_XX_impl.h.t65
-rw-r--r--gr-blocks/lib/mute_XX_impl.cc.t89
-rw-r--r--gr-blocks/lib/mute_XX_impl.h.t53
-rw-r--r--gr-blocks/lib/nop_impl.cc78
-rw-r--r--gr-blocks/lib/nop_impl.h54
-rw-r--r--gr-blocks/lib/null_sink_impl.cc60
-rw-r--r--gr-blocks/lib/null_sink_impl.h45
-rw-r--r--gr-blocks/lib/null_source_impl.cc63
-rw-r--r--gr-blocks/lib/null_source_impl.h45
-rw-r--r--gr-blocks/lib/pack_k_bits_bb_impl.cc76
-rw-r--r--gr-blocks/lib/pack_k_bits_bb_impl.h48
-rw-r--r--gr-blocks/lib/pdu.cc92
-rw-r--r--gr-blocks/lib/pdu_to_tagged_stream_impl.cc120
-rw-r--r--gr-blocks/lib/pdu_to_tagged_stream_impl.h48
-rw-r--r--gr-blocks/lib/peak_detector_XX_impl.cc.t122
-rw-r--r--gr-blocks/lib/peak_detector_XX_impl.h.t66
-rw-r--r--gr-blocks/lib/plateau_detector_fb_impl.cc83
-rw-r--r--gr-blocks/lib/plateau_detector_fb_impl.h50
-rw-r--r--gr-blocks/lib/probe_rate_impl.cc119
-rw-r--r--gr-blocks/lib/probe_rate_impl.h63
-rw-r--r--gr-blocks/lib/probe_signal_X_impl.cc.t68
-rw-r--r--gr-blocks/lib/probe_signal_X_impl.h.t52
-rw-r--r--gr-blocks/lib/probe_signal_vX_impl.cc.t69
-rw-r--r--gr-blocks/lib/probe_signal_vX_impl.h.t54
-rw-r--r--gr-blocks/lib/qa_block_tags.cc450
-rw-r--r--gr-blocks/lib/qa_block_tags.h50
-rw-r--r--gr-blocks/lib/qa_blocks.cc41
-rw-r--r--gr-blocks/lib/qa_blocks.h38
-rw-r--r--gr-blocks/lib/qa_rotator.cc75
-rw-r--r--gr-blocks/lib/qa_rotator.h39
-rw-r--r--gr-blocks/lib/repack_bits_bb_impl.cc123
-rw-r--r--gr-blocks/lib/repack_bits_bb_impl.h58
-rw-r--r--gr-blocks/lib/sample_and_hold_XX_impl.cc.t73
-rw-r--r--gr-blocks/lib/sample_and_hold_XX_impl.h.t50
-rw-r--r--gr-blocks/lib/sine_table.h1025
-rw-r--r--gr-blocks/lib/skiphead_impl.cc93
-rw-r--r--gr-blocks/lib/skiphead_impl.h50
-rw-r--r--gr-blocks/lib/socket_pdu_impl.cc198
-rw-r--r--gr-blocks/lib/socket_pdu_impl.h69
-rw-r--r--gr-blocks/lib/stream_pdu_base.cc130
-rw-r--r--gr-blocks/lib/stream_pdu_base.h60
-rw-r--r--gr-blocks/lib/tag_debug_impl.cc118
-rw-r--r--gr-blocks/lib/tag_debug_impl.h58
-rw-r--r--gr-blocks/lib/tagged_file_sink_impl.cc235
-rw-r--r--gr-blocks/lib/tagged_file_sink_impl.h61
-rw-r--r--gr-blocks/lib/tagged_stream_mux_impl.cc93
-rw-r--r--gr-blocks/lib/tagged_stream_mux_impl.h54
-rw-r--r--gr-blocks/lib/tagged_stream_to_pdu_impl.cc136
-rw-r--r--gr-blocks/lib/tagged_stream_to_pdu_impl.h58
-rw-r--r--gr-blocks/lib/tcp_connection.cc87
-rw-r--r--gr-blocks/lib/tcp_connection.h61
-rw-r--r--gr-blocks/lib/test_gr_blocks.cc43
-rw-r--r--gr-blocks/lib/tuntap_pdu_impl.cc139
-rw-r--r--gr-blocks/lib/tuntap_pdu_impl.h51
-rw-r--r--gr-blocks/lib/udp_sink_impl.cc148
-rw-r--r--gr-blocks/lib/udp_sink_impl.h65
-rw-r--r--gr-blocks/lib/udp_source_impl.cc215
-rw-r--r--gr-blocks/lib/udp_source_impl.h84
-rw-r--r--gr-blocks/lib/unpack_k_bits_bb_impl.cc77
-rw-r--r--gr-blocks/lib/unpack_k_bits_bb_impl.h48
-rw-r--r--gr-blocks/lib/vco_f_impl.cc68
-rw-r--r--gr-blocks/lib/vco_f_impl.h53
-rw-r--r--gr-blocks/lib/vector_insert_X_impl.cc.t109
-rw-r--r--gr-blocks/lib/vector_insert_X_impl.h.t58
-rw-r--r--gr-blocks/lib/vector_map_impl.cc127
-rw-r--r--gr-blocks/lib/vector_map_impl.h55
-rw-r--r--gr-blocks/lib/vector_sink_X_impl.cc.t83
-rw-r--r--gr-blocks/lib/vector_sink_X_impl.h.t56
-rw-r--r--gr-blocks/lib/vector_source_X_impl.cc.t144
-rw-r--r--gr-blocks/lib/vector_source_X_impl.h.t62
-rw-r--r--gr-blocks/lib/wavfile.cc258
-rw-r--r--gr-blocks/lib/wavfile_sink_impl.cc293
-rw-r--r--gr-blocks/lib/wavfile_sink_impl.h95
-rw-r--r--gr-blocks/lib/wavfile_source_impl.cc174
-rw-r--r--gr-blocks/lib/wavfile_source_impl.h70
-rw-r--r--gr-blocks/python/qa_argmax.py73
-rwxr-xr-xgr-blocks/python/qa_bin_statistics.py227
-rw-r--r--gr-blocks/python/qa_burst_tagger.py59
-rwxr-xr-xgr-blocks/python/qa_copy.py58
-rw-r--r--gr-blocks/python/qa_endian_swap.py66
-rw-r--r--gr-blocks/python/qa_file_source_sink.py93
-rwxr-xr-xgr-blocks/python/qa_head.py47
-rwxr-xr-xgr-blocks/python/qa_max.py65
-rwxr-xr-xgr-blocks/python/qa_message.py149
-rw-r--r--gr-blocks/python/qa_moving_average.py91
-rwxr-xr-xgr-blocks/python/qa_mute.py89
-rw-r--r--gr-blocks/python/qa_null_sink_source.py46
-rwxr-xr-xgr-blocks/python/qa_pack_k_bits.py68
-rwxr-xr-xgr-blocks/python/qa_pdu.py91
-rw-r--r--gr-blocks/python/qa_peak_detector.py98
-rw-r--r--gr-blocks/python/qa_peak_detector2.py1
-rwxr-xr-xgr-blocks/python/qa_plateau_detector_fb.py46
-rw-r--r--gr-blocks/python/qa_probe_signal.py65
-rwxr-xr-xgr-blocks/python/qa_repack_bits_bb.py127
-rw-r--r--gr-blocks/python/qa_sample_and_hold.py54
-rwxr-xr-xgr-blocks/python/qa_skiphead.py103
-rwxr-xr-xgr-blocks/python/qa_tag_debug.py44
-rw-r--r--gr-blocks/python/qa_tag_file_sink.py72
-rwxr-xr-xgr-blocks/python/qa_tagged_stream_mux.py111
-rw-r--r--gr-blocks/python/qa_udp_source_sink.py121
-rwxr-xr-xgr-blocks/python/qa_unpack_k_bits.py57
-rw-r--r--gr-blocks/python/qa_vco.py59
-rwxr-xr-xgr-blocks/python/qa_vector_insert.py59
-rw-r--r--gr-blocks/python/qa_vector_map.py104
-rwxr-xr-xgr-blocks/python/qa_vector_sink_source.py66
-rwxr-xr-xgr-blocks/python/qa_wavfile.py69
-rw-r--r--gr-blocks/python/test_16bit_1chunk.wavbin0 -> 52 bytes
-rw-r--r--gr-blocks/swig/blocks_swig.i263
-rw-r--r--gr-blocks/tests/CMakeLists.txt56
-rw-r--r--gr-blocks/tests/benchmark_nco.cc225
-rw-r--r--gr-blocks/tests/benchmark_vco.cc172
-rw-r--r--gr-blocks/tests/nco_results48
-rw-r--r--gr-comedi/src/CMakeLists.txt4
-rw-r--r--gr-digital/CMakeLists.txt3
-rw-r--r--gr-digital/examples/ofdm/rx_ofdm.grc1092
-rw-r--r--gr-digital/examples/ofdm/tx_ofdm.grc1143
-rw-r--r--gr-digital/grc/CMakeLists.txt4
-rw-r--r--gr-digital/grc/digital_block_tree.xml17
-rw-r--r--gr-digital/grc/digital_crc32_bb.xml33
-rw-r--r--gr-digital/grc/digital_header_payload_demux.xml94
-rw-r--r--gr-digital/grc/digital_ofdm_carrier_allocator_cvc.xml45
-rw-r--r--gr-digital/grc/digital_ofdm_chanest_vcvc.xml61
-rw-r--r--gr-digital/grc/digital_ofdm_cyclic_prefixer.xml20
-rw-r--r--gr-digital/grc/digital_ofdm_frame_equalizer_vcvc.xml45
-rw-r--r--gr-digital/grc/digital_ofdm_mod2.xml65
-rw-r--r--gr-digital/grc/digital_ofdm_serializer_vcc.xml50
-rw-r--r--gr-digital/grc/digital_ofdm_sync_sc_cfb.xml29
-rw-r--r--gr-digital/grc/digital_packet_headergenerator_bb.xml19
-rw-r--r--gr-digital/grc/digital_packet_headergenerator_bb_default.xml26
-rw-r--r--gr-digital/grc/digital_packet_headerparser_b.xml19
-rw-r--r--gr-digital/grc/digital_packet_headerparser_b_default.xml26
-rw-r--r--gr-digital/include/CMakeLists.txt7
-rw-r--r--gr-digital/include/digital/CMakeLists.txt40
-rw-r--r--gr-digital/include/digital/api.h33
-rw-r--r--gr-digital/include/digital/header_payload_demux.h90
-rw-r--r--gr-digital/include/digital/ofdm_frame_equalizer_vcvc.h63
-rw-r--r--gr-digital/include/digital/ofdm_serializer_vcc.h91
-rw-r--r--gr-digital/include/digital/packet_header_default.h101
-rw-r--r--gr-digital/include/digital/packet_header_ofdm.h83
-rw-r--r--gr-digital/include/digital/packet_headergenerator_bb.h57
-rw-r--r--gr-digital/include/digital/packet_headerparser_b.h65
-rw-r--r--gr-digital/include/digital_constellation.h74
-rw-r--r--gr-digital/include/digital_crc32_bb.h67
-rw-r--r--gr-digital/include/digital_ofdm_carrier_allocator_cvc.h116
-rw-r--r--gr-digital/include/digital_ofdm_chanest_vcvc.h133
-rw-r--r--gr-digital/include/digital_ofdm_cyclic_prefixer.h62
-rw-r--r--gr-digital/include/digital_ofdm_equalizer_base.h102
-rw-r--r--gr-digital/include/digital_ofdm_equalizer_simpledfe.h126
-rw-r--r--gr-digital/include/digital_ofdm_equalizer_static.h97
-rw-r--r--gr-digital/include/digital_ofdm_sync_sc_cfb.h79
-rw-r--r--gr-digital/lib/CMakeLists.txt47
-rw-r--r--gr-digital/lib/digital_constellation.cc31
-rw-r--r--gr-digital/lib/digital_crc32_bb.cc102
-rw-r--r--gr-digital/lib/digital_ofdm_carrier_allocator_cvc.cc156
-rw-r--r--gr-digital/lib/digital_ofdm_chanest_vcvc.cc281
-rw-r--r--gr-digital/lib/digital_ofdm_cyclic_prefixer.cc132
-rw-r--r--gr-digital/lib/digital_ofdm_equalizer_base.cc116
-rw-r--r--gr-digital/lib/digital_ofdm_equalizer_simpledfe.cc101
-rw-r--r--gr-digital/lib/digital_ofdm_equalizer_static.cc90
-rw-r--r--gr-digital/lib/digital_ofdm_sync_sc_cfb.cc109
-rw-r--r--gr-digital/lib/gnuradio-digital.rc.in55
-rw-r--r--gr-digital/lib/header_payload_demux_impl.cc292
-rw-r--r--gr-digital/lib/header_payload_demux_impl.h85
-rw-r--r--gr-digital/lib/ofdm_frame_equalizer_vcvc_impl.cc89
-rw-r--r--gr-digital/lib/ofdm_frame_equalizer_vcvc_impl.h57
-rw-r--r--gr-digital/lib/ofdm_serializer_vcc_impl.cc205
-rw-r--r--gr-digital/lib/ofdm_serializer_vcc_impl.h69
-rw-r--r--gr-digital/lib/packet_header_default.cc128
-rw-r--r--gr-digital/lib/packet_header_ofdm.cc115
-rw-r--r--gr-digital/lib/packet_headergenerator_bb_impl.cc90
-rw-r--r--gr-digital/lib/packet_headergenerator_bb_impl.h55
-rw-r--r--gr-digital/lib/packet_headerparser_b_impl.cc90
-rw-r--r--gr-digital/lib/packet_headerparser_b_impl.h48
-rw-r--r--gr-digital/python/CMakeLists.txt9
-rw-r--r--gr-digital/python/__init__.py1
-rw-r--r--gr-digital/python/ofdm_txrx.py268
-rwxr-xr-xgr-digital/python/qa_constellation.py51
-rwxr-xr-xgr-digital/python/qa_constellation_receiver.py50
-rwxr-xr-xgr-digital/python/qa_crc32_bb.py149
-rwxr-xr-xgr-digital/python/qa_header_payload_demux.py78
-rwxr-xr-xgr-digital/python/qa_ofdm_carrier_allocator_cvc.py154
-rwxr-xr-xgr-digital/python/qa_ofdm_chanest_vcvc.py282
-rwxr-xr-xgr-digital/python/qa_ofdm_cyclic_prefixer.py95
-rwxr-xr-xgr-digital/python/qa_ofdm_frame_equalizer_vcvc.py161
-rwxr-xr-xgr-digital/python/qa_ofdm_serializer_vcc.py212
-rwxr-xr-xgr-digital/python/qa_ofdm_sync_sc_cfb.py197
-rwxr-xr-xgr-digital/python/qa_ofdm_txrx.py58
-rwxr-xr-xgr-digital/python/qa_packet_headergenerator_bb.py157
-rwxr-xr-xgr-digital/python/qa_packet_headerparser_b.py71
-rw-r--r--gr-digital/python/qam.py125
-rw-r--r--gr-digital/python/qamlike.py75
-rw-r--r--gr-digital/python/utils/tagged_streams.py112
-rw-r--r--gr-digital/swig/CMakeLists.txt2
-rw-r--r--gr-digital/swig/digital_constellation.i28
-rw-r--r--gr-digital/swig/digital_crc32_bb.i32
-rw-r--r--gr-digital/swig/digital_ofdm_carrier_allocator_cvc.i37
-rw-r--r--gr-digital/swig/digital_ofdm_chanest_vcvc.i40
-rw-r--r--gr-digital/swig/digital_ofdm_cyclic_prefixer.i19
-rw-r--r--gr-digital/swig/digital_ofdm_equalizer_base.i64
-rw-r--r--gr-digital/swig/digital_ofdm_equalizer_simpledfe.i58
-rw-r--r--gr-digital/swig/digital_ofdm_equalizer_static.i55
-rw-r--r--gr-digital/swig/digital_ofdm_sync_sc_cfb.i33
-rw-r--r--gr-digital/swig/digital_swig.i40
-rw-r--r--gr-digital/swig/packet_header.i34
-rw-r--r--gr-fcd/lib/CMakeLists.txt19
-rw-r--r--gr-fcd/lib/gnuradio-fcd.rc.in55
-rw-r--r--gr-fft/lib/CMakeLists.txt16
-rw-r--r--gr-fft/lib/gnuradio-fft.rc.in55
-rw-r--r--gr-filter/grc/pfb_arb_resampler.xml3
-rw-r--r--gr-filter/lib/CMakeLists.txt22
-rw-r--r--gr-filter/lib/gnuradio-filter.rc.in55
-rw-r--r--gr-howto-write-a-block/CMakeLists.txt6
-rw-r--r--gr-howto-write-a-block/cmake/Modules/FindLog4cpp.cmake58
-rw-r--r--gr-howto-write-a-block/cmake/Modules/GrMiscUtils.cmake43
-rw-r--r--gr-howto-write-a-block/lib/CMakeLists.txt6
-rw-r--r--gr-noaa/lib/CMakeLists.txt20
-rw-r--r--gr-noaa/lib/gnuradio-noaa.rc.in55
-rw-r--r--gr-pager/lib/CMakeLists.txt20
-rw-r--r--gr-pager/lib/gnuradio-pager.rc.in55
-rw-r--r--gr-qtgui/lib/CMakeLists.txt17
-rw-r--r--gr-qtgui/lib/gnuradio-qtgui.rc.in55
-rw-r--r--gr-shd/lib/CMakeLists.txt20
-rw-r--r--gr-shd/lib/gnuradio-shd.rc.in55
-rw-r--r--gr-trellis/src/lib/CMakeLists.txt20
-rw-r--r--gr-trellis/src/lib/gnuradio-trellis.rc.in55
-rw-r--r--gr-uhd/lib/CMakeLists.txt20
-rw-r--r--gr-uhd/lib/gnuradio-uhd.rc.in55
-rw-r--r--gr-utils/src/python/modtool/code_generator.py1
-rw-r--r--gr-utils/src/python/modtool/modtool_add.py4
-rw-r--r--gr-utils/src/python/modtool/templates.py71
-rw-r--r--gr-video-sdl/src/CMakeLists.txt18
-rw-r--r--gr-video-sdl/src/gnuradio-video-sdl.rc.in55
-rw-r--r--gr-vocoder/lib/CMakeLists.txt18
-rw-r--r--gr-vocoder/lib/gnuradio-vocoder.rc.in33
-rw-r--r--gr-wavelet/lib/CMakeLists.txt18
-rw-r--r--gr-wavelet/lib/gnuradio-wavelet.rc.in33
-rw-r--r--gr-wxgui/src/python/fftsink_nongl.py4
-rw-r--r--gr-wxgui/src/python/waterfallsink_nongl.py5
-rw-r--r--grc/blocks/gr_vector_source_x.xml13
-rw-r--r--gruel/src/lib/CMakeLists.txt16
-rw-r--r--gruel/src/lib/gruel.rc.in55
456 files changed, 34966 insertions, 249 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 16e4ef378e..7270538043 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -41,8 +41,8 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules)
# Set the version information here
set(VERSION_INFO_MAJOR_VERSION 3)
set(VERSION_INFO_API_COMPAT 6)
-set(VERSION_INFO_MINOR_VERSION 4)
-set(VERSION_INFO_MAINT_VERSION 1)
+set(VERSION_INFO_MINOR_VERSION 5)
+set(VERSION_INFO_MAINT_VERSION git)
include(GrVersion) #setup version info
# Append -O2 optimization flag for Debug builds
@@ -96,6 +96,7 @@ if(MSVC)
)
add_definitions(-DHAVE_CONFIG_H)
add_definitions(/MP) #build with multiple processors
+ add_definitions(/bigobj) #allow for larger object files
endif(MSVC)
########################################################################
@@ -120,8 +121,10 @@ set(GR_PREFSDIR ${SYSCONFDIR}/${CMAKE_PROJECT_NAME}/conf.d)
OPTION(ENABLE_PERFORMANCE_COUNTERS "Enable block performance counters" OFF)
if(ENABLE_PERFORMANCE_COUNTERS)
message(STATUS "ADDING PERF COUNTERS")
+ SET(GR_PERFORMANCE_COUNTERS True)
add_definitions(-DGR_PERFORMANCE_COUNTERS)
else(ENABLE_PERFORMANCE_COUNTERS)
+ SET(GR_PERFORMANCE_COUNTERS False)
message(STATUS "NO PERF COUNTERS")
endif(ENABLE_PERFORMANCE_COUNTERS)
@@ -226,6 +229,9 @@ CPACK_COMPONENT("volk_devel"
add_subdirectory(volk)
endif(ENABLE_VOLK)
+# Handle gr_log enable/disable
+GR_LOGGING()
+
########################################################################
# Distribute the README file
########################################################################
@@ -253,7 +259,7 @@ add_subdirectory(docs)
add_subdirectory(gruel)
add_subdirectory(gnuradio-core)
add_subdirectory(grc)
-
+add_subdirectory(gr-blocks)
add_subdirectory(gr-fft)
add_subdirectory(gr-filter)
add_subdirectory(gr-atsc)
@@ -273,7 +279,28 @@ add_subdirectory(gr-vocoder)
add_subdirectory(gr-fcd)
add_subdirectory(gr-wavelet)
add_subdirectory(gr-wxgui)
-add_subdirectory(gr-blocks)
+
+# Create a config.h with some definitions to export to other projects.
+CONFIGURE_FILE(
+ ${CMAKE_CURRENT_SOURCE_DIR}/config.h.in
+ ${CMAKE_CURRENT_BINARY_DIR}/config.h
+)
+
+# Install config.h in include/gnuradio
+install(
+ FILES
+ ${CMAKE_CURRENT_BINARY_DIR}/config.h
+ DESTINATION ${GR_INCLUDE_DIR}/gnuradio
+ COMPONENT "core_devel"
+)
+
+# Install our Cmake modules into ${GR_PKG_DATA_DIR}/cmake/Modules
+file(GLOB cmake_modules "cmake/Modules/*.cmake")
+install(
+ FILES ${cmake_modules}
+ DESTINATION ${GR_PKG_DATA_DIR}/cmake/Modules
+ COMPONENT "core_devel"
+)
#finalize cpack after subdirs processed
include(GrPackage)
diff --git a/cmake/Modules/FindLog4cpp.cmake b/cmake/Modules/FindLog4cpp.cmake
new file mode 100644
index 0000000000..fc314c61a5
--- /dev/null
+++ b/cmake/Modules/FindLog4cpp.cmake
@@ -0,0 +1,53 @@
+# - Find Log4cpp
+# Find the native LOG4CPP includes and library
+#
+# LOG4CPP_INCLUDE_DIR - where to find LOG4CPP.h, etc.
+# LOG4CPP_LIBRARIES - List of libraries when using LOG4CPP.
+# LOG4CPP_FOUND - True if LOG4CPP found.
+
+
+if (LOG4CPP_INCLUDE_DIR)
+ # Already in cache, be silent
+ set(LOG4CPP_FIND_QUIETLY TRUE)
+endif ()
+
+find_path(LOG4CPP_INCLUDE_DIR log4cpp/Category.hh
+ /opt/local/include
+ /usr/local/include
+ /usr/include
+)
+
+set(LOG4CPP_NAMES log4cpp)
+find_library(LOG4CPP_LIBRARY
+ NAMES ${LOG4CPP_NAMES}
+ PATHS /usr/lib /usr/local/lib /opt/local/lib
+)
+
+
+if (LOG4CPP_INCLUDE_DIR AND LOG4CPP_LIBRARY)
+ set(LOG4CPP_FOUND TRUE)
+ set(LOG4CPP_LIBRARIES ${LOG4CPP_LIBRARY} CACHE INTERNAL "" FORCE)
+ set(LOG4CPP_INCLUDE_DIRS ${LOG4CPP_INCLUDE_DIR} CACHE INTERNAL "" FORCE)
+else ()
+ set(LOG4CPP_FOUND FALSE CACHE INTERNAL "" FORCE)
+ set(LOG4CPP_LIBRARY "" CACHE INTERNAL "" FORCE)
+ set(LOG4CPP_LIBRARIES "" CACHE INTERNAL "" FORCE)
+ set(LOG4CPP_INCLUDE_DIR "" CACHE INTERNAL "" FORCE)
+ set(LOG4CPP_INCLUDE_DIRS "" CACHE INTERNAL "" FORCE)
+endif ()
+
+if (LOG4CPP_FOUND)
+ if (NOT LOG4CPP_FIND_QUIETLY)
+ message(STATUS "Found LOG4CPP: ${LOG4CPP_LIBRARIES}")
+ endif ()
+else ()
+ if (LOG4CPP_FIND_REQUIRED)
+ message(STATUS "Looked for LOG4CPP libraries named ${LOG4CPPS_NAMES}.")
+ message(FATAL_ERROR "Could NOT find LOG4CPP library")
+ endif ()
+endif ()
+
+mark_as_advanced(
+ LOG4CPP_LIBRARIES
+ LOG4CPP_INCLUDE_DIRS
+)
diff --git a/cmake/Modules/GrMiscUtils.cmake b/cmake/Modules/GrMiscUtils.cmake
index 3e80846d62..69ff1f5ddc 100644
--- a/cmake/Modules/GrMiscUtils.cmake
+++ b/cmake/Modules/GrMiscUtils.cmake
@@ -209,6 +209,48 @@ function(GR_GEN_TARGET_DEPS name var)
endif()
endfunction(GR_GEN_TARGET_DEPS)
+########################################################################
+# Control use of gr_logger
+# Usage:
+# GR_LOGGING()
+#
+# Will set ENABLE_GR_LOG to 1 by default.
+# Can manually set with -DENABLE_GR_LOG=0|1
+########################################################################
+function(GR_LOGGING)
+ find_package(Log4cpp)
+
+ OPTION(ENABLE_GR_LOG "Use gr_logger" ON)
+ if(ENABLE_GR_LOG)
+ # If gr_logger is enabled, make it usable
+ add_definitions( -DENABLE_GR_LOG )
+
+ # also test LOG4CPP; if we have it, use this version of the logger
+ # otherwise, default to the stdout/stderr model.
+ if(LOG4CPP_FOUND)
+ SET(HAVE_LOG4CPP True CACHE INTERNAL "" FORCE)
+ add_definitions( -DHAVE_LOG4CPP )
+ else(not LOG4CPP_FOUND)
+ SET(HAVE_LOG4CPP False CACHE INTERNAL "" FORCE)
+ SET(LOG4CPP_INCLUDE_DIRS "" CACHE INTERNAL "" FORCE)
+ SET(LOG4CPP_LIBRARY_DIRS "" CACHE INTERNAL "" FORCE)
+ SET(LOG4CPP_LIBRARIES "" CACHE INTERNAL "" FORCE)
+ endif(LOG4CPP_FOUND)
+
+ SET(ENABLE_GR_LOG ${ENABLE_GR_LOG} CACHE INTERNAL "" FORCE)
+
+ else(ENABLE_GR_LOG)
+ SET(HAVE_LOG4CPP False CACHE INTERNAL "" FORCE)
+ SET(LOG4CPP_INCLUDE_DIRS "" CACHE INTERNAL "" FORCE)
+ SET(LOG4CPP_LIBRARY_DIRS "" CACHE INTERNAL "" FORCE)
+ SET(LOG4CPP_LIBRARIES "" CACHE INTERNAL "" FORCE)
+ endif(ENABLE_GR_LOG)
+
+ message(STATUS "ENABLE_GR_LOG set to ${ENABLE_GR_LOG}.")
+ message(STATUS "HAVE_LOG4CPP set to ${HAVE_LOG4CPP}.")
+ message(STATUS "LOG4CPP_LIBRARIES set to ${LOG4CPP_LIBRARIES}.")
+
+endfunction(GR_LOGGING)
########################################################################
# Run GRCC to compile .grc files into .py files.
diff --git a/cmake/Modules/GrVersion.cmake b/cmake/Modules/GrVersion.cmake
index 9199a702bb..bafd0a7326 100644
--- a/cmake/Modules/GrVersion.cmake
+++ b/cmake/Modules/GrVersion.cmake
@@ -1,4 +1,4 @@
-# Copyright 2011 Free Software Foundation, Inc.
+# Copyright 2011,2013 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -54,6 +54,8 @@ if("${MINOR_VERSION}" STREQUAL "git")
set(VERSION "${GIT_DESCRIBE}")
set(DOCVER "${MAJOR_VERSION}.${API_COMPAT}${MINOR_VERSION}")
set(LIBVER "${MAJOR_VERSION}.${API_COMPAT}${MINOR_VERSION}")
+ set(RC_MINOR_VERSION "0")
+ set(RC_MAINT_VERSION "0")
elseif("${MAINT_VERSION}" STREQUAL "git")
# VERSION: 3.3.1git-xxx-gxxxxxxxx
# DOCVER: 3.3.1git
@@ -61,6 +63,8 @@ elseif("${MAINT_VERSION}" STREQUAL "git")
set(VERSION "${GIT_DESCRIBE}")
set(DOCVER "${MAJOR_VERSION}.${API_COMPAT}.${MINOR_VERSION}${MAINT_VERSION}")
set(LIBVER "${MAJOR_VERSION}.${API_COMPAT}.${MINOR_VERSION}${MAINT_VERSION}")
+ math(EXPR RC_MINOR_VERSION "${MINOR_VERSION} - 1")
+ set(RC_MAINT_VERSION "0")
else()
# This is a numbered release.
# VERSION: 3.3.1{.x}
@@ -73,4 +77,6 @@ else()
endif()
set(DOCVER "${VERSION}")
set(LIBVER "${VERSION}")
+ set(RC_MINOR_VERSION ${MINOR_VERSION})
+ set(RC_MAINT_VERSION ${MAINT_VERSION})
endif()
diff --git a/config.h.in b/config.h.in
new file mode 100644
index 0000000000..2a2141b3d5
--- /dev/null
+++ b/config.h.in
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2013 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 GNURADIO_CONFIG_H
+#define GNURADIO_CONFIG_H
+#ifndef TRY_SHM_VMCIRCBUF
+#cmakedefine TRY_SHM_VMCIRCBUF
+#endif
+#ifndef GR_PERFORMANCE_COUNTERS
+#cmakedefine GR_PERFORMANCE_COUNTERS
+#endif
+#ifndef ENABLE_GR_LOG
+#cmakedefine ENABLE_GR_LOG
+#endif
+#ifndef HAVE_LOG4CPP
+#cmakedefine HAVE_LOG4CPP
+#endif
+
+#endif /* GNURADIO_CONFIG_H */
diff --git a/docs/doxygen/other/extra_pages.dox b/docs/doxygen/other/extra_pages.dox
index d40c692e03..94c741864d 100644
--- a/docs/doxygen/other/extra_pages.dox
+++ b/docs/doxygen/other/extra_pages.dox
@@ -79,6 +79,8 @@ audio-osx and audio-windows to be either satisfied or built.
\subsection dep_gr_comedi gr-comedi: Comedi hardware interface
\li comedilib (>= 0.8) http://www.comedi.org/
+\subsection dep_gr_log gr-log: Logging Tools (Optional)
+\li log4cpp (>= 1.0) http://log4cpp.sourceforge.net/
\section build_gr_cmake Building GNU Radio
diff --git a/docs/doxygen/other/logger.dox b/docs/doxygen/other/logger.dox
new file mode 100644
index 0000000000..9a97172ed0
--- /dev/null
+++ b/docs/doxygen/other/logger.dox
@@ -0,0 +1,205 @@
+/*! \page page_logger Logging
+
+\section logging Logging
+
+GNU Radio has a logging interface to enable various levels of logging
+information to be printed to the console or a file. The logger derives
+from log4cpp (http://log4cpp.sourceforge.net/) which is readily
+available in most Linux distributions. This is an optional dependency
+and GNU Radio will work without it.
+
+When configuring GNU Radio, the -DENABLE_GR_LOG=On|Off option to cmake
+will allow the user to toggle use of the logger on and off. The logger
+defaults to "on" and will use log4cpp if it is available. If log4cpp
+is not found, the default logging will output to standard output or
+standard error, depending on the level of the log message.
+
+Logging is useful for blocks to print out certain amounts of data at
+different levels. These levels are:
+
+<pre>
+ DEBUG < INFO < WARN < TRACE < ERROR < ALERT < CRIT < FATAL < EMERG
+</pre>
+
+
+The order here determines the level of output. These levels are
+hierarchical in that specifying any level also includes any level
+above it. For example, when using the Debug level, all Debug and
+higher messages are logged and Trace is ignored.
+
+\subsection configfile Logging Configuration
+
+The logging configuration can be found in the gnuradio-core.conf file
+under the [LOG] section. This allows us fairly complete control over
+the logging facilities. The main configuration functions are to set up
+the level of the loggers and set the default output behavior of the
+loggers.
+
+There are two default loggers that all gr_block's have access to:
+d_logger and d_debug_logger. The first is a standard logger meant to
+output simple information about the block while it is running. The
+debug logger is meant for debugging purposes and is added to make it
+convenient to use a secondary logger that outputs to a different
+stream or file.
+
+The four main configure options are:
+
+<pre>
+ log_level = debug
+ debug_level = debug
+ log_file = stdout
+ debug_file = stderr
+</pre>
+
+This establishes the two loggers as having access to all levels of
+logging events (DEBUG through EMERG). They are also configured not to
+use files but instead output to the console. The standard logger will
+output to standard out while the debug logger outputs to standard
+error.
+
+Changing these last two lines to another value will create files that
+are used to store the log messages. All messages are appended to the
+file.
+
+When using either standard error or standard out, the messages for the
+two different loggers will look like:
+
+<pre>
+ gr::log :\<level\>: \<block alias\> - \<message\>
+ gr::debug :\<level\>: \<block alias\> - \<message\>
+</pre>
+
+When using a file, the only difference in the format is that the
+message prefix of "gr::log" or "gr::debug" is not used. Instead, the
+time in milliseconds from the start of the program is inserted.
+
+Remember that a local "~/.gnuradio/config.conf" file can be used to
+override any parameter in the global file (see \ref prefs for more
+details).
+
+To use these loggers inside of a GNU Radio block, we use the protected
+data members of d_logger and d_debug_logger of gr_block and pass them
+to our pre-defined macros:
+
+\code
+ GR_LOG_<level>(<logger>, "<Message to print>");
+\endcode
+
+Where \<level\> is one of the levels as mentioned above, \<logger\> is
+either d_logger or d_debug_logger, and \<Message to print\> is the
+message we want to output. If we wanted to output an INFO level
+message to the standard logger and a WARN level message to the debug
+logger, it would look like this:
+
+\code
+ GR_LOG_INFO(d_logger, "Some info about the block");
+ GR_LOG_WARN(d_debug_logger, "Some warning about the block");
+\endcode
+
+When this is printed to wherever you are directing the output of the
+logger, it will look like:
+
+<pre>
+ gr::log :INFO: <block's alias> - Some info about the block
+ gr::debug :WARN: <block's alias> - Some warning about the block
+</pre>
+
+This provides us information about where the message came from, the
+level of the message, and the block that generated the message. We use
+the concept of the block's alias which by default (i.e., unless
+otherwise set by the user) includes the name of the block and a unique
+ID to distinguish it from other blocks of the same type.
+
+The various logging macros are defined in gr_logger.h. Here are some
+simple examples of using them:
+
+\code
+ GR_LOG_DEBUG(LOG, "DEBUG message");
+ GR_LOG_INFO(LOG, "INFO message");
+ GR_LOG_NOTICE(LOG, "NOTICE message");
+ GR_LOG_WARN(LOG, "WARNING message");
+ GR_LOG_ERROR(LOG, "ERROR message");
+ GR_LOG_CRIT(LOG, "CRIT message");
+ GR_LOG_ALERT(LOG, "ALERT message");
+ GR_LOG_FATAL(LOG, "FATAL message");
+ GR_LOG_EMERG(LOG, "EMERG message");
+\endcode
+
+If the logger is not enabled, then these macros become nops and do
+nothing (and d_logger and d_debug_logger are NULL pointers). If
+logging is enabled but the log4cpp library is not found, then TRACE,
+INFO, and NOTICE levels go to stdout and the rest to stderr.
+
+
+\subsection adv_config Advanced Configuration Options
+
+If not using the simplified settings discussed above, where we can
+direct the logger messages to either a file or one of the standard
+outputs, we must use a more complicated configuration file. We do this
+by specifying the "log_config" option in the [LOG] section. The
+log4cpp documentation will provide more information on how
+configuration works and looks. Mostly, a default configuration script
+provided with GNU Radio can be used. After installation, the default
+configuration script is located at:
+
+<pre>
+ $prefix/etc/gnuradio/gr_log_default.xml
+</pre>
+
+For the following examples, we will assume that our local
+"~/.gnuradio/config.conf" looks like this:
+
+\code
+[LOG]
+log_config = /opt/gr/etc/gnuadio/gr_log_default.xml
+log_level = debug
+debug_level = Off
+\endcode
+
+Inside of the XML default configuration file, we define the parameters
+for the two logger's, the standard logger the separate debug logger.
+
+If the levels of the two loggers are specified in our configuration
+file, as in the above example, these levels override any levels
+specified in the XML file. Here, we have turned on the standard logger
+(d_logger) to all levels and turned off the debug logger
+(d_debug_logger). So even if the debug logger is used in the code, it
+will not actually output any information. Conversely, any level of
+output passed to the standard logger will output because we have
+turned this value to the lowest level "debug."
+
+If both an XML configuration file is set and the "log_file" or
+"debug_file" options are set at the same time, both systems are
+actually used. So you can configure file access and the pattern
+through the XML file while also still outputting to stdout or stderr.
+
+
+\section advlog Advanced Usage
+
+The description above for using the logging facilities is specific to
+GNU Radio blocks. We have put the code necessary to access the
+debugger into the gr_block parent class to simplify access and make
+sure all blocks have the ability to quickly and easily use the logger.
+
+For non gr_block-based code, we have to get some information about the
+logger in order to properly access it. Each logger only exists once as
+a singleton in the system, but we need to get a pointer to the right
+logger and then set it up for our local use. The following code
+snippet shows how to do this to get access to the standard logger,
+which has a root of "gr_log." (access to the debug logger is similar
+except we would use "gr_log_debug." in the GR_LOG_GETLOGGER call):
+
+\code
+ gr_prefs *p = gr_prefs::singleton();
+ std::string log_file = p->get_string("LOG", "log_config", "");
+ std::string log_level = p->get_string("LOG", "log_level", "off");
+ GR_CONFIG_LOGGER(log_file);
+ GR_LOG_GETLOGGER(LOG, "gr_log." + "my_logger_name");
+ GR_LOG_SET_LEVEL(LOG, log_level);
+\endcode
+
+This creates a pointer called LOG (which is instantiated as a
+log4cpp:LoggerPtr in the macro) that we can now use locally as the
+input to our logging macros like 'GR_LOG_INFO(LOG, "message")'.
+
+*/
diff --git a/docs/doxygen/other/main_page.dox b/docs/doxygen/other/main_page.dox
index e7d4685f75..8895cd552d 100644
--- a/docs/doxygen/other/main_page.dox
+++ b/docs/doxygen/other/main_page.dox
@@ -39,6 +39,7 @@ More details on packages in GNU Radio:
\li \ref page_vocoder
More details on GNU Radio concepts:
+\li \ref page_logger
\li \ref page_pmt
\li \ref page_msg_passing
\li \ref page_metadata
diff --git a/gnuradio-core/CMakeLists.txt b/gnuradio-core/CMakeLists.txt
index b277103547..2bbb8570db 100644
--- a/gnuradio-core/CMakeLists.txt
+++ b/gnuradio-core/CMakeLists.txt
@@ -44,6 +44,7 @@ GR_REGISTER_COMPONENT("gnuradio-core" ENABLE_GR_CORE
)
include(GrMiscUtils)
+
GR_SET_GLOBAL(GNURADIO_CORE_INCLUDE_DIRS
${CMAKE_CURRENT_SOURCE_DIR}/src/lib/runtime
${CMAKE_CURRENT_BINARY_DIR}/src/lib/general
@@ -59,13 +60,17 @@ GR_SET_GLOBAL(GNURADIO_CORE_INCLUDE_DIRS
${CMAKE_CURRENT_BINARY_DIR}/src/lib/swig
${CMAKE_CURRENT_SOURCE_DIR}/src/lib/swig
${CMAKE_CURRENT_SOURCE_DIR}/src/lib/hier
+ ${CMAKE_BINARY_DIR}
)
+list(APPEND GNURADIO_CORE_INCLUDE_DIRS ${CMAKE_BINARY_DIR})
+
GR_SET_GLOBAL(GNURADIO_CORE_SWIG_INCLUDE_DIRS
${GNURADIO_CORE_INCLUDE_DIRS}
${CMAKE_CURRENT_SOURCE_DIR}/src/lib/swig
${CMAKE_SOURCE_DIR}/gruel/src/swig
${CMAKE_BINARY_DIR}/gruel/src/swig
+ ${CMAKE_BINARY_DIR}
)
########################################################################
@@ -107,12 +112,26 @@ CPACK_COMPONENT("core_swig"
DEPENDS "gruel_swig;core_python;core_devel"
)
+# Setup configure file
+configure_file(
+ ${CMAKE_CURRENT_SOURCE_DIR}/gnuradio-core.conf.in
+ ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-core.conf
+@ONLY)
+
install(
- FILES gnuradio-core.conf
+ FILES ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-core.conf
DESTINATION ${GR_PREFSDIR}
COMPONENT "core_runtime"
)
+if(ENABLE_GR_LOG AND HAVE_LOG4CPP)
+install(FILES
+ ${CMAKE_CURRENT_SOURCE_DIR}/gr_log_default.xml
+ DESTINATION ${GR_CONF_DIR}/gnuradio
+ COMPONENT "core_runtime"
+)
+endif(ENABLE_GR_LOG AND HAVE_LOG4CPP)
+
########################################################################
# Add subdirectories
########################################################################
diff --git a/gnuradio-core/gnuradio-core.conf b/gnuradio-core/gnuradio-core.conf
deleted file mode 100644
index d575d1dc8a..0000000000
--- a/gnuradio-core/gnuradio-core.conf
+++ /dev/null
@@ -1,14 +0,0 @@
-# This file contains system wide configuration data for GNU Radio.
-# You may override any setting on a per-user basis by editing
-# ~/.gnuradio/config.conf
-
-[DEFAULT]
-
-verbose = False
-
-# The maximum number of messages a block will store up before pruning
-# the queue by popping messages from the front.
-max_messages = 100
-
-[PerfCounters]
-on = False
diff --git a/gnuradio-core/gnuradio-core.conf.in b/gnuradio-core/gnuradio-core.conf.in
new file mode 100644
index 0000000000..25abedb253
--- /dev/null
+++ b/gnuradio-core/gnuradio-core.conf.in
@@ -0,0 +1,31 @@
+# This file contains system wide configuration data for GNU Radio.
+# You may override any setting on a per-user basis by editing
+# ~/.gnuradio/config.conf
+
+[DEFAULT]
+verbose = False
+
+# The maximum number of messages a block will store up before pruning
+# the queue by popping messages from the front.
+max_messages = 100
+
+
+[LOG]
+# Levels can be (case insensitive):
+# DEBUG, INFO, WARN, TRACE, ERROR, ALERT, CRIT, FATAL, EMERG
+log_level = debug
+debug_level = emerg
+
+# These file names can either be 'stdout' to output to standard output
+# or 'stderr' to output to standard error. Any other string will
+# create a file in which to output the logging information. An empty
+# string or no value here will ignore this level of configuration
+# completely.
+log_file = stdout
+debug_file = stderr
+
+# Used for advanced configuration of the logger
+#log_config = @CMAKE_INSTALL_PREFIX@/etc/gnuradio/gr_log_default.xml
+
+[PerfCounters]
+on = False
diff --git a/gnuradio-core/gr_log_default.xml b/gnuradio-core/gr_log_default.xml
new file mode 100644
index 0000000000..13b854c7e8
--- /dev/null
+++ b/gnuradio-core/gr_log_default.xml
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ * Copyright 2006,2010,2011 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.
+ */
+-->
+
+ <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
+
+ <appender name="RootConsoleAppender" class="org.apache.log4j.ConsoleAppender">
+ <param name="Target" value="System.out"/>
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="Root :%p: %c{1} - %m%n"/>
+ </layout>
+ </appender>
+
+ <!--Add appender to root to log ALL msgs in one place-->
+ <root>
+ <priority value="all" />
+ </root>
+
+ <appender name="errLogRootConsoleAppender" class="org.apache.log4j.ConsoleAppender">
+ <param name="Target" value="System.out"/>
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="gr::log :%p: %c{1} - %m%n"/>
+ </layout>
+ </appender>
+
+ <!-- Specify the level for some specific loggers-->
+ <category name="gr_log" >
+ <priority value ="all" />
+ <appender-ref ref="errLogRootConsoleAppender"/>
+ </category>
+
+ <appender name="errConsoleAppender" class="org.apache.log4j.ConsoleAppender">
+ <param name="Target" value="System.out"/>
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="gr::debug :%p: %c{1} - %m%n"/>
+ </layout>
+ </appender>
+
+ <category name="gr_log_debug" >
+ <priority value ="DEBUG" />
+ <appender-ref ref="errConsoleAppender"/>
+ </category>
+
+ </log4j:configuration>
+
diff --git a/gnuradio-core/src/lib/CMakeLists.txt b/gnuradio-core/src/lib/CMakeLists.txt
index 89a1bad88b..da6de8ed1b 100644
--- a/gnuradio-core/src/lib/CMakeLists.txt
+++ b/gnuradio-core/src/lib/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright 2010-2011 Free Software Foundation, Inc.
+# Copyright 2010-2011,2013 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -39,6 +39,21 @@ list(APPEND gnuradio_core_sources bug_work_around_6.cc)
list(APPEND test_gnuradio_core_sources bug_work_around_6.cc)
########################################################################
+# Set up Windows DLL resource files
+########################################################################
+
+IF(MSVC)
+ include(${CMAKE_SOURCE_DIR}/cmake/Modules/GrVersion.cmake)
+
+ configure_file(
+ ${CMAKE_CURRENT_SOURCE_DIR}/gnuradio-core.rc.in
+ ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-core.rc
+ @ONLY)
+
+ list(APPEND gnuradio_core_sources ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-core.rc)
+ENDIF(MSVC)
+
+########################################################################
# Setup the include and linker paths
########################################################################
include_directories(
@@ -54,13 +69,25 @@ link_directories(
${FFTW3F_LIBRARY_DIRS}
)
+include_directories(${LOG4CPP_INCLUDE_DIRS})
+link_directories(${LOG4CPP_LIBRARY_DIRS})
+
########################################################################
# Setup library
########################################################################
+
+# Only use if log4cpp is installed
+# Define ENABLE_GR_LOG so .h and .cc files can turn actual
+# logging and insert dummy functions.
+#if(LOG4CPP_FOUND)
+# add_definitions(-DENABLE_GR_LOG)
+#endif(LOG4CPP_FOUND)
+
list(APPEND gnuradio_core_libs
gruel
${Boost_LIBRARIES}
${FFTW3F_LIBRARIES}
+ ${LOG4CPP_LIBRARIES}
)
if(FFTW3F_THREADS_LIBRARIES)
@@ -101,6 +128,6 @@ include_directories(${CPPUNIT_INCLUDE_DIRS})
link_directories(${CPPUNIT_LIBRARY_DIRS})
add_library(test-gnuradio-core SHARED ${test_gnuradio_core_sources})
-target_link_libraries(test-gnuradio-core gnuradio-core ${CPPUNIT_LIBRARIES} ${Boost_LIBRARIES})
+target_link_libraries(test-gnuradio-core gnuradio-core ${CPPUNIT_LIBRARIES} ${Boost_LIBRARIES} ${LOG4CPP_LIBRARIES})
endif(ENABLE_TESTING)
diff --git a/gnuradio-core/src/lib/filter/gr_fir_sysconfig_x86.cc b/gnuradio-core/src/lib/filter/gr_fir_sysconfig_x86.cc
index 97b8106994..95e17123c8 100644
--- a/gnuradio-core/src/lib/filter/gr_fir_sysconfig_x86.cc
+++ b/gnuradio-core/src/lib/filter/gr_fir_sysconfig_x86.cc
@@ -48,6 +48,7 @@
// #include <gr_fir_sss_mmx.h>
// #include <gr_fir_sss_sse2.h>
+
#include <iostream>
using std::cerr;
@@ -207,7 +208,7 @@ gr_fir_sysconfig_x86::create_gr_fir_fcc (const std::vector<gr_complex> &taps)
if (gr_cpu::has_3dnow ()){
if (first){
- cerr << ">>> gr_fir_fcc: using 3DNow!\n";
+ cerr << ">>> gr_fir_fcc: gr_fir_fcc: using 3DNow!\n";
first = false;
}
return make_gr_fir_fcc_3dnow (taps);
@@ -215,7 +216,7 @@ gr_fir_sysconfig_x86::create_gr_fir_fcc (const std::vector<gr_complex> &taps)
if (gr_cpu::has_sse ()){
if (first){
- cerr << ">>> gr_fir_fcc: using SSE\n";
+ cerr << ">>> gr_fir_fcc: gr_fir_fcc: using SSE\n";
first = false;
}
return make_gr_fir_fcc_sse (taps);
@@ -326,19 +327,26 @@ gr_fir_sysconfig_x86::create_gr_fir_sss (const std::vector<short> &taps)
{
// FIXME -- probably want to figure out best answer for Athlon and code
// add code to select it here...
+ static bool first = true;
if (gr_cpu::has_sse2 ()){
- cerr << ">>> gr_fir_sss: using SSE2\n";
- return make_gr_fir_sss_sse2 (taps);
+ if(first) {
+ cerr << ">>> gr_fir_sss: using SSE2\n";
+ return make_gr_fir_sss_sse2 (taps);
+ }
}
if (gr_cpu::has_mmx ()){
- cerr << ">>> gr_fir_sss: using MMX\n";
- return make_gr_fir_sss_mmx (taps);
+ if(first) {
+ cerr << ">>> gr_fir_sss: using MMX\n";
+ return make_gr_fir_sss_mmx (taps);
+ }
}
- cerr << ">>> gr_fir_sss: handing off to parent class\n";
- return gr_fir_sysconfig_generic::create_gr_fir_sss (taps);
+ if(first) {
+ cerr << ">>> gr_fir_sss: handing off to parent class\n";
+ return gr_fir_sysconfig_generic::create_gr_fir_sss (taps);
+ }
}
#endif
diff --git a/gnuradio-core/src/lib/gengen/gr_vector_sink_X.cc.t b/gnuradio-core/src/lib/gengen/gr_vector_sink_X.cc.t
index a9e3a0a3ea..2b8207c027 100644
--- a/gnuradio-core/src/lib/gengen/gr_vector_sink_X.cc.t
+++ b/gnuradio-core/src/lib/gengen/gr_vector_sink_X.cc.t
@@ -28,6 +28,7 @@
#include <@NAME@.h>
#include <algorithm>
#include <gr_io_signature.h>
+#include <iostream>
@NAME@::@NAME@ (int vlen)
@@ -46,7 +47,9 @@ int
@TYPE@ *iptr = (@TYPE@ *) input_items[0];
for (int i = 0; i < noutput_items * d_vlen; i++)
d_data.push_back (iptr[i]);
-
+ std::vector<gr_tag_t> tags;
+ get_tags_in_range(tags, 0, nitems_read(0), nitems_read(0) + noutput_items);
+ d_tags.insert(d_tags.end(), tags.begin(), tags.end());
return noutput_items;
}
@@ -62,3 +65,9 @@ std::vector<@TYPE@>
{
return d_data;
}
+
+std::vector<gr_tag_t>
+@NAME@::tags () const
+{
+ return d_tags;
+}
diff --git a/gnuradio-core/src/lib/gengen/gr_vector_sink_X.h.t b/gnuradio-core/src/lib/gengen/gr_vector_sink_X.h.t
index b9126dc7b2..b7de1d101c 100644
--- a/gnuradio-core/src/lib/gengen/gr_vector_sink_X.h.t
+++ b/gnuradio-core/src/lib/gengen/gr_vector_sink_X.h.t
@@ -43,6 +43,7 @@ gr_make_@BASE_NAME@ (int vlen = 1);
class GR_CORE_API @NAME@ : public gr_sync_block {
friend GR_CORE_API @NAME@_sptr gr_make_@BASE_NAME@ (int vlen);
std::vector<@TYPE@> d_data;
+ std::vector<gr_tag_t> d_tags;
int d_vlen;
@NAME@ (int vlen);
@@ -54,6 +55,7 @@ class GR_CORE_API @NAME@ : public gr_sync_block {
void reset() {d_data.clear();}
void clear() {reset(); } // deprecated
std::vector<@TYPE@> data () const;
+ std::vector<gr_tag_t> tags () const;
};
#endif
diff --git a/gnuradio-core/src/lib/gengen/gr_vector_sink_X.i.t b/gnuradio-core/src/lib/gengen/gr_vector_sink_X.i.t
index d4a9409114..ee0ebf378b 100644
--- a/gnuradio-core/src/lib/gengen/gr_vector_sink_X.i.t
+++ b/gnuradio-core/src/lib/gengen/gr_vector_sink_X.i.t
@@ -35,5 +35,6 @@ class @NAME@ : public gr_sync_block {
void clear(); // deprecated
void reset();
std::vector<@TYPE@> data () const;
+ std::vector<gr_tag_t> tags () const;
};
diff --git a/gnuradio-core/src/lib/gengen/gr_vector_source_X.cc.t b/gnuradio-core/src/lib/gengen/gr_vector_source_X.cc.t
index 9f68f9cf14..19272ee24b 100644
--- a/gnuradio-core/src/lib/gengen/gr_vector_source_X.cc.t
+++ b/gnuradio-core/src/lib/gengen/gr_vector_source_X.cc.t
@@ -30,20 +30,39 @@
#include <gr_io_signature.h>
#include <stdexcept>
-
-@NAME@::@NAME@ (const std::vector<@TYPE@> &data, bool repeat, int vlen)
+@NAME@::@NAME@ (const std::vector<@TYPE@> &data, bool repeat, int vlen, const std::vector<gr_tag_t> &tags)
: gr_sync_block ("@BASE_NAME@",
gr_make_io_signature (0, 0, 0),
gr_make_io_signature (1, 1, sizeof (@TYPE@) * vlen)),
d_data (data),
d_repeat (repeat),
d_offset (0),
- d_vlen (vlen)
+ d_vlen (vlen),
+ d_tags (tags),
+ d_tagpos (0)
{
+ if (tags.size() == 0) {
+ d_settags = 0;
+ } else {
+ d_settags = 1;
+ set_output_multiple(data.size() / vlen);
+ }
if ((data.size() % vlen) != 0)
throw std::invalid_argument("data length must be a multiple of vlen");
}
+void
+@NAME@::set_data (const std::vector<@TYPE@> &data, const std::vector<gr_tag_t> &tags){
+ d_data = data;
+ d_tags = tags;
+ rewind();
+ if (tags.size() == 0) {
+ d_settags = false;
+ } else {
+ d_settags = true;
+ }
+}
+
int
@NAME@::work (int noutput_items,
gr_vector_const_void_star &input_items,
@@ -54,36 +73,52 @@ int
if (d_repeat){
unsigned int size = d_data.size ();
unsigned int offset = d_offset;
-
if (size == 0)
return -1;
- for (int i = 0; i < noutput_items*d_vlen; i++){
- optr[i] = d_data[offset++];
- if (offset >= size)
- offset = 0;
+ if (d_settags) {
+ int n_outputitems_per_vector = d_data.size() / d_vlen;
+ for (int i = 0; i < noutput_items; i += n_outputitems_per_vector) {
+ // FIXME do proper vector copy
+ memcpy((void *) optr, (const void *) &d_data[0], size * sizeof (@TYPE@));
+ optr += size;
+ for (unsigned t = 0; t < d_tags.size(); t++) {
+ add_item_tag(0, nitems_written(0)+i+d_tags[t].offset, d_tags[t].key, d_tags[t].value);
+ }
+ }
+ } else {
+ for (int i = 0; i < noutput_items*d_vlen; i++){
+ optr[i] = d_data[offset++];
+ if (offset >= size) {
+ offset = 0;
+ }
+ }
}
+
+
d_offset = offset;
return noutput_items;
- }
-
- else {
+ } else {
if (d_offset >= d_data.size ())
return -1; // Done!
unsigned n = std::min ((unsigned) d_data.size () - d_offset,
- (unsigned) noutput_items*d_vlen);
- for (unsigned i = 0; i < n; i++)
+ (unsigned) noutput_items*d_vlen);
+ for (unsigned i = 0; i < n; i++) {
optr[i] = d_data[d_offset + i];
-
+ }
+ for (unsigned t = 0; t < d_tags.size(); t++) {
+ if ((d_tags[t].offset >= d_offset) && (d_tags[t].offset < d_offset+n))
+ add_item_tag(0, d_tags[t].offset, d_tags[t].key, d_tags[t].value);
+ }
d_offset += n;
return n/d_vlen;
}
}
@NAME@_sptr
-gr_make_@BASE_NAME@ (const std::vector<@TYPE@> &data, bool repeat, int vlen)
+gr_make_@BASE_NAME@ (const std::vector<@TYPE@> &data, bool repeat, int vlen, const std::vector<gr_tag_t> &tags)
{
- return gnuradio::get_initial_sptr(new @NAME@ (data, repeat, vlen));
+ return gnuradio::get_initial_sptr(new @NAME@ (data, repeat, vlen, tags));
}
diff --git a/gnuradio-core/src/lib/gengen/gr_vector_source_X.h.t b/gnuradio-core/src/lib/gengen/gr_vector_source_X.h.t
index fe02c1346f..041cc47a45 100644
--- a/gnuradio-core/src/lib/gengen/gr_vector_source_X.h.t
+++ b/gnuradio-core/src/lib/gengen/gr_vector_source_X.h.t
@@ -38,24 +38,27 @@ typedef boost::shared_ptr<@NAME@> @NAME@_sptr;
class @NAME@ : public gr_sync_block {
friend GR_CORE_API @NAME@_sptr
- gr_make_@BASE_NAME@ (const std::vector<@TYPE@> &data, bool repeat, int vlen);
+ gr_make_@BASE_NAME@ (const std::vector<@TYPE@> &data, bool repeat, int vlen, const std::vector<gr_tag_t> &tags);
std::vector<@TYPE@> d_data;
bool d_repeat;
unsigned int d_offset;
int d_vlen;
+ bool d_settags;
+ std::vector<gr_tag_t> d_tags;
+ unsigned int d_tagpos;
- @NAME@ (const std::vector<@TYPE@> &data, bool repeat, int vlen);
+ @NAME@ (const std::vector<@TYPE@> &data, bool repeat, int vlen, const std::vector<gr_tag_t> &tags);
public:
void rewind() {d_offset=0;}
virtual int work (int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items);
- void set_data(const std::vector<@TYPE@> &data){ d_data = data; rewind(); }
+ void set_data(const std::vector<@TYPE@> &data, const std::vector<gr_tag_t> &tags = std::vector<gr_tag_t>());
};
GR_CORE_API @NAME@_sptr
-gr_make_@BASE_NAME@ (const std::vector<@TYPE@> &data, bool repeat = false, int vlen = 1);
+gr_make_@BASE_NAME@ (const std::vector<@TYPE@> &data, bool repeat = false, int vlen = 1, const std::vector<gr_tag_t> &tags = std::vector<gr_tag_t>());
#endif
diff --git a/gnuradio-core/src/lib/gengen/gr_vector_source_X.i.t b/gnuradio-core/src/lib/gengen/gr_vector_source_X.i.t
index 4986c68a35..1f1479f947 100644
--- a/gnuradio-core/src/lib/gengen/gr_vector_source_X.i.t
+++ b/gnuradio-core/src/lib/gengen/gr_vector_source_X.i.t
@@ -25,13 +25,13 @@
GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@);
@NAME@_sptr
-gr_make_@BASE_NAME@ (const std::vector<@TYPE@> &data, bool repeat = false, int vlen = 1)
+gr_make_@BASE_NAME@ (const std::vector<@TYPE@> &data, bool repeat = false, int vlen = 1, const std::vector<gr_tag_t> &tags=std::vector<gr_tag_t>())
throw(std::invalid_argument);
class @NAME@ : public gr_sync_block {
public:
void rewind();
- void set_data(const std::vector<@TYPE@> &data);
+ void set_data(const std::vector<@TYPE@> &data, const std::vector<gr_tag_t> &tags = std::vector<gr_tag_t>());
private:
- @NAME@ (const std::vector<@TYPE@> &data, int vlen);
+ @NAME@ (const std::vector<@TYPE@> &data, bool repeat, int vlen, const std::vector<gr_tag_t> &tags);
};
diff --git a/gnuradio-core/src/lib/gnuradio-core.rc.in b/gnuradio-core/src/lib/gnuradio-core.rc.in
new file mode 100644
index 0000000000..a5579ce4ed
--- /dev/null
+++ b/gnuradio-core/src/lib/gnuradio-core.rc.in
@@ -0,0 +1,55 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2013 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.
+ */
+
+#include <afxres.h>
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@
+ PRODUCTVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@
+ FILEFLAGSMASK 0x3fL
+#ifndef NDEBUG
+ FILEFLAGS 0x0L
+#else
+ FILEFLAGS 0x1L
+#endif
+ FILEOS VOS__WINDOWS32
+ FILETYPE VFT_DLL
+ FILESUBTYPE VFT2_DRV_INSTALLABLE
+ BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904b0"
+ BEGIN
+ VALUE "FileDescription", "gnuradio-core"
+ VALUE "FileVersion", "@VERSION@"
+ VALUE "InternalName", "gnuradio-core.dll"
+ VALUE "LegalCopyright", "Licensed under GPLv3 or any later version"
+ VALUE "OriginalFilename", "gnuradio-core.dll"
+ VALUE "ProductName", "gnuradio-core"
+ VALUE "ProductVersion", "@VERSION@"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+ END
diff --git a/gnuradio-core/src/lib/io/gr_message_sink.cc b/gnuradio-core/src/lib/io/gr_message_sink.cc
index ae0b5c7649..3816f5da48 100644
--- a/gnuradio-core/src/lib/io/gr_message_sink.cc
+++ b/gnuradio-core/src/lib/io/gr_message_sink.cc
@@ -34,7 +34,6 @@
#include <stdexcept>
#include <string.h>
-
// public constructor that returns a shared_ptr
gr_message_sink_sptr
@@ -42,12 +41,25 @@ gr_make_message_sink (size_t itemsize, gr_msg_queue_sptr msgq, bool dont_block)
{
return gnuradio::get_initial_sptr(new gr_message_sink(itemsize, msgq, dont_block));
}
+gr_message_sink_sptr
+gr_make_message_sink (size_t itemsize, gr_msg_queue_sptr msgq, bool dont_block, const std::string& lengthtagname)
+{
+ return gnuradio::get_initial_sptr(new gr_message_sink(itemsize, msgq, dont_block, lengthtagname));
+}
gr_message_sink::gr_message_sink (size_t itemsize, gr_msg_queue_sptr msgq, bool dont_block)
: gr_sync_block("message_sink",
gr_make_io_signature(1, 1, itemsize),
gr_make_io_signature(0, 0, 0)),
- d_itemsize(itemsize), d_msgq(msgq), d_dont_block(dont_block)
+ d_itemsize(itemsize), d_msgq(msgq), d_dont_block(dont_block), d_tags(false), d_items_read(0)
+{
+}
+
+gr_message_sink::gr_message_sink (size_t itemsize, gr_msg_queue_sptr msgq, bool dont_block, const std::string& lengthtagname)
+ : gr_sync_block("message_sink",
+ gr_make_io_signature(1, 1, itemsize),
+ gr_make_io_signature(0, 0, 0)),
+ d_itemsize(itemsize), d_msgq(msgq), d_dont_block(dont_block), d_tags(true), d_lengthtagname(lengthtagname), d_items_read(0)
{
}
@@ -62,18 +74,46 @@ gr_message_sink::work(int noutput_items,
{
const char *in = (const char *) input_items[0];
- // if we'd block, drop the data on the floor and say everything is OK
- if (d_dont_block && d_msgq->full_p())
- return noutput_items;
+ if (d_tags) {
+ long packet_length = 0;
+ std::vector<gr_tag_t> tags;
+ this->get_tags_in_range(tags, 0, d_items_read, d_items_read+1);
+ //const size_t ninput_items = noutput_items; //assumption for sync block, this can change
+ for (unsigned int i = 0; i < tags.size(); i++) {
+ if (pmt::pmt_symbol_to_string(tags[i].key) == d_lengthtagname) {
+ packet_length = pmt::pmt_to_long(tags[i].value);
+ }
+ }
+ assert(packet_length != 0);
- // build a message to hold whatever we've got
- gr_message_sptr msg = gr_make_message(0, // msg type
- d_itemsize, // arg1 for other end
- noutput_items, // arg2 for other end (redundant)
- noutput_items * d_itemsize); // len of msg
- memcpy(msg->msg(), in, noutput_items * d_itemsize);
-
- d_msgq->handle(msg); // send it
-
- return noutput_items;
+ // FIXME run this multiple times if input_items >= N * packet_length
+ if (noutput_items >= packet_length ) {
+ // If the message queue is full we drop the packet.
+ if (!d_msgq->full_p()) {
+ gr_message_sptr msg = gr_make_message(0, // msg type
+ d_itemsize, // arg1 for other end
+ packet_length, // arg2 for other end (redundant)
+ packet_length * d_itemsize); // len of msg
+ memcpy(msg->msg(), in, packet_length * d_itemsize);
+ d_msgq->handle(msg); // send it
+ }
+ d_items_read += packet_length;
+ return packet_length;
+ } else {
+ return 0;
+ }
+ } else {
+ // If the queue if full we drop all the data we got.
+ if (!d_msgq->full_p()) {
+ // build a message to hold whatever we've got
+ gr_message_sptr msg = gr_make_message(0, // msg type
+ d_itemsize, // arg1 for other end
+ noutput_items, // arg2 for other end (redundant)
+ noutput_items * d_itemsize); // len of msg
+ memcpy(msg->msg(), in, noutput_items * d_itemsize);
+
+ d_msgq->handle(msg); // send it
+ }
+ return noutput_items;
+ }
}
diff --git a/gnuradio-core/src/lib/io/gr_message_sink.h b/gnuradio-core/src/lib/io/gr_message_sink.h
index 84005694a1..2db84cff44 100644
--- a/gnuradio-core/src/lib/io/gr_message_sink.h
+++ b/gnuradio-core/src/lib/io/gr_message_sink.h
@@ -27,13 +27,23 @@
#include <gr_sync_block.h>
#include <gr_message.h>
#include <gr_msg_queue.h>
+#include <string>
class gr_message_sink;
typedef boost::shared_ptr<gr_message_sink> gr_message_sink_sptr;
-GR_CORE_API gr_message_sink_sptr gr_make_message_sink (size_t itemsize,
- gr_msg_queue_sptr msgq,
- bool dont_block);
+GR_CORE_API gr_message_sink_sptr gr_make_message_sink (
+ size_t itemsize,
+ gr_msg_queue_sptr msgq,
+ bool dont_block
+);
+
+GR_CORE_API gr_message_sink_sptr gr_make_message_sink (
+ size_t itemsize,
+ gr_msg_queue_sptr msgq,
+ bool dont_block,
+ const std::string& lengthtagname
+);
/*!
* \brief Gather received items into messages and insert into msgq
@@ -45,12 +55,21 @@ class GR_CORE_API gr_message_sink : public gr_sync_block
size_t d_itemsize;
gr_msg_queue_sptr d_msgq;
bool d_dont_block;
+ bool d_tags;
+ std::string d_lengthtagname;
+ uint64_t d_items_read;
friend GR_CORE_API gr_message_sink_sptr
- gr_make_message_sink(size_t itemsize, gr_msg_queue_sptr msgq, bool dont_block);
+ gr_make_message_sink(size_t itemsize, gr_msg_queue_sptr msgq,
+ bool dont_block);
+ friend GR_CORE_API gr_message_sink_sptr
+ gr_make_message_sink(size_t itemsize, gr_msg_queue_sptr msgq,
+ bool dont_block, const std::string& lengthtagname);
protected:
gr_message_sink (size_t itemsize, gr_msg_queue_sptr msgq, bool dont_block);
+ gr_message_sink (size_t itemsize, gr_msg_queue_sptr msgq, bool dont_block,
+ const std::string& lengthtagname);
public:
~gr_message_sink ();
diff --git a/gnuradio-core/src/lib/io/gr_message_sink.i b/gnuradio-core/src/lib/io/gr_message_sink.i
index 8415cbd66d..b22eff18c0 100644
--- a/gnuradio-core/src/lib/io/gr_message_sink.i
+++ b/gnuradio-core/src/lib/io/gr_message_sink.i
@@ -22,14 +22,21 @@
GR_SWIG_BLOCK_MAGIC(gr,message_sink);
+#include <string>
+
gr_message_sink_sptr gr_make_message_sink (size_t itemsize,
gr_msg_queue_sptr msgq,
bool dont_block);
+gr_message_sink_sptr gr_make_message_sink (size_t itemsize,
+ gr_msg_queue_sptr msgq,
+ bool dont_block,
+ const std::string& lengthtagname);
class gr_message_sink : public gr_sync_block
{
protected:
gr_message_sink (size_t itemsize, gr_msg_queue_sptr msgq, bool dont_block);
+ gr_message_sink (size_t itemsize, gr_msg_queue_sptr msgq, bool dont_block, const std::string& lengthtagname);
public:
~gr_message_sink ();
diff --git a/gnuradio-core/src/lib/io/gr_message_source.cc b/gnuradio-core/src/lib/io/gr_message_source.cc
index fb3da89a8b..0b79bb526b 100644
--- a/gnuradio-core/src/lib/io/gr_message_source.cc
+++ b/gnuradio-core/src/lib/io/gr_message_source.cc
@@ -36,7 +36,6 @@
// public constructor that returns a shared_ptr
-
gr_message_source_sptr
gr_make_message_source(size_t itemsize, int msgq_limit)
{
@@ -50,11 +49,19 @@ gr_make_message_source(size_t itemsize, gr_msg_queue_sptr msgq)
return gnuradio::get_initial_sptr(new gr_message_source(itemsize, msgq));
}
+// public constructor that takes existing message queue and adds messages length tags.
+gr_message_source_sptr
+gr_make_message_source(size_t itemsize, gr_msg_queue_sptr msgq, const std::string& lengthtagname)
+{
+ return gnuradio::get_initial_sptr(new gr_message_source(itemsize, msgq, lengthtagname));
+}
+
gr_message_source::gr_message_source (size_t itemsize, int msgq_limit)
: gr_sync_block("message_source",
gr_make_io_signature(0, 0, 0),
gr_make_io_signature(1, 1, itemsize)),
- d_itemsize(itemsize), d_msgq(gr_make_msg_queue(msgq_limit)), d_msg_offset(0), d_eof(false)
+ d_itemsize(itemsize), d_msgq(gr_make_msg_queue(msgq_limit)), d_msg_offset(0), d_eof(false),
+ d_tags(false)
{
}
@@ -62,11 +69,19 @@ gr_message_source::gr_message_source (size_t itemsize, gr_msg_queue_sptr msgq)
: gr_sync_block("message_source",
gr_make_io_signature(0, 0, 0),
gr_make_io_signature(1, 1, itemsize)),
- d_itemsize(itemsize), d_msgq(msgq), d_msg_offset(0), d_eof(false)
+ d_itemsize(itemsize), d_msgq(msgq), d_msg_offset(0), d_eof(false), d_tags(false)
{
}
gr_message_source::~gr_message_source()
+{}
+
+gr_message_source::gr_message_source(size_t itemsize, gr_msg_queue_sptr msgq, const std::string& lengthtagname)
+ : gr_sync_block("message_source",
+ gr_make_io_signature(0, 0, 0),
+ gr_make_io_signature(1, 1, itemsize)),
+ d_itemsize(itemsize), d_msgq(msgq), d_msg_offset(0), d_eof(false),
+ d_tags(true), d_lengthtagname(lengthtagname)
{
}
@@ -86,15 +101,21 @@ gr_message_source::work(int noutput_items,
int mm = std::min(noutput_items - nn, (int)((d_msg->length() - d_msg_offset) / d_itemsize));
memcpy (out, &(d_msg->msg()[d_msg_offset]), mm * d_itemsize);
+ if (d_tags && (d_msg_offset == 0)) {
+ const uint64_t offset = this->nitems_written(0) + nn;
+ pmt::pmt_t key = pmt::pmt_string_to_symbol(d_lengthtagname);
+ pmt::pmt_t value = pmt::pmt_from_long(d_msg->length());
+ this->add_item_tag(0, offset, key, value);
+ }
nn += mm;
out += mm * d_itemsize;
d_msg_offset += mm * d_itemsize;
assert(d_msg_offset <= d_msg->length());
if (d_msg_offset == d_msg->length()){
- if (d_msg->type() == 1) // type == 1 sets EOF
- d_eof = true;
- d_msg.reset();
+ if (d_msg->type() == 1) // type == 1 sets EOF
+ d_eof = true;
+ d_msg.reset();
}
}
else {
@@ -102,17 +123,17 @@ gr_message_source::work(int noutput_items,
// No current message
//
if (d_msgq->empty_p() && nn > 0){ // no more messages in the queue, return what we've got
- break;
+ break;
}
-
+
if (d_eof)
- return -1;
-
+ return -1;
+
d_msg = d_msgq->delete_head(); // block, waiting for a message
d_msg_offset = 0;
-
+
if ((d_msg->length() % d_itemsize) != 0)
- throw std::runtime_error("msg length is not a multiple of d_itemsize");
+ throw std::runtime_error("msg length is not a multiple of d_itemsize");
}
}
diff --git a/gnuradio-core/src/lib/io/gr_message_source.h b/gnuradio-core/src/lib/io/gr_message_source.h
index c510d1775f..1828475987 100644
--- a/gnuradio-core/src/lib/io/gr_message_source.h
+++ b/gnuradio-core/src/lib/io/gr_message_source.h
@@ -33,6 +33,8 @@ typedef boost::shared_ptr<gr_message_source> gr_message_source_sptr;
GR_CORE_API gr_message_source_sptr gr_make_message_source (size_t itemsize, int msgq_limit=0);
GR_CORE_API gr_message_source_sptr gr_make_message_source (size_t itemsize, gr_msg_queue_sptr msgq);
+GR_CORE_API gr_message_source_sptr gr_make_message_source (size_t itemsize, gr_msg_queue_sptr msgq,
+ const std::string& lengthtagname);
/*!
* \brief Turn received messages into a stream
@@ -46,15 +48,21 @@ class GR_CORE_API gr_message_source : public gr_sync_block
gr_message_sptr d_msg;
unsigned d_msg_offset;
bool d_eof;
+ bool d_tags;
+ // FIXME: Is this adequate tagname length.
+ std::string d_lengthtagname;
friend GR_CORE_API gr_message_source_sptr
- gr_make_message_source(size_t itemsize, int msgq_limit);
+ gr_make_message_source(size_t itemsize, int msgq_limit);
friend GR_CORE_API gr_message_source_sptr
- gr_make_message_source(size_t itemsize, gr_msg_queue_sptr msgq);
+ gr_make_message_source(size_t itemsize, gr_msg_queue_sptr msgq);
+ friend GR_CORE_API gr_message_source_sptr
+ gr_make_message_source(size_t itemsize, gr_msg_queue_sptr msgq, const std::string& lengthtagname);
protected:
gr_message_source (size_t itemsize, int msgq_limit);
gr_message_source (size_t itemsize, gr_msg_queue_sptr msgq);
+ gr_message_source (size_t itemsize, gr_msg_queue_sptr msgq, const std::string& lengthtagname);
public:
~gr_message_source ();
diff --git a/gnuradio-core/src/lib/io/gr_message_source.i b/gnuradio-core/src/lib/io/gr_message_source.i
index 9ee9157e8c..bb1ddfcc31 100644
--- a/gnuradio-core/src/lib/io/gr_message_source.i
+++ b/gnuradio-core/src/lib/io/gr_message_source.i
@@ -22,14 +22,18 @@
GR_SWIG_BLOCK_MAGIC(gr,message_source);
+#include <string>
+
gr_message_source_sptr gr_make_message_source (size_t itemsize, int msgq_limit=0);
gr_message_source_sptr gr_make_message_source (size_t itemsize, gr_msg_queue_sptr msgq);
+gr_message_source_sptr gr_make_message_source (size_t itemsize, gr_msg_queue_sptr msgq, const std::string& lengthtagname);
class gr_message_source : public gr_sync_block
{
protected:
gr_message_source (size_t itemsize, int msgq_limit);
gr_message_source (size_t itemsize, gr_msg_queue_sptr msgq);
+ gr_message_source (size_t itemsize, gr_msg_queue_sptr msgq, const std::string& lengthtagname);
public:
~gr_message_source ();
diff --git a/gnuradio-core/src/lib/io/gr_pdu.h b/gnuradio-core/src/lib/io/gr_pdu.h
index a5ae87db7f..53058ccb6c 100644
--- a/gnuradio-core/src/lib/io/gr_pdu.h
+++ b/gnuradio-core/src/lib/io/gr_pdu.h
@@ -23,17 +23,18 @@
#ifndef GR_PDU_H
#define GR_PDU_H
+#include <gr_core_api.h>
#include <gr_complex.h>
#include <gruel/pmt.h>
-#define pdu_port_id pmt::mp("pdus")
-#define pdu_length_tag pmt::mp("pdu_length")
+#define PDU_PORT_ID pmt::mp("pdus")
+#define PDU_LENGTH_TAG pmt::mp("pdu_length")
enum gr_pdu_vector_type { pdu_byte, pdu_float, pdu_complex };
-size_t gr_pdu_itemsize(gr_pdu_vector_type type);
-bool gr_pdu_type_matches(gr_pdu_vector_type type, pmt::pmt_t v);
-pmt::pmt_t gr_pdu_make_vector(gr_pdu_vector_type type, const uint8_t* buf, size_t items);
-gr_pdu_vector_type type_from_pmt(pmt::pmt_t vector);
+GR_CORE_API size_t gr_pdu_itemsize(gr_pdu_vector_type type);
+GR_CORE_API bool gr_pdu_type_matches(gr_pdu_vector_type type, pmt::pmt_t v);
+GR_CORE_API pmt::pmt_t gr_pdu_make_vector(gr_pdu_vector_type type, const uint8_t* buf, size_t items);
+GR_CORE_API gr_pdu_vector_type type_from_pmt(pmt::pmt_t vector);
#endif
diff --git a/gnuradio-core/src/lib/io/gr_pdu_to_tagged_stream.cc b/gnuradio-core/src/lib/io/gr_pdu_to_tagged_stream.cc
index 5c319dc39d..a702b66a2b 100644
--- a/gnuradio-core/src/lib/io/gr_pdu_to_tagged_stream.cc
+++ b/gnuradio-core/src/lib/io/gr_pdu_to_tagged_stream.cc
@@ -49,7 +49,7 @@ gr_pdu_to_tagged_stream::gr_pdu_to_tagged_stream (gr_pdu_vector_type t)
gr_make_io_signature(1, 1, gr_pdu_itemsize(t))),
d_vectortype(t), d_itemsize(gr_pdu_itemsize(t))
{
- message_port_register_in(pdu_port_id);
+ message_port_register_in(PDU_PORT_ID);
}
gr_pdu_to_tagged_stream::~gr_pdu_to_tagged_stream()
@@ -77,8 +77,8 @@ gr_pdu_to_tagged_stream::work(int noutput_items,
if(noutput_items > 0){
// grab a message if one exists
- //pmt::pmt_t msg( delete_head_nowait( pdu_port_id ) );
- pmt::pmt_t msg( delete_head_blocking( pdu_port_id ) );
+ //pmt::pmt_t msg( delete_head_nowait( PDU_PORT_ID ) );
+ pmt::pmt_t msg( delete_head_blocking( PDU_PORT_ID ) );
if(msg.get() == NULL ){
return nout;
}
@@ -99,7 +99,7 @@ gr_pdu_to_tagged_stream::work(int noutput_items,
uint64_t offset = nitems_written(0) + nout;
// add a tag for pdu length
- add_item_tag(0, offset, pdu_length_tag, pmt::pmt_from_long( pmt::pmt_length(vect) ), pmt::mp(alias()));
+ add_item_tag(0, offset, PDU_LENGTH_TAG, pmt::pmt_from_long( pmt::pmt_length(vect) ), pmt::mp(alias()));
// if we recieved metadata add it as tags
if( !pmt_eq(meta, pmt::PMT_NIL) ){
diff --git a/gnuradio-core/src/lib/io/gr_tagged_stream_to_pdu.cc b/gnuradio-core/src/lib/io/gr_tagged_stream_to_pdu.cc
index 8211b7672d..1b869edfab 100644
--- a/gnuradio-core/src/lib/io/gr_tagged_stream_to_pdu.cc
+++ b/gnuradio-core/src/lib/io/gr_tagged_stream_to_pdu.cc
@@ -49,7 +49,7 @@ gr_tagged_stream_to_pdu::gr_tagged_stream_to_pdu (gr_pdu_vector_type t)
d_vectortype(t), d_itemsize(gr_pdu_itemsize(t)), d_inpdu(false),
d_pdu_meta(pmt::PMT_NIL), d_pdu_vector(pmt::PMT_NIL)
{
- message_port_register_out(pdu_port_id);
+ message_port_register_out(PDU_PORT_ID);
}
gr_tagged_stream_to_pdu::~gr_tagged_stream_to_pdu()
@@ -70,7 +70,7 @@ gr_tagged_stream_to_pdu::work(int noutput_items,
get_tags_in_range(d_tags, 0, abs_N, abs_N+1);
bool found_length_tag(false);
for(d_tags_itr = d_tags.begin(); (d_tags_itr != d_tags.end()) && (!found_length_tag); d_tags_itr++){
- if( pmt::pmt_equal( (*d_tags_itr).key, pdu_length_tag ) ){
+ if( pmt::pmt_equal( (*d_tags_itr).key, PDU_LENGTH_TAG ) ){
if( (*d_tags_itr).offset != abs_N ){
throw std::runtime_error("expected next pdu length tag on a different item...");
}
@@ -91,7 +91,7 @@ gr_tagged_stream_to_pdu::work(int noutput_items,
// copy any tags in this range into our meta object
get_tags_in_range(d_tags, 0, abs_N, abs_N+ncopy);
for(d_tags_itr = d_tags.begin(); d_tags_itr != d_tags.end(); d_tags_itr++){
- if( ! pmt_equal( (*d_tags_itr).key, pdu_length_tag ) ){
+ if( ! pmt_equal( (*d_tags_itr).key, PDU_LENGTH_TAG ) ){
d_pdu_meta = pmt_dict_add(d_pdu_meta, (*d_tags_itr).key, (*d_tags_itr).value);
}
}
@@ -127,7 +127,7 @@ void gr_tagged_stream_to_pdu::send_message(){
}
pmt::pmt_t msg = pmt::pmt_cons( d_pdu_meta, d_pdu_vector );
- message_port_pub( pdu_port_id, msg );
+ message_port_pub( PDU_PORT_ID, msg );
d_pdu_meta = pmt::PMT_NIL;
d_pdu_vector = pmt::PMT_NIL;
diff --git a/gnuradio-core/src/lib/runtime/CMakeLists.txt b/gnuradio-core/src/lib/runtime/CMakeLists.txt
index 70938a0f17..80db1e7e7e 100644
--- a/gnuradio-core/src/lib/runtime/CMakeLists.txt
+++ b/gnuradio-core/src/lib/runtime/CMakeLists.txt
@@ -62,6 +62,7 @@ list(APPEND gnuradio_core_sources
${CMAKE_CURRENT_SOURCE_DIR}/gr_error_handler.cc
${CMAKE_CURRENT_SOURCE_DIR}/gr_io_signature.cc
${CMAKE_CURRENT_SOURCE_DIR}/gr_local_sighandler.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/gr_logger.cc
${CMAKE_CURRENT_SOURCE_DIR}/gr_message.cc
${CMAKE_CURRENT_SOURCE_DIR}/gr_msg_accepter.cc
${CMAKE_CURRENT_SOURCE_DIR}/gr_msg_handler.cc
@@ -78,6 +79,7 @@ list(APPEND gnuradio_core_sources
${CMAKE_CURRENT_SOURCE_DIR}/gr_sync_decimator.cc
${CMAKE_CURRENT_SOURCE_DIR}/gr_sync_interpolator.cc
${CMAKE_CURRENT_SOURCE_DIR}/gr_sys_paths.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/gr_tagged_stream_block.cc
${CMAKE_CURRENT_SOURCE_DIR}/gr_top_block.cc
${CMAKE_CURRENT_SOURCE_DIR}/gr_top_block_impl.cc
${CMAKE_CURRENT_SOURCE_DIR}/gr_tpb_detail.cc
@@ -105,6 +107,7 @@ list(APPEND test_gnuradio_core_sources
${CMAKE_CURRENT_SOURCE_DIR}/qa_block_tags.cc
${CMAKE_CURRENT_SOURCE_DIR}/qa_runtime.cc
${CMAKE_CURRENT_SOURCE_DIR}/qa_set_msg_handler.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_logger.cc
)
########################################################################
@@ -126,6 +129,7 @@ install(FILES
${CMAKE_CURRENT_SOURCE_DIR}/gr_error_handler.h
${CMAKE_CURRENT_SOURCE_DIR}/gr_io_signature.h
${CMAKE_CURRENT_SOURCE_DIR}/gr_local_sighandler.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/gr_logger.h
${CMAKE_CURRENT_SOURCE_DIR}/gr_message.h
${CMAKE_CURRENT_SOURCE_DIR}/gr_msg_accepter.h
${CMAKE_CURRENT_SOURCE_DIR}/gr_msg_handler.h
@@ -143,6 +147,7 @@ install(FILES
${CMAKE_CURRENT_SOURCE_DIR}/gr_sync_block.h
${CMAKE_CURRENT_SOURCE_DIR}/gr_sync_decimator.h
${CMAKE_CURRENT_SOURCE_DIR}/gr_sync_interpolator.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/gr_tagged_stream_block.h
${CMAKE_CURRENT_SOURCE_DIR}/gr_top_block.h
${CMAKE_CURRENT_SOURCE_DIR}/gr_top_block_impl.h
${CMAKE_CURRENT_SOURCE_DIR}/gr_tpb_detail.h
@@ -170,6 +175,7 @@ install(FILES
${CMAKE_CURRENT_SOURCE_DIR}/gr_dispatcher.i
${CMAKE_CURRENT_SOURCE_DIR}/gr_error_handler.i
${CMAKE_CURRENT_SOURCE_DIR}/gr_io_signature.i
+ ${CMAKE_CURRENT_SOURCE_DIR}/gr_logger.i
${CMAKE_CURRENT_SOURCE_DIR}/gr_message.i
${CMAKE_CURRENT_SOURCE_DIR}/gr_msg_handler.i
${CMAKE_CURRENT_SOURCE_DIR}/gr_msg_queue.i
@@ -178,10 +184,12 @@ install(FILES
${CMAKE_CURRENT_SOURCE_DIR}/gr_sync_block.i
${CMAKE_CURRENT_SOURCE_DIR}/gr_sync_decimator.i
${CMAKE_CURRENT_SOURCE_DIR}/gr_sync_interpolator.i
+ ${CMAKE_CURRENT_SOURCE_DIR}/gr_tagged_stream_block.i
${CMAKE_CURRENT_SOURCE_DIR}/gr_tags.i
${CMAKE_CURRENT_SOURCE_DIR}/gr_top_block.i
${CMAKE_CURRENT_SOURCE_DIR}/runtime.i
DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig
COMPONENT "core_swig"
)
+
endif(ENABLE_PYTHON)
diff --git a/gnuradio-core/src/lib/runtime/gr_block.cc b/gnuradio-core/src/lib/runtime/gr_block.cc
index 54d2676203..4950e8666c 100644
--- a/gnuradio-core/src/lib/runtime/gr_block.cc
+++ b/gnuradio-core/src/lib/runtime/gr_block.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004,2009,2010 Free Software Foundation, Inc.
+ * Copyright 2004,2009,2010,2013 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -29,6 +29,7 @@
#include <stdexcept>
#include <iostream>
#include <gr_block_registry.h>
+#include <gr_prefs.h>
gr_block::gr_block (const std::string &name,
gr_io_signature_sptr input_signature,
@@ -49,6 +50,52 @@ gr_block::gr_block (const std::string &name,
d_min_output_buffer(std::max(output_signature->max_streams(),1), -1)
{
global_block_registry.register_primitive(alias(), this);
+
+#ifdef ENABLE_GR_LOG
+#ifdef HAVE_LOG4CPP
+ gr_prefs *p = gr_prefs::singleton();
+ std::string config_file = p->get_string("LOG", "log_config", "");
+ std::string log_level = p->get_string("LOG", "log_level", "off");
+ std::string log_file = p->get_string("LOG", "log_file", "");
+ std::string debug_level = p->get_string("LOG", "debug_level", "off");
+ std::string debug_file = p->get_string("LOG", "debug_file", "");
+
+ GR_CONFIG_LOGGER(config_file);
+
+ GR_LOG_GETLOGGER(LOG, "gr_log." + alias());
+ GR_LOG_SET_LEVEL(LOG, log_level);
+ if(log_file.size() > 0) {
+ if(log_file == "stdout") {
+ GR_LOG_ADD_CONSOLE_APPENDER(LOG, "cout","gr::log :%p: %c{1} - %m%n");
+ }
+ else if(log_file == "stderr") {
+ GR_LOG_ADD_CONSOLE_APPENDER(LOG, "cerr","gr::log :%p: %c{1} - %m%n");
+ }
+ else {
+ GR_LOG_ADD_FILE_APPENDER(LOG, log_file , true,"%r :%p: %c{1} - %m%n");
+ }
+ }
+ d_logger = LOG;
+
+ GR_LOG_GETLOGGER(DLOG, "gr_log_debug." + alias());
+ GR_LOG_SET_LEVEL(DLOG, debug_level);
+ if(debug_file.size() > 0) {
+ if(debug_file == "stdout") {
+ GR_LOG_ADD_CONSOLE_APPENDER(DLOG, "cout","gr::debug :%p: %c{1} - %m%n");
+ }
+ else if(debug_file == "stderr") {
+ GR_LOG_ADD_CONSOLE_APPENDER(DLOG, "cerr", "gr::debug :%p: %c{1} - %m%n");
+ }
+ else {
+ GR_LOG_ADD_FILE_APPENDER(DLOG, debug_file, true, "%r :%p: %c{1} - %m%n");
+ }
+ }
+ d_debug_logger = DLOG;
+#endif /* HAVE_LOG4CPP */
+#else /* ENABLE_GR_LOG */
+ d_logger = NULL;
+ d_debug_logger = NULL;
+#endif /* ENABLE_GR_LOG */
}
gr_block::~gr_block ()
diff --git a/gnuradio-core/src/lib/runtime/gr_block.h b/gnuradio-core/src/lib/runtime/gr_block.h
index 0783e86848..e4b30267e6 100644
--- a/gnuradio-core/src/lib/runtime/gr_block.h
+++ b/gnuradio-core/src/lib/runtime/gr_block.h
@@ -26,6 +26,7 @@
#include <gr_core_api.h>
#include <gr_basic_block.h>
#include <gr_tags.h>
+#include <gr_logger.h>
/*!
* \brief The abstract base class for all 'terminal' processing blocks.
@@ -616,6 +617,11 @@ class GR_CORE_API gr_block : public gr_basic_block {
*/
gruel::mutex d_setlock;
+ /*! Used by blocks to access the logger system.
+ */
+ gr_logger_ptr d_logger;
+ gr_logger_ptr d_debug_logger;
+
// These are really only for internal use, but leaving them public avoids
// having to work up an ever-varying list of friend GR_CORE_APIs
diff --git a/gnuradio-core/src/lib/runtime/gr_logger.cc b/gnuradio-core/src/lib/runtime/gr_logger.cc
new file mode 100644
index 0000000000..530c66f964
--- /dev/null
+++ b/gnuradio-core/src/lib/runtime/gr_logger.cc
@@ -0,0 +1,204 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 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.
+ */
+
+/*******************************************************************************
+* Author: Mark Plett
+* Description:
+* The gr_log module wraps the log4cpp library for logging in gnuradio.
+*******************************************************************************/
+
+//#ifdef HAVE_CONFIG_H
+//#include "config.h"
+//#endif
+
+#include <gr_logger.h>
+#include <stdexcept>
+#include <algorithm>
+
+#ifdef ENABLE_GR_LOG
+#ifdef HAVE_LOG4CPP
+
+bool gr_logger_configured(false);
+
+void
+logger_load_config(const std::string &config_filename)
+{
+ if(!gr_logger_configured){
+ gr_logger_configured = true;
+ if(config_filename.size() != 0) {
+ try
+ {
+ log4cpp::PropertyConfigurator::configure(config_filename);
+ }
+ catch( log4cpp::ConfigureFailure &e )
+ {
+ std::cout << "Logger config failed :" << e.what() << std::endl;
+ }
+ };
+ };
+}
+
+void
+logger_load_config_and_watch(const std::string &config_filename,
+ unsigned int watch_period)
+{
+// NOTE:: NEEDS CODE TO WATCH FILE HERE
+ if(!gr_logger_configured){
+ gr_logger_configured = true;
+ if(config_filename.size() != 0) {
+ try
+ {
+ log4cpp::PropertyConfigurator::configure(config_filename);
+ }
+ catch( log4cpp::ConfigureFailure &e )
+ {
+ std::cout << "Logger config failed :" << e.what() << std::endl;
+ }
+ };
+ };
+}
+
+void
+logger_reset_config(void){
+ std::vector<log4cpp::Category*> *loggers = log4cpp::Category::getCurrentCategories();
+ std::vector<log4cpp::Category*>::iterator logger = loggers->begin();
+// We can't destroy categories but we can neuter them by removing all appenders.
+ for (;logger!=loggers->end();logger++){
+ (*logger)->removeAllAppenders();
+ };
+}
+
+void
+logger_set_level(gr_logger_ptr logger, const std::string &level)
+{
+ std::string nocase = level;
+ std::transform(level.begin(), level.end(), nocase.begin(), ::tolower);
+
+ if(nocase == "off" || nocase == "notset")
+ logger_set_level(logger, log4cpp::Priority::NOTSET);
+ else if(nocase == "debug")
+ logger_set_level(logger, log4cpp::Priority::DEBUG);
+ else if(nocase == "info")
+ logger_set_level(logger, log4cpp::Priority::INFO);
+ else if(nocase == "notice")
+ logger_set_level(logger, log4cpp::Priority::NOTICE);
+ else if(nocase == "warn")
+ logger_set_level(logger, log4cpp::Priority::WARN);
+ else if(nocase == "error")
+ logger_set_level(logger, log4cpp::Priority::ERROR);
+ else if(nocase == "crit")
+ logger_set_level(logger, log4cpp::Priority::CRIT);
+ else if(nocase == "alert")
+ logger_set_level(logger, log4cpp::Priority::ALERT);
+ else if(nocase=="fatal")
+ logger_set_level(logger, log4cpp::Priority::FATAL);
+ else if(nocase == "all" || nocase == "emerg")
+ logger_set_level(logger, log4cpp::Priority::EMERG);
+ else
+ throw std::runtime_error("logger_set_level: Bad level type.\n");
+}
+
+void
+logger_set_level(gr_logger_ptr logger, log4cpp::Priority::Value level)
+{
+ logger->setPriority(level);
+}
+
+void
+logger_get_level(gr_logger_ptr logger, std::string &level)
+{
+ log4cpp::Priority::Value levelPtr = logger->getPriority();
+ if(levelPtr == log4cpp::Priority::NOTSET) level = "noset";
+ if(levelPtr == log4cpp::Priority::DEBUG) level = "debug";
+ if(levelPtr == log4cpp::Priority::INFO) level = "info";
+ if(levelPtr == log4cpp::Priority::NOTICE) level = "notice";
+ if(levelPtr == log4cpp::Priority::WARN) level = "warn";
+ if(levelPtr == log4cpp::Priority::ERROR) level = "error";
+ if(levelPtr == log4cpp::Priority::CRIT) level = "crit";
+ if(levelPtr == log4cpp::Priority::ALERT) level = "alert";
+ if(levelPtr == log4cpp::Priority::FATAL) level = "fatal";
+ if(levelPtr == log4cpp::Priority::EMERG) level = "emerg";
+};
+
+void
+logger_get_level(gr_logger_ptr logger,log4cpp::Priority::Value level)
+{
+ level = logger->getPriority();
+}
+
+void
+logger_add_console_appender(gr_logger_ptr logger,std::string target,std::string pattern)
+{
+
+ log4cpp::PatternLayout* layout = new log4cpp::PatternLayout();
+ log4cpp::Appender* app;
+ if(target=="cout")
+ app = new log4cpp::OstreamAppender("ConsoleAppender::",&std::cout);
+ else
+ app = new log4cpp::OstreamAppender("ConsoleAppender::",&std::cerr);
+
+ layout->setConversionPattern(pattern);
+ app->setLayout(layout);
+ logger->setAppender(app);
+
+}
+
+void
+logger_add_file_appender(gr_logger_ptr logger,std::string filename,bool append,std::string pattern)
+{
+
+ log4cpp::PatternLayout* layout = new log4cpp::PatternLayout();
+ log4cpp::Appender* app = new
+ log4cpp::FileAppender("FileAppender::"+filename,
+ filename);
+ layout->setConversionPattern(pattern);
+ app->setLayout(layout);
+ logger->setAppender(app);
+
+}
+
+void
+logger_add_rollingfile_appender(gr_logger_ptr logger,std::string filename,
+ size_t filesize,int bkup_index,bool append,mode_t mode,std::string pattern)
+{
+ log4cpp::PatternLayout* layout = new log4cpp::PatternLayout();
+ log4cpp::Appender* app = new
+ log4cpp::RollingFileAppender("RollFileAppender::"+filename,filename,filesize,bkup_index,append,mode);
+ layout->setConversionPattern(pattern);
+ app->setLayout(layout);
+ logger->setAppender(app);
+}
+
+void
+logger_get_logger_names(std::vector<std::string>& names){
+ std::vector<log4cpp::Category*> *loggers = log4cpp::Category::getCurrentCategories();
+ std::vector<log4cpp::Category*>::iterator logger = loggers->begin();
+
+ names.clear();
+ for (;logger!=loggers->end();logger++){
+ names.push_back((*logger)->getName());
+ };
+
+}
+
+#endif /* HAVE_LOG4CPP */
+#endif /* ENABLE_GR_LOGGER */
diff --git a/gnuradio-core/src/lib/runtime/gr_logger.h b/gnuradio-core/src/lib/runtime/gr_logger.h
new file mode 100644
index 0000000000..2ccd498822
--- /dev/null
+++ b/gnuradio-core/src/lib/runtime/gr_logger.h
@@ -0,0 +1,564 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2012-2013 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.
+ */
+
+/*******************************************************************************
+* Author: Mark Plett
+* Description:
+* The gr_logger module wraps the log4cpp library for logging in gnuradio
+*******************************************************************************/
+
+#ifndef INCLUDED_GR_LOGGER_H
+#define INCLUDED_GR_LOGGER_H
+
+/*!
+* \file gr_logger.h
+* \ingroup logging
+* \brief GNURADIO logging wrapper for log4cpp library (C++ port of log4j)
+*
+*/
+
+#ifndef ENABLE_GR_LOG
+#include "config.h"
+//#define GR_LOG_CONFIG_H
+#endif
+
+#include <gr_core_api.h>
+#include <assert.h>
+#include <iostream>
+
+//#ifndef ENABLE_GR_LOG
+//#define ENABLE_GR_LOG 1
+//#endif
+//#ifndef HAVE_LOG4CPP
+//#define HAVE_LOG4CPP 2
+//#endif
+
+#ifdef ENABLE_GR_LOG
+
+// We have three configurations... first logging to stdout/stderr
+#ifndef HAVE_LOG4CPP
+//#warning GR logging Enabled and using std::cout
+
+typedef std::string gr_logger_ptr;
+
+#define GR_LOG_DECLARE_LOGPTR(logger)
+#define GR_LOG_ASSIGN_LOGPTR(logger,name)
+#define GR_CONFIG_LOGGER(config)
+#define GR_CONFIG_AND_WATCH_LOGGER(config,period)
+#define GR_LOG_GETLOGGER(logger, name)
+#define GR_SET_LEVEL(name, level)
+#define GR_LOG_SET_LEVEL(logger, level)
+#define GR_GET_LEVEL(name, level)
+#define GR_LOG_GET_LEVEL(logger, level)
+#define GR_ADD_CONSOLE_APPENDER(logger,target,pattern)
+#define GR_LOG_ADD_CONSOLE_APPENDER(logger,target,pattern)
+#define GR_ADD_FILE_APPENDER(name,filename,append,pattern)
+#define GR_LOG_ADD_FILE_APPENDER(logger,filename,append,pattern)
+#define GR_ADD_ROLLINGFILE_APPENDER(name,filename,filesize,bkup_index,append,mode,pattern)
+#define GR_LOG_ADD_ROLLINGFILE_APPENDER(logger,filename,filesize,bkup_index,append,mode,pattern)
+#define GR_GET_LOGGER_NAMES(names)
+#define GR_RESET_CONFIGURATION()
+#define GR_DEBUG(name, msg) std::cout<<"DEBUG: "<<msg<<std::endl
+#define GR_INFO(name, msg) std::cout<<"INFO: "<<msg<<std::endl
+#define GR_NOTICE(name, msg) std::cout<<"NOTICE: "<<msg<<std::endl
+#define GR_WARN(name, msg) std::cerr<<"WARN: "<<msg<<std::endl
+#define GR_ERROR(name, msg) std::cerr<<"ERROR: "<<msg<<std::endl
+#define GR_ALERT(name, msg) std::cerr<<"ERROR: "<<msg<<std::endl
+#define GR_CRIT(name, msg) std::cerr<<"ERROR: "<<msg<<std::endl
+#define GR_FATAL(name, msg) std::cerr<<"FATAL: "<<msg<<std::endl
+#define GR_EMERG(name, msg) std::cerr<<"EMERG: "<<msg<<std::endl
+#define GR_ERRORIF(name, cond, msg) if((cond)) std::cerr<<"ERROR: "<<msg<<std::endl
+#define GR_ASSERT(name, cond, msg) if(!(cond)) std::cerr<<"ERROR: "<<msg<<std::endl; assert(cond)
+#define GR_LOG_DEBUG(logger, msg) std::cout<<"DEBUG: "<<msg<<std::endl
+#define GR_LOG_INFO(logger, msg) std::cout<<"INFO: "<<msg<<std::endl
+#define GR_LOG_NOTICE(logger, msg) std::cout<<"NOTICE: "<<msg<<std::endl
+#define GR_LOG_WARN(logger, msg) std::cerr<<"WARN: "<<msg<<std::endl
+#define GR_LOG_ERROR(logger, msg) std::cerr<<"ERROR: "<<msg<<std::endl
+#define GR_LOG_ALERT(logger, msg) std::cerr<<"ALERT: "<<msg<<std::endl
+#define GR_LOG_CRIT(logger, msg) std::cerr<<"CRIT: "<<msg<<std::endl
+#define GR_LOG_FATAL(logger, msg) std::cerr<<"FATAL: "<<msg<<std::endl
+#define GR_LOG_EMERG(logger, msg) std::cerr<<"EMERG: "<<msg<<std::endl
+#define GR_LOG_ERRORIF(logger, cond, msg) if((cond)) std::cerr<<"ERROR: "<<msg<<std::endl
+#define GR_LOG_ASSERT(logger, cond, msg) std::cerr<<"ERROR: "<<msg<<std::endl; assert(cond)
+
+#else /* HAVE_LOG4CPP */
+// Second configuration...logging to log4cpp
+
+#include <log4cpp/Category.hh>
+#include <log4cpp/PropertyConfigurator.hh>
+#include <log4cpp/FileAppender.hh>
+#include <log4cpp/RollingFileAppender.hh>
+#include <log4cpp/OstreamAppender.hh>
+#include <log4cpp/PatternLayout.hh>
+
+/*!
+ * \brief GR_LOG macros
+ * \ingroup logging
+ *
+ * These macros wrap the standard LOG4CPP_LEVEL macros. The availablie macros
+ * are:
+ * GR_LOG_DEBUG
+ * GR_LOG_INFO
+ * GR_LOG_WARN
+ * GR_LOG_TRACE
+ * GR_LOG_ERROR
+ * GR_LOG_ALERT
+ * GR_LOG_CRIT
+ * GR_LOG_FATAL
+ * GR_LOG_EMERG
+ */
+typedef log4cpp::Category* gr_logger_ptr;
+
+/* Macros for Programmatic Configuration */
+#define GR_LOG_DECLARE_LOGPTR(logger) \
+ gr_logger_ptr logger;
+
+#define GR_LOG_ASSIGN_LOGPTR(logger,name) \
+ logger = gr_logger::getLogger(name);
+
+#define GR_CONFIG_LOGGER(config) \
+ logger_load_config(config)
+
+#define GR_CONFIG_AND_WATCH_LOGGER(config,period) \
+ logger_load_config_and_watch(config,period)
+
+#define GR_LOG_GETLOGGER(logger, name) \
+ gr_logger_ptr logger = gr_logger::getLogger(name);
+
+#define GR_SET_LEVEL(name, level){ \
+ gr_logger_ptr logger = gr_logger::getLogger(name);\
+ logger_set_level(logger,level);}
+
+#define GR_LOG_SET_LEVEL(logger, level) \
+ logger_set_level(logger, level);
+
+#define GR_GET_LEVEL(name, level){ \
+ gr_logger_ptr logger = gr_logger::getLogger(name);\
+ logger_get_level(logger,level);}
+
+#define GR_LOG_GET_LEVEL(logger, level) \
+ logger_get_level(logger,level);
+
+#define GR_ADD_CONSOLE_APPENDER(name,target,pattern){\
+ gr_logger_ptr logger = gr_logger::getLogger(name);\
+ logger_add_console_appender(logger,target,pattern);}
+
+#define GR_LOG_ADD_CONSOLE_APPENDER(logger,target,pattern){\
+ logger_add_console_appender(logger,target,pattern);}
+
+#define GR_ADD_FILE_APPENDER(name,filename,append,pattern){\
+ gr_logger_ptr logger = gr_logger::getLogger(name);\
+ logger_add_file_appender(logger,filename,append,pattern);}
+
+#define GR_LOG_ADD_FILE_APPENDER(logger,filename,append,pattern){\
+ logger_add_file_appender(logger,filename,append,pattern);}
+
+#define GR_ADD_ROLLINGFILE_APPENDER(name,filename,filesize,bkup_index,append,mode,pattern){\
+ gr_logger_ptr logger = gr_logger::getLogger(name);\
+ logger_add_rollingfile_appender(logger,filename,filesize,bkup_index,append,mode,pattern);}
+
+#define GR_LOG_ADD_ROLLINGFILE_APPENDER(logger,filename,filesize,bkup_index,append,mode,pattern){\
+ logger_add_rollingfile_appender(logger,filename,filesize,bkup_index,append,mode,pattern);}
+
+#define GR_GET_LOGGER_NAMES(names){ \
+ logger_get_logger_names(names);}
+
+#define GR_RESET_CONFIGURATION(){ \
+ logger_reset_config();}
+
+/* Logger name referenced macros */
+#define GR_DEBUG(name, msg) { \
+ gr_logger_ptr logger = gr_logger::getLogger(name);\
+ *logger<< log4cpp::Priority::DEBUG << msg << log4cpp::eol;}
+
+#define GR_INFO(name, msg) { \
+ gr_logger_ptr logger = gr_logger::getLogger(name);\
+ *logger<< log4cpp::Priority::INFO << msg << log4cpp::eol;}
+
+#define GR_NOTICE(name, msg) { \
+ gr_logger_ptr logger = gr_logger::getLogger(name);\
+ *logger << log4cpp::Priority::NOTICE << msg;}
+
+#define GR_WARN(name, msg) { \
+ gr_logger_ptr logger = gr_logger::getLogger(name);\
+ *logger<< log4cpp::Priority::WARN << msg << log4cpp::eol;}
+
+#define GR_ERROR(name, msg) { \
+ gr_logger_ptr logger = gr_logger::getLogger(name);\
+ *logger<< log4cpp::Priority::ERROR << msg << log4cpp::eol;}
+
+#define GR_CRIT(name, msg) { \
+ gr_logger_ptr logger = gr_logger::getLogger(name);\
+ *logger<< log4cpp::Priority::CRIT << msg << log4cpp::eol;}
+
+#define GR_ALERT(name, msg) { \
+ gr_logger_ptr logger = gr_logger::getLogger(name);\
+ *logger<< log4cpp::Priority::ALERT << msg << log4cpp::eol;}
+
+#define GR_FATAL(name, msg) { \
+ gr_logger_ptr logger = gr_logger::getLogger(name);\
+ *logger<< log4cpp::Priority::FATAL << msg << log4cpp::eol;}
+
+#define GR_EMERG(name, msg) { \
+ gr_logger_ptr logger = gr_logger::getLogger(name);\
+ *logger<< log4cpp::Priority::EMERG << msg << log4cpp::eol;}
+
+#define GR_ERRORIF(name, cond, msg) { \
+if((cond)){\
+ gr_logger_ptr logger = gr_logger::getLogger(name);\
+ *logger<< log4cpp::Priority::ERROR << msg << log4cpp::eol;};\
+};
+
+#define GR_ASSERT(name, cond, msg) { \
+if((!cond)){\
+ gr_logger_ptr logger = gr_logger::getLogger(name);\
+ *logger<< log4cpp::Priority::EMERG << msg << log4cpp::eol;};\
+ assert(0);\
+};
+
+/* LoggerPtr Referenced Macros */
+#define GR_LOG_DEBUG(logger, msg) { \
+ *logger << log4cpp::Priority::DEBUG << msg << log4cpp::eol;}
+
+#define GR_LOG_INFO(logger, msg) { \
+ *logger << log4cpp::Priority::INFO << msg << log4cpp::eol;}
+
+#define GR_LOG_NOTICE(logger, msg) { \
+ *logger << log4cpp::Priority::NOTICE << msg << log4cpp::eol;}
+
+#define GR_LOG_WARN(logger, msg) { \
+ *logger << log4cpp::Priority::WARN << msg << log4cpp::eol;}
+
+#define GR_LOG_ERROR(logger, msg) { \
+ *logger << log4cpp::Priority::ERROR << msg << log4cpp::eol;}
+
+#define GR_LOG_CRIT(logger, msg) { \
+ *logger << log4cpp::Priority::CRIT << msg << log4cpp::eol;}
+
+#define GR_LOG_ALERT(logger, msg) { \
+ *logger << log4cpp::Priority::ALERT << msg << log4cpp::eol;}
+
+#define GR_LOG_FATAL(logger, msg) { \
+ *logger << log4cpp::Priority::FATAL << msg << log4cpp::eol;}
+
+#define GR_LOG_EMERG(logger, msg) { \
+ *logger << log4cpp::Priority::EMERG << msg << log4cpp::eol;}
+
+#define GR_LOG_ERRORIF(logger,cond, msg) { \
+if((!cond)){\
+ *logger<< log4cpp::Priority::ERROR << msg << log4cpp::eol;};\
+ assert(0);\
+};
+
+#define GR_LOG_ASSERT(logger, cond, msg) { \
+if((!cond)){\
+ *logger<< log4cpp::Priority::EMERG << msg << log4cpp::eol;};\
+ assert(0);\
+};
+
+/*!
+ * \brief Load logger's configuration file.
+ *
+ * Initialize the GNU Radio logger by loading the configuration file
+ * \p config_filename.
+ *
+ * \param config_filename The configuration file. Set to "" for the
+ * basic logger that outputs to the console.
+ */
+GR_CORE_API void logger_load_config(const std::string &config_filename="");
+
+
+GR_CORE_API void logger_load_config_and_watch(const std::string &config_filename,
+ unsigned int watch_period);
+
+GR_CORE_API void logger_reset_config(void);
+
+/*!
+ * \brief Set the logger's output level.
+ *
+ * Sets the level of the logger. This takes a string that is
+ * translated to the standard levels and can be (case insensitive):
+ *
+ * \li off , notset
+ * \li debug
+ * \li info
+ * \li notice
+ * \li warn
+ * \li error
+ * \li crit
+ * \li alert
+ * \li fatal
+ * \li emerg
+ *
+ * \param logger the logger to set the level of.
+ * \param level string to set the level to.
+ */
+GR_CORE_API void logger_set_level(gr_logger_ptr logger, const std::string &level);
+
+/*!
+ * \brief Set the logger's output level.
+ *
+ * Sets the level of the logger. This takes the actual Log4cpp::Priority
+ * data type, which can be:
+ *
+ * \li log4cpp::Priority::NOTSET
+ * \li log4cpp::Priority::DEBUG
+ * \li log4cpp::Priority::INFO
+ * \li log4cpp::Priority::NOTICE
+ * \li log4cpp::Priority::WARN
+ * \li log4cpp::Priority::ERROR
+ * \li log4cpp::Priority::CRIT
+ * \li log4cpp::Priority::ALERT
+ * \li log4cpp::Priority::FATAL
+ * \li log4cpp::Priority::EMERG
+ *
+ * \param logger the logger to set the level of.
+ * \param level new logger level of type Log4cpp::Priority
+ */
+void logger_set_level(gr_logger_ptr logger, log4cpp::Priority::Value level);
+
+
+/*!
+ * \brief Get the logger's output level.
+ *
+ * Gets the level of the logger. This returns a string that
+ * corresponds to the standard levels and can be (case insensitive):
+ *
+ * \li notset
+ * \li debug
+ * \li info
+ * \li notice
+ * \li warn
+ * \li error
+ * \li crit
+ * \li alert
+ * \li fatal
+ * \li emerg
+ *
+ * \param logger the logger to get the level of.
+ * \param level string to get the level into.
+ */
+GR_CORE_API void logger_get_level(gr_logger_ptr logger, std::string &level);
+
+/*!
+ * \brief Get the logger's output level.
+ *
+ * Gets the level of the logger. This returns the actual Log4cpp::Level
+ * data type, which can be:
+ *
+ * \li log4cpp::Priority::NOTSET
+ * \li log4cpp::Priority::DEBUG
+ * \li log4cpp::Priority::INFO
+ * \li log4cpp::Priority::NOTICE
+ * \li log4cpp::Priority::WARN
+ * \li log4cpp::Priority::ERROR
+ * \li log4cpp::Priority::CRIT
+ * \li log4cpp::Priority::ALERT
+ * \li log4cpp::Priority::FATAL
+ * \li log4cpp::Priority::EMERG
+ *
+ * \param logger the logger to get the level of.
+ * \param level of the logger.
+ */
+GR_CORE_API void logger_get_level(gr_logger_ptr logger, log4cpp::Priority::Value &level);
+
+GR_CORE_API void logger_add_console_appender(gr_logger_ptr logger,std::string target,std::string pattern);
+
+GR_CORE_API void logger_add_file_appender(gr_logger_ptr logger,std::string filename,bool append,std::string pattern);
+
+GR_CORE_API void logger_add_rollingfile_appender(gr_logger_ptr logger,std::string filename,
+ size_t filesize,int bkup_index,bool append,mode_t mode,std::string pattern);
+
+GR_CORE_API void logger_get_logger_names(std::vector<std::string>& names);
+
+/*!
+ * \brief instantiate (configure) logger.
+ * \ingroup logging
+ *
+ */
+class gr_logger
+{
+ public:
+ /*!
+ * \brief contructor take log configuration file and configures loggers.
+ */
+ gr_logger(std::string config_filename)
+ {
+ // Load configuration file
+ logger_load_config(config_filename);
+ };
+
+ /*!
+ * \brief contructor take log configuration file and watchtime and configures
+ */
+ gr_logger(std::string config_filename, int watchPeriodSec)
+ {
+ // Load configuration file
+ logger_load_config_and_watch(config_filename,watchPeriodSec);
+
+ };
+
+ static gr_logger_ptr getLogger(std::string name)
+ {
+ if(log4cpp::Category::exists(name)){
+ gr_logger_ptr logger = &log4cpp::Category::getInstance(name);
+ return logger;
+ }
+ else
+ {
+ gr_logger_ptr logger = &log4cpp::Category::getInstance(name);
+ logger->setPriority(log4cpp::Priority::NOTSET);
+ return logger;
+ };
+ };
+
+ // Wrappers for logging macros
+ /*! \brief inline function, wrapper to set the logger level */
+ void set_level(std::string name,std::string level){GR_SET_LEVEL(name,level);}
+
+ /*! \brief inline function, wrapper to get the logger level */
+ void get_level(std::string name,std::string &level){GR_GET_LEVEL(name,level);}
+
+ /*! \brief inline function, wrapper for DEBUG message */
+ void debug(std::string name,std::string msg){GR_DEBUG(name,msg);};
+
+ /*! \brief inline function, wrapper for INFO message */
+ void info(std::string name,std::string msg){GR_INFO(name,msg);};
+
+ /*! \brief inline function, wrapper for NOTICE message */
+ void notice(std::string name,std::string msg){GR_NOTICE(name,msg);};
+
+ /*! \brief inline function, wrapper for WARN message */
+ void warn(std::string name,std::string msg){GR_WARN(name,msg);};
+
+ /*! \brief inline function, wrapper for ERROR message */
+ void error(std::string name,std::string msg){GR_ERROR(name,msg);};
+
+ /*! \brief inline function, wrapper for CRIT message */
+ void crit(std::string name,std::string msg){GR_CRIT(name,msg);};
+
+ /*! \brief inline function, wrapper for ALERT message */
+ void alert(std::string name,std::string msg){GR_ALERT(name,msg);};
+
+ /*! \brief inline function, wrapper for FATAL message */
+ void fatal(std::string name,std::string msg){GR_FATAL(name,msg);};
+
+ /*! \brief inline function, wrapper for EMERG message */
+ void emerg(std::string name,std::string msg){GR_EMERG(name,msg);};
+
+ /*! \brief inline function, wrapper for LOG4CPP_ASSERT for conditional ERROR message */
+ void errorIF(std::string name,bool cond,std::string msg){GR_ERRORIF(name,cond,msg);};
+
+ /*! \brief inline function, wrapper for LOG4CPP_ASSERT for conditional ERROR message */
+ void gr_assert(std::string name,bool cond,std::string msg){GR_ASSERT(name,cond,msg);};
+
+ // Wrappers for Logger Pointer referenced functions
+ /*! \brief inline function, wrapper to set the logger level */
+ void set_log_level(gr_logger_ptr logger,std::string level){GR_LOG_SET_LEVEL(logger,level);}
+
+ /*! \brief inline function, wrapper to get the logger level */
+ void get_log_level(gr_logger_ptr logger,std::string &level){GR_LOG_GET_LEVEL(logger,level);}
+
+ /*! \brief inline function, wrapper for LOG4CPP_DEBUG for DEBUG message */
+ void log_debug(gr_logger_ptr logger,std::string msg){GR_LOG_DEBUG(logger,msg);};
+
+ /*! \brief inline function, wrapper for LOG4CPP_INFO for INFO message */
+ void log_info(gr_logger_ptr logger,std::string msg){GR_LOG_INFO(logger,msg);};
+
+ /*! \brief inline function, wrapper for NOTICE message */
+ void log_notice(gr_logger_ptr logger,std::string msg){GR_LOG_NOTICE(logger,msg);};
+
+ /*! \brief inline function, wrapper for LOG4CPP_WARN for WARN message */
+ void log_warn(gr_logger_ptr logger,std::string msg){GR_LOG_WARN(logger,msg);};
+
+ /*! \brief inline function, wrapper for LOG4CPP_ERROR for ERROR message */
+ void log_error(gr_logger_ptr logger,std::string msg){GR_LOG_ERROR(logger,msg);};
+
+ /*! \brief inline function, wrapper for NOTICE message */
+ void log_crit(gr_logger_ptr logger,std::string msg){GR_LOG_CRIT(logger,msg);};
+
+ /*! \brief inline function, wrapper for ALERT message */
+ void log_alert(gr_logger_ptr logger,std::string msg){GR_LOG_ALERT(logger,msg);};
+
+ /*! \brief inline function, wrapper for FATAL message */
+ void log_fatal(gr_logger_ptr logger,std::string msg){GR_LOG_FATAL(logger,msg);};
+
+ /*! \brief inline function, wrapper for EMERG message */
+ void log_emerg(gr_logger_ptr logger,std::string msg){GR_LOG_EMERG(logger,msg);};
+
+ /*! \brief inline function, wrapper for LOG4CPP_ASSERT for conditional ERROR message */
+ void log_errorIF(gr_logger_ptr logger,bool cond,std::string msg){GR_LOG_ERRORIF(logger,cond,msg);};
+
+ /*! \brief inline function, wrapper for LOG4CPP_ASSERT for conditional ERROR message */
+ void log_assert(gr_logger_ptr logger,bool cond,std::string msg){GR_LOG_ASSERT(logger,cond,msg);};
+};
+
+
+#endif /* HAVE_LOG4CPP */
+
+// If Logger disable do nothing
+#else /* ENABLE_GR_LOG */
+
+typedef void* gr_logger_ptr;
+
+#define GR_LOG_DECLARE_LOGPTR(logger)
+#define GR_LOG_ASSIGN_LOGPTR(logger,name)
+#define GR_CONFIG_LOGGER(config)
+#define GR_CONFIG_AND_WATCH_LOGGER(config,period)
+#define GR_LOG_GETLOGGER(logger, name)
+#define GR_SET_LEVEL(name, level)
+#define GR_LOG_SET_LEVEL(logger, level)
+#define GR_GET_LEVEL(name, level)
+#define GR_LOG_GET_LEVEL(logger, level)
+#define GR_ADD_CONSOLE_APPENDER(logger,target,pattern)
+#define GR_LOG_ADD_CONSOLE_APPENDER(logger,target,pattern)
+#define GR_ADD_FILE_APPENDER(name,filename,append,pattern)
+#define GR_LOG_ADD_FILE_APPENDER(logger,filename,append,pattern)
+#define GR_ADD_ROLLINGFILE_APPENDER(name,filename,filesize,bkup_index,append,mode,pattern)
+#define GR_LOG_ADD_ROLLINGFILE_APPENDER(logger,filename,filesize,bkup_index,append,mode,pattern)
+#define GR_GET_LOGGER_NAMES(names)
+#define GR_RESET_CONFIGURATION()
+#define GR_DEBUG(name, msg)
+#define GR_INFO(name, msg)
+#define GR_NOTICE(name, msg)
+#define GR_WARN(name, msg)
+#define GR_ERROR(name, msg)
+#define GR_ALERT(name, msg)
+#define GR_CRIT(name, msg)
+#define GR_FATAL(name, msg)
+#define GR_EMERG(name, msg)
+#define GR_ERRORIF(name, cond, msg)
+#define GR_ASSERT(name, cond, msg)
+#define GR_LOG_DEBUG(logger, msg)
+#define GR_LOG_INFO(logger, msg)
+#define GR_LOG_NOTICE(logger, msg)
+#define GR_LOG_WARN(logger, msg)
+#define GR_LOG_ERROR(logger, msg)
+#define GR_LOG_ALERT(logger, msg)
+#define GR_LOG_CRIT(logger, msg)
+#define GR_LOG_FATAL(logger, msg)
+#define GR_LOG_EMERG(logger, msg)
+#define GR_LOG_ERRORIF(logger, cond, msg)
+#define GR_LOG_ASSERT(logger, cond, msg)
+
+#endif /* ENABLE_GR_LOG */
+#endif /* INCLUDED_GR_LOGGER_H */
diff --git a/gnuradio-core/src/lib/runtime/gr_logger.i b/gnuradio-core/src/lib/runtime/gr_logger.i
new file mode 100644
index 0000000000..70e50e02b3
--- /dev/null
+++ b/gnuradio-core/src/lib/runtime/gr_logger.i
@@ -0,0 +1,109 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 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 this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+/*******************************************************************************
+* Copyright 2011 Johns Hopkins University Applied Physics Lab
+* Author: Mark Plett
+* Description:
+* SWIG interface generator file for gr_logger module. gr_logger wraps log4cpp logging
+* for gnuradio.
+*******************************************************************************/
+
+%feature("autodoc", "1"); // generate python docstrings
+
+%include "exception.i"
+%import "gnuradio.i" // the common stuff
+
+%{
+#include "gnuradio_swig_bug_workaround.h" // mandatory bug fix
+#include <stdexcept>
+%}
+
+//-----------------------------------
+
+#ifdef ENABLE_GR_LOG
+#ifdef HAVE_LOG4CPP
+
+%{
+// The .h files
+#include <gr_logger.h>
+#include <log4cpp/Category.hh>
+%}
+
+namespace log4cpp{
+class LoggerPtr {
+public:
+ ~LoggerPtr();
+};
+};
+void logger_load_config(const std::string &config_filename);
+void logger_set_level(log4cpp::LoggerPtr logger, const std::string &level);
+
+%rename(log) gr_logger;
+
+class gr_logger
+{
+private:
+
+public:
+ //gr_logger(std::string config_filename);
+ gr_logger(std::string config_filename,int watchPeriodSec);
+ void set_level(std::string name,std::string level);
+ void get_level(std::string name,std::string &level);
+ void add_console_appender(std::string name,std::string target,std::string pattern);
+ void add_file_appender(std::string name,std::string filename,bool append,std::string patter);
+ void add_rollingfile_appender(std::string name,std::string filename,size_t filesize,int bkup_indx,bool append,mode_t mode,std::string pattern);
+
+ void notice(std::string name,std::string msg);
+ void debug(std::string name,std::string msg);
+ void info(std::string name,std::string msg);
+ void warn(std::string name,std::string msg);
+ void error(std::string name,std::string msg);
+ void emerg(std::string name,std::string msg);
+ void crit(std::string name,std::string msg);
+ void errorIF(std::string name,bool cond,std::string msg);
+ void gr_assert(std::string name,bool cond,std::string msg);
+
+ static gr_logger_ptr getLogger(std::string name);
+
+ void log_set_level(gr_logger_ptr logger,std::string level);
+ void log_get_level(gr_logger_ptr logger,std::string &level);
+ void log_add_console_appender(gr_logger_ptr logger,std::string target,std::string pattern);
+ void log_add_file_appender(gr_logger_ptr logger,std::string filename,bool append,std::string pattern);
+ void log_add_rollingfile_appender(gr_logger_ptr logger,std::string filename,size_t filesize,int bkup_index,bool append,mode_t mode,std::string pattern);
+
+ void log_notice(gr_logger_ptr logger,std::string msg);
+ void log_debug(gr_logger_ptr logger,std::string msg);
+ void log_info(gr_logger_ptr logger,std::string msg);
+ void log_warn(gr_logger_ptr logger,std::string msg);
+ void log_error(gr_logger_ptr logger,std::string msg);
+ void log_crit(gr_logger_ptr logger,std::string msg);
+ void log_emerg(gr_logger_ptr logger,std::string msg);
+ void log_errorIF(gr_logger_ptr logger,bool cond,std::string msg);
+ void log_assert(gr_logger_ptr logger,bool cond,std::string msg);
+
+ void get_logger_names(std::vector<std::string>& names);
+ void reset_configuration();
+
+};
+
+#endif /* HAVE_LOG4CPP */
+#endif /* ENABLE_GR_LOG */
diff --git a/gnuradio-core/src/lib/runtime/gr_tagged_stream_block.cc b/gnuradio-core/src/lib/runtime/gr_tagged_stream_block.cc
new file mode 100644
index 0000000000..3c4a75fd37
--- /dev/null
+++ b/gnuradio-core/src/lib/runtime/gr_tagged_stream_block.cc
@@ -0,0 +1,144 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2013 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gr_tagged_stream_block.h>
+
+gr_tagged_stream_block::gr_tagged_stream_block (const std::string &name,
+ gr_io_signature_sptr input_signature,
+ gr_io_signature_sptr output_signature,
+ const std::string &length_tag_key)
+ : gr_block(name, input_signature, output_signature),
+ d_length_tag_key(pmt::pmt_string_to_symbol(length_tag_key)),
+ d_n_input_items_reqd(input_signature->min_streams(), 0),
+ d_length_tag_key_str(length_tag_key)
+{
+}
+
+
+// This is evil hackery: We trick the scheduler into creating the right number of input items
+void
+gr_tagged_stream_block::forecast (int noutput_items, gr_vector_int &ninput_items_required)
+{
+ unsigned ninputs = ninput_items_required.size();
+ for (unsigned i = 0; i < ninputs; i++) {
+ if (i < d_n_input_items_reqd.size() && d_n_input_items_reqd[i] != 0) {
+ ninput_items_required[i] = d_n_input_items_reqd[i];
+ } else {
+ // If there's no item, there's no tag--so there must at least be one!
+ ninput_items_required[i] = std::max(1, (int) std::floor((double) noutput_items / relative_rate() + 0.5));
+ }
+ }
+}
+
+
+void
+gr_tagged_stream_block::parse_length_tags(
+ const std::vector<std::vector<gr_tag_t> > &tags,
+ gr_vector_int &n_input_items_reqd
+){
+ for (unsigned i = 0; i < tags.size(); i++) {
+ for (unsigned k = 0; k < tags[i].size(); k++) {
+ if (tags[i][k].key == d_length_tag_key) {
+ n_input_items_reqd[i] = pmt::pmt_to_long(tags[i][k].value);
+ remove_item_tag(i, tags[i][k]);
+ }
+ }
+ }
+}
+
+
+int
+gr_tagged_stream_block::calculate_output_stream_length(const gr_vector_int &ninput_items)
+{
+ int noutput_items = *std::max_element(ninput_items.begin(), ninput_items.end());
+ return (int) std::floor(relative_rate() * noutput_items + 0.5);
+}
+
+
+void
+gr_tagged_stream_block::update_length_tags(int n_produced, int n_ports)
+{
+ for (int i = 0; i < n_ports; i++) {
+ add_item_tag(i, nitems_written(i),
+ d_length_tag_key,
+ pmt::pmt_from_long(n_produced)
+ );
+ }
+ return;
+}
+
+
+int
+gr_tagged_stream_block::general_work (int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+{
+ if (d_length_tag_key_str.empty()) {
+ return work(noutput_items, ninput_items, input_items, output_items);
+ }
+
+ if (d_n_input_items_reqd[0] == 0) { // Otherwise, it's already set from a previous call
+ std::vector<std::vector<gr_tag_t> > tags(input_items.size(), std::vector<gr_tag_t>());
+ for (unsigned i = 0; i < input_items.size(); i++) {
+ get_tags_in_range(tags[i], i, nitems_read(i), nitems_read(i)+1);
+ }
+ d_n_input_items_reqd.assign(input_items.size(), -1);
+ parse_length_tags(tags, d_n_input_items_reqd);
+ }
+ for (unsigned i = 0; i < input_items.size(); i++) {
+ if (d_n_input_items_reqd[i] == -1) {
+ throw std::runtime_error("Missing length tag.");
+ }
+ if (d_n_input_items_reqd[i] > ninput_items[i]) {
+ return 0;
+ }
+ }
+
+ int min_output_size = calculate_output_stream_length(d_n_input_items_reqd);
+ if (noutput_items < min_output_size) {
+ set_min_noutput_items(min_output_size);
+ return 0;
+ }
+ set_min_noutput_items(1);
+
+ // WORK CALLED HERE //
+ int n_produced = work(noutput_items, d_n_input_items_reqd, input_items, output_items);
+ //////////////////////
+
+ if (n_produced == WORK_DONE) {
+ return n_produced;
+ }
+ for (int i = 0; i < (int) d_n_input_items_reqd.size(); i++) {
+ consume(i, d_n_input_items_reqd[i]);
+ }
+ update_length_tags(n_produced, output_items.size());
+
+ d_n_input_items_reqd.assign(input_items.size(), 0);
+
+ return n_produced;
+}
+
diff --git a/gnuradio-core/src/lib/runtime/gr_tagged_stream_block.h b/gnuradio-core/src/lib/runtime/gr_tagged_stream_block.h
new file mode 100644
index 0000000000..a9d396c06f
--- /dev/null
+++ b/gnuradio-core/src/lib/runtime/gr_tagged_stream_block.h
@@ -0,0 +1,138 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2013 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_TAGGED_STREAM_BLOCK_H
+#define INCLUDED_GR_TAGGED_STREAM_BLOCK_H
+
+#include <gr_core_api.h>
+#include <gr_block.h>
+
+/*!
+ * \brief Block that operates on PDUs in form of tagged streams
+ * \ingroup base_blk
+ *
+ * Override work to provide the signal processing implementation.
+ */
+class GR_CORE_API gr_tagged_stream_block : public gr_block
+{
+ private:
+ pmt::pmt_t d_length_tag_key; //! This is the key for the tag that stores the PDU length
+ gr_vector_int d_n_input_items_reqd; //! How many input items do I need to process the next PDU?
+
+ protected:
+ std::string d_length_tag_key_str;
+ gr_tagged_stream_block (void){} //allows pure virtual interface sub-classes
+ gr_tagged_stream_block (const std::string &name,
+ gr_io_signature_sptr input_signature,
+ gr_io_signature_sptr output_signature,
+ const std::string &length_tag_key);
+
+ /* \brief Parse all tags on the first sample of a PDU, return the number of items per input
+ * and prune the length tags.
+ *
+ * In most cases, you don't need to override this, unless the number of items read
+ * is not directly coded in one single tag.
+ *
+ * Default behaviour:
+ * - Go through all input ports
+ * - On every input port, search for the tag with the key specified in \p length_tag_key
+ * - Copy that value as an int to the corresponding position in \p n_input_items_reqd
+ * - Remove the length tag.
+ *
+ * \param[in] tags All the tags found on the first item of every input port.
+ * \param[out] n_input_items_reqd Number of items which will be read from every input
+ */
+ virtual void parse_length_tags(
+ const std::vector<std::vector<gr_tag_t> > &tags,
+ gr_vector_int &n_input_items_reqd
+ );
+
+ /* \brief Calculate the number of output items.
+ *
+ * This is basically the inverse function to forecast(): Given a number of input
+ * items, it returns the maximum number of output items.
+ *
+ * You most likely need to override this function, unless your block is a sync
+ * block or integer interpolator/decimator.
+ *
+ */
+ virtual int calculate_output_stream_length(const gr_vector_int &ninput_items);
+
+ /* \brief Set the new length tags on the output stream
+ *
+ * Default behaviour: Set a tag with key \p length_tag_key and
+ * the number of produced items on every output port.
+ *
+ * For anything else, override this.
+ *
+ * \param n_produced Length of the new PDU
+ * \param n_ports Number of output ports
+ */
+ virtual void update_length_tags(int n_produced, int n_ports);
+
+ public:
+
+ /* \brief Don't override this.
+ */
+ void /* final */ forecast (int noutput_items, gr_vector_int &ninput_items_required);
+
+ /* - Reads the number of input items from the tags using parse_length_tags()
+ * - Checks there's enough data on the input and output buffers
+ * - If not, inform the scheduler and do nothing
+ * - Calls work() with the exact number of items per PDU
+ * - Updates the tags using update_length_tags()
+ */
+ int general_work (int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+
+ /*!
+ * \brief Just like gr_block::general_work, but makes sure the input is valid
+ *
+ * The user must override work to define the signal processing code.
+ * Check the documentation for general_work() to see what happens here.
+ *
+ * Like gr_sync_block, this calls consume() for you (it consumes ninput_items[i]
+ * items from the i-th port).
+ *
+ * A note on tag propagation: The PDU length tags are handled by other functions,
+ * but all other tags are handled just as in any other \p gr_block. So, most likely,
+ * you either set the tag propagation policy to TPP_DONT and handle the tag
+ * propagation manually, or you propagate tags through the scheduler and don't
+ * do anything here.
+ *
+ * \param noutput_items The size of the writable output buffer
+ * \param ninput_items The exact size of the items on every input for this particular PDU.
+ * These will be consumed if a length tag key is provided!
+ * \param input_items See gr_block
+ * \param output_items See gr_block
+ */
+ virtual int work (int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items) = 0;
+
+};
+
+#endif /* INCLUDED_GR_TAGGED_STREAM_BLOCK_H */
+
diff --git a/gnuradio-core/src/lib/runtime/gr_tagged_stream_block.i b/gnuradio-core/src/lib/runtime/gr_tagged_stream_block.i
new file mode 100644
index 0000000000..9fc803dca1
--- /dev/null
+++ b/gnuradio-core/src/lib/runtime/gr_tagged_stream_block.i
@@ -0,0 +1,30 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2013 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.
+ */
+class gr_tagged_stream_block : public gr_block
+{
+ protected:
+ gr_tagged_stream_block (const std::string &name,
+ gr_io_signature_sptr input_signature,
+ gr_io_signature_sptr output_signature,
+ const std::string &length_tag_key);
+};
+
diff --git a/gnuradio-core/src/lib/runtime/qa_gr_logger.cc b/gnuradio-core/src/lib/runtime/qa_gr_logger.cc
new file mode 100644
index 0000000000..a8e4a1d766
--- /dev/null
+++ b/gnuradio-core/src/lib/runtime/qa_gr_logger.cc
@@ -0,0 +1,52 @@
+/*
+ * Copyright 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.
+ */
+
+/*
+ * This class gathers together all the test cases for the example
+ * directory into a single test suite. As you create new test cases,
+ * add them here.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <qa_gr_logger.h>
+#include <gr_logger.h>
+
+void
+qa_gr_logger::t1()
+{
+#ifdef ENABLE_GR_LOG
+ // This doesn't really test anything, more just
+ // making sure nothing's gone horribly wrong.
+
+ GR_LOG_GETLOGGER(LOG,"main");
+ GR_ADD_CONSOLE_APPENDER("main","cout","%d{%H:%M:%S} : %m%n");
+ GR_LOG_NOTICE(LOG,"test from c++ NOTICE");
+ GR_LOG_DEBUG(LOG,"test from c++ DEBUG");
+ GR_LOG_INFO(LOG,"test from c++ INFO");
+ GR_LOG_WARN(LOG,"test from c++ WARN");
+ GR_LOG_ERROR(LOG,"test from c++ ERROR");
+ GR_LOG_FATAL(LOG,"test from c++ FATAL");
+ CPPUNIT_ASSERT(true);
+#endif
+}
diff --git a/gnuradio-core/src/lib/runtime/qa_gr_logger.h b/gnuradio-core/src/lib/runtime/qa_gr_logger.h
new file mode 100644
index 0000000000..b0d3711523
--- /dev/null
+++ b/gnuradio-core/src/lib/runtime/qa_gr_logger.h
@@ -0,0 +1,42 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 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 Example 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 Example Public License for more details.
+ *
+ * You should have received a copy of the GNU Example 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_QA_GR_LOG_H
+#define INCLUDED_QA_GR_LOG_H
+
+#include <cppunit/extensions/HelperMacros.h>
+#include <cppunit/TestSuite.h>
+
+//! collect all the tests for the example directory
+
+class qa_gr_logger : public CppUnit::TestCase {
+ public:
+ CPPUNIT_TEST_SUITE(qa_gr_logger);
+ CPPUNIT_TEST(t1);
+ CPPUNIT_TEST_SUITE_END();
+
+ private:
+ void t1();
+
+};
+
+#endif /* INCLUDED_QA_GR_LOG_H */
diff --git a/gnuradio-core/src/lib/runtime/qa_runtime.cc b/gnuradio-core/src/lib/runtime/qa_runtime.cc
index 5e62c79915..62c95ef5c4 100644
--- a/gnuradio-core/src/lib/runtime/qa_runtime.cc
+++ b/gnuradio-core/src/lib/runtime/qa_runtime.cc
@@ -34,6 +34,7 @@
#include <qa_gr_io_signature.h>
#include <qa_gr_block.h>
#include <qa_gr_flowgraph.h>
+#include <qa_gr_logger.h>
#include <qa_gr_top_block.h>
#include <qa_gr_hier_block2.h>
#include <qa_gr_hier_block2_derived.h>
@@ -50,6 +51,7 @@ qa_runtime::suite ()
s->addTest (qa_gr_io_signature::suite ());
s->addTest (qa_gr_block::suite ());
s->addTest (qa_gr_flowgraph::suite ());
+ s->addTest (qa_gr_logger::suite ());
s->addTest (qa_gr_top_block::suite ());
s->addTest (qa_gr_hier_block2::suite ());
s->addTest (qa_gr_hier_block2_derived::suite ());
diff --git a/gnuradio-core/src/lib/runtime/runtime.i b/gnuradio-core/src/lib/runtime/runtime.i
index 8e35df8342..dd7b095547 100644
--- a/gnuradio-core/src/lib/runtime/runtime.i
+++ b/gnuradio-core/src/lib/runtime/runtime.i
@@ -39,7 +39,9 @@
#include <gr_sync_block.h>
#include <gr_sync_decimator.h>
#include <gr_sync_interpolator.h>
+#include <gr_tagged_stream_block.h>
#include <gr_top_block.h>
+#include <gr_logger.h>
%}
%constant int sizeof_char = sizeof(char);
@@ -66,4 +68,6 @@
%include <gr_sync_block.i>
%include <gr_sync_decimator.i>
%include <gr_sync_interpolator.i>
+%include <gr_tagged_stream_block.i>
%include <gr_top_block.i>
+%include <gr_logger.i>
diff --git a/gnuradio-core/src/lib/swig/CMakeLists.txt b/gnuradio-core/src/lib/swig/CMakeLists.txt
index d8a64cc0f6..2c89494e78 100644
--- a/gnuradio-core/src/lib/swig/CMakeLists.txt
+++ b/gnuradio-core/src/lib/swig/CMakeLists.txt
@@ -25,9 +25,19 @@ set(GR_SWIG_INCLUDE_DIRS
${CMAKE_CURRENT_BINARY_DIR}
${GNURADIO_CORE_SWIG_INCLUDE_DIRS}
${GRUEL_INCLUDE_DIRS}
+ ${LOG4CPP_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS}
)
-set(GR_SWIG_LIBRARIES gnuradio-core)
+set(GR_SWIG_LIBRARIES
+ gnuradio-core
+ ${LOG4CPP_LIBRARIES}
+)
+
+# Only use if log4cpp is installed
+# Define ENABLE_GR_LOG for the .i file to ignore it.
+if(ENABLE_GR_LOG)
+ SET(GR_SWIG_FLAGS "-DENABLE_GR_LOG")
+endif(ENABLE_GR_LOG)
link_directories(${Boost_LIBRARY_DIRS})
diff --git a/gnuradio-core/src/lib/swig/gnuradio.i b/gnuradio-core/src/lib/swig/gnuradio.i
index 3a421ad5d6..4378e6aad2 100644
--- a/gnuradio-core/src/lib/swig/gnuradio.i
+++ b/gnuradio-core/src/lib/swig/gnuradio.i
@@ -38,6 +38,7 @@
#include <gr_types.h>
#include <stddef.h> // size_t
#include <complex>
+#include <string.h>
%}
%feature("autodoc","1");
@@ -48,6 +49,7 @@
%include <std_vector.i>
%include <stl.i>
%include <std_except.i>
+%include <std_string.i>
typedef std::complex<float> gr_complex;
typedef std::complex<double> gr_complexd;
@@ -64,7 +66,8 @@ namespace std {
%template() vector<int>;
%template() vector<float>;
%template() vector<double>;
- // %template() std::complex<float>;
+ %template() vector<std::string>;
+ %template() vector<gr_tag_t>;
%template() vector< std::complex<float> >;
%template() vector< std::vector< unsigned char > >;
diff --git a/gnuradio-core/src/lib/swig/gnuradio_swig_bug_workaround.h b/gnuradio-core/src/lib/swig/gnuradio_swig_bug_workaround.h
index 1994f06609..bbbabaf07b 100644
--- a/gnuradio-core/src/lib/swig/gnuradio_swig_bug_workaround.h
+++ b/gnuradio-core/src/lib/swig/gnuradio_swig_bug_workaround.h
@@ -40,6 +40,7 @@ class gr_msg_queue;
class gr_sync_block;
class gr_sync_decimator;
class gr_sync_interpolator;
+class gr_tagged_stream_block;
class gr_top_block;
#endif /* INCLUDED_GNURADIO_SWIG_BUG_WORKAROUND_H */
diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_message_tags.py b/gnuradio-core/src/python/gnuradio/gr/qa_message_tags.py
new file mode 100644
index 0000000000..566a09988e
--- /dev/null
+++ b/gnuradio-core/src/python/gnuradio/gr/qa_message_tags.py
@@ -0,0 +1,26 @@
+import time
+
+from gnuradio import gr, gr_unittest
+
+class test_message_tags (gr_unittest.TestCase):
+
+ def test_1 (self):
+ data = ('hello', 'you', 'there')
+ tx_msgq = gr.msg_queue ()
+ rx_msgq = gr.msg_queue ()
+ for d in data:
+ tx_msgq.insert_tail(gr.message_from_string(d))
+ tb = gr.top_block()
+ src = gr.message_source(gr.sizeof_char, tx_msgq, "packet_length")
+ snk = gr.message_sink(gr.sizeof_char, rx_msgq, False, "packet_length")
+ tb.connect(src, snk)
+ tb.start()
+ time.sleep(1)
+ tb.stop()
+ for d in data:
+ msg = rx_msgq.delete_head()
+ contents = msg.to_string()
+ self.assertEqual(d, contents)
+
+if __name__ == '__main__':
+ gr_unittest.run(test_message_tags, "test_message_tags.xml")
diff --git a/gnuradio-core/src/tests/CMakeLists.txt b/gnuradio-core/src/tests/CMakeLists.txt
index dbd52f05c7..2340f123e1 100644
--- a/gnuradio-core/src/tests/CMakeLists.txt
+++ b/gnuradio-core/src/tests/CMakeLists.txt
@@ -36,6 +36,9 @@ link_directories(
${CPPUNIT_LIBRARY_DIRS}
)
+include_directories(${LOG4CPP_INCLUDE_DIRS})
+link_directories(${LOG4CPP_LIBRARY_DIRS})
+
########################################################################
# Build benchmarks and non-registered tests
########################################################################
diff --git a/gr-analog/grc/analog_plateau_detector_fb.xml b/gr-analog/grc/analog_plateau_detector_fb.xml
new file mode 100644
index 0000000000..f14efc97f4
--- /dev/null
+++ b/gr-analog/grc/analog_plateau_detector_fb.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<block>
+ <name>Plateau Detector</name>
+ <key>analog_plateau_detector_fb</key>
+ <import>from gnuradio import analog</import>
+ <make>analog.plateau_detector_fb($max_len, $threshold)</make>
+ <param>
+ <name>Max. plateau length</name>
+ <key>max_len</key>
+ <type>int</type>
+ </param>
+ <param>
+ <name>Threshold</name>
+ <key>threshold</key>
+ <value>0.9</value>
+ <type>real</type>
+ </param>
+ <sink>
+ <name>in</name>
+ <type>real</type>
+ </sink>
+ <source>
+ <name>out</name>
+ <type>byte</type>
+ </source>
+</block>
diff --git a/gr-analog/include/analog/CMakeLists.txt b/gr-analog/include/analog/CMakeLists.txt
index b113dacc44..f46960c984 100644
--- a/gr-analog/include/analog/CMakeLists.txt
+++ b/gr-analog/include/analog/CMakeLists.txt
@@ -93,6 +93,7 @@ install(FILES
fmdet_cf.h
frequency_modulator_fc.h
phase_modulator_fc.h
+ plateau_detector_fb.h
pll_carriertracking_cc.h
pll_freqdet_cf.h
pll_refout_cc.h
@@ -105,7 +106,7 @@ install(FILES
rail_ff.h
rotator.h
sig_source_waveform.h
- simple_squelch_cc.h
+ simple_squelch_cc.h
DESTINATION ${GR_INCLUDE_DIR}/gnuradio/analog
COMPONENT "analog_devel"
)
diff --git a/gr-analog/include/analog/plateau_detector_fb.h b/gr-analog/include/analog/plateau_detector_fb.h
new file mode 100644
index 0000000000..33629bd18b
--- /dev/null
+++ b/gr-analog/include/analog/plateau_detector_fb.h
@@ -0,0 +1,71 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 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_ANALOG_PLATEAU_DETECTOR_FB_H
+#define INCLUDED_ANALOG_PLATEAU_DETECTOR_FB_H
+
+#include <analog/api.h>
+#include <gr_sync_block.h>
+
+namespace gr {
+ namespace analog {
+
+ /*!
+ * \brief Detects a plateau and marks the middle.
+ *
+ * Detect a plateau of a-priori known height. Input is a stream of floats,
+ * the output is a stream of bytes. Whenever a plateau is detected, the
+ * middle of that plateau is marked with a '1' on the output stream (all
+ * other samples are left at zero).
+ *
+ * You can use this in a Schmidl & Cox synchronisation algorithm to interpret
+ * the output of the normalized correlator. Just pass the length of the cyclic
+ * prefix (in samples) as the max_len parameter).
+ *
+ * Unlike the peak detectors, you must the now the absolute height of the plateau.
+ * Whenever the amplitude exceeds the given threshold, it starts assuming the
+ * presence of a plateau.
+ *
+ * An implicit hysteresis is provided by the fact that after detecting one plateau,
+ * it waits at least max_len samples before the next plateau can be detected.
+ *
+ * \ingroup analog
+ *
+ */
+ class ANALOG_API plateau_detector_fb : virtual public gr_sync_block
+ {
+ public:
+ typedef boost::shared_ptr<plateau_detector_fb> sptr;
+
+ /*!
+ * \param max_len Maximum length of the plateau
+ * \param threshold Anything above this value is considered a plateau
+ */
+ static sptr make(int max_len, float threshold=0.9);
+ };
+
+ } // namespace analog
+} // namespace gr
+
+#endif /* INCLUDED_ANALOG_PLATEAU_DETECTOR_FB_H */
+
diff --git a/gr-analog/lib/CMakeLists.txt b/gr-analog/lib/CMakeLists.txt
index f7d6723b4e..396ff04654 100644
--- a/gr-analog/lib/CMakeLists.txt
+++ b/gr-analog/lib/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright 2012 Free Software Foundation, Inc.
+# Copyright 2012-2013 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -121,6 +121,7 @@ list(APPEND analog_sources
fmdet_cf_impl.cc
frequency_modulator_fc_impl.cc
phase_modulator_fc_impl.cc
+ plateau_detector_fb_impl.cc
pll_carriertracking_cc_impl.cc
pll_freqdet_cf_impl.cc
pll_refout_cc_impl.cc
@@ -135,6 +136,21 @@ list(APPEND analog_sources
sincos.cc
)
+#Add Windows DLL resource file if using MSVC
+IF(MSVC)
+ include(${CMAKE_SOURCE_DIR}/cmake/Modules/GrVersion.cmake)
+
+ configure_file(
+ ${CMAKE_CURRENT_SOURCE_DIR}/gnuradio-analog.rc.in
+ ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-analog.rc
+ @ONLY)
+
+ list(APPEND analog_sources
+ ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-analog.rc
+ )
+
+ENDIF(MSVC)
+
list(APPEND analog_libs
volk
gnuradio-core
diff --git a/gr-analog/lib/gnuradio-analog.rc.in b/gr-analog/lib/gnuradio-analog.rc.in
new file mode 100644
index 0000000000..7c8c1919f0
--- /dev/null
+++ b/gr-analog/lib/gnuradio-analog.rc.in
@@ -0,0 +1,55 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2013 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.
+ */
+
+#include <afxres.h>
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@
+ PRODUCTVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@
+ FILEFLAGSMASK 0x3fL
+#ifndef NDEBUG
+ FILEFLAGS 0x0L
+#else
+ FILEFLAGS 0x1L
+#endif
+ FILEOS VOS__WINDOWS32
+ FILETYPE VFT_DLL
+ FILESUBTYPE VFT2_DRV_INSTALLABLE
+ BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904b0"
+ BEGIN
+ VALUE "FileDescription", "gnuradio-analog"
+ VALUE "FileVersion", "@VERSION@"
+ VALUE "InternalName", "gnuradio-analog.dll"
+ VALUE "LegalCopyright", "Licensed under GPLv3 or any later version"
+ VALUE "OriginalFilename", "gnuradio-analog.dll"
+ VALUE "ProductName", "gnuradio-analog"
+ VALUE "ProductVersion", "@VERSION@"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+ END
diff --git a/gr-analog/lib/plateau_detector_fb_impl.cc b/gr-analog/lib/plateau_detector_fb_impl.cc
new file mode 100644
index 0000000000..0d2890bc55
--- /dev/null
+++ b/gr-analog/lib/plateau_detector_fb_impl.cc
@@ -0,0 +1,82 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gr_io_signature.h>
+#include "plateau_detector_fb_impl.h"
+
+namespace gr {
+ namespace analog {
+
+plateau_detector_fb::sptr
+plateau_detector_fb::make(int max_len, float threshold)
+{
+ return gnuradio::get_initial_sptr (new plateau_detector_fb_impl(max_len, threshold));
+}
+
+plateau_detector_fb_impl::plateau_detector_fb_impl(int max_len, float threshold)
+ : gr_sync_block("plateau_detector_fb",
+ gr_make_io_signature(1, 1, sizeof (float)),
+ gr_make_io_signature(1, 1, sizeof (char))),
+ d_max_len(max_len),
+ d_threshold(threshold)
+{}
+
+plateau_detector_fb_impl::~plateau_detector_fb_impl()
+{
+}
+
+int
+plateau_detector_fb_impl::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+{
+ const float *in = (const float *) input_items[0];
+ unsigned char *out = (unsigned char *) output_items[0];
+ int flank_start;
+
+ memset((void *) out, 0x00, noutput_items);
+ int i;
+ for (i = 0; i < noutput_items; i++) {
+ if (in[i] >= d_threshold) {
+ if (noutput_items-i < 2*d_max_len) { // If we can't finish, come back later
+ break;
+ }
+ flank_start = i;
+ while (i < noutput_items && in[i] >= d_threshold)
+ i++;
+ if ((i - flank_start) > 1) { // 1 Sample is not a plateau
+ out[flank_start + (i-flank_start)/2] = 1;
+ i = std::min(i+d_max_len, noutput_items-1);
+ }
+ }
+ }
+
+ return i;
+}
+
+ } /* namespace analog */
+} /* namespace gr */
+
diff --git a/gr-analog/lib/plateau_detector_fb_impl.h b/gr-analog/lib/plateau_detector_fb_impl.h
new file mode 100644
index 0000000000..daf1dd56d9
--- /dev/null
+++ b/gr-analog/lib/plateau_detector_fb_impl.h
@@ -0,0 +1,50 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 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_ANALOG_PLATEAU_DETECTOR_FB_IMPL_H
+#define INCLUDED_ANALOG_PLATEAU_DETECTOR_FB_IMPL_H
+
+#include <analog/plateau_detector_fb.h>
+
+namespace gr {
+ namespace analog {
+
+class plateau_detector_fb_impl : public plateau_detector_fb
+{
+ private:
+ int d_max_len;
+ float d_threshold;
+
+ public:
+ plateau_detector_fb_impl(int max_len, float threshold);
+ ~plateau_detector_fb_impl();
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+};
+
+ } // namespace analog
+} // namespace gr
+
+#endif /* INCLUDED_ANALOG_PLATEAU_DETECTOR_FB_IMPL_H */
+
diff --git a/gr-analog/python/CMakeLists.txt b/gr-analog/python/CMakeLists.txt
index 1657e5bf32..af4ed578f3 100644
--- a/gr-analog/python/CMakeLists.txt
+++ b/gr-analog/python/CMakeLists.txt
@@ -49,3 +49,4 @@ foreach(py_qa_test_file ${py_qa_test_files})
GR_ADD_TEST(${py_qa_test_name} ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B} ${py_qa_test_file})
endforeach(py_qa_test_file)
endif(ENABLE_TESTING)
+
diff --git a/gr-analog/python/qa_plateau_detector_fb.py b/gr-analog/python/qa_plateau_detector_fb.py
new file mode 100755
index 0000000000..5f8abc74ec
--- /dev/null
+++ b/gr-analog/python/qa_plateau_detector_fb.py
@@ -0,0 +1,46 @@
+#!/usr/bin/env python
+#
+# Copyright 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.
+#
+
+from gnuradio import gr, gr_unittest
+import analog_swig as analog
+
+class qa_plateau_detector_fb (gr_unittest.TestCase):
+
+ def setUp (self):
+ self.tb = gr.top_block ()
+
+ def tearDown (self):
+ self.tb = None
+
+ def test_001_t (self):
+ # | Spur spike 1 | Plateau | Spur spike 2
+ test_signal = (0, 1, .2, .4, .6, .8, 1, 1, 1, 1, 1, .8, .6, .4, 1, 0)
+ expected_sig = (0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0)
+ # | Center of Plateau
+ sink = gr.vector_sink_b()
+ self.tb.connect(gr.vector_source_f(test_signal), analog.plateau_detector_fb(5), sink)
+ self.tb.run ()
+ self.assertEqual(expected_sig, sink.data())
+
+
+if __name__ == '__main__':
+ gr_unittest.run(qa_plateau_detector_fb, "qa_plateau_detector_fb.xml")
diff --git a/gr-analog/swig/analog_swig.i b/gr-analog/swig/analog_swig.i
index 016537c949..96f4e23a8c 100644
--- a/gr-analog/swig/analog_swig.i
+++ b/gr-analog/swig/analog_swig.i
@@ -46,6 +46,7 @@
#include "analog/noise_source_f.h"
#include "analog/noise_source_c.h"
#include "analog/phase_modulator_fc.h"
+#include "analog/plateau_detector_fb.h"
#include "analog/pll_carriertracking_cc.h"
#include "analog/pll_freqdet_cf.h"
#include "analog/pll_refout_cc.h"
@@ -85,6 +86,7 @@
%include "analog/noise_source_f.h"
%include "analog/noise_source_c.h"
%include "analog/phase_modulator_fc.h"
+%include "analog/plateau_detector_fb.h"
%include "analog/pll_carriertracking_cc.h"
%include "analog/pll_freqdet_cf.h"
%include "analog/pll_refout_cc.h"
@@ -120,6 +122,7 @@ GR_SWIG_BLOCK_MAGIC2(analog, noise_source_i);
GR_SWIG_BLOCK_MAGIC2(analog, noise_source_f);
GR_SWIG_BLOCK_MAGIC2(analog, noise_source_c);
GR_SWIG_BLOCK_MAGIC2(analog, phase_modulator_fc);
+GR_SWIG_BLOCK_MAGIC2(analog, plateau_detector_fb);
GR_SWIG_BLOCK_MAGIC2(analog, pll_carriertracking_cc);
GR_SWIG_BLOCK_MAGIC2(analog, pll_freqdet_cf);
GR_SWIG_BLOCK_MAGIC2(analog, pll_refout_cc);
diff --git a/gr-atsc/src/lib/CMakeLists.txt b/gr-atsc/src/lib/CMakeLists.txt
index 3d2b84a03c..86c0be4430 100644
--- a/gr-atsc/src/lib/CMakeLists.txt
+++ b/gr-atsc/src/lib/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright 2011-212 Free Software Foundation, Inc.
+# Copyright 2011-2013 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -30,6 +30,9 @@ include_directories(
link_directories(${Boost_LIBRARY_DIRS})
+include_directories(${LOG4CPP_INCLUDE_DIRS})
+link_directories(${LOG4CPP_LIBRARY_DIRS})
+
########################################################################
# Generate viterbi mux source
# http://www.vtk.org/Wiki/CMake_Cross_Compiling#Using_executables_in_the_build_created_during_the_build
@@ -95,9 +98,24 @@ list(APPEND gr_atsc_sources
plinfo.cc
)
+#Add Windows DLL resource file under MSVC
+IF(MSVC)
+ include(${CMAKE_SOURCE_DIR}/cmake/Modules/GrVersion.cmake)
+
+ configure_file(
+ ${CMAKE_CURRENT_SOURCE_DIR}/gnuradio-atsc.rc.in
+ ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-atsc.rc
+ @ONLY)
+
+ list(APPEND gr_atsc_sources
+ ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-atsc.rc
+ )
+ENDIF(MSVC)
+
list(APPEND atsc_libs
gnuradio-core
${Boost_LIBRARIES}
+ ${LOG4CPP_LIBRARIES}
)
add_library(gnuradio-atsc SHARED ${gr_atsc_sources})
diff --git a/gr-atsc/src/lib/gnuradio-atsc.rc.in b/gr-atsc/src/lib/gnuradio-atsc.rc.in
new file mode 100644
index 0000000000..f0d7699f00
--- /dev/null
+++ b/gr-atsc/src/lib/gnuradio-atsc.rc.in
@@ -0,0 +1,55 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2013 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.
+ */
+
+#include <afxres.h>
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@
+ PRODUCTVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@
+ FILEFLAGSMASK 0x3fL
+#ifndef NDEBUG
+ FILEFLAGS 0x0L
+#else
+ FILEFLAGS 0x1L
+#endif
+ FILEOS VOS__WINDOWS32
+ FILETYPE VFT_DLL
+ FILESUBTYPE VFT2_DRV_INSTALLABLE
+ BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904b0"
+ BEGIN
+ VALUE "FileDescription", "gnuradio-atsc"
+ VALUE "FileVersion", "@VERSION@"
+ VALUE "InternalName", "gnuradio-atsc.dll"
+ VALUE "LegalCopyright", "Licensed under GPLv3 or any later version"
+ VALUE "OriginalFilename", "gnuradio-atsc.dll"
+ VALUE "ProductName", "gnuradio-atsc"
+ VALUE "ProductVersion", "@VERSION@"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+ END
diff --git a/gr-audio/lib/CMakeLists.txt b/gr-audio/lib/CMakeLists.txt
index f39264d5d2..c9e2806ebd 100644
--- a/gr-audio/lib/CMakeLists.txt
+++ b/gr-audio/lib/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright 2011 Free Software Foundation, Inc.
+# Copyright 2011,2013 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -30,7 +30,10 @@ include_directories(
link_directories(${Boost_LIBRARY_DIRS})
-list(APPEND gr_audio_libs gnuradio-core ${Boost_LIBRARIES})
+include_directories(${LOG4CPP_INCLUDE_DIRS})
+link_directories(${LOG4CPP_LIBRARY_DIRS})
+
+list(APPEND gr_audio_libs gnuradio-core ${Boost_LIBRARIES} ${LOG4CPP_LIBRARIES})
list(APPEND gr_audio_sources gr_audio_registry.cc)
list(APPEND gr_audio_confs ${CMAKE_CURRENT_SOURCE_DIR}/gr-audio.conf)
@@ -142,6 +145,20 @@ if(WIN32)
${CMAKE_CURRENT_SOURCE_DIR}/windows/audio_windows_sink.cc
)
+ #Add Windows DLL resource file if using MSVC
+ IF(MSVC)
+ include(${CMAKE_SOURCE_DIR}/cmake/Modules/GrVersion.cmake)
+
+ configure_file(
+ ${CMAKE_CURRENT_SOURCE_DIR}/gnuradio-audio.rc.in
+ ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-audio.rc
+ @ONLY)
+
+ list(APPEND gr_audio_sources
+ ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-audio.rc
+ )
+ ENDIF()
+
endif(WIN32)
########################################################################
diff --git a/gr-audio/lib/gnuradio-audio.rc.in b/gr-audio/lib/gnuradio-audio.rc.in
new file mode 100644
index 0000000000..5173278a0a
--- /dev/null
+++ b/gr-audio/lib/gnuradio-audio.rc.in
@@ -0,0 +1,55 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2013 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.
+ */
+
+#include <afxres.h>
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@
+ PRODUCTVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@
+ FILEFLAGSMASK 0x3fL
+#ifndef NDEBUG
+ FILEFLAGS 0x0L
+#else
+ FILEFLAGS 0x1L
+#endif
+ FILEOS VOS__WINDOWS32
+ FILETYPE VFT_DLL
+ FILESUBTYPE VFT2_DRV_INSTALLABLE
+ BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904b0"
+ BEGIN
+ VALUE "FileDescription", "gnuradio-audio"
+ VALUE "FileVersion", "@VERSION@"
+ VALUE "InternalName", "gnuradio-audio.dll"
+ VALUE "LegalCopyright", "Licensed under GPLv3 or any later version"
+ VALUE "OriginalFilename", "gnuradio-audio.dll"
+ VALUE "ProductName", "gnuradio-audio"
+ VALUE "ProductVersion", "@VERSION@"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+ END
diff --git a/gr-blocks/CMakeLists.txt b/gr-blocks/CMakeLists.txt
index 7e2f43562f..c4821da2b8 100644
--- a/gr-blocks/CMakeLists.txt
+++ b/gr-blocks/CMakeLists.txt
@@ -34,6 +34,8 @@ GR_REGISTER_COMPONENT("gr-blocks" ENABLE_GR_BLOCKS
GR_SET_GLOBAL(GR_BLOCKS_INCLUDE_DIRS
${CMAKE_CURRENT_SOURCE_DIR}/lib
${CMAKE_CURRENT_SOURCE_DIR}/include
+ ${CMAKE_CURRENT_BINARY_DIR}/lib
+ ${CMAKE_CURRENT_BINARY_DIR}/include
)
########################################################################
@@ -80,6 +82,9 @@ CPACK_COMPONENT("blocks_swig"
########################################################################
add_subdirectory(include/blocks)
add_subdirectory(lib)
+#if(ENABLE_TESTING)
+# add_subdirectory(tests)
+#endif(ENABLE_TESTING)
if(ENABLE_PYTHON)
add_subdirectory(python)
add_subdirectory(swig)
diff --git a/gr-blocks/grc/blocks_argmax_xx.xml b/gr-blocks/grc/blocks_argmax_xx.xml
new file mode 100644
index 0000000000..7adfa75973
--- /dev/null
+++ b/gr-blocks/grc/blocks_argmax_xx.xml
@@ -0,0 +1,61 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##ArgMax:
+## 1 output, 2 to inf inputs
+###################################################
+ -->
+<block>
+ <name>Argmax</name>
+ <key>blocks_argmax_xx</key>
+ <import>from gnuradio import blocks</import>
+ <make>blocks.argmax_$(type.fcn)($vlen)</make>
+ <param>
+ <name>IO Type</name>
+ <key>type</key>
+ <type>enum</type>
+ <option>
+ <name>Float</name>
+ <key>float</key>
+ <opt>fcn:fs</opt>
+ </option>
+ <option>
+ <name>Int</name>
+ <key>int</key>
+ <opt>fcn:is</opt>
+ </option>
+ <option>
+ <name>Short</name>
+ <key>short</key>
+ <opt>fcn:dd</opt>
+ </option>
+ </param>
+ <param>
+ <name>Num Inputs</name>
+ <key>num_inputs</key>
+ <value>2</value>
+ <type>int</type>
+ </param>
+ <param>
+ <name>Vec Length</name>
+ <key>vlen</key>
+ <value>1</value>
+ <type>int</type>
+ </param>
+ <check>$num_inputs &gt;= 1</check>
+ <check>$vlen &gt;= 1</check>
+ <sink>
+ <name>in</name>
+ <type>$type</type>
+ <vlen>$vlen</vlen>
+ <nports>$num_inputs</nports>
+ </sink>
+ <source>
+ <name>max_vec</name>
+ <type>short</type>
+ </source>
+ <source>
+ <name>max_inp</name>
+ <type>short</type>
+ </source>
+</block>
diff --git a/gr-blocks/grc/blocks_block_tree.xml b/gr-blocks/grc/blocks_block_tree.xml
index 0077ec9484..e7b7bb2c04 100644
--- a/gr-blocks/grc/blocks_block_tree.xml
+++ b/gr-blocks/grc/blocks_block_tree.xml
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<!--
- Copyright 2012 Free Software Foundation, Inc.
+ Copyright 2012,2013 Free Software Foundation, Inc.
This file is part of GNU Radio
@@ -31,11 +31,29 @@
<cat>
<name>Sources (New)</name>
<block>blocks_file_source</block>
+ <block>blocks_file_descriptor_source</block>
<block>blocks_file_meta_source</block>
+ <block>blocks_pdu_to_tagged_stream</block>
+ <block>blocks_message_source</block>
+ <block>blocks_message_burst_source</block>
+ <block>blocks_udp_source</block>
+ <block>blocks_wavfile_source</block>
+ <block>blocks_vector_source_x</block>
+ <block>blocks_null_source</block>
</cat>
<cat>
<name>Sinks (New)</name>
+ <block>blocks_file_sink</block>
+ <block>blocks_file_descriptor_sink</block>
<block>blocks_file_meta_sink</block>
+ <block>blocks_tagged_stream_to_pdu</block>
+ <block>blocks_tag_debug</block>
+ <block>blocks_message_sink</block>
+ <block>blocks_tagged_file_sink</block>
+ <block>blocks_udp_sink</block>
+ <block>blocks_wavfile_sink</block>
+ <block>blocks_vector_sink_x</block>
+ <block>blocks_null_sink</block>
</cat>
<cat>
<name>Math Operations (New) </name>
@@ -51,6 +69,9 @@
<block>blocks_nlog10_ff</block>
<block>blocks_rms_xx</block>
<block>blocks_transcendental</block>
+ <block>blocks_argmax_xx</block>
+ <block>blocks_max_xx</block>
+ <block>blocks_vco_f</block>
</cat>
<cat>
<name>Boolean Operations (New) </name>
@@ -79,14 +100,13 @@
<block>blocks_int_to_float</block>
<block>blocks_interleaved_short_to_complex</block>
<block>blocks_short_to_char</block>
+ <block>blocks_repack_bits_bb</block>
<block>blocks_short_to_float</block>
<block>blocks_uchar_to_float</block>
</cat>
<cat>
<name>Stream Operations (New) </name>
<block>blocks_delay</block>
- <block>blocks_packed_to_unpacked_xx</block>
- <block>blocks_unpacked_to_packed_xx</block>
<block>blocks_deinterleave</block>
<block>blocks_interleave</block>
<block>blocks_keep_m_in_n</block>
@@ -99,13 +119,51 @@
<block>blocks_streams_to_vector</block>
<block>blocks_vector_to_stream</block>
<block>blocks_vector_to_streams</block>
+ <block>blocks_peak_detector_xb</block>
<block>blocks_peak_detector2_fb</block>
+ <block>blocks_plateau_detector_fb</block>
<block>blocks_regenerate_bb</block>
<block>blocks_stretch_ff</block>
<block>blocks_threshold_ff</block>
+ <block>blocks_burst_tagger</block>
+ <block>blocks_endian_swap</block>
+ <block>blocks_vector_insert_x</block>
</cat>
<cat>
+ <name>Misc Conversions (New) </name>
+ <block>blocks_packed_to_unpacked_xx</block>
+ <block>blocks_unpacked_to_packed_xx</block>
+ <block>blocks_pack_k_bits_bb</block>
+ <block>blocks_unpack_k_bits_bb</block>
+ </cat>
+ <cat>
<name>Misc (New) </name>
<block>blocks_throttle</block>
+ <block>blocks_probe_rate</block>
+ <block>blocks_head</block>
+ <block>blocks_skiphead</block>
+ <block>blocks_copy</block>
+ <block>blocks_nop</block>
+ </cat>
+ <cat>
+ <name>Networking</name>
+ <block>blocks_tuntap_pdu</block>
+ <block>blocks_socket_pdu</block>
+ </cat>
+ <cat>
+ <name>Level Controls (New)</name>
+ <block>blocks_mute_xx</block>
+ <block>blocks_sample_and_hold_xx</block>
+ <block>blocks_moving_average_xx</block>
+ </cat>
+ <cat>
+ <name>Probes (New)</name>
+ <block>blocks_probe_signal_x</block>
+ <block>blocks_probe_signal_vx</block>
</cat>
+ <cat>
+ <name>Message Tools (New)</name>
+ <block>blocks_message_strobe</block>
+ <block>blocks_message_debug</block>
+ </cat>
</cat>
diff --git a/gr-blocks/grc/blocks_burst_tagger.xml b/gr-blocks/grc/blocks_burst_tagger.xml
new file mode 100644
index 0000000000..f603b53489
--- /dev/null
+++ b/gr-blocks/grc/blocks_burst_tagger.xml
@@ -0,0 +1,87 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##Burst tagger:
+## all types, 1 output, 2 input: stream & trigger (short)
+###################################################
+ -->
+<block>
+ <name>Burst Tagger</name>
+ <key>blocks_burst_tagger</key>
+ <import>from gnuradio import blocks</import>
+ <make>blocks.burst_tagger($type.size)
+self.$(id).set_true_tag($true_key,$true_value)
+self.$(id).set_false_tag($false_key,$false_value)
+ </make>
+ <callback>set_true_tag($true_key,$true_value)</callback>
+ <callback>set_false_tag($false_key,$false_value)</callback>
+ <param>
+ <name>Stream Type</name>
+ <key>type</key>
+ <type>enum</type>
+ <option>
+ <name>Complex</name>
+ <key>complex</key>
+ <opt>size:gr.sizeof_gr_complex</opt>
+ </option>
+ <option>
+ <name>Float</name>
+ <key>float</key>
+ <opt>size:gr.sizeof_float</opt>
+ </option>
+ <option>
+ <name>Int</name>
+ <key>int</key>
+ <opt>size:gr.sizeof_int</opt>
+ </option>
+ <option>
+ <name>Short</name>
+ <key>short</key>
+ <opt>size:gr.sizeof_short</opt>
+ </option>
+ <option>
+ <name>Byte</name>
+ <key>byte</key>
+ <opt>size:gr.sizeof_char</opt>
+ </option>
+ </param>
+ <param>
+ <name>True KeyID</name>
+ <key>true_key</key>
+ <value>burst</value>
+ <type>string</type>
+ </param>
+ <param>
+ <name>True Value</name>
+ <key>true_value</key>
+ <value>True</value>
+ <type>bool</type>
+ </param>
+ <param>
+ <name>False KeyID</name>
+ <key>false_key</key>
+ <value>burst</value>
+ <type>string</type>
+ </param>
+ <param>
+ <name>False Value</name>
+ <key>false_value</key>
+ <value>False</value>
+ <type>bool</type>
+ </param>
+ <sink>
+ <name>in</name>
+ <type>$type</type>
+ <vlen>1</vlen>
+ </sink>
+ <sink>
+ <name>trigger</name>
+ <type>short</type>
+ <vlen>1</vlen>
+ </sink>
+ <source>
+ <name>out</name>
+ <type>$type</type>
+ <vlen>1</vlen>
+ </source>
+</block>
diff --git a/gr-blocks/grc/blocks_copy.xml b/gr-blocks/grc/blocks_copy.xml
new file mode 100644
index 0000000000..55c4b343d3
--- /dev/null
+++ b/gr-blocks/grc/blocks_copy.xml
@@ -0,0 +1,75 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##Copy
+###################################################
+ -->
+<block>
+ <name>Copy</name>
+ <key>blocks_copy</key>
+ <import>from gnuradio import blocks</import>
+ <make>blocks.copy($type.size*$vlen)
+self.$(id).set_enabled($enabled)</make>
+ <callback>set_enabled($enabled)</callback>
+ <param>
+ <name>Type</name>
+ <key>type</key>
+ <type>enum</type>
+ <option>
+ <name>Complex</name>
+ <key>complex</key>
+ <opt>size:gr.sizeof_gr_complex</opt>
+ </option>
+ <option>
+ <name>Float</name>
+ <key>float</key>
+ <opt>size:gr.sizeof_float</opt>
+ </option>
+ <option>
+ <name>Int</name>
+ <key>int</key>
+ <opt>size:gr.sizeof_int</opt>
+ </option>
+ <option>
+ <name>Short</name>
+ <key>short</key>
+ <opt>size:gr.sizeof_short</opt>
+ </option>
+ <option>
+ <name>Byte</name>
+ <key>byte</key>
+ <opt>size:gr.sizeof_char</opt>
+ </option>
+ </param>
+ <param>
+ <name>Enabled</name>
+ <key>enabled</key>
+ <value>True</value>
+ <type>bool</type>
+ <option>
+ <name>Enabled</name>
+ <key>True</key>
+ </option>
+ <option>
+ <name>Disabled</name>
+ <key>False</key>
+ </option>
+ </param>
+ <param>
+ <name>Vec Length</name>
+ <key>vlen</key>
+ <value>1</value>
+ <type>int</type>
+ </param>
+ <check>$vlen &gt; 0</check>
+ <sink>
+ <name>in</name>
+ <type>$type</type>
+ <vlen>$vlen</vlen>
+ </sink>
+ <source>
+ <name>out</name>
+ <type>$type</type>
+ <vlen>$vlen</vlen>
+ </source>
+</block>
diff --git a/gr-blocks/grc/blocks_endian_swap.xml b/gr-blocks/grc/blocks_endian_swap.xml
new file mode 100644
index 0000000000..5fea420664
--- /dev/null
+++ b/gr-blocks/grc/blocks_endian_swap.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##Add Block:
+## all types, 1 output, 2 to inf inputs
+###################################################
+ -->
+<block>
+ <name>Endian Swap</name>
+ <key>blocks_endian_swap</key>
+ <import>from gnuradio import blocks</import>
+ <make>blocks.endian_swap($type.size)</make>
+ <param>
+ <name>IO Type</name>
+ <key>type</key>
+ <type>enum</type>
+ <option>
+ <name>Complex</name>
+ <key>complex</key>
+ <opt>size:8</opt>
+ </option>
+ <option>
+ <name>Int</name>
+ <key>s32</key>
+ <opt>size:4</opt>
+ </option>
+ <option>
+ <name>Short</name>
+ <key>s16</key>
+ <opt>size:2</opt>
+ </option>
+ </param>
+ <sink>
+ <name>in</name>
+ <type>$type</type>
+ </sink>
+ <source>
+ <name>out</name>
+ <type>$type</type>
+ </source>
+</block>
diff --git a/gr-blocks/grc/blocks_file_descriptor_sink.xml b/gr-blocks/grc/blocks_file_descriptor_sink.xml
new file mode 100644
index 0000000000..211d86dfd3
--- /dev/null
+++ b/gr-blocks/grc/blocks_file_descriptor_sink.xml
@@ -0,0 +1,59 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##File Sink
+###################################################
+ -->
+<block>
+ <name>File Descriptor Sink</name>
+ <key>blocks_file_descriptor_sink</key>
+ <import>from gnuradio import blocks</import>
+ <make>blocks.file_descriptor_sink($type.size*$vlen, $fd)</make>
+ <param>
+ <name>File Descriptor</name>
+ <key>fd</key>
+ <type>int</type>
+ </param>
+ <param>
+ <name>Input Type</name>
+ <key>type</key>
+ <type>enum</type>
+ <option>
+ <name>Complex</name>
+ <key>complex</key>
+ <opt>size:gr.sizeof_gr_complex</opt>
+ </option>
+ <option>
+ <name>Float</name>
+ <key>float</key>
+ <opt>size:gr.sizeof_float</opt>
+ </option>
+ <option>
+ <name>Int</name>
+ <key>int</key>
+ <opt>size:gr.sizeof_int</opt>
+ </option>
+ <option>
+ <name>Short</name>
+ <key>short</key>
+ <opt>size:gr.sizeof_short</opt>
+ </option>
+ <option>
+ <name>Byte</name>
+ <key>byte</key>
+ <opt>size:gr.sizeof_char</opt>
+ </option>
+ </param>
+ <param>
+ <name>Vec Length</name>
+ <key>vlen</key>
+ <value>1</value>
+ <type>int</type>
+ </param>
+ <check>$vlen &gt; 0</check>
+ <sink>
+ <name>in</name>
+ <type>$type</type>
+ <vlen>$vlen</vlen>
+ </sink>
+</block>
diff --git a/gr-blocks/grc/blocks_file_descriptor_source.xml b/gr-blocks/grc/blocks_file_descriptor_source.xml
new file mode 100644
index 0000000000..b29335c3af
--- /dev/null
+++ b/gr-blocks/grc/blocks_file_descriptor_source.xml
@@ -0,0 +1,73 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##File Source
+###################################################
+ -->
+<block>
+ <name>File Descriptor Source</name>
+ <key>blocks_file_descriptor_source</key>
+ <import>from gnuradio import blocks</import>
+ <make>blocks.file_descriptor_source($type.size*$vlen, $fd, $repeat)</make>
+ <param>
+ <name>File Descriptor</name>
+ <key>fd</key>
+ <type>int</type>
+ </param>
+ <param>
+ <name>Output Type</name>
+ <key>type</key>
+ <type>enum</type>
+ <option>
+ <name>Complex</name>
+ <key>complex</key>
+ <opt>size:gr.sizeof_gr_complex</opt>
+ </option>
+ <option>
+ <name>Float</name>
+ <key>float</key>
+ <opt>size:gr.sizeof_float</opt>
+ </option>
+ <option>
+ <name>Int</name>
+ <key>int</key>
+ <opt>size:gr.sizeof_int</opt>
+ </option>
+ <option>
+ <name>Short</name>
+ <key>short</key>
+ <opt>size:gr.sizeof_short</opt>
+ </option>
+ <option>
+ <name>Byte</name>
+ <key>byte</key>
+ <opt>size:gr.sizeof_char</opt>
+ </option>
+ </param>
+ <param>
+ <name>Repeat</name>
+ <key>repeat</key>
+ <value>True</value>
+ <type>enum</type>
+ <option>
+ <name>Yes</name>
+ <key>True</key>
+ </option>
+ <option>
+ <name>No</name>
+ <key>False</key>
+ </option>
+ </param>
+ <param>
+ <name>Vec Length</name>
+ <key>vlen</key>
+ <value>1</value>
+ <type>int</type>
+ </param>
+ <check>$vlen &gt; 0</check>
+ <source>
+ <name>out</name>
+ <type>$type</type>
+ <vlen>$vlen</vlen>
+ </source>
+</block>
diff --git a/gr-blocks/grc/blocks_file_sink.xml b/gr-blocks/grc/blocks_file_sink.xml
new file mode 100644
index 0000000000..75ef86a6b8
--- /dev/null
+++ b/gr-blocks/grc/blocks_file_sink.xml
@@ -0,0 +1,78 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##File Sink
+###################################################
+ -->
+<block>
+ <name>File Sink</name>
+ <key>blocks_file_sink</key>
+ <import>from gnuradio import blocks</import>
+ <make>blocks.file_sink($type.size*$vlen, $file)
+self.$(id).set_unbuffered($unbuffered)</make>
+ <callback>set_unbuffered($unbuffered)</callback>
+ <callback>open($file)</callback>
+ <param>
+ <name>File</name>
+ <key>file</key>
+ <value></value>
+ <type>file_save</type>
+ </param>
+ <param>
+ <name>Input Type</name>
+ <key>type</key>
+ <type>enum</type>
+ <option>
+ <name>Complex</name>
+ <key>complex</key>
+ <opt>size:gr.sizeof_gr_complex</opt>
+ </option>
+ <option>
+ <name>Float</name>
+ <key>float</key>
+ <opt>size:gr.sizeof_float</opt>
+ </option>
+ <option>
+ <name>Int</name>
+ <key>int</key>
+ <opt>size:gr.sizeof_int</opt>
+ </option>
+ <option>
+ <name>Short</name>
+ <key>short</key>
+ <opt>size:gr.sizeof_short</opt>
+ </option>
+ <option>
+ <name>Byte</name>
+ <key>byte</key>
+ <opt>size:gr.sizeof_char</opt>
+ </option>
+ </param>
+ <param>
+ <name>Vec Length</name>
+ <key>vlen</key>
+ <value>1</value>
+ <type>int</type>
+ </param>
+ <param>
+ <name>Unbuffered</name>
+ <key>unbuffered</key>
+ <value>False</value>
+ <type>bool</type>
+ <option>
+ <name>Off</name>
+ <key>False</key>
+ </option>
+ <option>
+ <name>On</name>
+ <key>True</key>
+ </option>
+ </param>
+
+ <check>$vlen &gt; 0</check>
+ <sink>
+ <name>in</name>
+ <type>$type</type>
+ <vlen>$vlen</vlen>
+ </sink>
+</block>
diff --git a/gr-blocks/grc/blocks_head.xml b/gr-blocks/grc/blocks_head.xml
new file mode 100644
index 0000000000..8b6e67820c
--- /dev/null
+++ b/gr-blocks/grc/blocks_head.xml
@@ -0,0 +1,65 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##Head
+###################################################
+ -->
+<block>
+ <name>Head</name>
+ <key>blocks_head</key>
+ <import>from gnuradio import blocks</import>
+ <make>blocks.head($type.size*$vlen, $num_items)</make>
+ <param>
+ <name>Type</name>
+ <key>type</key>
+ <type>enum</type>
+ <option>
+ <name>Complex</name>
+ <key>complex</key>
+ <opt>size:gr.sizeof_gr_complex</opt>
+ </option>
+ <option>
+ <name>Float</name>
+ <key>float</key>
+ <opt>size:gr.sizeof_float</opt>
+ </option>
+ <option>
+ <name>Int</name>
+ <key>int</key>
+ <opt>size:gr.sizeof_int</opt>
+ </option>
+ <option>
+ <name>Short</name>
+ <key>short</key>
+ <opt>size:gr.sizeof_short</opt>
+ </option>
+ <option>
+ <name>Byte</name>
+ <key>byte</key>
+ <opt>size:gr.sizeof_char</opt>
+ </option>
+ </param>
+ <param>
+ <name>Num Items</name>
+ <key>num_items</key>
+ <value>1024</value>
+ <type>int</type>
+ </param>
+ <param>
+ <name>Vec Length</name>
+ <key>vlen</key>
+ <value>1</value>
+ <type>int</type>
+ </param>
+ <check>$vlen &gt; 0</check>
+ <sink>
+ <name>in</name>
+ <type>$type</type>
+ <vlen>$vlen</vlen>
+ </sink>
+ <source>
+ <name>out</name>
+ <type>$type</type>
+ <vlen>$vlen</vlen>
+ </source>
+</block>
diff --git a/gr-blocks/grc/blocks_max_xx.xml b/gr-blocks/grc/blocks_max_xx.xml
new file mode 100644
index 0000000000..afbcae93dc
--- /dev/null
+++ b/gr-blocks/grc/blocks_max_xx.xml
@@ -0,0 +1,58 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##Max:
+## 1 output, 2 to inf inputs
+###################################################
+ -->
+<block>
+ <name>Max</name>
+ <key>blocks_max_xx</key>
+ <import>from gnuradio import blocks</import>
+ <make>blocks.max_$(type.fcn)($vlen)</make>
+ <param>
+ <name>IO Type</name>
+ <key>type</key>
+ <type>enum</type>
+ <option>
+ <name>Float</name>
+ <key>float</key>
+ <opt>fcn:ff</opt>
+ </option>
+ <option>
+ <name>Int</name>
+ <key>int</key>
+ <opt>fcn:ii</opt>
+ </option>
+ <option>
+ <name>Short</name>
+ <key>short</key>
+ <opt>fcn:dd</opt>
+ </option>
+ </param>
+ <param>
+ <name>Num Inputs</name>
+ <key>num_inputs</key>
+ <value>1</value>
+ <type>int</type>
+ </param>
+ <param>
+ <name>Vec Length</name>
+ <key>vlen</key>
+ <value>1</value>
+ <type>int</type>
+ </param>
+ <check>$num_inputs &gt;= 1</check>
+ <check>$vlen &gt;= 1</check>
+ <sink>
+ <name>in</name>
+ <type>$type</type>
+ <vlen>$vlen</vlen>
+ <nports>$num_inputs</nports>
+ </sink>
+ <source>
+ <name>out</name>
+ <type>$type</type>
+ <vlen>1</vlen>
+ </source>
+</block>
diff --git a/gr-blocks/grc/blocks_message_burst_source.xml b/gr-blocks/grc/blocks_message_burst_source.xml
new file mode 100644
index 0000000000..208955e557
--- /dev/null
+++ b/gr-blocks/grc/blocks_message_burst_source.xml
@@ -0,0 +1,58 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##Message Burst Source (the sink port is a message)
+###################################################
+ -->
+<block>
+ <name>Message Burst Source</name>
+ <key>blocks_message_burst_source</key>
+ <import>from gnuradio import blocks</import>
+ <make>blocks.message_burst_source($type.size*$vlen, $(id)_msgq_in)</make>
+ <param>
+ <name>Output Type</name>
+ <key>type</key>
+ <type>enum</type>
+ <option>
+ <name>Complex</name>
+ <key>complex</key>
+ <opt>size:gr.sizeof_gr_complex</opt>
+ </option>
+ <option>
+ <name>Float</name>
+ <key>float</key>
+ <opt>size:gr.sizeof_float</opt>
+ </option>
+ <option>
+ <name>Int</name>
+ <key>int</key>
+ <opt>size:gr.sizeof_int</opt>
+ </option>
+ <option>
+ <name>Short</name>
+ <key>short</key>
+ <opt>size:gr.sizeof_short</opt>
+ </option>
+ <option>
+ <name>Byte</name>
+ <key>byte</key>
+ <opt>size:gr.sizeof_char</opt>
+ </option>
+ </param>
+ <param>
+ <name>Vec Length</name>
+ <key>vlen</key>
+ <value>1</value>
+ <type>int</type>
+ </param>
+ <check>$vlen &gt; 0</check>
+ <sink>
+ <name>in</name>
+ <type>msg</type>
+ </sink>
+ <source>
+ <name>out</name>
+ <type>$type</type>
+ <vlen>$vlen</vlen>
+ </source>
+</block>
diff --git a/gr-blocks/grc/blocks_message_debug.xml b/gr-blocks/grc/blocks_message_debug.xml
new file mode 100644
index 0000000000..c547c7542d
--- /dev/null
+++ b/gr-blocks/grc/blocks_message_debug.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##Message Debug
+###################################################
+ -->
+<block>
+ <name>Message Debug</name>
+ <key>blocks_message_debug</key>
+ <import>from gnuradio import blocks</import>
+ <make>blocks.message_debug()</make>
+ <sink>
+ <name>print</name>
+ <type>message</type>
+ <optional>1</optional>
+ </sink>
+ <sink>
+ <name>store</name>
+ <type>message</type>
+ <optional>1</optional>
+ </sink>
+ <sink>
+ <name>print_pdu</name>
+ <type>message</type>
+ <optional>1</optional>
+ </sink>
+</block>
diff --git a/gr-blocks/grc/blocks_message_sink.xml b/gr-blocks/grc/blocks_message_sink.xml
new file mode 100644
index 0000000000..c1f21f6521
--- /dev/null
+++ b/gr-blocks/grc/blocks_message_sink.xml
@@ -0,0 +1,72 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##Message Sink (the source port is a message)
+###################################################
+ -->
+<block>
+ <name>Message Sink</name>
+ <key>blocks_message_sink</key>
+ <import>from gnuradio import blocks</import>
+ <make>blocks.message_sink($type.size*$vlen, $(id)_msgq_out, $dont_block)</make>
+ <param>
+ <name>Input Type</name>
+ <key>type</key>
+ <type>enum</type>
+ <option>
+ <name>Complex</name>
+ <key>complex</key>
+ <opt>size:gr.sizeof_gr_complex</opt>
+ </option>
+ <option>
+ <name>Float</name>
+ <key>float</key>
+ <opt>size:gr.sizeof_float</opt>
+ </option>
+ <option>
+ <name>Int</name>
+ <key>int</key>
+ <opt>size:gr.sizeof_int</opt>
+ </option>
+ <option>
+ <name>Short</name>
+ <key>short</key>
+ <opt>size:gr.sizeof_short</opt>
+ </option>
+ <option>
+ <name>Byte</name>
+ <key>byte</key>
+ <opt>size:gr.sizeof_char</opt>
+ </option>
+ </param>
+ <param>
+ <name>Don't Block</name>
+ <key>dont_block</key>
+ <value>False</value>
+ <type>enum</type>
+ <option>
+ <name>Don't Block</name>
+ <key>True</key>
+ </option>
+ <option>
+ <name>Block</name>
+ <key>False</key>
+ </option>
+ </param>
+ <param>
+ <name>Vec Length</name>
+ <key>vlen</key>
+ <value>1</value>
+ <type>int</type>
+ </param>
+ <check>$vlen &gt; 0</check>
+ <sink>
+ <name>in</name>
+ <type>$type</type>
+ <vlen>$vlen</vlen>
+ </sink>
+ <source>
+ <name>out</name>
+ <type>msg</type>
+ </source>
+</block>
diff --git a/gr-blocks/grc/blocks_message_source.xml b/gr-blocks/grc/blocks_message_source.xml
new file mode 100644
index 0000000000..12c6569606
--- /dev/null
+++ b/gr-blocks/grc/blocks_message_source.xml
@@ -0,0 +1,58 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##Message Source (the sink port is a message)
+###################################################
+ -->
+<block>
+ <name>Message Source</name>
+ <key>blocks_message_source</key>
+ <import>from gnuradio import blocks</import>
+ <make>blocks.message_source($type.size*$vlen, $(id)_msgq_in)</make>
+ <param>
+ <name>Output Type</name>
+ <key>type</key>
+ <type>enum</type>
+ <option>
+ <name>Complex</name>
+ <key>complex</key>
+ <opt>size:gr.sizeof_gr_complex</opt>
+ </option>
+ <option>
+ <name>Float</name>
+ <key>float</key>
+ <opt>size:gr.sizeof_float</opt>
+ </option>
+ <option>
+ <name>Int</name>
+ <key>int</key>
+ <opt>size:gr.sizeof_int</opt>
+ </option>
+ <option>
+ <name>Short</name>
+ <key>short</key>
+ <opt>size:gr.sizeof_short</opt>
+ </option>
+ <option>
+ <name>Byte</name>
+ <key>byte</key>
+ <opt>size:gr.sizeof_char</opt>
+ </option>
+ </param>
+ <param>
+ <name>Vec Length</name>
+ <key>vlen</key>
+ <value>1</value>
+ <type>int</type>
+ </param>
+ <check>$vlen &gt; 0</check>
+ <sink>
+ <name>in</name>
+ <type>msg</type>
+ </sink>
+ <source>
+ <name>out</name>
+ <type>$type</type>
+ <vlen>$vlen</vlen>
+ </source>
+</block>
diff --git a/gr-blocks/grc/blocks_message_strobe.xml b/gr-blocks/grc/blocks_message_strobe.xml
new file mode 100644
index 0000000000..25c98cd01c
--- /dev/null
+++ b/gr-blocks/grc/blocks_message_strobe.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##Message Strobe
+###################################################
+ -->
+<block>
+ <name>Message Strobe</name>
+ <key>blocks_message_strobe</key>
+ <import>from gnuradio import blocks</import>
+ <import>from gruel import pmt</import>
+ <make>blocks.message_strobe($msg, $period)</make>
+ <param>
+ <name>Message PMT</name>
+ <key>msg</key>
+ <value>pmt.pmt_intern("TEST")</value>
+ <type>raw</type>
+ </param>
+ <param>
+ <name>Period (ms)</name>
+ <key>period</key>
+ <value>1000</value>
+ <type>real</type>
+ </param>
+ <sink>
+ <name>set_msg</name>
+ <type>message</type>
+ <optional>1</optional>
+ </sink>
+ <source>
+ <name>strobe</name>
+ <type>message</type>
+ <optional>1</optional>
+ </source>
+</block>
diff --git a/gr-blocks/grc/blocks_moving_average_xx.xml b/gr-blocks/grc/blocks_moving_average_xx.xml
new file mode 100644
index 0000000000..e90903ad85
--- /dev/null
+++ b/gr-blocks/grc/blocks_moving_average_xx.xml
@@ -0,0 +1,68 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##Moving Average
+###################################################
+ -->
+<block>
+ <name>Moving Average</name>
+ <key>blocks_moving_average_xx</key>
+ <import>from gnuradio import blocks</import>
+ <make>blocks.moving_average_$(type.fcn)($length, $scale, $max_iter)</make>
+ <callback>set_length_and_scale($length, $scale)</callback>
+ <param>
+ <name>Type</name>
+ <key>type</key>
+ <type>enum</type>
+ <option>
+ <name>Complex</name>
+ <key>complex</key>
+ <opt>fcn:cc</opt>
+ <opt>scale:complex</opt>
+ </option>
+ <option>
+ <name>Float</name>
+ <key>float</key>
+ <opt>fcn:ff</opt>
+ <opt>scale:real</opt>
+ </option>
+ <option>
+ <name>Int</name>
+ <key>int</key>
+ <opt>fcn:ii</opt>
+ <opt>scale:int</opt>
+ </option>
+ <option>
+ <name>Short</name>
+ <key>short</key>
+ <opt>fcn:ss</opt>
+ <opt>scale:int</opt>
+ </option>
+ </param>
+ <param>
+ <name>Length</name>
+ <key>length</key>
+ <value>1000</value>
+ <type>int</type>
+ </param>
+ <param>
+ <name>Scale</name>
+ <key>scale</key>
+ <value>1</value>
+ <type>$type.scale</type>
+ </param>
+ <param>
+ <name>Max Iter</name>
+ <key>max_iter</key>
+ <value>4000</value>
+ <type>int</type>
+ </param>
+ <sink>
+ <name>in</name>
+ <type>$type</type>
+ </sink>
+ <source>
+ <name>out</name>
+ <type>$type</type>
+ </source>
+</block>
diff --git a/gr-blocks/grc/blocks_mute_xx.xml b/gr-blocks/grc/blocks_mute_xx.xml
new file mode 100644
index 0000000000..7023d32674
--- /dev/null
+++ b/gr-blocks/grc/blocks_mute_xx.xml
@@ -0,0 +1,61 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##Mute Block:
+## Cast input to bool.
+###################################################
+ -->
+<block>
+ <name>Mute</name>
+ <key>blocks_mute_xx</key>
+ <import>from gnuradio import blocks</import>
+ <make>blocks.mute_$(type.fcn)(bool($mute))</make>
+ <callback>set_mute(bool($mute))</callback>
+ <param>
+ <name>IO Type</name>
+ <key>type</key>
+ <type>enum</type>
+ <option>
+ <name>Complex</name>
+ <key>complex</key>
+ <opt>fcn:cc</opt>
+ </option>
+ <option>
+ <name>Float</name>
+ <key>float</key>
+ <opt>fcn:ff</opt>
+ </option>
+ <option>
+ <name>Int</name>
+ <key>int</key>
+ <opt>fcn:ii</opt>
+ </option>
+ <option>
+ <name>Short</name>
+ <key>short</key>
+ <opt>fcn:ss</opt>
+ </option>
+ </param>
+ <param>
+ <name>Mute</name>
+ <key>mute</key>
+ <value>False</value>
+ <type>raw</type>
+ <option>
+ <name>True</name>
+ <key>True</key>
+ </option>
+ <option>
+ <name>False</name>
+ <key>False</key>
+ </option>
+ </param>
+ <sink>
+ <name>in</name>
+ <type>$type</type>
+ </sink>
+ <source>
+ <name>out</name>
+ <type>$type</type>
+ </source>
+</block>
diff --git a/gr-blocks/grc/blocks_nop.xml b/gr-blocks/grc/blocks_nop.xml
new file mode 100644
index 0000000000..d38c23839d
--- /dev/null
+++ b/gr-blocks/grc/blocks_nop.xml
@@ -0,0 +1,68 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##Nop
+###################################################
+ -->
+<block>
+ <name>Nop</name>
+ <key>blocks_nop</key>
+ <import>from gnuradio import blocks</import>
+ <make>blocks.nop($type.size*$vlen)</make>
+ <param>
+ <name>Type</name>
+ <key>type</key>
+ <type>enum</type>
+ <option>
+ <name>Complex</name>
+ <key>complex</key>
+ <opt>size:gr.sizeof_gr_complex</opt>
+ </option>
+ <option>
+ <name>Float</name>
+ <key>float</key>
+ <opt>size:gr.sizeof_float</opt>
+ </option>
+ <option>
+ <name>Int</name>
+ <key>int</key>
+ <opt>size:gr.sizeof_int</opt>
+ </option>
+ <option>
+ <name>Short</name>
+ <key>short</key>
+ <opt>size:gr.sizeof_short</opt>
+ </option>
+ <option>
+ <name>Byte</name>
+ <key>byte</key>
+ <opt>size:gr.sizeof_char</opt>
+ </option>
+ </param>
+ <param>
+ <name>Num Ports</name>
+ <key>num_ports</key>
+ <value>1</value>
+ <type>int</type>
+ </param>
+ <param>
+ <name>Vec Length</name>
+ <key>vlen</key>
+ <value>1</value>
+ <type>int</type>
+ </param>
+ <check>$num_ports &gt; 0</check>
+ <check>$vlen &gt; 0</check>
+ <sink>
+ <name>in</name>
+ <type>$type</type>
+ <vlen>$vlen</vlen>
+ <nports>$num_ports</nports>
+ </sink>
+ <source>
+ <name>out</name>
+ <type>$type</type>
+ <vlen>$vlen</vlen>
+ <nports>$num_ports</nports>
+ </source>
+</block>
diff --git a/gr-blocks/grc/blocks_null_sink.xml b/gr-blocks/grc/blocks_null_sink.xml
new file mode 100644
index 0000000000..2ae20e619a
--- /dev/null
+++ b/gr-blocks/grc/blocks_null_sink.xml
@@ -0,0 +1,54 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##Null Sink
+###################################################
+ -->
+<block>
+ <name>Null Sink</name>
+ <key>blocks_null_sink</key>
+ <import>from gnuradio import blocks</import>
+ <make>blocks.null_sink($type.size*$vlen)</make>
+ <param>
+ <name>Input Type</name>
+ <key>type</key>
+ <type>enum</type>
+ <option>
+ <name>Complex</name>
+ <key>complex</key>
+ <opt>size:gr.sizeof_gr_complex</opt>
+ </option>
+ <option>
+ <name>Float</name>
+ <key>float</key>
+ <opt>size:gr.sizeof_float</opt>
+ </option>
+ <option>
+ <name>Int</name>
+ <key>int</key>
+ <opt>size:gr.sizeof_int</opt>
+ </option>
+ <option>
+ <name>Short</name>
+ <key>short</key>
+ <opt>size:gr.sizeof_short</opt>
+ </option>
+ <option>
+ <name>Byte</name>
+ <key>byte</key>
+ <opt>size:gr.sizeof_char</opt>
+ </option>
+ </param>
+ <param>
+ <name>Vec Length</name>
+ <key>vlen</key>
+ <value>1</value>
+ <type>int</type>
+ </param>
+ <check>$vlen &gt; 0</check>
+ <sink>
+ <name>in</name>
+ <type>$type</type>
+ <vlen>$vlen</vlen>
+ </sink>
+</block>
diff --git a/gr-blocks/grc/blocks_null_source.xml b/gr-blocks/grc/blocks_null_source.xml
new file mode 100644
index 0000000000..01d3905cab
--- /dev/null
+++ b/gr-blocks/grc/blocks_null_source.xml
@@ -0,0 +1,54 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##Null Source
+###################################################
+ -->
+<block>
+ <name>Null Source</name>
+ <key>blocks_null_source</key>
+ <import>from gnuradio import blocks</import>
+ <make>blocks.null_source($type.size*$vlen)</make>
+ <param>
+ <name>Output Type</name>
+ <key>type</key>
+ <type>enum</type>
+ <option>
+ <name>Complex</name>
+ <key>complex</key>
+ <opt>size:gr.sizeof_gr_complex</opt>
+ </option>
+ <option>
+ <name>Float</name>
+ <key>float</key>
+ <opt>size:gr.sizeof_float</opt>
+ </option>
+ <option>
+ <name>Int</name>
+ <key>int</key>
+ <opt>size:gr.sizeof_int</opt>
+ </option>
+ <option>
+ <name>Short</name>
+ <key>short</key>
+ <opt>size:gr.sizeof_short</opt>
+ </option>
+ <option>
+ <name>Byte</name>
+ <key>byte</key>
+ <opt>size:gr.sizeof_char</opt>
+ </option>
+ </param>
+ <param>
+ <name>Vec Length</name>
+ <key>vlen</key>
+ <value>1</value>
+ <type>int</type>
+ </param>
+ <check>$vlen &gt; 0</check>
+ <source>
+ <name>out</name>
+ <type>$type</type>
+ <vlen>$vlen</vlen>
+ </source>
+</block>
diff --git a/gr-blocks/grc/blocks_pack_k_bits_bb.xml b/gr-blocks/grc/blocks_pack_k_bits_bb.xml
new file mode 100644
index 0000000000..5400eb4af9
--- /dev/null
+++ b/gr-blocks/grc/blocks_pack_k_bits_bb.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##Pack K Bits
+###################################################
+ -->
+<block>
+ <name>Pack K Bits</name>
+ <key>blocks_pack_k_bits_bb</key>
+ <import>from gnuradio import blocks</import>
+ <make>blocks.pack_k_bits_bb($k)</make>
+ <param>
+ <name>K</name>
+ <key>k</key>
+ <type>int</type>
+ </param>
+ <sink>
+ <name>in</name>
+ <type>byte</type>
+ </sink>
+ <source>
+ <name>out</name>
+ <type>byte</type>
+ </source>
+
+ <doc>
+ Pack K unpacked bits (one bit per byte) into a single packed byte containing k bits and 8 - k zeros.
+ </doc>
+
+</block>
diff --git a/gr-blocks/grc/blocks_pdu_to_tagged_stream.xml b/gr-blocks/grc/blocks_pdu_to_tagged_stream.xml
new file mode 100644
index 0000000000..2a7de84759
--- /dev/null
+++ b/gr-blocks/grc/blocks_pdu_to_tagged_stream.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+## PDU Message to Tagged Stream
+###################################################
+ -->
+<block>
+ <name>PDU to Tagged Stream</name>
+ <key>blocks_pdu_to_tagged_stream</key>
+ <import>from gnuradio import blocks</import>
+ <make>blocks.pdu_to_tagged_stream($type.tv)</make>
+ <param>
+ <name>Item Type</name>
+ <key>type</key>
+ <type>enum</type>
+ <option>
+ <name>Byte</name>
+ <key>byte</key>
+ <opt>tv:blocks.byte_t</opt>
+ </option>
+ <option>
+ <name>Complex</name>
+ <key>complex</key>
+ <opt>tv:blocks.complex_t</opt>
+ </option>
+ <option>
+ <name>Float</name>
+ <key>float</key>
+ <opt>tv:blocks.float_t</opt>
+ </option>
+ </param>
+ <sink>
+ <name>pdus</name>
+ <type>message</type>
+ </sink>
+ <source>
+ <name>out</name>
+ <type>$type</type>
+ </source>
+</block>
diff --git a/gr-blocks/grc/blocks_peak_detector_xb.xml b/gr-blocks/grc/blocks_peak_detector_xb.xml
new file mode 100644
index 0000000000..1aabf89474
--- /dev/null
+++ b/gr-blocks/grc/blocks_peak_detector_xb.xml
@@ -0,0 +1,68 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##Peak Detector
+###################################################
+ -->
+<block>
+ <name>Peak Detector</name>
+ <key>blocks_peak_detector_xb</key>
+ <import>from gnuradio import blocks</import>
+ <make>blocks.peak_detector_$(type.fcn)b($threshold_factor_rise, $threshold_factor_fall, $look_ahead, $alpha)</make>
+ <callback>set_threshold_factor_rise($threshold_factor_rise)</callback>
+ <callback>set_threshold_factor_fall($threshold_factor_fall)</callback>
+ <callback>set_look_ahead($look_ahead)</callback>
+ <callback>set_alpha($alpha)</callback>
+ <param>
+ <name>Input Type</name>
+ <key>type</key>
+ <type>enum</type>
+ <option>
+ <name>Float</name>
+ <key>float</key>
+ <opt>fcn:f</opt>
+ </option>
+ <option>
+ <name>Int</name>
+ <key>int</key>
+ <opt>fcn:i</opt>
+ </option>
+ <option>
+ <name>Short</name>
+ <key>short</key>
+ <opt>fcn:s</opt>
+ </option>
+ </param>
+ <param>
+ <name>TH Factor Rise</name>
+ <key>threshold_factor_rise</key>
+ <value>0.25</value>
+ <type>real</type>
+ </param>
+ <param>
+ <name>TH Factor Fall</name>
+ <key>threshold_factor_fall</key>
+ <value>0.40</value>
+ <type>real</type>
+ </param>
+ <param>
+ <name>Look Ahead</name>
+ <key>look_ahead</key>
+ <value>10</value>
+ <type>int</type>
+ </param>
+ <param>
+ <name>Alpha</name>
+ <key>alpha</key>
+ <value>0.001</value>
+ <type>real</type>
+ </param>
+ <sink>
+ <name>in</name>
+ <type>$type</type>
+ </sink>
+ <source>
+ <name>out</name>
+ <type>byte</type>
+ </source>
+</block>
diff --git a/gr-blocks/grc/blocks_plateau_detector_fb.xml b/gr-blocks/grc/blocks_plateau_detector_fb.xml
new file mode 100644
index 0000000000..90f67a4cf5
--- /dev/null
+++ b/gr-blocks/grc/blocks_plateau_detector_fb.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<block>
+ <name>Plateau Detector</name>
+ <key>blocks_plateau_detector_fb</key>
+ <import>from gnuradio import blocks</import>
+ <make>blocks.plateau_detector_fb($max_len, $threshold)</make>
+ <param>
+ <name>Max. plateau length</name>
+ <key>max_len</key>
+ <type>int</type>
+ </param>
+ <param>
+ <name>Threshold</name>
+ <key>threshold</key>
+ <value>0.9</value>
+ <type>real</type>
+ </param>
+ <sink>
+ <name>in</name>
+ <type>float</type>
+ </sink>
+ <source>
+ <name>out</name>
+ <type>byte</type>
+ </source>
+</block>
diff --git a/gr-blocks/grc/blocks_probe_rate.xml b/gr-blocks/grc/blocks_probe_rate.xml
new file mode 100644
index 0000000000..08df23e0d2
--- /dev/null
+++ b/gr-blocks/grc/blocks_probe_rate.xml
@@ -0,0 +1,66 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##Probe Rate
+###################################################
+ -->
+<block>
+ <name>Probe Rate</name>
+ <key>blocks_probe_rate</key>
+ <import>from gnuradio import blocks</import>
+ <make>blocks.probe_rate($type.size*$vlen, $mintime, $alpha)</make>
+ <param>
+ <name>Input Type</name>
+ <key>type</key>
+ <type>enum</type>
+ <option>
+ <name>Complex</name>
+ <key>complex</key>
+ <opt>size:gr.sizeof_gr_complex</opt>
+ </option>
+ <option>
+ <name>Float</name>
+ <key>float</key>
+ <opt>size:gr.sizeof_float</opt>
+ </option>
+ <option>
+ <name>Int</name>
+ <key>int</key>
+ <opt>size:gr.sizeof_int</opt>
+ </option>
+ <option>
+ <name>Short</name>
+ <key>short</key>
+ <opt>size:gr.sizeof_short</opt>
+ </option>
+ <option>
+ <name>Byte</name>
+ <key>byte</key>
+ <opt>size:gr.sizeof_char</opt>
+ </option>
+ </param>
+ <param>
+ <name>Vec Length</name>
+ <key>vlen</key>
+ <value>1</value>
+ <type>int</type>
+ </param>
+ <param>
+ <name>Min Update Time (ms)</name>
+ <key>mintime</key>
+ <value>500.0</value>
+ <type>real</type>
+ </param>
+ <param>
+ <name>Update Alpha</name>
+ <key>alpha</key>
+ <value>0.15</value>
+ <type>real</type>
+ </param>
+ <check>$vlen &gt;= 1</check>
+ <sink>
+ <name>in</name>
+ <type>$type</type>
+ <vlen>$vlen</vlen>
+ </sink>
+</block>
diff --git a/gr-blocks/grc/blocks_probe_signal_vx.xml b/gr-blocks/grc/blocks_probe_signal_vx.xml
new file mode 100644
index 0000000000..f4e945ab0d
--- /dev/null
+++ b/gr-blocks/grc/blocks_probe_signal_vx.xml
@@ -0,0 +1,59 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##Probe Signal
+###################################################
+ -->
+<block>
+ <name>Probe Signal</name>
+ <key>blocks_probe_signal_vx</key>
+ <import>from gnuradio import blocks</import>
+ <make>blocks.probe_signal_v$(type.fcn)($vlen)</make>
+ <param>
+ <name>Input Type</name>
+ <key>type</key>
+ <type>enum</type>
+ <option>
+ <name>Complex</name>
+ <key>complex</key>
+ <opt>fcn:c</opt>
+ </option>
+ <option>
+ <name>Float</name>
+ <key>float</key>
+ <opt>fcn:f</opt>
+ </option>
+ <option>
+ <name>Int</name>
+ <key>int</key>
+ <opt>fcn:i</opt>
+ </option>
+ <option>
+ <name>Short</name>
+ <key>short</key>
+ <opt>fcn:s</opt>
+ </option>
+ <option>
+ <name>Byte</name>
+ <key>byte</key>
+ <opt>fcn:b</opt>
+ </option>
+ </param>
+ <param>
+ <name>Vec Length</name>
+ <key>vlen</key>
+ <value>1</value>
+ <type>int</type>
+ </param>
+ <check>$vlen &gt; 0</check>
+ <sink>
+ <name>in</name>
+ <type>$type</type>
+ <vlen>$vlen</vlen>
+ </sink>
+ <doc>
+Available functions to probe: level()
+
+Use with the function probe block.
+ </doc>
+</block>
diff --git a/gr-blocks/grc/blocks_probe_signal_x.xml b/gr-blocks/grc/blocks_probe_signal_x.xml
new file mode 100644
index 0000000000..726f0fa747
--- /dev/null
+++ b/gr-blocks/grc/blocks_probe_signal_x.xml
@@ -0,0 +1,51 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##Probe Signal
+###################################################
+ -->
+<block>
+ <name>Probe Signal</name>
+ <key>blocks_probe_signal_x</key>
+ <import>from gnuradio import blocks</import>
+ <make>blocks.probe_signal_$(type.fcn)()</make>
+ <param>
+ <name>Input Type</name>
+ <key>type</key>
+ <type>enum</type>
+ <option>
+ <name>Complex</name>
+ <key>complex</key>
+ <opt>fcn:c</opt>
+ </option>
+ <option>
+ <name>Float</name>
+ <key>float</key>
+ <opt>fcn:f</opt>
+ </option>
+ <option>
+ <name>Int</name>
+ <key>int</key>
+ <opt>fcn:i</opt>
+ </option>
+ <option>
+ <name>Short</name>
+ <key>short</key>
+ <opt>fcn:s</opt>
+ </option>
+ <option>
+ <name>Byte</name>
+ <key>byte</key>
+ <opt>fcn:b</opt>
+ </option>
+ </param>
+ <sink>
+ <name>in</name>
+ <type>$type</type>
+ </sink>
+ <doc>
+Available functions to probe: level()
+
+Use with the function probe block.
+ </doc>
+</block>
diff --git a/gr-blocks/grc/blocks_repack_bits_bb.xml b/gr-blocks/grc/blocks_repack_bits_bb.xml
new file mode 100644
index 0000000000..4ad5ec631b
--- /dev/null
+++ b/gr-blocks/grc/blocks_repack_bits_bb.xml
@@ -0,0 +1,46 @@
+<block>
+ <name>Repack Bits</name>
+ <key>blocks_repack_bits_bb</key>
+ <import>from gnuradio import blocks</import>
+ <make>blocks.repack_bits_bb($k, $l, $len_tag_key, $align_output)</make>
+ <param>
+ <name>Bits per input byte</name>
+ <key>k</key>
+ <value>1</value>
+ <type>int</type>
+ </param>
+ <param>
+ <name>Bits per output byte</name>
+ <key>l</key>
+ <value>8</value>
+ <type>int</type>
+ </param>
+ <param>
+ <name>Length Tag Key</name>
+ <key>len_tag_key</key>
+ <value>""</value>
+ <type>string</type>
+ </param>
+ <param>
+ <name>Packet Alignment</name>
+ <key>align_output</key>
+ <value>False</value>
+ <type>enum</type>
+ <option>
+ <name>Output</name>
+ <key>True</key>
+ </option>
+ <option>
+ <name>Input</name>
+ <key>False</key>
+ </option>
+ </param>
+ <sink>
+ <name>in</name>
+ <type>byte</type>
+ </sink>
+ <source>
+ <name>out</name>
+ <type>byte</type>
+ </source>
+</block>
diff --git a/gr-blocks/grc/blocks_sample_and_hold_xx.xml b/gr-blocks/grc/blocks_sample_and_hold_xx.xml
new file mode 100644
index 0000000000..1583204c02
--- /dev/null
+++ b/gr-blocks/grc/blocks_sample_and_hold_xx.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##Sample and Hold
+###################################################
+ -->
+<block>
+ <name>Sample and Hold</name>
+ <key>blocks_sample_and_hold_xx</key>
+ <import>from gnuradio import blocks</import>
+ <make>blocks.sample_and_hold_$(type.fcn)()</make>
+ <param>
+ <name>Type</name>
+ <key>type</key>
+ <type>enum</type>
+ <option>
+ <name>Float</name>
+ <key>float</key>
+ <opt>fcn:ff</opt>
+ </option>
+ <option>
+ <name>Int</name>
+ <key>int</key>
+ <opt>fcn:ii</opt>
+ </option>
+ <option>
+ <name>Short</name>
+ <key>short</key>
+ <opt>fcn:ss</opt>
+ </option>
+ <option>
+ <name>Byte</name>
+ <key>byte</key>
+ <opt>fcn:bb</opt>
+ </option>
+ </param>
+ <sink>
+ <name>in</name>
+ <type>$type</type>
+ </sink>
+ <sink>
+ <name>ctrl</name>
+ <type>byte</type>
+ </sink>
+ <source>
+ <name>out</name>
+ <type>$type</type>
+ </source>
+</block>
diff --git a/gr-blocks/grc/blocks_skiphead.xml b/gr-blocks/grc/blocks_skiphead.xml
new file mode 100644
index 0000000000..7d90862830
--- /dev/null
+++ b/gr-blocks/grc/blocks_skiphead.xml
@@ -0,0 +1,65 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##Skip Head
+###################################################
+ -->
+<block>
+ <name>Skip Head</name>
+ <key>blocks_skiphead</key>
+ <import>from gnuradio import blocks</import>
+ <make>blocks.skiphead($type.size*$vlen, $num_items)</make>
+ <param>
+ <name>Type</name>
+ <key>type</key>
+ <type>enum</type>
+ <option>
+ <name>Complex</name>
+ <key>complex</key>
+ <opt>size:gr.sizeof_gr_complex</opt>
+ </option>
+ <option>
+ <name>Float</name>
+ <key>float</key>
+ <opt>size:gr.sizeof_float</opt>
+ </option>
+ <option>
+ <name>Int</name>
+ <key>int</key>
+ <opt>size:gr.sizeof_int</opt>
+ </option>
+ <option>
+ <name>Short</name>
+ <key>short</key>
+ <opt>size:gr.sizeof_short</opt>
+ </option>
+ <option>
+ <name>Byte</name>
+ <key>byte</key>
+ <opt>size:gr.sizeof_char</opt>
+ </option>
+ </param>
+ <param>
+ <name>Num Items</name>
+ <key>num_items</key>
+ <value>1024</value>
+ <type>int</type>
+ </param>
+ <param>
+ <name>Vec Length</name>
+ <key>vlen</key>
+ <value>1</value>
+ <type>int</type>
+ </param>
+ <check>$vlen &gt; 0</check>
+ <sink>
+ <name>in</name>
+ <type>$type</type>
+ <vlen>$vlen</vlen>
+ </sink>
+ <source>
+ <name>out</name>
+ <type>$type</type>
+ <vlen>$vlen</vlen>
+ </source>
+</block>
diff --git a/gr-blocks/grc/blocks_socket_pdu.xml b/gr-blocks/grc/blocks_socket_pdu.xml
new file mode 100644
index 0000000000..1e897cfc4b
--- /dev/null
+++ b/gr-blocks/grc/blocks_socket_pdu.xml
@@ -0,0 +1,62 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+## Socket PDU Message source/sink
+###################################################
+ -->
+<block>
+ <name>Socket PDU</name>
+ <key>blocks_socket_pdu</key>
+ <import>from gnuradio import blocks</import>
+ <make>blocks.socket_pdu($type, $host, $port, $mtu)</make>
+ <param>
+ <name>Type</name>
+ <key>type</key>
+ <value>TCP_SERVER</value>
+ <type>enum</type>
+ <option>
+ <name>TCP Server</name>
+ <key>"TCP_SERVER"</key>
+ </option>
+ <option>
+ <name>TCP Client</name>
+ <key>"TCP_CLIENT"</key>
+ </option>
+ <option>
+ <name>UDP Server</name>
+ <key>"UDP_SERVER"</key>
+ </option>
+ <option>
+ <name>UDP Client</name>
+ <key>"UDP_CLIENT"</key>
+ </option>
+ </param>
+ <param>
+ <name>Host</name>
+ <key>host</key>
+ <value></value>
+ <type>string</type>
+ </param>
+ <param>
+ <name>Port</name>
+ <key>port</key>
+ <value>52001</value>
+ <type>string</type>
+ </param>
+ <param>
+ <name>MTU</name>
+ <key>mtu</key>
+ <value>10000</value>
+ <type>int</type>
+ </param>
+ <sink>
+ <name>pdus</name>
+ <type>message</type>
+ <optional>1</optional>
+ </sink>
+ <source>
+ <name>pdus</name>
+ <type>message</type>
+ <optional>1</optional>
+ </source>
+</block>
diff --git a/gr-blocks/grc/blocks_tag_debug.xml b/gr-blocks/grc/blocks_tag_debug.xml
new file mode 100644
index 0000000000..929e53afed
--- /dev/null
+++ b/gr-blocks/grc/blocks_tag_debug.xml
@@ -0,0 +1,82 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+## Tag Debug
+###################################################
+ -->
+<block>
+ <name>Tag Debug</name>
+ <key>blocks_tag_debug</key>
+ <import>from gnuradio import blocks</import>
+ <make>blocks.tag_debug($type.size*$vlen, $name)</make>
+ <callback>set_display($display)</callback>
+ <param>
+ <name>Input Type</name>
+ <key>type</key>
+ <type>enum</type>
+ <option>
+ <name>Complex</name>
+ <key>complex</key>
+ <opt>size:gr.sizeof_gr_complex</opt>
+ </option>
+ <option>
+ <name>Float</name>
+ <key>float</key>
+ <opt>size:gr.sizeof_float</opt>
+ </option>
+ <option>
+ <name>Int</name>
+ <key>int</key>
+ <opt>size:gr.sizeof_int</opt>
+ </option>
+ <option>
+ <name>Short</name>
+ <key>short</key>
+ <opt>size:gr.sizeof_short</opt>
+ </option>
+ <option>
+ <name>Byte</name>
+ <key>byte</key>
+ <opt>size:gr.sizeof_char</opt>
+ </option>
+ </param>
+ <param>
+ <name>Name</name>
+ <key>name</key>
+ <type>string</type>
+ </param>
+ <param>
+ <name>Num Inputs</name>
+ <key>num_inputs</key>
+ <value>1</value>
+ <type>int</type>
+ </param>
+ <param>
+ <name>Vec Length</name>
+ <key>vlen</key>
+ <value>1</value>
+ <type>int</type>
+ </param>
+ <param>
+ <name>Display</name>
+ <key>display</key>
+ <value>True</value>
+ <type>bool</type>
+ <option>
+ <name>On</name>
+ <key>True</key>
+ </option>
+ <option>
+ <name>Off</name>
+ <key>False</key>
+ </option>
+ </param>
+ <check>$num_inputs &gt;= 1</check>
+ <check>$vlen &gt; 0</check>
+ <sink>
+ <name>in</name>
+ <type>$type</type>
+ <vlen>$vlen</vlen>
+ <nports>$num_inputs</nports>
+ </sink>
+</block>
diff --git a/gr-blocks/grc/blocks_tagged_file_sink.xml b/gr-blocks/grc/blocks_tagged_file_sink.xml
new file mode 100644
index 0000000000..a849c48c9a
--- /dev/null
+++ b/gr-blocks/grc/blocks_tagged_file_sink.xml
@@ -0,0 +1,60 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##Tagged File Sink
+###################################################
+ -->
+<block>
+ <name>Tagged File Sink</name>
+ <key>blocks_tagged_file_sink</key>
+ <import>from gnuradio import blocks</import>
+ <make>blocks.tagged_file_sink($type.size*$vlen, $samp_rate)</make>
+ <param>
+ <name>Input Type</name>
+ <key>type</key>
+ <type>enum</type>
+ <option>
+ <name>Complex</name>
+ <key>complex</key>
+ <opt>size:gr.sizeof_gr_complex</opt>
+ </option>
+ <option>
+ <name>Float</name>
+ <key>float</key>
+ <opt>size:gr.sizeof_float</opt>
+ </option>
+ <option>
+ <name>Int</name>
+ <key>int</key>
+ <opt>size:gr.sizeof_int</opt>
+ </option>
+ <option>
+ <name>Short</name>
+ <key>short</key>
+ <opt>size:gr.sizeof_short</opt>
+ </option>
+ <option>
+ <name>Byte</name>
+ <key>byte</key>
+ <opt>size:gr.sizeof_char</opt>
+ </option>
+ </param>
+ <param>
+ <name>Sample Rate</name>
+ <key>samp_rate</key>
+ <value>samp_rate</value>
+ <type>int</type>
+ </param>
+ <param>
+ <name>Vec Length</name>
+ <key>vlen</key>
+ <value>1</value>
+ <type>int</type>
+ </param>
+ <check>$vlen &gt; 0</check>
+ <sink>
+ <name>in</name>
+ <type>$type</type>
+ <vlen>$vlen</vlen>
+ </sink>
+</block>
diff --git a/gr-blocks/grc/blocks_tagged_stream_mux.xml b/gr-blocks/grc/blocks_tagged_stream_mux.xml
new file mode 100644
index 0000000000..40d98a3346
--- /dev/null
+++ b/gr-blocks/grc/blocks_tagged_stream_mux.xml
@@ -0,0 +1,65 @@
+<block>
+ <name>Tagged Stream Mux</name>
+ <key>blocks_tagged_stream_mux</key>
+ <category>Stream Operations</category>
+ <import>from gnuradio import blocks</import>
+ <make>blocks.tagged_stream_mux($type.size*$vlen, $lengthtagname)</make>
+ <param>
+ <name>IO Type</name>
+ <key>type</key>
+ <type>enum</type>
+ <option>
+ <name>Complex</name>
+ <key>complex</key>
+ <opt>size:gr.sizeof_gr_complex</opt>
+ </option>
+ <option>
+ <name>Float</name>
+ <key>float</key>
+ <opt>size:gr.sizeof_float</opt>
+ </option>
+ <option>
+ <name>Int</name>
+ <key>int</key>
+ <opt>size:gr.sizeof_int</opt>
+ </option>
+ <option>
+ <name>Short</name>
+ <key>short</key>
+ <opt>size:gr.sizeof_short</opt>
+ </option>
+ <option>
+ <name>Byte</name>
+ <key>byte</key>
+ <opt>size:gr.sizeof_char</opt>
+ </option>
+ </param>
+ <param>
+ <name>Number of inputs</name>
+ <key>ninputs</key>
+ <type>int</type>
+ </param>
+ <param>
+ <name>Length tag names</name>
+ <key>lengthtagname</key>
+ <type>string</type>
+ </param>
+ <param>
+ <name>Vector Length</name>
+ <key>vlen</key>
+ <value>1</value>
+ <type>int</type>
+ </param>
+ <sink>
+ <name>in</name>
+ <type>$type</type>
+ <vlen>$vlen</vlen>
+ <nports>$ninputs</nports>
+ </sink>
+ <source>
+ <name>out</name>
+ <type>$type</type>
+ <vlen>$vlen</vlen>
+ </source>
+</block>
+
diff --git a/gr-blocks/grc/blocks_tagged_stream_to_pdu.xml b/gr-blocks/grc/blocks_tagged_stream_to_pdu.xml
new file mode 100644
index 0000000000..6dd7b9be30
--- /dev/null
+++ b/gr-blocks/grc/blocks_tagged_stream_to_pdu.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+## Tagged Stream to PDU Message
+###################################################
+ -->
+<block>
+ <name>Tagged Stream to PDU</name>
+ <key>blocks_tagged_stream_to_pdu</key>
+ <import>from gnuradio import blocks</import>
+ <make>blocks.tagged_stream_to_pdu($type.tv)</make>
+ <param>
+ <name>Item Type</name>
+ <key>type</key>
+ <type>enum</type>
+ <option>
+ <name>Byte</name>
+ <key>byte</key>
+ <opt>tv:blocks.byte_t</opt>
+ </option>
+ <option>
+ <name>Complex</name>
+ <key>complex</key>
+ <opt>tv:blocks.complex_t</opt>
+ </option>
+ <option>
+ <name>Float</name>
+ <key>float</key>
+ <opt>tv:blocks.float_t</opt>
+ </option>
+ </param>
+ <sink>
+ <name>in</name>
+ <type>$type</type>
+ </sink>
+ <source>
+ <name>pdus</name>
+ <type>message</type>
+ </source>
+</block>
diff --git a/gr-blocks/grc/blocks_tuntap_pdu.xml b/gr-blocks/grc/blocks_tuntap_pdu.xml
new file mode 100644
index 0000000000..d9a63d4a7f
--- /dev/null
+++ b/gr-blocks/grc/blocks_tuntap_pdu.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+## TUNTAP PDU async message source/sink
+###################################################
+ -->
+<block>
+ <name>TUNTAP PDU</name>
+ <key>blocks_tuntap_pdu</key>
+ <import>from gnuradio import blocks</import>
+ <make>blocks.tuntap_pdu($ifn, $mtu)</make>
+ <param>
+ <name>Interface Name</name>
+ <key>ifn</key>
+ <value>tun0</value>
+ <type>string</type>
+ </param>
+ <param>
+ <name>MTU</name>
+ <key>mtu</key>
+ <value>10000</value>
+ <type>int</type>
+ </param>
+ <sink>
+ <name>pdus</name>
+ <type>message</type>
+ <optional>1</optional>
+ </sink>
+ <source>
+ <name>pdus</name>
+ <type>message</type>
+ <optional>1</optional>
+ </source>
+</block>
diff --git a/gr-blocks/grc/blocks_udp_sink.xml b/gr-blocks/grc/blocks_udp_sink.xml
new file mode 100644
index 0000000000..a001b2f1bb
--- /dev/null
+++ b/gr-blocks/grc/blocks_udp_sink.xml
@@ -0,0 +1,77 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##UDP Sink
+###################################################
+ -->
+<block>
+ <name>UDP Sink</name>
+ <key>blocks_udp_sink</key>
+ <import>from gnuradio import blocks</import>
+ <make>blocks.udp_sink($type.size*$vlen, $ipaddr, $port, $psize, $eof)</make>
+ <callback>set_mtu($mtu)</callback>
+ <param>
+ <name>Input Type</name>
+ <key>type</key>
+ <type>enum</type>
+ <option>
+ <name>Complex</name>
+ <key>complex</key>
+ <opt>size:gr.sizeof_gr_complex</opt>
+ </option>
+ <option>
+ <name>Float</name>
+ <key>float</key>
+ <opt>size:gr.sizeof_float</opt>
+ </option>
+ <option>
+ <name>Int</name>
+ <key>int</key>
+ <opt>size:gr.sizeof_int</opt>
+ </option>
+ <option>
+ <name>Short</name>
+ <key>short</key>
+ <opt>size:gr.sizeof_short</opt>
+ </option>
+ <option>
+ <name>Byte</name>
+ <key>byte</key>
+ <opt>size:gr.sizeof_char</opt>
+ </option>
+ </param>
+ <param>
+ <name>Destination IP Address</name>
+ <key>ipaddr</key>
+ <type>string</type>
+ </param>
+ <param>
+ <name>Destination Port</name>
+ <key>port</key>
+ <type>int</type>
+ </param>
+ <param>
+ <name>Payload Size</name>
+ <key>psize</key>
+ <value>1472</value>
+ <type>int</type>
+ </param>
+ <param>
+ <name>Send Null Pkt as EOF</name>
+ <key>eof</key>
+ <value>True</value>
+ <type>bool</type>
+ </param>
+ <param>
+ <name>Vec Length</name>
+ <key>vlen</key>
+ <value>1</value>
+ <type>int</type>
+ </param>
+ <check>$vlen &gt; 0</check>
+ <sink>
+ <name>in</name>
+ <type>$type</type>
+ <vlen>$vlen</vlen>
+ </sink>
+</block>
diff --git a/gr-blocks/grc/blocks_udp_source.xml b/gr-blocks/grc/blocks_udp_source.xml
new file mode 100644
index 0000000000..bca1dff8b8
--- /dev/null
+++ b/gr-blocks/grc/blocks_udp_source.xml
@@ -0,0 +1,79 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##UDP Source
+###################################################
+ -->
+<block>
+ <name>UDP Source</name>
+ <key>blocks_udp_source</key>
+ <import>from gnuradio import blocks</import>
+ <make>blocks.udp_source($type.size*$vlen, $ipaddr, $port, $psize, $eof)</make>
+ <callback>set_mtu($mtu)</callback>
+ <param>
+ <name>Output Type</name>
+ <key>type</key>
+ <type>enum</type>
+ <option>
+ <name>Complex</name>
+ <key>complex</key>
+ <opt>size:gr.sizeof_gr_complex</opt>
+ </option>
+ <option>
+ <name>Float</name>
+ <key>float</key>
+ <opt>size:gr.sizeof_float</opt>
+ </option>
+ <option>
+ <name>Int</name>
+ <key>int</key>
+ <opt>size:gr.sizeof_int</opt>
+ </option>
+ <option>
+ <name>Short</name>
+ <key>short</key>
+ <opt>size:gr.sizeof_short</opt>
+ </option>
+ <option>
+ <name>Byte</name>
+ <key>byte</key>
+ <opt>size:gr.sizeof_char</opt>
+ </option>
+ </param>
+ <param>
+ <name>IP Address</name>
+ <key>ipaddr</key>
+ <value>127.0.0.1</value>
+ <type>string</type>
+ </param>
+ <param>
+ <name>Port</name>
+ <key>port</key>
+ <value>1234</value>
+ <type>int</type>
+ </param>
+ <param>
+ <name>Payload Size</name>
+ <key>psize</key>
+ <value>1472</value>
+ <type>int</type>
+ </param>
+ <param>
+ <name>Null Pkt is EOF</name>
+ <key>eof</key>
+ <value>True</value>
+ <type>bool</type>
+ </param>
+ <param>
+ <name>Vec Length</name>
+ <key>vlen</key>
+ <value>1</value>
+ <type>int</type>
+ </param>
+ <check>$vlen &gt; 0</check>
+ <source>
+ <name>out</name>
+ <type>$type</type>
+ <vlen>$vlen</vlen>
+ </source>
+</block>
diff --git a/gr-blocks/grc/blocks_unpack_k_bits_bb.xml b/gr-blocks/grc/blocks_unpack_k_bits_bb.xml
new file mode 100644
index 0000000000..90d7493af0
--- /dev/null
+++ b/gr-blocks/grc/blocks_unpack_k_bits_bb.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##Unpack K Bits
+###################################################
+ -->
+<block>
+ <name>Unpack K Bits</name>
+ <key>blocks_unpack_k_bits_bb</key>
+ <import>from gnuradio import blocks</import>
+ <make>blocks.unpack_k_bits_bb($k)</make>
+ <param>
+ <name>K</name>
+ <key>k</key>
+ <type>int</type>
+ </param>
+ <sink>
+ <name>in</name>
+ <type>byte</type>
+ </sink>
+ <source>
+ <name>out</name>
+ <type>byte</type>
+ </source>
+</block>
diff --git a/gr-blocks/grc/blocks_vco_f.xml b/gr-blocks/grc/blocks_vco_f.xml
new file mode 100644
index 0000000000..77a3ba0bd4
--- /dev/null
+++ b/gr-blocks/grc/blocks_vco_f.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##VCO
+###################################################
+ -->
+<block>
+ <name>VCO</name>
+ <key>blocks_vco_f</key>
+ <import>from gnuradio import blocks</import>
+ <make>blocks.vco_f($samp_rate, $sensitivity, $amplitude)</make>
+ <param>
+ <name>Sample Rate</name>
+ <key>samp_rate</key>
+ <type>real</type>
+ </param>
+ <param>
+ <name>Sensitivity</name>
+ <key>sensitivity</key>
+ <type>real</type>
+ </param>
+ <param>
+ <name>Amplitude</name>
+ <key>amplitude</key>
+ <type>real</type>
+ </param>
+ <sink>
+ <name>in</name>
+ <type>float</type>
+ </sink>
+ <source>
+ <name>out</name>
+ <type>float</type>
+ </source>
+</block>
diff --git a/gr-blocks/grc/blocks_vector_insert_x.xml b/gr-blocks/grc/blocks_vector_insert_x.xml
new file mode 100644
index 0000000000..2bc7ada2e6
--- /dev/null
+++ b/gr-blocks/grc/blocks_vector_insert_x.xml
@@ -0,0 +1,80 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##Vector Source
+###################################################
+ -->
+<block>
+ <name>Vector Insert</name>
+ <key>blocks_vector_insert_x</key>
+ <import>from gnuradio import blocks</import>
+ <make>blocks.vector_insert_$(type.fcn)($vector, $period, $offset)</make>
+ <param>
+ <name>Output Type</name>
+ <key>type</key>
+ <type>enum</type>
+ <option>
+ <name>Byte</name>
+ <key>byte</key>
+ <opt>fcn:b</opt>
+ <opt>vec_type:int_vector</opt>
+ </option>
+ <option>
+ <name>Complex</name>
+ <key>complex</key>
+ <opt>fcn:c</opt>
+ <opt>vec_type:complex_vector</opt>
+ </option>
+ <option>
+ <name>Float</name>
+ <key>float</key>
+ <opt>fcn:f</opt>
+ <opt>vec_type:real_vector</opt>
+ </option>
+ <option>
+ <name>Int</name>
+ <key>int</key>
+ <opt>fcn:i</opt>
+ <opt>vec_type:int_vector</opt>
+ </option>
+ <option>
+ <name>Short</name>
+ <key>short</key>
+ <opt>fcn:s</opt>
+ <opt>vec_type:int_vector</opt>
+ </option>
+ </param>
+ <param>
+ <name>Vector</name>
+ <key>vector</key>
+ <value>0, 0, 0</value>
+ <type>$type.vec_type</type>
+ </param>
+ <param>
+ <name>Periodicity</name>
+ <key>period</key>
+ <value>100</value>
+ <type>int</type>
+ </param>
+ <param>
+ <name>Offset</name>
+ <key>offset</key>
+ <value>0</value>
+ <type>int</type>
+ </param>
+ <sink>
+ <name>in</name>
+ <type>$type</type>
+ </sink>
+ <source>
+ <name>out</name>
+ <type>$type</type>
+ </source>
+
+ <doc>
+ Periodicity, the length of the periodicity at which the vector should be inserted at the output.
+ (i.e. one vector for every N output items)
+
+ Offset sepcifies where in the cycle period we should begin at.
+ </doc>
+</block>
diff --git a/gr-blocks/grc/blocks_vector_sink_x.xml b/gr-blocks/grc/blocks_vector_sink_x.xml
new file mode 100644
index 0000000000..7f51731975
--- /dev/null
+++ b/gr-blocks/grc/blocks_vector_sink_x.xml
@@ -0,0 +1,54 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##Vector sink
+###################################################
+ -->
+<block>
+ <name>Vector Sink</name>
+ <key>blocks_vector_sink_x</key>
+ <import>from gnuradio import blocks</import>
+ <make>blocks.vector_sink_$(type.fcn)($vlen)</make>
+ <param>
+ <name>Input Type</name>
+ <key>type</key>
+ <type>enum</type>
+ <option>
+ <name>Complex</name>
+ <key>complex</key>
+ <opt>fcn:c</opt>
+ </option>
+ <option>
+ <name>Float</name>
+ <key>float</key>
+ <opt>fcn:f</opt>
+ </option>
+ <option>
+ <name>Int</name>
+ <key>int</key>
+ <opt>fcn:i</opt>
+ </option>
+ <option>
+ <name>Short</name>
+ <key>short</key>
+ <opt>fcn:s</opt>
+ </option>
+ <option>
+ <name>Byte</name>
+ <key>byte</key>
+ <opt>fcn:b</opt>
+ </option>
+ </param>
+ <param>
+ <name>Vec Length</name>
+ <key>vlen</key>
+ <value>1</value>
+ <type>int</type>
+ </param>
+ <check>$vlen &gt; 0</check>
+ <sink>
+ <name>in</name>
+ <type>$type</type>
+ <vlen>$vlen</vlen>
+ </sink>
+</block>
diff --git a/gr-blocks/grc/blocks_vector_source_x.xml b/gr-blocks/grc/blocks_vector_source_x.xml
new file mode 100644
index 0000000000..5221c4f3eb
--- /dev/null
+++ b/gr-blocks/grc/blocks_vector_source_x.xml
@@ -0,0 +1,85 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##Vector Source
+###################################################
+ -->
+<block>
+ <name>Vector Source</name>
+ <key>blocks_vector_source_x</key>
+ <import>from gnuradio import blocks</import>
+ <make>blocks.vector_source_$(type.fcn)($vector, $repeat, $vlen, $tags)</make>
+ <param>
+ <name>Output Type</name>
+ <key>type</key>
+ <type>enum</type>
+ <option>
+ <name>Complex</name>
+ <key>complex</key>
+ <opt>fcn:c</opt>
+ <opt>vec_type:complex_vector</opt>
+ </option>
+ <option>
+ <name>Float</name>
+ <key>float</key>
+ <opt>fcn:f</opt>
+ <opt>vec_type:real_vector</opt>
+ </option>
+ <option>
+ <name>Int</name>
+ <key>int</key>
+ <opt>fcn:i</opt>
+ <opt>vec_type:int_vector</opt>
+ </option>
+ <option>
+ <name>Short</name>
+ <key>short</key>
+ <opt>fcn:s</opt>
+ <opt>vec_type:int_vector</opt>
+ </option>
+ <option>
+ <name>Byte</name>
+ <key>byte</key>
+ <opt>fcn:b</opt>
+ <opt>vec_type:int_vector</opt>
+ </option>
+ </param>
+ <param>
+ <name>Vector</name>
+ <key>vector</key>
+ <value>[0, 0, 0]</value>
+ <type>raw</type>
+ </param>
+ <param>
+ <name>Tags</name>
+ <key>tags</key>
+ <value>[]</value>
+ <type>raw</type>
+ </param>
+ <param>
+ <name>Repeat</name>
+ <key>repeat</key>
+ <value>True</value>
+ <type>enum</type>
+ <option>
+ <name>Yes</name>
+ <key>True</key>
+ </option>
+ <option>
+ <name>No</name>
+ <key>False</key>
+ </option>
+ </param>
+ <param>
+ <name>Vec Length</name>
+ <key>vlen</key>
+ <value>1</value>
+ <type>int</type>
+ </param>
+ <check>$vlen &gt; 0</check>
+ <source>
+ <name>out</name>
+ <type>$type</type>
+ <vlen>$vlen</vlen>
+ </source>
+</block>
diff --git a/gr-blocks/grc/blocks_wavfile_sink.xml b/gr-blocks/grc/blocks_wavfile_sink.xml
new file mode 100644
index 0000000000..8e81d8d202
--- /dev/null
+++ b/gr-blocks/grc/blocks_wavfile_sink.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##Wav File Sink
+###################################################
+ -->
+<block>
+ <name>Wav File Sink</name>
+ <key>blocks_wavfile_sink</key>
+ <import>from gnuradio import blocks</import>
+ <make>blocks.wavfile_sink($file, $nchan, $samp_rate, $bits_per_sample)</make>
+ <callback>open($file)</callback>
+ <param>
+ <name>File</name>
+ <key>file</key>
+ <value></value>
+ <type>file_save</type>
+ </param>
+ <param>
+ <name>N Channels</name>
+ <key>nchan</key>
+ <value>1</value>
+ <type>int</type>
+ </param>
+ <param>
+ <name>Sample Rate</name>
+ <key>samp_rate</key>
+ <value>samp_rate</value>
+ <type>int</type>
+ </param>
+ <param>
+ <name>Bits per Sample</name>
+ <key>bits_per_sample</key>
+ <value>8</value>
+ <type>int</type>
+ </param>
+ <check>1 &lt;= $nchan</check>
+ <sink>
+ <name>in</name>
+ <type>float</type>
+ <nports>$nchan</nports>
+ </sink>
+</block>
diff --git a/gr-blocks/grc/blocks_wavfile_source.xml b/gr-blocks/grc/blocks_wavfile_source.xml
new file mode 100644
index 0000000000..deb48472a4
--- /dev/null
+++ b/gr-blocks/grc/blocks_wavfile_source.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##Wav File Source
+###################################################
+ -->
+<block>
+ <name>Wav File Source</name>
+ <key>blocks_wavfile_source</key>
+ <import>from gnuradio import blocks</import>
+ <make>blocks.wavfile_source($file, $repeat)</make>
+ <param>
+ <name>File</name>
+ <key>file</key>
+ <value></value>
+ <type>file_open</type>
+ </param>
+ <param>
+ <name>Repeat</name>
+ <key>repeat</key>
+ <value>True</value>
+ <type>enum</type>
+ <option>
+ <name>Yes</name>
+ <key>True</key>
+ </option>
+ <option>
+ <name>No</name>
+ <key>False</key>
+ </option>
+ </param>
+ <param>
+ <name>N Channels</name>
+ <key>nchan</key>
+ <value>1</value>
+ <type>int</type>
+ </param>
+ <check>1 &lt;= $nchan</check>
+ <source>
+ <name>out</name>
+ <type>float</type>
+ <nports>$nchan</nports>
+ </source>
+</block>
diff --git a/gr-blocks/include/blocks/CMakeLists.txt b/gr-blocks/include/blocks/CMakeLists.txt
index d3c08f6e6d..7b74ca7a5d 100644
--- a/gr-blocks/include/blocks/CMakeLists.txt
+++ b/gr-blocks/include/blocks/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright 2012 Free Software Foundation, Inc.
+# Copyright 2013 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -69,17 +69,28 @@ expand_h(add_const_XX ss ii ff cc)
expand_h(add_const_vXX ss ii ff cc)
expand_h(and_XX bb ss ii)
expand_h(and_const_XX bb ss ii)
+expand_h(argmax_XX fs is ss)
expand_h(divide_XX ss ii ff cc)
expand_h(integrate_XX ss ii ff cc)
+expand_h(max_XX ff ii ss)
+expand_h(moving_average_XX ss ii ff cc)
expand_h(multiply_XX ss ii)
expand_h(multiply_const_XX ss ii)
expand_h(multiply_const_vXX ss ii ff cc)
+expand_h(mute_XX ss ii ff cc)
expand_h(not_XX bb ss ii)
expand_h(or_XX bb ss ii)
+expand_h(peak_detector_XX fb ib sb)
+expand_h(probe_signal_X b s i f c)
+expand_h(probe_signal_vX b s i f c)
+expand_h(sample_and_hold_XX bb ss ii ff)
expand_h(sub_XX ss ii ff cc)
expand_h(xor_XX bb ss ii)
expand_h(packed_to_unpacked_XX bb ss ii)
expand_h(unpacked_to_packed_XX bb ss ii)
+expand_h(vector_insert_X b s i f c)
+expand_h(vector_sink_X b s i f c)
+expand_h(vector_source_X b s i f c)
add_custom_target(blocks_generated_includes DEPENDS
${generated_includes}
@@ -91,11 +102,23 @@ add_custom_target(blocks_generated_includes DEPENDS
install(FILES
${generated_includes}
api.h
+ control_loop.h
count_bits.h
+ file_sink_base.h
+ lfsr_15_1_0.h
+ lfsr_32k.h
log2_const.h
+ rotator.h
+ wavfile.h
add_ff.h
+ annotator_1to1.h
+ annotator_alltoall.h
+ annotator_raw.h
+ bin_statistics_f.h
+ burst_tagger.h
char_to_float.h
char_to_short.h
+ check_lfsr_32k_s.h
complex_to_interleaved_short.h
complex_to_float.h
complex_to_imag.h
@@ -104,8 +127,13 @@ install(FILES
complex_to_mag_squared.h
complex_to_arg.h
conjugate_cc.h
+ copy.h
deinterleave.h
delay.h
+ endian_swap.h
+ file_descriptor_sink.h
+ file_descriptor_source.h
+ file_sink.h
file_source.h
file_meta_sink.h
file_meta_source.h
@@ -114,37 +142,67 @@ install(FILES
float_to_int.h
float_to_short.h
float_to_uchar.h
+ head.h
int_to_float.h
interleave.h
interleaved_short_to_complex.h
keep_m_in_n.h
keep_one_in_n.h
+ lfsr_32k_source_s.h
+ message_debug.h
+ message_sink.h
+ message_source.h
+ message_strobe.h
+ message_burst_source.h
multiply_cc.h
multiply_ff.h
multiply_conjugate_cc.h
multiply_const_cc.h
multiply_const_ff.h
nlog10_ff.h
+ nop.h
+ null_sink.h
+ null_source.h
+ pack_k_bits_bb.h
patterned_interleaver.h
+ pdu.h
+ pdu_to_tagged_stream.h
peak_detector2_fb.h
+ plateau_detector_fb.h
+ probe_rate.h
regenerate_bb.h
+ repack_bits_bb.h
repeat.h
rms_cf.h
rms_ff.h
short_to_char.h
short_to_float.h
+ skiphead.h
+ socket_pdu.h
stream_mux.h
stream_to_streams.h
stream_to_vector.h
streams_to_stream.h
streams_to_vector.h
stretch_ff.h
+ tag_debug.h
+ tagged_file_sink.h
+ tagged_stream_mux.h
+ tagged_stream_to_pdu.h
threshold_ff.h
throttle.h
transcendental.h
+ tuntap_pdu.h
uchar_to_float.h
+ udp_sink.h
+ udp_source.h
+ unpack_k_bits_bb.h
+ vco_f.h
+ vector_map.h
vector_to_stream.h
vector_to_streams.h
+ wavfile_sink.h
+ wavfile_source.h
DESTINATION ${GR_INCLUDE_DIR}/gnuradio/blocks
COMPONENT "blocks_devel"
)
diff --git a/gr-blocks/include/blocks/annotator_1to1.h b/gr-blocks/include/blocks/annotator_1to1.h
new file mode 100644
index 0000000000..6cc8db6eef
--- /dev/null
+++ b/gr-blocks/include/blocks/annotator_1to1.h
@@ -0,0 +1,60 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2010,2013 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_ANNOTATOR_1TO1_H
+#define INCLUDED_GR_ANNOTATOR_1TO1_H
+
+#include <blocks/api.h>
+#include <gr_sync_block.h>
+
+namespace gr {
+ namespace blocks {
+
+ /*!
+ * \brief 1-to-1 stream annotator testing block. FOR TESTING PURPOSES ONLY.
+ *
+ * This block creates tags to be sent downstream every 10,000
+ * items it sees. The tags contain the name and ID of the
+ * instantiated block, use "seq" as a key, and have a counter that
+ * increments by 1 for every tag produced that is used as the
+ * tag's value. The tags are propagated using the 1-to-1 policy.
+ *
+ * It also stores a copy of all tags it sees flow past it. These
+ * tags can be recalled externally with the data() member.
+ *
+ * This block is only meant for testing and showing how to use the tags.
+ */
+ class BLOCKS_API annotator_1to1 : virtual public gr_sync_block
+ {
+ public:
+ // gr::blocks::annotator_1to1::sptr
+ typedef boost::shared_ptr<annotator_1to1> sptr;
+
+ static sptr make(int when, size_t sizeof_stream_item);
+
+ virtual std::vector<gr_tag_t> data() const = 0;
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_GR_ANNOTATOR_1TO1_H */
diff --git a/gr-blocks/include/blocks/annotator_alltoall.h b/gr-blocks/include/blocks/annotator_alltoall.h
new file mode 100644
index 0000000000..558aea69ca
--- /dev/null
+++ b/gr-blocks/include/blocks/annotator_alltoall.h
@@ -0,0 +1,61 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2010,2013 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_ANNOTATOR_ALLTOALL_H
+#define INCLUDED_GR_ANNOTATOR_ALLTOALL_H
+
+#include <blocks/api.h>
+#include <gr_sync_block.h>
+
+namespace gr {
+ namespace blocks {
+
+ /*!
+ * \brief All-to-all stream annotator testing block. FOR TESTING PURPOSES ONLY.
+ *
+ * This block creates tags to be sent downstream every 10,000
+ * items it sees. The tags contain the name and ID of the
+ * instantiated block, use "seq" as a key, and have a counter that
+ * increments by 1 for every tag produced that is used as the
+ * tag's value. The tags are propagated using the all-to-all
+ * policy.
+ *
+ * It also stores a copy of all tags it sees flow past it. These
+ * tags can be recalled externally with the data() member.
+ *
+ * This block is only meant for testing and showing how to use the tags.
+ */
+ class BLOCKS_API annotator_alltoall : virtual public gr_sync_block
+ {
+ public:
+ // gr::blocks::annotator_alltoall::sptr
+ typedef boost::shared_ptr<annotator_alltoall> sptr;
+
+ static sptr make(int when, size_t sizeof_stream_item);
+
+ virtual std::vector<gr_tag_t> data() const = 0;
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_GR_ANNOTATOR_ALLTOALL_H */
diff --git a/gr-blocks/include/blocks/annotator_raw.h b/gr-blocks/include/blocks/annotator_raw.h
new file mode 100644
index 0000000000..e835f0bd8d
--- /dev/null
+++ b/gr-blocks/include/blocks/annotator_raw.h
@@ -0,0 +1,57 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2010,2013 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_ANNOTATOR_RAW_H
+#define INCLUDED_GR_ANNOTATOR_RAW_H
+
+#include <blocks/api.h>
+#include <gr_sync_block.h>
+#include <gr_tags.h>
+
+namespace gr {
+ namespace blocks {
+
+ /*!
+ * \brief raw stream annotator testing block.
+ *
+ * This block creates arbitrary tags to be sent downstream blocks
+ * to be sent are set manually via accessor methods and are sent
+ * only once.
+ *
+ * This block is intended for testing of tag related blocks
+ */
+ class BLOCKS_API annotator_raw : virtual public gr_sync_block
+ {
+ public:
+ // gr::blocks::annotator_raw::sptr
+ typedef boost::shared_ptr<annotator_raw> sptr;
+
+ static sptr make(size_t sizeof_stream_item);
+
+ // insert a tag to be added
+ void add_tag(uint64_t offset, pmt::pmt_t key, pmt::pmt_t val);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_GR_ANNOTATOR_RAW_H */
diff --git a/gr-blocks/include/blocks/argmax_XX.h.t b/gr-blocks/include/blocks/argmax_XX.h.t
new file mode 100644
index 0000000000..4c25c1c8c4
--- /dev/null
+++ b/gr-blocks/include/blocks/argmax_XX.h.t
@@ -0,0 +1,60 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007,2013 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.
+ */
+
+// @WARNING@
+
+#ifndef @GUARD_NAME@
+#define @GUARD_NAME@
+
+#include <blocks/api.h>
+#include <gr_sync_block.h>
+
+namespace gr {
+ namespace blocks {
+
+ /*!
+ * \brief Compares vectors from multiple streams and determines
+ * the index in the vector and stream number where the maximum
+ * value occurred.
+ * \ingroup math_blk
+ *
+ * Data is passed in as a vector of length \p vlen from multiple
+ * input sources. It will look through these streams of \p vlen
+ * data items and output two streams.
+ * Stream 0 will contain the index value in the vector where
+ * the maximum value occurred.
+ * Stream 1 will contain the number of the input stream that
+ * held the maximum value.
+ */
+ class BLOCKS_API @NAME@ : virtual public gr_sync_block
+ {
+ public:
+ // gr::blocks::@NAME@::sptr
+ typedef boost::shared_ptr<@NAME@> sptr;
+
+ static sptr make(size_t vlen);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* @GUARD_NAME@ */
diff --git a/gr-blocks/include/blocks/bin_statistics_f.h b/gr-blocks/include/blocks/bin_statistics_f.h
new file mode 100644
index 0000000000..a73afc82d6
--- /dev/null
+++ b/gr-blocks/include/blocks/bin_statistics_f.h
@@ -0,0 +1,76 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2006,2013 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_BIN_STATISTICS_F_H
+#define INCLUDED_GR_BIN_STATISTICS_F_H
+
+#include <blocks/api.h>
+#include <gr_sync_block.h>
+#include <gr_msg_queue.h>
+#include <gr_feval.h>
+
+namespace gr {
+ namespace blocks {
+
+ /*!
+ * \brief control scanning and record frequency domain statistics
+ * \ingroup sink_blk
+ */
+ class BLOCKS_API bin_statistics_f : virtual public gr_sync_block
+ {
+ protected:
+ std::vector<float> d_max; // per bin maxima
+
+ virtual size_t vlen() const = 0;
+ virtual double center_freq() const = 0;
+ virtual gr_msg_queue_sptr msgq() const = 0;
+
+ virtual void reset_stats() = 0;
+ virtual void accrue_stats(const float *input) = 0;
+ virtual void send_stats() = 0;
+
+ public:
+ // gr::blocks::bin_statistics_f::sptr
+ typedef boost::shared_ptr<bin_statistics_f> sptr;
+
+ /*!
+ * Build a bin statistics block. See qa_bin_statistics.py and
+ * gr-uhd/examples/python/usrp_spectrum_sense.py for examples of
+ * its use, specifically how to use the callback function.
+ *
+ * \param vlen vector length
+ * \param msgq message queue
+ * \param tune a gr_feval_dd callback function
+ * \param tune_delay number of samples for the tune delay
+ * \param dwell_delay number of samples for the dwell delay
+ */
+ static sptr make(unsigned int vlen, // vector length
+ gr_msg_queue_sptr msgq,
+ gr_feval_dd *tune, // callback
+ size_t tune_delay, // samples
+ size_t dwell_delay); // samples
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_GR_BIN_STATISTICS_F_H */
diff --git a/gr-blocks/include/blocks/burst_tagger.h b/gr-blocks/include/blocks/burst_tagger.h
new file mode 100644
index 0000000000..408405f97b
--- /dev/null
+++ b/gr-blocks/include/blocks/burst_tagger.h
@@ -0,0 +1,74 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2010,2013 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_BURST_TAGGER_H
+#define INCLUDED_GR_BURST_TAGGER_H
+
+#include <blocks/api.h>
+#include <gr_sync_block.h>
+
+namespace gr {
+ namespace blocks {
+
+ /*!
+ * \brief Sets a burst on/off tag based on the value of the trigger input.
+ * \ingroup misc_blk
+ *
+ * This block takes two inputs, a signal stream on the input
+ * stream 0 and a trigger stream of shorts on input stream 1. If
+ * the trigger stream goes above 0, a tag with the key "burst"
+ * will be transmitted as a pmt::PMT_T. When the trigger signal
+ * falls below 0, the "burst" tag will be transmitted as
+ * pmt::PMT_F.
+ *
+ * The signal on stream 0 is retransmitted to output stream 0.
+ */
+ class BLOCKS_API burst_tagger : virtual public gr_sync_block
+ {
+ public:
+ // gr::blocks::burst_tagger::sptr
+ typedef boost::shared_ptr<burst_tagger> sptr;
+
+ /*!
+ * Build a burst tagger blocks.
+ *
+ * \param itemsize itemsize of the signal stream on input 0.
+ */
+ static sptr make(size_t itemsize);
+
+ /*!
+ * For the true burst tag, change the key name to \p key and a
+ * new value of \p value.
+ */
+ virtual void set_true_tag(const std::string &key, bool value) = 0;
+
+ /*!
+ * For the false burst tag, change the key name to \p key and a
+ * new value of \p value.
+ */
+ virtual void set_false_tag(const std::string &key, bool value) = 0;
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_GR_BURST_TAGGER_H */
diff --git a/gr-blocks/include/blocks/check_lfsr_32k_s.h b/gr-blocks/include/blocks/check_lfsr_32k_s.h
new file mode 100644
index 0000000000..4eba436e80
--- /dev/null
+++ b/gr-blocks/include/blocks/check_lfsr_32k_s.h
@@ -0,0 +1,56 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2013 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_CHECK_LFSR_32K_S_H
+#define INCLUDED_GR_CHECK_LFSR_32K_S_H
+
+#include <blocks/api.h>
+#include <gr_sync_block.h>
+
+namespace gr {
+ namespace blocks {
+
+ /*!
+ * \brief sink that checks if its input stream consists of a lfsr_32k sequence.
+ * \ingroup sink_blk
+ *
+ * This sink is typically used along with
+ * gr::blocks::lfsr_32k_source_s to test the USRP using its
+ * digital loopback mode.
+ */
+ class BLOCKS_API check_lfsr_32k_s : virtual public gr_sync_block
+ {
+ public:
+ // gr::blocks::check_lfsr_32k_s::sptr
+ typedef boost::shared_ptr<check_lfsr_32k_s> sptr;
+
+ static sptr make();
+
+ virtual long ntotal () const = 0;
+ virtual long nright () const = 0;
+ virtual long runlength () const = 0;
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_GR_CHECK_LFSR_32K_S_H */
diff --git a/gr-blocks/include/blocks/control_loop.h b/gr-blocks/include/blocks/control_loop.h
new file mode 100644
index 0000000000..e59429a1f7
--- /dev/null
+++ b/gr-blocks/include/blocks/control_loop.h
@@ -0,0 +1,233 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2011,2013 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 GR_BLOCKS_CONTROL_LOOP
+#define GR_BLOCKS_CONTROL_LOOP
+
+#include <blocks/api.h>
+
+namespace gr {
+ namespace blocks {
+
+ class BLOCKS_API control_loop
+ {
+ protected:
+ float d_phase, d_freq;
+ float d_max_freq, d_min_freq;
+ float d_damping, d_loop_bw;
+ float d_alpha, d_beta;
+
+ public:
+ control_loop(float loop_bw, float max_freq, float min_freq);
+ virtual ~control_loop();
+
+ /*! \brief update the system gains from the loop bandwidth and damping factor
+ *
+ * This function updates the system gains based on the loop
+ * bandwidth and damping factor of the system. These two
+ * factors can be set separately through their own set
+ * functions.
+ */
+ void update_gains();
+
+ /*! \brief Advance the control loop based on the current gain
+ * settings and the inputted error signal.
+ */
+ void advance_loop(float error);
+
+ /*! \brief Keep the phase between -2pi and 2pi
+ *
+ * This function keeps the phase between -2pi and 2pi. If the
+ * phase is greater than 2pi by d, it wraps around to be -2pi+d;
+ * similarly if it is less than -2pi by d, it wraps around to
+ * 2pi-d.
+ *
+ * This function should be called after advance_loop to keep the
+ * phase in a good operating region. It is set as a separate
+ * method in case another way is desired as this is fairly
+ * heavy-handed.
+ */
+ void phase_wrap();
+
+ /*! \brief Keep the frequency between d_min_freq and d_max_freq
+ *
+ * This function keeps the frequency between d_min_freq and
+ * d_max_freq. If the frequency is greater than d_max_freq, it
+ * is set to d_max_freq. If the frequency is less than
+ * d_min_freq, it is set to d_min_freq.
+ *
+ * This function should be called after advance_loop to keep the
+ * frequency in the specified region. It is set as a separate
+ * method in case another way is desired as this is fairly
+ * heavy-handed.
+ */
+ void frequency_limit();
+
+ /*******************************************************************
+ * SET FUNCTIONS
+ *******************************************************************/
+
+ /*!
+ * \brief Set the loop bandwidth
+ *
+ * Set the loop filter's bandwidth to \p bw. This should be
+ * between 2*pi/200 and 2*pi/100 (in rads/samp). It must also be
+ * a positive number.
+ *
+ * When a new damping factor is set, the gains, alpha and beta,
+ * of the loop are recalculated by a call to update_gains().
+ *
+ * \param bw (float) new bandwidth
+ */
+ void set_loop_bandwidth(float bw);
+
+ /*!
+ * \brief Set the loop damping factor
+ *
+ * Set the loop filter's damping factor to \p df. The damping
+ * factor should be sqrt(2)/2.0 for critically damped systems.
+ * Set it to anything else only if you know what you are
+ * doing. It must be a number between 0 and 1.
+ *
+ * When a new damping factor is set, the gains, alpha and beta,
+ * of the loop are recalculated by a call to update_gains().
+ *
+ * \param df (float) new damping factor
+ */
+ void set_damping_factor(float df);
+
+ /*!
+ * \brief Set the loop gain alpha
+ *
+ * Set's the loop filter's alpha gain parameter.
+ *
+ * This value should really only be set by adjusting the loop
+ * bandwidth and damping factor.
+ *
+ * \param alpha (float) new alpha gain
+ *
+ */
+ void set_alpha(float alpha);
+
+ /*!
+ * \brief Set the loop gain beta
+ *
+ * Set's the loop filter's beta gain parameter.
+ *
+ * This value should really only be set by adjusting the loop
+ * bandwidth and damping factor.
+ *
+ * \param beta (float) new beta gain
+ */
+ void set_beta(float beta);
+
+ /*!
+ * \brief Set the control loop's frequency.
+ *
+ * Set's the control loop's frequency. While this is normally
+ * updated by the inner loop of the algorithm, it could be
+ * useful to manually initialize, set, or reset this under
+ * certain circumstances.
+ *
+ * \param freq (float) new frequency
+ */
+ void set_frequency(float freq);
+
+ /*!
+ * \brief Set the control loop's phase.
+ *
+ * Set's the control loop's phase. While this is normally
+ * updated by the inner loop of the algorithm, it could be
+ * useful to manually initialize, set, or reset this under
+ * certain circumstances.
+ *
+ * \param phase (float) new phase
+ */
+ void set_phase(float phase);
+
+ /*!
+ * \brief Set the control loop's maximum frequency.
+ *
+ * Set the maximum frequency the control loop can track.
+ *
+ * \param freq (float) new max frequency
+ */
+ void set_max_freq(float freq);
+
+ /*!
+ * \brief Set the control loop's minimum frequency.
+ *
+ * Set the minimum frequency the control loop can track.
+ *
+ * \param freq (float) new min frequency
+ */
+ void set_min_freq(float freq);
+
+ /*******************************************************************
+ * GET FUNCTIONS
+ *******************************************************************/
+
+ /*!
+ * \brief Returns the loop bandwidth
+ */
+ float get_loop_bandwidth() const;
+
+ /*!
+ * \brief Returns the loop damping factor
+ */
+ float get_damping_factor() const;
+
+ /*!
+ * \brief Returns the loop gain alpha
+ */
+ float get_alpha() const;
+
+ /*!
+ * \brief Returns the loop gain beta
+ */
+ float get_beta() const;
+
+ /*!
+ * \brief Get the control loop's frequency estimate
+ */
+ float get_frequency() const;
+
+ /*!
+ * \brief Get the control loop's phase estimate
+ */
+ float get_phase() const;
+
+ /*!
+ * \brief Get the control loop's maximum frequency.
+ */
+ float get_max_freq() const;
+
+ /*!
+ * \brief Get the control loop's minimum frequency.
+ */
+ float get_min_freq() const;
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* GR_BLOCKS_CONTROL_LOOP */
diff --git a/gr-blocks/include/blocks/copy.h b/gr-blocks/include/blocks/copy.h
new file mode 100644
index 0000000000..5ed0ea0e92
--- /dev/null
+++ b/gr-blocks/include/blocks/copy.h
@@ -0,0 +1,54 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2006,2009,2013 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_COPY_H
+#define INCLUDED_GR_COPY_H
+
+#include <blocks/api.h>
+#include <gr_block.h>
+
+namespace gr {
+ namespace blocks {
+
+ /*!
+ * \brief output[i] = input[i]
+ * \ingroup misc_blk
+ *
+ * When enabled (default), this block copies its input to its
+ * output. When disabled, this block drops its input on the floor.
+ */
+ class BLOCKS_API copy : virtual public gr_block
+ {
+ public:
+ // gr::blocks::copy::sptr
+ typedef boost::shared_ptr<copy> sptr;
+
+ static sptr make(size_t itemsize);
+
+ virtual void set_enabled(bool enable) = 0;
+ virtual bool enabled() const = 0;
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_GR_COPY_H */
diff --git a/gr-blocks/include/blocks/endian_swap.h b/gr-blocks/include/blocks/endian_swap.h
new file mode 100644
index 0000000000..4b5a76218e
--- /dev/null
+++ b/gr-blocks/include/blocks/endian_swap.h
@@ -0,0 +1,50 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2012,2013 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_ENDIAN_SWAP_H
+#define INCLUDED_GR_ENDIAN_SWAP_H
+
+#include <blocks/api.h>
+#include <gr_sync_block.h>
+
+namespace gr {
+ namespace blocks {
+
+ /*!
+ * \brief Convert stream of items into thier byte swapped version
+ *
+ * \param item_size_bytes number of bytes per item, 1=no-op,
+ * 2=uint16_t, 4=uint32_t, 8=uint64_t
+ */
+ class BLOCKS_API endian_swap : virtual public gr_sync_block
+ {
+ public:
+ // gr::blocks::endian_swap::sptr
+ typedef boost::shared_ptr<endian_swap> sptr;
+
+ static sptr make(size_t item_size_bytes=1);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_GR_ENDIAN_SWAP_H */
diff --git a/gr-blocks/include/blocks/file_descriptor_sink.h b/gr-blocks/include/blocks/file_descriptor_sink.h
new file mode 100644
index 0000000000..df59e24c0a
--- /dev/null
+++ b/gr-blocks/include/blocks/file_descriptor_sink.h
@@ -0,0 +1,54 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2013 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_FILE_DESCRIPTOR_SINK_H
+#define INCLUDED_GR_FILE_DESCRIPTOR_SINK_H
+
+#include <blocks/api.h>
+#include <gr_sync_block.h>
+
+namespace gr {
+ namespace blocks {
+
+ /*!
+ * \brief Write stream to file descriptor.
+ * \ingroup sink_blk
+ */
+ class BLOCKS_API file_descriptor_sink : virtual public gr_sync_block
+ {
+ public:
+ // gr::blocks::file_descriptor_sink::sptr
+ typedef boost::shared_ptr<file_descriptor_sink> sptr;
+
+ /*!
+ * Build a file descriptor sink block.
+ *
+ * \param itemsize item size of the incoming data stream.
+ * \param fd file descriptor (as an integer).
+ */
+ static sptr make(size_t itemsize, int fd);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_GR_FILE_DESCRIPTOR_SINK_H */
diff --git a/gr-blocks/include/blocks/file_descriptor_source.h b/gr-blocks/include/blocks/file_descriptor_source.h
new file mode 100644
index 0000000000..ff4f14792b
--- /dev/null
+++ b/gr-blocks/include/blocks/file_descriptor_source.h
@@ -0,0 +1,61 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2013 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_FILE_DESCRIPTOR_SOURCE_H
+#define INCLUDED_GR_FILE_DESCRIPTOR_SOURCE_H
+
+#include <blocks/api.h>
+#include <gr_sync_block.h>
+
+
+namespace gr {
+ namespace blocks {
+
+ /*!
+ * \brief Read stream from file descriptor.
+ * \ingroup source_blk
+ */
+ class BLOCKS_API file_descriptor_source : virtual public gr_sync_block
+ {
+ protected:
+ virtual int read_items(char *buf, int nitems) = 0;
+ virtual int handle_residue(char *buf, int nbytes_read) = 0;
+ virtual void flush_residue() = 0;
+
+ public:
+ // gr::blocks::file_descriptor_source::sptr
+ typedef boost::shared_ptr<file_descriptor_source> sptr;
+
+ /*!
+ * Build a file descriptor source block.
+ *
+ * \param itemsize item size of the incoming data stream.
+ * \param fd file descriptor (as an integer).
+ * \param repeat repeat the data stream continuously.
+ */
+ static sptr make(size_t itemsize, int fd, bool repeat);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_GR_FILE_DESCRIPTOR_SOURCE_H */
diff --git a/gr-blocks/include/blocks/file_sink.h b/gr-blocks/include/blocks/file_sink.h
new file mode 100644
index 0000000000..08c2adf1f7
--- /dev/null
+++ b/gr-blocks/include/blocks/file_sink.h
@@ -0,0 +1,55 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2007,2013 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_FILE_SINK_H
+#define INCLUDED_GR_FILE_SINK_H
+
+#include <blocks/api.h>
+#include <blocks/file_sink_base.h>
+#include <gr_sync_block.h>
+
+namespace gr {
+ namespace blocks {
+
+ /*!
+ * \brief Write stream to file.
+ * \ingroup sink_blk
+ */
+ class BLOCKS_API file_sink : virtual public gr_sync_block,
+ virtual public file_sink_base
+ {
+ public:
+ // gr::blocks::file_sink::sptr
+ typedef boost::shared_ptr<file_sink> sptr;
+
+ /*!
+ * \brief Make a file sink.
+ * \param itemsize size of the input data items.
+ * \param filename name of the file to open and write output to.
+ */
+ static sptr make(size_t itemsize, const char *filename);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_GR_FILE_SINK_H */
diff --git a/gr-blocks/include/blocks/file_sink_base.h b/gr-blocks/include/blocks/file_sink_base.h
new file mode 100644
index 0000000000..3eeb0e63da
--- /dev/null
+++ b/gr-blocks/include/blocks/file_sink_base.h
@@ -0,0 +1,80 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2007,2008,2013 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_FILE_SINK_BASE_H
+#define INCLUDED_GR_FILE_SINK_BASE_H
+
+#include <blocks/api.h>
+#include <boost/thread.hpp>
+#include <cstdio>
+
+namespace gr {
+ namespace blocks {
+
+ /*!
+ * \brief Common base class for file sinks
+ */
+ class BLOCKS_API file_sink_base
+ {
+ protected:
+ FILE *d_fp; // current FILE pointer
+ FILE *d_new_fp; // new FILE pointer
+ bool d_updated; // is there a new FILE pointer?
+ bool d_is_binary;
+ boost::mutex d_mutex;
+ bool d_unbuffered;
+
+ protected:
+ file_sink_base(const char *filename, bool is_binary);
+
+ public:
+ file_sink_base() {}
+ ~file_sink_base();
+
+ /*!
+ * \brief Open filename and begin output to it.
+ */
+ bool open(const char *filename);
+
+ /*!
+ * \brief Close current output file.
+ *
+ * Closes current output file and ignores any output until
+ * open is called to connect to another file.
+ */
+ void close();
+
+ /*!
+ * \brief if we've had an update, do it now.
+ */
+ void do_update();
+
+ /*!
+ * \brief turn on unbuffered writes for slower outputs
+ */
+ void set_unbuffered(bool unbuffered);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_GR_FILE_SINK_BASE_H */
diff --git a/gr-blocks/include/blocks/head.h b/gr-blocks/include/blocks/head.h
new file mode 100644
index 0000000000..cc7d3808e5
--- /dev/null
+++ b/gr-blocks/include/blocks/head.h
@@ -0,0 +1,55 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2009,2012,2013 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_HEAD_H
+#define INCLUDED_GR_HEAD_H
+
+#include <blocks/api.h>
+#include <gr_sync_block.h>
+#include <stddef.h> // size_t
+
+namespace gr {
+ namespace blocks {
+
+ /*!
+ * \brief copies the first N items to the output then signals done
+ * \ingroup slicedice_blk
+ *
+ * Useful for building test cases
+ */
+ class BLOCKS_API head : virtual public gr_sync_block
+ {
+ public:
+ // gr::blocks::head::sptr
+ typedef boost::shared_ptr<head> sptr;
+
+ static sptr make(size_t sizeof_stream_item,
+ uint64_t nitems);
+
+ virtual void reset() = 0;
+ virtual void set_length(int nitems) = 0;
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_GR_HEAD_H */
diff --git a/gr-blocks/include/blocks/lfsr_15_1_0.h b/gr-blocks/include/blocks/lfsr_15_1_0.h
new file mode 100644
index 0000000000..a79ed62eb8
--- /dev/null
+++ b/gr-blocks/include/blocks/lfsr_15_1_0.h
@@ -0,0 +1,69 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004 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_GRI_LFSR_15_1_0_H
+#define INCLUDED_GRI_LFSR_15_1_0_H
+
+#include <blocks/api.h>
+
+namespace gr {
+ namespace blocks {
+
+ /*!
+ * \brief Linear Feedback Shift Register using primitive polynomial x^15 + x + 1
+ * \ingroup misc
+ *
+ * Generates a maximal length pseudo-random sequence of length
+ * 2^15 - 1 bits.
+ */
+ class BLOCKS_API lfsr_15_1_0
+ {
+ private:
+ unsigned long d_sr; // shift register
+
+ public:
+ lfsr_15_1_0() { reset(); }
+
+ void reset() { d_sr = 0x7fff; }
+
+ int next_bit()
+ {
+ d_sr = ((((d_sr >> 1) ^ d_sr) & 0x1) << 14) | (d_sr >> 1);
+ return d_sr & 0x1;
+ }
+
+ int next_byte ()
+ {
+ int v = 0;
+ for(int i = 0; i < 8; i++) {
+ v >>= 1;
+ if(next_bit ())
+ v |= 0x80;
+ }
+ return v;
+ }
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_GRI_LFSR_15_1_0_H */
diff --git a/gr-blocks/include/blocks/lfsr_32k.h b/gr-blocks/include/blocks/lfsr_32k.h
new file mode 100644
index 0000000000..7e70f6512b
--- /dev/null
+++ b/gr-blocks/include/blocks/lfsr_32k.h
@@ -0,0 +1,90 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2013 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_GRI_LFSR_32k_H
+#define INCLUDED_GRI_LFSR_32k_H
+
+#include <blocks/api.h>
+#include <blocks/lfsr_15_1_0.h>
+
+namespace gr {
+ namespace blocks {
+
+ /*!
+ * \brief generate pseudo-random sequence of length 32768 bits.
+ * \ingroup misc
+ *
+ * This is based on gri_lfsr_15_1_0 with an extra 0 added at the
+ * end of the sequence.
+ */
+ class BLOCKS_API lfsr_32k
+ {
+ private:
+ lfsr_15_1_0 d_lfsr;
+ unsigned int d_count;
+
+ public:
+ lfsr_32k() { reset (); }
+
+ void reset()
+ {
+ d_lfsr.reset();
+ d_count = 0;
+ }
+
+ int next_bit()
+ {
+ if(d_count == 32767) {
+ d_count = 0;
+ return 0;
+ }
+ d_count++;
+ return d_lfsr.next_bit();
+ }
+
+ int next_byte()
+ {
+ int v = 0;
+ for(int i = 0; i < 8; i++) {
+ v >>= 1;
+ if(next_bit ())
+ v |= 0x80;
+ }
+ return v;
+ }
+
+ int next_short()
+ {
+ int v = 0;
+ for(int i = 0; i < 16; i++) {
+ v >>= 1;
+ if(next_bit ())
+ v |= 0x8000;
+ }
+ return v;
+ }
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_GRI_LFSR_32k_H */
diff --git a/gr-blocks/include/blocks/lfsr_32k_source_s.h b/gr-blocks/include/blocks/lfsr_32k_source_s.h
new file mode 100644
index 0000000000..c24cc31b29
--- /dev/null
+++ b/gr-blocks/include/blocks/lfsr_32k_source_s.h
@@ -0,0 +1,55 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2013 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_LFSR_32K_SOURCE_S_H
+#define INCLUDED_GR_LFSR_32K_SOURCE_S_H
+
+#include <blocks/api.h>
+#include <blocks/lfsr_32k.h>
+#include <gr_sync_block.h>
+
+namespace gr {
+ namespace blocks {
+
+ /*!
+ * \brief LFSR pseudo-random source with period of 2^15 bits (2^11 shorts)
+ * \ingroup source_blk
+ *
+ * This source is typically used along with gr::blocks::check_lfsr_32k_s to
+ * test the USRP using its digital loopback mode.
+ */
+ class BLOCKS_API lfsr_32k_source_s : virtual public gr_sync_block
+ {
+ public:
+ // gr::blocks::lfsr_32k_source_s::sptr
+ typedef boost::shared_ptr<lfsr_32k_source_s> sptr;
+
+ /*!
+ * \brief Make a LFSR 32k source block.
+ */
+ static sptr make();
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_GR_LFSR_32K_SOURCE_S_H */
diff --git a/gr-blocks/include/blocks/max_XX.h.t b/gr-blocks/include/blocks/max_XX.h.t
new file mode 100644
index 0000000000..9e74bf3cac
--- /dev/null
+++ b/gr-blocks/include/blocks/max_XX.h.t
@@ -0,0 +1,58 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007,2013 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.
+ */
+
+// @WARNING@
+
+#ifndef @GUARD_NAME@
+#define @GUARD_NAME@
+
+#include <blocks/api.h>
+#include <gr_sync_block.h>
+
+namespace gr {
+ namespace blocks {
+
+ /*!
+ * \brief Compares vectors from multiple streams and determines
+ * the maximum value from each vector over all streams.
+ * \ingroup math_blk
+ *
+ * Data is passed in as a vector of length \p vlen from multiple
+ * input sources. It will look through these streams of \p vlen
+ * data items and output two streams.
+ * Stream 0 will contain the index value in the vector where
+ * the maximum value occurred.
+ */
+ class BLOCKS_API @NAME@ : virtual public gr_sync_block
+ {
+ public:
+ // gr::blocks::@NAME@::sptr
+ typedef boost::shared_ptr<@NAME@> sptr;
+
+ static sptr make(size_t vlen);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* @GUARD_NAME@ */
+
diff --git a/gr-blocks/include/blocks/message_burst_source.h b/gr-blocks/include/blocks/message_burst_source.h
new file mode 100644
index 0000000000..864d43452f
--- /dev/null
+++ b/gr-blocks/include/blocks/message_burst_source.h
@@ -0,0 +1,52 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2012-2013 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_MESSAGE_BURST_SOURCE_H
+#define INCLUDED_GR_MESSAGE_BURST_SOURCE_H
+
+#include <blocks/api.h>
+#include <gr_sync_block.h>
+#include <gr_msg_queue.h>
+
+namespace gr {
+ namespace blocks {
+
+ /*!
+ * \brief Turn received messages into a stream and tag them for UHD to send.
+ * \ingroup source_blk
+ */
+ class BLOCKS_API message_burst_source : virtual public gr_sync_block
+ {
+ public:
+ // gr::blocks::message_source::sptr
+ typedef boost::shared_ptr<message_burst_source> sptr;
+
+ static sptr make(size_t itemsize, int msgq_limit);
+ static sptr make(size_t itemsize, gr_msg_queue_sptr msgq);
+
+ virtual gr_msg_queue_sptr msgq() const = 0;
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_GR_MESSAGE_BURST_SOURCE_H */
diff --git a/gr-blocks/include/blocks/message_debug.h b/gr-blocks/include/blocks/message_debug.h
new file mode 100644
index 0000000000..f0212331c2
--- /dev/null
+++ b/gr-blocks/include/blocks/message_debug.h
@@ -0,0 +1,85 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2005,2012-2013 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_MESSAGE_DEBUG_H
+#define INCLUDED_GR_MESSAGE_DEBUG_H
+
+#include <blocks/api.h>
+#include <gr_block.h>
+
+namespace gr {
+ namespace blocks {
+
+ /*!
+ * \brief Debug block for the message passing system.
+ * \ingroup sink_blk
+ *
+ * The message debug block is used to capture and print or store
+ * messages as they are received. Any block that generates a
+ * message may connect that message port to one or more of the
+ * three message input ports of this debug block. The message
+ * ports are:
+ *
+ * \li print: prints the message directly to standard out.
+ * \li store: stores the message in an internal vector. May be
+ * access using the get_message function.
+ * \li print_pdu: specifically designed to handle formatted PDUs
+ * (see pdu.h).
+ */
+ class BLOCKS_API message_debug : virtual public gr_block
+ {
+ public:
+ // gr::blocks::message_debug::sptr
+ typedef boost::shared_ptr<message_debug> sptr;
+
+ /*!
+ * \brief Build the message debug block. It takes no parameters
+ * and has three message ports: print, store, and
+ * print_pdu.
+ */
+ static sptr make();
+
+ /*!
+ * \brief Reports the number of messages received by this block.
+ */
+ virtual int num_messages() = 0;
+
+ /*!
+ * \brief Get a message (as a PMT) from the message vector at index \p i.
+ *
+ * Messages passed to the 'store' port will be stored in a
+ * vector. This function retrieves those messages by index. They
+ * are index in order of when they were received (all messages
+ * are just pushed onto the back of a vector). This is mostly
+ * useful in debugging message passing graphs and in QA code.
+ *
+ * \param i The index in the vector for the message to retrieve.
+ *
+ * \return a message at index \p i as a pmt_t.
+ */
+ virtual pmt::pmt_t get_message(int i) = 0;
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_GR_MESSAGE_DEBUG_H */
diff --git a/gr-blocks/include/blocks/message_sink.h b/gr-blocks/include/blocks/message_sink.h
new file mode 100644
index 0000000000..5d14836dd4
--- /dev/null
+++ b/gr-blocks/include/blocks/message_sink.h
@@ -0,0 +1,49 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2005,2013 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_MESSAGE_SINK_H
+#define INCLUDED_GR_MESSAGE_SINK_H
+
+#include <blocks/api.h>
+#include <gr_sync_block.h>
+#include <gr_msg_queue.h>
+
+namespace gr {
+ namespace blocks {
+
+ /*!
+ * \brief Gather received items into messages and insert into msgq
+ * \ingroup sink_blk
+ */
+ class BLOCKS_API message_sink : virtual public gr_sync_block
+ {
+ public:
+ // gr::blocks::message_sink::sptr
+ typedef boost::shared_ptr<message_sink> sptr;
+
+ static sptr make (size_t itemsize, gr_msg_queue_sptr msgq, bool dont_block);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_GR_MESSAGE_SINK_H */
diff --git a/gr-blocks/include/blocks/message_source.h b/gr-blocks/include/blocks/message_source.h
new file mode 100644
index 0000000000..5b55191880
--- /dev/null
+++ b/gr-blocks/include/blocks/message_source.h
@@ -0,0 +1,52 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2005,2013 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_MESSAGE_SOURCE_H
+#define INCLUDED_GR_MESSAGE_SOURCE_H
+
+#include <blocks/api.h>
+#include <gr_sync_block.h>
+#include <gr_msg_queue.h>
+
+namespace gr {
+ namespace blocks {
+
+ /*!
+ * \brief Turn received messages into a stream
+ * \ingroup source_blk
+ */
+ class BLOCKS_API message_source : virtual public gr_sync_block
+ {
+ public:
+ // gr::blocks::message_source::sptr
+ typedef boost::shared_ptr<message_source> sptr;
+
+ static sptr make(size_t itemsize, int msgq_limit=0);
+ static sptr make(size_t itemsize, gr_msg_queue_sptr msgq);
+
+ virtual gr_msg_queue_sptr msgq() const = 0;
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_GR_MESSAGE_SOURCE_H */
diff --git a/gr-blocks/include/blocks/message_strobe.h b/gr-blocks/include/blocks/message_strobe.h
new file mode 100644
index 0000000000..6b427d539c
--- /dev/null
+++ b/gr-blocks/include/blocks/message_strobe.h
@@ -0,0 +1,81 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2012-2013 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_MESSAGE_STROBE_H
+#define INCLUDED_GR_MESSAGE_STROBE_H
+
+#include <blocks/api.h>
+#include <gr_block.h>
+
+namespace gr {
+ namespace blocks {
+
+ /*!
+ * \brief Send message at defined interval
+ * \ingroup msg_blk
+ *
+ * Takes a PMT message and sends it out every \p period_ms
+ * milliseconds. Useful for testing/debugging the message system.
+ */
+ class BLOCKS_API message_strobe : virtual public gr_block
+ {
+ public:
+ // gr::blocks::message_strobe::sptr
+ typedef boost::shared_ptr<message_strobe> sptr;
+
+ /*!
+ * Make a message stobe block to send message \p msg every \p
+ * period_ms milliseconds.
+ *
+ * \param msg The message to send as a PMT.
+ * \param period_ms the time period in milliseconds in which to
+ * send \p msg.
+ */
+ static sptr make(pmt::pmt_t msg, float period_ms);
+
+ /*!
+ * Reset the message being sent.
+ * \param msg The message to send as a PMT.
+ */
+ virtual void set_msg(pmt::pmt_t msg) = 0;
+
+ /*!
+ * Get the value of the message being sent.
+ */
+ virtual pmt::pmt_t msg() const = 0;
+
+ /*!
+ * Reset the sending interval.
+ * \param period_ms the time period in milliseconds.
+ */
+ virtual void set_period(float period_ms) = 0;
+
+ /*!
+ * Get the time interval of the strobe.
+ */
+ virtual float period() const = 0;
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_GR_MESSAGE_STROBE_H */
diff --git a/gr-blocks/include/blocks/moving_average_XX.h.t b/gr-blocks/include/blocks/moving_average_XX.h.t
new file mode 100644
index 0000000000..6b7883fdd4
--- /dev/null
+++ b/gr-blocks/include/blocks/moving_average_XX.h.t
@@ -0,0 +1,84 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008,2013 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.
+ */
+
+// @WARNING@
+
+#ifndef @GUARD_NAME@
+#define @GUARD_NAME@
+
+#include <blocks/api.h>
+#include <gr_sync_block.h>
+
+namespace gr {
+ namespace blocks {
+
+ /*!
+ * \brief output is the moving sum of the last N samples, scaled by the scale factor
+ * \ingroup filter_blk
+ */
+ class BLOCKS_API @NAME@ : virtual public gr_sync_block
+ {
+ public:
+ // gr::blocks::@NAME@::sptr
+ typedef boost::shared_ptr<@NAME@> sptr;
+
+ /*!
+ * Create a moving average block.
+ *
+ * \param length Number of samples to use in the average.
+ * \param scale scale factor for the result.
+ * \param max_iter limits how long we go without flushing the accumulator
+ * This is necessary to avoid numerical instability for float and complex.
+ */
+ static sptr make(int length, @O_TYPE@ scale,
+ int max_iter = 4096);
+
+ /*!
+ * Get the length used in the avaraging calculation.
+ */
+ virtual int length() const = 0;
+
+ /*!
+ * Get the scale factor being used.
+ */
+ virtual @O_TYPE@ scale() const = 0;
+
+ /*!
+ * Set both the length and the scale factor together.
+ */
+ virtual void set_length_and_scale(int length, @O_TYPE@ scale) = 0;
+
+ /*!
+ * Set the length.
+ */
+ virtual void set_length(int length) = 0;
+
+ /*!
+ * Set the scale factor.
+ */
+ virtual void set_scale(@O_TYPE@ scale) = 0;
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* @GUARD_NAME@ */
diff --git a/gr-blocks/include/blocks/mute_XX.h.t b/gr-blocks/include/blocks/mute_XX.h.t
new file mode 100644
index 0000000000..2b1c8b9a4d
--- /dev/null
+++ b/gr-blocks/include/blocks/mute_XX.h.t
@@ -0,0 +1,54 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2013 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.
+ */
+
+// @WARNING@
+
+#ifndef @GUARD_NAME@
+#define @GUARD_NAME@
+
+#include <blocks/api.h>
+#include <gr_sync_block.h>
+
+namespace gr {
+ namespace blocks {
+
+ /*!
+ * \brief output = input or zero if muted.
+ * \ingroup level_blk
+ */
+ class BLOCKS_API @NAME@ : virtual public gr_sync_block
+ {
+ public:
+ // gr::blocks::@NAME@::sptr
+ typedef boost::shared_ptr<@NAME@> sptr;
+
+ static sptr make(bool mute=false);
+
+ virtual bool mute() const = 0;
+ virtual void set_mute(bool mute=false) = 0;
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* @GUARD_NAME@ */
+
diff --git a/gr-blocks/include/blocks/nop.h b/gr-blocks/include/blocks/nop.h
new file mode 100644
index 0000000000..b3135e1cc8
--- /dev/null
+++ b/gr-blocks/include/blocks/nop.h
@@ -0,0 +1,56 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2010,2013 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_NOP_H
+#define INCLUDED_GR_NOP_H
+
+#include <blocks/api.h>
+#include <gr_block.h>
+#include <stddef.h> // size_t
+
+namespace gr {
+ namespace blocks {
+
+ /*!
+ * \brief Does nothing. Used for testing only.
+ * \ingroup misc_blk
+ */
+ class BLOCKS_API nop : virtual public gr_block
+ {
+ public:
+ // gr::blocks::nop::sptr
+ typedef boost::shared_ptr<nop> sptr;
+
+ /*!
+ * Build a nop block.
+ *
+ * \param sizeof_stream_item size of the stream items in bytes.
+ */
+ static sptr make(size_t sizeof_stream_item);
+
+ virtual int nmsgs_received() const = 0;
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_GR_NOP_H */
diff --git a/gr-blocks/include/blocks/null_sink.h b/gr-blocks/include/blocks/null_sink.h
new file mode 100644
index 0000000000..c13a7552c6
--- /dev/null
+++ b/gr-blocks/include/blocks/null_sink.h
@@ -0,0 +1,55 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2010,2013 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_NULL_SINK_H
+#define INCLUDED_GR_NULL_SINK_H
+
+#include <blocks/api.h>
+#include <gr_sync_block.h>
+#include <stddef.h> // size_t
+
+namespace gr {
+ namespace blocks {
+
+ /*!
+ * \brief Bit bucket. Use as a termination point when a sink is
+ * required and we don't want to do anything real.
+ * \ingroup sink_blk
+ */
+ class BLOCKS_API null_sink : virtual public gr_sync_block
+ {
+ public:
+ // gr::blocks::null_sink::sptr
+ typedef boost::shared_ptr<null_sink> sptr;
+
+ /*!
+ * Build a null sink block.
+ *
+ * \param sizeof_stream_item size of the stream items in bytes.
+ */
+ static sptr make(size_t sizeof_stream_item);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_GR_NULL_SINK_H */
diff --git a/gr-blocks/include/blocks/null_source.h b/gr-blocks/include/blocks/null_source.h
new file mode 100644
index 0000000000..904a0c1ba3
--- /dev/null
+++ b/gr-blocks/include/blocks/null_source.h
@@ -0,0 +1,53 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2010,2013 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_NULL_SOURCE_H
+#define INCLUDED_GR_NULL_SOURCE_H
+
+#include <blocks/api.h>
+#include <gr_sync_block.h>
+
+namespace gr {
+ namespace blocks {
+
+ /*!
+ * \brief A source of zeros used mainly for testing.
+ * \ingroup source_blk
+ */
+ class BLOCKS_API null_source : virtual public gr_sync_block
+ {
+ public:
+ // gr::blocks::null_source::sptr
+ typedef boost::shared_ptr<null_source> sptr;
+
+ /*!
+ * Build a null source block.
+ *
+ * \param sizeof_stream_item size of the stream items in bytes.
+ */
+ static sptr make(size_t sizeof_stream_item);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_GR_NULL_SOURCE_H */
diff --git a/gr-blocks/include/blocks/pack_k_bits_bb.h b/gr-blocks/include/blocks/pack_k_bits_bb.h
new file mode 100644
index 0000000000..5bf71c9c3e
--- /dev/null
+++ b/gr-blocks/include/blocks/pack_k_bits_bb.h
@@ -0,0 +1,53 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2012-2013 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_PACK_K_BITS_BB_H
+#define INCLUDED_GR_PACK_K_BITS_BB_H
+
+#include <blocks/api.h>
+#include <gr_sync_decimator.h>
+
+namespace gr {
+ namespace blocks {
+
+ /*!
+ * \brief Converts a stream of bytes with 1 bit in the LSB to a
+ * byte with k relevent bits.
+ * \ingroup converter_blk
+ */
+ class BLOCKS_API pack_k_bits_bb : virtual public gr_sync_decimator
+ {
+ public:
+ // gr::blocks::pack_k_bits_bb::sptr
+ typedef boost::shared_ptr<pack_k_bits_bb> sptr;
+
+ /*!
+ * \brief Make a pack_k_bits block.
+ * \param k number of bits to be packed.
+ */
+ static sptr make(unsigned k);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_GR_PACK_K_BITS_BB_H */
diff --git a/gr-blocks/include/blocks/pdu.h b/gr-blocks/include/blocks/pdu.h
new file mode 100644
index 0000000000..de0999c574
--- /dev/null
+++ b/gr-blocks/include/blocks/pdu.h
@@ -0,0 +1,48 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2013 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_BLOCKS_PDU_H
+#define INCLUDED_BLOCKS_PDU_H
+
+#include <blocks/api.h>
+#include <gr_complex.h>
+#include <gruel/pmt.h>
+
+#define PDU_PORT_ID pmt::mp("pdus")
+#define PDU_LENGTH_TAG pmt::mp("pdu_length")
+
+namespace gr {
+ namespace blocks {
+ namespace pdu {
+
+ enum vector_type { byte_t, float_t, complex_t };
+
+ BLOCKS_API size_t itemsize(vector_type type);
+ BLOCKS_API bool type_matches(vector_type type, pmt::pmt_t v);
+ BLOCKS_API pmt::pmt_t make_vector(vector_type type, const uint8_t* buf, size_t items);
+ BLOCKS_API vector_type type_from_pmt(pmt::pmt_t vector);
+
+ } /* namespace pdu */
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_BLOCKS_PDU_H */
diff --git a/gr-blocks/include/blocks/pdu_to_tagged_stream.h b/gr-blocks/include/blocks/pdu_to_tagged_stream.h
new file mode 100644
index 0000000000..cf64f41dc2
--- /dev/null
+++ b/gr-blocks/include/blocks/pdu_to_tagged_stream.h
@@ -0,0 +1,53 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2013 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_BLOCKS_PDU_TO_TAGGED_STREAM_H
+#define INCLUDED_BLOCKS_PDU_TO_TAGGED_STREAM_H
+
+#include <blocks/api.h>
+#include <blocks/pdu.h>
+#include <gr_sync_block.h>
+
+namespace gr {
+ namespace blocks {
+
+ /*!
+ * \brief Turns received PDUs into a tagged stream of items
+ * \ingroup source_blk
+ */
+ class BLOCKS_API pdu_to_tagged_stream : virtual public gr_sync_block
+ {
+ public:
+ // gr::blocks::pdu_to_tagged_stream::sptr
+ typedef boost::shared_ptr<pdu_to_tagged_stream> sptr;
+
+ /*!
+ * \brief Construct a pdu_to_tagged_stream block
+ * \param type PDU type of pdu::vector_type
+ */
+ static sptr make(pdu::vector_type type);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_BLOCKS_PDU_TO_TAGGED_STREAM_H */
diff --git a/gr-blocks/include/blocks/peak_detector_XX.h.t b/gr-blocks/include/blocks/peak_detector_XX.h.t
new file mode 100644
index 0000000000..fead53d208
--- /dev/null
+++ b/gr-blocks/include/blocks/peak_detector_XX.h.t
@@ -0,0 +1,117 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007,2013 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.
+ */
+
+// @WARNING@
+
+#ifndef @GUARD_NAME@
+#define @GUARD_NAME@
+
+#include <blocks/api.h>
+#include <gr_sync_block.h>
+
+namespace gr {
+ namespace blocks {
+
+ /*!
+ * \brief Detect the peak of a signal
+ * \ingroup level_blk
+ *
+ * If a peak is detected, this block outputs a 1,
+ * or it outputs 0's.
+ */
+ class BLOCKS_API @NAME@ : virtual public gr_sync_block
+ {
+ public:
+ // gr::blocks::@NAME@::sptr
+ typedef boost::shared_ptr<@NAME@> sptr;
+
+ /*!
+ * Make a peak detector block.
+ *
+ * \param threshold_factor_rise The threshold factor determins
+ * when a peak has started. An average of the signal is
+ * calculated and when the value of the signal goes over
+ * threshold_factor_rise*average, we start looking for a
+ * peak.
+ * \param threshold_factor_fall The threshold factor determins
+ * when a peak has ended. An average of the signal is
+ * calculated and when the value of the signal goes
+ * bellow threshold_factor_fall*average, we stop looking
+ * for a peak.
+ * \param look_ahead The look-ahead value is used when the
+ * threshold is found to look if there another peak
+ * within this step range. If there is a larger value,
+ * we set that as the peak and look ahead again. This is
+ * continued until the highest point is found with This
+ * look-ahead range.
+ * \param alpha The gain value of a moving average filter
+ */
+ static sptr make(float threshold_factor_rise = 0.25,
+ float threshold_factor_fall = 0.40,
+ int look_ahead = 10,
+ float alpha = 0.001);
+
+ /*! \brief Set the threshold factor value for the rise time
+ * \param thr new threshold factor
+ */
+ virtual void set_threshold_factor_rise(float thr) = 0;
+
+ /*! \brief Set the threshold factor value for the fall time
+ * \param thr new threshold factor
+ */
+ virtual void set_threshold_factor_fall(float thr) = 0;
+
+ /*! \brief Set the look-ahead factor
+ * \param look new look-ahead factor
+ */
+ virtual void set_look_ahead(int look) = 0;
+
+ /*! \brief Set the running average alpha
+ * \param alpha new alpha for running average
+ */
+ virtual void set_alpha(int alpha) = 0;
+
+ /*! \brief Get the threshold factor value for the rise time
+ * \return threshold factor
+ */
+ virtual float threshold_factor_rise() = 0;
+
+ /*! \brief Get the threshold factor value for the fall time
+ * \return threshold factor
+ */
+ virtual float threshold_factor_fall() = 0;
+
+ /*! \brief Get the look-ahead factor value
+ * \return look-ahead factor
+ */
+ virtual int look_ahead() = 0;
+
+ /*! \brief Get the alpha value of the running average
+ * \return alpha
+ */
+ virtual float alpha() = 0;
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* @GUARD_NAME@ */
diff --git a/gr-blocks/include/blocks/plateau_detector_fb.h b/gr-blocks/include/blocks/plateau_detector_fb.h
new file mode 100644
index 0000000000..041f9c1baf
--- /dev/null
+++ b/gr-blocks/include/blocks/plateau_detector_fb.h
@@ -0,0 +1,71 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2012-2013 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_BLOCKS_PLATEAU_DETECTOR_FB_H
+#define INCLUDED_BLOCKS_PLATEAU_DETECTOR_FB_H
+
+#include <blocks/api.h>
+#include <gr_sync_block.h>
+
+namespace gr {
+ namespace blocks {
+
+ /*!
+ * \brief Detects a plateau and marks the middle.
+ *
+ * Detect a plateau of a-priori known height. Input is a stream of floats,
+ * the output is a stream of bytes. Whenever a plateau is detected, the
+ * middle of that plateau is marked with a '1' on the output stream (all
+ * other samples are left at zero).
+ *
+ * You can use this in a Schmidl & Cox synchronisation algorithm to interpret
+ * the output of the normalized correlator. Just pass the length of the cyclic
+ * prefix (in samples) as the max_len parameter).
+ *
+ * Unlike the peak detectors, you must the now the absolute height of the plateau.
+ * Whenever the amplitude exceeds the given threshold, it starts assuming the
+ * presence of a plateau.
+ *
+ * An implicit hysteresis is provided by the fact that after detecting one plateau,
+ * it waits at least max_len samples before the next plateau can be detected.
+ *
+ * \ingroup level_blk
+ *
+ */
+ class BLOCKS_API plateau_detector_fb : virtual public gr_sync_block
+ {
+ public:
+ typedef boost::shared_ptr<plateau_detector_fb> sptr;
+
+ /*!
+ * \param max_len Maximum length of the plateau
+ * \param threshold Anything above this value is considered a plateau
+ */
+ static sptr make(int max_len, float threshold=0.9);
+ };
+
+ } // namespace blocks
+} // namespace gr
+
+#endif /* INCLUDED_BLOCKS_PLATEAU_DETECTOR_FB_H */
+
diff --git a/gr-blocks/include/blocks/probe_rate.h b/gr-blocks/include/blocks/probe_rate.h
new file mode 100644
index 0000000000..3401d2acd1
--- /dev/null
+++ b/gr-blocks/include/blocks/probe_rate.h
@@ -0,0 +1,60 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2005,2013 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_BLOCKS_PROBE_RATE_H
+#define INCLUDED_BLOCKS_PROBE_RATE_H
+
+#include <blocks/api.h>
+#include <gr_sync_block.h>
+
+namespace gr {
+ namespace blocks {
+
+ /*!
+ * \brief throughput measurement
+ */
+ class BLOCKS_API probe_rate : virtual public gr_sync_block
+ {
+ public:
+ // gr::blocks::probe_rate::sptr
+ typedef boost::shared_ptr<probe_rate> sptr;
+
+ /*!
+ * \brief Make a throughput measurement block
+ * \param itemsize size of each stream item
+ * \param update_rate_ms minimum update time in milliseconds
+ * \param alpha gain for running average filter
+ */
+ static sptr make(size_t itemsize, double update_rate_ms = 500.0, double alpha = 0.0001);
+
+ virtual void set_alpha(double alpha) = 0;
+
+ virtual double rate() = 0;
+
+ virtual bool start() = 0;
+ virtual bool stop() = 0;
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_BLOCKS_PROBE_RATE_H */
diff --git a/gr-blocks/include/blocks/probe_signal_X.h.t b/gr-blocks/include/blocks/probe_signal_X.h.t
new file mode 100644
index 0000000000..01b7bad0c4
--- /dev/null
+++ b/gr-blocks/include/blocks/probe_signal_X.h.t
@@ -0,0 +1,52 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2005,2012-2013 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.
+ */
+
+// @WARNING@
+
+#ifndef @GUARD_NAME@
+#define @GUARD_NAME@
+
+#include <blocks/api.h>
+#include <gr_sync_block.h>
+
+namespace gr {
+ namespace blocks {
+
+ /*!
+ * \brief Sink that allows a sample to be grabbed from Python.
+ * \ingroup sink_blk
+ */
+ class BLOCKS_API @NAME@ : virtual public gr_sync_block
+ {
+ public:
+ // gr::blocks::@NAME@::sptr
+ typedef boost::shared_ptr<@NAME@> sptr;
+
+ static sptr make();
+
+ virtual @TYPE@ level() const = 0;
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* @GUARD_NAME@ */
diff --git a/gr-blocks/include/blocks/probe_signal_vX.h.t b/gr-blocks/include/blocks/probe_signal_vX.h.t
new file mode 100644
index 0000000000..487f280db4
--- /dev/null
+++ b/gr-blocks/include/blocks/probe_signal_vX.h.t
@@ -0,0 +1,53 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2005,2012-2013 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.
+ */
+
+// @WARNING@
+
+#ifndef @GUARD_NAME@
+#define @GUARD_NAME@
+
+#include <vector>
+#include <blocks/api.h>
+#include <gr_sync_block.h>
+
+namespace gr {
+ namespace blocks {
+
+ /*!
+ * \brief Sink that allows a vector of samples to be grabbed from Python.
+ * \ingroup sink_blk
+ */
+ class BLOCKS_API @NAME@ : virtual public gr_sync_block
+ {
+ public:
+ // gr::blocks::@NAME@::sptr
+ typedef boost::shared_ptr<@NAME@> sptr;
+
+ static sptr make(size_t size);
+
+ virtual std::vector<@TYPE@> level() const = 0;
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* @GUARD_NAME@ */
diff --git a/gr-blocks/include/blocks/repack_bits_bb.h b/gr-blocks/include/blocks/repack_bits_bb.h
new file mode 100644
index 0000000000..9ade0a4353
--- /dev/null
+++ b/gr-blocks/include/blocks/repack_bits_bb.h
@@ -0,0 +1,65 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 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_BLOCKS_REPACK_BITS_BB_H
+#define INCLUDED_BLOCKS_REPACK_BITS_BB_H
+
+#include <blocks/api.h>
+#include <gr_tagged_stream_block.h>
+
+namespace gr {
+ namespace blocks {
+
+ /*!
+ * \brief Pack \p k bits from the input stream onto \p k bits of the output stream.
+ * \ingroup blocks
+ *
+ * No bits are lost here; any value for k and l (within [1, 8]) is allowed.
+ * On every fresh input byte, it starts reading on the LSB, and starts copying
+ * to the LSB as well.
+ *
+ * If a packet length tag is given, this block assumes a tagged stream.
+ * In this case, the tag with the packet length is updated accordingly.
+ * Also, the number of input bits is padded with zeros if the number of input
+ * bits is not an integer multiple of \p l, or bits are truncated from the input
+ * if \p align_output is set to true.
+ */
+ class BLOCKS_API repack_bits_bb : virtual public gr_tagged_stream_block
+ {
+ public:
+ typedef boost::shared_ptr<repack_bits_bb> sptr;
+
+ /*!
+ * \param k Number of relevant bits on the input stream
+ * \param l Number of relevant bits on the output stream
+ * \param len_tag_key If not empty, this is the key for the length tag.
+ * \param align_output If len_tag_key is given, this controls if the input
+ * or the output is aligned.
+ */
+ static sptr make(int k, int l=8, const std::string &len_tag_key="", bool align_output=false);
+ };
+
+ } // namespace blocks
+} // namespace gr
+
+#endif /* INCLUDED_BLOCKS_REPACK_BITS_BB_H */
+
diff --git a/gr-blocks/include/blocks/rotator.h b/gr-blocks/include/blocks/rotator.h
new file mode 100644
index 0000000000..96ece63574
--- /dev/null
+++ b/gr-blocks/include/blocks/rotator.h
@@ -0,0 +1,63 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2003,2008,2013 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 _GR_ROTATOR_H_
+#define _GR_ROTATOR_H_
+
+#include <blocks/api.h>
+#include <gr_complex.h>
+
+namespace gr {
+ namespace blocks {
+
+ class BLOCKS_API rotator
+ {
+ private:
+ gr_complex d_phase;
+ gr_complex d_phase_incr;
+ unsigned int d_counter;
+
+ public:
+ rotator() : d_phase(1), d_phase_incr(1), d_counter(0)
+ { }
+
+ void set_phase(gr_complex phase) { d_phase = phase / abs(phase); }
+ void set_phase_incr(gr_complex incr) { d_phase_incr = incr / abs(incr); }
+
+ gr_complex rotate(gr_complex in)
+ {
+ d_counter++;
+
+ gr_complex z = in * d_phase; // rotate in by phase
+ d_phase *= d_phase_incr; // incr our phase (complex mult == add phases)
+
+ if((d_counter % 512) == 0)
+ d_phase /= abs(d_phase); // Normalize to ensure multiplication is rotation
+
+ return z;
+ }
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* _GR_ROTATOR_H_ */
diff --git a/gr-blocks/include/blocks/sample_and_hold_XX.h.t b/gr-blocks/include/blocks/sample_and_hold_XX.h.t
new file mode 100644
index 0000000000..3266523efb
--- /dev/null
+++ b/gr-blocks/include/blocks/sample_and_hold_XX.h.t
@@ -0,0 +1,53 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007,2013 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.
+ */
+
+// @WARNING@
+
+#ifndef @GUARD_NAME@
+#define @GUARD_NAME@
+
+#include <blocks/api.h>
+#include <gr_sync_block.h>
+
+namespace gr {
+ namespace blocks {
+
+ /*!
+ * \brief sample and hold circuit
+ * \ingroup level_blk
+ *
+ * Samples the data stream (input stream 0) and holds the value if
+ * the control signal is 1 (intput stream 1).
+ */
+ class BLOCKS_API @NAME@ : virtual public gr_sync_block
+ {
+ public:
+ // gr::blocks::@NAME@::sptr
+ typedef boost::shared_ptr<@NAME@> sptr;
+
+ static sptr make();
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* @GUARD_NAME@ */
diff --git a/gr-blocks/include/blocks/skiphead.h b/gr-blocks/include/blocks/skiphead.h
new file mode 100644
index 0000000000..e6745af8ea
--- /dev/null
+++ b/gr-blocks/include/blocks/skiphead.h
@@ -0,0 +1,53 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2005,2013 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_SKIPHEAD_H
+#define INCLUDED_GR_SKIPHEAD_H
+
+#include <blocks/api.h>
+#include <gr_sync_block.h>
+#include <stddef.h> // size_t
+
+namespace gr {
+ namespace blocks {
+
+ /*!
+ * \brief skips the first N items, from then on copies items to the output
+ * \ingroup slicedice_blk
+ *
+ * Useful for building test cases and sources which have metadata
+ * or junk at the start
+ */
+ class BLOCKS_API skiphead : virtual public gr_block
+ {
+ public:
+ // gr::blocks::skiphead::sptr
+ typedef boost::shared_ptr<skiphead> sptr;
+
+ static sptr make(size_t itemsize,
+ uint64_t nitems_to_skip);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_GR_SKIPHEAD_H */
diff --git a/gr-blocks/include/blocks/socket_pdu.h b/gr-blocks/include/blocks/socket_pdu.h
new file mode 100644
index 0000000000..58d5ad2628
--- /dev/null
+++ b/gr-blocks/include/blocks/socket_pdu.h
@@ -0,0 +1,55 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2013 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_BLOCKS_SOCKET_PDU_H
+#define INCLUDED_BLOCKS_SOCKET_PDU_H
+
+#include <blocks/api.h>
+#include <gr_block.h>
+
+namespace gr {
+ namespace blocks {
+
+ /*!
+ * \brief Creates socket interface and translates traffic to PDUs
+ * \ingroup net_blk
+ */
+ class BLOCKS_API socket_pdu : virtual public gr_block
+ {
+ public:
+ // gr::blocks::socket_pdu::sptr
+ typedef boost::shared_ptr<socket_pdu> sptr;
+
+ /*!
+ * \brief Construct a SOCKET PDU interface
+ * \param type type of socket (TCP_SERVER, TCP_CLIENT, UDP_SERVER, UDP_CLIENT)
+ * \param addr address of host
+ * \param port port number to use
+ * \param MTU Maximum Transmission Unit size
+ */
+ static sptr make(std::string type, std::string addr, std::string port, int MTU=10000);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_BLOCKS_SOCKET_PDU_H */
diff --git a/gr-blocks/include/blocks/tag_debug.h b/gr-blocks/include/blocks/tag_debug.h
new file mode 100644
index 0000000000..9d27a26ecd
--- /dev/null
+++ b/gr-blocks/include/blocks/tag_debug.h
@@ -0,0 +1,80 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2012-2013 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_TAG_DEBUG_H
+#define INCLUDED_GR_TAG_DEBUG_H
+
+#include <blocks/api.h>
+#include <gr_sync_block.h>
+
+namespace gr {
+ namespace blocks {
+
+ /*!
+ * \brief Bit bucket that prints out any tag received.
+ * \ingroup sink_blk
+ *
+ * This block collects all tags sent to it on all input ports and
+ * displays them to stdout in a formatted way. The \p name
+ * parameter is used to identify which debug sink generated the
+ * tag, so when connecting a block to this debug sink, an
+ * appropriate name is something that identifies the input block.
+ *
+ * This block otherwise acts as a NULL sink in that items from the
+ * input stream are ignored. It is designed to be able to attach
+ * to any block and watch all tags streaming out of that block for
+ * debugging purposes.
+ *
+ * The tags from the last call to this work function are stored
+ * and can be retrieved using the function 'current_tags'.
+ */
+ class BLOCKS_API tag_debug : virtual public gr_sync_block
+ {
+ public:
+ // gr::blocks::tag_debug::sptr
+ typedef boost::shared_ptr<tag_debug> sptr;
+
+ /*!
+ * Build a tag debug block
+ *
+ * \param sizeof_stream_item size of the items in the incoming stream.
+ * \param name name to identify which debug sink generated the info.
+ */
+ static sptr make(size_t sizeof_stream_item,
+ const std::string &name);
+
+ /*!
+ * \brief Returns a vector of gr_tag_t items as of the last call to
+ * work.
+ */
+ virtual std::vector<gr_tag_t> current_tags() = 0;
+
+ /*!
+ * \brief Set the display of tags to stdout on/off.
+ */
+ virtual void set_display(bool d) = 0;
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_GR_TAG_DEBUG_H */
diff --git a/gr-blocks/include/blocks/tagged_file_sink.h b/gr-blocks/include/blocks/tagged_file_sink.h
new file mode 100644
index 0000000000..62da72f789
--- /dev/null
+++ b/gr-blocks/include/blocks/tagged_file_sink.h
@@ -0,0 +1,65 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2010,2013 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_TAGGED_FILE_SINK_H
+#define INCLUDED_GR_TAGGED_FILE_SINK_H
+
+#include <blocks/api.h>
+#include <gr_sync_block.h>
+
+namespace gr {
+ namespace blocks {
+
+ /*!
+ * \brief A file sink that uses tags to save files.
+ * \ingroup sink_blk
+ *
+ * The sink uses a tag with the key 'burst' to trigger the saving
+ * of the burst data to a new file. If the value of this tag is
+ * True, it will open a new file and start writing all incoming
+ * data to it. If the tag is False, it will close the file (if
+ * already opened). The file names are based on the time when the
+ * burst tag was seen. If there is an 'rx_time' tag (standard with
+ * UHD sources), that is used as the time. If no 'rx_time' tag is
+ * found, the new time is calculated based off the sample rate of
+ * the block.
+ */
+ class BLOCKS_API tagged_file_sink : virtual public gr_sync_block
+ {
+ public:
+ // gr::blocks::tagged_file_sink::sptr
+ typedef boost::shared_ptr<tagged_file_sink> sptr;
+
+ /*!
+ * \brief Build a tagged_file_sink block.
+ *
+ * \param itemsize The item size of the input data stream.
+ * \param samp_rate The sample rate used to determine the time
+ * difference between bursts
+ */
+ static sptr make(size_t itemsize, double samp_rate);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_GR_TAGGED_FILE_SINK_H */
diff --git a/gr-blocks/include/blocks/tagged_stream_mux.h b/gr-blocks/include/blocks/tagged_stream_mux.h
new file mode 100644
index 0000000000..23e8a94403
--- /dev/null
+++ b/gr-blocks/include/blocks/tagged_stream_mux.h
@@ -0,0 +1,61 @@
+/* -*- c++ -*- */
+/* Copyright 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_TAGGED_STREAM_MUX_H
+#define INCLUDED_TAGGED_STREAM_MUX_H
+
+#include <blocks/api.h>
+#include <gr_tagged_stream_block.h>
+
+namespace gr {
+ namespace blocks {
+
+ /*!
+ * \brief Combines tagged streams.
+ *
+ * \description
+ * Takes N streams as input. Each stream is tagged with packet lengths.
+ * Packets are output sequentially from each input stream.
+ *
+ * The output signal has a new length tag, which is the sum of all
+ * individual length tags.
+ *
+ * All other tags are propagated as expected, i.e. they stay associated
+ * with the same input item.
+ *
+ * \ingroup blocks
+ */
+ class BLOCKS_API tagged_stream_mux : virtual public gr_tagged_stream_block
+ {
+ public:
+ typedef boost::shared_ptr<tagged_stream_mux> sptr;
+
+ /* \param itemsize Items size (number of bytes per item)
+ * \param lengthtagname Length tag key
+ */
+ static sptr make(size_t itemsize, const std::string &lengthtagname);
+ };
+
+ } // namespace blocks
+} // namespace gr
+
+#endif /* INCLUDED_TAGGED_STREAM_MUX_H */
+
diff --git a/gr-blocks/include/blocks/tagged_stream_to_pdu.h b/gr-blocks/include/blocks/tagged_stream_to_pdu.h
new file mode 100644
index 0000000000..32e72a7879
--- /dev/null
+++ b/gr-blocks/include/blocks/tagged_stream_to_pdu.h
@@ -0,0 +1,53 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2013 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_BLOCKS_TAGGED_STREAM_TO_PDU_H
+#define INCLUDED_BLOCKS_TAGGED_STREAM_TO_PDU_H
+
+#include <blocks/api.h>
+#include <blocks/pdu.h>
+#include <gr_sync_block.h>
+
+namespace gr {
+ namespace blocks {
+
+ /*!
+ * \brief Turns received stream data and tags into PDUs
+ * \ingroup source_blk
+ */
+ class BLOCKS_API tagged_stream_to_pdu : virtual public gr_sync_block
+ {
+ public:
+ // gr::blocks::tagged_stream_to_pdu::sptr
+ typedef boost::shared_ptr<tagged_stream_to_pdu> sptr;
+
+ /*!
+ * \brief Construct a tagged_stream_to_pdu block
+ * \param type PDU type of pdu::vector_type
+ */
+ static sptr make(pdu::vector_type type);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_BLOCKS_TAGGED_STREAM_TO_PDU_H */
diff --git a/gr-blocks/include/blocks/tuntap_pdu.h b/gr-blocks/include/blocks/tuntap_pdu.h
new file mode 100644
index 0000000000..70abb0bd5b
--- /dev/null
+++ b/gr-blocks/include/blocks/tuntap_pdu.h
@@ -0,0 +1,53 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2013 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_BLOCKS_TUNTAP_PDU_H
+#define INCLUDED_BLOCKS_TUNTAP_PDU_H
+
+#include <blocks/api.h>
+#include <gr_block.h>
+
+namespace gr {
+ namespace blocks {
+
+ /*!
+ * \brief Creates TUNTAP interface and translates traffic to PDUs
+ * \ingroup net_blk
+ */
+ class BLOCKS_API tuntap_pdu : virtual public gr_block
+ {
+ public:
+ // gr::blocks::tuntap_pdu::sptr
+ typedef boost::shared_ptr<tuntap_pdu> sptr;
+
+ /*!
+ * \brief Construct a TUNTAP PDU interface
+ * \param dev Device name to create
+ * \param MTU Maximum Transmission Unit size
+ */
+ static sptr make(std::string dev, int MTU=10000);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_BLOCKS_TUNTAP_PDU_H */
diff --git a/gr-blocks/include/blocks/udp_sink.h b/gr-blocks/include/blocks/udp_sink.h
new file mode 100644
index 0000000000..69c5f0ffae
--- /dev/null
+++ b/gr-blocks/include/blocks/udp_sink.h
@@ -0,0 +1,81 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007-2010,2013 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_UDP_SINK_H
+#define INCLUDED_GR_UDP_SINK_H
+
+#include <blocks/api.h>
+#include <gr_sync_block.h>
+
+namespace gr {
+ namespace blocks {
+
+ /*!
+ * \brief Write stream to an UDP socket.
+ * \ingroup sink_blk
+ */
+ class BLOCKS_API udp_sink : virtual public gr_sync_block
+ {
+ public:
+ // gr::blocks::udp_sink::sptr
+ typedef boost::shared_ptr<udp_sink> sptr;
+
+ /*!
+ * \brief UDP Sink Constructor
+ *
+ * \param itemsize The size (in bytes) of the item datatype
+ * \param host The name or IP address of the receiving host; use
+ * NULL or None for no connection
+ * \param port Destination port to connect to on receiving host
+ * \param payload_size UDP payload size by default set to
+ * 1472 = (1500 MTU - (8 byte UDP header) - (20 byte IP header))
+ * \param eof Send zero-length packet on disconnect
+ */
+ static sptr make(size_t itemsize,
+ const std::string &host, int port,
+ int payload_size=1472, bool eof=true);
+
+ /*! \brief return the PAYLOAD_SIZE of the socket */
+ virtual int payload_size() = 0;
+
+ /*! \brief Change the connection to a new destination
+ *
+ * \param host The name or IP address of the receiving host; use
+ * NULL or None to break the connection without closing
+ * \param port Destination port to connect to on receiving host
+ *
+ * Calls disconnect() to terminate any current connection first.
+ */
+ virtual void connect(const std::string &host, int port) = 0;
+
+ /*! \brief Send zero-length packet (if eof is requested) then stop sending
+ *
+ * Zero-byte packets can be interpreted as EOF by gr_udp_source.
+ * Note that disconnect occurs automatically when the sink is
+ * destroyed, but not when its top_block stops.*/
+ virtual void disconnect() = 0;
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_GR_UDP_SINK_H */
diff --git a/gr-blocks/include/blocks/udp_source.h b/gr-blocks/include/blocks/udp_source.h
new file mode 100644
index 0000000000..b72db30db0
--- /dev/null
+++ b/gr-blocks/include/blocks/udp_source.h
@@ -0,0 +1,84 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007-2010,2013 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_UDP_SOURCE_H
+#define INCLUDED_GR_UDP_SOURCE_H
+
+#include <blocks/api.h>
+#include <gr_sync_block.h>
+
+namespace gr {
+ namespace blocks {
+
+ /*!
+ * \brief Read stream from an UDP socket.
+ * \ingroup source_blk
+ */
+ class BLOCKS_API udp_source : virtual public gr_sync_block
+ {
+ public:
+ // gr::blocks::udp_source::sptr
+ typedef boost::shared_ptr<udp_source> sptr;
+
+ /*!
+ * \brief UDP Source Constructor
+ *
+ * \param itemsize The size (in bytes) of the item datatype
+ * \param host The name or IP address of the receiving host; can be
+ * NULL, None, or "0.0.0.0" to allow reading from any
+ * interface on the host
+ * \param port The port number on which to receive data; use 0 to
+ * have the system assign an unused port number
+ * \param payload_size UDP payload size by default set to 1472 =
+ * (1500 MTU - (8 byte UDP header) - (20 byte IP header))
+ * \param eof Interpret zero-length packet as EOF (default: true)
+ */
+ static sptr make(size_t itemsize,
+ const std::string &host, int port,
+ int payload_size=1472,
+ bool eof=true);
+
+ /*! \brief Change the connection to a new destination
+ *
+ * \param host The name or IP address of the receiving host; use
+ * NULL or None to break the connection without closing
+ * \param port Destination port to connect to on receiving host
+ *
+ * Calls disconnect() to terminate any current connection first.
+ */
+ virtual void connect(const std::string &host, int port) = 0;
+
+ /*! \brief Cut the connection if we have one set up.
+ */
+ virtual void disconnect() = 0;
+
+ /*! \brief return the PAYLOAD_SIZE of the socket */
+ virtual int payload_size() = 0;
+
+ /*! \brief return the port number of the socket */
+ virtual int get_port() = 0;
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_GR_UDP_SOURCE_H */
diff --git a/gr-blocks/include/blocks/unpack_k_bits_bb.h b/gr-blocks/include/blocks/unpack_k_bits_bb.h
new file mode 100644
index 0000000000..b716ded1d3
--- /dev/null
+++ b/gr-blocks/include/blocks/unpack_k_bits_bb.h
@@ -0,0 +1,52 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2006,2013 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_UNPACK_K_BITS_BB_H
+#define INCLUDED_GR_UNPACK_K_BITS_BB_H
+
+#include <blocks/api.h>
+#include <gr_sync_interpolator.h>
+
+namespace gr {
+ namespace blocks {
+
+ /*!
+ * \brief Converts a byte with k relevent bits to k output bytes with 1 bit in the LSB.
+ * \ingroup converter_blk
+ */
+ class BLOCKS_API unpack_k_bits_bb : virtual public gr_sync_interpolator
+ {
+ public:
+ // gr::blocks::unpack_k_bits_bb::sptr
+ typedef boost::shared_ptr<unpack_k_bits_bb> sptr;
+
+ /*!
+ * \brief Make an unpack_k_bits block.
+ * \param k number of bits to unpack.
+ */
+ static sptr make(unsigned k);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_GR_UNPACK_K_BITS_BB_H */
diff --git a/gr-blocks/include/blocks/vco_f.h b/gr-blocks/include/blocks/vco_f.h
new file mode 100644
index 0000000000..0a5bf97d1f
--- /dev/null
+++ b/gr-blocks/include/blocks/vco_f.h
@@ -0,0 +1,57 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2005,2013 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_VCO_F_H
+#define INCLUDED_GR_VCO_F_H
+
+#include <blocks/api.h>
+#include <gr_sync_block.h>
+
+namespace gr {
+ namespace blocks {
+
+ /*!
+ * \brief VCO - Voltage controlled oscillator
+ * \ingroup misc
+ *
+ * input: float stream of control voltages; output: float oscillator output
+ */
+ class BLOCKS_API vco_f : virtual public gr_sync_block
+ {
+ public:
+ // gr::blocks::vco_f::sptr
+ typedef boost::shared_ptr<vco_f> sptr;
+
+ /*!
+ * \brief VCO - Voltage controlled oscillator
+ *
+ * \param sampling_rate sampling rate (Hz)
+ * \param sensitivity units are radians/sec/volt
+ * \param amplitude output amplitude
+ */
+ static sptr make(double sampling_rate, double sensitivity, double amplitude);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_GR_VCO_F_H */
diff --git a/gr-blocks/include/blocks/vector_insert_X.h.t b/gr-blocks/include/blocks/vector_insert_X.h.t
new file mode 100644
index 0000000000..aeb4a5248a
--- /dev/null
+++ b/gr-blocks/include/blocks/vector_insert_X.h.t
@@ -0,0 +1,54 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2012-2013 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.
+ */
+
+// @WARNING@
+
+#ifndef @GUARD_NAME@
+#define @GUARD_NAME@
+
+#include <blocks/api.h>
+#include <gr_block.h>
+
+namespace gr {
+ namespace blocks {
+
+ /*!
+ * \brief source of @TYPE@'s that gets its data from a vector
+ * \ingroup source_blk
+ */
+ class BLOCKS_API @NAME@ : virtual public gr_block
+ {
+ public:
+ // gr::blocks::@NAME@::sptr
+ typedef boost::shared_ptr<@NAME@> sptr;
+
+ static sptr make(const std::vector<@TYPE@> &data,
+ int periodicity, int offset=0);
+
+ virtual void rewind() = 0;
+ virtual void set_data(const std::vector<@TYPE@> &data) = 0;
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* @GUARD_NAME@ */
diff --git a/gr-blocks/include/blocks/vector_map.h b/gr-blocks/include/blocks/vector_map.h
new file mode 100644
index 0000000000..64c8744975
--- /dev/null
+++ b/gr-blocks/include/blocks/vector_map.h
@@ -0,0 +1,71 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2012,2013 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_VECTOR_MAP_H
+#define INCLUDED_GR_VECTOR_MAP_H
+
+#include <blocks/api.h>
+#include <vector>
+#include <gr_sync_block.h>
+
+namespace gr {
+ namespace blocks {
+
+ /*!
+ * \brief Maps elements from a set of input vectors to a set of output vectors.
+ * \ingroup slicedice_blk
+ *
+ * If in[i] is the input vector in the i'th stream then the output
+ * vector in the j'th stream is:
+ *
+ * out[j][k] = in[mapping[j][k][0]][mapping[j][k][1]]
+ *
+ * That is mapping is of the form (out_stream1_mapping,
+ * out_stream2_mapping, ...) and out_stream1_mapping is of the
+ * form (element1_mapping, element2_mapping, ...) and
+ * element1_mapping is of the form (in_stream, in_element).
+ */
+ class BLOCKS_API vector_map : virtual public gr_sync_block
+ {
+ public:
+ // gr::blocks::vector_map::sptr
+ typedef boost::shared_ptr<vector_map> sptr;
+
+ /*!
+ * Build a vector map block.
+ *
+ * \param item_size (integer) size of vector elements
+ * \param in_vlens (vector of integers) number of elements in each
+ * input vector
+ * \param mapping (vector of vectors of vectors of integers) how to
+ * map elements from input to output vectors
+ */
+ static sptr make(size_t item_size, std::vector<size_t> in_vlens,
+ std::vector< std::vector< std::vector<size_t> > > mapping);
+
+ virtual void set_mapping(std::vector< std::vector< std::vector<size_t> > > mapping) = 0;
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_GR_VECTOR_MAP_H */
diff --git a/gr-blocks/include/blocks/vector_sink_X.h.t b/gr-blocks/include/blocks/vector_sink_X.h.t
new file mode 100644
index 0000000000..d15c795721
--- /dev/null
+++ b/gr-blocks/include/blocks/vector_sink_X.h.t
@@ -0,0 +1,54 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2008,2009,2013 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.
+ */
+
+// @WARNING@
+
+#ifndef @GUARD_NAME@
+#define @GUARD_NAME@
+
+#include <blocks/api.h>
+#include <gr_sync_block.h>
+
+namespace gr {
+ namespace blocks {
+
+ /*!
+ * \brief @TYPE@ sink that writes to a vector
+ * \ingroup sink_blk
+ */
+ class BLOCKS_API @NAME@ : virtual public gr_sync_block
+ {
+ public:
+ // gr::blocks::@NAME@::sptr
+ typedef boost::shared_ptr<@NAME@> sptr;
+
+ static sptr make(int vlen = 1);
+
+ virtual void reset() = 0;
+ virtual std::vector<@TYPE@> data() const = 0;
+ virtual std::vector<gr_tag_t> tags() const = 0;
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* @GUARD_NAME@ */
diff --git a/gr-blocks/include/blocks/vector_source_X.h.t b/gr-blocks/include/blocks/vector_source_X.h.t
new file mode 100644
index 0000000000..c68b638e62
--- /dev/null
+++ b/gr-blocks/include/blocks/vector_source_X.h.t
@@ -0,0 +1,56 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2008,2012-2013 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.
+ */
+
+// @WARNING@
+
+#ifndef @GUARD_NAME@
+#define @GUARD_NAME@
+
+#include <blocks/api.h>
+#include <gr_sync_block.h>
+
+namespace gr {
+ namespace blocks {
+
+ /*!
+ * \brief source of @TYPE@'s that gets its data from a vector
+ * \ingroup source_blk
+ */
+ class BLOCKS_API @NAME@ : virtual public gr_sync_block
+ {
+ public:
+ // gr::blocks::@NAME@::sptr
+ typedef boost::shared_ptr<@NAME@> sptr;
+
+ static sptr make(const std::vector<@TYPE@> &data,
+ bool repeat=false, int vlen=1,
+ const std::vector<gr_tag_t> &tags=std::vector<gr_tag_t>());
+
+ virtual void rewind() = 0;
+ virtual void set_data(const std::vector<@TYPE@> &data,
+ const std::vector<gr_tag_t> &tags=std::vector<gr_tag_t>()) = 0;
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* @GUARD_NAME@ */
diff --git a/gr-blocks/include/blocks/wavfile.h b/gr-blocks/include/blocks/wavfile.h
new file mode 100644
index 0000000000..690f8fc22a
--- /dev/null
+++ b/gr-blocks/include/blocks/wavfile.h
@@ -0,0 +1,101 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008,2013 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.
+ */
+
+// This file stores all the RIFF file type knowledge for the gr_wavfile_*
+// blocks.
+
+#include <blocks/api.h>
+#include <cstdio>
+
+namespace gr {
+ namespace blocks {
+
+ /*!
+ * \brief Read signal information from a given WAV file.
+ *
+ * \param[in] fp File pointer to an opened, empty file.
+ * \param[out] sample_rate Stores the sample rate [S/s]
+ * \param[out] nchans Number of channels
+ * \param[out] bytes_per_sample Bytes per sample, can either be 1 or 2 (corresponding o
+ * 8 or 16 bit samples, respectively)
+ * \param[out] first_sample_pos Number of the first byte containing a sample. Use this
+ * with fseek() to jump from the end of the file to the
+ * first sample when in repeat mode.
+ * \param[out] samples_per_chan Number of samples per channel
+ * \return True on a successful read, false if the file could not be read or is
+ * not a valid WAV file.
+ */
+ bool
+ wavheader_parse(FILE *fp,
+ unsigned int &sample_rate,
+ int &nchans,
+ int &bytes_per_sample,
+ int &first_sample_pos,
+ unsigned int &samples_per_chan);
+
+ /*!
+ * \brief Read one sample from an open WAV file at the current position.
+ *
+ * Takes care of endianness.
+ */
+ short int
+ wav_read_sample(FILE *fp, int bytes_per_sample);
+
+
+ /*!
+ * \brief Write a valid RIFF file header
+ *
+ * Note: Some header values are kept blank because they're usually
+ * not known a-priori (file and chunk lengths). Use
+ * gri_wavheader_complete() to fill these in.
+ */
+ bool
+ wavheader_write(FILE *fp,
+ unsigned int sample_rate,
+ int nchans,
+ int bytes_per_sample);
+
+ /*!
+ * \brief Write one sample to an open WAV file at the current position.
+ *
+ * Takes care of endianness.
+ */
+ void
+ wav_write_sample(FILE *fp, short int sample, int bytes_per_sample);
+
+
+ /*!
+ * \brief Complete a WAV header
+ *
+ * Note: The stream position is changed during this function. If
+ * anything needs to be written to the WAV file after calling this
+ * function (which shouldn't happen), you need to fseek() to the
+ * end of the file (or whereever).
+ *
+ * \param[in] fp File pointer to an open WAV file with a blank header
+ * \param[in] byte_count Length of all samples written to the file in bytes.
+ */
+ bool
+ wavheader_complete(FILE *fp, unsigned int byte_count);
+
+ } /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/include/blocks/wavfile_sink.h b/gr-blocks/include/blocks/wavfile_sink.h
new file mode 100644
index 0000000000..b095191d07
--- /dev/null
+++ b/gr-blocks/include/blocks/wavfile_sink.h
@@ -0,0 +1,87 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008,2009,2013 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_WAVFILE_SINK_H
+#define INCLUDED_GR_WAVFILE_SINK_H
+
+#include <blocks/api.h>
+#include <gr_sync_block.h>
+
+namespace gr {
+ namespace blocks {
+
+ /*!
+ * \brief Write stream to a Microsoft PCM (.wav) file.
+ *
+ * Values must be floats within [-1;1].
+ * Check gr_make_wavfile_sink() for extra info.
+ *
+ * \ingroup sink_blk
+ */
+ class BLOCKS_API wavfile_sink : virtual public gr_sync_block
+ {
+ public:
+ // gr::blocks::wavfile_sink::sptr
+ typedef boost::shared_ptr<wavfile_sink> sptr;
+
+ /*
+ * \p filename The .wav file to be opened
+ * \p n_channels Number of channels (2 = stereo or I/Q output)
+ * \p sample_rate Sample rate [S/s]
+ * \p bits_per_sample 16 or 8 bit, default is 16
+ */
+ static sptr make(const char *filename,
+ int n_channels,
+ unsigned int sample_rate,
+ int bits_per_sample = 16);
+
+ /*!
+ * \brief Opens a new file and writes a WAV header. Thread-safe.
+ */
+ virtual bool open(const char* filename) = 0;
+
+ /*!
+ * \brief Closes the currently active file and completes the WAV
+ * header. Thread-safe.
+ */
+ virtual void close() = 0;
+
+ /*!
+ * \brief Set the sample rate. This will not affect the WAV file
+ * currently opened. Any following open() calls will use this new
+ * sample rate.
+ */
+ virtual void set_sample_rate(unsigned int sample_rate) = 0;
+
+ /*!
+ * \brief Set bits per sample. This will not affect the WAV file
+ * currently opened (see set_sample_rate()). If the value is
+ * neither 8 nor 16, the call is ignored and the current value
+ * is kept.
+ */
+ virtual void set_bits_per_sample(int bits_per_sample) = 0;
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_GR_WAVFILE_SINK_H */
diff --git a/gr-blocks/include/blocks/wavfile_source.h b/gr-blocks/include/blocks/wavfile_source.h
new file mode 100644
index 0000000000..46cb82b698
--- /dev/null
+++ b/gr-blocks/include/blocks/wavfile_source.h
@@ -0,0 +1,70 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2008,2013 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_WAVFILE_SOURCE_H
+#define INCLUDED_GR_WAVFILE_SOURCE_H
+
+#include <blocks/api.h>
+#include <gr_sync_block.h>
+
+namespace gr {
+ namespace blocks {
+
+ /*!
+ * \brief Read stream from a Microsoft PCM (.wav) file, output floats
+ *
+ * Unless otherwise called, values are within [-1;1].
+ * Check gr_make_wavfile_source() for extra info.
+ *
+ * \ingroup source_blk
+ */
+ class BLOCKS_API wavfile_source : virtual public gr_sync_block
+ {
+ public:
+ // gr::blocks::wavfile_source::sptr
+ typedef boost::shared_ptr<wavfile_source> sptr;
+
+ static sptr make(const char *filename, bool repeat = false);
+
+ /*!
+ * \brief Read the sample rate as specified in the wav file header
+ */
+ virtual unsigned int sample_rate() const = 0;
+
+ /*!
+ * \brief Return the number of bits per sample as specified in
+ * the wav file header. Only 8 or 16 bit are supported here.
+ */
+ virtual int bits_per_sample() const = 0;
+
+ /*!
+ * \brief Return the number of channels in the wav file as
+ * specified in the wav file header. This is also the max number
+ * of outputs you can have.
+ */
+ virtual int channels() const = 0;
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_GR_WAVFILE_SOURCE_H */
diff --git a/gr-blocks/lib/CMakeLists.txt b/gr-blocks/lib/CMakeLists.txt
index 20e3ae4aa6..eb7af51c0b 100644
--- a/gr-blocks/lib/CMakeLists.txt
+++ b/gr-blocks/lib/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright 2012 Free Software Foundation, Inc.
+# Copyright 2012-2013 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -95,17 +95,28 @@ expand_cc_h_impl(add_const_XX ss ii ff cc)
expand_cc_h_impl(add_const_vXX ss ii ff cc)
expand_cc_h_impl(and_XX bb ss ii)
expand_cc_h_impl(and_const_XX bb ss ii)
+expand_cc_h_impl(argmax_XX fs is ss)
expand_cc_h_impl(divide_XX ss ii ff cc)
expand_cc_h_impl(integrate_XX ss ii ff cc)
+expand_cc_h_impl(max_XX ff ii ss)
+expand_cc_h_impl(moving_average_XX ss ii ff cc)
expand_cc_h_impl(multiply_XX ss ii)
expand_cc_h_impl(multiply_const_XX ss ii)
expand_cc_h_impl(multiply_const_vXX ss ii ff cc)
+expand_cc_h_impl(mute_XX ss ii ff cc)
expand_cc_h_impl(not_XX bb ss ii)
expand_cc_h_impl(or_XX bb ss ii)
+expand_cc_h_impl(peak_detector_XX fb ib sb)
+expand_cc_h_impl(probe_signal_X b s i f c)
+expand_cc_h_impl(probe_signal_vX b s i f c)
+expand_cc_h_impl(sample_and_hold_XX bb ss ii ff)
expand_cc_h_impl(sub_XX ss ii ff cc)
expand_cc_h_impl(xor_XX bb ss ii)
expand_cc_h_impl(packed_to_unpacked_XX bb ss ii)
expand_cc_h_impl(unpacked_to_packed_XX bb ss ii)
+expand_cc_h_impl(vector_insert_X b s i f c)
+expand_cc_h_impl(vector_sink_X b s i f c)
+expand_cc_h_impl(vector_source_X b s i f c)
########################################################################
# Setup the include and linker paths
@@ -128,10 +139,19 @@ link_directories(${Boost_LIBRARY_DIRS})
########################################################################
list(APPEND gr_blocks_sources
${generated_sources}
+ control_loop.cc
count_bits.cc
+ file_sink_base.cc
+ wavfile.cc
add_ff_impl.cc
+ annotator_1to1_impl.cc
+ annotator_alltoall_impl.cc
+ annotator_raw_impl.cc
+ bin_statistics_f_impl.cc
+ burst_tagger_impl.cc
char_to_float_impl.cc
char_to_short_impl.cc
+ check_lfsr_32k_s_impl.cc
complex_to_interleaved_short_impl.cc
complex_to_float_impl.cc
complex_to_real_impl.cc
@@ -140,8 +160,13 @@ list(APPEND gr_blocks_sources
complex_to_mag_squared_impl.cc
complex_to_arg_impl.cc
conjugate_cc_impl.cc
+ copy_impl.cc
deinterleave_impl.cc
delay_impl.cc
+ endian_swap_impl.cc
+ file_descriptor_sink_impl.cc
+ file_descriptor_source_impl.cc
+ file_sink_impl.cc
file_source_impl.cc
file_meta_sink_impl.cc
file_meta_source_impl.cc
@@ -152,46 +177,93 @@ list(APPEND gr_blocks_sources
float_to_short_impl.cc
float_array_to_uchar.cc
float_to_uchar_impl.cc
+ head_impl.cc
int_to_float_impl.cc
interleave_impl.cc
interleaved_short_array_to_complex.cc
interleaved_short_to_complex_impl.cc
keep_m_in_n_impl.cc
keep_one_in_n_impl.cc
+ lfsr_32k_source_s_impl.cc
+ message_debug_impl.cc
+ message_sink_impl.cc
+ message_source_impl.cc
+ message_strobe_impl.cc
+ message_burst_source_impl.cc
multiply_cc_impl.cc
multiply_ff_impl.cc
multiply_conjugate_cc_impl.cc
multiply_const_cc_impl.cc
multiply_const_ff_impl.cc
nlog10_ff_impl.cc
+ nop_impl.cc
+ null_sink_impl.cc
+ null_source_impl.cc
+ pack_k_bits_bb_impl.cc
patterned_interleaver_impl.cc
+ pdu.cc
+ tag_debug_impl.cc
+ pdu_to_tagged_stream_impl.cc
peak_detector2_fb_impl.cc
+ plateau_detector_fb_impl.cc
+ probe_rate_impl.cc
regenerate_bb_impl.cc
+ repack_bits_bb_impl.cc
repeat_impl.cc
rms_cf_impl.cc
rms_ff_impl.cc
short_to_char_impl.cc
short_to_float_impl.cc
+ skiphead_impl.cc
+ socket_pdu_impl.cc
stream_mux_impl.cc
+ stream_pdu_base.cc
stream_to_streams_impl.cc
stream_to_vector_impl.cc
streams_to_stream_impl.cc
streams_to_vector_impl.cc
stretch_ff_impl.cc
+ tagged_file_sink_impl.cc
+ tagged_stream_to_pdu_impl.cc
threshold_ff_impl.cc
throttle_impl.cc
transcendental_impl.cc
+ tcp_connection.cc
+ tuntap_pdu_impl.cc
+ tagged_stream_mux_impl.cc
uchar_array_to_float.cc
uchar_to_float_impl.cc
+ udp_sink_impl.cc
+ udp_source_impl.cc
+ unpack_k_bits_bb_impl.cc
+ vco_f_impl.cc
+ vector_map_impl.cc
vector_to_stream_impl.cc
vector_to_streams_impl.cc
+ wavfile_sink_impl.cc
+ wavfile_source_impl.cc
)
+#Add Windows DLL resource file if using MSVC
+IF(MSVC)
+ include(${CMAKE_SOURCE_DIR}/cmake/Modules/GrVersion.cmake)
+
+ configure_file(
+ ${CMAKE_CURRENT_SOURCE_DIR}/gnuradio-blocks.rc.in
+ ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-blocks.rc
+ @ONLY)
+
+ list(APPEND gr_blocks_sources
+ ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-blocks.rc
+ )
+ENDIF(MSVC)
+
list(APPEND blocks_libs
gnuradio-core
volk
${Boost_LIBRARIES}
${BLOCKS_LIBRARIES}
+ ${LOG4CPP_LIBRARIES}
)
add_library(gnuradio-blocks SHARED ${gr_blocks_sources})
@@ -199,3 +271,37 @@ add_dependencies(gnuradio-blocks blocks_generated_includes)
target_link_libraries(gnuradio-blocks ${blocks_libs})
GR_LIBRARY_FOO(gnuradio-blocks RUNTIME_COMPONENT "blocks_runtime" DEVEL_COMPONENT "blocks_devel")
+
+########################################################################
+# QA C++ Code for gr-filter
+########################################################################
+if(ENABLE_TESTING)
+ include(GrTest)
+
+ include_directories(
+ ${GR_FILTER_INCLUDE_DIRS}
+ ${CPPUNIT_INCLUDE_DIRS})
+ link_directories(${CPPUNIT_LIBRARY_DIRS})
+
+ list(APPEND test_gr_blocks_sources
+ ${CMAKE_CURRENT_SOURCE_DIR}/test_gr_blocks.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/qa_blocks.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/qa_block_tags.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/qa_rotator.cc
+ )
+
+ add_executable(test-gr-blocks ${test_gr_blocks_sources})
+
+ list(APPEND GR_TEST_TARGET_DEPS test-gr-blocks gnuradio-blocks)
+
+ target_link_libraries(
+ test-gr-blocks
+ gnuradio-core
+ gnuradio-blocks
+ gnuradio-filter
+ ${Boost_LIBRARIES}
+ ${CPPUNIT_LIBRARIES}
+ )
+
+ GR_ADD_TEST(test_gr_blocks test-gr-blocks)
+endif(ENABLE_TESTING)
diff --git a/gr-blocks/lib/ConfigChecks.cmake b/gr-blocks/lib/ConfigChecks.cmake
index 72d6d1d8ab..7f60aed403 100644
--- a/gr-blocks/lib/ConfigChecks.cmake
+++ b/gr-blocks/lib/ConfigChecks.cmake
@@ -56,7 +56,7 @@ CHECK_INCLUDE_FILE_CXX(windows.h HAVE_WINDOWS_H)
IF(HAVE_WINDOWS_H)
ADD_DEFINITIONS(-DHAVE_WINDOWS_H -DUSING_WINSOCK)
MESSAGE(STATUS "Adding windows libs to gr blocks libs...")
- LIST(APPEND gnuradio_core_libs WS2_32.lib WSock32.lib)
+ LIST(APPEND blocks_libs WS2_32.lib WSock32.lib)
ENDIF(HAVE_WINDOWS_H)
########################################################################
diff --git a/gr-blocks/lib/add_XX_impl.h.t b/gr-blocks/lib/add_XX_impl.h.t
index a1c486b859..2e20ef5fe3 100644
--- a/gr-blocks/lib/add_XX_impl.h.t
+++ b/gr-blocks/lib/add_XX_impl.h.t
@@ -32,6 +32,7 @@ namespace gr {
class BLOCKS_API @NAME_IMPL@ : public @NAME@
{
+ private:
size_t d_vlen;
public:
diff --git a/gr-blocks/lib/annotator_1to1_impl.cc b/gr-blocks/lib/annotator_1to1_impl.cc
new file mode 100644
index 0000000000..d3f4758684
--- /dev/null
+++ b/gr-blocks/lib/annotator_1to1_impl.cc
@@ -0,0 +1,113 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2010,2013 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "annotator_1to1_impl.h"
+#include <gr_io_signature.h>
+#include <string.h>
+#include <iostream>
+#include <iomanip>
+
+namespace gr {
+ namespace blocks {
+
+ annotator_1to1::sptr
+ annotator_1to1::make(int when, size_t sizeof_stream_item)
+ {
+ return gnuradio::get_initial_sptr
+ (new annotator_1to1_impl(when, sizeof_stream_item));
+ }
+
+ annotator_1to1_impl::annotator_1to1_impl(int when, size_t sizeof_stream_item)
+ : gr_sync_block("annotator_1to1",
+ gr_make_io_signature(1, -1, sizeof_stream_item),
+ gr_make_io_signature(1, -1, sizeof_stream_item)),
+ d_itemsize(sizeof_stream_item), d_when((uint64_t)when)
+ {
+ set_tag_propagation_policy(TPP_ONE_TO_ONE);
+
+ d_tag_counter = 0;
+ set_relative_rate(1.0);
+ }
+
+ annotator_1to1_impl::~annotator_1to1_impl()
+ {
+ }
+
+ int
+ annotator_1to1_impl::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ const float *in = (const float*)input_items[0];
+ float *out = (float*)output_items[0];
+
+ std::stringstream str;
+ str << name() << unique_id();
+
+ uint64_t abs_N = 0;
+ int ninputs = input_items.size();
+ for(int i = 0; i < ninputs; i++) {
+ abs_N = nitems_read(i);
+
+ std::vector<gr_tag_t> all_tags;
+ get_tags_in_range(all_tags, i, abs_N, abs_N + noutput_items);
+
+ std::vector<gr_tag_t>::iterator itr;
+ for(itr = all_tags.begin(); itr != all_tags.end(); itr++) {
+ d_stored_tags.push_back(*itr);
+ }
+ }
+
+ // Storing the current noutput_items as the value to the "noutput_items" key
+ pmt::pmt_t srcid = pmt::pmt_string_to_symbol(str.str());
+ pmt::pmt_t key = pmt::pmt_string_to_symbol("seq");
+
+ // Work does nothing to the data stream; just copy all inputs to outputs
+ // Adds a new tag when the number of items read is a multiple of d_when
+ abs_N = nitems_read(0);
+ int noutputs = output_items.size();
+ for(int j = 0; j < noutput_items; j++) {
+ // the min() is a hack to make sure this doesn't segfault if
+ // there are a different number of ins and outs. This is
+ // specifically designed to test the 1-to-1 propagation policy.
+ for(int i = 0; i < std::min(noutputs, ninputs); i++) {
+ if(abs_N % d_when == 0) {
+ pmt::pmt_t value = pmt::pmt_from_uint64(d_tag_counter++);
+ add_item_tag(i, abs_N, key, value, srcid);
+ }
+
+ in = (const float*)input_items[i];
+ out = (float*)output_items[i];
+ out[j] = in[j];
+ }
+ abs_N++;
+ }
+
+ return noutput_items;
+ }
+
+ } /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/annotator_1to1_impl.h b/gr-blocks/lib/annotator_1to1_impl.h
new file mode 100644
index 0000000000..3306602e2c
--- /dev/null
+++ b/gr-blocks/lib/annotator_1to1_impl.h
@@ -0,0 +1,56 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2010,2013 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_ANNOTATOR_1TO1_IMPL_H
+#define INCLUDED_GR_ANNOTATOR_1TO1_IMPL_H
+
+#include <blocks/annotator_1to1.h>
+
+namespace gr {
+ namespace blocks {
+
+ class annotator_1to1_impl : public annotator_1to1
+ {
+ private:
+ size_t d_itemsize;
+ uint64_t d_when;
+ uint64_t d_tag_counter;
+ std::vector<gr_tag_t> d_stored_tags;
+
+ public:
+ annotator_1to1_impl(int when, size_t sizeof_stream_item);
+ ~annotator_1to1_impl();
+
+ std::vector<gr_tag_t> data() const
+ {
+ return d_stored_tags;
+ }
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_GR_ANNOTATOR_1TO1_IMPL_H */
diff --git a/gr-blocks/lib/annotator_alltoall_impl.cc b/gr-blocks/lib/annotator_alltoall_impl.cc
new file mode 100644
index 0000000000..5af1a9c18e
--- /dev/null
+++ b/gr-blocks/lib/annotator_alltoall_impl.cc
@@ -0,0 +1,117 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2010,2013 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "annotator_alltoall_impl.h"
+#include <gr_io_signature.h>
+#include <string.h>
+#include <iostream>
+#include <iomanip>
+
+namespace gr {
+ namespace blocks {
+
+ annotator_alltoall::sptr
+ annotator_alltoall::make(int when, size_t sizeof_stream_item)
+ {
+ return gnuradio::get_initial_sptr
+ (new annotator_alltoall_impl(when, sizeof_stream_item));
+ }
+
+ annotator_alltoall_impl::annotator_alltoall_impl(int when,
+ size_t sizeof_stream_item)
+ : gr_sync_block("annotator_alltoall",
+ gr_make_io_signature(1, -1, sizeof_stream_item),
+ gr_make_io_signature(1, -1, sizeof_stream_item)),
+ d_itemsize(sizeof_stream_item), d_when((uint64_t)when)
+ {
+ set_tag_propagation_policy(TPP_ALL_TO_ALL);
+
+ d_tag_counter = 0;
+ }
+
+ annotator_alltoall_impl::~annotator_alltoall_impl()
+ {
+ }
+
+ int
+ annotator_alltoall_impl::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ const float *in = (const float*)input_items[0];
+ float *out = (float*)output_items[0];
+
+ std::stringstream str;
+ str << name() << unique_id();
+
+ uint64_t abs_N = 0, end_N;
+ int ninputs = input_items.size();
+ for(int i = 0; i < ninputs; i++) {
+ abs_N = nitems_read(i);
+ end_N = abs_N + (uint64_t)(noutput_items);
+
+ std::vector<gr_tag_t> all_tags;
+ get_tags_in_range(all_tags, i, abs_N, end_N);
+
+ std::vector<gr_tag_t>::iterator itr;
+ for(itr = all_tags.begin(); itr != all_tags.end(); itr++) {
+ d_stored_tags.push_back(*itr);
+ }
+ }
+
+ // Source ID and key for any tag that might get applied from this block
+ pmt::pmt_t srcid = pmt::pmt_string_to_symbol(str.str());
+ pmt::pmt_t key = pmt::pmt_string_to_symbol("seq");
+
+ // Work does nothing to the data stream; just copy all inputs to
+ // outputs Adds a new tag when the number of items read is a
+ // multiple of d_when
+ abs_N = nitems_written(0);
+ int noutputs = output_items.size();
+
+ for(int j = 0; j < noutput_items; j++) {
+ for(int i = 0; i < noutputs; i++) {
+ if(abs_N % d_when == 0) {
+ pmt::pmt_t value = pmt::pmt_from_uint64(d_tag_counter++);
+ add_item_tag(i, abs_N, key, value, srcid);
+ }
+
+ // Sum all of the inputs together for each output. Just 'cause.
+ out = (float*)output_items[i];
+ out[j] = 0;
+ for(int ins = 0; ins < ninputs; ins++) {
+ in = (const float*)input_items[ins];
+ out[j] += in[j];
+ }
+ }
+ abs_N++;
+ }
+
+ return noutput_items;
+ }
+
+ } /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/annotator_alltoall_impl.h b/gr-blocks/lib/annotator_alltoall_impl.h
new file mode 100644
index 0000000000..24c21948bc
--- /dev/null
+++ b/gr-blocks/lib/annotator_alltoall_impl.h
@@ -0,0 +1,56 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2010,2013 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_ANNOTATOR_ALLTOALL_IMPL_H
+#define INCLUDED_GR_ANNOTATOR_ALLTOALL_IMPL_H
+
+#include <blocks/annotator_alltoall.h>
+
+namespace gr {
+ namespace blocks {
+
+ class annotator_alltoall_impl : public annotator_alltoall
+ {
+ private:
+ size_t d_itemsize;
+ uint64_t d_when;
+ uint64_t d_tag_counter;
+ std::vector<gr_tag_t> d_stored_tags;
+
+ public:
+ annotator_alltoall_impl(int when, size_t sizeof_stream_item);
+ ~annotator_alltoall_impl();
+
+ std::vector<gr_tag_t> data() const
+ {
+ return d_stored_tags;
+ }
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_GR_ANNOTATOR_ALLTOALL_IMPL_H */
diff --git a/gr-blocks/lib/annotator_raw_impl.cc b/gr-blocks/lib/annotator_raw_impl.cc
new file mode 100644
index 0000000000..1b92523089
--- /dev/null
+++ b/gr-blocks/lib/annotator_raw_impl.cc
@@ -0,0 +1,112 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2010,2013 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "annotator_raw_impl.h"
+#include <gr_io_signature.h>
+#include <string.h>
+#include <iostream>
+#include <iomanip>
+#include <stdexcept>
+
+using namespace pmt;
+
+namespace gr {
+ namespace blocks {
+
+ annotator_raw::sptr
+ annotator_raw::make(size_t sizeof_stream_item)
+ {
+ return gnuradio::get_initial_sptr
+ (new annotator_raw_impl(sizeof_stream_item));
+ }
+
+ annotator_raw_impl::annotator_raw_impl(size_t sizeof_stream_item)
+ : gr_sync_block("annotator_raw",
+ gr_make_io_signature(1, 1, sizeof_stream_item),
+ gr_make_io_signature(1, 1, sizeof_stream_item)),
+ d_itemsize(sizeof_stream_item)
+ {
+ set_tag_propagation_policy(TPP_ONE_TO_ONE);
+ set_relative_rate(1.0);
+ }
+
+ void annotator_raw_impl::add_tag(uint64_t offset, pmt_t key, pmt_t val)
+ {
+ gruel::scoped_lock l(d_mutex);
+
+ gr_tag_t tag;
+ tag.srcid = pmt::pmt_intern(name());
+ tag.key = key;
+ tag.value = val;
+ tag.offset = offset;
+
+ // add our new tag
+ d_queued_tags.push_back(tag);
+ // make sure our tags are in offset order
+ std::sort(d_queued_tags.begin(), d_queued_tags.end(),
+ gr_tag_t::offset_compare);
+ // make sure we are not adding an item in the past!
+ if(tag.offset > nitems_read(0)) {
+ throw std::runtime_error("annotator_raw::add_tag: item added too far in the past\n.");
+ }
+ }
+
+ annotator_raw_impl::~annotator_raw_impl()
+ {
+ }
+
+ int
+ annotator_raw_impl::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ gruel::scoped_lock l(d_mutex);
+
+ const char *in = (const char*)input_items[0];
+ char *out = (char*)output_items[0];
+
+ uint64_t start_N = nitems_read(0);
+ uint64_t end_N = start_N + (uint64_t)(noutput_items);
+
+ // locate queued tags that fall in this range and insert them when appropriate
+ std::vector<gr_tag_t>::iterator i = d_queued_tags.begin();
+ while( i != d_queued_tags.end() ) {
+ if( (*i).offset >= start_N && (*i).offset < end_N) {
+ add_item_tag(0, (*i).offset,(*i).key, (*i).value, (*i).srcid);
+ i = d_queued_tags.erase(i);
+ }
+ else {
+ break;
+ }
+ }
+
+ // copy data across
+ memcpy(out, in, noutput_items*d_itemsize);
+ return noutput_items;
+ }
+
+ } /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/annotator_raw_impl.h b/gr-blocks/lib/annotator_raw_impl.h
new file mode 100644
index 0000000000..2e349bfe33
--- /dev/null
+++ b/gr-blocks/lib/annotator_raw_impl.h
@@ -0,0 +1,54 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2010,2013 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_ANNOTATOR_RAW_IMPL_H
+#define INCLUDED_GR_ANNOTATOR_RAW_IMPL_H
+
+#include <blocks/annotator_raw.h>
+#include <gruel/thread.h>
+
+namespace gr {
+ namespace blocks {
+
+ class annotator_raw_impl : public annotator_raw
+ {
+ private:
+ size_t d_itemsize;
+ std::vector<gr_tag_t> d_queued_tags;
+ gruel::mutex d_mutex;
+
+ public:
+ annotator_raw_impl(size_t sizeof_stream_item);
+ ~annotator_raw_impl();
+
+ // insert a tag to be added
+ void add_tag(uint64_t offset, pmt::pmt_t key, pmt::pmt_t val);
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_GR_ANNOTATOR_RAW_IMPL_H */
diff --git a/gr-blocks/lib/argmax_XX_impl.cc.t b/gr-blocks/lib/argmax_XX_impl.cc.t
new file mode 100644
index 0000000000..56673ef995
--- /dev/null
+++ b/gr-blocks/lib/argmax_XX_impl.cc.t
@@ -0,0 +1,86 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007,2013 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.
+ */
+
+// @WARNING@
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <@NAME_IMPL@.h>
+#include <gr_io_signature.h>
+
+namespace gr {
+ namespace blocks {
+
+ @NAME@::sptr
+ @NAME@::make(size_t vlen)
+ {
+ return gnuradio::get_initial_sptr
+ (new @NAME_IMPL@(vlen));
+ }
+
+ @NAME_IMPL@::@NAME_IMPL@(size_t vlen)
+ : gr_sync_block("@BASE_NAME@",
+ gr_make_io_signature(1, -1, vlen*sizeof(@I_TYPE@)),
+ gr_make_io_signature(2, 2, sizeof(@O_TYPE@))),
+ d_vlen(vlen)
+ {
+ }
+
+ @NAME_IMPL@::~@NAME_IMPL@()
+ {
+ }
+
+ int
+ @NAME_IMPL@::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ int ninputs = input_items.size ();
+
+ @O_TYPE@ *x_optr = (@O_TYPE@ *)output_items[0];
+ @O_TYPE@ *y_optr = (@O_TYPE@ *)output_items[1];
+
+ for(int i = 0; i < noutput_items; i++) {
+ @I_TYPE@ max = ((@I_TYPE@ *)input_items[0])[i*d_vlen];
+ int x = 0;
+ int y = 0;
+
+ for(int j = 0; j < (int)d_vlen; j++ ) {
+ for(int k = 0; k < ninputs; k++) {
+ if(((@I_TYPE@ *)input_items[k])[i*d_vlen + j] > max) {
+ max = ((@I_TYPE@ *)input_items[k])[i*d_vlen + j];
+ x = j;
+ y = k;
+ }
+ }
+ }
+
+ *x_optr++ = (@O_TYPE@)x;
+ *y_optr++ = (@O_TYPE@)y;
+ }
+ return noutput_items;
+ }
+
+ } /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/argmax_XX_impl.h.t b/gr-blocks/lib/argmax_XX_impl.h.t
new file mode 100644
index 0000000000..0f1643f6b9
--- /dev/null
+++ b/gr-blocks/lib/argmax_XX_impl.h.t
@@ -0,0 +1,50 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007,2013 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.
+ */
+
+// @WARNING@
+
+#ifndef @GUARD_NAME_IMPL@
+#define @GUARD_NAME_IMPL@
+
+#include <blocks/@NAME@.h>
+
+namespace gr {
+ namespace blocks {
+
+ class @NAME_IMPL@ : public @NAME@
+ {
+ private:
+ size_t d_vlen;
+
+ public:
+ @NAME_IMPL@(size_t vlen);
+ ~@NAME_IMPL@();
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* @GUARD_NAME_IMPL@ */
diff --git a/gr-blocks/lib/bin_statistics_f_impl.cc b/gr-blocks/lib/bin_statistics_f_impl.cc
new file mode 100644
index 0000000000..014222a63d
--- /dev/null
+++ b/gr-blocks/lib/bin_statistics_f_impl.cc
@@ -0,0 +1,178 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2006,2010,2013 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "bin_statistics_f_impl.h"
+#include <gr_io_signature.h>
+#include <string.h>
+
+namespace gr {
+ namespace blocks {
+
+ bin_statistics_f::sptr
+ bin_statistics_f::make(unsigned int vlen,
+ gr_msg_queue_sptr msgq,
+ gr_feval_dd *tune,
+ size_t tune_delay,
+ size_t dwell_delay)
+ {
+ return gnuradio::get_initial_sptr
+ (new bin_statistics_f_impl(vlen, msgq, tune,
+ tune_delay, dwell_delay));
+ }
+
+ bin_statistics_f_impl::bin_statistics_f_impl(unsigned int vlen,
+ gr_msg_queue_sptr msgq,
+ gr_feval_dd *tune,
+ size_t tune_delay,
+ size_t dwell_delay)
+ : gr_sync_block("bin_statistics_f",
+ gr_make_io_signature(1, 1, sizeof(float) * vlen),
+ gr_make_io_signature(0, 0, 0)),
+ d_vlen(vlen), d_msgq(msgq), d_tune(tune),
+ d_tune_delay(tune_delay), d_dwell_delay(dwell_delay),
+ d_center_freq(0), d_delay(0),
+ d_max(vlen)
+ {
+ enter_init();
+ }
+
+ bin_statistics_f_impl::~bin_statistics_f_impl()
+ {
+ }
+
+ void
+ bin_statistics_f_impl::enter_init()
+ {
+ d_state = ST_INIT;
+ d_delay = 0;
+ }
+
+ void
+ bin_statistics_f_impl::enter_tune_delay()
+ {
+ d_state = ST_TUNE_DELAY;
+ d_delay = d_tune_delay;
+ d_center_freq = d_tune->calleval(0);
+ }
+
+ void
+ bin_statistics_f_impl::enter_dwell_delay()
+ {
+ d_state = ST_DWELL_DELAY;
+ d_delay = d_dwell_delay;
+ reset_stats();
+ }
+
+ void
+ bin_statistics_f_impl::leave_dwell_delay()
+ {
+ send_stats();
+ }
+
+ int
+ bin_statistics_f_impl::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ const float *input = (const float*)input_items[0];
+ size_t vlen = d_max.size();
+
+ int n = 0;
+ int t;
+
+ while(n < noutput_items) {
+ switch(d_state) {
+
+ case ST_INIT:
+ enter_tune_delay();
+ break;
+
+ case ST_TUNE_DELAY:
+ t = std::min(noutput_items - n, int(d_delay));
+ n += t;
+ d_delay -= t;
+ assert(d_delay >= 0);
+ if(d_delay == 0)
+ enter_dwell_delay();
+ break;
+
+ case ST_DWELL_DELAY:
+ t = std::min(noutput_items - n, int(d_delay));
+ for(int i = 0; i < t; i++) {
+ accrue_stats(&input[n * vlen]);
+ n++;
+ }
+ d_delay -= t;
+ assert(d_delay >= 0);
+ if(d_delay == 0) {
+ leave_dwell_delay();
+ enter_tune_delay();
+ }
+ break;
+
+ default:
+ assert(0);
+ }
+ }
+
+ return noutput_items;
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // virtual methods for gathering stats
+ //////////////////////////////////////////////////////////////////////////
+
+ void
+ bin_statistics_f_impl::reset_stats()
+ {
+ for (size_t i = 0; i < vlen(); i++){
+ d_max[i] = 0;
+ }
+ }
+
+ void
+ bin_statistics_f_impl::accrue_stats(const float *input)
+ {
+ for(size_t i = 0; i < vlen(); i++) {
+ d_max[i] = std::max(d_max[i], input[i]); // compute per bin maxima
+ }
+ }
+
+ void
+ bin_statistics_f_impl::send_stats()
+ {
+ if(msgq()->full_p()) // if the queue is full, don't block, drop the data...
+ return;
+
+ // build & send a message
+ gr_message_sptr msg = gr_make_message(0, center_freq(), vlen(), vlen() * sizeof(float));
+ memcpy(msg->msg(), &d_max[0], vlen() * sizeof(float));
+ msgq()->insert_tail(msg);
+ }
+
+ } /* namespace blocks */
+} /* namespace gr */
+
diff --git a/gr-blocks/lib/bin_statistics_f_impl.h b/gr-blocks/lib/bin_statistics_f_impl.h
new file mode 100644
index 0000000000..0abb60ed38
--- /dev/null
+++ b/gr-blocks/lib/bin_statistics_f_impl.h
@@ -0,0 +1,82 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2006,2013 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_BIN_STATISTICS_F_IMPL_H
+#define INCLUDED_GR_BIN_STATISTICS_F_IMPL_H
+
+#include <blocks/bin_statistics_f.h>
+#include <gr_feval.h>
+#include <gr_message.h>
+#include <gr_msg_queue.h>
+
+namespace gr {
+ namespace blocks {
+
+ class bin_statistics_f_impl : public bin_statistics_f
+ {
+ private:
+ enum state_t { ST_INIT, ST_TUNE_DELAY, ST_DWELL_DELAY };
+
+ size_t d_vlen;
+ gr_msg_queue_sptr d_msgq;
+ gr_feval_dd *d_tune;
+ size_t d_tune_delay;
+ size_t d_dwell_delay;
+ double d_center_freq;
+
+ state_t d_state;
+ size_t d_delay; // nsamples remaining to state transition
+
+ void enter_init();
+ void enter_tune_delay();
+ void enter_dwell_delay();
+ void leave_dwell_delay();
+
+ protected:
+ std::vector<float> d_max; // per bin maxima
+
+ size_t vlen() const { return d_vlen; }
+ double center_freq() const { return d_center_freq; }
+ gr_msg_queue_sptr msgq() const { return d_msgq; }
+
+ virtual void reset_stats();
+ virtual void accrue_stats(const float *input);
+ virtual void send_stats();
+
+ public:
+ bin_statistics_f_impl(unsigned int vlen,
+ gr_msg_queue_sptr msgq,
+ gr_feval_dd *tune,
+ size_t tune_delay,
+ size_t dwell_delay);
+ ~bin_statistics_f_impl();
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_GR_BIN_STATISTICS_F_IMPL_H */
diff --git a/gr-blocks/lib/burst_tagger_impl.cc b/gr-blocks/lib/burst_tagger_impl.cc
new file mode 100644
index 0000000000..5d0691bde6
--- /dev/null
+++ b/gr-blocks/lib/burst_tagger_impl.cc
@@ -0,0 +1,116 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2010,2013 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "burst_tagger_impl.h"
+#include <gr_io_signature.h>
+#include <string.h>
+
+namespace gr {
+ namespace blocks {
+
+ burst_tagger::sptr
+ burst_tagger::make(size_t itemsize)
+ {
+ return gnuradio::get_initial_sptr
+ (new burst_tagger_impl(itemsize));
+ }
+
+ burst_tagger_impl::burst_tagger_impl(size_t itemsize)
+ : gr_sync_block("burst_tagger",
+ gr_make_io_signature2(2, 2, itemsize, sizeof(short)),
+ gr_make_io_signature(1, 1, itemsize)),
+ d_itemsize(itemsize), d_state(false)
+ {
+ std::stringstream str;
+ str << name() << unique_id();
+
+ d_true_key = pmt::pmt_string_to_symbol("burst");
+ d_true_value = pmt::PMT_T;
+
+ d_false_key = pmt::pmt_string_to_symbol("burst");
+ d_false_value = pmt::PMT_F;
+
+ d_id = pmt::pmt_string_to_symbol(str.str());
+ }
+
+ burst_tagger_impl::~burst_tagger_impl()
+ {
+ }
+
+ void
+ burst_tagger_impl::set_true_tag(const std::string &key, bool value)
+ {
+ d_true_key = pmt::pmt_string_to_symbol(key);
+ if(value == true) {
+ d_true_value = pmt::PMT_T;
+ }
+ else {
+ d_true_value = pmt::PMT_F;
+ }
+ }
+
+ void
+ burst_tagger_impl::set_false_tag (const std::string &key, bool value)
+ {
+ d_false_key = pmt::pmt_string_to_symbol(key);
+ if(value == true) {
+ d_false_value = pmt::PMT_T;
+ }
+ else {
+ d_false_value = pmt::PMT_F;
+ }
+ }
+
+ int
+ burst_tagger_impl::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ const char *signal = (const char*)input_items[0];
+ const short *trigger = (const short*)input_items[1];
+ char *out = (char*)output_items[0];
+
+ memcpy(out, signal, noutput_items * d_itemsize);
+
+ for(int i = 0; i < noutput_items; i++) {
+ if(trigger[i] > 0) {
+ if(d_state == false) {
+ d_state = true;
+ add_item_tag(0, nitems_written(0)+i, d_true_key, d_true_value, d_id);
+ }
+ }
+ else {
+ if(d_state == true) {
+ d_state = false;
+ add_item_tag(0, nitems_written(0)+i, d_false_key, d_false_value, d_id);
+ }
+ }
+ }
+ return noutput_items;
+ }
+
+ } /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/burst_tagger_impl.h b/gr-blocks/lib/burst_tagger_impl.h
new file mode 100644
index 0000000000..80bdec12fb
--- /dev/null
+++ b/gr-blocks/lib/burst_tagger_impl.h
@@ -0,0 +1,59 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2010,2013 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_BURST_TAGGER_IMPL_H
+#define INCLUDED_GR_BURST_TAGGER_IMPL_H
+
+#include <blocks/burst_tagger.h>
+
+namespace gr {
+ namespace blocks {
+
+ class burst_tagger_impl : public burst_tagger
+ {
+ private:
+ size_t d_itemsize;
+ bool d_state;
+ pmt::pmt_t d_true_key;
+ pmt::pmt_t d_true_value;
+
+ pmt::pmt_t d_false_key;
+ pmt::pmt_t d_false_value;
+
+ pmt::pmt_t d_id;
+
+ public:
+ burst_tagger_impl(size_t itemsize);
+ ~burst_tagger_impl();
+
+ void set_true_tag(const std::string &key, bool value);
+ void set_false_tag(const std::string &key, bool value);
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_GR_BURST_TAGGER_IMPL_H */
diff --git a/gr-blocks/lib/check_lfsr_32k_s_impl.cc b/gr-blocks/lib/check_lfsr_32k_s_impl.cc
new file mode 100644
index 0000000000..b8e88003a2
--- /dev/null
+++ b/gr-blocks/lib/check_lfsr_32k_s_impl.cc
@@ -0,0 +1,179 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2010,2013 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "check_lfsr_32k_s_impl.h"
+#include <gr_io_signature.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+namespace gr {
+ namespace blocks {
+
+ check_lfsr_32k_s::sptr
+ check_lfsr_32k_s::make()
+ {
+ return gnuradio::get_initial_sptr
+ (new check_lfsr_32k_s_impl());
+ }
+
+ check_lfsr_32k_s_impl::check_lfsr_32k_s_impl()
+ : gr_sync_block("gr_check_lfsr_32k",
+ gr_make_io_signature(1, 1, sizeof(short)),
+ gr_make_io_signature(0, 0, 0)),
+ d_state(SEARCHING), d_history(0), d_ntotal(0), d_nright(0),
+ d_runlength(0), d_index(0)
+ {
+ lfsr_32k lfsr;
+
+ for(int i = 0; i < BUFSIZE; i++)
+ d_buffer[i] = lfsr.next_short();
+
+ enter_SEARCHING();
+ }
+
+ check_lfsr_32k_s_impl::~check_lfsr_32k_s_impl()
+ {
+ }
+
+ int
+ check_lfsr_32k_s_impl::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ unsigned short *in = (unsigned short*)input_items[0];
+
+ for(int i = 0; i < noutput_items; i++) {
+ unsigned short x = in[i];
+ unsigned short expected;
+
+ switch(d_state) {
+ case MATCH0:
+ if(x == d_buffer[0])
+ enter_MATCH1();
+ break;
+
+ case MATCH1:
+ if(x == d_buffer[1])
+ enter_MATCH2();
+ else
+ enter_MATCH0();
+ break;
+
+ case MATCH2:
+ if(x == d_buffer[2])
+ enter_LOCKED();
+ else
+ enter_MATCH0();
+ break;
+
+ case LOCKED:
+ expected = d_buffer[d_index];
+ d_index = d_index + 1;
+ if(d_index >= BUFSIZE)
+ d_index = 0;
+
+ if(x == expected)
+ right();
+ else {
+ wrong();
+ log_error(expected, x);
+ if(wrong_three_times())
+ enter_SEARCHING();
+ }
+ break;
+
+ default:
+ abort();
+ }
+
+ d_ntotal++;
+ }
+
+ return noutput_items;
+ }
+
+ void
+ check_lfsr_32k_s_impl::enter_SEARCHING()
+ {
+ d_state = SEARCHING;
+ wrong(); // reset history
+ wrong();
+ wrong();
+
+ d_runlength = 0;
+ d_index = 0; // reset LFSR to beginning
+
+ if(0)
+ fprintf(stdout, "gr_check_lfsr_32k: enter_SEARCHING at offset %8ld (0x%08lx)\n",
+ d_ntotal, d_ntotal);
+
+ enter_MATCH0();
+ }
+
+ void
+ check_lfsr_32k_s_impl::enter_MATCH0()
+ {
+ d_state = MATCH0;
+ }
+
+ void
+ check_lfsr_32k_s_impl::enter_MATCH1()
+ {
+ d_state = MATCH1;
+ }
+
+ void
+ check_lfsr_32k_s_impl::enter_MATCH2()
+ {
+ d_state = MATCH2;
+ }
+
+ void
+ check_lfsr_32k_s_impl::enter_LOCKED()
+ {
+ d_state = LOCKED;
+ right(); // setup history
+ right();
+ right();
+
+ d_index = 3; // already matched first 3 items
+
+ if(0)
+ fprintf(stdout, "gr_check_lfsr_32k: enter_LOCKED at offset %8ld (0x%08lx)\n",
+ d_ntotal, d_ntotal);
+ }
+
+ void
+ check_lfsr_32k_s_impl::log_error(unsigned short expected, unsigned short actual)
+ {
+ if(0)
+ fprintf(stdout,
+ "gr_check_lfsr_32k: expected %5d (0x%04x) got %5d (0x%04x) offset %8ld (0x%08lx)\n",
+ expected, expected, actual, actual, d_ntotal, d_ntotal);
+ }
+
+ } /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/check_lfsr_32k_s_impl.h b/gr-blocks/lib/check_lfsr_32k_s_impl.h
new file mode 100644
index 0000000000..f6d3c8daa2
--- /dev/null
+++ b/gr-blocks/lib/check_lfsr_32k_s_impl.h
@@ -0,0 +1,94 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2013 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_CHECK_LFSR_32K_S_IMPL_H
+#define INCLUDED_GR_CHECK_LFSR_32K_S_IMPL_H
+
+#include <blocks/check_lfsr_32k_s.h>
+#include <blocks/lfsr_32k.h>
+
+namespace gr {
+ namespace blocks {
+
+ class check_lfsr_32k_s_impl : public check_lfsr_32k_s
+ {
+ private:
+ enum state {
+ SEARCHING, // searching for synchronization
+ MATCH0,
+ MATCH1,
+ MATCH2,
+ LOCKED // is locked
+ };
+
+ state d_state;
+ unsigned int d_history; // bitmask of decisions
+
+ long d_ntotal; // total number of shorts
+ long d_nright; // # of correct shorts
+ long d_runlength; // # of correct shorts in a row
+
+ static const int BUFSIZE = 2048 - 1; // ensure pattern isn't packet aligned
+ int d_index;
+ unsigned short d_buffer[BUFSIZE];
+
+ void enter_SEARCHING();
+ void enter_MATCH0();
+ void enter_MATCH1();
+ void enter_MATCH2();
+ void enter_LOCKED();
+
+ void right()
+ {
+ d_history = (d_history << 1) | 0x1;
+ d_nright++;
+ d_runlength++;
+ }
+
+ void wrong()
+ {
+ d_history = (d_history << 1) | 0x0;
+ d_runlength = 0;
+ }
+
+ bool right_three_times() { return (d_history & 0x7) == 0x7; }
+ bool wrong_three_times() { return (d_history & 0x7) == 0x0; }
+
+ void log_error(unsigned short expected, unsigned short actual);
+
+ public:
+ check_lfsr_32k_s_impl();
+ ~check_lfsr_32k_s_impl();
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+
+ long ntotal() const { return d_ntotal; }
+ long nright() const { return d_nright; }
+ long runlength() const { return d_runlength; }
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_GR_CHECK_LFSR_32K_S_IMPL_H */
diff --git a/gr-blocks/lib/control_loop.cc b/gr-blocks/lib/control_loop.cc
new file mode 100644
index 0000000000..44f4e53394
--- /dev/null
+++ b/gr-blocks/lib/control_loop.cc
@@ -0,0 +1,214 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2011,2013 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <blocks/control_loop.h>
+#include <gr_math.h>
+#include <stdexcept>
+
+namespace gr {
+ namespace blocks {
+
+#define M_TWOPI (2.0f*M_PI)
+
+ control_loop::control_loop(float loop_bw,
+ float max_freq, float min_freq)
+ : d_phase(0), d_freq(0), d_max_freq(max_freq), d_min_freq(min_freq)
+ {
+ // Set the damping factor for a critically damped system
+ d_damping = sqrtf(2.0f)/2.0f;
+
+ // Set the bandwidth, which will then call update_gains()
+ set_loop_bandwidth(loop_bw);
+ }
+
+ control_loop::~control_loop()
+ {
+ }
+
+ void
+ control_loop::update_gains()
+ {
+ float denom = (1.0 + 2.0*d_damping*d_loop_bw + d_loop_bw*d_loop_bw);
+ d_alpha = (4*d_damping*d_loop_bw) / denom;
+ d_beta = (4*d_loop_bw*d_loop_bw) / denom;
+ }
+
+ void
+ control_loop::advance_loop(float error)
+ {
+ d_freq = d_freq + d_beta * error;
+ d_phase = d_phase + d_freq + d_alpha * error;
+ }
+
+ void
+ control_loop::phase_wrap()
+ {
+ while(d_phase>M_TWOPI)
+ d_phase -= M_TWOPI;
+ while(d_phase<-M_TWOPI)
+ d_phase += M_TWOPI;
+ }
+
+ void
+ control_loop::frequency_limit()
+ {
+ if(d_freq > d_max_freq)
+ d_freq = d_max_freq;
+ else if(d_freq < d_min_freq)
+ d_freq = d_min_freq;
+ }
+
+ /*******************************************************************
+ * SET FUNCTIONS
+ *******************************************************************/
+
+ void
+ control_loop::set_loop_bandwidth(float bw)
+ {
+ if(bw < 0) {
+ throw std::out_of_range ("control_loop: invalid bandwidth. Must be >= 0.");
+ }
+
+ d_loop_bw = bw;
+ update_gains();
+ }
+
+ void
+ control_loop::set_damping_factor(float df)
+ {
+ if(df < 0 || df > 1.0) {
+ throw std::out_of_range ("control_loop: invalid damping factor. Must be in [0,1].");
+ }
+
+ d_damping = df;
+ update_gains();
+ }
+
+ void
+ control_loop::set_alpha(float alpha)
+ {
+ if(alpha < 0 || alpha > 1.0) {
+ throw std::out_of_range ("control_loop: invalid alpha. Must be in [0,1].");
+ }
+ d_alpha = alpha;
+ }
+
+ void
+ control_loop::set_beta(float beta)
+ {
+ if(beta < 0 || beta > 1.0) {
+ throw std::out_of_range ("control_loop: invalid beta. Must be in [0,1].");
+ }
+ d_beta = beta;
+ }
+
+ void
+ control_loop::set_frequency(float freq)
+ {
+ if(freq > d_max_freq)
+ d_freq = d_min_freq;
+ else if(freq < d_min_freq)
+ d_freq = d_max_freq;
+ else
+ d_freq = freq;
+ }
+
+ void
+ control_loop::set_phase(float phase)
+ {
+ d_phase = phase;
+ while(d_phase>M_TWOPI)
+ d_phase -= M_TWOPI;
+ while(d_phase<-M_TWOPI)
+ d_phase += M_TWOPI;
+ }
+
+ void
+ control_loop::set_max_freq(float freq)
+ {
+ d_max_freq = freq;
+ }
+
+ void
+ control_loop::set_min_freq(float freq)
+ {
+ d_min_freq = freq;
+ }
+
+ /*******************************************************************
+ * GET FUNCTIONS
+ *******************************************************************/
+
+ float
+ control_loop::get_loop_bandwidth() const
+ {
+ return d_loop_bw;
+ }
+
+ float
+ control_loop::get_damping_factor() const
+ {
+ return d_damping;
+ }
+
+ float
+ control_loop::get_alpha() const
+ {
+ return d_alpha;
+ }
+
+ float
+ control_loop::get_beta() const
+ {
+ return d_beta;
+ }
+
+ float
+ control_loop::get_frequency() const
+ {
+ return d_freq;
+ }
+
+ float
+ control_loop::get_phase() const
+ {
+ return d_phase;
+ }
+
+ float
+ control_loop::get_max_freq() const
+ {
+ return d_max_freq;
+ }
+
+ float
+ control_loop::get_min_freq() const
+ {
+ return d_min_freq;
+ }
+
+ } /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/copy_impl.cc b/gr-blocks/lib/copy_impl.cc
new file mode 100644
index 0000000000..929f22b7d3
--- /dev/null
+++ b/gr-blocks/lib/copy_impl.cc
@@ -0,0 +1,91 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2006,2009,2013 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "copy_impl.h"
+#include <gr_io_signature.h>
+#include <string.h>
+
+namespace gr {
+ namespace blocks {
+
+ copy::sptr
+ copy::make(size_t itemsize)
+ {
+ return gnuradio::get_initial_sptr
+ (new copy_impl(itemsize));
+ }
+
+ copy_impl::copy_impl(size_t itemsize)
+ : gr_block("copy",
+ gr_make_io_signature(1, -1, itemsize),
+ gr_make_io_signature(1, -1, itemsize)),
+ d_itemsize(itemsize),
+ d_enabled(true)
+ {
+ }
+
+ copy_impl::~copy_impl()
+ {
+ }
+
+ void
+ copy_impl::forecast(int noutput_items, gr_vector_int &ninput_items_required)
+ {
+ unsigned ninputs = ninput_items_required.size();
+ for (unsigned i = 0; i < ninputs; i++)
+ ninput_items_required[i] = noutput_items;
+ }
+
+ bool
+ copy_impl::check_topology(int ninputs, int noutputs)
+ {
+ return ninputs == noutputs;
+ }
+
+ int
+ copy_impl::general_work(int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ const uint8_t **in = (const uint8_t**)&input_items[0];
+ uint8_t **out = (uint8_t**)&output_items[0];
+
+ int n = 0;
+ if(d_enabled) {
+ int ninputs = input_items.size();
+ for(int i = 0; i < ninputs; i++) {
+ memcpy(out[i], in[i], noutput_items*d_itemsize);
+ }
+ n = noutput_items;
+ }
+
+ consume_each(noutput_items);
+ return n;
+ }
+
+ } /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/copy_impl.h b/gr-blocks/lib/copy_impl.h
new file mode 100644
index 0000000000..1f0f1a655e
--- /dev/null
+++ b/gr-blocks/lib/copy_impl.h
@@ -0,0 +1,56 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2006,2009,2013 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_COPY_IMPL_H
+#define INCLUDED_GR_COPY_IMPL_H
+
+#include <blocks/copy.h>
+
+namespace gr {
+ namespace blocks {
+
+ class copy_impl : public copy
+ {
+ private:
+ size_t d_itemsize;
+ bool d_enabled;
+
+ public:
+ copy_impl(size_t itemsize);
+ ~copy_impl();
+
+ void forecast(int noutput_items, gr_vector_int &ninput_items_required);
+ bool check_topology(int ninputs, int noutputs);
+
+ void set_enabled(bool enable) { d_enabled = enable; }
+ bool enabled() const { return d_enabled;}
+
+ int general_work(int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_GR_COPY_IMPL_H */
diff --git a/gr-blocks/lib/endian_swap_impl.cc b/gr-blocks/lib/endian_swap_impl.cc
new file mode 100644
index 0000000000..7e67c30147
--- /dev/null
+++ b/gr-blocks/lib/endian_swap_impl.cc
@@ -0,0 +1,110 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2010,2012,2013 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "endian_swap_impl.h"
+#include <gr_io_signature.h>
+#include <volk/volk.h>
+
+namespace gr {
+ namespace blocks {
+
+ endian_swap::sptr
+ endian_swap::make(size_t item_size_bytes)
+ {
+ return gnuradio::get_initial_sptr
+ (new endian_swap_impl(item_size_bytes));
+ }
+
+ endian_swap_impl::endian_swap_impl (size_t item_size_bytes)
+ : gr_sync_block("endian_swap_impl",
+ gr_make_io_signature(1, 1, item_size_bytes),
+ gr_make_io_signature(1, 1, item_size_bytes))
+ {
+ const int alignment_multiple = volk_get_alignment();
+ set_alignment(std::max(1, alignment_multiple));
+ }
+
+ endian_swap_impl::~endian_swap_impl()
+ {
+ }
+
+ int
+ endian_swap_impl::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ const char *in = (const char*)input_items[0];
+ char *out = (char*)output_items[0];
+
+ int nbytes(output_signature()->sizeof_stream_item(0));
+ if(is_unaligned()) {
+ switch(nbytes){
+ case 1:
+ memcpy(out,in,noutput_items);
+ break;
+ case 2:
+ memcpy(out,in,2*noutput_items);
+ volk_16u_byteswap_u((uint16_t*)out,noutput_items);
+ break;
+ case 4:
+ memcpy(out,in,4*noutput_items);
+ volk_32u_byteswap_u((uint32_t*)out,noutput_items);
+ break;
+ case 8:
+ memcpy(out,in,8*noutput_items);
+ volk_64u_byteswap_u((uint64_t*)out,noutput_items);
+ break;
+ default:
+ throw std::runtime_error("itemsize is not valid for endian_swap!");
+ }
+ }
+ else {
+ switch(nbytes) {
+ case 1:
+ memcpy(out,in,noutput_items);
+ break;
+ case 2:
+ memcpy(out,in,2*noutput_items);
+ volk_16u_byteswap_a((uint16_t*)out,noutput_items);
+ break;
+ case 4:
+ memcpy(out,in,4*noutput_items);
+ volk_32u_byteswap_a((uint32_t*)out,noutput_items);
+ break;
+ case 8:
+ memcpy(out,in,8*noutput_items);
+ volk_64u_byteswap_a((uint64_t*)out,noutput_items);
+ break;
+ default:
+ throw std::runtime_error("itemsize is not valid for endian_swap!");
+ }
+ }
+
+ return noutput_items;
+ }
+
+ } /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/endian_swap_impl.h b/gr-blocks/lib/endian_swap_impl.h
new file mode 100644
index 0000000000..517df44f17
--- /dev/null
+++ b/gr-blocks/lib/endian_swap_impl.h
@@ -0,0 +1,48 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2012,2013 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_ENDIAN_SWAP_IMPL_H
+#define INCLUDED_GR_ENDIAN_SWAP_IMPL_H
+
+#include <blocks/endian_swap.h>
+
+namespace gr {
+ namespace blocks {
+
+ class endian_swap_impl : public endian_swap
+ {
+ private:
+ size_t item_size_bytes;
+
+ public:
+ endian_swap_impl(size_t item_size_bytes);
+ ~endian_swap_impl();
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_GR_ENDIAN_SWAP_IMPL_H */
diff --git a/gr-blocks/lib/file_descriptor_sink_impl.cc b/gr-blocks/lib/file_descriptor_sink_impl.cc
new file mode 100644
index 0000000000..a1f26220d2
--- /dev/null
+++ b/gr-blocks/lib/file_descriptor_sink_impl.cc
@@ -0,0 +1,94 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2010,2013 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "file_descriptor_sink_impl.h"
+#include <gr_io_signature.h>
+#include <cstdio>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <stdexcept>
+#include <stdio.h>
+
+#ifdef HAVE_IO_H
+#include <io.h>
+#endif
+
+namespace gr {
+ namespace blocks {
+
+ file_descriptor_sink::sptr
+ file_descriptor_sink::make(size_t itemsize, int fd)
+ {
+ return gnuradio::get_initial_sptr
+ (new file_descriptor_sink_impl(itemsize, fd));
+ }
+
+ file_descriptor_sink_impl::file_descriptor_sink_impl(size_t itemsize, int fd)
+ : gr_sync_block("file_descriptor_sink",
+ gr_make_io_signature(1, 1, itemsize),
+ gr_make_io_signature(0, 0, 0)),
+ d_itemsize(itemsize), d_fd(fd)
+ {
+ }
+
+ file_descriptor_sink_impl::~file_descriptor_sink_impl()
+ {
+ close(d_fd);
+ }
+
+ int
+ file_descriptor_sink_impl::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ char *inbuf = (char*)input_items[0];
+ unsigned long byte_size = noutput_items * d_itemsize;
+
+ while(byte_size > 0) {
+ ssize_t r;
+
+ r = write(d_fd, inbuf, byte_size);
+ if(r == -1) {
+ if(errno == EINTR)
+ continue;
+ else {
+ perror("file_descriptor_sink");
+ return -1; // indicate we're done
+ }
+ }
+ else {
+ byte_size -= r;
+ inbuf += r;
+ }
+ }
+
+ return noutput_items;
+ }
+
+ } /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/file_descriptor_sink_impl.h b/gr-blocks/lib/file_descriptor_sink_impl.h
new file mode 100644
index 0000000000..90b02f4163
--- /dev/null
+++ b/gr-blocks/lib/file_descriptor_sink_impl.h
@@ -0,0 +1,49 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2013 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_FILE_DESCRIPTOR_SINK_IMPL_H
+#define INCLUDED_GR_FILE_DESCRIPTOR_SINK_IMPL_H
+
+#include <blocks/file_descriptor_sink.h>
+
+namespace gr {
+ namespace blocks {
+
+ class file_descriptor_sink_impl : public file_descriptor_sink
+ {
+ private:
+ size_t d_itemsize;
+ int d_fd;
+
+ public:
+ file_descriptor_sink_impl(size_t itemsize, int fd);
+ ~file_descriptor_sink_impl();
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_GR_FILE_DESCRIPTOR_SINK_IMPL_H */
diff --git a/gr-blocks/lib/file_descriptor_source_impl.cc b/gr-blocks/lib/file_descriptor_source_impl.cc
new file mode 100644
index 0000000000..667e96b7fa
--- /dev/null
+++ b/gr-blocks/lib/file_descriptor_source_impl.cc
@@ -0,0 +1,156 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2005,2013 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "file_descriptor_source_impl.h"
+#include <gr_io_signature.h>
+#include <cstdio>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <stdexcept>
+#include <stdio.h>
+#include <string.h>
+
+#ifdef HAVE_IO_H
+#include <io.h>
+#endif
+
+namespace gr {
+ namespace blocks {
+
+ file_descriptor_source::sptr
+ file_descriptor_source::make(size_t itemsize, int fd, bool repeat)
+ {
+ return gnuradio::get_initial_sptr
+ (new file_descriptor_source_impl(itemsize, fd, repeat));
+ }
+
+ file_descriptor_source_impl::file_descriptor_source_impl(size_t itemsize,
+ int fd,
+ bool repeat)
+ : gr_sync_block("file_descriptor_source",
+ gr_make_io_signature(0, 0, 0),
+ gr_make_io_signature(1, 1, itemsize)),
+ d_itemsize(itemsize), d_fd(fd), d_repeat(repeat),
+ d_residue(new unsigned char[itemsize]), d_residue_len (0)
+ {
+ }
+
+ file_descriptor_source_impl::~file_descriptor_source_impl()
+ {
+ close(d_fd);
+ delete [] d_residue;
+ }
+
+ int
+ file_descriptor_source_impl::read_items(char *buf, int nitems)
+ {
+ assert(nitems > 0);
+ assert(d_residue_len < d_itemsize);
+
+ int nbytes_read = 0;
+
+ if(d_residue_len > 0) {
+ memcpy(buf, d_residue, d_residue_len);
+ nbytes_read = d_residue_len;
+ d_residue_len = 0;
+ }
+
+ int r = read(d_fd, buf + nbytes_read,
+ nitems * d_itemsize - nbytes_read);
+ if(r <= 0) {
+ handle_residue(buf, nbytes_read);
+ return r;
+ }
+
+ r = handle_residue(buf, r + nbytes_read);
+
+ if(r == 0) // block until we get something
+ return read_items(buf, nitems);
+
+ return r;
+ }
+
+ int
+ file_descriptor_source_impl::handle_residue(char *buf, int nbytes_read)
+ {
+ assert(nbytes_read >= 0);
+ int nitems_read = nbytes_read / d_itemsize;
+ d_residue_len = nbytes_read % d_itemsize;
+ if(d_residue_len > 0) {
+ // fprintf (stderr, "handle_residue: %d\n", d_residue_len);
+ memcpy(d_residue, buf + nbytes_read - d_residue_len, d_residue_len);
+ }
+ return nitems_read;
+ }
+
+ int
+ file_descriptor_source_impl::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ assert(noutput_items > 0);
+
+ char *o = (char*)output_items[0];
+ int nread = 0;
+
+ while(1) {
+ int r = read_items(o, noutput_items - nread);
+ if(r == -1) {
+ if(errno == EINTR)
+ continue;
+ else {
+ perror("file_descriptor_source[read]");
+ return -1;
+ }
+ }
+ else if(r == 0) { // end of file
+ if(!d_repeat)
+ break;
+ else {
+ flush_residue();
+ if(lseek(d_fd, 0, SEEK_SET) == -1) {
+ perror("file_descriptor_source[lseek]");
+ return -1;
+ }
+ }
+ }
+ else {
+ o += r * d_itemsize;
+ nread += r;
+ break;
+ }
+ }
+
+ if(nread == 0) // EOF
+ return -1;
+
+ return nread;
+ }
+
+ } /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/file_descriptor_source_impl.h b/gr-blocks/lib/file_descriptor_source_impl.h
new file mode 100644
index 0000000000..dd86e18af1
--- /dev/null
+++ b/gr-blocks/lib/file_descriptor_source_impl.h
@@ -0,0 +1,58 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2013 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_FILE_DESCRIPTOR_SOURCE_IMPL_H
+#define INCLUDED_GR_FILE_DESCRIPTOR_SOURCE_IMPL_H
+
+#include <blocks/file_descriptor_source.h>
+
+namespace gr {
+ namespace blocks {
+
+ class file_descriptor_source_impl : public file_descriptor_source
+ {
+ private:
+ size_t d_itemsize;
+ int d_fd;
+ bool d_repeat;
+
+ unsigned char *d_residue;
+ unsigned long d_residue_len;
+
+ protected:
+ int read_items(char *buf, int nitems);
+ int handle_residue(char *buf, int nbytes_read);
+ void flush_residue() { d_residue_len = 0; }
+
+ public:
+ file_descriptor_source_impl(size_t itemsize, int fd, bool repeat);
+ ~file_descriptor_source_impl();
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_GR_FILE_DESCRIPTOR_SOURCE_IMPL_H */
diff --git a/gr-blocks/lib/file_sink_base.cc b/gr-blocks/lib/file_sink_base.cc
new file mode 100644
index 0000000000..47c8f9882b
--- /dev/null
+++ b/gr-blocks/lib/file_sink_base.cc
@@ -0,0 +1,131 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2006,2007,2009,2013 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <blocks/file_sink_base.h>
+#include <cstdio>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <stdexcept>
+#include <stdio.h>
+#include <gruel/thread.h>
+
+// win32 (mingw/msvc) specific
+#ifdef HAVE_IO_H
+#include <io.h>
+#endif
+#ifdef O_BINARY
+#define OUR_O_BINARY O_BINARY
+#else
+#define OUR_O_BINARY 0
+#endif
+
+// should be handled via configure
+#ifdef O_LARGEFILE
+#define OUR_O_LARGEFILE O_LARGEFILE
+#else
+#define OUR_O_LARGEFILE 0
+#endif
+
+namespace gr {
+ namespace blocks {
+
+ file_sink_base::file_sink_base(const char *filename, bool is_binary)
+ : d_fp(0), d_new_fp(0), d_updated(false), d_is_binary(is_binary)
+ {
+ if (!open(filename))
+ throw std::runtime_error ("can't open file");
+ }
+
+ file_sink_base::~file_sink_base()
+ {
+ close();
+ if(d_fp) {
+ fclose(d_fp);
+ d_fp = 0;
+ }
+ }
+
+ bool
+ file_sink_base::open(const char *filename)
+ {
+ gruel::scoped_lock guard(d_mutex); // hold mutex for duration of this function
+
+ // we use the open system call to get access to the O_LARGEFILE flag.
+ int fd;
+ if((fd = ::open(filename,
+ O_WRONLY|O_CREAT|O_TRUNC|OUR_O_LARGEFILE|OUR_O_BINARY,
+ 0664)) < 0){
+ perror(filename);
+ return false;
+ }
+ if(d_new_fp) { // if we've already got a new one open, close it
+ fclose(d_new_fp);
+ d_new_fp = 0;
+ }
+
+ if((d_new_fp = fdopen (fd, d_is_binary ? "wb" : "w")) == NULL) {
+ perror (filename);
+ ::close(fd); // don't leak file descriptor if fdopen fails.
+ }
+
+ d_updated = true;
+ return d_new_fp != 0;
+ }
+
+ void
+ file_sink_base::close()
+ {
+ gruel::scoped_lock guard(d_mutex); // hold mutex for duration of this function
+
+ if(d_new_fp) {
+ fclose(d_new_fp);
+ d_new_fp = 0;
+ }
+ d_updated = true;
+ }
+
+ void
+ file_sink_base::do_update()
+ {
+ if(d_updated) {
+ gruel::scoped_lock guard(d_mutex); // hold mutex for duration of this block
+ if(d_fp)
+ fclose(d_fp);
+ d_fp = d_new_fp; // install new file pointer
+ d_new_fp = 0;
+ d_updated = false;
+ }
+ }
+
+ void
+ file_sink_base::set_unbuffered(bool unbuffered)
+ {
+ d_unbuffered = unbuffered;
+ }
+
+ } /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/file_sink_impl.cc b/gr-blocks/lib/file_sink_impl.cc
new file mode 100644
index 0000000000..88dcb5a021
--- /dev/null
+++ b/gr-blocks/lib/file_sink_impl.cc
@@ -0,0 +1,90 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2006,2007,2010,2013 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "file_sink_impl.h"
+#include <gr_io_signature.h>
+#include <stdexcept>
+
+namespace gr {
+ namespace blocks {
+
+ file_sink::sptr
+ file_sink::make(size_t itemsize, const char *filename)
+ {
+ return gnuradio::get_initial_sptr
+ (new file_sink_impl(itemsize, filename));
+ }
+
+ file_sink_impl::file_sink_impl(size_t itemsize, const char *filename)
+ : gr_sync_block("file_sink",
+ gr_make_io_signature(1, 1, itemsize),
+ gr_make_io_signature(0, 0, 0)),
+ file_sink_base(filename, true),
+ d_itemsize(itemsize)
+ {
+ }
+
+ file_sink_impl::~file_sink_impl()
+ {
+ }
+
+ int
+ file_sink_impl::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ char *inbuf = (char*)input_items[0];
+ int nwritten = 0;
+
+ do_update(); // update d_fp is reqd
+
+ if(!d_fp)
+ return noutput_items; // drop output on the floor
+
+ while(nwritten < noutput_items) {
+ int count = fwrite(inbuf, d_itemsize, noutput_items - nwritten, d_fp);
+ if(count == 0) {
+ if(ferror(d_fp)) {
+ std::stringstream s;
+ s << "file_sink write failed with error " << fileno(d_fp) << std::endl;
+ throw std::runtime_error(s.str());
+ }
+ else { // is EOF
+ break;
+ }
+ }
+ nwritten += count;
+ inbuf += count * d_itemsize;
+ }
+
+ if(d_unbuffered)
+ fflush (d_fp);
+
+ return nwritten;
+ }
+
+ } /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/file_sink_impl.h b/gr-blocks/lib/file_sink_impl.h
new file mode 100644
index 0000000000..8e802ad88a
--- /dev/null
+++ b/gr-blocks/lib/file_sink_impl.h
@@ -0,0 +1,48 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2007,2013 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_FILE_SINK_IMPL_H
+#define INCLUDED_GR_FILE_SINK_IMPL_H
+
+#include <blocks/file_sink.h>
+
+namespace gr {
+ namespace blocks {
+
+ class file_sink_impl : public file_sink
+ {
+ private:
+ size_t d_itemsize;
+
+ public:
+ file_sink_impl(size_t itemsize, const char *filename);
+ ~file_sink_impl();
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_GR_FILE_SINK_IMPL_H */
diff --git a/gr-blocks/lib/gen_sine_table.py b/gr-blocks/lib/gen_sine_table.py
new file mode 100755
index 0000000000..d7d11eff11
--- /dev/null
+++ b/gr-blocks/lib/gen_sine_table.py
@@ -0,0 +1,77 @@
+#!/usr/bin/env python
+#
+# Copyright 2004 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.
+#
+
+import math
+import sys
+
+def wrap (x):
+ if x >= 2**31:
+ return x - 2**32
+ return x
+
+def gen_approx_table (f, nentries, min_x, max_x):
+ """return a list of nentries containing tuples of the form:
+ (m, c, abs_error). min_x and max_x specify the domain
+ of the table.
+ """
+ r = []
+ incx = float (max_x - min_x) / nentries
+ for i in range (nentries):
+ a = (i * incx) + min_x
+ b = ((i + 1) * incx) + min_x
+ m = (f(b)-f(a))/(b-a)
+ c = (3*a+b)*(f(a)-f(b))/(4*(b-a)) + (f((a+b)/2) + f(a))/2
+ abs_error = c+m*a-f(a)
+ r.append ((m, c, abs_error))
+ return r
+
+def scaled_sine (x):
+ return math.sin (x * math.pi / 2**31)
+
+def gen_sine_table ():
+ nbits = 10
+ nentries = 2**nbits
+
+ # min_x = -2**31
+ # max_x = 2**31-1
+ min_x = 0
+ max_x = 2**32-1
+ t = gen_approx_table (scaled_sine, nentries, min_x, max_x)
+
+ max_error = 0
+ for e in t:
+ max_error = max (max_error, abs (e[2]))
+
+ # sys.stdout.write ('static const int WORDBITS = 32;\n')
+ # sys.stdout.write ('static const int NBITS = %d;\n' % (nbits,))
+
+ sys.stdout.write (' // max_error = %22.15e\n' % (max_error,))
+
+ # sys.stdout.write ('static const double sine_table[%d][2] = {\n'% (nentries,))
+
+ for e in t:
+ sys.stdout.write (' { %22.15e, %22.15e },\n' % (2 * e[0], e[1]))
+
+ # sys.stdout.write ('};\n')
+
+if __name__ == '__main__':
+ gen_sine_table ()
diff --git a/gr-blocks/lib/gnuradio-blocks.rc.in b/gr-blocks/lib/gnuradio-blocks.rc.in
new file mode 100644
index 0000000000..126db75091
--- /dev/null
+++ b/gr-blocks/lib/gnuradio-blocks.rc.in
@@ -0,0 +1,54 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2013 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.
+ */
+#include <afxres.h>
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@
+ PRODUCTVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@
+ FILEFLAGSMASK 0x3fL
+#ifndef NDEBUG
+ FILEFLAGS 0x0L
+#else
+ FILEFLAGS 0x1L
+#endif
+ FILEOS VOS__WINDOWS32
+ FILETYPE VFT_DLL
+ FILESUBTYPE VFT2_DRV_INSTALLABLE
+ BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904b0"
+ BEGIN
+ VALUE "FileDescription", "gnuradio-blocks"
+ VALUE "FileVersion", "@VERSION@"
+ VALUE "InternalName", "gnuradio-blocks.dll"
+ VALUE "LegalCopyright", "Licensed under GPLv3 or any later version"
+ VALUE "OriginalFilename", "gnuradio-blocks.dll"
+ VALUE "ProductName", "gnuradio-blocks"
+ VALUE "ProductVersion", "@VERSION@"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+ END
diff --git a/gr-blocks/lib/head_impl.cc b/gr-blocks/lib/head_impl.cc
new file mode 100644
index 0000000000..7dfa36607c
--- /dev/null
+++ b/gr-blocks/lib/head_impl.cc
@@ -0,0 +1,75 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2009,2013 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "head_impl.h"
+#include <gr_io_signature.h>
+#include <string.h>
+
+namespace gr {
+ namespace blocks {
+
+ head::sptr
+ head::make(size_t sizeof_stream_item, uint64_t nitems)
+ {
+ return gnuradio::get_initial_sptr
+ (new head_impl(sizeof_stream_item, nitems));
+ }
+
+ head_impl::head_impl(size_t sizeof_stream_item, uint64_t nitems)
+ : gr_sync_block("head",
+ gr_make_io_signature(1, 1, sizeof_stream_item),
+ gr_make_io_signature(1, 1, sizeof_stream_item)),
+ d_nitems(nitems), d_ncopied_items(0)
+ {
+ }
+
+ head_impl::~head_impl()
+ {
+ }
+
+ int
+ head_impl::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ if(d_ncopied_items >= d_nitems)
+ return -1; // Done!
+
+ unsigned n = std::min(d_nitems - d_ncopied_items,
+ (uint64_t)noutput_items);
+
+ if(n == 0)
+ return 0;
+
+ memcpy(output_items[0], input_items[0],
+ n * input_signature()->sizeof_stream_item (0));
+ d_ncopied_items += n;
+
+ return n;
+ }
+
+ } /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/head_impl.h b/gr-blocks/lib/head_impl.h
new file mode 100644
index 0000000000..a56acfbb27
--- /dev/null
+++ b/gr-blocks/lib/head_impl.h
@@ -0,0 +1,52 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2009,2012,2013 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_HEAD_IMPL_H
+#define INCLUDED_GR_HEAD_IMPL_H
+
+#include <blocks/head.h>
+
+namespace gr {
+ namespace blocks {
+
+ class head_impl : public head
+ {
+ private:
+ uint64_t d_nitems;
+ uint64_t d_ncopied_items;
+
+ public:
+ head_impl(size_t sizeof_stream_item, uint64_t nitems);
+ ~head_impl();
+
+ void reset() { d_ncopied_items = 0; }
+ void set_length(int nitems) { d_nitems = nitems; }
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_GR_HEAD_IMPL_H */
diff --git a/gr-blocks/lib/lfsr_32k_source_s_impl.cc b/gr-blocks/lib/lfsr_32k_source_s_impl.cc
new file mode 100644
index 0000000000..738e732b49
--- /dev/null
+++ b/gr-blocks/lib/lfsr_32k_source_s_impl.cc
@@ -0,0 +1,79 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2010,2013 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "lfsr_32k_source_s_impl.h"
+#include <gr_io_signature.h>
+#include <stdexcept>
+
+namespace gr {
+ namespace blocks {
+
+ lfsr_32k_source_s::sptr
+ lfsr_32k_source_s::make()
+ {
+ return gnuradio::get_initial_sptr
+ (new lfsr_32k_source_s_impl());
+ }
+
+ lfsr_32k_source_s_impl::lfsr_32k_source_s_impl()
+ : gr_sync_block("lfsr_32k_source_s",
+ gr_make_io_signature(0, 0, 0),
+ gr_make_io_signature(1, 1, sizeof(short))),
+ d_index(0)
+ {
+ lfsr_32k lfsr;
+
+ for(int i = 0; i < BUFSIZE; i++)
+ d_buffer[i] = lfsr.next_short();
+ }
+
+ lfsr_32k_source_s_impl::~lfsr_32k_source_s_impl()
+ {
+ }
+
+ int
+ lfsr_32k_source_s_impl::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ short *out = (short*)output_items[0];
+ short *buf = d_buffer;
+ int index = d_index;
+
+ for(int i = 0; i < noutput_items; i++) {
+ out[i] = buf[index];
+ // index = (index + 1) & (BUFSIZE - 1);
+ index = index + 1;
+ if(index >= BUFSIZE)
+ index = 0;
+ }
+
+ d_index = index;
+ return noutput_items;
+ }
+
+ } /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/lfsr_32k_source_s_impl.h b/gr-blocks/lib/lfsr_32k_source_s_impl.h
new file mode 100644
index 0000000000..b8c684e8d6
--- /dev/null
+++ b/gr-blocks/lib/lfsr_32k_source_s_impl.h
@@ -0,0 +1,52 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2013 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_LFSR_32K_SOURCE_S_IMPL_H
+#define INCLUDED_GR_LFSR_32K_SOURCE_S_IMPL_H
+
+#include <blocks/lfsr_32k_source_s.h>
+#include <blocks/lfsr_32k.h>
+#include <gr_sync_block.h>
+
+namespace gr {
+ namespace blocks {
+
+ class lfsr_32k_source_s_impl : public lfsr_32k_source_s
+ {
+ private:
+ static const int BUFSIZE = 2048 - 1; // ensure pattern isn't packet aligned
+ int d_index;
+ short d_buffer[BUFSIZE];
+
+ public:
+ lfsr_32k_source_s_impl();
+ ~lfsr_32k_source_s_impl();
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_GR_LFSR_32K_SOURCE_S_IMPL_H */
diff --git a/gr-blocks/lib/max_XX_impl.cc.t b/gr-blocks/lib/max_XX_impl.cc.t
new file mode 100644
index 0000000000..669e2fd30d
--- /dev/null
+++ b/gr-blocks/lib/max_XX_impl.cc.t
@@ -0,0 +1,81 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 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.
+ */
+
+// @WARNING@
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <@NAME_IMPL@.h>
+#include <gr_io_signature.h>
+
+namespace gr {
+ namespace blocks {
+
+ @NAME@::sptr
+ @NAME@::make(size_t vlen)
+ {
+ return gnuradio::get_initial_sptr
+ (new @NAME_IMPL@(vlen));
+ }
+
+ @NAME_IMPL@::@NAME_IMPL@(size_t vlen)
+ : gr_sync_block("@BASE_NAME@",
+ gr_make_io_signature(1, -1, vlen*sizeof(@I_TYPE@)),
+ gr_make_io_signature(1, 1, sizeof(@O_TYPE@))),
+ d_vlen(vlen)
+ {
+ }
+
+ @NAME_IMPL@::~@NAME_IMPL@()
+ {
+ }
+
+ int
+ @NAME_IMPL@::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ @O_TYPE@ *optr = (@O_TYPE@ *)output_items[0];
+
+ int ninputs = input_items.size();
+
+ for(int i = 0; i < noutput_items; i++) {
+ @I_TYPE@ max = ((@I_TYPE@ *)input_items[0])[i*d_vlen];
+
+ for(int j = 0; j < (int)d_vlen; j++ ) {
+ for(int k = 0; k < ninputs; k++) {
+ if(((@I_TYPE@ *)input_items[k])[i*d_vlen + j] > max) {
+ max = ((@I_TYPE@*)input_items[k])[i*d_vlen + j];
+ }
+ }
+ }
+
+ *optr++ = (@O_TYPE@)max;
+ }
+ return noutput_items;
+ }
+
+ } /* namespace blocks */
+} /* namespace gr */
+
diff --git a/gr-blocks/lib/max_XX_impl.h.t b/gr-blocks/lib/max_XX_impl.h.t
new file mode 100644
index 0000000000..0f1643f6b9
--- /dev/null
+++ b/gr-blocks/lib/max_XX_impl.h.t
@@ -0,0 +1,50 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007,2013 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.
+ */
+
+// @WARNING@
+
+#ifndef @GUARD_NAME_IMPL@
+#define @GUARD_NAME_IMPL@
+
+#include <blocks/@NAME@.h>
+
+namespace gr {
+ namespace blocks {
+
+ class @NAME_IMPL@ : public @NAME@
+ {
+ private:
+ size_t d_vlen;
+
+ public:
+ @NAME_IMPL@(size_t vlen);
+ ~@NAME_IMPL@();
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* @GUARD_NAME_IMPL@ */
diff --git a/gr-blocks/lib/message_burst_source_impl.cc b/gr-blocks/lib/message_burst_source_impl.cc
new file mode 100644
index 0000000000..f3c90eda31
--- /dev/null
+++ b/gr-blocks/lib/message_burst_source_impl.cc
@@ -0,0 +1,149 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2012-2013 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "message_burst_source_impl.h"
+#include <gr_io_signature.h>
+#include <cstdio>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <stdexcept>
+#include <string.h>
+#include <gr_tags.h>
+
+namespace gr {
+ namespace blocks {
+
+ message_burst_source::sptr
+ message_burst_source::make(size_t itemsize, int msgq_limit)
+ {
+ return gnuradio::get_initial_sptr
+ (new message_burst_source_impl(itemsize, msgq_limit));
+ }
+
+ message_burst_source::sptr
+ message_burst_source::make(size_t itemsize, gr_msg_queue_sptr msgq)
+ {
+ return gnuradio::get_initial_sptr
+ (new message_burst_source_impl(itemsize, msgq));
+ }
+
+ message_burst_source_impl::message_burst_source_impl(size_t itemsize, int msgq_limit)
+ : gr_sync_block("message_burst_source",
+ gr_make_io_signature(0, 0, 0),
+ gr_make_io_signature(1, 1, itemsize)),
+ d_itemsize(itemsize), d_msgq(gr_make_msg_queue(msgq_limit)),
+ d_msg_offset(0), d_eof(false)
+ {
+ std::stringstream id;
+ id << name() << unique_id();
+ d_me = pmt::pmt_string_to_symbol(id.str());
+ }
+
+ message_burst_source_impl::message_burst_source_impl(size_t itemsize, gr_msg_queue_sptr msgq)
+ : gr_sync_block("message_burst_source",
+ gr_make_io_signature(0, 0, 0),
+ gr_make_io_signature(1, 1, itemsize)),
+ d_itemsize(itemsize), d_msgq(msgq),
+ d_msg_offset(0), d_eof(false)
+ {
+ std::stringstream id;
+ id << name() << unique_id();
+ d_me = pmt::pmt_string_to_symbol(id.str());
+ }
+
+ message_burst_source_impl::~message_burst_source_impl()
+ {
+ }
+
+ int
+ message_burst_source_impl::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ char *out = (char*)output_items[0];
+ int nn = 0;
+
+ uint64_t abs_sample_count = nitems_written(0);
+
+ while(nn < noutput_items) {
+ if(d_msg) {
+ //
+ // Consume whatever we can from the current message
+ //
+
+ int mm = std::min(noutput_items - nn,
+ (int)((d_msg->length() - d_msg_offset) / d_itemsize));
+ memcpy(out, &(d_msg->msg()[d_msg_offset]), mm * d_itemsize);
+
+ nn += mm;
+ out += mm * d_itemsize;
+ d_msg_offset += mm * d_itemsize;
+ assert(d_msg_offset <= d_msg->length());
+
+ if(d_msg_offset == d_msg->length()) {
+ if(d_msg->type() == 1) // type == 1 sets EOF
+ d_eof = true;
+ d_msg.reset();
+ //tag end of burst
+ add_item_tag(0, //stream ID
+ abs_sample_count+nn-1, //sample number
+ pmt::pmt_string_to_symbol("tx_eob"),
+ pmt::pmt_from_bool(1),
+ d_me); //block src id
+ }
+ }
+ else {
+ //
+ // No current message
+ //
+ if(d_msgq->empty_p() && nn > 0) { // no more messages in the queue, return what we've got
+ break;
+ }
+
+ if(d_eof)
+ return -1;
+
+ d_msg = d_msgq->delete_head(); // block, waiting for a message
+ d_msg_offset = 0;
+ //tag start of burst
+ add_item_tag(0, //stream ID
+ abs_sample_count+nn, //sample number
+ pmt::pmt_string_to_symbol("tx_sob"),
+ pmt::pmt_from_bool(1),
+ d_me); //block src id
+
+ if((d_msg->length() % d_itemsize) != 0)
+ throw std::runtime_error("msg length is not a multiple of d_itemsize");
+ }
+ }
+
+ return nn;
+ }
+
+ } /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/message_burst_source_impl.h b/gr-blocks/lib/message_burst_source_impl.h
new file mode 100644
index 0000000000..2d5e6a974f
--- /dev/null
+++ b/gr-blocks/lib/message_burst_source_impl.h
@@ -0,0 +1,58 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2012-2013 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_MESSAGE_BURST_SOURCE_IMPL_H
+#define INCLUDED_GR_MESSAGE_BURST_SOURCE_IMPL_H
+
+#include <blocks/message_burst_source.h>
+#include <gr_message.h>
+
+namespace gr {
+ namespace blocks {
+
+ class message_burst_source_impl : public message_burst_source
+ {
+ private:
+ size_t d_itemsize;
+ gr_msg_queue_sptr d_msgq;
+ gr_message_sptr d_msg;
+ unsigned d_msg_offset;
+ bool d_eof;
+
+ pmt::pmt_t d_me;
+
+ public:
+ message_burst_source_impl(size_t itemsize, int msgq_limit);
+ message_burst_source_impl(size_t itemsize, gr_msg_queue_sptr msgq);
+ ~message_burst_source_impl();
+
+ gr_msg_queue_sptr msgq() const { return d_msgq; }
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_GR_MESSAGE_BURST_SOURCE_IMPL_H */
diff --git a/gr-blocks/lib/message_debug_impl.cc b/gr-blocks/lib/message_debug_impl.cc
new file mode 100644
index 0000000000..d7b1e5db09
--- /dev/null
+++ b/gr-blocks/lib/message_debug_impl.cc
@@ -0,0 +1,120 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2005,2010,2012-2013 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "message_debug_impl.h"
+#include <gr_io_signature.h>
+#include <cstdio>
+#include <iostream>
+
+namespace gr {
+ namespace blocks {
+
+ message_debug::sptr
+ message_debug::make()
+ {
+ return gnuradio::get_initial_sptr
+ (new message_debug_impl());
+ }
+
+ void
+ message_debug_impl::print(pmt::pmt_t msg)
+ {
+ std::cout << "******* MESSAGE DEBUG PRINT ********\n";
+ pmt::pmt_print(msg);
+ std::cout << "************************************\n";
+ }
+
+ void
+ message_debug_impl::store(pmt::pmt_t msg)
+ {
+ gruel::scoped_lock guard(d_mutex);
+ d_messages.push_back(msg);
+ }
+
+ void
+ message_debug_impl::print_pdu(pmt::pmt_t pdu)
+ {
+ pmt::pmt_t meta = pmt::pmt_car(pdu);
+ pmt::pmt_t vector = pmt::pmt_cdr(pdu);
+ std::cout << "* MESSAGE DEBUG PRINT PDU VERBOSE *\n";
+ pmt::pmt_print(meta);
+ size_t len = pmt::pmt_length(vector);
+ std::cout << "pdu_length = " << len << std::endl;
+ std::cout << "contents = " << std::endl;
+ size_t offset(0);
+ const uint8_t* d = (const uint8_t*) pmt_uniform_vector_elements(vector, offset);
+ for(size_t i=0; i<len; i+=16){
+ printf("%04x: ", ((unsigned int)i));
+ for(size_t j=i; j<std::min(i+16,len); j++){
+ printf("%02x ",d[j] );
+ }
+
+ std::cout << std::endl;
+ }
+
+ std::cout << "***********************************\n";
+ }
+
+ int
+ message_debug_impl::num_messages()
+ {
+ return (int)d_messages.size();
+ }
+
+ pmt::pmt_t
+ message_debug_impl::get_message(int i)
+ {
+ gruel::scoped_lock guard(d_mutex);
+
+ if((size_t)i >= d_messages.size()) {
+ throw std::runtime_error("message_debug: index for message out of bounds.\n");
+ }
+
+ return d_messages[i];
+ }
+
+ message_debug_impl::message_debug_impl()
+ : gr_block("message_debug",
+ gr_make_io_signature(0, 0, 0),
+ gr_make_io_signature(0, 0, 0))
+ {
+ message_port_register_in(pmt::mp("print"));
+ set_msg_handler(pmt::mp("print"), boost::bind(&message_debug_impl::print, this, _1));
+
+ message_port_register_in(pmt::mp("store"));
+ set_msg_handler(pmt::mp("store"), boost::bind(&message_debug_impl::store, this, _1));
+
+ message_port_register_in(pmt::mp("print_pdu"));
+ set_msg_handler(pmt::mp("print_pdu"), boost::bind(&message_debug_impl::print_pdu, this, _1));
+ }
+
+ message_debug_impl::~message_debug_impl()
+ {
+ }
+
+ } /* namespace blocks */
+} /* namespace gr */
+
diff --git a/gr-blocks/lib/message_debug_impl.h b/gr-blocks/lib/message_debug_impl.h
new file mode 100644
index 0000000000..c9d82bd561
--- /dev/null
+++ b/gr-blocks/lib/message_debug_impl.h
@@ -0,0 +1,89 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2005,2012-2013 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_MESSAGE_DEBUG_IMPL_H
+#define INCLUDED_GR_MESSAGE_DEBUG_IMPL_H
+
+#include <blocks/message_debug.h>
+#include <gr_block.h>
+#include <gruel/thread.h>
+#include <gruel/pmt.h>
+
+namespace gr {
+ namespace blocks {
+
+ class message_debug_impl : public message_debug
+ {
+ private:
+
+ /*!
+ * \brief Messages received in this port are printed to stdout.
+ *
+ * This port receives messages from the scheduler's message
+ * handling mechanism and prints it to stdout. This message
+ * handler function is only meant to be used by the scheduler to
+ * handle messages posted to port 'print'.
+ *
+ * \param msg A pmt message passed from the scheduler's message handling.
+ */
+ void print(pmt::pmt_t msg);
+
+ /*!
+ * \brief PDU formatted messages received in this port are printed to stdout.
+ *
+ * This port receives messages from the scheduler's message
+ * handling mechanism and prints it to stdout. This message
+ * handler function is only meant to be used by the scheduler to
+ * handle messages posted to port 'print'.
+ *
+ * \param pdu A PDU message passed from the scheduler's message handling.
+ */
+ void print_pdu(pmt::pmt_t pdu);
+
+ /*!
+ * \brief Messages received in this port are stored in a vector.
+ *
+ * This port receives messages from the scheduler's message
+ * handling mechanism and stores it in a vector. Messages can be
+ * retrieved later using the 'get_message' function. This
+ * message handler function is only meant to be used by the
+ * scheduler to handle messages posted to port 'store'.
+ *
+ * \param msg A pmt message passed from the scheduler's message handling.
+ */
+ void store(pmt::pmt_t msg);
+
+ gruel::mutex d_mutex;
+ std::vector<pmt::pmt_t> d_messages;
+
+ public:
+ message_debug_impl();
+ ~message_debug_impl();
+
+ int num_messages();
+ pmt::pmt_t get_message(int i);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_GR_MESSAGE_DEBUG_IMPL_H */
diff --git a/gr-blocks/lib/message_sink_impl.cc b/gr-blocks/lib/message_sink_impl.cc
new file mode 100644
index 0000000000..a8dbfb4c71
--- /dev/null
+++ b/gr-blocks/lib/message_sink_impl.cc
@@ -0,0 +1,83 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2005,2010,2013 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "message_sink_impl.h"
+#include <gr_io_signature.h>
+#include <cstdio>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <stdexcept>
+#include <string.h>
+
+namespace gr {
+ namespace blocks {
+
+ message_sink::sptr
+ message_sink::make(size_t itemsize, gr_msg_queue_sptr msgq, bool dont_block)
+ {
+ return gnuradio::get_initial_sptr
+ (new message_sink_impl(itemsize, msgq, dont_block));
+ }
+
+ message_sink_impl::message_sink_impl(size_t itemsize, gr_msg_queue_sptr msgq, bool dont_block)
+ : gr_sync_block("message_sink",
+ gr_make_io_signature(1, 1, itemsize),
+ gr_make_io_signature(0, 0, 0)),
+ d_itemsize(itemsize), d_msgq(msgq), d_dont_block(dont_block)
+ {
+ }
+
+ message_sink_impl::~message_sink_impl()
+ {
+ }
+
+ int
+ message_sink_impl::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ const char *in = (const char*)input_items[0];
+
+ // if we'd block, drop the data on the floor and say everything is OK
+ if(d_dont_block && d_msgq->full_p())
+ return noutput_items;
+
+ // build a message to hold whatever we've got
+ gr_message_sptr msg = gr_make_message(0, // msg type
+ d_itemsize, // arg1 for other end
+ noutput_items, // arg2 for other end (redundant)
+ noutput_items * d_itemsize); // len of msg
+ memcpy(msg->msg(), in, noutput_items * d_itemsize);
+
+ d_msgq->handle(msg); // send it
+
+ return noutput_items;
+ }
+
+ } /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/message_sink_impl.h b/gr-blocks/lib/message_sink_impl.h
new file mode 100644
index 0000000000..a3106bc058
--- /dev/null
+++ b/gr-blocks/lib/message_sink_impl.h
@@ -0,0 +1,50 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2005,2013 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_MESSAGE_SINK_IMPL_H
+#define INCLUDED_GR_MESSAGE_SINK_IMPL_H
+
+#include <blocks/message_sink.h>
+
+namespace gr {
+ namespace blocks {
+
+ class message_sink_impl : public message_sink
+ {
+ private:
+ size_t d_itemsize;
+ gr_msg_queue_sptr d_msgq;
+ bool d_dont_block;
+
+ public:
+ message_sink_impl(size_t itemsize, gr_msg_queue_sptr msgq, bool dont_block);
+ ~message_sink_impl();
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_GR_MESSAGE_SINK_IMPL_H */
diff --git a/gr-blocks/lib/message_source_impl.cc b/gr-blocks/lib/message_source_impl.cc
new file mode 100644
index 0000000000..cda4fc16c0
--- /dev/null
+++ b/gr-blocks/lib/message_source_impl.cc
@@ -0,0 +1,127 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2005,2010,2013 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "message_source_impl.h"
+#include <gr_io_signature.h>
+#include <cstdio>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <stdexcept>
+#include <string.h>
+
+namespace gr {
+ namespace blocks {
+
+ message_source::sptr
+ message_source::make(size_t itemsize, int msgq_limit)
+ {
+ return gnuradio::get_initial_sptr
+ (new message_source_impl(itemsize, msgq_limit));
+ }
+
+ message_source::sptr
+ message_source::make(size_t itemsize, gr_msg_queue_sptr msgq)
+ {
+ return gnuradio::get_initial_sptr
+ (new message_source_impl(itemsize, msgq));
+ }
+
+ message_source_impl::message_source_impl(size_t itemsize, int msgq_limit)
+ : gr_sync_block("message_source",
+ gr_make_io_signature(0, 0, 0),
+ gr_make_io_signature(1, 1, itemsize)),
+ d_itemsize(itemsize), d_msgq(gr_make_msg_queue(msgq_limit)),
+ d_msg_offset(0), d_eof(false)
+ {
+ }
+
+ message_source_impl::message_source_impl(size_t itemsize, gr_msg_queue_sptr msgq)
+ : gr_sync_block("message_source",
+ gr_make_io_signature(0, 0, 0),
+ gr_make_io_signature(1, 1, itemsize)),
+ d_itemsize(itemsize), d_msgq(msgq),
+ d_msg_offset(0), d_eof(false)
+ {
+ }
+
+ message_source_impl::~message_source_impl()
+ {
+ }
+
+ int
+ message_source_impl::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ char *out = (char*)output_items[0];
+ int nn = 0;
+
+ while(nn < noutput_items) {
+ if(d_msg) {
+ //
+ // Consume whatever we can from the current message
+ //
+ int mm = std::min(noutput_items - nn,
+ (int)((d_msg->length() - d_msg_offset) / d_itemsize));
+ memcpy(out, &(d_msg->msg()[d_msg_offset]), mm * d_itemsize);
+
+ nn += mm;
+ out += mm * d_itemsize;
+ d_msg_offset += mm * d_itemsize;
+ assert(d_msg_offset <= d_msg->length());
+
+ if(d_msg_offset == d_msg->length()) {
+ if(d_msg->type() == 1) // type == 1 sets EOF
+ d_eof = true;
+ d_msg.reset();
+ }
+ }
+ else {
+ //
+ // No current message
+ //
+ if(d_msgq->empty_p() && nn > 0) { // no more messages in the queue, return what we've got
+ break;
+ }
+
+ if(d_eof)
+ return -1;
+
+ d_msg = d_msgq->delete_head(); // block, waiting for a message
+ d_msg_offset = 0;
+
+ if((d_msg->length() % d_itemsize) != 0)
+ throw std::runtime_error("msg length is not a multiple of d_itemsize");
+ }
+ }
+
+ return nn;
+ }
+
+ } /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/message_source_impl.h b/gr-blocks/lib/message_source_impl.h
new file mode 100644
index 0000000000..c420704478
--- /dev/null
+++ b/gr-blocks/lib/message_source_impl.h
@@ -0,0 +1,56 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2005,2013 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_MESSAGE_SOURCE_IMPL_H
+#define INCLUDED_GR_MESSAGE_SOURCE_IMPL_H
+
+#include <blocks/message_source.h>
+#include <gr_message.h>
+
+namespace gr {
+ namespace blocks {
+
+ class message_source_impl : public message_source
+ {
+ private:
+ size_t d_itemsize;
+ gr_msg_queue_sptr d_msgq;
+ gr_message_sptr d_msg;
+ unsigned d_msg_offset;
+ bool d_eof;
+
+ public:
+ message_source_impl(size_t itemsize, int msgq_limit);
+ message_source_impl(size_t itemsize, gr_msg_queue_sptr msgq);
+ ~message_source_impl();
+
+ gr_msg_queue_sptr msgq() const { return d_msgq; }
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_GR_MESSAGE_SOURCE_IMPL_H */
diff --git a/gr-blocks/lib/message_strobe_impl.cc b/gr-blocks/lib/message_strobe_impl.cc
new file mode 100644
index 0000000000..c4b0e5d567
--- /dev/null
+++ b/gr-blocks/lib/message_strobe_impl.cc
@@ -0,0 +1,85 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2012-2013 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "message_strobe_impl.h"
+#include <gr_io_signature.h>
+#include <cstdio>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <stdexcept>
+#include <string.h>
+#include <iostream>
+
+namespace gr {
+ namespace blocks {
+
+ message_strobe::sptr
+ message_strobe::make(pmt::pmt_t msg, float period_ms)
+ {
+ return gnuradio::get_initial_sptr
+ (new message_strobe_impl(msg, period_ms));
+ }
+
+ message_strobe_impl::message_strobe_impl(pmt::pmt_t msg, float period_ms)
+ : gr_block("message_strobe",
+ gr_make_io_signature(0, 0, 0),
+ gr_make_io_signature(0, 0, 0)),
+ d_finished(false),
+ d_period_ms(period_ms),
+ d_msg(msg)
+ {
+ message_port_register_out(pmt::mp("strobe"));
+ d_thread = boost::shared_ptr<boost::thread>
+ (new boost::thread(boost::bind(&message_strobe_impl::run, this)));
+
+ message_port_register_in(pmt::mp("set_msg"));
+ set_msg_handler(pmt::mp("set_msg"),
+ boost::bind(&message_strobe_impl::set_msg, this, _1));
+ }
+
+ message_strobe_impl::~message_strobe_impl()
+ {
+ d_finished = true;
+ d_thread->interrupt();
+ d_thread->join();
+ }
+
+ void message_strobe_impl::run()
+ {
+ while(!d_finished) {
+ boost::this_thread::sleep(boost::posix_time::milliseconds(d_period_ms));
+ if(d_finished) {
+ return;
+ }
+
+ message_port_pub(pmt::mp("strobe"), d_msg);
+ }
+ }
+
+ } /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/message_strobe_impl.h b/gr-blocks/lib/message_strobe_impl.h
new file mode 100644
index 0000000000..1b2edae593
--- /dev/null
+++ b/gr-blocks/lib/message_strobe_impl.h
@@ -0,0 +1,54 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2012-2013 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_MESSAGE_STROBE_IMPL_H
+#define INCLUDED_GR_MESSAGE_STROBE_IMPL_H
+
+#include <blocks/message_strobe.h>
+
+namespace gr {
+ namespace blocks {
+
+ class BLOCKS_API message_strobe_impl : public message_strobe
+ {
+ private:
+ boost::shared_ptr<boost::thread> d_thread;
+ bool d_finished;
+ float d_period_ms;
+ pmt::pmt_t d_msg;
+
+ void run();
+
+ public:
+ message_strobe_impl(pmt::pmt_t msg, float period_ms);
+ ~message_strobe_impl();
+
+ void set_msg(pmt::pmt_t msg) { d_msg = msg; }
+ pmt::pmt_t msg() const { return d_msg; }
+ void set_period(float period_ms) { d_period_ms = period_ms; }
+ float period() const { return d_period_ms; }
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_GR_MESSAGE_STROBE_IMPL_H */
diff --git a/gr-blocks/lib/moving_average_XX_impl.cc.t b/gr-blocks/lib/moving_average_XX_impl.cc.t
new file mode 100644
index 0000000000..566deff116
--- /dev/null
+++ b/gr-blocks/lib/moving_average_XX_impl.cc.t
@@ -0,0 +1,114 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008,2010,2013 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.
+ */
+
+// @WARNING@
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "@NAME_IMPL@.h"
+#include <gr_io_signature.h>
+
+namespace gr {
+ namespace blocks {
+
+ @NAME@::sptr
+ @NAME@::make(int length, @O_TYPE@ scale, int max_iter)
+ {
+ return gnuradio::get_initial_sptr
+ (new @NAME_IMPL@(length, scale, max_iter));
+ }
+
+ @NAME_IMPL@::@NAME_IMPL@(int length, @O_TYPE@ scale, int max_iter)
+ : gr_sync_block("@NAME@",
+ gr_make_io_signature(1, 1, sizeof(@I_TYPE@)),
+ gr_make_io_signature(1, 1, sizeof(@O_TYPE@))),
+ d_length(length),
+ d_scale(scale),
+ d_max_iter(max_iter),
+ d_new_length(length),
+ d_new_scale(scale),
+ d_updated(false)
+ {
+ set_history(length);
+ }
+
+ @NAME_IMPL@::~@NAME_IMPL@()
+ {
+ }
+
+ void
+ @NAME_IMPL@::set_length_and_scale(int length, @O_TYPE@ scale)
+ {
+ d_new_length = length;
+ d_new_scale = scale;
+ d_updated = true;
+ }
+
+ void
+ @NAME_IMPL@::set_length(int length)
+ {
+ d_new_length = length;
+ d_updated = true;
+ }
+
+ void
+ @NAME_IMPL@::set_scale(@O_TYPE@ scale)
+ {
+ d_new_scale = scale;
+ d_updated = true;
+ }
+
+ int
+ @NAME_IMPL@::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ if(d_updated) {
+ d_length = d_new_length;
+ d_scale = d_new_scale;
+ set_history(d_length);
+ d_updated = false;
+ return 0; // history requirements might have changed
+ }
+
+ const @I_TYPE@ *in = (const @I_TYPE@ *)input_items[0];
+ @O_TYPE@ *out = (@O_TYPE@ *)output_items[0];
+
+ @I_TYPE@ sum = 0;
+ int num_iter = (noutput_items>d_max_iter) ? d_max_iter : noutput_items;
+ for(int i = 0; i < d_length-1; i++) {
+ sum += in[i];
+ }
+
+ for(int i = 0; i < num_iter; i++) {
+ sum += in[i+d_length-1];
+ out[i] = sum * d_scale;
+ sum -= in[i];
+ }
+
+ return num_iter;
+ }
+
+ } /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/moving_average_XX_impl.h.t b/gr-blocks/lib/moving_average_XX_impl.h.t
new file mode 100644
index 0000000000..7234cbe139
--- /dev/null
+++ b/gr-blocks/lib/moving_average_XX_impl.h.t
@@ -0,0 +1,65 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008,2013 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.
+ */
+
+// @WARNING@
+
+#ifndef @GUARD_NAME_IMPL@
+#define @GUARD_NAME_IMPL@
+
+#include <blocks/@NAME@.h>
+
+namespace gr {
+ namespace blocks {
+
+ class @NAME_IMPL@ : public @NAME@
+ {
+ private:
+ int d_length;
+ @O_TYPE@ d_scale;
+ int d_max_iter;
+
+ int d_new_length;
+ @O_TYPE@ d_new_scale;
+ bool d_updated;
+
+ public:
+ @NAME_IMPL@(int length, @O_TYPE@ scale,
+ int max_iter = 4096);
+ ~@NAME_IMPL@();
+
+ int length() const { return d_new_length; }
+ @O_TYPE@ scale() const { return d_new_scale; }
+
+ void set_length_and_scale(int length, @O_TYPE@ scale);
+ void set_length(int length);
+ void set_scale(@O_TYPE@ scale);
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* @GUARD_NAME_IMPL@ */
diff --git a/gr-blocks/lib/mute_XX_impl.cc.t b/gr-blocks/lib/mute_XX_impl.cc.t
new file mode 100644
index 0000000000..b29e9edada
--- /dev/null
+++ b/gr-blocks/lib/mute_XX_impl.cc.t
@@ -0,0 +1,89 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2010,2013 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.
+ */
+
+// @WARNING@
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <@NAME_IMPL@.h>
+#include <gr_io_signature.h>
+#include <string.h>
+
+namespace gr {
+ namespace blocks {
+
+ @NAME@::sptr
+ @NAME@::make(bool mute)
+ {
+ return gnuradio::get_initial_sptr
+ (new @NAME_IMPL@(mute));
+ }
+
+ @NAME_IMPL@::@NAME_IMPL@(bool mute)
+ : gr_sync_block("@BASE_NAME@",
+ gr_make_io_signature(1, 1, sizeof(@I_TYPE@)),
+ gr_make_io_signature(1, 1, sizeof(@O_TYPE@))),
+ d_mute(mute)
+ {
+ }
+
+ @NAME_IMPL@::~@NAME_IMPL@()
+ {
+ }
+
+ int
+ @NAME_IMPL@::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ @I_TYPE@ *iptr = (@I_TYPE@ *)input_items[0];
+ @O_TYPE@ *optr = (@O_TYPE@ *)output_items[0];
+
+ int size = noutput_items;
+
+ if(d_mute) {
+ memset(optr, 0, noutput_items * sizeof(@O_TYPE@));
+ }
+ else {
+ while(size >= 8) {
+ *optr++ = *iptr++;
+ *optr++ = *iptr++;
+ *optr++ = *iptr++;
+ *optr++ = *iptr++;
+ *optr++ = *iptr++;
+ *optr++ = *iptr++;
+ *optr++ = *iptr++;
+ *optr++ = *iptr++;
+ size -= 8;
+ }
+
+ while(size-- > 0)
+ *optr++ = *iptr++;
+ }
+
+ return noutput_items;
+ }
+
+ } /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/mute_XX_impl.h.t b/gr-blocks/lib/mute_XX_impl.h.t
new file mode 100644
index 0000000000..de93c8eb82
--- /dev/null
+++ b/gr-blocks/lib/mute_XX_impl.h.t
@@ -0,0 +1,53 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2013 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.
+ */
+
+// @WARNING@
+
+#ifndef @GUARD_NAME_IMPL@
+#define @GUARD_NAME_IMPL@
+
+#include <blocks/@NAME@.h>
+
+namespace gr {
+ namespace blocks {
+
+ class @NAME_IMPL@ : public @NAME@
+ {
+ private:
+ bool d_mute;
+
+ public:
+ @NAME_IMPL@(bool mute);
+ ~@NAME_IMPL@();
+
+ bool mute() const { return d_mute; }
+ void set_mute(bool mute) { d_mute = mute; }
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* @GUARD_NAME_IMPL@ */
diff --git a/gr-blocks/lib/nop_impl.cc b/gr-blocks/lib/nop_impl.cc
new file mode 100644
index 0000000000..766f07e2b8
--- /dev/null
+++ b/gr-blocks/lib/nop_impl.cc
@@ -0,0 +1,78 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2010,2013 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "nop_impl.h"
+#include <gr_io_signature.h>
+#include <boost/bind.hpp>
+
+namespace gr {
+ namespace blocks {
+
+ nop::sptr
+ nop::make(size_t sizeof_stream_item)
+ {
+ return gnuradio::get_initial_sptr
+ (new nop_impl(sizeof_stream_item));
+ }
+
+ nop_impl::nop_impl (size_t sizeof_stream_item)
+ : gr_block("nop",
+ gr_make_io_signature(0, -1, sizeof_stream_item),
+ gr_make_io_signature(0, -1, sizeof_stream_item)),
+ d_nmsgs_recvd(0)
+ {
+ // Arrange to have count_received_msgs called when messages are received.
+ message_port_register_in(pmt::mp("port"));
+ set_msg_handler(pmt::mp("port"), boost::bind(&nop_impl::count_received_msgs, this, _1));
+ }
+
+ nop_impl::~nop_impl()
+ {
+ }
+
+ // Trivial message handler that just counts them.
+ // (N.B., This feature is used in qa_set_msg_handler)
+ void
+ nop_impl::count_received_msgs(pmt::pmt_t msg)
+ {
+ d_nmsgs_recvd++;
+ }
+
+ int
+ nop_impl::general_work(int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ // eat any input that's available
+ for(unsigned i = 0; i < ninput_items.size (); i++)
+ consume(i, ninput_items[i]);
+
+ return noutput_items;
+ }
+
+ } /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/nop_impl.h b/gr-blocks/lib/nop_impl.h
new file mode 100644
index 0000000000..b236abb7aa
--- /dev/null
+++ b/gr-blocks/lib/nop_impl.h
@@ -0,0 +1,54 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2010,2013 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_NOP_IMPL_H
+#define INCLUDED_GR_NOP_IMPL_H
+
+#include <blocks/nop.h>
+
+namespace gr {
+ namespace blocks {
+
+ class nop_impl : public nop
+ {
+ protected:
+ int d_nmsgs_recvd;
+
+ // Method that just counts any received messages.
+ void count_received_msgs(pmt::pmt_t msg);
+
+ public:
+ nop_impl(size_t sizeof_stream_item);
+ ~nop_impl();
+
+ int nmsgs_received() const { return d_nmsgs_recvd; }
+
+ int general_work(int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_GR_NOP_IMPL_H */
diff --git a/gr-blocks/lib/null_sink_impl.cc b/gr-blocks/lib/null_sink_impl.cc
new file mode 100644
index 0000000000..b780a2405a
--- /dev/null
+++ b/gr-blocks/lib/null_sink_impl.cc
@@ -0,0 +1,60 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2010,2013 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "null_sink_impl.h"
+#include <gr_io_signature.h>
+
+namespace gr {
+ namespace blocks {
+
+ null_sink::sptr
+ null_sink::make(size_t sizeof_stream_item)
+ {
+ return gnuradio::get_initial_sptr
+ (new null_sink_impl(sizeof_stream_item));
+ }
+
+ null_sink_impl::null_sink_impl(size_t sizeof_stream_item)
+ : gr_sync_block("null_sink",
+ gr_make_io_signature(1, 1, sizeof_stream_item),
+ gr_make_io_signature(0, 0, 0))
+ {
+ }
+
+ null_sink_impl::~null_sink_impl()
+ {
+ }
+
+ int
+ null_sink_impl::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ return noutput_items;
+ }
+
+ } /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/null_sink_impl.h b/gr-blocks/lib/null_sink_impl.h
new file mode 100644
index 0000000000..bb4c695c23
--- /dev/null
+++ b/gr-blocks/lib/null_sink_impl.h
@@ -0,0 +1,45 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2010,2013 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_NULL_SINK_IMPL_H
+#define INCLUDED_GR_NULL_SINK_IMPL_H
+
+#include <blocks/null_sink.h>
+
+namespace gr {
+ namespace blocks {
+
+ class null_sink_impl : public null_sink
+ {
+ public:
+ null_sink_impl(size_t sizeof_stream_item);
+ ~null_sink_impl();
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_GR_NULL_SINK_IMPL_H */
diff --git a/gr-blocks/lib/null_source_impl.cc b/gr-blocks/lib/null_source_impl.cc
new file mode 100644
index 0000000000..81999d0501
--- /dev/null
+++ b/gr-blocks/lib/null_source_impl.cc
@@ -0,0 +1,63 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2010,2013 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "null_source_impl.h"
+#include <gr_io_signature.h>
+#include <string.h>
+
+namespace gr {
+ namespace blocks {
+
+ null_source::sptr
+ null_source::make(size_t sizeof_stream_item)
+ {
+ return gnuradio::get_initial_sptr
+ (new null_source_impl(sizeof_stream_item));
+ }
+
+ null_source_impl::null_source_impl (size_t sizeof_stream_item)
+ : gr_sync_block("null_source",
+ gr_make_io_signature(0, 0, 0),
+ gr_make_io_signature(1, 1, sizeof_stream_item))
+ {
+ }
+
+ null_source_impl::~null_source_impl()
+ {
+ }
+
+ int
+ null_source_impl::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ void *optr = (void*)output_items[0];
+ memset(optr, 0, noutput_items * output_signature()->sizeof_stream_item(0));
+ return noutput_items;
+ }
+
+ } /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/null_source_impl.h b/gr-blocks/lib/null_source_impl.h
new file mode 100644
index 0000000000..36201d54b6
--- /dev/null
+++ b/gr-blocks/lib/null_source_impl.h
@@ -0,0 +1,45 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2010,2013 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_NULL_SOURCE_IMPL_H
+#define INCLUDED_GR_NULL_SOURCE_IMPL_H
+
+#include <blocks/null_source.h>
+
+namespace gr {
+ namespace blocks {
+
+ class null_source_impl : public null_source
+ {
+ public:
+ null_source_impl(size_t sizeof_stream_item);
+ ~null_source_impl();
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_GR_NULL_SOURCE_IMPL_H */
diff --git a/gr-blocks/lib/pack_k_bits_bb_impl.cc b/gr-blocks/lib/pack_k_bits_bb_impl.cc
new file mode 100644
index 0000000000..2a7fcc04cb
--- /dev/null
+++ b/gr-blocks/lib/pack_k_bits_bb_impl.cc
@@ -0,0 +1,76 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2012-2013 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.
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "pack_k_bits_bb_impl.h"
+#include <gr_io_signature.h>
+#include <stdexcept>
+#include <iostream>
+
+namespace gr {
+ namespace blocks {
+
+ pack_k_bits_bb::sptr
+ pack_k_bits_bb::make(unsigned k)
+ {
+ return gnuradio::get_initial_sptr
+ (new pack_k_bits_bb_impl(k));
+ }
+
+ pack_k_bits_bb_impl::pack_k_bits_bb_impl(unsigned k)
+ : gr_sync_decimator("pack_k_bits_bb",
+ gr_make_io_signature(1, 1, sizeof(unsigned char)),
+ gr_make_io_signature(1, 1, sizeof(unsigned char)),
+ k),
+ d_k(k)
+ {
+ if(d_k == 0)
+ throw std::out_of_range("interpolation must be > 0");
+ }
+
+ pack_k_bits_bb_impl::~pack_k_bits_bb_impl()
+ {
+ }
+
+ int
+ pack_k_bits_bb_impl::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ const unsigned char *in = (const unsigned char *)input_items[0];
+ unsigned char *out = (unsigned char *)output_items[0];
+
+ for(int i = 0; i < noutput_items; i++) {
+ out[i] = 0x00;
+ for(unsigned int j = 0; j < d_k; j++) {
+ out[i] |= (0x01 & in[i*d_k+j])<<(d_k-j-1);
+ }
+ }
+
+ return noutput_items;
+ }
+
+ } /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/pack_k_bits_bb_impl.h b/gr-blocks/lib/pack_k_bits_bb_impl.h
new file mode 100644
index 0000000000..668d438a46
--- /dev/null
+++ b/gr-blocks/lib/pack_k_bits_bb_impl.h
@@ -0,0 +1,48 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2012-2013 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_PACK_K_BITS_BB_IMPL_H
+#define INCLUDED_GR_PACK_K_BITS_BB_IMPL_H
+
+#include <blocks/pack_k_bits_bb.h>
+
+namespace gr {
+ namespace blocks {
+
+ class pack_k_bits_bb_impl : public pack_k_bits_bb
+ {
+ private:
+ unsigned d_k; // number of relevent bits to pack from k input bytes
+
+ public:
+ pack_k_bits_bb_impl(unsigned k);
+ ~pack_k_bits_bb_impl();
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_GR_PACK_K_BITS_BB_IMPL_H */
diff --git a/gr-blocks/lib/pdu.cc b/gr-blocks/lib/pdu.cc
new file mode 100644
index 0000000000..41a2d88c3a
--- /dev/null
+++ b/gr-blocks/lib/pdu.cc
@@ -0,0 +1,92 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2013 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <blocks/pdu.h>
+
+namespace gr {
+ namespace blocks {
+ namespace pdu {
+
+ size_t
+ itemsize(vector_type type)
+ {
+ switch(type) {
+ case byte_t:
+ return sizeof(char);
+ case float_t:
+ return sizeof(float);
+ case complex_t:
+ return sizeof(gr_complex);
+ default:
+ throw std::runtime_error("bad PDU type");
+ }
+ }
+
+ bool
+ type_matches(vector_type type, pmt::pmt_t v)
+ {
+ switch(type) {
+ case byte_t:
+ return pmt::pmt_is_u8vector(v);
+ case float_t:
+ return pmt::pmt_is_f32vector(v);
+ case complex_t:
+ return pmt::pmt_is_c32vector(v);
+ default:
+ throw std::runtime_error("bad PDU type");
+ }
+ }
+
+ pmt::pmt_t
+ make_vector(vector_type type, const uint8_t *buf, size_t items)
+ {
+ switch(type) {
+ case byte_t:
+ return pmt::pmt_init_u8vector(items, buf);
+ case float_t:
+ return pmt::pmt_init_f32vector(items, (const float *)buf);
+ case complex_t:
+ return pmt::pmt_init_c32vector(items, (const gr_complex *)buf);
+ default:
+ throw std::runtime_error("bad PDU type");
+ }
+ }
+
+ vector_type
+ type_from_pmt(pmt::pmt_t vector)
+ {
+ if(pmt_is_u8vector(vector))
+ return byte_t;
+ if(pmt_is_f32vector(vector))
+ return float_t;
+ if(pmt_is_c32vector(vector))
+ return complex_t;
+ throw std::runtime_error("bad PDU type");
+ }
+
+ } /* namespace pdu */
+ } /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/pdu_to_tagged_stream_impl.cc b/gr-blocks/lib/pdu_to_tagged_stream_impl.cc
new file mode 100644
index 0000000000..80785b4781
--- /dev/null
+++ b/gr-blocks/lib/pdu_to_tagged_stream_impl.cc
@@ -0,0 +1,120 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2013 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "pdu_to_tagged_stream_impl.h"
+#include <blocks/pdu.h>
+#include <gr_io_signature.h>
+
+namespace gr {
+ namespace blocks {
+
+ pdu_to_tagged_stream::sptr
+ pdu_to_tagged_stream::make(pdu::vector_type type)
+ {
+ return gnuradio::get_initial_sptr(new pdu_to_tagged_stream_impl(type));
+ }
+
+ pdu_to_tagged_stream_impl::pdu_to_tagged_stream_impl(pdu::vector_type type)
+ : gr_sync_block("pdu_to_tagged_stream",
+ gr_make_io_signature(0, 0, 0),
+ gr_make_io_signature(1, 1, pdu::itemsize(type))),
+ d_itemsize(pdu::itemsize(type)),
+ d_type(type)
+ {
+ message_port_register_in(PDU_PORT_ID);
+ }
+
+ int
+ pdu_to_tagged_stream_impl::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ char *out = (char *)output_items[0];
+ int nout = 0;
+
+ // if we have remaining output, send it
+ if (d_remain.size() > 0) {
+ nout = std::min((size_t)d_remain.size()/d_itemsize, (size_t)noutput_items);
+ memcpy(out, &d_remain[0], nout*d_itemsize);
+ d_remain.erase(d_remain.begin(), d_remain.begin()+nout);
+ noutput_items -= nout;
+ out += nout*d_itemsize;
+ }
+
+ // if we have space for at least one item output as much as we can
+ if (noutput_items > 0) {
+
+ // grab a message if one exists
+ pmt::pmt_t msg(delete_head_blocking(PDU_PORT_ID));
+ if (msg.get() == NULL)
+ return nout;
+
+ // make sure type is valid
+ if (!pmt::pmt_is_pair(msg)) // TODO: implement pdu::is_valid()
+ throw std::runtime_error("received a malformed pdu message");
+
+ // grab the components of the pdu message
+ pmt::pmt_t meta(pmt::pmt_car(msg));
+ pmt::pmt_t vect(pmt::pmt_cdr(msg));
+
+ // compute offset for output tag
+ uint64_t offset = nitems_written(0) + nout;
+
+ // add a tag for pdu length
+ add_item_tag(0, offset, PDU_LENGTH_TAG, pmt::pmt_from_long(pmt::pmt_length(vect)), pmt::mp(alias()));
+
+ // if we recieved metadata add it as tags
+ if (!pmt_eq(meta, pmt::PMT_NIL) ) {
+ pmt::pmt_t pair(pmt::pmt_dict_keys(meta));
+
+ while (!pmt_eq(pair, pmt::PMT_NIL) ) {
+ pmt::pmt_t k(pmt::pmt_cdr(pair));
+ pmt::pmt_t v(pmt::pmt_dict_ref(meta, k, pmt::PMT_NIL));
+ add_item_tag(0, offset, k, v, pmt::mp(alias()));
+ }
+ }
+
+ // copy vector output
+ size_t ncopy = std::min((size_t)noutput_items, (size_t)pmt::pmt_length(vect));
+ size_t nsave = pmt::pmt_length(vect) - ncopy;
+
+ // copy output
+ size_t io(0);
+ nout += ncopy;
+ memcpy(out, pmt_uniform_vector_elements(vect,io), ncopy*d_itemsize);
+
+ // save leftover items if needed for next work call
+ if (nsave > 0) {
+ d_remain.resize(nsave*d_itemsize, 0);
+ memcpy(&d_remain[0], pmt_uniform_vector_elements(vect,ncopy), nsave*d_itemsize);
+ }
+ }
+
+ return nout;
+ }
+
+ } /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/pdu_to_tagged_stream_impl.h b/gr-blocks/lib/pdu_to_tagged_stream_impl.h
new file mode 100644
index 0000000000..ca1c6437bd
--- /dev/null
+++ b/gr-blocks/lib/pdu_to_tagged_stream_impl.h
@@ -0,0 +1,48 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2013 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_PDU_TO_TAGGED_STREAM_IMPL_H
+#define INCLUDED_PDU_TO_TAGGED_STREAM_IMPL_H
+
+#include <blocks/pdu_to_tagged_stream.h>
+
+namespace gr {
+ namespace blocks {
+
+ class BLOCKS_API pdu_to_tagged_stream_impl : public pdu_to_tagged_stream
+ {
+ size_t d_itemsize;
+ pdu::vector_type d_type;
+ std::vector<uint8_t> d_remain;
+
+ public:
+ pdu_to_tagged_stream_impl(pdu::vector_type type);
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif
diff --git a/gr-blocks/lib/peak_detector_XX_impl.cc.t b/gr-blocks/lib/peak_detector_XX_impl.cc.t
new file mode 100644
index 0000000000..27518962f5
--- /dev/null
+++ b/gr-blocks/lib/peak_detector_XX_impl.cc.t
@@ -0,0 +1,122 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007,2010,2013 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.
+ */
+
+// @WARNING@
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "@NAME_IMPL@.h"
+#include <gr_io_signature.h>
+#include <string.h>
+
+namespace gr {
+ namespace blocks {
+
+ @NAME@::sptr
+ @NAME@::make(float threshold_factor_rise,
+ float threshold_factor_fall,
+ int look_ahead, float alpha)
+ {
+ return gnuradio::get_initial_sptr
+ (new @NAME_IMPL@(threshold_factor_rise,
+ threshold_factor_fall,
+ look_ahead, alpha));
+ }
+
+ @NAME_IMPL@::@NAME_IMPL@(float threshold_factor_rise,
+ float threshold_factor_fall,
+ int look_ahead, float alpha)
+ : gr_sync_block("@BASE_NAME@",
+ gr_make_io_signature(1, 1, sizeof(@I_TYPE@)),
+ gr_make_io_signature(1, 1, sizeof(char))),
+ d_threshold_factor_rise(threshold_factor_rise),
+ d_threshold_factor_fall(threshold_factor_fall),
+ d_look_ahead(look_ahead), d_avg_alpha(alpha), d_avg(0), d_found(0)
+ {
+ }
+
+ @NAME_IMPL@::~@NAME_IMPL@()
+ {
+ }
+
+ int
+ @NAME_IMPL@::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ @I_TYPE@ *iptr = (@I_TYPE@*)input_items[0];
+ char *optr = (char*)output_items[0];
+
+ memset(optr, 0, noutput_items*sizeof(char));
+
+ @I_TYPE@ peak_val = -(@I_TYPE@)INFINITY;
+ int peak_ind = 0;
+ unsigned char state = 0;
+ int i = 0;
+
+ //printf("noutput_items %d\n",noutput_items);
+ while(i < noutput_items) {
+ if(state == 0) { // below threshold
+ if(iptr[i] > d_avg*d_threshold_factor_rise) {
+ state = 1;
+ }
+ else {
+ d_avg = (d_avg_alpha)*iptr[i] + (1-d_avg_alpha)*d_avg;
+ i++;
+ }
+ }
+ else if(state == 1) { // above threshold, have not found peak
+ //printf("Entered State 1: %f i: %d noutput_items: %d\n", iptr[i], i, noutput_items);
+ if(iptr[i] > peak_val) {
+ peak_val = iptr[i];
+ peak_ind = i;
+ d_avg = (d_avg_alpha)*iptr[i] + (1-d_avg_alpha)*d_avg;
+ i++;
+ }
+ else if(iptr[i] > d_avg*d_threshold_factor_fall) {
+ d_avg = (d_avg_alpha)*iptr[i] + (1-d_avg_alpha)*d_avg;
+ i++;
+ }
+ else {
+ optr[peak_ind] = 1;
+ state = 0;
+ peak_val = -(@I_TYPE@)INFINITY;
+ //printf("Leaving State 1: Peak: %f Peak Ind: %d i: %d noutput_items: %d\n",
+ //peak_val, peak_ind, i, noutput_items);
+ }
+ }
+ }
+
+ if(state == 0) {
+ //printf("Leave in State 0, produced %d\n",noutput_items);
+ return noutput_items;
+ }
+ else { // only return up to passing the threshold
+ //printf("Leave in State 1, only produced %d of %d\n",peak_ind,noutput_items);
+ return peak_ind+1;
+ }
+ }
+
+ } /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/peak_detector_XX_impl.h.t b/gr-blocks/lib/peak_detector_XX_impl.h.t
new file mode 100644
index 0000000000..ef52f0f744
--- /dev/null
+++ b/gr-blocks/lib/peak_detector_XX_impl.h.t
@@ -0,0 +1,66 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007,2013 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.
+ */
+
+// @WARNING@
+
+#ifndef @GUARD_NAME_IMPL@
+#define @GUARD_NAME_IMPL@
+
+#include <blocks/@NAME@.h>
+
+namespace gr {
+ namespace blocks {
+
+ class @NAME_IMPL@ : public @NAME@
+ {
+ private:
+ float d_threshold_factor_rise;
+ float d_threshold_factor_fall;
+ int d_look_ahead;
+ float d_avg_alpha;
+ float d_avg;
+ unsigned char d_found;
+
+ public:
+ @NAME_IMPL@(float threshold_factor_rise,
+ float threshold_factor_fall,
+ int look_ahead, float alpha);
+ ~@NAME_IMPL@();
+
+ void set_threshold_factor_rise(float thr) { d_threshold_factor_rise = thr; }
+ void set_threshold_factor_fall(float thr) { d_threshold_factor_fall = thr; }
+ void set_look_ahead(int look) { d_look_ahead = look; }
+ void set_alpha(int alpha) { d_avg_alpha = alpha; }
+ float threshold_factor_rise() { return d_threshold_factor_rise; }
+ float threshold_factor_fall() { return d_threshold_factor_fall; }
+ int look_ahead() { return d_look_ahead; }
+ float alpha() { return d_avg_alpha; }
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* @GUARD_NAME_IMPL@ */
diff --git a/gr-blocks/lib/plateau_detector_fb_impl.cc b/gr-blocks/lib/plateau_detector_fb_impl.cc
new file mode 100644
index 0000000000..f68ef6463f
--- /dev/null
+++ b/gr-blocks/lib/plateau_detector_fb_impl.cc
@@ -0,0 +1,83 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2012-2013 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gr_io_signature.h>
+#include "plateau_detector_fb_impl.h"
+
+namespace gr {
+ namespace blocks {
+
+ plateau_detector_fb::sptr
+ plateau_detector_fb::make(int max_len, float threshold)
+ {
+ return gnuradio::get_initial_sptr
+ (new plateau_detector_fb_impl(max_len, threshold));
+ }
+
+ plateau_detector_fb_impl::plateau_detector_fb_impl(int max_len, float threshold)
+ : gr_sync_block("plateau_detector_fb",
+ gr_make_io_signature(1, 1, sizeof(float)),
+ gr_make_io_signature(1, 1, sizeof(char))),
+ d_max_len(max_len),
+ d_threshold(threshold)
+ {}
+
+ plateau_detector_fb_impl::~plateau_detector_fb_impl()
+ {
+ }
+
+ int
+ plateau_detector_fb_impl::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ const float *in = (const float *) input_items[0];
+ unsigned char *out = (unsigned char *) output_items[0];
+ int flank_start;
+
+ memset((void *) out, 0x00, noutput_items);
+ int i;
+ for(i = 0; i < noutput_items; i++) {
+ if(in[i] >= d_threshold) {
+ if(noutput_items-i < 2*d_max_len) { // If we can't finish, come back later
+ break;
+ }
+ flank_start = i;
+ while(i < noutput_items && in[i] >= d_threshold)
+ i++;
+ if((i - flank_start) > 1) { // 1 Sample is not a plateau
+ out[flank_start + (i-flank_start)/2] = 1;
+ i = std::min(i+d_max_len, noutput_items-1);
+ }
+ }
+ }
+
+ return i;
+ }
+
+ } /* namespace blocks */
+} /* namespace gr */
+
diff --git a/gr-blocks/lib/plateau_detector_fb_impl.h b/gr-blocks/lib/plateau_detector_fb_impl.h
new file mode 100644
index 0000000000..67682d00f3
--- /dev/null
+++ b/gr-blocks/lib/plateau_detector_fb_impl.h
@@ -0,0 +1,50 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2012-2013 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_BLOCKS_PLATEAU_DETECTOR_FB_IMPL_H
+#define INCLUDED_BLOCKS_PLATEAU_DETECTOR_FB_IMPL_H
+
+#include <blocks/plateau_detector_fb.h>
+
+namespace gr {
+ namespace blocks {
+
+class plateau_detector_fb_impl : public plateau_detector_fb
+{
+ private:
+ int d_max_len;
+ float d_threshold;
+
+ public:
+ plateau_detector_fb_impl(int max_len, float threshold);
+ ~plateau_detector_fb_impl();
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+};
+
+ } // namespace blocks
+} // namespace gr
+
+#endif /* INCLUDED_BLOCKS_PLATEAU_DETECTOR_FB_IMPL_H */
+
diff --git a/gr-blocks/lib/probe_rate_impl.cc b/gr-blocks/lib/probe_rate_impl.cc
new file mode 100644
index 0000000000..37749c85e3
--- /dev/null
+++ b/gr-blocks/lib/probe_rate_impl.cc
@@ -0,0 +1,119 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2005,2013 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "probe_rate_impl.h"
+#include <gr_io_signature.h>
+
+namespace gr {
+ namespace blocks {
+
+ probe_rate::sptr
+ probe_rate::make(size_t itemsize, double update_rate_ms, double alpha)
+ {
+ return gnuradio::get_initial_sptr
+ (new probe_rate_impl(itemsize,update_rate_ms,alpha));
+ }
+
+ probe_rate_impl::probe_rate_impl(size_t itemsize, double update_rate_ms, double alpha) :
+ gr_sync_block("probe_rate",
+ gr_make_io_signature(1,1,itemsize),
+ gr_make_io_signature(0,0,itemsize)),
+ d_alpha(alpha),
+ d_beta(1.0-alpha),
+ d_avg(0),
+ d_min_update_time(update_rate_ms),
+ d_lastthru(0),
+ d_itemsize(itemsize)
+ {
+ }
+
+ probe_rate_impl::~probe_rate_impl(){}
+
+ int probe_rate_impl::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items){
+ d_lastthru += noutput_items;
+ boost::posix_time::ptime now(boost::posix_time::microsec_clock::local_time());
+ boost::posix_time::time_duration diff = now - d_last_update;
+ double diff_ms = diff.total_milliseconds();
+ if(diff_ms >= d_min_update_time){
+ double rate_this_update = d_lastthru *1e3 / diff_ms;
+ d_lastthru = 0;
+ d_last_update = now;
+ if(d_avg == 0){
+ d_avg = rate_this_update;
+ } else {
+ d_avg = rate_this_update*d_alpha + d_avg*d_beta;
+ }
+ }
+ return noutput_items;
+ }
+
+ void probe_rate_impl::setup_rpc(){
+#ifdef GR_CTRLPORT
+ add_rpc_variable(
+ rpcbasic_sptr(new rpcbasic_register_get<probe_rate_impl, double >(
+ alias(), "rate_items",
+ &probe_rate_impl::rate,
+ pmt::mp(0), pmt::mp(1e6), pmt::mp(1),
+ "items/sec", "Item rate",
+ RPC_PRIVLVL_MIN, DISPTIME | DISPOPTSTRIP)));
+ add_rpc_variable(
+ rpcbasic_sptr(new rpcbasic_register_get<probe_rate_impl, double >(
+ alias(), "timesincelast",
+ &probe_rate_impl::timesincelast,
+ pmt::mp(0), pmt::mp(d_min_update_time*2), pmt::mp(0),
+ "ms", "Time since last update",
+ RPC_PRIVLVL_MIN, DISPTIME | DISPOPTSTRIP)));
+#endif
+ }
+
+ void probe_rate_impl::set_alpha(double alpha){ d_alpha = alpha; }
+
+ double probe_rate_impl::rate(){ return d_avg; }
+
+ double probe_rate_impl::timesincelast(){
+ boost::posix_time::ptime now(boost::posix_time::microsec_clock::local_time());
+ boost::posix_time::time_duration diff = now - d_last_update;
+ return diff.total_milliseconds();
+ }
+
+ bool probe_rate_impl::start(){
+ d_avg = 0;
+ d_lastthru = 0;
+ d_last_update = boost::posix_time::microsec_clock::local_time();
+ return true;
+ }
+
+ bool probe_rate_impl::stop(){
+ return true;
+ }
+
+
+
+ } /* namespace blocks */
+} /* namespace gr */
+
diff --git a/gr-blocks/lib/probe_rate_impl.h b/gr-blocks/lib/probe_rate_impl.h
new file mode 100644
index 0000000000..81f7b4e138
--- /dev/null
+++ b/gr-blocks/lib/probe_rate_impl.h
@@ -0,0 +1,63 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2005,2013 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_PROBE_RATE_IMPL_H
+#define INCLUDED_GR_PROBE_RATE_IMPL_H
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <blocks/probe_rate.h>
+
+namespace gr {
+ namespace blocks {
+
+ class probe_rate_impl : public probe_rate
+ {
+ private:
+ double d_alpha, d_beta, d_avg;
+ double d_min_update_time;
+ boost::posix_time::ptime d_last_update;
+ uint64_t d_lastthru;
+ size_t d_itemsize;
+ void setup_rpc();
+
+ public:
+ probe_rate_impl(size_t itemsize, double update_rate_ms, double alpha = 0.0001);
+ ~probe_rate_impl();
+ void set_alpha(double alpha);
+ double rate();
+ double timesincelast();
+ bool start();
+ bool stop();
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+
+ }; // end class
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif
diff --git a/gr-blocks/lib/probe_signal_X_impl.cc.t b/gr-blocks/lib/probe_signal_X_impl.cc.t
new file mode 100644
index 0000000000..4cda4e5273
--- /dev/null
+++ b/gr-blocks/lib/probe_signal_X_impl.cc.t
@@ -0,0 +1,68 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2005,2010,2012-2013 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.
+ */
+
+// @WARNING@
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <@NAME_IMPL@.h>
+#include <gr_io_signature.h>
+
+namespace gr {
+ namespace blocks {
+
+ @NAME@::sptr
+ @BASE_NAME@::make()
+ {
+ return gnuradio::get_initial_sptr
+ (new @NAME_IMPL@());
+ }
+
+ @NAME_IMPL@::@NAME_IMPL@()
+ : gr_sync_block("@BASE_NAME@",
+ gr_make_io_signature(1, 1, sizeof(@TYPE@)),
+ gr_make_io_signature(0, 0, 0)),
+ d_level(0)
+ {
+ }
+
+ @NAME_IMPL@::~@NAME_IMPL@()
+ {
+ }
+
+ int
+ @NAME_IMPL@::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ const @TYPE@ *in = (const @TYPE@ *)input_items[0];
+
+ if(noutput_items > 0)
+ d_level = in[noutput_items-1];
+
+ return noutput_items;
+ }
+
+ } /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/probe_signal_X_impl.h.t b/gr-blocks/lib/probe_signal_X_impl.h.t
new file mode 100644
index 0000000000..9c3d05becd
--- /dev/null
+++ b/gr-blocks/lib/probe_signal_X_impl.h.t
@@ -0,0 +1,52 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2005,2012-2013 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.
+ */
+
+// @WARNING@
+
+#ifndef @GUARD_NAME_IMPL@
+#define @GUARD_NAME_IMPL@
+
+#include <blocks/@NAME@.h>
+
+namespace gr {
+ namespace blocks {
+
+ class @NAME_IMPL@ : public @NAME@
+ {
+ private:
+ @TYPE@ d_level;
+
+ public:
+ @NAME_IMPL@();
+ ~@NAME_IMPL@();
+
+ @TYPE@ level() const { return d_level; }
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* @GUARD_NAME_IMPL@ */
diff --git a/gr-blocks/lib/probe_signal_vX_impl.cc.t b/gr-blocks/lib/probe_signal_vX_impl.cc.t
new file mode 100644
index 0000000000..bd520b0bc8
--- /dev/null
+++ b/gr-blocks/lib/probe_signal_vX_impl.cc.t
@@ -0,0 +1,69 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2005,2010,2012-2013 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.
+ */
+
+// @WARNING@
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+
+#include <@NAME_IMPL@.h>
+#include <gr_io_signature.h>
+
+namespace gr {
+ namespace blocks {
+
+ @NAME@::sptr
+ @BASE_NAME@::make(size_t size)
+ {
+ return gnuradio::get_initial_sptr
+ (new @NAME_IMPL@(size));
+ }
+
+ @NAME_IMPL@::@NAME_IMPL@(size_t size)
+ : gr_sync_block("@BASE_NAME@",
+ gr_make_io_signature(1, 1, size*sizeof(@TYPE@)),
+ gr_make_io_signature(0, 0, 0)),
+ d_level(size, 0), d_size(size)
+ {
+ }
+
+ @NAME_IMPL@::~@NAME_IMPL@()
+ {
+ }
+
+ int
+ @NAME_IMPL@::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ const @TYPE@ *in = (const @TYPE@ *)input_items[0];
+
+ for(size_t i=0; i<d_size; i++)
+ d_level[i] = in[(noutput_items-1)*d_size+i];
+
+ return noutput_items;
+ }
+
+ } /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/probe_signal_vX_impl.h.t b/gr-blocks/lib/probe_signal_vX_impl.h.t
new file mode 100644
index 0000000000..1424334a7f
--- /dev/null
+++ b/gr-blocks/lib/probe_signal_vX_impl.h.t
@@ -0,0 +1,54 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2005,2012-2013 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.
+ */
+
+// @WARNING@
+
+#ifndef @GUARD_NAME_IMPL@
+#define @GUARD_NAME_IMPL@
+
+#include <vector>
+#include <blocks/@NAME@.h>
+
+namespace gr {
+ namespace blocks {
+
+ class @NAME_IMPL@ : public @NAME@
+ {
+ private:
+ std::vector<@TYPE@> d_level;
+ size_t d_size;
+
+ public:
+ @NAME_IMPL@(size_t size);
+ ~@NAME_IMPL@();
+
+ std::vector<@TYPE@> level() const { return d_level; }
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* @GUARD_NAME_IMPL@ */
diff --git a/gr-blocks/lib/qa_block_tags.cc b/gr-blocks/lib/qa_block_tags.cc
new file mode 100644
index 0000000000..ea9832ca68
--- /dev/null
+++ b/gr-blocks/lib/qa_block_tags.cc
@@ -0,0 +1,450 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2010,2013 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <qa_block_tags.h>
+#include <gr_block.h>
+#include <gr_top_block.h>
+#include <gr_null_source.h>
+#include <gr_null_sink.h>
+#include <gr_head.h>
+#include <blocks/annotator_alltoall.h>
+#include <blocks/annotator_1to1.h>
+#include <gr_keep_one_in_n.h>
+#include <gr_tags.h>
+
+
+// ----------------------------------------------------------------
+
+using namespace pmt;
+
+// set to 1 to turn on debug output
+// The debug output fully checks that the tags seen are what are expected. While
+// this behavior currently works with our implementation, there is no guarentee
+// that the tags will be coming in this specific order, so it's dangerous to
+// rely on this as a test of the tag system working. We would really want to
+// tags we know we should see and then test that they all occur once, but in no
+// particular order.
+#define QA_TAGS_DEBUG 0
+
+void
+qa_block_tags::t0()
+{
+ unsigned int N = 1000;
+ gr_top_block_sptr tb = gr_make_top_block("top");
+ gr_block_sptr src (gr_make_null_source(sizeof(int)));
+ gr_block_sptr head (gr_make_head(sizeof(int), N));
+ gr_block_sptr snk (gr_make_null_sink(sizeof(int)));
+
+ tb->connect(src, 0, head, 0);
+ tb->connect(head, 0, snk, 0);
+
+ //CPPUNIT_ASSERT_THROW(src->nitems_read(0), std::runtime_error);
+ //CPPUNIT_ASSERT_THROW(src->nitems_written(0), std::runtime_error);
+ CPPUNIT_ASSERT_EQUAL(src->nitems_read(0), (uint64_t)0);
+ CPPUNIT_ASSERT_EQUAL(src->nitems_written(0), (uint64_t)0);
+
+ tb->run();
+
+ CPPUNIT_ASSERT_THROW(src->nitems_read(0), std::invalid_argument);
+ CPPUNIT_ASSERT(src->nitems_written(0) >= N);
+ CPPUNIT_ASSERT_EQUAL(snk->nitems_read(0), (uint64_t)1000);
+ CPPUNIT_ASSERT_THROW(snk->nitems_written(0), std::invalid_argument);
+}
+
+
+void
+qa_block_tags::t1()
+{
+ int N = 40000;
+ gr_top_block_sptr tb = gr_make_top_block("top");
+ gr_block_sptr src (gr_make_null_source(sizeof(int)));
+ gr_block_sptr head (gr_make_head(sizeof(int), N));
+ gr::blocks::annotator_alltoall::sptr ann0(gr::blocks::annotator_alltoall::make(10000, sizeof(int)));
+ gr::blocks::annotator_alltoall::sptr ann1(gr::blocks::annotator_alltoall::make(10000, sizeof(int)));
+ gr::blocks::annotator_alltoall::sptr ann2(gr::blocks::annotator_alltoall::make(10000, sizeof(int)));
+ gr::blocks::annotator_alltoall::sptr ann3(gr::blocks::annotator_alltoall::make(10000, sizeof(int)));
+ gr::blocks::annotator_alltoall::sptr ann4(gr::blocks::annotator_alltoall::make(10000, sizeof(int)));
+ gr_block_sptr snk0 (gr_make_null_sink(sizeof(int)));
+ gr_block_sptr snk1 (gr_make_null_sink(sizeof(int)));
+
+ tb->connect(src, 0, head, 0);
+ tb->connect(head, 0, ann0, 0);
+
+ tb->connect(ann0, 0, ann1, 0);
+ tb->connect(ann0, 1, ann2, 0);
+ tb->connect(ann1, 0, ann3, 0);
+ tb->connect(ann2, 0, ann4, 0);
+
+ tb->connect(ann3, 0, snk0, 0);
+ tb->connect(ann4, 0, snk1, 0);
+
+ tb->run();
+
+ std::vector<gr_tag_t> tags0 = ann0->data();
+ std::vector<gr_tag_t> tags3 = ann3->data();
+ std::vector<gr_tag_t> tags4 = ann4->data();
+
+ // The first annotator does not receive any tags from the null sink upstream
+ CPPUNIT_ASSERT_EQUAL(tags0.size(), (size_t)0);
+ CPPUNIT_ASSERT_EQUAL(tags3.size(), (size_t)8);
+ CPPUNIT_ASSERT_EQUAL(tags4.size(), (size_t)8);
+
+#if QA_TAGS_DEBUG
+ // Kludge together the tags that we know should result from the above graph
+ std::stringstream str0, str1, str2;
+ str0 << ann0->name() << ann0->unique_id();
+ str1 << ann1->name() << ann1->unique_id();
+ str2 << ann2->name() << ann2->unique_id();
+
+ pmt_t expected_tags3[8];
+ expected_tags3[0] = mp(pmt_from_uint64(0), mp(str1.str()), mp("seq"), mp(0));
+ expected_tags3[1] = mp(pmt_from_uint64(0), mp(str0.str()), mp("seq"), mp(0));
+ expected_tags3[2] = mp(pmt_from_uint64(10000), mp(str1.str()), mp("seq"), mp(1));
+ expected_tags3[3] = mp(pmt_from_uint64(10000), mp(str0.str()), mp("seq"), mp(2));
+ expected_tags3[4] = mp(pmt_from_uint64(20000), mp(str1.str()), mp("seq"), mp(2));
+ expected_tags3[5] = mp(pmt_from_uint64(20000), mp(str0.str()), mp("seq"), mp(4));
+ expected_tags3[6] = mp(pmt_from_uint64(30000), mp(str1.str()), mp("seq"), mp(3));
+ expected_tags3[7] = mp(pmt_from_uint64(30000), mp(str0.str()), mp("seq"), mp(6));
+
+ pmt_t expected_tags4[8];
+ expected_tags4[0] = mp(pmt_from_uint64(0), mp(str2.str()), mp("seq"), mp(0));
+ expected_tags4[1] = mp(pmt_from_uint64(0), mp(str0.str()), mp("seq"), mp(1));
+ expected_tags4[2] = mp(pmt_from_uint64(10000), mp(str2.str()), mp("seq"), mp(1));
+ expected_tags4[3] = mp(pmt_from_uint64(10000), mp(str0.str()), mp("seq"), mp(3));
+ expected_tags4[4] = mp(pmt_from_uint64(20000), mp(str2.str()), mp("seq"), mp(2));
+ expected_tags4[5] = mp(pmt_from_uint64(20000), mp(str0.str()), mp("seq"), mp(5));
+ expected_tags4[6] = mp(pmt_from_uint64(30000), mp(str2.str()), mp("seq"), mp(3));
+ expected_tags4[7] = mp(pmt_from_uint64(30000), mp(str0.str()), mp("seq"), mp(7));
+
+ std::cout << std::endl << "qa_block_tags::t1" << std::endl;
+
+ // For annotator 3, we know it gets tags from ann0 and ann1, test this
+ for(size_t i = 0; i < tags3.size(); i++) {
+ std::cout << "tags3[" << i << "] = " << tags3[i] << "\t\t" << expected_tags3[i] << std::endl;
+ CPPUNIT_ASSERT_EQUAL(pmt_write_string(tags3[i]), pmt_write_string(expected_tags3[i]));
+ }
+
+ // For annotator 4, we know it gets tags from ann0 and ann2, test this
+ std::cout << std::endl;
+ for(size_t i = 0; i < tags4.size(); i++) {
+ std::cout << "tags4[" << i << "] = " << tags4[i] << "\t\t" << expected_tags4[i] << std::endl;
+ CPPUNIT_ASSERT_EQUAL(pmt_write_string(tags4[i]), pmt_write_string(expected_tags4[i]));
+ }
+#endif
+}
+
+void
+qa_block_tags::t2 ()
+{
+ int N = 40000;
+ gr_top_block_sptr tb = gr_make_top_block("top");
+ gr_block_sptr src (gr_make_null_source(sizeof(int)));
+ gr_block_sptr head (gr_make_head(sizeof(int), N));
+ gr::blocks::annotator_alltoall::sptr ann0(gr::blocks::annotator_alltoall::make(10000, sizeof(int)));
+ gr::blocks::annotator_alltoall::sptr ann1(gr::blocks::annotator_alltoall::make(10000, sizeof(int)));
+ gr::blocks::annotator_alltoall::sptr ann2(gr::blocks::annotator_alltoall::make(10000, sizeof(int)));
+ gr::blocks::annotator_alltoall::sptr ann3(gr::blocks::annotator_alltoall::make(10000, sizeof(int)));
+ gr::blocks::annotator_alltoall::sptr ann4(gr::blocks::annotator_alltoall::make(10000, sizeof(int)));
+ gr_block_sptr snk0 (gr_make_null_sink(sizeof(int)));
+ gr_block_sptr snk1 (gr_make_null_sink(sizeof(int)));
+ gr_block_sptr snk2 (gr_make_null_sink(sizeof(int)));
+
+ tb->connect(src, 0, head, 0);
+ tb->connect(head, 0, ann0, 0);
+
+ tb->connect(ann0, 0, ann1, 0);
+ tb->connect(ann0, 1, ann1, 1);
+ tb->connect(ann1, 0, ann2, 0);
+ tb->connect(ann1, 1, ann3, 0);
+ tb->connect(ann1, 2, ann4, 0);
+
+ tb->connect(ann2, 0, snk0, 0);
+ tb->connect(ann3, 0, snk1, 0);
+ tb->connect(ann4, 0, snk2, 0);
+
+ tb->run();
+
+ std::vector<gr_tag_t> tags0 = ann0->data();
+ std::vector<gr_tag_t> tags1 = ann1->data();
+ std::vector<gr_tag_t> tags2 = ann2->data();
+ std::vector<gr_tag_t> tags3 = ann4->data();
+ std::vector<gr_tag_t> tags4 = ann4->data();
+
+ // The first annotator does not receive any tags from the null sink upstream
+ CPPUNIT_ASSERT_EQUAL(tags0.size(), (size_t)0);
+ CPPUNIT_ASSERT_EQUAL(tags1.size(), (size_t)8);
+
+ // Make sure the rest all have 12 tags
+ CPPUNIT_ASSERT_EQUAL(tags2.size(), (size_t)12);
+ CPPUNIT_ASSERT_EQUAL(tags3.size(), (size_t)12);
+ CPPUNIT_ASSERT_EQUAL(tags4.size(), (size_t)12);
+
+
+#if QA_TAGS_DEBUG
+ // Kludge together the tags that we know should result from the above graph
+ std::stringstream str0, str1;
+ str0 << ann0->name() << ann0->unique_id();
+ str1 << ann1->name() << ann1->unique_id();
+
+ pmt_t expected_tags2[12];
+ expected_tags2[0] = mp(pmt_from_uint64(0), mp(str1.str()), mp("seq"), mp(0));
+ expected_tags2[1] = mp(pmt_from_uint64(0), mp(str0.str()), mp("seq"), mp(0));
+ expected_tags2[2] = mp(pmt_from_uint64(0), mp(str0.str()), mp("seq"), mp(1));
+ expected_tags2[3] = mp(pmt_from_uint64(10000), mp(str1.str()), mp("seq"), mp(3));
+ expected_tags2[4] = mp(pmt_from_uint64(10000), mp(str0.str()), mp("seq"), mp(2));
+ expected_tags2[5] = mp(pmt_from_uint64(10000), mp(str0.str()), mp("seq"), mp(3));
+ expected_tags2[6] = mp(pmt_from_uint64(20000), mp(str1.str()), mp("seq"), mp(6));
+ expected_tags2[7] = mp(pmt_from_uint64(20000), mp(str0.str()), mp("seq"), mp(4));
+ expected_tags2[8] = mp(pmt_from_uint64(20000), mp(str0.str()), mp("seq"), mp(5));
+ expected_tags2[9] = mp(pmt_from_uint64(30000), mp(str1.str()), mp("seq"), mp(9));
+ expected_tags2[10] = mp(pmt_from_uint64(30000), mp(str0.str()), mp("seq"), mp(6));
+ expected_tags2[11] = mp(pmt_from_uint64(30000), mp(str0.str()), mp("seq"), mp(7));
+
+ pmt_t expected_tags4[12];
+ expected_tags4[0] = mp(pmt_from_uint64(0), mp(str1.str()), mp("seq"), mp(2));
+ expected_tags4[1] = mp(pmt_from_uint64(0), mp(str0.str()), mp("seq"), mp(0));
+ expected_tags4[2] = mp(pmt_from_uint64(0), mp(str0.str()), mp("seq"), mp(1));
+ expected_tags4[3] = mp(pmt_from_uint64(10000), mp(str1.str()), mp("seq"), mp(5));
+ expected_tags4[4] = mp(pmt_from_uint64(10000), mp(str0.str()), mp("seq"), mp(2));
+ expected_tags4[5] = mp(pmt_from_uint64(10000), mp(str0.str()), mp("seq"), mp(3));
+ expected_tags4[6] = mp(pmt_from_uint64(20000), mp(str1.str()), mp("seq"), mp(8));
+ expected_tags4[7] = mp(pmt_from_uint64(20000), mp(str0.str()), mp("seq"), mp(4));
+ expected_tags4[8] = mp(pmt_from_uint64(20000), mp(str0.str()), mp("seq"), mp(5));
+ expected_tags4[9] = mp(pmt_from_uint64(30000), mp(str1.str()), mp("seq"), mp(11));
+ expected_tags4[10] = mp(pmt_from_uint64(30000), mp(str0.str()), mp("seq"), mp(6));
+ expected_tags4[11] = mp(pmt_from_uint64(30000), mp(str0.str()), mp("seq"), mp(7));
+
+ std::cout << std::endl << "qa_block_tags::t2" << std::endl;
+
+ // For annotator[2-4], we know it gets tags from ann0 and ann1
+ // but the tags from the different outputs of ann1 are different for each.
+ // Just testing ann2 and ann4; if they are correct it would be
+ // inconceivable for ann3 to have it wrong.
+ for(size_t i = 0; i < tags2.size(); i++) {
+ std::cout << "tags2[" << i << "] = " << tags2[i] << "\t\t" << expected_tags2[i] << std::endl;
+ CPPUNIT_ASSERT_EQUAL(pmt_write_string(tags2[i]), pmt_write_string(expected_tags2[i]));
+ }
+
+ std::cout << std::endl;
+ for(size_t i = 0; i < tags4.size(); i++) {
+ std::cout << "tags2[" << i << "] = " << tags4[i] << "\t\t" << expected_tags4[i] << std::endl;
+ CPPUNIT_ASSERT_EQUAL(pmt_write_string(tags4[i]), pmt_write_string(expected_tags4[i]));
+ }
+#endif
+}
+
+
+void
+qa_block_tags::t3()
+{
+ int N = 40000;
+ gr_top_block_sptr tb = gr_make_top_block("top");
+ gr_block_sptr src (gr_make_null_source(sizeof(int)));
+ gr_block_sptr head (gr_make_head(sizeof(int), N));
+ gr::blocks::annotator_1to1::sptr ann0 (gr::blocks::annotator_1to1::make(10000, sizeof(int)));
+ gr::blocks::annotator_alltoall::sptr ann1 (gr::blocks::annotator_alltoall::make(10000, sizeof(int)));
+ gr::blocks::annotator_alltoall::sptr ann2 (gr::blocks::annotator_alltoall::make(10000, sizeof(int)));
+ gr::blocks::annotator_1to1::sptr ann3 (gr::blocks::annotator_1to1::make(10000, sizeof(int)));
+ gr::blocks::annotator_1to1::sptr ann4 (gr::blocks::annotator_1to1::make(10000, sizeof(int)));
+ gr_block_sptr snk0 (gr_make_null_sink(sizeof(int)));
+ gr_block_sptr snk1 (gr_make_null_sink(sizeof(int)));
+
+ tb->connect(src, 0, head, 0);
+ tb->connect(head, 0, ann0, 0);
+ tb->connect(head, 0, ann0, 1);
+
+ tb->connect(ann0, 0, ann1, 0);
+ tb->connect(ann0, 1, ann2, 0);
+ tb->connect(ann1, 0, ann3, 0);
+ tb->connect(ann2, 0, ann4, 0);
+
+ tb->connect(ann3, 0, snk0, 0);
+ tb->connect(ann4, 0, snk1, 0);
+
+ tb->run();
+
+
+ std::vector<gr_tag_t> tags0 = ann0->data();
+ std::vector<gr_tag_t> tags3 = ann3->data();
+ std::vector<gr_tag_t> tags4 = ann4->data();
+
+ // The first annotator does not receive any tags from the null sink upstream
+ CPPUNIT_ASSERT_EQUAL(tags0.size(), (size_t)0);
+ CPPUNIT_ASSERT_EQUAL(tags3.size(), (size_t)8);
+ CPPUNIT_ASSERT_EQUAL(tags4.size(), (size_t)8);
+
+#if QA_TAGS_DEBUG
+ // Kludge together the tags that we know should result from the above graph
+ std::stringstream str0, str1, str2;
+ str0 << ann0->name() << ann0->unique_id();
+ str1 << ann1->name() << ann1->unique_id();
+ str2 << ann2->name() << ann2->unique_id();
+
+ pmt_t expected_tags3[8];
+ expected_tags3[0] = mp(pmt_from_uint64(0), mp(str1.str()), mp("seq"), mp(0));
+ expected_tags3[1] = mp(pmt_from_uint64(0), mp(str0.str()), mp("seq"), mp(0));
+ expected_tags3[2] = mp(pmt_from_uint64(10000), mp(str1.str()), mp("seq"), mp(1));
+ expected_tags3[3] = mp(pmt_from_uint64(10000), mp(str0.str()), mp("seq"), mp(2));
+ expected_tags3[4] = mp(pmt_from_uint64(20000), mp(str1.str()), mp("seq"), mp(2));
+ expected_tags3[5] = mp(pmt_from_uint64(20000), mp(str0.str()), mp("seq"), mp(4));
+ expected_tags3[6] = mp(pmt_from_uint64(30000), mp(str1.str()), mp("seq"), mp(3));
+ expected_tags3[7] = mp(pmt_from_uint64(30000), mp(str0.str()), mp("seq"), mp(6));
+
+ pmt_t expected_tags4[8];
+ expected_tags4[0] = mp(pmt_from_uint64(0), mp(str2.str()), mp("seq"), mp(0));
+ expected_tags4[1] = mp(pmt_from_uint64(0), mp(str0.str()), mp("seq"), mp(1));
+ expected_tags4[2] = mp(pmt_from_uint64(10000), mp(str2.str()), mp("seq"), mp(1));
+ expected_tags4[3] = mp(pmt_from_uint64(10000), mp(str0.str()), mp("seq"), mp(3));
+ expected_tags4[4] = mp(pmt_from_uint64(20000), mp(str2.str()), mp("seq"), mp(2));
+ expected_tags4[5] = mp(pmt_from_uint64(20000), mp(str0.str()), mp("seq"), mp(5));
+ expected_tags4[6] = mp(pmt_from_uint64(30000), mp(str2.str()), mp("seq"), mp(3));
+ expected_tags4[7] = mp(pmt_from_uint64(30000), mp(str0.str()), mp("seq"), mp(7));
+
+ std::cout << std::endl << "qa_block_tags::t3" << std::endl;
+
+ // For annotator 3, we know it gets tags from ann0 and ann1, test this
+ for(size_t i = 0; i < tags3.size(); i++) {
+ std::cout << "tags3[" << i << "] = " << tags3[i] << "\t\t" << expected_tags3[i] << std::endl;
+ CPPUNIT_ASSERT_EQUAL(pmt_write_string(tags3[i]), pmt_write_string(expected_tags3[i]));
+ }
+
+ // For annotator 4, we know it gets tags from ann0 and ann2, test this
+ std::cout << std::endl;
+ for(size_t i = 0; i < tags4.size(); i++) {
+ std::cout << "tags4[" << i << "] = " << tags4[i] << "\t\t" << expected_tags4[i] << std::endl;
+ CPPUNIT_ASSERT_EQUAL(pmt_write_string(tags4[i]), pmt_write_string(expected_tags4[i]));
+ }
+#endif
+}
+
+
+void
+qa_block_tags::t4()
+{
+ int N = 40000;
+ gr_top_block_sptr tb = gr_make_top_block("top");
+ gr_block_sptr src (gr_make_null_source(sizeof(int)));
+ gr_block_sptr head (gr_make_head(sizeof(int), N));
+ gr::blocks::annotator_1to1::sptr ann0(gr::blocks::annotator_1to1::make(10000, sizeof(int)));
+ gr::blocks::annotator_1to1::sptr ann1(gr::blocks::annotator_1to1::make(10000, sizeof(int)));
+ gr::blocks::annotator_1to1::sptr ann2(gr::blocks::annotator_1to1::make(10000, sizeof(int)));
+ gr_block_sptr snk0 (gr_make_null_sink(sizeof(int)));
+ gr_block_sptr snk1 (gr_make_null_sink(sizeof(int)));
+
+ // using 1-to-1 tag propagation without having equal number of
+ // ins and outs. Make sure this works; will just exit run early.
+ tb->connect(src, 0, head, 0);
+ tb->connect(head, 0, ann0, 0);
+ tb->connect(ann0, 0, ann1, 0);
+ tb->connect(ann0, 1, ann2, 0);
+ tb->connect(ann1, 0, snk0, 0);
+ tb->connect(ann2, 0, snk1, 0);
+
+ std::cerr << std::endl
+ << "NOTE: This is supposed to produce an error from gr_block_executor"
+ << std::endl;
+ tb->run();
+}
+
+
+void
+qa_block_tags::t5()
+{
+ int N = 40000;
+ gr_top_block_sptr tb = gr_make_top_block("top");
+ gr_block_sptr src (gr_make_null_source(sizeof(float)));
+ gr_block_sptr head (gr_make_head(sizeof(float), N));
+ gr::blocks::annotator_alltoall::sptr ann0(gr::blocks::annotator_alltoall::make(10000, sizeof(float)));
+ gr::blocks::annotator_alltoall::sptr ann1(gr::blocks::annotator_alltoall::make(10000, sizeof(float)));
+ gr::blocks::annotator_alltoall::sptr ann2(gr::blocks::annotator_alltoall::make(1000, sizeof(float)));
+ gr_block_sptr snk0 (gr_make_null_sink(sizeof(float)));
+
+ // Rate change blocks
+ gr_keep_one_in_n_sptr dec10 (gr_make_keep_one_in_n(sizeof(float), 10));
+
+ tb->connect(src, 0, head, 0);
+ tb->connect(head, 0, ann0, 0);
+ tb->connect(ann0, 0, ann1, 0);
+ tb->connect(ann1, 0, dec10, 0);
+ tb->connect(dec10, 0, ann2, 0);
+ tb->connect(ann2, 0, snk0, 0);
+
+ tb->run();
+
+ std::vector<gr_tag_t> tags0 = ann0->data();
+ std::vector<gr_tag_t> tags1 = ann1->data();
+ std::vector<gr_tag_t> tags2 = ann2->data();
+
+ // The first annotator does not receive any tags from the null sink upstream
+ CPPUNIT_ASSERT_EQUAL(tags0.size(), (size_t)0);
+ CPPUNIT_ASSERT_EQUAL(tags1.size(), (size_t)4);
+ CPPUNIT_ASSERT_EQUAL(tags2.size(), (size_t)8);
+
+
+#if QA_TAGS_DEBUG
+ // Kludge together the tags that we know should result from the above graph
+ std::stringstream str0, str1, str2;
+ str0 << ann0->name() << ann0->unique_id();
+ str1 << ann1->name() << ann1->unique_id();
+ str2 << ann2->name() << ann2->unique_id();
+
+ pmt_t expected_tags1[5];
+ expected_tags1[0] = mp(pmt_from_uint64(0), mp(str0.str()), mp("seq"), mp(0));
+ expected_tags1[1] = mp(pmt_from_uint64(10000), mp(str0.str()), mp("seq"), mp(1));
+ expected_tags1[2] = mp(pmt_from_uint64(20000), mp(str0.str()), mp("seq"), mp(2));
+ expected_tags1[3] = mp(pmt_from_uint64(30000), mp(str0.str()), mp("seq"), mp(3));
+
+ pmt_t expected_tags2[10];
+ expected_tags2[0] = mp(pmt_from_uint64(0), mp(str1.str()), mp("seq"), mp(0));
+ expected_tags2[1] = mp(pmt_from_uint64(0), mp(str0.str()), mp("seq"), mp(0));
+ expected_tags2[2] = mp(pmt_from_uint64(1000), mp(str1.str()), mp("seq"), mp(1));
+ expected_tags2[3] = mp(pmt_from_uint64(1000), mp(str0.str()), mp("seq"), mp(1));
+ expected_tags2[4] = mp(pmt_from_uint64(2000), mp(str1.str()), mp("seq"), mp(2));
+ expected_tags2[5] = mp(pmt_from_uint64(2000), mp(str0.str()), mp("seq"), mp(2));
+ expected_tags2[6] = mp(pmt_from_uint64(3000), mp(str1.str()), mp("seq"), mp(3));
+ expected_tags2[7] = mp(pmt_from_uint64(3000), mp(str0.str()), mp("seq"), mp(3));
+ expected_tags2[8] = mp(pmt_from_uint64(4000), mp(str1.str()), mp("seq"), mp(4));
+ expected_tags2[9] = mp(pmt_from_uint64(4000), mp(str0.str()), mp("seq"), mp(4));
+
+ std::cout << std::endl << "qa_block_tags::t5" << std::endl;
+
+ // annotator 1 gets tags from annotator 0
+ std::cout << "tags1.size(): " << tags1.size() << std::endl;
+ for(size_t i = 0; i < tags1.size(); i++) {
+ std::cout << "tags1[" << i << "] = " << tags1[i] << "\t\t" << expected_tags1[i] << std::endl;
+ CPPUNIT_ASSERT_EQUAL(pmt_write_string(tags1[i]), pmt_write_string(expected_tags1[i]));
+ }
+
+ // annotator 2 gets tags from annotators 0 and 1
+ std::cout << std::endl;
+ std::cout << "tags2.size(): " << tags2.size() << std::endl;
+ for(size_t i = 0; i < tags2.size(); i++) {
+ std::cout << "tags2[" << i << "] = " << tags2[i] << "\t\t" << expected_tags2[i] << std::endl;
+ CPPUNIT_ASSERT_EQUAL(pmt_write_string(tags2[i]), pmt_write_string(expected_tags2[i]));
+ }
+#endif
+}
+
diff --git a/gr-blocks/lib/qa_block_tags.h b/gr-blocks/lib/qa_block_tags.h
new file mode 100644
index 0000000000..83bebe23f6
--- /dev/null
+++ b/gr-blocks/lib/qa_block_tags.h
@@ -0,0 +1,50 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2010,2013 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_QA_BLOCK_TAGS_H
+#define INCLUDED_QA_BLOCK_TAGS_H
+
+#include <cppunit/extensions/HelperMacros.h>
+#include <cppunit/TestCase.h>
+#include <stdexcept>
+
+class qa_block_tags : public CppUnit::TestCase
+{
+ CPPUNIT_TEST_SUITE(qa_block_tags);
+ CPPUNIT_TEST(t0);
+ CPPUNIT_TEST(t1);
+ CPPUNIT_TEST(t2);
+ CPPUNIT_TEST(t3);
+ CPPUNIT_TEST(t4);
+ CPPUNIT_TEST(t5);
+ CPPUNIT_TEST_SUITE_END();
+
+ private:
+ void t0();
+ void t1();
+ void t2();
+ void t3();
+ void t4();
+ void t5();
+};
+
+#endif /* INCLUDED_QA_BLOCK_TAGS_H */
diff --git a/gr-blocks/lib/qa_blocks.cc b/gr-blocks/lib/qa_blocks.cc
new file mode 100644
index 0000000000..409b5d5762
--- /dev/null
+++ b/gr-blocks/lib/qa_blocks.cc
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2012-2013 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.
+ */
+
+/*
+ * This class gathers together all the test cases for the gr-blocks
+ * directory into a single test suite. As you create new test cases,
+ * add them here.
+ */
+
+#include <qa_blocks.h>
+#include <qa_block_tags.h>
+#include <qa_rotator.h>
+
+CppUnit::TestSuite *
+qa_gr_blocks::suite()
+{
+ CppUnit::TestSuite *s = new CppUnit::TestSuite("gr-blocks");
+
+ s->addTest(qa_block_tags::suite());
+ s->addTest(qa_rotator::suite());
+
+ return s;
+}
diff --git a/gr-blocks/lib/qa_blocks.h b/gr-blocks/lib/qa_blocks.h
new file mode 100644
index 0000000000..88eac60426
--- /dev/null
+++ b/gr-blocks/lib/qa_blocks.h
@@ -0,0 +1,38 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2012-2013 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 _QA_GR_BLOCKS_H_
+#define _QA_GR_BLOCKS_H_
+
+#include <gruel/attributes.h>
+#include <cppunit/TestSuite.h>
+
+//! collect all the tests for the gr-blocks directory
+
+class __GR_ATTR_EXPORT qa_gr_blocks
+{
+ public:
+ //! return suite of tests for all of gr-blocks directory
+ static CppUnit::TestSuite *suite();
+};
+
+#endif /* _QA_GR_BLOCKS_H_ */
diff --git a/gr-blocks/lib/qa_rotator.cc b/gr-blocks/lib/qa_rotator.cc
new file mode 100644
index 0000000000..86bbdd5282
--- /dev/null
+++ b/gr-blocks/lib/qa_rotator.cc
@@ -0,0 +1,75 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2002,2013 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <gruel/attributes.h>
+#include <cppunit/TestAssert.h>
+#include <qa_rotator.h>
+#include <blocks/rotator.h>
+#include <stdio.h>
+#include <cmath>
+#include <gr_expj.h>
+
+// error vector magnitude
+__GR_ATTR_UNUSED static float
+error_vector_mag(gr_complex a, gr_complex b)
+{
+ return abs(a-b);
+}
+
+void
+qa_rotator::t1()
+{
+ static const unsigned int N = 100000;
+
+ gr::blocks::rotator r;
+
+ double phase_incr = 2*M_PI / 1003;
+ double phase = 0;
+
+ // Old code: We increment then return the rotated value, thus we
+ // need to start one tick back r.set_phase(gr_complex(1,0) *
+ // conj(gr_expj(phase_incr)));
+
+ r.set_phase(gr_complex(1,0));
+ r.set_phase_incr(gr_expj(phase_incr));
+
+ for(unsigned i = 0; i < N; i++) {
+ gr_complex expected = gr_expj(phase);
+ gr_complex actual = r.rotate(gr_complex(1, 0));
+
+#if 0
+ float evm = error_vector_mag(expected, actual);
+ printf("[%6d] expected: (%8.6f, %8.6f) actual: (%8.6f, %8.6f) evm: %8.6f\n",
+ i, expected.real(), expected.imag(), actual.real(), actual.imag(), evm);
+#endif
+
+ CPPUNIT_ASSERT_COMPLEXES_EQUAL(expected, actual, 0.0001);
+
+ phase += phase_incr;
+ if(phase >= 2*M_PI)
+ phase -= 2*M_PI;
+ }
+}
diff --git a/gr-blocks/lib/qa_rotator.h b/gr-blocks/lib/qa_rotator.h
new file mode 100644
index 0000000000..575ea506c7
--- /dev/null
+++ b/gr-blocks/lib/qa_rotator.h
@@ -0,0 +1,39 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008,2013 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 _QA_GR_ROTATOR_H_
+#define _QA_GR_ROTATOR_H_
+
+#include <cppunit/extensions/HelperMacros.h>
+#include <cppunit/TestCase.h>
+
+class qa_rotator : public CppUnit::TestCase
+{
+ CPPUNIT_TEST_SUITE(qa_rotator);
+ CPPUNIT_TEST(t1);
+ CPPUNIT_TEST_SUITE_END();
+
+ private:
+ void t1();
+};
+
+#endif /* _QA_GR_ROTATOR_H_ */
diff --git a/gr-blocks/lib/repack_bits_bb_impl.cc b/gr-blocks/lib/repack_bits_bb_impl.cc
new file mode 100644
index 0000000000..c7ed054c8a
--- /dev/null
+++ b/gr-blocks/lib/repack_bits_bb_impl.cc
@@ -0,0 +1,123 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gr_io_signature.h>
+#include "repack_bits_bb_impl.h"
+
+namespace gr {
+ namespace blocks {
+
+ repack_bits_bb::sptr
+ repack_bits_bb::make(int k, int l, const std::string &len_tag_key, bool align_output)
+ {
+ return gnuradio::get_initial_sptr (new repack_bits_bb_impl(k, l, len_tag_key, align_output));
+ }
+
+ repack_bits_bb_impl::repack_bits_bb_impl(int k, int l, const std::string &len_tag_key, bool align_output)
+ : gr_tagged_stream_block("repack_bits_bb",
+ gr_make_io_signature(1, 1, sizeof (char)),
+ gr_make_io_signature(1, 1, sizeof (char)),
+ len_tag_key),
+ d_k(k), d_l(l),
+ d_packet_mode(!len_tag_key.empty()),
+ d_in_index(0), d_out_index(0),
+ d_align_output(align_output)
+ {
+ if (d_k > 8 || d_k < 1 || d_l > 8 || d_l < 1) {
+ throw std::invalid_argument("k and l must be in [1, 8]");
+ }
+
+ set_relative_rate((double) d_k / d_l);
+ }
+
+ repack_bits_bb_impl::~repack_bits_bb_impl()
+ {
+ }
+
+ int
+ repack_bits_bb_impl::calculate_output_stream_length(const gr_vector_int &ninput_items)
+ {
+ int n_out_bytes_required = (ninput_items[0] * d_k) / d_l;
+ if ((ninput_items[0] * d_k) % d_l && (!d_packet_mode || (d_packet_mode && !d_align_output))) {
+ n_out_bytes_required++;
+ }
+
+ return n_out_bytes_required;
+ }
+
+ int
+ repack_bits_bb_impl::work (int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ const unsigned char *in = (const unsigned char *) input_items[0];
+ unsigned char *out = (unsigned char *) output_items[0];
+ int bytes_to_write = noutput_items;
+
+ if (d_packet_mode) { // noutput_items could be larger than necessary
+ int bytes_to_read = ninput_items[0];
+ bytes_to_write = bytes_to_read * d_k / d_l;
+ if (!d_align_output && (((bytes_to_read * d_k) % d_l) != 0)) {
+ bytes_to_write++;
+ }
+ }
+
+ int n_read = 0;
+ int n_written = 0;
+ while(n_written < bytes_to_write && n_read < ninput_items[0]) {
+ if (d_out_index == 0) { // Starting a fresh byte
+ out[n_written] = 0;
+ }
+ out[n_written] |= ((in[n_read] >> d_in_index) & 0x01) << d_out_index;
+
+ d_in_index = (d_in_index + 1) % d_k;
+ d_out_index = (d_out_index + 1) % d_l;
+ if (d_in_index == 0) {
+ n_read++;
+ d_in_index = 0;
+ }
+ if (d_out_index == 0) {
+ n_written++;
+ d_out_index = 0;
+ }
+ }
+
+ if (d_packet_mode) {
+ if (d_out_index) {
+ n_written++;
+ d_out_index = 0;
+ }
+ } else {
+ consume_each(n_read);
+ }
+
+ return n_written;
+ }
+
+ } /* namespace blocks */
+} /* namespace gr */
+
diff --git a/gr-blocks/lib/repack_bits_bb_impl.h b/gr-blocks/lib/repack_bits_bb_impl.h
new file mode 100644
index 0000000000..bf39f8cb0f
--- /dev/null
+++ b/gr-blocks/lib/repack_bits_bb_impl.h
@@ -0,0 +1,58 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 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_BLOCKS_REPACK_BITS_BB_IMPL_H
+#define INCLUDED_BLOCKS_REPACK_BITS_BB_IMPL_H
+
+#include <blocks/repack_bits_bb.h>
+
+namespace gr {
+ namespace blocks {
+
+ class repack_bits_bb_impl : public repack_bits_bb
+ {
+ private:
+ const int d_k; //! Bits on input stream
+ const int d_l; //! Bits on output stream
+ const bool d_packet_mode;
+ int d_in_index; // Current bit of input byte
+ int d_out_index; // Current bit of output byte
+ bool d_align_output; //! true if the output shall be aligned, false if the input shall be aligned
+
+ protected:
+ int calculate_output_stream_length(const gr_vector_int &ninput_items);
+
+ public:
+ repack_bits_bb_impl(int k, int l, const std::string &len_tag_key, bool align_output);
+ ~repack_bits_bb_impl();
+
+ int work(int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } // namespace blocks
+} // namespace gr
+
+#endif /* INCLUDED_BLOCKS_REPACK_BITS_BB_IMPL_H */
+
diff --git a/gr-blocks/lib/sample_and_hold_XX_impl.cc.t b/gr-blocks/lib/sample_and_hold_XX_impl.cc.t
new file mode 100644
index 0000000000..617b2d6ee5
--- /dev/null
+++ b/gr-blocks/lib/sample_and_hold_XX_impl.cc.t
@@ -0,0 +1,73 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007,2010,2013 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.
+ */
+
+// @WARNING@
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <@NAME_IMPL@.h>
+#include <gr_io_signature.h>
+
+namespace gr {
+ namespace blocks {
+
+ @NAME@::sptr
+ @NAME@::make()
+ {
+ return gnuradio::get_initial_sptr
+ (new @NAME_IMPL@());
+ }
+
+ @NAME_IMPL@::@NAME_IMPL@()
+ : gr_sync_block("@BASE_NAME@",
+ gr_make_io_signature2(2, 2, sizeof(@I_TYPE@), sizeof(char)),
+ gr_make_io_signature(1, 1, sizeof(@O_TYPE@))),
+ d_data(0)
+ {
+ }
+
+ @NAME_IMPL@::~@NAME_IMPL@()
+ {
+ }
+
+ int
+ @NAME_IMPL@::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ @I_TYPE@ *iptr = (@I_TYPE@ *)input_items[0];
+ const char *ctrl = (const char *)input_items[1];
+ @O_TYPE@ *optr = (@O_TYPE@ *)output_items[0];
+
+ for(int i = 0; i < noutput_items; i++) {
+ if(ctrl[i]) {
+ d_data = iptr[i];
+ }
+ optr[i] = d_data;
+ }
+ return noutput_items;
+ }
+
+ } /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/sample_and_hold_XX_impl.h.t b/gr-blocks/lib/sample_and_hold_XX_impl.h.t
new file mode 100644
index 0000000000..048bf0d0e7
--- /dev/null
+++ b/gr-blocks/lib/sample_and_hold_XX_impl.h.t
@@ -0,0 +1,50 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007,2013 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.
+ */
+
+// @WARNING@
+
+#ifndef @GUARD_NAME_IMPL@
+#define @GUARD_NAME_IMPL@
+
+#include <blocks/@NAME@.h>
+
+namespace gr {
+ namespace blocks {
+
+ class @NAME_IMPL@ : public @NAME@
+ {
+ private:
+ @O_TYPE@ d_data;
+
+ public:
+ @NAME_IMPL@();
+ ~@NAME_IMPL@();
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* @GUARD_NAME_IMPL@ */
diff --git a/gr-blocks/lib/sine_table.h b/gr-blocks/lib/sine_table.h
new file mode 100644
index 0000000000..69834943bc
--- /dev/null
+++ b/gr-blocks/lib/sine_table.h
@@ -0,0 +1,1025 @@
+ // max_error = 2.353084136763606e-06
+ { 2.925817799165007e-09, 7.219194364267018e-09 },
+ { 2.925707643778599e-09, 2.526699001579799e-07 },
+ { 2.925487337153070e-09, 1.191140162167675e-06 },
+ { 2.925156887582842e-09, 3.284585035595589e-06 },
+ { 2.924716307509151e-09, 6.994872605695784e-06 },
+ { 2.924165613519592e-09, 1.278374920658798e-05 },
+ { 2.923504826347475e-09, 2.111280464718590e-05 },
+ { 2.922733970871080e-09, 3.244343744537165e-05 },
+ { 2.921853076112655e-09, 4.723682007436170e-05 },
+ { 2.920862175237416e-09, 6.595386421935634e-05 },
+ { 2.919761305552202e-09, 8.905518605213658e-05 },
+ { 2.918550508504146e-09, 1.170010715193098e-04 },
+ { 2.917229829679050e-09, 1.502514416517192e-04 },
+ { 2.915799318799769e-09, 1.892658178912071e-04 },
+ { 2.914259029724184e-09, 2.345032874456615e-04 },
+ { 2.912609020443340e-09, 2.864224686607020e-04 },
+ { 2.910849353079123e-09, 3.454814764261432e-04 },
+ { 2.908980093882049e-09, 4.121378876027343e-04 },
+ { 2.907001313228646e-09, 4.868487064877691e-04 },
+ { 2.904913085618902e-09, 5.700703303049837e-04 },
+ { 2.902715489673383e-09, 6.622585147355725e-04 },
+ { 2.900408608130373e-09, 7.638683394782519e-04 },
+ { 2.897992527842612e-09, 8.753541738578119e-04 },
+ { 2.895467339774186e-09, 9.971696424604937e-04 },
+ { 2.892833138996999e-09, 1.129767590823255e-03 },
+ { 2.890090024687216e-09, 1.273600051161478e-03 },
+ { 2.887238100121550e-09, 1.429118208142094e-03 },
+ { 2.884277472673313e-09, 1.596772364709564e-03 },
+ { 2.881208253808507e-09, 1.777011907950626e-03 },
+ { 2.878030559081432e-09, 1.970285275029487e-03 },
+ { 2.874744508130554e-09, 2.177039919152579e-03 },
+ { 2.871350224673798e-09, 2.397722275614272e-03 },
+ { 2.867847836504030e-09, 2.632777727878843e-03 },
+ { 2.864237475484149e-09, 2.882650573737405e-03 },
+ { 2.860519277542297e-09, 3.147783991507308e-03 },
+ { 2.856693382666432e-09, 3.428620006328931e-03 },
+ { 2.852759934899389e-09, 3.725599456482154e-03 },
+ { 2.848719082333207e-09, 4.039161959812243e-03 },
+ { 2.844570977103752e-09, 4.369745880190706e-03 },
+ { 2.840315775384800e-09, 4.717788294077374e-03 },
+ { 2.835953637382310e-09, 5.083724957128360e-03 },
+ { 2.831484727328322e-09, 5.467990270896617e-03 },
+ { 2.826909213474759e-09, 5.871017249604038e-03 },
+ { 2.822227268087134e-09, 6.293237486988512e-03 },
+ { 2.817439067438018e-09, 6.735081123237729e-03 },
+ { 2.812544791800534e-09, 7.196976811989608e-03 },
+ { 2.807544625441273e-09, 7.679351687456759e-03 },
+ { 2.802438756613836e-09, 8.182631331563162e-03 },
+ { 2.797227377551135e-09, 8.707239741274575e-03 },
+ { 2.791910684458716e-09, 9.253599295902304e-03 },
+ { 2.786488877507140e-09, 9.822130724578715e-03 },
+ { 2.780962160824228e-09, 1.041325307382490e-02 },
+ { 2.775330742487884e-09, 1.102738367513773e-02 },
+ { 2.769594834517682e-09, 1.166493811278924e-02 },
+ { 2.763754652867477e-09, 1.232633019159818e-02 },
+ { 2.757810417416620e-09, 1.301197190494069e-02 },
+ { 2.751762351962413e-09, 1.372227340270610e-02 },
+ { 2.745610684210923e-09, 1.445764295952962e-02 },
+ { 2.739355645769094e-09, 1.521848694296229e-02 },
+ { 2.732997472135539e-09, 1.600520978188769e-02 },
+ { 2.726536402691907e-09, 1.681821393496225e-02 },
+ { 2.719972680693777e-09, 1.765789985920713e-02 },
+ { 2.713306553261610e-09, 1.852466597868779e-02 },
+ { 2.706538271371373e-09, 1.941890865333146e-02 },
+ { 2.699668089844909e-09, 2.034102214787814e-02 },
+ { 2.692696267340880e-09, 2.129139860085272e-02 },
+ { 2.685623066344263e-09, 2.227042799383416e-02 },
+ { 2.678448753157212e-09, 2.327849812064098e-02 },
+ { 2.671173597888530e-09, 2.431599455681316e-02 },
+ { 2.663797874443630e-09, 2.538330062913108e-02 },
+ { 2.656321860514457e-09, 2.648079738524795e-02 },
+ { 2.648745837568575e-09, 2.760886356354952e-02 },
+ { 2.641070090839117e-09, 2.876787556300114e-02 },
+ { 2.633294909313421e-09, 2.995820741329835e-02 },
+ { 2.625420585722845e-09, 3.118023074495535e-02 },
+ { 2.617447416531143e-09, 3.243431475972608e-02 },
+ { 2.609375701923643e-09, 3.372082620101990e-02 },
+ { 2.601205745795833e-09, 3.504012932452527e-02 },
+ { 2.592937855741933e-09, 3.639258586895711e-02 },
+ { 2.584572343043400e-09, 3.777855502693250e-02 },
+ { 2.576109522656942e-09, 3.919839341605197e-02 },
+ { 2.567549713203028e-09, 4.065245505002102e-02 },
+ { 2.558893236953688e-09, 4.214109131001403e-02 },
+ { 2.550140419820252e-09, 4.366465091617666e-02 },
+ { 2.541291591341445e-09, 4.522347989919473e-02 },
+ { 2.532347084670572e-09, 4.681792157215026e-02 },
+ { 2.523307236563343e-09, 4.844831650239501e-02 },
+ { 2.514172387364900e-09, 5.011500248369893e-02 },
+ { 2.504942880997064e-09, 5.181831450849345e-02 },
+ { 2.495619064945627e-09, 5.355858474024022e-02 },
+ { 2.486201290246928e-09, 5.533614248606705e-02 },
+ { 2.476689911475047e-09, 5.715131416942842e-02 },
+ { 2.467085286727668e-09, 5.900442330315692e-02 },
+ { 2.457387777613798e-09, 6.089579046229943e-02 },
+ { 2.447597749239101e-09, 6.282573325755320e-02 },
+ { 2.437715570192557e-09, 6.479456630859221e-02 },
+ { 2.427741612532542e-09, 6.680260121764925e-02 },
+ { 2.417676251773166e-09, 6.885014654319160e-02 },
+ { 2.407519866869294e-09, 7.093750777401114e-02 },
+ { 2.397272840203310e-09, 7.306498730310884e-02 },
+ { 2.386935557569868e-09, 7.523288440214027e-02 },
+ { 2.376508408161815e-09, 7.744149519577415e-02 },
+ { 2.365991784555363e-09, 7.969111263635709e-02 },
+ { 2.355386082695641e-09, 8.198202647865405e-02 },
+ { 2.344691701881232e-09, 8.431452325495814e-02 },
+ { 2.333909044749407e-09, 8.668888625021409e-02 },
+ { 2.323038517261246e-09, 8.910539547731611e-02 },
+ { 2.312080528685971e-09, 9.156432765274414e-02 },
+ { 2.301035491585642e-09, 9.406595617227698e-02 },
+ { 2.289903821799651e-09, 9.661055108691619e-02 },
+ { 2.278685938428940e-09, 9.919837907903295e-02 },
+ { 2.267382263820762e-09, 1.018297034385580e-01 },
+ { 2.255993223551837e-09, 1.045047840397028e-01 },
+ { 2.244519246413220e-09, 1.072238773174577e-01 },
+ { 2.232960764393620e-09, 1.099872362446146e-01 },
+ { 2.221318212663309e-09, 1.127951103088245e-01 },
+ { 2.209592029557811e-09, 1.156477454898748e-01 },
+ { 2.197782656561395e-09, 1.185453842371912e-01 },
+ { 2.185890538290176e-09, 1.214882654476019e-01 },
+ { 2.173916122475606e-09, 1.244766244431883e-01 },
+ { 2.161859859947797e-09, 1.275106929493488e-01 },
+ { 2.149722204618256e-09, 1.305906990731841e-01 },
+ { 2.137503613462743e-09, 1.337168672820376e-01 },
+ { 2.125204546504321e-09, 1.368894183821595e-01 },
+ { 2.112825466795944e-09, 1.401085694976751e-01 },
+ { 2.100366840402933e-09, 1.433745340497602e-01 },
+ { 2.087829136385612e-09, 1.466875217359607e-01 },
+ { 2.075212826781308e-09, 1.500477385098620e-01 },
+ { 2.062518386587093e-09, 1.534553865607503e-01 },
+ { 2.049746293741359e-09, 1.569106642937665e-01 },
+ { 2.036897029106193e-09, 1.604137663100403e-01 },
+ { 2.023971076449323e-09, 1.639648833871233e-01 },
+ { 2.010968922425217e-09, 1.675642024598467e-01 },
+ { 1.997891056557933e-09, 1.712119066008896e-01 },
+ { 1.984737971221581e-09, 1.749081750021970e-01 },
+ { 1.971510161622434e-09, 1.786531829561379e-01 },
+ { 1.958208125780130e-09, 1.824471018371070e-01 },
+ { 1.944832364508511e-09, 1.862900990834311e-01 },
+ { 1.931383381397782e-09, 1.901823381790926e-01 },
+ { 1.917861682794392e-09, 1.941239786363039e-01 },
+ { 1.904267777782611e-09, 1.981151759777950e-01 },
+ { 1.890602178165317e-09, 2.021560817195309e-01 },
+ { 1.876865398444616e-09, 2.062468433536743e-01 },
+ { 1.863057955802572e-09, 2.103876043317229e-01 },
+ { 1.849180370081465e-09, 2.145785040479915e-01 },
+ { 1.835233163764673e-09, 2.188196778231083e-01 },
+ { 1.821216861956509e-09, 2.231112568880342e-01 },
+ { 1.807131992362945e-09, 2.274533683680190e-01 },
+ { 1.792979085271234e-09, 2.318461352671018e-01 },
+ { 1.778758673530482e-09, 2.362896764525300e-01 },
+ { 1.764471292530943e-09, 2.407841066397789e-01 },
+ { 1.750117480184598e-09, 2.453295363773890e-01 },
+ { 1.735697776904342e-09, 2.499260720324433e-01 },
+ { 1.721212725583874e-09, 2.545738157760434e-01 },
+ { 1.706662871577097e-09, 2.592728655691494e-01 },
+ { 1.692048762677849e-09, 2.640233151485341e-01 },
+ { 1.677370949099090e-09, 2.688252540131204e-01 },
+ { 1.662629983452104e-09, 2.736787674105404e-01 },
+ { 1.647826420726167e-09, 2.785839363237506e-01 },
+ { 1.632960818266680e-09, 2.835408374583758e-01 },
+ { 1.618033735755429e-09, 2.885495432295704e-01 },
+ { 1.603045735188609e-09, 2.936101217498361e-01 },
+ { 1.587997380855918e-09, 2.987226368167127e-01 },
+ { 1.572889239319430e-09, 3.038871479007593e-01 },
+ { 1.557721879392051e-09, 3.091037101339017e-01 },
+ { 1.542495872116447e-09, 3.143723742978435e-01 },
+ { 1.527211790743024e-09, 3.196931868130269e-01 },
+ { 1.511870210708909e-09, 3.250661897274744e-01 },
+ { 1.496471709615926e-09, 3.304914207062036e-01 },
+ { 1.481016867208896e-09, 3.359689130207621e-01 },
+ { 1.465506265353924e-09, 3.414986955389885e-01 },
+ { 1.449940488016384e-09, 3.470807927151147e-01 },
+ { 1.434320121238994e-09, 3.527152245800635e-01 },
+ { 1.418645753119802e-09, 3.584020067320109e-01 },
+ { 1.402917973789838e-09, 3.641411503272979e-01 },
+ { 1.387137375391042e-09, 3.699326620714776e-01 },
+ { 1.371304552054134e-09, 3.757765442106153e-01 },
+ { 1.355420099875958e-09, 3.816727945230153e-01 },
+ { 1.339484616897137e-09, 3.876214063110671e-01 },
+ { 1.323498703079580e-09, 3.936223683933865e-01 },
+ { 1.307462960283922e-09, 3.996756650972121e-01 },
+ { 1.291377992246768e-09, 4.057812762511174e-01 },
+ { 1.275244404558188e-09, 4.119391771778626e-01 },
+ { 1.259062804638585e-09, 4.181493386877248e-01 },
+ { 1.242833801715929e-09, 4.244117270719281e-01 },
+ { 1.226558006803155e-09, 4.307263040962509e-01 },
+ { 1.210236032674760e-09, 4.370930269951803e-01 },
+ { 1.193868493843725e-09, 4.435118484661861e-01 },
+ { 1.177456006538695e-09, 4.499827166641340e-01 },
+ { 1.160999188680582e-09, 4.565055751961679e-01 },
+ { 1.144498659859216e-09, 4.630803631168164e-01 },
+ { 1.127955041310214e-09, 4.697070149232604e-01 },
+ { 1.111368955891417e-09, 4.763854605510119e-01 },
+ { 1.094741028059551e-09, 4.831156253697562e-01 },
+ { 1.078071883846871e-09, 4.898974301794375e-01 },
+ { 1.061362150836978e-09, 4.967307912069362e-01 },
+ { 1.044612458142151e-09, 5.036156201023686e-01 },
+ { 1.027823436378632e-09, 5.105518239364775e-01 },
+ { 1.010995717643647e-09, 5.175393051975563e-01 },
+ { 9.941299354913699e-10, 5.245779617890562e-01 },
+ { 9.772267249089968e-10, 5.316676870274011e-01 },
+ { 9.602867222926046e-10, 5.388083696401416e-01 },
+ { 9.433105654240147e-10, 5.459998937639375e-01 },
+ { 9.262988934458084e-10, 5.532421389435711e-01 },
+ { 9.092523468378193e-10, 5.605349801305876e-01 },
+ { 8.921715673928355e-10, 5.678782876825250e-01 },
+ { 8.750571981926701e-10, 5.752719273622372e-01 },
+ { 8.579098835836508e-10, 5.827157603377209e-01 },
+ { 8.407302691522673e-10, 5.902096431821322e-01 },
+ { 8.235190017016133e-10, 5.977534278737073e-01 },
+ { 8.062767292259225e-10, 6.053469617967722e-01 },
+ { 7.890041008871165e-10, 6.129900877421282e-01 },
+ { 7.717017669898175e-10, 6.206826439083659e-01 },
+ { 7.543703789572603e-10, 6.284244639030392e-01 },
+ { 7.370105893063053e-10, 6.362153767444958e-01 },
+ { 7.196230516231919e-10, 6.440552068636356e-01 },
+ { 7.022084205389746e-10, 6.519437741060674e-01 },
+ { 6.847673517046416e-10, 6.598808937346672e-01 },
+ { 6.673005017664976e-10, 6.678663764322770e-01 },
+ { 6.498085283416530e-10, 6.759000283046127e-01 },
+ { 6.322920899929834e-10, 6.839816508836737e-01 },
+ { 6.147518462045659e-10, 6.921110411311926e-01 },
+ { 5.971884573565851e-10, 7.002879914425926e-01 },
+ { 5.796025847007168e-10, 7.085122896509806e-01 },
+ { 5.619948903351406e-10, 7.167837190315758e-01 },
+ { 5.443660371796048e-10, 7.251020583063744e-01 },
+ { 5.267166889504394e-10, 7.334670816491009e-01 },
+ { 5.090475101356742e-10, 7.418785586903696e-01 },
+ { 4.913591659698399e-10, 7.503362545232619e-01 },
+ { 4.736523224091392e-10, 7.588399297089872e-01 },
+ { 4.559276461062478e-10, 7.673893402829834e-01 },
+ { 4.381858043851147e-10, 7.759842377612828e-01 },
+ { 4.204274652161870e-10, 7.846243691469355e-01 },
+ { 4.026532971908398e-10, 7.933094769370790e-01 },
+ { 3.848639694963359e-10, 8.020392991300200e-01 },
+ { 3.670601518910503e-10, 8.108135692324444e-01 },
+ { 3.492425146784233e-10, 8.196320162675177e-01 },
+ { 3.314117286825031e-10, 8.284943647824689e-01 },
+ { 3.135684652223755e-10, 8.374003348569865e-01 },
+ { 2.957133960867535e-10, 8.463496421118015e-01 },
+ { 2.778471935089361e-10, 8.553419977173513e-01 },
+ { 2.599705301412391e-10, 8.643771084029740e-01 },
+ { 2.420840790301135e-10, 8.734546764660205e-01 },
+ { 2.241885135902046e-10, 8.825743997817682e-01 },
+ { 2.062845075795238e-10, 8.917359718130367e-01 },
+ { 1.883727350736140e-10, 9.009390816205823e-01 },
+ { 1.704538704408269e-10, 9.101834138731877e-01 },
+ { 1.525285883160648e-10, 9.194686488588080e-01 },
+ { 1.345975635762696e-10, 9.287944624950824e-01 },
+ { 1.166614713141648e-10, 9.381605263410157e-01 },
+ { 9.872098681369190e-11, 9.475665076080466e-01 },
+ { 8.077678552380464e-11, 9.570120691722380e-01 },
+ { 6.282954303364090e-11, 9.664968695860140e-01 },
+ { 4.487993504668797e-11, 9.760205630906909e-01 },
+ { 2.692863735553042e-11, 9.855827996289697e-01 },
+ { 8.976325816439114e-12, 9.951832248577780e-01 },
+ { -8.976323676304494e-12, 1.004821480161519e+00 },
+ { -2.692863521550168e-11, 1.014497202665280e+00 },
+ { -4.487993290681805e-11, 1.024210025248670e+00 },
+ { -6.282954089398273e-11, 1.033959576559617e+00 },
+ { -8.077678338451706e-11, 1.043745481028715e+00 },
+ { -9.872098467477489e-11, 1.053567358883467e+00 },
+ { -1.166614691757772e-10, 1.063424826163223e+00 },
+ { -1.345975614383584e-10, 1.073317494734013e+00 },
+ { -1.525285861788948e-10, 1.083244972303963e+00 },
+ { -1.704538683042922e-10, 1.093206862438572e+00 },
+ { -1.883727329379793e-10, 1.103202764576806e+00 },
+ { -2.062845054446831e-10, 1.113232274046796e+00 },
+ { -2.241885114563697e-10, 1.123294982082432e+00 },
+ { -2.420840768973375e-10, 1.133390475839767e+00 },
+ { -2.599705280096278e-10, 1.143518338413855e+00 },
+ { -2.778471913784365e-10, 1.153678148855860e+00 },
+ { -2.957133939575774e-10, 1.163869482190458e+00 },
+ { -3.135684630945758e-10, 1.174091909433296e+00 },
+ { -3.314117265561857e-10, 1.184344997608959e+00 },
+ { -3.492425125535882e-10, 1.194628309769018e+00 },
+ { -3.670601497678034e-10, 1.204941405010466e+00 },
+ { -3.848639673748360e-10, 1.215283838494269e+00 },
+ { -4.026532950710339e-10, 1.225655161464298e+00 },
+ { -4.204274630982869e-10, 1.236054921266445e+00 },
+ { -4.381858022691734e-10, 1.246482661367958e+00 },
+ { -4.559276439922654e-10, 1.256937921377146e+00 },
+ { -4.736523202972214e-10, 1.267420237063216e+00 },
+ { -4.913591638600925e-10, 1.277929140376502e+00 },
+ { -5.090475080282032e-10, 1.288464159468706e+00 },
+ { -5.267166868452449e-10, 1.299024818713528e+00 },
+ { -5.443660350768455e-10, 1.309610638727845e+00 },
+ { -5.619948882348695e-10, 1.320221136392390e+00 },
+ { -5.796025826029868e-10, 1.330855824873457e+00 },
+ { -5.971884552615020e-10, 1.341514213644420e+00 },
+ { -6.147518441122357e-10, 1.352195808507556e+00 },
+ { -6.322920879034590e-10, 1.362900111616144e+00 },
+ { -6.498085262549874e-10, 1.373626621496939e+00 },
+ { -6.673004996827436e-10, 1.384374833072571e+00 },
+ { -6.847673496239581e-10, 1.395144237684605e+00 },
+ { -7.022084184613616e-10, 1.405934323116231e+00 },
+ { -7.196230495488082e-10, 1.416744573616104e+00 },
+ { -7.370105872352039e-10, 1.427574469921397e+00 },
+ { -7.543703768894941e-10, 1.438423489281758e+00 },
+ { -7.717017649255453e-10, 1.449291105483472e+00 },
+ { -7.890040988262324e-10, 1.460176788873383e+00 },
+ { -8.062767271686383e-10, 1.471080006383765e+00 },
+ { -8.235189996479819e-10, 1.482000221556656e+00 },
+ { -8.407302671024475e-10, 1.492936894569018e+00 },
+ { -8.579098815375368e-10, 1.503889482257845e+00 },
+ { -8.750571961505266e-10, 1.514857438145604e+00 },
+ { -8.921715653546624e-10, 1.525840212465756e+00 },
+ { -9.092523448036167e-10, 1.536837252188703e+00 },
+ { -9.262988914157881e-10, 1.547848001047890e+00 },
+ { -9.433105633981766e-10, 1.558871899565883e+00 },
+ { -9.602867202711075e-10, 1.569908385081254e+00 },
+ { -9.772267228916820e-10, 1.580956891774897e+00 },
+ { -9.941299334786078e-10, 1.592016850697478e+00 },
+ { -1.010995715635332e-09, 1.603087689796053e+00 },
+ { -1.027823434374870e-09, 1.614168833942028e+00 },
+ { -1.044612456143047e-09, 1.625259704958335e+00 },
+ { -1.061362148842745e-09, 1.636359721647526e+00 },
+ { -1.078071881857297e-09, 1.647468299819543e+00 },
+ { -1.094741026074900e-09, 1.658584852320419e+00 },
+ { -1.111368953911690e-09, 1.669708789060341e+00 },
+ { -1.127955039335462e-09, 1.680839517042381e+00 },
+ { -1.144498657889600e-09, 1.691976440391624e+00 },
+ { -1.160999186716154e-09, 1.703118960383971e+00 },
+ { -1.177456004579561e-09, 1.714266475475616e+00 },
+ { -1.193868491889832e-09, 1.725418381332405e+00 },
+ { -1.210236030726319e-09, 1.736574070859850e+00 },
+ { -1.226558004860220e-09, 1.747732934232508e+00 },
+ { -1.242833799778447e-09, 1.758894358924547e+00 },
+ { -1.259062802706714e-09, 1.770057729740021e+00 },
+ { -1.275244402631982e-09, 1.781222428842935e+00 },
+ { -1.291377990326492e-09, 1.792387835788660e+00 },
+ { -1.307462958369363e-09, 1.803553327553897e+00 },
+ { -1.323498701170897e-09, 1.814718278568759e+00 },
+ { -1.339484614994490e-09, 1.825882060747428e+00 },
+ { -1.355420097979292e-09, 1.837044043519582e+00 },
+ { -1.371304550163662e-09, 1.848203593862598e+00 },
+ { -1.387137373506711e-09, 1.859360076332671e+00 },
+ { -1.402917971911754e-09, 1.870512853097495e+00 },
+ { -1.418645751248018e-09, 1.881661283967967e+00 },
+ { -1.434320119373722e-09, 1.892804726431080e+00 },
+ { -1.449940486157623e-09, 1.903942535681972e+00 },
+ { -1.465506263501516e-09, 1.915074064656886e+00 },
+ { -1.481016865363264e-09, 1.926198664066737e+00 },
+ { -1.496471707776859e-09, 1.937315682428795e+00 },
+ { -1.511870208876724e-09, 1.948424466101625e+00 },
+ { -1.527211788917509e-09, 1.959524359317042e+00 },
+ { -1.542495870297867e-09, 1.970614704215133e+00 },
+ { -1.557721877580406e-09, 1.981694840876775e+00 },
+ { -1.572889237514880e-09, 1.992764107358707e+00 },
+ { -1.587997379058514e-09, 2.003821839726753e+00 },
+ { -1.603045733398246e-09, 2.014867372090665e+00 },
+ { -1.618033733972424e-09, 2.025900036638798e+00 },
+ { -1.632960816490822e-09, 2.036919163671778e+00 },
+ { -1.647826418957721e-09, 2.047924081638631e+00 },
+ { -1.662629981691070e-09, 2.058914117170269e+00 },
+ { -1.677370947345626e-09, 2.069888595116115e+00 },
+ { -1.692048760931849e-09, 2.080846838577820e+00 },
+ { -1.706662869838827e-09, 2.091788168946183e+00 },
+ { -1.721212723853279e-09, 2.102711905935372e+00 },
+ { -1.735697775181424e-09, 2.113617367619504e+00 },
+ { -1.750117478469621e-09, 2.124503870468520e+00 },
+ { -1.764471290823748e-09, 2.135370729383332e+00 },
+ { -1.778758671831281e-09, 2.146217257733207e+00 },
+ { -1.792979083579974e-09, 2.157042767390815e+00 },
+ { -1.807131990679890e-09, 2.167846568770014e+00 },
+ { -1.821216860281448e-09, 2.178627970860822e+00 },
+ { -1.835233162097977e-09, 2.189386281268046e+00 },
+ { -1.849180368423027e-09, 2.200120806246095e+00 },
+ { -1.863057954152340e-09, 2.210830850737588e+00 },
+ { -1.876865396802907e-09, 2.221515718409926e+00 },
+ { -1.890602176531920e-09, 2.232174711691990e+00 },
+ { -1.904267776157843e-09, 2.242807131812679e+00 },
+ { -1.917861681178094e-09, 2.253412278837029e+00 },
+ { -1.931383379790273e-09, 2.263989451705295e+00 },
+ { -1.944832362909578e-09, 2.274537948269257e+00 },
+ { -1.958208124189984e-09, 2.285057065331676e+00 },
+ { -1.971510160041235e-09, 2.295546098682665e+00 },
+ { -1.984737969649064e-09, 2.306004343138794e+00 },
+ { -1.997891054994522e-09, 2.316431092581699e+00 },
+ { -2.010968920870647e-09, 2.326825639994779e+00 },
+ { -2.023971074903858e-09, 2.337187277503834e+00 },
+ { -2.036897027569834e-09, 2.347515296413520e+00 },
+ { -2.049746292214264e-09, 2.357808987247877e+00 },
+ { -2.062518385069210e-09, 2.368067639787542e+00 },
+ { -2.075212825272584e-09, 2.378290543109652e+00 },
+ { -2.087829134886364e-09, 2.388476985626922e+00 },
+ { -2.100366838912949e-09, 2.398626255125417e+00 },
+ { -2.112825465315542e-09, 2.408737638805759e+00 },
+ { -2.125204545033289e-09, 2.418810423320288e+00 },
+ { -2.137503612001452e-09, 2.428843894814472e+00 },
+ { -2.149722203166389e-09, 2.438837338964302e+00 },
+ { -2.161859858505829e-09, 2.448790041018174e+00 },
+ { -2.173916121043380e-09, 2.458701285834241e+00 },
+ { -2.185890536867478e-09, 2.468570357921585e+00 },
+ { -2.197782655148702e-09, 2.478396541480230e+00 },
+ { -2.209592028154913e-09, 2.488179120439544e+00 },
+ { -2.221318211270522e-09, 2.497917378500214e+00 },
+ { -2.232960763010574e-09, 2.507610599172123e+00 },
+ { -2.244519245040444e-09, 2.517258065817044e+00 },
+ { -2.255993222189014e-09, 2.526859061686102e+00 },
+ { -2.267382262468209e-09, 2.536412869962689e+00 },
+ { -2.278685937086658e-09, 2.545918773800664e+00 },
+ { -2.289903820467374e-09, 2.555376056366064e+00 },
+ { -2.301035490263848e-09, 2.564784000877677e+00 },
+ { -2.312080527374447e-09, 2.574141890646339e+00 },
+ { -2.323038515960257e-09, 2.583449009117307e+00 },
+ { -2.333909043458635e-09, 2.592704639909166e+00 },
+ { -2.344691700601153e-09, 2.601908066856634e+00 },
+ { -2.355386081425938e-09, 2.611058574048749e+00 },
+ { -2.365991783296513e-09, 2.620155445872768e+00 },
+ { -2.376508406913500e-09, 2.629197967052127e+00 },
+ { -2.386935556332088e-09, 2.638185422689490e+00 },
+ { -2.397272838976436e-09, 2.647117098307332e+00 },
+ { -2.407519865653114e-09, 2.655992279887846e+00 },
+ { -2.417676250567891e-09, 2.664810253915885e+00 },
+ { -2.427741611338014e-09, 2.673570307418169e+00 },
+ { -2.437715569009093e-09, 2.682271728006635e+00 },
+ { -2.447597748066437e-09, 2.690913803917100e+00 },
+ { -2.457387776452357e-09, 2.699495824053297e+00 },
+ { -2.467085285577292e-09, 2.708017078025636e+00 },
+ { -2.476689910335470e-09, 2.716476856194105e+00 },
+ { -2.486201289118733e-09, 2.724874449709689e+00 },
+ { -2.495619063828443e-09, 2.733209150554255e+00 },
+ { -2.504942879891263e-09, 2.741480251583985e+00 },
+ { -2.514172386270163e-09, 2.749687046568741e+00 },
+ { -2.523307235480146e-09, 2.757828830235740e+00 },
+ { -2.532347083598520e-09, 2.765904898308531e+00 },
+ { -2.541291590280960e-09, 2.773914547551261e+00 },
+ { -2.550140418771202e-09, 2.781857075807392e+00 },
+ { -2.558893235915887e-09, 2.789731782043156e+00 },
+ { -2.567549712176927e-09, 2.797537966388929e+00 },
+ { -2.576109521642196e-09, 2.805274930179221e+00 },
+ { -2.584572342040407e-09, 2.812941975996573e+00 },
+ { -2.592937854750428e-09, 2.820538407710556e+00 },
+ { -2.601205744816134e-09, 2.828063530521908e+00 },
+ { -2.609375700955458e-09, 2.835516651001539e+00 },
+ { -2.617447415574869e-09, 2.842897077134583e+00 },
+ { -2.625420584778350e-09, 2.850204118359573e+00 },
+ { -2.633294908380520e-09, 2.857437085611509e+00 },
+ { -2.641070089918234e-09, 2.864595291363663e+00 },
+ { -2.648745836659391e-09, 2.871678049666939e+00 },
+ { -2.656321859617343e-09, 2.878684676194483e+00 },
+ { -2.663797873558322e-09, 2.885614488280000e+00 },
+ { -2.671173597015318e-09, 2.892466804962122e+00 },
+ { -2.678448752295859e-09, 2.899240947023252e+00 },
+ { -2.685623065495139e-09, 2.905936237033475e+00 },
+ { -2.692696266503800e-09, 2.912551999389617e+00 },
+ { -2.699668089019767e-09, 2.919087560358171e+00 },
+ { -2.706538270558513e-09, 2.925542248116882e+00 },
+ { -2.713306552460767e-09, 2.931915392794031e+00 },
+ { -2.719972679905295e-09, 2.938206326512581e+00 },
+ { -2.726536401915442e-09, 2.944414383428562e+00 },
+ { -2.732997471371516e-09, 2.950538899775061e+00 },
+ { -2.739355645017194e-09, 2.956579213900666e+00 },
+ { -2.745610683471516e-09, 2.962534666313284e+00 },
+ { -2.751762351235315e-09, 2.968404599718795e+00 },
+ { -2.757810416701751e-09, 2.974188359063684e+00 },
+ { -2.763754652165128e-09, 2.979885291576143e+00 },
+ { -2.769594833827588e-09, 2.985494746805227e+00 },
+ { -2.775330741810390e-09, 2.991016076664491e+00 },
+ { -2.780962160159068e-09, 2.996448635469842e+00 },
+ { -2.786488876854607e-09, 3.001791779983262e+00 },
+ { -2.791910683818570e-09, 3.007044869450794e+00 },
+ { -2.797227376923695e-09, 3.012207265645876e+00 },
+ { -2.802438755998943e-09, 3.017278332907412e+00 },
+ { -2.807544624838820e-09, 3.022257438182037e+00 },
+ { -2.812544791210840e-09, 3.027143951064684e+00 },
+ { -2.817439066860792e-09, 3.031937243837070e+00 },
+ { -2.822227267522746e-09, 3.036636691510884e+00 },
+ { -2.826909212922864e-09, 3.041241671864994e+00 },
+ { -2.831484726789317e-09, 3.045751565488710e+00 },
+ { -2.835953636855826e-09, 3.050165755818853e+00 },
+ { -2.840315774871260e-09, 3.054483629182857e+00 },
+ { -2.844570976602957e-09, 3.058704574835744e+00 },
+ { -2.848719081844986e-09, 3.062827985002047e+00 },
+ { -2.852759934424164e-09, 3.066853254915581e+00 },
+ { -2.856693382203833e-09, 3.070779782857041e+00 },
+ { -2.860519277092708e-09, 3.074606970196721e+00 },
+ { -2.864237475047239e-09, 3.078334221430809e+00 },
+ { -2.867847836080156e-09, 3.081960944223928e+00 },
+ { -2.871350224262603e-09, 3.085486549445314e+00 },
+ { -2.874744507732462e-09, 3.088910451211251e+00 },
+ { -2.878030558696270e-09, 3.092232066921130e+00 },
+ { -2.881208253436038e-09, 3.095450817298478e+00 },
+ { -2.884277472313999e-09, 3.098566126429974e+00 },
+ { -2.887238099774968e-09, 3.101577421802070e+00 },
+ { -2.890090024353816e-09, 3.104484134342861e+00 },
+ { -2.892833138676371e-09, 3.107285698457308e+00 },
+ { -2.895467339466766e-09, 3.109981552069083e+00 },
+ { -2.897992527547963e-09, 3.112571136655481e+00 },
+ { -2.900408607848946e-09, 3.115053897289195e+00 },
+ { -2.902715489404992e-09, 3.117429282673042e+00 },
+ { -2.904913085363323e-09, 3.119696745180238e+00 },
+ { -2.907001312986328e-09, 3.121855740892224e+00 },
+ { -2.908980093652563e-09, 3.123905729634218e+00 },
+ { -2.910849352862924e-09, 3.125846175016163e+00 },
+ { -2.912609020239985e-09, 3.127676544466606e+00 },
+ { -2.914259029534118e-09, 3.129396309273659e+00 },
+ { -2.915799318622574e-09, 3.131004944618667e+00 },
+ { -2.917229829515169e-09, 3.132501929616775e+00 },
+ { -2.918550508353347e-09, 3.133886747350606e+00 },
+ { -2.919761305414294e-09, 3.135158884909254e+00 },
+ { -2.920862175112829e-09, 3.136317833424958e+00 },
+ { -2.921853076000972e-09, 3.137363088107359e+00 },
+ { -2.922733970772719e-09, 3.138294148283254e+00 },
+ { -2.923504826262027e-09, 3.139110517429204e+00 },
+ { -2.924165613447473e-09, 3.139811703211207e+00 },
+ { -2.924716307449950e-09, 3.140397217517018e+00 },
+ { -2.925156887536978e-09, 3.140866576495489e+00 },
+ { -2.925487337120335e-09, 3.141219300588825e+00 },
+ { -2.925707643758784e-09, 3.141454914570261e+00 },
+ { -2.925817799158535e-09, 3.141572947579352e+00 },
+ { -2.925817799171455e-09, 3.141572933154836e+00 },
+ { -2.925707643798390e-09, 3.141454409272987e+00 },
+ { -2.925487337185779e-09, 3.141216918378770e+00 },
+ { -2.925156887628892e-09, 3.140860007424112e+00 },
+ { -2.924716307568119e-09, 3.140383227898687e+00 },
+ { -2.924165613591896e-09, 3.139786135867868e+00 },
+ { -2.923504826432903e-09, 3.139068292003385e+00 },
+ { -2.922733970969412e-09, 3.138229261619561e+00 },
+ { -2.921853076224321e-09, 3.137268614707029e+00 },
+ { -2.920862175361976e-09, 3.136185925964038e+00 },
+ { -2.919761305690083e-09, 3.134980774833275e+00 },
+ { -2.918550508654911e-09, 3.133652745531368e+00 },
+ { -2.917229829843137e-09, 3.132201427085629e+00 },
+ { -2.915799318976726e-09, 3.130626413363146e+00 },
+ { -2.914259029914435e-09, 3.128927303107136e+00 },
+ { -2.912609020646661e-09, 3.127103699965947e+00 },
+ { -2.910849353295315e-09, 3.125155212527586e+00 },
+ { -2.908980094111509e-09, 3.123081454351802e+00 },
+ { -2.907001313470937e-09, 3.120882043999591e+00 },
+ { -2.904913085874448e-09, 3.118556605068443e+00 },
+ { -2.902715489941767e-09, 3.116104766219928e+00 },
+ { -2.900408608411958e-09, 3.113526161214776e+00 },
+ { -2.897992528137022e-09, 3.110820428940251e+00 },
+ { -2.895467340081818e-09, 3.107987213444579e+00 },
+ { -2.892833139317615e-09, 3.105026163964191e+00 },
+ { -2.890090025020589e-09, 3.101936934956479e+00 },
+ { -2.887238100468092e-09, 3.098719186130021e+00 },
+ { -2.884277473032614e-09, 3.095372582472161e+00 },
+ { -2.881208254180937e-09, 3.091896794282404e+00 },
+ { -2.878030559466594e-09, 3.088291497198199e+00 },
+ { -2.874744508528832e-09, 3.084556372228054e+00 },
+ { -2.871350225084755e-09, 3.080691105776848e+00 },
+ { -2.867847836928063e-09, 3.076695389678615e+00 },
+ { -2.864237475921086e-09, 3.072568921221621e+00 },
+ { -2.860519277991847e-09, 3.068311403179147e+00 },
+ { -2.856693383129018e-09, 3.063922543837792e+00 },
+ { -2.852759935374575e-09, 3.059402057023109e+00 },
+ { -2.848719082821403e-09, 3.054749662130841e+00 },
+ { -2.844570977604520e-09, 3.049965084150782e+00 },
+ { -2.840315775898525e-09, 3.045048053697736e+00 },
+ { -2.835953637908582e-09, 3.039998307034967e+00 },
+ { -2.831484727867511e-09, 3.034815586104635e+00 },
+ { -2.826909214026628e-09, 3.029499638550941e+00 },
+ { -2.822227268651470e-09, 3.024050217748861e+00 },
+ { -2.817439068015245e-09, 3.018467082830179e+00 },
+ { -2.812544792390175e-09, 3.012749998707001e+00 },
+ { -2.807544626043751e-09, 3.006898736100911e+00 },
+ { -2.802438757228650e-09, 3.000913071564665e+00 },
+ { -2.797227378178760e-09, 2.994792787510961e+00 },
+ { -2.791910685098702e-09, 2.988537672233504e+00 },
+ { -2.786488878159805e-09, 2.982147519935565e+00 },
+ { -2.780962161489413e-09, 2.975622130750641e+00 },
+ { -2.775330743165298e-09, 2.968961310769028e+00 },
+ { -2.769594835207775e-09, 2.962164872061613e+00 },
+ { -2.763754653569747e-09, 2.955232632701135e+00 },
+ { -2.757810418131543e-09, 2.948164416789036e+00 },
+ { -2.751762352689432e-09, 2.940960054474719e+00 },
+ { -2.745610684950541e-09, 2.933619381982341e+00 },
+ { -2.739355646520809e-09, 2.926142241629213e+00 },
+ { -2.732997472899722e-09, 2.918528481852205e+00 },
+ { -2.726536403468318e-09, 2.910777957226018e+00 },
+ { -2.719972681482232e-09, 2.902890528487386e+00 },
+ { -2.713306554062453e-09, 2.894866062556452e+00 },
+ { -2.706538272184154e-09, 2.886704432555728e+00 },
+ { -2.699668090670078e-09, 2.878405517834426e+00 },
+ { -2.692696268177908e-09, 2.869969203985464e+00 },
+ { -2.685623067193599e-09, 2.861395382869544e+00 },
+ { -2.678448754018380e-09, 2.852683952631486e+00 },
+ { -2.671173598761847e-09, 2.843834817723832e+00 },
+ { -2.663797875328991e-09, 2.834847888922988e+00 },
+ { -2.656321861411517e-09, 2.825723083350459e+00 },
+ { -2.648745838477759e-09, 2.816460324492298e+00 },
+ { -2.641070091759922e-09, 2.807059542215146e+00 },
+ { -2.633294910246296e-09, 2.797520672788269e+00 },
+ { -2.625420586667340e-09, 2.787843658897949e+00 },
+ { -2.617447417487602e-09, 2.778028449668942e+00 },
+ { -2.609375702891616e-09, 2.768075000678399e+00 },
+ { -2.601205746775692e-09, 2.757983273976943e+00 },
+ { -2.592937856733464e-09, 2.747753238101915e+00 },
+ { -2.584572344046340e-09, 2.737384868096553e+00 },
+ { -2.576109523671634e-09, 2.726878145526201e+00 },
+ { -2.567549714229129e-09, 2.716233058492422e+00 },
+ { -2.558893237991435e-09, 2.705449601651722e+00 },
+ { -2.550140420869302e-09, 2.694527776227857e+00 },
+ { -2.541291592402089e-09, 2.683467590030445e+00 },
+ { -2.532347085742440e-09, 2.672269057466213e+00 },
+ { -2.523307237646751e-09, 2.660932199557362e+00 },
+ { -2.514172388459584e-09, 2.649457043952206e+00 },
+ { -2.504942882102813e-09, 2.637843624941622e+00 },
+ { -2.495619066062810e-09, 2.626091983472908e+00 },
+ { -2.486201291375123e-09, 2.614202167160335e+00 },
+ { -2.476689912614465e-09, 2.602174230302269e+00 },
+ { -2.467085287878098e-09, 2.590008233889805e+00 },
+ { -2.457387778775451e-09, 2.577704245623143e+00 },
+ { -2.447597750411553e-09, 2.565262339920002e+00 },
+ { -2.437715571376127e-09, 2.552682597931055e+00 },
+ { -2.427741613727123e-09, 2.539965107548168e+00 },
+ { -2.417676252978335e-09, 2.527109963417675e+00 },
+ { -2.407519868085581e-09, 2.514117266951687e+00 },
+ { -2.397272841430131e-09, 2.500987126335739e+00 },
+ { -2.386935558807595e-09, 2.487719656543254e+00 },
+ { -2.376508409410024e-09, 2.474314979341178e+00 },
+ { -2.365991785814531e-09, 2.460773223303822e+00 },
+ { -2.355386083965131e-09, 2.447094523817833e+00 },
+ { -2.344691703161363e-09, 2.433279023095734e+00 },
+ { -2.333909046040126e-09, 2.419326870180582e+00 },
+ { -2.323038518562289e-09, 2.405238220956597e+00 },
+ { -2.312080529997549e-09, 2.391013238157397e+00 },
+ { -2.301035492907384e-09, 2.376652091371587e+00 },
+ { -2.289903823131822e-09, 2.362154957053137e+00 },
+ { -2.278685939771276e-09, 2.347522018525197e+00 },
+ { -2.267382265173420e-09, 2.332753465990296e+00 },
+ { -2.255993224914501e-09, 2.317849496533128e+00 },
+ { -2.244519247786155e-09, 2.302810314130351e+00 },
+ { -2.232960765776561e-09, 2.287636129652823e+00 },
+ { -2.221318214056095e-09, 2.272327160873552e+00 },
+ { -2.209592030960763e-09, 2.256883632472565e+00 },
+ { -2.197782657974034e-09, 2.241305776039511e+00 },
+ { -2.185890539712767e-09, 2.225593830081461e+00 },
+ { -2.173916123907886e-09, 2.209748040023618e+00 },
+ { -2.161859861389976e-09, 2.193768658216360e+00 },
+ { -2.149722206070124e-09, 2.177655943935795e+00 },
+ { -2.137503614923981e-09, 2.161410163388424e+00 },
+ { -2.125204547975352e-09, 2.145031589714984e+00 },
+ { -2.112825468276292e-09, 2.128520502989477e+00 },
+ { -2.100366841892917e-09, 2.111877190225612e+00 },
+ { -2.087829137884807e-09, 2.095101945374541e+00 },
+ { -2.075212828290086e-09, 2.078195069329960e+00 },
+ { -2.062518388104923e-09, 2.061156869925600e+00 },
+ { -2.049746295268559e-09, 2.043987661939897e+00 },
+ { -2.036897030642658e-09, 2.026687767092888e+00 },
+ { -2.023971077994576e-09, 2.009257514048162e+00 },
+ { -2.010968923979840e-09, 1.991697238413571e+00 },
+ { -1.997891058121344e-09, 1.974007282737320e+00 },
+ { -1.984737972794098e-09, 1.956187996511354e+00 },
+ { -1.971510163203686e-09, 1.938239736166060e+00 },
+ { -1.958208127370276e-09, 1.920162865072273e+00 },
+ { -1.944832366107339e-09, 1.901957753535934e+00 },
+ { -1.931383383005451e-09, 1.883624778799427e+00 },
+ { -1.917861684410531e-09, 1.865164325035177e+00 },
+ { -1.904267779407432e-09, 1.846576783346324e+00 },
+ { -1.890602179798714e-09, 1.827862551760622e+00 },
+ { -1.876865400086483e-09, 1.809022035228338e+00 },
+ { -1.863057957452539e-09, 1.790055645617624e+00 },
+ { -1.849180371740008e-09, 1.770963801711725e+00 },
+ { -1.835233165431475e-09, 1.751746929201178e+00 },
+ { -1.821216863631569e-09, 1.732405460681919e+00 },
+ { -1.807131994045840e-09, 1.712939835648088e+00 },
+ { -1.792979086962494e-09, 1.693350500488565e+00 },
+ { -1.778758675229683e-09, 1.673637908477153e+00 },
+ { -1.764471294238191e-09, 1.653802519770021e+00 },
+ { -1.750117481899733e-09, 1.633844801396848e+00 },
+ { -1.735697778626995e-09, 1.613765227254186e+00 },
+ { -1.721212727314574e-09, 1.593564278099856e+00 },
+ { -1.706662873315474e-09, 1.573242441540939e+00 },
+ { -1.692048764423848e-09, 1.552800212030258e+00 },
+ { -1.677370950852395e-09, 1.532238090855187e+00 },
+ { -1.662629985213192e-09, 1.511556586131055e+00 },
+ { -1.647826422494560e-09, 1.490756212788764e+00 },
+ { -1.632960820042537e-09, 1.469837492568651e+00 },
+ { -1.618033737538645e-09, 1.448800954008929e+00 },
+ { -1.603045736978760e-09, 1.427647132435469e+00 },
+ { -1.587997382653428e-09, 1.406376569953373e+00 },
+ { -1.572889241124034e-09, 1.384989815432507e+00 },
+ { -1.557721881203696e-09, 1.363487424499449e+00 },
+ { -1.542495873934815e-09, 1.341869959524515e+00 },
+ { -1.527211792568486e-09, 1.320137989611176e+00 },
+ { -1.511870212541253e-09, 1.298292090581491e+00 },
+ { -1.496471711454994e-09, 1.276332844965754e+00 },
+ { -1.481016869054634e-09, 1.254260841988828e+00 },
+ { -1.465506267206068e-09, 1.232076677556547e+00 },
+ { -1.449940489875303e-09, 1.209780954243628e+00 },
+ { -1.434320123104372e-09, 1.187374281276747e+00 },
+ { -1.418645754991533e-09, 1.164857274523495e+00 },
+ { -1.402917975667710e-09, 1.142230556475749e+00 },
+ { -1.387137377275425e-09, 1.119494756236361e+00 },
+ { -1.371304553944712e-09, 1.096650509501278e+00 },
+ { -1.355420101772623e-09, 1.073698458546610e+00 },
+ { -1.339484618799891e-09, 1.050639252211352e+00 },
+ { -1.323498704988051e-09, 1.027473545880543e+00 },
+ { -1.307462962198534e-09, 1.004202001471034e+00 },
+ { -1.291377994167204e-09, 9.808252874104182e-01 },
+ { -1.275244406484394e-09, 9.573440786237052e-01 },
+ { -1.259062806570190e-09, 9.337590565128454e-01 },
+ { -1.242833803653464e-09, 9.100709089414796e-01 },
+ { -1.226558008746195e-09, 8.862803302125812e-01 },
+ { -1.210236034623253e-09, 8.623880210538113e-01 },
+ { -1.193868495797618e-09, 8.383946885959868e-01 },
+ { -1.177456008497777e-09, 8.143010463544786e-01 },
+ { -1.160999190645010e-09, 7.901078142102129e-01 },
+ { -1.144498661828833e-09, 7.658157183877095e-01 },
+ { -1.127955043284965e-09, 7.414254914366063e-01 },
+ { -1.111368957870986e-09, 7.169378722095157e-01 },
+ { -1.094741030044308e-09, 6.923536058430697e-01 },
+ { -1.078071885836393e-09, 6.676734437331688e-01 },
+ { -1.061362152831423e-09, 6.428981435165511e-01 },
+ { -1.044612460141255e-09, 6.180284690466404e-01 },
+ { -1.027823438382183e-09, 5.930651903718045e-01 },
+ { -1.010995719652015e-09, 5.680090837138436e-01 },
+ { -9.941299375042378e-10, 5.428609314418970e-01 },
+ { -9.772267269262058e-10, 5.176215220520872e-01 },
+ { -9.602867243141016e-10, 4.922916501421032e-01 },
+ { -9.433105674499058e-10, 4.668721163885412e-01 },
+ { -9.262988954758817e-10, 4.413637275202624e-01 },
+ { -9.092523488719689e-10, 4.157672962958654e-01 },
+ { -8.921715694311144e-10, 3.900836414778084e-01 },
+ { -8.750572002347607e-10, 3.643135878065193e-01 },
+ { -8.579098856296589e-10, 3.384579659762392e-01 },
+ { -8.407302712022458e-10, 3.125176126069478e-01 },
+ { -8.235190037551917e-10, 2.864933702193017e-01 },
+ { -8.062767312831008e-10, 2.603860872080448e-01 },
+ { -7.890041029479477e-10, 2.341966178147619e-01 },
+ { -7.717017690542486e-10, 2.079258220999725e-01 },
+ { -7.543703810250266e-10, 1.815745659161734e-01 },
+ { -7.370105913774597e-10, 1.551437208801425e-01 },
+ { -7.196230536974697e-10, 1.286341643433767e-01 },
+ { -7.022084226165876e-10, 1.020467793657360e-01 },
+ { -6.847673537853251e-10, 7.538245468350446e-02 },
+ { -6.673005038502516e-10, 4.864208468284503e-02 },
+ { -6.498085304282128e-10, 2.182656936863137e-02 },
+ { -6.322920920826137e-10, -5.063185663820913e-03 },
+ { -6.147518482969490e-10, -3.202626926150343e-02 },
+ { -5.971884594516681e-10, -5.906176474160862e-02 },
+ { -5.796025867984469e-10, -8.616874992366363e-02 },
+ { -5.619948924353588e-10, -1.133462971605448e-01 },
+ { -5.443660392823640e-10, -1.405934733692621e-01 },
+ { -5.267166910556339e-10, -1.679093400638023e-01 },
+ { -5.090475122431451e-10, -1.952929533862739e-01 },
+ { -4.913591680795342e-10, -2.227433641394564e-01 },
+ { -4.736523245210571e-10, -2.502596178194491e-01 },
+ { -4.559276482202303e-10, -2.778407546490776e-01 },
+ { -4.381858065011618e-10, -3.054858096104932e-01 },
+ { -4.204274673340870e-10, -3.331938124792702e-01 },
+ { -4.026532993105397e-10, -3.609637878577768e-01 },
+ { -3.848639716178888e-10, -3.887947552098022e-01 },
+ { -3.670601540142443e-10, -4.166857288948674e-01 },
+ { -3.492425168032583e-10, -4.446357182029681e-01 },
+ { -3.314117308088734e-10, -4.726437273896633e-01 },
+ { -3.135684673501752e-10, -5.007087557112619e-01 },
+ { -2.957133982159296e-10, -5.288297974607742e-01 },
+ { -2.778471956393828e-10, -5.570058420037128e-01 },
+ { -2.599705322729564e-10, -5.852358738143247e-01 },
+ { -2.420840811628366e-10, -6.135188725122560e-01 },
+ { -2.241885157240923e-10, -6.418538128986450e-01 },
+ { -2.062845097142585e-10, -6.702396649949099e-01 },
+ { -1.883727372093546e-10, -6.986753940779493e-01 },
+ { -1.704538725773087e-10, -7.271599607197149e-01 },
+ { -1.525285904532877e-10, -7.556923208240308e-01 },
+ { -1.345975657140748e-10, -7.842714256651911e-01 },
+ { -1.166614734526054e-10, -8.128962219265712e-01 },
+ { -9.872098895260891e-11, -8.415656517393372e-01 },
+ { -8.077678766314517e-11, -8.702786527215916e-01 },
+ { -6.282954517324612e-11, -8.990341580176152e-01 },
+ { -4.487993718655790e-11, -9.278310963373758e-01 },
+ { -2.692863949561210e-11, -9.566683919968972e-01 },
+ { -8.976327956520795e-12, -9.855449649582175e-01 },
+ { 8.976321536169872e-12, -1.014459730869357e+00 },
+ { 2.692863307547294e-11, -1.043411601105914e+00 },
+ { 4.487993076694813e-11, -1.072399482811314e+00 },
+ { 6.282953875437751e-11, -1.101422278938424e+00 },
+ { 8.077678124517653e-11, -1.130478888291020e+00 },
+ { 9.872098253591082e-11, -1.159568205565684e+00 },
+ { 1.166614670373367e-10, -1.188689121393192e+00 },
+ { 1.345975593005002e-10, -1.217840522381901e+00 },
+ { 1.525285840416718e-10, -1.247021291159495e+00 },
+ { 1.704538661678104e-10, -1.276230306415868e+00 },
+ { 1.883727308022916e-10, -1.305466442946703e+00 },
+ { 2.062845033098954e-10, -1.334728571696106e+00 },
+ { 2.241885093225349e-10, -1.364015559800721e+00 },
+ { 2.420840747645085e-10, -1.393326270633325e+00 },
+ { 2.599705258779635e-10, -1.422659563847049e+00 },
+ { 2.778471892479898e-10, -1.452014295419243e+00 },
+ { 2.957133918284542e-10, -1.481389317696831e+00 },
+ { 3.135684609667761e-10, -1.510783479440191e+00 },
+ { 3.314117244297624e-10, -1.540195625869043e+00 },
+ { 3.492425104288060e-10, -1.569624598707558e+00 },
+ { 3.670601476445565e-10, -1.599069236228850e+00 },
+ { 3.848639652533361e-10, -1.628528373302631e+00 },
+ { 4.026532929512281e-10, -1.658000841439269e+00 },
+ { 4.204274609803869e-10, -1.687485468837799e+00 },
+ { 4.381858001531792e-10, -1.716981080430596e+00 },
+ { 4.559276418782829e-10, -1.746486497931567e+00 },
+ { 4.736523181853565e-10, -1.776000539882225e+00 },
+ { 4.913591617503452e-10, -1.805522021699094e+00 },
+ { 5.090475059206794e-10, -1.835049755721194e+00 },
+ { 5.267166847401562e-10, -1.864582551257262e+00 },
+ { 5.443660329740862e-10, -1.894119214633676e+00 },
+ { 5.619948861345454e-10, -1.923658549242818e+00 },
+ { 5.796025805053097e-10, -1.953199355591180e+00 },
+ { 5.971884531664190e-10, -1.982740431347091e+00 },
+ { 6.147518420199055e-10, -2.012280571390674e+00 },
+ { 6.322920858139346e-10, -2.041818567861395e+00 },
+ { 6.498085241682158e-10, -2.071353210208005e+00 },
+ { 6.673004975990425e-10, -2.100883285238127e+00 },
+ { 6.847673475432746e-10, -2.130407577166309e+00 },
+ { 7.022084163838545e-10, -2.159924867664933e+00 },
+ { 7.196230474743716e-10, -2.189433935913779e+00 },
+ { 7.370105851640495e-10, -2.218933558650552e+00 },
+ { 7.543703748217808e-10, -2.248422510220072e+00 },
+ { 7.717017628611672e-10, -2.277899562625407e+00 },
+ { 7.890040967654542e-10, -2.307363485579104e+00 },
+ { 8.062767251113011e-10, -2.336813046552684e+00 },
+ { 8.235189975944034e-10, -2.366247010829556e+00 },
+ { 8.407302650525749e-10, -2.395664141553858e+00 },
+ { 8.579098794915287e-10, -2.425063199784153e+00 },
+ { 8.750571941082773e-10, -2.454442944543319e+00 },
+ { 8.921715633164894e-10, -2.483802132872044e+00 },
+ { 9.092523427695200e-10, -2.513139519878584e+00 },
+ { 9.262988893857148e-10, -2.542453858792682e+00 },
+ { 9.433105613723914e-10, -2.571743901017465e+00 },
+ { 9.602867182493987e-10, -2.601008396180870e+00 },
+ { 9.772267208744730e-10, -2.630246092190425e+00 },
+ { 9.941299314658458e-10, -2.659455735283526e+00 },
+ { 1.010995713627070e-09, -2.688636070081818e+00 },
+ { 1.027823432371055e-09, -2.717785839644439e+00 },
+ { 1.044612454143997e-09, -2.746903785521352e+00 },
+ { 1.061362146848353e-09, -2.775988647805256e+00 },
+ { 1.078071879867828e-09, -2.805039165187255e+00 },
+ { 1.094741024090249e-09, -2.834054075009077e+00 },
+ { 1.111368951931856e-09, -2.863032113318052e+00 },
+ { 1.127955037360817e-09, -2.891972014920939e+00 },
+ { 1.144498655920037e-09, -2.920872513436805e+00 },
+ { 1.160999184751779e-09, -2.949732341353290e+00 },
+ { 1.177456002620215e-09, -2.978550230079517e+00 },
+ { 1.193868489936097e-09, -3.007324910002949e+00 },
+ { 1.210236028777826e-09, -3.036055110540183e+00 },
+ { 1.226558002917232e-09, -3.064739560196251e+00 },
+ { 1.242833797841123e-09, -3.093376986616735e+00 },
+ { 1.259062800774685e-09, -3.121966116643377e+00 },
+ { 1.275244400705935e-09, -3.150505676371791e+00 },
+ { 1.291377988406056e-09, -3.178994391202159e+00 },
+ { 1.307462956454857e-09, -3.207430985899192e+00 },
+ { 1.323498699262108e-09, -3.235814184645077e+00 },
+ { 1.339484613091842e-09, -3.264142711097884e+00 },
+ { 1.355420096082785e-09, -3.292415288443373e+00 },
+ { 1.371304548273191e-09, -3.320630639454825e+00 },
+ { 1.387137371622433e-09, -3.348787486547389e+00 },
+ { 1.402917970033511e-09, -3.376884551834256e+00 },
+ { 1.418645749376393e-09, -3.404920557184582e+00 },
+ { 1.434320117508396e-09, -3.432894224276359e+00 },
+ { 1.449940484298756e-09, -3.460804274656981e+00 },
+ { 1.465506261649108e-09, -3.488649429796768e+00 },
+ { 1.481016863517580e-09, -3.516428411149154e+00 },
+ { 1.496471705937951e-09, -3.544139940202303e+00 },
+ { 1.511870207044433e-09, -3.571782738540999e+00 },
+ { 1.527211787092206e-09, -3.599355527901174e+00 },
+ { 1.542495868479076e-09, -3.626857030226671e+00 },
+ { 1.557721875768920e-09, -3.654285967729458e+00 },
+ { 1.572889235710329e-09, -3.681641062941412e+00 },
+ { 1.587997377261005e-09, -3.708921038776707e+00 },
+ { 1.603045731607830e-09, -3.736124618586623e+00 },
+ { 1.618033732189314e-09, -3.763250526218862e+00 },
+ { 1.632960814715177e-09, -3.790297486071938e+00 },
+ { 1.647826417189275e-09, -3.817264223155802e+00 },
+ { 1.662629979930247e-09, -3.844149463148589e+00 },
+ { 1.677370945591844e-09, -3.870951932452996e+00 },
+ { 1.692048759186008e-09, -3.897670358257890e+00 },
+ { 1.706662868100504e-09, -3.924303468590212e+00 },
+ { 1.721212722122685e-09, -3.950849992378278e+00 },
+ { 1.735697773458400e-09, -3.977308659506432e+00 },
+ { 1.750117476754591e-09, -4.003678200876669e+00 },
+ { 1.764471289116712e-09, -4.029957348461003e+00 },
+ { 1.778758670132079e-09, -4.056144835364877e+00 },
+ { 1.792979081888926e-09, -4.082239395882965e+00 },
+ { 1.807131988996465e-09, -4.108239765556996e+00 },
+ { 1.821216858606652e-09, -4.134144681236933e+00 },
+ { 1.835233160431175e-09, -4.159952881133585e+00 },
+ { 1.849180366764537e-09, -4.185663104882633e+00 },
+ { 1.863057952502055e-09, -4.211274093599509e+00 },
+ { 1.876865395161145e-09, -4.236784589940537e+00 },
+ { 1.890602174898734e-09, -4.262193338157148e+00 },
+ { 1.904267774533022e-09, -4.287499084158302e+00 },
+ { 1.917861679562008e-09, -4.312700575567174e+00 },
+ { 1.931383378182392e-09, -4.337796561778708e+00 },
+ { 1.944832361310856e-09, -4.362785794021793e+00 },
+ { 1.958208122599839e-09, -4.387667025411434e+00 },
+ { 1.971510158459931e-09, -4.412439011013396e+00 },
+ { 1.984737968076495e-09, -4.437100507898339e+00 },
+ { 1.997891053431005e-09, -4.461650275204912e+00 },
+ { 2.010968919316289e-09, -4.486087074191693e+00 },
+ { 2.023971073358447e-09, -4.510409668301784e+00 },
+ { 2.036897026033634e-09, -4.534616823217992e+00 },
+ { 2.049746290686799e-09, -4.558707306921882e+00 },
+ { 2.062518383551274e-09, -4.582679889754607e+00 },
+ { 2.075212823764071e-09, -4.606533344469879e+00 },
+ { 2.087829133387063e-09, -4.630266446298172e+00 },
+ { 2.100366837422912e-09, -4.653877973001258e+00 },
+ { 2.112825463835087e-09, -4.677366704934605e+00 },
+ { 2.125204543562522e-09, -4.700731425099899e+00 },
+ { 2.137503610540056e-09, -4.723970919208608e+00 },
+ { 2.149722201714786e-09, -4.747083975738060e+00 },
+ { 2.161859857063438e-09, -4.770069385989595e+00 },
+ { 2.173916119610994e-09, -4.792925944149308e+00 },
+ { 2.185890535445098e-09, -4.815652447340950e+00 },
+ { 2.197782653735957e-09, -4.838247695689436e+00 },
+ { 2.209592026751962e-09, -4.860710492376411e+00 },
+ { 2.221318209877576e-09, -4.883039643700314e+00 },
+ { 2.232960761627846e-09, -4.905233959130168e+00 },
+ { 2.244519243667616e-09, -4.927292251368517e+00 },
+ { 2.255993220826402e-09, -4.949213336406265e+00 },
+ { 2.267382261115285e-09, -4.970996033581527e+00 },
+ { 2.278685935744269e-09, -4.992639165639563e+00 },
+ { 2.289903819135414e-09, -5.014141558784778e+00 },
+ { 2.301035488942000e-09, -5.035502042744443e+00 },
+ { 2.312080526062763e-09, -5.056719450823151e+00 },
+ { 2.323038514659161e-09, -5.077792619963239e+00 },
+ { 2.333909042168180e-09, -5.098720390796817e+00 },
+ { 2.344691699320969e-09, -5.119501607709159e+00 },
+ { 2.355386080156553e-09, -5.140135118892792e+00 },
+ { 2.365991782037187e-09, -5.160619776404897e+00 },
+ { 2.376508405665132e-09, -5.180954436227641e+00 },
+ { 2.386935555094626e-09, -5.201137958319343e+00 },
+ { 2.397272837749508e-09, -5.221169206676762e+00 },
+ { 2.407519864436774e-09, -5.241047049389645e+00 },
+ { 2.417676249362563e-09, -5.260770358700167e+00 },
+ { 2.427741610143750e-09, -5.280338011053974e+00 },
+ { 2.437715567825576e-09, -5.299748887163106e+00 },
+ { 2.447597746894037e-09, -5.319001872058887e+00 },
+ { 2.457387775290440e-09, -5.338095855149190e+00 },
+ { 2.467085284426756e-09, -5.357029730277389e+00 },
+ { 2.476689909196263e-09, -5.375802395772283e+00 },
+ { 2.486201287990485e-09, -5.394412754510426e+00 },
+ { 2.495619062711154e-09, -5.412859713968929e+00 },
+ { 2.504942878785408e-09, -5.431142186284682e+00 },
+ { 2.514172385175743e-09, -5.449259088303476e+00 },
+ { 2.523307234396791e-09, -5.467209341642627e+00 },
+ { 2.532347082526785e-09, -5.484991872743321e+00 },
+ { 2.541291589219998e-09, -5.502605612925014e+00 },
+ { 2.550140417722072e-09, -5.520049498445633e+00 },
+ { 2.558893234878378e-09, -5.537322470548212e+00 },
+ { 2.567549711150773e-09, -5.554423475524196e+00 },
+ { 2.576109520627371e-09, -5.571351464763084e+00 },
+ { 2.584572341037361e-09, -5.588105394812198e+00 },
+ { 2.592937853759161e-09, -5.604684227423386e+00 },
+ { 2.601205743836355e-09, -5.621086929615246e+00 },
+ { 2.609375699987564e-09, -5.637312473723475e+00 },
+ { 2.617447414618146e-09, -5.653359837454964e+00 },
+ { 2.625420583833750e-09, -5.669228003945694e+00 },
+ { 2.633294907447937e-09, -5.684915961806963e+00 },
+ { 2.641070088997271e-09, -5.700422705186584e+00 },
+ { 2.648745835750128e-09, -5.715747233817712e+00 },
+ { 2.656321858720176e-09, -5.730888553077074e+00 },
+ { 2.663797872673252e-09, -5.745845674030161e+00 },
+ { 2.671173596142054e-09, -5.760617613492118e+00 },
+ { 2.678448751434797e-09, -5.775203394076705e+00 },
+ { 2.685623064645538e-09, -5.789602044248679e+00 },
+ { 2.692696265666640e-09, -5.803812598380606e+00 },
+ { 2.699668088194915e-09, -5.817834096797069e+00 },
+ { 2.706538269745573e-09, -5.831665585834668e+00 },
+ { 2.713306551659817e-09, -5.845306117889361e+00 },
+ { 2.719972679116734e-09, -5.858754751472542e+00 },
+ { 2.726536401139295e-09, -5.872010551255358e+00 },
+ { 2.732997470607439e-09, -5.885072588127400e+00 },
+ { 2.739355644265558e-09, -5.897939939244211e+00 },
+ { 2.745610682731633e-09, -5.910611688078208e+00 },
+ { 2.751762350508137e-09, -5.923086924473290e+00 },
+ { 2.757810415987146e-09, -5.935364744687794e+00 },
+ { 2.763754651462700e-09, -5.947444251452243e+00 },
+ { 2.769594833137415e-09, -5.959324554015538e+00 },
+ { 2.775330741132843e-09, -5.971004768198829e+00 },
+ { 2.780962159494174e-09, -5.982484016437981e+00 },
+ { 2.786488876202047e-09, -5.993761427840588e+00 },
+ { 2.791910683178690e-09, -6.004836138231525e+00 },
+ { 2.797227376295779e-09, -6.015707290202086e+00 },
+ { 2.802438755383971e-09, -6.026374033162623e+00 },
+ { 2.807544624236659e-09, -6.036835523383457e+00 },
+ { 2.812544790621093e-09, -6.047090924050914e+00 },
+ { 2.817439066283459e-09, -6.057139405311101e+00 },
+ { 2.822227266958278e-09, -6.066980144322601e+00 },
+ { 2.826909212371261e-09, -6.076612325295799e+00 },
+ { 2.831484726250221e-09, -6.086035139548830e+00 },
+ { 2.835953636329660e-09, -6.095247785550617e+00 },
+ { 2.840315774357203e-09, -6.104249468967751e+00 },
+ { 2.844570976102082e-09, -6.113039402715685e+00 },
+ { 2.848719081357095e-09, -6.121616806996519e+00 },
+ { 2.852759933948860e-09, -6.129980909353977e+00 },
+ { 2.856693381741114e-09, -6.138130944714082e+00 },
+ { 2.860519276643053e-09, -6.146066155436312e+00 },
+ { 2.864237474610633e-09, -6.153785791350256e+00 },
+ { 2.867847835656203e-09, -6.161289109809551e+00 },
+ { 2.871350223851726e-09, -6.168575375732642e+00 },
+ { 2.874744507333867e-09, -6.175643861647406e+00 },
+ { 2.878030558310989e-09, -6.182493847739853e+00 },
+ { 2.881208253063899e-09, -6.189124621889823e+00 },
+ { 2.884277471954592e-09, -6.195535479723423e+00 },
+ { 2.887238099428306e-09, -6.201725724651554e+00 },
+ { 2.890090024020323e-09, -6.207694667918394e+00 },
+ { 2.892833138356060e-09, -6.213441628635915e+00 },
+ { 2.895467339159240e-09, -6.218965933835304e+00 },
+ { 2.897992527253659e-09, -6.224266918505075e+00 },
+ { 2.900408607567016e-09, -6.229343925633495e+00 },
+ { 2.902715489136496e-09, -6.234196306254763e+00 },
+ { 2.904913085108075e-09, -6.238823419482017e+00 },
+ { 2.907001312743911e-09, -6.243224632557377e+00 },
+ { 2.908980093422997e-09, -6.247399320887848e+00 },
+ { 2.910849352646620e-09, -6.251346868091392e+00 },
+ { 2.912609020036956e-09, -6.255066666028537e+00 },
+ { 2.914259029343965e-09, -6.258558114851525e+00 },
+ { 2.915799318445710e-09, -6.261820623039620e+00 },
+ { 2.917229829350759e-09, -6.264853607438842e+00 },
+ { 2.918550508202463e-09, -6.267656493305673e+00 },
+ { 2.919761305276718e-09, -6.270228714337005e+00 },
+ { 2.920862174988150e-09, -6.272569712717951e+00 },
+ { 2.921853075889193e-09, -6.274678939154603e+00 },
+ { 2.922733970674264e-09, -6.276555852917634e+00 },
+ { 2.923504826176907e-09, -6.278199921870962e+00 },
+ { 2.924165613375264e-09, -6.279610622518139e+00 },
+ { 2.924716307391075e-09, -6.280787440034993e+00 },
+ { 2.925156887490598e-09, -6.281729868306345e+00 },
+ { 2.925487337087508e-09, -6.282437409966992e+00 },
+ { 2.925707643739298e-09, -6.282909576428774e+00 },
+ { 2.925817799151970e-09, -6.283145887925411e+00 },
diff --git a/gr-blocks/lib/skiphead_impl.cc b/gr-blocks/lib/skiphead_impl.cc
new file mode 100644
index 0000000000..feb39eb8f4
--- /dev/null
+++ b/gr-blocks/lib/skiphead_impl.cc
@@ -0,0 +1,93 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2005,2007,2010,2013 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "skiphead_impl.h"
+#include <gr_io_signature.h>
+#include <string.h>
+
+namespace gr {
+ namespace blocks {
+
+ skiphead::sptr
+ skiphead::make(size_t itemsize, uint64_t nitems_to_skip)
+ {
+ return gnuradio::get_initial_sptr
+ (new skiphead_impl(itemsize, nitems_to_skip));
+ }
+
+ skiphead_impl::skiphead_impl(size_t itemsize, uint64_t nitems_to_skip)
+ : gr_block("skiphead",
+ gr_make_io_signature(1, 1, itemsize),
+ gr_make_io_signature(1, 1, itemsize)),
+ d_nitems_to_skip(nitems_to_skip), d_nitems(0)
+ {
+ }
+
+ skiphead_impl::~skiphead_impl()
+ {
+ }
+
+ int
+ skiphead_impl::general_work(int noutput_items,
+ gr_vector_int &ninput_items_,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ const char *in = (const char*)input_items[0];
+ char *out = (char*)output_items[0];
+
+ int ninput_items = std::min(ninput_items_[0], noutput_items);
+ int ii = 0; // input index
+
+ while (ii < ninput_items) {
+ uint64_t ni_total = ii + d_nitems; // total items processed so far
+ if(ni_total < d_nitems_to_skip) { // need to skip some more
+
+ int n_to_skip = (int)std::min(d_nitems_to_skip - ni_total,
+ (uint64_t)(ninput_items - ii));
+ ii += n_to_skip;
+ }
+
+ else { // nothing left to skip. copy away
+ int n_to_copy = ninput_items - ii;
+ if(n_to_copy > 0) {
+ size_t itemsize = output_signature()->sizeof_stream_item(0);
+ memcpy(out, in + (ii*itemsize), n_to_copy*itemsize);
+ }
+
+ d_nitems += ninput_items;
+ consume_each(ninput_items);
+ return n_to_copy;
+ }
+ }
+
+ d_nitems += ninput_items;
+ consume_each(ninput_items);
+ return 0;
+ }
+
+ } /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/skiphead_impl.h b/gr-blocks/lib/skiphead_impl.h
new file mode 100644
index 0000000000..d8e0870cb1
--- /dev/null
+++ b/gr-blocks/lib/skiphead_impl.h
@@ -0,0 +1,50 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2005,2013 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_SKIPHEAD_IMPL_H
+#define INCLUDED_GR_SKIPHEAD_IMPL_H
+
+#include <blocks/skiphead.h>
+
+namespace gr {
+ namespace blocks {
+
+ class skiphead_impl : public skiphead
+ {
+ private:
+ uint64_t d_nitems_to_skip;
+ uint64_t d_nitems; // total items seen
+
+ public:
+ skiphead_impl(size_t itemsize, uint64_t nitems_to_skip);
+ ~skiphead_impl();
+
+ int general_work(int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_GR_SKIPHEAD_IMPL_H */
diff --git a/gr-blocks/lib/socket_pdu_impl.cc b/gr-blocks/lib/socket_pdu_impl.cc
new file mode 100644
index 0000000000..0a48c2b9f4
--- /dev/null
+++ b/gr-blocks/lib/socket_pdu_impl.cc
@@ -0,0 +1,198 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2013 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "socket_pdu_impl.h"
+#include "tcp_connection.h"
+#include <gr_io_signature.h>
+#include <gr_pdu.h>
+
+namespace gr {
+ namespace blocks {
+
+ socket_pdu::sptr
+ socket_pdu::make(std::string type, std::string addr, std::string port, int MTU)
+ {
+ return gnuradio::get_initial_sptr(new socket_pdu_impl(type, addr, port, MTU));
+ }
+
+ socket_pdu_impl::socket_pdu_impl(std::string type, std::string addr, std::string port, int MTU)
+ : gr_block("socket_pdu",
+ gr_make_io_signature (0, 0, 0),
+ gr_make_io_signature (0, 0, 0))
+ {
+ message_port_register_in(PDU_PORT_ID);
+ message_port_register_out(PDU_PORT_ID);
+
+ if ((type == "TCP_SERVER") || (type == "TCP_CLIENT")) {
+ boost::asio::ip::tcp::resolver resolver(d_io_service);
+ boost::asio::ip::tcp::resolver::query query(boost::asio::ip::tcp::v4(), addr, port);
+ d_tcp_endpoint = *resolver.resolve(query);
+ }
+
+ if ((type == "UDP_SERVER") || (type == "UDP_CLIENT")) {
+ boost::asio::ip::udp::resolver resolver(d_io_service);
+ boost::asio::ip::udp::resolver::query query(boost::asio::ip::udp::v4(), addr, port);
+
+ if (type == "UDP_SERVER")
+ d_udp_endpoint = *resolver.resolve(query);
+ else
+ d_udp_endpoint_other = *resolver.resolve(query);
+ }
+
+ if (type == "TCP_SERVER") {
+ d_acceptor_tcp.reset(new boost::asio::ip::tcp::acceptor(d_io_service, d_tcp_endpoint));
+ d_acceptor_tcp->set_option(boost::asio::ip::tcp::acceptor::reuse_address(true));
+ start_tcp_accept();
+ set_msg_handler(PDU_PORT_ID, boost::bind(&socket_pdu_impl::tcp_server_send, this, _1));
+
+ }
+ else if (type =="TCP_CLIENT") {
+ boost::system::error_code error = boost::asio::error::host_not_found;
+ d_tcp_socket.reset(new boost::asio::ip::tcp::socket(d_io_service));
+ d_tcp_socket->connect(d_tcp_endpoint, error);
+ if (error)
+ throw boost::system::system_error(error);
+
+ set_msg_handler(PDU_PORT_ID, boost::bind(&socket_pdu_impl::tcp_client_send, this, _1));
+
+ d_tcp_socket->async_read_some(
+ boost::asio::buffer(d_rxbuf),
+ boost::bind(&socket_pdu_impl::handle_tcp_read, this,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred)
+ );
+ }
+ else if (type =="UDP_SERVER") {
+ d_udp_socket.reset(new boost::asio::ip::udp::socket(d_io_service, d_udp_endpoint));
+ d_udp_socket->async_receive_from(boost::asio::buffer(d_rxbuf), d_udp_endpoint_other,
+ boost::bind(&socket_pdu_impl::handle_udp_read, this,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred));
+ set_msg_handler(PDU_PORT_ID, boost::bind(&socket_pdu_impl::udp_send, this, _1));
+ }
+ else if (type =="UDP_CLIENT") {
+ d_udp_socket.reset(new boost::asio::ip::udp::socket(d_io_service, d_udp_endpoint));
+ d_udp_socket->async_receive_from(boost::asio::buffer(d_rxbuf), d_udp_endpoint_other,
+ boost::bind(&socket_pdu_impl::handle_udp_read, this,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred));
+ set_msg_handler(PDU_PORT_ID, boost::bind(&socket_pdu_impl::udp_send, this, _1));
+ }
+ else
+ throw std::runtime_error("gr::blocks:socket_pdu: unknown socket type");
+
+ d_thread = gruel::thread(boost::bind(&socket_pdu_impl::run_io_service, this));
+ d_started = true;
+ }
+
+ void
+ socket_pdu_impl::handle_tcp_read(const boost::system::error_code& error, size_t bytes_transferred)
+ {
+ if (!error) {
+ pmt::pmt_t vector = pmt::pmt_init_u8vector(bytes_transferred, (const uint8_t *)&d_rxbuf[0]);
+ pmt::pmt_t pdu = pmt::pmt_cons(pmt::PMT_NIL, vector);
+ message_port_pub(PDU_PORT_ID, pdu);
+
+ d_tcp_socket->async_read_some(boost::asio::buffer(d_rxbuf),
+ boost::bind(&socket_pdu_impl::handle_tcp_read, this,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred));
+ }
+ else
+ throw boost::system::system_error(error);
+ }
+
+ void
+ socket_pdu_impl::start_tcp_accept()
+ {
+ tcp_connection::sptr new_connection = tcp_connection::make(d_acceptor_tcp->get_io_service());
+
+ d_acceptor_tcp->async_accept(new_connection->socket(),
+ boost::bind(&socket_pdu_impl::handle_tcp_accept, this,
+ new_connection, boost::asio::placeholders::error));
+ }
+
+ void
+ socket_pdu_impl::tcp_server_send(pmt::pmt_t msg)
+ {
+ pmt::pmt_t vector = pmt::pmt_cdr(msg);
+ for(size_t i = 0; i < d_tcp_connections.size(); i++)
+ d_tcp_connections[i]->send(vector);
+ }
+
+ void
+ socket_pdu_impl::handle_tcp_accept(tcp_connection::sptr new_connection, const boost::system::error_code& error)
+ {
+ if (!error) {
+ new_connection->start(this);
+ d_tcp_connections.push_back(new_connection);
+ start_tcp_accept();
+ }
+ else
+ std::cout << error << std::endl;
+ }
+
+ void
+ socket_pdu_impl::tcp_client_send(pmt::pmt_t msg)
+ {
+ pmt::pmt_t vector = pmt::pmt_cdr(msg);
+ size_t len = pmt::pmt_length(vector);
+ size_t offset(0);
+ boost::array<char, 10000> txbuf;
+ memcpy(&txbuf[0], pmt::pmt_uniform_vector_elements(vector, offset), len);
+ d_tcp_socket->send(boost::asio::buffer(txbuf,len));
+ }
+
+ void
+ socket_pdu_impl::udp_send(pmt::pmt_t msg)
+ {
+ pmt::pmt_t vector = pmt::pmt_cdr(msg);
+ size_t len = pmt::pmt_length(vector);
+ size_t offset(0);
+ boost::array<char, 10000> txbuf;
+ memcpy(&txbuf[0], pmt::pmt_uniform_vector_elements(vector, offset), len);
+ if (d_udp_endpoint_other.address().to_string() != "0.0.0.0")
+ d_udp_socket->send_to(boost::asio::buffer(txbuf,len), d_udp_endpoint_other);
+ }
+
+ void
+ socket_pdu_impl::handle_udp_read(const boost::system::error_code& error, size_t bytes_transferred)
+ {
+ if (!error) {
+ pmt::pmt_t vector = pmt::pmt_init_u8vector(bytes_transferred, (const uint8_t*)&d_rxbuf[0]);
+ pmt::pmt_t pdu = pmt::pmt_cons( pmt::PMT_NIL, vector);
+
+ message_port_pub(PDU_PORT_ID, pdu);
+
+ d_udp_socket->async_receive_from(boost::asio::buffer(d_rxbuf), d_udp_endpoint_other,
+ boost::bind(&socket_pdu_impl::handle_udp_read, this,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred));
+ }
+ }
+
+ } /* namespace blocks */
+}/* namespace gr */
diff --git a/gr-blocks/lib/socket_pdu_impl.h b/gr-blocks/lib/socket_pdu_impl.h
new file mode 100644
index 0000000000..78602754c7
--- /dev/null
+++ b/gr-blocks/lib/socket_pdu_impl.h
@@ -0,0 +1,69 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2013 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_BLOCKS_SOCKET_PDU_IMPL_H
+#define INCLUDED_BLOCKS_SOCKET_PDU_IMPL_H
+
+#include <blocks/socket_pdu.h>
+#include "stream_pdu_base.h"
+#include "tcp_connection.h"
+
+namespace gr {
+ namespace blocks {
+
+ class socket_pdu_impl : public socket_pdu, public stream_pdu_base
+ {
+ private:
+ boost::asio::io_service d_io_service;
+ boost::array<char, 10000> d_rxbuf;
+ void run_io_service() { d_io_service.run(); }
+
+ // TCP specific
+ boost::asio::ip::tcp::endpoint d_tcp_endpoint;
+ std::vector<tcp_connection::sptr> d_tcp_connections;
+ void handle_tcp_read(const boost::system::error_code& error, size_t bytes_transferred);
+
+ // TCP server specific
+ boost::shared_ptr<boost::asio::ip::tcp::acceptor> d_acceptor_tcp;
+ void start_tcp_accept();
+ void tcp_server_send(pmt::pmt_t msg);
+ void handle_tcp_accept(tcp_connection::sptr new_connection, const boost::system::error_code& error);
+
+ // TCP client specific
+ boost::shared_ptr<boost::asio::ip::tcp::socket> d_tcp_socket;
+ void tcp_client_send(pmt::pmt_t msg);
+
+ // UDP specific
+ boost::asio::ip::udp::endpoint d_udp_endpoint;
+ boost::asio::ip::udp::endpoint d_udp_endpoint_other;
+ boost::shared_ptr<boost::asio::ip::udp::socket> d_udp_socket;
+ void handle_udp_read(const boost::system::error_code& error, size_t bytes_transferred);
+ void udp_send(pmt::pmt_t msg);
+
+ public:
+ socket_pdu_impl(std::string type, std::string addr, std::string port, int MTU);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_BLOCKS_SOCKET_PDU_IMPL_H */
diff --git a/gr-blocks/lib/stream_pdu_base.cc b/gr-blocks/lib/stream_pdu_base.cc
new file mode 100644
index 0000000000..21fbb5eabe
--- /dev/null
+++ b/gr-blocks/lib/stream_pdu_base.cc
@@ -0,0 +1,130 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2013 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#ifdef HAVE_IO_H
+#include <io.h>
+#endif
+
+#ifdef HAVE_WINDOWS_H
+#include <winsock2.h>
+#endif
+
+#include <blocks/pdu.h>
+#include <gr_basic_block.h>
+#include "stream_pdu_base.h"
+#include <boost/format.hpp>
+
+static const long timeout_us = 100*1000; //100ms
+
+namespace gr {
+ namespace blocks {
+
+ stream_pdu_base::stream_pdu_base(int MTU)
+ : d_fd(-1),
+ d_started(false),
+ d_finished(false)
+ {
+ // reserve space for rx buffer
+ d_rxbuf.resize(MTU,0);
+ }
+
+ stream_pdu_base::~stream_pdu_base()
+ {
+ stop_rxthread();
+ }
+
+ void
+ stream_pdu_base::start_rxthread(gr_basic_block *blk, pmt::pmt_t port)
+ {
+ d_blk = blk;
+ d_port = port;
+ d_thread = gruel::thread(boost::bind(&stream_pdu_base::run, this));
+ d_started = true;
+ }
+
+ void
+ stream_pdu_base::stop_rxthread()
+ {
+ d_finished = true;
+
+ if (d_started) {
+ d_thread.interrupt();
+ d_thread.join();
+ }
+ }
+
+ void
+ stream_pdu_base::run()
+ {
+ while(!d_finished) {
+ if (!wait_ready())
+ continue;
+
+ const int result = read(d_fd, &d_rxbuf[0], d_rxbuf.size());
+ if (result <= 0)
+ throw std::runtime_error("stream_pdu_base, bad socket read!");
+
+ pmt::pmt_t vector = pmt::pmt_init_u8vector(result, &d_rxbuf[0]);
+ pmt::pmt_t pdu = pmt::pmt_cons(pmt::PMT_NIL, vector);
+
+ d_blk->message_port_pub(d_port, pdu);
+ }
+ }
+
+ bool
+ stream_pdu_base::wait_ready()
+ {
+ //setup timeval for timeout
+ timeval tv;
+ tv.tv_sec = 0;
+ tv.tv_usec = timeout_us;
+
+ //setup rset for timeout
+ fd_set rset;
+ FD_ZERO(&rset);
+ FD_SET(d_fd, &rset);
+
+ //call select with timeout on receive socket
+ return ::select(d_fd+1, &rset, NULL, NULL, &tv) > 0;
+ }
+
+ void
+ stream_pdu_base::send(pmt::pmt_t msg)
+ {
+ pmt::pmt_t vector = pmt::pmt_cdr(msg);
+ size_t offset(0);
+ size_t itemsize(pdu::itemsize(pdu::type_from_pmt(vector)));
+ int len(pmt::pmt_length(vector)*itemsize);
+
+ const int rv = write(d_fd, pmt::pmt_uniform_vector_elements(vector, offset), len);
+ if (rv != len) {
+ std::cerr << boost::format("WARNING: stream_pdu_base::send(pdu) write failed! (d_fd=%d, len=%d, rv=%d)")
+ % d_fd % len % rv << std::endl;
+ }
+ }
+
+ } /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/stream_pdu_base.h b/gr-blocks/lib/stream_pdu_base.h
new file mode 100644
index 0000000000..66eaaf0c04
--- /dev/null
+++ b/gr-blocks/lib/stream_pdu_base.h
@@ -0,0 +1,60 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2013 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_STREAM_PDU_BASE_H
+#define INCLUDED_STREAM_PDU_BASE_H
+
+#include <gruel/thread.h>
+#include <gruel/pmt.h>
+
+class gr_basic_block;
+
+namespace gr {
+ namespace blocks {
+
+ class stream_pdu_base
+ {
+ public:
+ stream_pdu_base(int MTU=10000);
+ ~stream_pdu_base();
+
+ protected:
+ int d_fd;
+ bool d_started;
+ bool d_finished;
+ std::vector<uint8_t> d_rxbuf;
+ gruel::thread d_thread;
+
+ pmt::pmt_t d_port;
+ gr_basic_block *d_blk;
+
+ void run();
+ void send(pmt::pmt_t msg);
+ bool wait_ready();
+ void start_rxthread(gr_basic_block *blk, pmt::pmt_t rxport);
+ void stop_rxthread();
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_STREAM_PDU_BASE_H */
diff --git a/gr-blocks/lib/tag_debug_impl.cc b/gr-blocks/lib/tag_debug_impl.cc
new file mode 100644
index 0000000000..a216879637
--- /dev/null
+++ b/gr-blocks/lib/tag_debug_impl.cc
@@ -0,0 +1,118 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2012-2013 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "tag_debug_impl.h"
+#include <gr_io_signature.h>
+#include <iostream>
+#include <iomanip>
+
+namespace gr {
+ namespace blocks {
+
+ tag_debug::sptr
+ tag_debug::make(size_t sizeof_stream_item,
+ const std::string &name)
+ {
+ return gnuradio::get_initial_sptr
+ (new tag_debug_impl(sizeof_stream_item, name));
+ }
+
+ tag_debug_impl::tag_debug_impl(size_t sizeof_stream_item,
+ const std::string &name)
+ : gr_sync_block("tag_debug",
+ gr_make_io_signature(1, -1, sizeof_stream_item),
+ gr_make_io_signature(0, 0, 0)),
+ d_name(name), d_display(true)
+ {
+ }
+
+ tag_debug_impl::~tag_debug_impl()
+ {
+ }
+
+ std::vector<gr_tag_t>
+ tag_debug_impl::current_tags()
+ {
+ gruel::scoped_lock l(d_mutex);
+ return d_tags;
+ }
+
+ void
+ tag_debug_impl::set_display(bool d)
+ {
+ gruel::scoped_lock l(d_mutex);
+ d_display = d;
+ }
+
+ int
+ tag_debug_impl::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ gruel::scoped_lock l(d_mutex);
+
+ std::stringstream sout;
+ if(d_display) {
+ sout << std::endl
+ << "----------------------------------------------------------------------";
+ sout << std::endl << "Tag Debug: " << d_name << std::endl;
+ }
+
+ uint64_t abs_N, end_N;
+ for(size_t i = 0; i < input_items.size(); i++) {
+ abs_N = nitems_read(i);
+ end_N = abs_N + (uint64_t)(noutput_items);
+
+ d_tags.clear();
+ get_tags_in_range(d_tags, i, abs_N, end_N);
+
+ if(d_display) {
+ sout << "Input Stream: " << std::setw(2) << std::setfill('0')
+ << i << std::setfill(' ') << std::endl;
+ for(d_tags_itr = d_tags.begin(); d_tags_itr != d_tags.end(); d_tags_itr++) {
+ sout << std::setw(10) << "Offset: " << d_tags_itr->offset
+ << std::setw(10) << "Source: "
+ << (pmt::pmt_is_symbol(d_tags_itr->srcid) ? pmt::pmt_symbol_to_string(d_tags_itr->srcid) : "n/a")
+ << std::setw(10) << "Key: " << pmt::pmt_symbol_to_string(d_tags_itr->key)
+ << std::setw(10) << "Value: ";
+ sout << d_tags_itr->value << std::endl;
+ }
+ }
+ }
+
+ if(d_display) {
+ sout << "----------------------------------------------------------------------";
+ sout << std::endl;
+
+ if(d_tags.size() > 0)
+ std::cout << sout.str();
+ }
+
+ return noutput_items;
+ }
+
+ } /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/tag_debug_impl.h b/gr-blocks/lib/tag_debug_impl.h
new file mode 100644
index 0000000000..988d0e1103
--- /dev/null
+++ b/gr-blocks/lib/tag_debug_impl.h
@@ -0,0 +1,58 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2012-2013 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_TAG_DEBUG_IMPL_H
+#define INCLUDED_GR_TAG_DEBUG_IMPL_H
+
+#include <blocks/tag_debug.h>
+#include <gruel/thread.h>
+#include <stddef.h>
+
+namespace gr {
+ namespace blocks {
+
+ class tag_debug_impl : public tag_debug
+ {
+ private:
+ std::string d_name;
+ std::vector<gr_tag_t> d_tags;
+ std::vector<gr_tag_t>::iterator d_tags_itr;
+ bool d_display;
+ gruel::mutex d_mutex;
+
+ public:
+ tag_debug_impl(size_t sizeof_stream_item, const std::string &name);
+ ~tag_debug_impl();
+
+ std::vector<gr_tag_t> current_tags();
+
+ void set_display(bool d);
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_GR_TAG_DEBUG_IMPL_H */
diff --git a/gr-blocks/lib/tagged_file_sink_impl.cc b/gr-blocks/lib/tagged_file_sink_impl.cc
new file mode 100644
index 0000000000..a2e9ab3853
--- /dev/null
+++ b/gr-blocks/lib/tagged_file_sink_impl.cc
@@ -0,0 +1,235 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2010,2013 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "tagged_file_sink_impl.h"
+#include <gr_io_signature.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <stdexcept>
+#include <iostream>
+
+#ifdef HAVE_IO_H
+#include <io.h>
+#endif
+
+#ifdef O_BINARY
+#define OUR_O_BINARY O_BINARY
+#else
+#define OUR_O_BINARY 0
+#endif
+
+// should be handled via configure
+#ifdef O_LARGEFILE
+#define OUR_O_LARGEFILE O_LARGEFILE
+#else
+#define OUR_O_LARGEFILE 0
+#endif
+
+namespace gr {
+ namespace blocks {
+
+ tagged_file_sink::sptr
+ tagged_file_sink::make(size_t itemsize, double samp_rate)
+ {
+ return gnuradio::get_initial_sptr
+ (new tagged_file_sink_impl(itemsize, samp_rate));
+ }
+
+ tagged_file_sink_impl::tagged_file_sink_impl(size_t itemsize, double samp_rate)
+ : gr_sync_block("tagged_file_sink",
+ gr_make_io_signature(1, 1, itemsize),
+ gr_make_io_signature(0, 0, 0)),
+ d_itemsize (itemsize), d_n(0), d_sample_rate(samp_rate)
+ {
+ d_state = NOT_IN_BURST;
+ d_last_N = 0;
+ d_timeval = 0;
+ }
+
+ tagged_file_sink_impl::~tagged_file_sink_impl()
+ {
+ }
+
+ int
+ tagged_file_sink_impl::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ char *inbuf = (char*)input_items[0];
+
+ uint64_t start_N = nitems_read(0);
+ uint64_t end_N = start_N + (uint64_t)(noutput_items);
+ pmt::pmt_t bkey = pmt::pmt_string_to_symbol("burst");
+ pmt::pmt_t tkey = pmt::pmt_string_to_symbol("rx_time"); // use gr_tags::key_time
+
+ std::vector<gr_tag_t> all_tags;
+ get_tags_in_range(all_tags, 0, start_N, end_N);
+
+ std::sort(all_tags.begin(), all_tags.end(), gr_tag_t::offset_compare);
+
+ std::vector<gr_tag_t>::iterator vitr = all_tags.begin();
+
+ // Look for a time tag and initialize d_timeval.
+ std::vector<gr_tag_t> time_tags_outer;
+ get_tags_in_range(time_tags_outer, 0, start_N, end_N, tkey);
+ if(time_tags_outer.size() > 0) {
+ const gr_tag_t tag = time_tags_outer[0];
+ uint64_t offset = tag.offset;
+ pmt::pmt_t time = tag.value;
+ uint64_t tsecs = pmt::pmt_to_uint64(pmt::pmt_tuple_ref(time, 0));
+ double tfrac = pmt::pmt_to_double(pmt::pmt_tuple_ref(time, 1));
+ double delta = (double)offset / d_sample_rate;
+ d_timeval = (double)tsecs + tfrac + delta;
+ d_last_N = offset;
+ }
+
+ int idx = 0, idx_stop = 0;
+ while(idx < noutput_items) {
+ if(d_state == NOT_IN_BURST) {
+ while(vitr != all_tags.end()) {
+ if((pmt::pmt_eqv((*vitr).key, bkey)) &&
+ pmt::pmt_is_true((*vitr).value)) {
+
+ uint64_t N = (*vitr).offset;
+ idx = (int)(N - start_N);
+
+ //std::cout << std::endl << "Found start of burst: "
+ // << idx << ", " << N << std::endl;
+
+ // Find time burst occurred by getting latest time tag and extrapolating
+ // to new time based on sample rate of this block.
+ std::vector<gr_tag_t> time_tags;
+ //get_tags_in_range(time_tags, 0, d_last_N, N, gr_tags::key_time);
+ get_tags_in_range(time_tags, 0, d_last_N, N, tkey);
+ if(time_tags.size() > 0) {
+ const gr_tag_t tag = time_tags[time_tags.size()-1];
+
+ uint64_t time_nitems = tag.offset;
+
+ // Get time based on last time tag from USRP
+ pmt::pmt_t time = tag.value;
+ uint64_t tsecs = pmt::pmt_to_uint64(pmt::pmt_tuple_ref(time, 0));
+ double tfrac = pmt::pmt_to_double(pmt::pmt_tuple_ref(time, 1));
+
+ // Get new time from last time tag + difference in time to when
+ // burst tag occured based on the sample rate
+ double delta = (double)(N - time_nitems) / d_sample_rate;
+ d_timeval = (double)tsecs + tfrac + delta;
+
+ //std::cout.setf(std::ios::fixed, std::ios::floatfield);
+ //std::cout.precision(8);
+ //std::cout << "Time found: " << (double)tsecs + tfrac << std::endl;
+ //std::cout << " time: " << d_timeval << std::endl;
+ //std::cout << " time at N = " << time_nitems << " burst N = " << N << std::endl;
+ }
+ else {
+ // if no time tag, use last seen tag and update time based on
+ // sample rate of the block
+ d_timeval += (double)(N - d_last_N) / d_sample_rate;
+ //std::cout << "Time not found" << std::endl;
+ //std::cout << " time: " << d_timeval << std::endl;
+ }
+ d_last_N = N;
+
+ std::stringstream filename;
+ filename.setf(std::ios::fixed, std::ios::floatfield);
+ filename.precision(8);
+ filename << "file" << unique_id() << "_" << d_n << "_" << d_timeval << ".dat";
+ d_n++;
+
+ int fd;
+ if((fd = ::open(filename.str().c_str(),
+ O_WRONLY|O_CREAT|O_TRUNC|OUR_O_LARGEFILE|OUR_O_BINARY,
+ 0664)) < 0){
+ perror(filename.str().c_str());
+ return -1;
+ }
+
+ // FIXME:
+ //if((d_handle = fdopen (fd, d_is_binary ? "wb" : "w")) == NULL) {
+ if((d_handle = fdopen (fd, "wb")) == NULL) {
+ perror(filename.str().c_str());
+ ::close(fd); // don't leak file descriptor if fdopen fails.
+ }
+
+ //std::cout << "Created new file: " << filename.str() << std::endl;
+
+ d_state = IN_BURST;
+ break;
+ }
+
+ vitr++;
+ }
+ if(d_state == NOT_IN_BURST)
+ return noutput_items;
+ }
+ else { // In burst
+ while(vitr != all_tags.end()) {
+ if((pmt::pmt_eqv((*vitr).key, bkey)) &&
+ pmt::pmt_is_false((*vitr).value)) {
+ uint64_t N = (*vitr).offset;
+ idx_stop = (int)N - start_N;
+
+ //std::cout << "Found end of burst: "
+ // << idx_stop << ", " << N << std::endl;
+
+ int count = fwrite (&inbuf[d_itemsize*idx], d_itemsize,
+ idx_stop-idx, d_handle);
+ if(count == 0) {
+ if(ferror(d_handle)) {
+ perror("tagged_file_sink: error writing file");
+ }
+ }
+ idx = idx_stop;
+ d_state = NOT_IN_BURST;
+ vitr++;
+ fclose(d_handle);
+ break;
+ }
+ else {
+ vitr++;
+ }
+ }
+ if(d_state == IN_BURST) {
+ int count = fwrite (&inbuf[d_itemsize*idx], d_itemsize,
+ noutput_items-idx, d_handle);
+ if (count == 0) {
+ if(ferror(d_handle)) {
+ perror("tagged_file_sink: error writing file");
+ }
+ }
+ idx = noutput_items;
+ }
+ }
+ }
+
+ return noutput_items;
+ }
+
+ } /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/tagged_file_sink_impl.h b/gr-blocks/lib/tagged_file_sink_impl.h
new file mode 100644
index 0000000000..f64cedf2f9
--- /dev/null
+++ b/gr-blocks/lib/tagged_file_sink_impl.h
@@ -0,0 +1,61 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2010,2013 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_TAGGED_FILE_SINK_IMPL_H
+#define INCLUDED_GR_TAGGED_FILE_SINK_IMPL_H
+
+#include <blocks/tagged_file_sink.h>
+#include <cstdio> // for FILE
+
+namespace gr {
+ namespace blocks {
+
+ class tagged_file_sink_impl : public tagged_file_sink
+ {
+ private:
+ enum {
+ NOT_IN_BURST = 0,
+ IN_BURST
+ };
+
+ size_t d_itemsize;
+ int d_state;
+ FILE *d_handle;
+ int d_n;
+ double d_sample_rate;
+ uint64_t d_last_N;
+ double d_timeval;
+
+ public:
+ tagged_file_sink_impl(size_t itemsize, double samp_rate);
+ ~tagged_file_sink_impl();
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+
+#endif /* INCLUDED_GR_TAGGED_FILE_SINK_IMPL_H */
diff --git a/gr-blocks/lib/tagged_stream_mux_impl.cc b/gr-blocks/lib/tagged_stream_mux_impl.cc
new file mode 100644
index 0000000000..59e36fa07e
--- /dev/null
+++ b/gr-blocks/lib/tagged_stream_mux_impl.cc
@@ -0,0 +1,93 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gr_io_signature.h>
+#include "tagged_stream_mux_impl.h"
+
+namespace gr {
+ namespace blocks {
+
+ tagged_stream_mux::sptr
+ tagged_stream_mux::make(size_t itemsize, const std::string &lengthtagname)
+ {
+ return gnuradio::get_initial_sptr (new tagged_stream_mux_impl(itemsize, lengthtagname));
+ }
+
+ tagged_stream_mux_impl::tagged_stream_mux_impl(size_t itemsize, const std::string &lengthtagname)
+ : gr_tagged_stream_block("tagged_stream_mux",
+ gr_make_io_signature(1, -1, itemsize),
+ gr_make_io_signature(1, 1, itemsize),
+ lengthtagname),
+ d_itemsize(itemsize)
+ {
+ set_tag_propagation_policy(TPP_DONT);
+ }
+
+ tagged_stream_mux_impl::~tagged_stream_mux_impl()
+ {
+ }
+
+ int
+ tagged_stream_mux_impl::calculate_output_stream_length(const gr_vector_int &ninput_items)
+ {
+ int nout = 0;
+ for (unsigned i = 0; i < ninput_items.size(); i++) {
+ nout += ninput_items[i];
+ }
+ return nout;
+ }
+
+ int
+ tagged_stream_mux_impl::work (int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ unsigned char *out = (unsigned char *) output_items[0];
+ int n_produced = 0;
+
+ set_relative_rate(ninput_items.size());
+
+ for (unsigned int i = 0; i < input_items.size(); i++) {
+ const unsigned char *in = (const unsigned char *) input_items[i];
+
+ std::vector<gr_tag_t> tags;
+ get_tags_in_range(tags, i, nitems_read(i), nitems_read(i)+ninput_items[i]);
+ for (unsigned int j = 0; j < tags.size(); j++) {
+ const uint64_t offset = tags[j].offset - nitems_read(i) + nitems_written(0) + n_produced;
+ add_item_tag(0, offset, tags[j].key, tags[j].value);
+ }
+ memcpy((void *) out, (const void *) in, ninput_items[i] * d_itemsize);
+ out += ninput_items[i] * d_itemsize;
+ n_produced += ninput_items[i];
+ }
+
+ return n_produced;
+ }
+
+ } /* namespace blocks */
+} /* namespace gr */
+
diff --git a/gr-blocks/lib/tagged_stream_mux_impl.h b/gr-blocks/lib/tagged_stream_mux_impl.h
new file mode 100644
index 0000000000..19862e6868
--- /dev/null
+++ b/gr-blocks/lib/tagged_stream_mux_impl.h
@@ -0,0 +1,54 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 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_TAGGED_STREAM_MUX_IMPL_H
+#define INCLUDED_TAGGED_STREAM_MUX_IMPL_H
+
+#include <vector>
+#include <blocks/tagged_stream_mux.h>
+
+namespace gr {
+ namespace blocks {
+
+ class tagged_stream_mux_impl : public tagged_stream_mux
+ {
+ private:
+ size_t d_itemsize;
+
+ protected:
+ int calculate_output_stream_length(const std::vector<int> &ninput_items);
+
+ public:
+ tagged_stream_mux_impl(size_t itemsize, const std::string &lengthtagname);
+ ~tagged_stream_mux_impl();
+
+ int work(int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } // namespace blocks
+} // namespace gr
+
+#endif
+
diff --git a/gr-blocks/lib/tagged_stream_to_pdu_impl.cc b/gr-blocks/lib/tagged_stream_to_pdu_impl.cc
new file mode 100644
index 0000000000..acd07292f4
--- /dev/null
+++ b/gr-blocks/lib/tagged_stream_to_pdu_impl.cc
@@ -0,0 +1,136 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2013 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "tagged_stream_to_pdu_impl.h"
+#include <blocks/pdu.h>
+#include <gr_io_signature.h>
+
+namespace gr {
+ namespace blocks {
+
+ tagged_stream_to_pdu::sptr
+ tagged_stream_to_pdu::make(pdu::vector_type type)
+ {
+ return gnuradio::get_initial_sptr(new tagged_stream_to_pdu_impl(type));
+ }
+
+ tagged_stream_to_pdu_impl::tagged_stream_to_pdu_impl(pdu::vector_type type)
+ : gr_sync_block("tagged_stream_to_pdu",
+ gr_make_io_signature(1, 1, pdu::itemsize(type)),
+ gr_make_io_signature(0, 0, 0)),
+ d_itemsize(pdu::itemsize(type)),
+ d_inpdu(false),
+ d_type(type),
+ d_pdu_meta(pmt::PMT_NIL),
+ d_pdu_vector(pmt::PMT_NIL)
+ {
+ message_port_register_out(PDU_PORT_ID);
+ }
+
+ int
+ tagged_stream_to_pdu_impl::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ const uint8_t *in = (const uint8_t*) input_items[0];
+ uint64_t abs_N = nitems_read(0);
+
+ // if we are not in a pdu already, start a new one
+ if (!d_inpdu) {
+ bool found_length_tag(false);
+
+ get_tags_in_range(d_tags, 0, abs_N, abs_N+1);
+
+ for (d_tags_itr = d_tags.begin(); (d_tags_itr != d_tags.end()) && (!found_length_tag); d_tags_itr++) {
+ if (pmt::pmt_equal((*d_tags_itr).key, PDU_LENGTH_TAG )) {
+
+ if ((*d_tags_itr).offset != abs_N )
+ throw std::runtime_error("expected next pdu length tag on a different item...");
+
+ found_length_tag = true;
+ d_pdu_length = pmt::pmt_to_long((*d_tags_itr).value);
+ d_pdu_remain = d_pdu_length;
+ d_pdu_meta = pmt::pmt_make_dict();
+ break;
+ } // if have length tag
+ } // iter over tags
+
+ if (!found_length_tag)
+ throw std::runtime_error("tagged stream does not contain a pdu_length tag");
+ }
+
+ size_t ncopy = std::min((size_t)noutput_items, d_pdu_remain);
+
+ // copy any tags in this range into our meta object
+ get_tags_in_range(d_tags, 0, abs_N, abs_N+ncopy);
+ for (d_tags_itr = d_tags.begin(); d_tags_itr != d_tags.end(); d_tags_itr++)
+ if(!pmt_equal((*d_tags_itr).key, PDU_LENGTH_TAG ))
+ d_pdu_meta = pmt_dict_add(d_pdu_meta, (*d_tags_itr).key, (*d_tags_itr).value);
+
+ // copy samples for this vector into either a pmt or our save buffer
+ if (ncopy == d_pdu_remain) { // we will send this pdu
+ if (d_save.size() == 0) {
+ d_pdu_vector = pdu::make_vector(d_type, in, ncopy);
+ send_message();
+ }
+ else {
+ size_t oldsize = d_save.size();
+ d_save.resize((oldsize + ncopy)*d_itemsize, 0);
+ memcpy(&d_save[oldsize*d_itemsize], in, ncopy*d_itemsize);
+ d_pdu_vector = pdu::make_vector(d_type, &d_save[0], d_pdu_length);
+ send_message();
+ d_save.clear();
+ }
+ }
+ else {
+ d_inpdu = true;
+ size_t oldsize = d_save.size();
+ d_save.resize((oldsize+ncopy)*d_itemsize);
+ memcpy(&d_save[oldsize*d_itemsize], in, ncopy*d_itemsize);
+ d_pdu_remain -= ncopy;
+ }
+
+ return ncopy;
+ }
+
+ void
+ tagged_stream_to_pdu_impl::send_message()
+ {
+ if (pmt::pmt_length(d_pdu_vector) != d_pdu_length)
+ throw std::runtime_error("msg length not correct");
+
+ pmt::pmt_t msg = pmt::pmt_cons(d_pdu_meta, d_pdu_vector);
+ message_port_pub(PDU_PORT_ID, msg);
+
+ d_pdu_meta = pmt::PMT_NIL;
+ d_pdu_vector = pmt::PMT_NIL;
+ d_pdu_length = 0;
+ d_pdu_remain = 0;
+ d_inpdu = false;
+ }
+
+ } /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/tagged_stream_to_pdu_impl.h b/gr-blocks/lib/tagged_stream_to_pdu_impl.h
new file mode 100644
index 0000000000..84d7f6c3cb
--- /dev/null
+++ b/gr-blocks/lib/tagged_stream_to_pdu_impl.h
@@ -0,0 +1,58 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2013 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_TAGGED_STREAM_TO_PDU_IMPL_H
+#define INCLUDED_TAGGED_STREAM_TO_PDU_IMPL_H
+
+#include <blocks/tagged_stream_to_pdu.h>
+
+namespace gr {
+ namespace blocks {
+
+ class BLOCKS_API tagged_stream_to_pdu_impl : public tagged_stream_to_pdu
+ {
+ size_t d_itemsize;
+ size_t d_pdu_length;
+ size_t d_pdu_remain;
+ bool d_inpdu;
+ pdu::vector_type d_type;
+ std::vector<uint8_t> d_save;
+ pmt::pmt_t d_pdu_meta;
+ pmt::pmt_t d_pdu_vector;
+
+ std::vector<gr_tag_t>::iterator d_tags_itr;
+ std::vector<gr_tag_t> d_tags;
+
+ public:
+ tagged_stream_to_pdu_impl(pdu::vector_type type);
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+
+ void send_message();
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif
diff --git a/gr-blocks/lib/tcp_connection.cc b/gr-blocks/lib/tcp_connection.cc
new file mode 100644
index 0000000000..4ead6442d8
--- /dev/null
+++ b/gr-blocks/lib/tcp_connection.cc
@@ -0,0 +1,87 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2013 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "tcp_connection.h"
+#include <gr_basic_block.h>
+#include <gr_pdu.h>
+//#include <boost/asio.hpp>
+//#include <boost/bind.hpp>
+
+namespace gr {
+ namespace blocks {
+
+ tcp_connection::sptr tcp_connection::make(boost::asio::io_service& io_service)
+ {
+ return sptr(new tcp_connection(io_service));
+ }
+
+ tcp_connection::tcp_connection(boost::asio::io_service& io_service)
+ : d_socket(io_service)
+ {
+ }
+
+ void
+ tcp_connection::send(pmt::pmt_t vector)
+ {
+ size_t len = pmt::pmt_length(vector);
+ size_t offset(0);
+ boost::array<char, 10000> txbuf;
+ memcpy(&txbuf[0], pmt::pmt_uniform_vector_elements(vector, offset), len);
+ boost::asio::async_write(d_socket, boost::asio::buffer(txbuf, len),
+ boost::bind(&tcp_connection::handle_write, this,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred));
+ }
+
+ void
+ tcp_connection::start(gr_basic_block *block)
+ {
+ d_block = block;
+ d_socket.async_read_some(boost::asio::buffer(d_buf),
+ boost::bind(&tcp_connection::handle_read, this,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred));
+ }
+
+ void
+ tcp_connection::handle_read(const boost::system::error_code& error, size_t bytes_transferred)
+ {
+ if (!error) {
+ pmt::pmt_t vector = pmt::pmt_init_u8vector(bytes_transferred, (const uint8_t*)&d_buf[0]);
+ pmt::pmt_t pdu = pmt::pmt_cons( pmt::PMT_NIL, vector);
+
+ d_block->message_port_pub(PDU_PORT_ID, pdu);
+
+ d_socket.async_read_some(boost::asio::buffer(d_buf),
+ boost::bind(&tcp_connection::handle_read, this,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred));
+
+ }
+ }
+
+ } /* namespace blocks */
+}/* namespace gr */
diff --git a/gr-blocks/lib/tcp_connection.h b/gr-blocks/lib/tcp_connection.h
new file mode 100644
index 0000000000..ba57de0783
--- /dev/null
+++ b/gr-blocks/lib/tcp_connection.h
@@ -0,0 +1,61 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2013 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_TCP_CONNECTION_H
+#define INCLUDED_TCP_CONNECTION_H
+
+#include <boost/array.hpp>
+#include <boost/asio.hpp>
+#include <gruel/pmt.h>
+
+class gr_basic_block;
+
+namespace gr {
+ namespace blocks {
+
+ class tcp_connection
+ {
+ private:
+ boost::asio::ip::tcp::socket d_socket;
+ boost::array<char, 10000> d_buf;
+ std::string d_message;
+ gr_basic_block *d_block;
+
+ tcp_connection(boost::asio::io_service& io_service);
+
+ public:
+ typedef boost::shared_ptr<tcp_connection> sptr;
+
+ static sptr make(boost::asio::io_service& io_service);
+
+ boost::asio::ip::tcp::socket& socket() { return d_socket; };
+
+ void start(gr_basic_block *block);
+ void send(pmt::pmt_t vector);
+ void handle_read(const boost::system::error_code& error, size_t bytes_transferred);
+ void handle_write(const boost::system::error_code& error, size_t bytes_transferred) { }
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_TCP_CONNECTION_H */
diff --git a/gr-blocks/lib/test_gr_blocks.cc b/gr-blocks/lib/test_gr_blocks.cc
new file mode 100644
index 0000000000..f03745dc99
--- /dev/null
+++ b/gr-blocks/lib/test_gr_blocks.cc
@@ -0,0 +1,43 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2012-2013 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.
+ */
+
+#include <cppunit/TextTestRunner.h>
+#include <cppunit/XmlOutputter.h>
+
+#include <gr_unittests.h>
+#include <qa_blocks.h>
+#include <iostream>
+
+int
+main(int argc, char **argv)
+{
+ CppUnit::TextTestRunner runner;
+ std::ofstream xmlfile(get_unittest_path("gr_blocks.xml").c_str());
+ CppUnit::XmlOutputter *xmlout = new CppUnit::XmlOutputter(&runner.result(), xmlfile);
+
+ runner.addTest(qa_gr_blocks::suite());
+ runner.setOutputter(xmlout);
+
+ bool was_successful = runner.run("", false);
+
+ return was_successful ? 0 : 1;
+}
diff --git a/gr-blocks/lib/tuntap_pdu_impl.cc b/gr-blocks/lib/tuntap_pdu_impl.cc
new file mode 100644
index 0000000000..8de817738f
--- /dev/null
+++ b/gr-blocks/lib/tuntap_pdu_impl.cc
@@ -0,0 +1,139 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2013 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "tuntap_pdu_impl.h"
+#include <gr_io_signature.h>
+#include <blocks/pdu.h>
+#include <boost/format.hpp>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+#if (defined(linux) || defined(__linux) || defined(__linux__))
+#include <sys/ioctl.h>
+#include <arpa/inet.h>
+#include <linux/if.h>
+#endif
+
+namespace gr {
+ namespace blocks {
+
+ tuntap_pdu::sptr
+ tuntap_pdu::make(std::string dev, int MTU)
+ {
+#if (defined(linux) || defined(__linux) || defined(__linux__))
+ return gnuradio::get_initial_sptr(new tuntap_pdu_impl(dev, MTU));
+#else
+ throw std::runtime_error("tuntap_pdu not implemented on this platform");
+#endif
+ }
+
+#if (defined(linux) || defined(__linux) || defined(__linux__))
+ tuntap_pdu_impl::tuntap_pdu_impl(std::string dev, int MTU)
+ : gr_block("tuntap_pdu",
+ gr_make_io_signature (0, 0, 0),
+ gr_make_io_signature (0, 0, 0)),
+ stream_pdu_base(MTU),
+ d_dev(dev)
+ {
+ // make the tuntap
+ char dev_cstr[1024];
+ memset(dev_cstr, 0x00, 1024);
+ strncpy(dev_cstr, dev.c_str(), std::min(sizeof(dev_cstr), dev.size()));
+
+ d_fd = tun_alloc(dev_cstr);
+ if (d_fd <= 0)
+ throw std::runtime_error("gr::tuntap_pdu::make: tun_alloc failed (are you running as root?)");
+
+ std::cout << boost::format(
+ "Allocated virtual ethernet interface: %s\n"
+ "You must now use ifconfig to set its IP address. E.g.,\n"
+ " $ sudo ifconfig %s 192.168.200.1\n"
+ "Be sure to use a different address in the same subnet for each machine.\n"
+ ) % dev % dev << std::endl;
+
+ // set up output message port
+ message_port_register_out(PDU_PORT_ID);
+ start_rxthread(this, PDU_PORT_ID);
+
+ // set up input message port
+ message_port_register_in(PDU_PORT_ID);
+ set_msg_handler(PDU_PORT_ID, boost::bind(&tuntap_pdu_impl::send, this, _1));
+ }
+
+ int
+ tuntap_pdu_impl::tun_alloc(char *dev, int flags)
+ {
+ struct ifreq ifr;
+ int fd, err;
+ const char *clonedev = "/dev/net/tun";
+
+ /* Arguments taken by the function:
+ *
+ * char *dev: the name of an interface (or '\0'). MUST have enough
+ * space to hold the interface name if '\0' is passed
+ * int flags: interface flags (eg, IFF_TUN etc.)
+ */
+
+ /* open the clone device */
+ if ((fd = open(clonedev, O_RDWR)) < 0)
+ return fd;
+
+ /* preparation of the struct ifr, of type "struct ifreq" */
+ memset(&ifr, 0, sizeof(ifr));
+
+ ifr.ifr_flags = flags; /* IFF_TUN or IFF_TAP, plus maybe IFF_NO_PI */
+
+ /* if a device name was specified, put it in the structure; otherwise,
+ * the kernel will try to allocate the "next" device of the
+ * specified type
+ */
+ if (*dev)
+ strncpy(ifr.ifr_name, dev, IFNAMSIZ);
+
+ /* try to create the device */
+ if ((err = ioctl(fd, TUNSETIFF, (void *) &ifr)) < 0) {
+ close(fd);
+ return err;
+ }
+
+ /* if the operation was successful, write back the name of the
+ * interface to the variable "dev", so the caller can know
+ * it. Note that the caller MUST reserve space in *dev (see calling
+ * code below)
+ */
+ strcpy(dev, ifr.ifr_name);
+
+ /* this is the special file descriptor that the caller will use to talk
+ * with the virtual interface
+ */
+ return fd;
+ }
+#endif
+
+ } /* namespace blocks */
+}/* namespace gr */
diff --git a/gr-blocks/lib/tuntap_pdu_impl.h b/gr-blocks/lib/tuntap_pdu_impl.h
new file mode 100644
index 0000000000..396d9d51c8
--- /dev/null
+++ b/gr-blocks/lib/tuntap_pdu_impl.h
@@ -0,0 +1,51 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2013 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_BLOCKS_TUNTAP_PDU_IMPL_H
+#define INCLUDED_BLOCKS_TUNTAP_PDU_IMPL_H
+
+#include <blocks/tuntap_pdu.h>
+#include "stream_pdu_base.h"
+
+#if (defined(linux) || defined(__linux) || defined(__linux__))
+#include <linux/if_tun.h>
+#endif
+
+namespace gr {
+ namespace blocks {
+
+ class tuntap_pdu_impl : public tuntap_pdu, public stream_pdu_base
+ {
+#if (defined(linux) || defined(__linux) || defined(__linux__))
+ private:
+ std::string d_dev;
+ int tun_alloc(char *dev, int flags = IFF_TAP | IFF_NO_PI);
+
+ public:
+ tuntap_pdu_impl(std::string dev, int MTU);
+#endif
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_BLOCKS_TUNTAP_PDU_IMPL_H */
diff --git a/gr-blocks/lib/udp_sink_impl.cc b/gr-blocks/lib/udp_sink_impl.cc
new file mode 100644
index 0000000000..db21da3eeb
--- /dev/null
+++ b/gr-blocks/lib/udp_sink_impl.cc
@@ -0,0 +1,148 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007-2010,2013 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "udp_sink_impl.h"
+#include <gr_io_signature.h>
+#include <boost/asio.hpp>
+#include <boost/format.hpp>
+#include <gruel/thread.h>
+#include <stdexcept>
+#include <stdio.h>
+#include <string.h>
+
+namespace gr {
+ namespace blocks {
+
+ udp_sink::sptr
+ udp_sink::make(size_t itemsize,
+ const std::string &host, int port,
+ int payload_size, bool eof)
+ {
+ return gnuradio::get_initial_sptr
+ (new udp_sink_impl(itemsize, host, port,
+ payload_size, eof));
+ }
+
+ udp_sink_impl::udp_sink_impl(size_t itemsize,
+ const std::string &host, int port,
+ int payload_size, bool eof)
+ : gr_sync_block("udp_sink",
+ gr_make_io_signature(1, 1, itemsize),
+ gr_make_io_signature(0, 0, 0)),
+ d_itemsize(itemsize), d_payload_size(payload_size), d_eof(eof),
+ d_connected(false)
+ {
+ // Get the destination address
+ connect(host, port);
+ }
+
+ // public constructor that returns a shared_ptr
+ udp_sink_impl::~udp_sink_impl()
+ {
+ if(d_connected)
+ disconnect();
+ }
+
+ void
+ udp_sink_impl::connect(const std::string &host, int port)
+ {
+ if(d_connected)
+ disconnect();
+
+ std::string s_port = (boost::format("%d")%port).str();
+ if(host.size() > 0) {
+ boost::asio::ip::udp::resolver resolver(d_io_service);
+ boost::asio::ip::udp::resolver::query query(boost::asio::ip::udp::v4(),
+ host, s_port);
+ d_endpoint = *resolver.resolve(query);
+
+ d_socket = new boost::asio::ip::udp::socket(d_io_service);
+ d_socket->open(boost::asio::ip::udp::v4());
+
+ boost::asio::socket_base::reuse_address roption(true);
+ d_socket->set_option(roption);
+
+ d_connected = true;
+ }
+ }
+
+ void
+ udp_sink_impl::disconnect()
+ {
+ if(!d_connected)
+ return;
+
+ gruel::scoped_lock guard(d_mutex); // protect d_socket from work()
+
+ // Send a few zero-length packets to signal receiver we are done
+ boost::array<char, 1> send_buf = {{ 0 }};
+ if(d_eof) {
+ int i;
+ for(i = 0; i < 3; i++)
+ d_socket->send_to(boost::asio::buffer(send_buf), d_endpoint);
+ }
+
+ d_socket->close();
+ delete d_socket;
+
+ d_connected = false;
+ }
+
+ int
+ udp_sink_impl::work (int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ const char *in = (const char *) input_items[0];
+ ssize_t r=0, bytes_sent=0, bytes_to_send=0;
+ ssize_t total_size = noutput_items*d_itemsize;
+
+ gruel::scoped_lock guard(d_mutex); // protect d_socket
+
+ while(bytes_sent < total_size) {
+ bytes_to_send = std::min((ssize_t)d_payload_size, (total_size-bytes_sent));
+
+ if(d_connected) {
+ try {
+ r = d_socket->send_to(boost::asio::buffer((void*)(in+bytes_sent), bytes_to_send),
+ d_endpoint);
+ }
+ catch(std::exception& e) {
+ GR_LOG_ERROR(d_logger, boost::format("send error: %s") % e.what());
+ return -1;
+ }
+ }
+ else
+ r = bytes_to_send; // discarded for lack of connection
+ bytes_sent += r;
+ }
+
+ return noutput_items;
+ }
+
+ } /* namespace blocks */
+} /* namespace gr */
+
diff --git a/gr-blocks/lib/udp_sink_impl.h b/gr-blocks/lib/udp_sink_impl.h
new file mode 100644
index 0000000000..243d499b60
--- /dev/null
+++ b/gr-blocks/lib/udp_sink_impl.h
@@ -0,0 +1,65 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007-2010,2013 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_UDP_SINK_IMPL_H
+#define INCLUDED_GR_UDP_SINK_IMPL_H
+
+#include <blocks/udp_sink.h>
+#include <boost/asio.hpp>
+
+namespace gr {
+ namespace blocks {
+
+ class udp_sink_impl : public udp_sink
+ {
+ private:
+ size_t d_itemsize;
+
+ int d_payload_size; // maximum transmission unit (packet length)
+ bool d_eof; // send zero-length packet on disconnect
+ bool d_connected; // are we connected?
+ gruel::mutex d_mutex; // protects d_socket and d_connected
+
+ boost::asio::ip::udp::socket *d_socket; // handle to socket
+ boost::asio::ip::udp::endpoint d_endpoint;
+ boost::asio::io_service d_io_service;
+
+ public:
+ udp_sink_impl(size_t itemsize,
+ const std::string &host, int port,
+ int payload_size, bool eof);
+ ~udp_sink_impl();
+
+ int payload_size() { return d_payload_size; }
+
+ void connect(const std::string &host, int port);
+ void disconnect();
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_GR_UDP_SINK_IMPL_H */
diff --git a/gr-blocks/lib/udp_source_impl.cc b/gr-blocks/lib/udp_source_impl.cc
new file mode 100644
index 0000000000..e6e9caf8ad
--- /dev/null
+++ b/gr-blocks/lib/udp_source_impl.cc
@@ -0,0 +1,215 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007-2010,2013 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "udp_source_impl.h"
+#include <gr_io_signature.h>
+#include <gr_math.h>
+#include <stdexcept>
+#include <errno.h>
+#include <stdio.h>
+#include <string.h>
+
+namespace gr {
+ namespace blocks {
+
+ udp_source::sptr
+ udp_source::make(size_t itemsize,
+ const std::string &ipaddr, int port,
+ int payload_size, bool eof)
+ {
+ return gnuradio::get_initial_sptr
+ (new udp_source_impl(itemsize, ipaddr, port,
+ payload_size, eof));
+ }
+
+ udp_source_impl::udp_source_impl(size_t itemsize,
+ const std::string &host, int port,
+ int payload_size, bool eof)
+ : gr_sync_block("udp_source",
+ gr_make_io_signature(0, 0, 0),
+ gr_make_io_signature(1, 1, itemsize)),
+ d_itemsize(itemsize), d_payload_size(payload_size),
+ d_eof(eof), d_connected(false), d_residual(0), d_sent(0), d_offset(0)
+ {
+ // Give us some more room to play.
+ d_rxbuf = new char[4*d_payload_size];
+ d_residbuf = new char[50*d_payload_size];
+
+ connect(host, port);
+ }
+
+ udp_source_impl::~udp_source_impl()
+ {
+ if(d_connected)
+ disconnect();
+
+ delete [] d_rxbuf;
+ delete [] d_residbuf;
+ }
+
+ void
+ udp_source_impl::connect(const std::string &host, int port)
+ {
+ if(d_connected)
+ disconnect();
+
+ d_host = host;
+ d_port = static_cast<unsigned short>(port);
+
+ std::string s_port;
+ s_port = (boost::format("%d")%d_port).str();
+
+ if(host.size() > 0) {
+ boost::asio::ip::udp::resolver resolver(d_io_service);
+ boost::asio::ip::udp::resolver::query query(boost::asio::ip::udp::v4(),
+ host, s_port);
+ d_endpoint = *resolver.resolve(query);
+
+ d_socket = new boost::asio::ip::udp::socket(d_io_service);
+ d_socket->open(d_endpoint.protocol());
+
+ boost::asio::socket_base::linger loption(true, 0);
+ d_socket->set_option(loption);
+
+ boost::asio::socket_base::reuse_address roption(true);
+ d_socket->set_option(roption);
+
+ d_socket->bind(d_endpoint);
+
+ start_receive();
+ d_udp_thread = gruel::thread(boost::bind(&udp_source_impl::run_io_service, this));
+ d_connected = true;
+ }
+ }
+
+ void
+ udp_source_impl::disconnect()
+ {
+ gruel::scoped_lock lock(d_setlock);
+
+ if(!d_connected)
+ return;
+
+ d_io_service.stop();
+
+ d_socket->close();
+ delete d_socket;
+
+ d_connected = false;
+ }
+
+ // Return port number of d_socket
+ int
+ udp_source_impl::get_port(void)
+ {
+ //return d_endpoint.port();
+ return d_socket->local_endpoint().port();
+ }
+
+ void
+ udp_source_impl::start_receive()
+ {
+ d_socket->async_receive_from(boost::asio::buffer((void*)d_rxbuf, d_payload_size), d_endpoint_rcvd,
+ boost::bind(&udp_source_impl::handle_read, this,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred));
+ }
+
+ void
+ udp_source_impl::handle_read(const boost::system::error_code& error,
+ size_t bytes_transferred)
+ {
+ if(!error) {
+ {
+ boost::lock_guard<gruel::mutex> lock(d_udp_mutex);
+ if(d_eof && (bytes_transferred == 1) && (d_rxbuf[0] == 0x00)) {
+ // If we are using EOF notification, test for it and don't
+ // add anything to the output.
+ d_residual = -1;
+ d_cond_wait.notify_one();
+ return;
+ }
+ else {
+ // Make sure we never go beyond the boundary of the
+ // residual buffer. This will just drop the last bit of
+ // data in the buffer if we've run out of room.
+ if((int)(d_residual + bytes_transferred) > (50*d_payload_size)) {
+ GR_LOG_WARN(d_logger, "Too much data; dropping packet.");
+ }
+ else {
+ // otherwise, copy receid data into local buffer for
+ // copying later.
+ memcpy(d_residbuf+d_residual, d_rxbuf, bytes_transferred);
+ d_residual += bytes_transferred;
+ }
+ }
+ d_cond_wait.notify_one();
+ }
+ }
+ start_receive();
+ }
+
+ int
+ udp_source_impl::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ gruel::scoped_lock l(d_setlock);
+
+ char *out = (char*)output_items[0];
+
+ // Use async receive_from to get data from UDP buffer and wait
+ // on a conditional signal before proceeding. We use this
+ // because the conditional wait is interruptable while a
+ // synchronous receive_from is not.
+ boost::unique_lock<boost::mutex> lock(d_udp_mutex);
+ d_cond_wait.wait(lock);
+
+ if(d_residual < 0)
+ return -1;
+
+ int to_be_sent = (int)(d_residual - d_sent);
+ int to_send = std::min(noutput_items, to_be_sent);
+
+ // Copy the received data in the residual buffer to the output stream
+ memcpy(out, d_residbuf+d_sent, to_send);
+ int nitems = to_send/d_itemsize;
+
+ // Keep track of where we are if we don't have enough output
+ // space to send all the data in the residbuf.
+ if(to_send == to_be_sent) {
+ d_residual = 0;
+ d_sent = 0;
+ }
+ else {
+ d_sent += to_send;
+ }
+
+ return nitems;
+ }
+
+ } /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/udp_source_impl.h b/gr-blocks/lib/udp_source_impl.h
new file mode 100644
index 0000000000..8927f5f933
--- /dev/null
+++ b/gr-blocks/lib/udp_source_impl.h
@@ -0,0 +1,84 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007-2010,2013 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_UDP_SOURCE_IMPL_H
+#define INCLUDED_GR_UDP_SOURCE_IMPL_H
+
+#include <blocks/udp_source.h>
+#include <boost/asio.hpp>
+#include <boost/format.hpp>
+#include <gruel/thread.h>
+
+namespace gr {
+ namespace blocks {
+
+ class udp_source_impl : public udp_source
+ {
+ private:
+ size_t d_itemsize;
+ int d_payload_size; // maximum transmission unit (packet length)
+ bool d_eof; // look for an EOF signal
+ bool d_connected; // are we connected?
+ char *d_rxbuf; // get UDP buffer items
+ char *d_residbuf; // hold buffer between calls
+ ssize_t d_residual; // hold information about number of bytes stored in residbuf
+ ssize_t d_sent; // track how much of d_residbuf we've outputted
+ size_t d_offset; // point to residbuf location offset
+
+ std::string d_host;
+ unsigned short d_port;
+
+ boost::asio::ip::udp::socket *d_socket;
+ boost::asio::ip::udp::endpoint d_endpoint;
+ boost::asio::ip::udp::endpoint d_endpoint_rcvd;
+ boost::asio::io_service d_io_service;
+
+ gruel::condition_variable d_cond_wait;
+ gruel::mutex d_udp_mutex;
+ gruel::thread d_udp_thread;
+
+ void start_receive();
+ void handle_read(const boost::system::error_code& error,
+ size_t bytes_transferred);
+ void run_io_service() { d_io_service.run(); }
+
+ public:
+ udp_source_impl(size_t itemsize,
+ const std::string &host, int port,
+ int payload_size, bool eof);
+ ~udp_source_impl();
+
+ void connect(const std::string &host, int port);
+ void disconnect();
+
+ int payload_size() { return d_payload_size; }
+ int get_port();
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_GR_UDP_SOURCE_H */
diff --git a/gr-blocks/lib/unpack_k_bits_bb_impl.cc b/gr-blocks/lib/unpack_k_bits_bb_impl.cc
new file mode 100644
index 0000000000..367100be84
--- /dev/null
+++ b/gr-blocks/lib/unpack_k_bits_bb_impl.cc
@@ -0,0 +1,77 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2005,2010,2013 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.
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "unpack_k_bits_bb_impl.h"
+#include <gr_io_signature.h>
+#include <stdexcept>
+#include <iostream>
+
+namespace gr {
+ namespace blocks {
+
+ unpack_k_bits_bb::sptr
+ unpack_k_bits_bb::make(unsigned k)
+ {
+ return gnuradio::get_initial_sptr
+ (new unpack_k_bits_bb_impl(k));
+ }
+
+ unpack_k_bits_bb_impl::unpack_k_bits_bb_impl(unsigned k)
+ : gr_sync_interpolator("unpack_k_bits_bb",
+ gr_make_io_signature(1, 1, sizeof(unsigned char)),
+ gr_make_io_signature(1, 1, sizeof(unsigned char)),
+ k),
+ d_k(k)
+ {
+ if(d_k == 0)
+ throw std::out_of_range("interpolation must be > 0");
+ }
+
+ unpack_k_bits_bb_impl::~unpack_k_bits_bb_impl()
+ {
+ }
+
+ int
+ unpack_k_bits_bb_impl::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ const unsigned char *in = (const unsigned char *)input_items[0];
+ unsigned char *out = (unsigned char *)output_items[0];
+
+ int n = 0;
+ for(unsigned int i = 0; i < noutput_items/d_k; i++) {
+ unsigned int t = in[i];
+ for(int j = d_k - 1; j >= 0; j--)
+ out[n++] = (t >> j) & 0x01;
+ }
+
+ assert(n == noutput_items);
+ return noutput_items;
+ }
+
+ } /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/unpack_k_bits_bb_impl.h b/gr-blocks/lib/unpack_k_bits_bb_impl.h
new file mode 100644
index 0000000000..c72d16ebf8
--- /dev/null
+++ b/gr-blocks/lib/unpack_k_bits_bb_impl.h
@@ -0,0 +1,48 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2006,2013 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_UNPACK_K_BITS_BB_IMPL_H
+#define INCLUDED_GR_UNPACK_K_BITS_BB_IMPL_H
+
+#include <blocks/unpack_k_bits_bb.h>
+
+namespace gr {
+ namespace blocks {
+
+ class unpack_k_bits_bb_impl : public unpack_k_bits_bb
+ {
+ private:
+ unsigned d_k; // number of relevent bits to unpack into k output bytes
+
+ public:
+ unpack_k_bits_bb_impl(unsigned k);
+ ~unpack_k_bits_bb_impl();
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_GR_UNPACK_K_BITS_BB_IMPL_H */
diff --git a/gr-blocks/lib/vco_f_impl.cc b/gr-blocks/lib/vco_f_impl.cc
new file mode 100644
index 0000000000..21e7d0a0f2
--- /dev/null
+++ b/gr-blocks/lib/vco_f_impl.cc
@@ -0,0 +1,68 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2005,2010,2013 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "vco_f_impl.h"
+#include <gr_io_signature.h>
+#include <math.h>
+
+namespace gr {
+ namespace blocks {
+
+ vco_f::sptr
+ vco_f::make(double sampling_rate, double sensitivity, double amplitude)
+ {
+ return gnuradio::get_initial_sptr
+ (new vco_f_impl(sampling_rate, sensitivity, amplitude));
+ }
+
+ vco_f_impl::vco_f_impl(double sampling_rate, double sensitivity, double amplitude)
+ : gr_sync_block("vco_f",
+ gr_make_io_signature(1, 1, sizeof(float)),
+ gr_make_io_signature(1, 1, sizeof(float))),
+ d_sampling_rate(sampling_rate), d_sensitivity(sensitivity),
+ d_amplitude(amplitude), d_k(d_sensitivity/d_sampling_rate)
+ {
+ }
+
+ vco_f_impl::~vco_f_impl()
+ {
+ }
+
+ int
+ vco_f_impl::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ const float *input = (const float*)input_items[0];
+ float *output = (float*)output_items[0];
+
+ d_vco.cos(output, input, noutput_items, d_k, d_amplitude);
+
+ return noutput_items;
+ }
+
+ } /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/vco_f_impl.h b/gr-blocks/lib/vco_f_impl.h
new file mode 100644
index 0000000000..37435b7736
--- /dev/null
+++ b/gr-blocks/lib/vco_f_impl.h
@@ -0,0 +1,53 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2005,2013 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_VCO_F_IMPL_H
+#define INCLUDED_GR_VCO_F_IMPL_H
+
+#include <blocks/vco_f.h>
+#include <gr_fxpt_vco.h>
+
+namespace gr {
+ namespace blocks {
+
+ class vco_f_impl : public vco_f
+ {
+ private:
+ double d_sampling_rate;
+ double d_sensitivity;
+ double d_amplitude;
+ double d_k;
+ gr_fxpt_vco d_vco;
+
+ public:
+ vco_f_impl(double sampling_rate, double sensitivity, double amplitude);
+ ~vco_f_impl();
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_GR_VCO_F_H */
diff --git a/gr-blocks/lib/vector_insert_X_impl.cc.t b/gr-blocks/lib/vector_insert_X_impl.cc.t
new file mode 100644
index 0000000000..adf31fe05a
--- /dev/null
+++ b/gr-blocks/lib/vector_insert_X_impl.cc.t
@@ -0,0 +1,109 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 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.
+ */
+
+// @WARNING@
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <@NAME_IMPL@.h>
+#include <algorithm>
+#include <gr_io_signature.h>
+#include <stdexcept>
+#include <stdio.h>
+
+namespace gr {
+ namespace blocks {
+
+ @NAME@::sptr
+ @NAME@::make(const std::vector<@TYPE@> &data, int periodicity, int offset)
+ {
+ return gnuradio::get_initial_sptr
+ (new @NAME_IMPL@(data, periodicity, offset));
+ }
+
+ @NAME_IMPL@::@NAME_IMPL@(const std::vector<@TYPE@> &data,
+ int periodicity, int offset)
+ : gr_block("@BASE_NAME@",
+ gr_make_io_signature(1, 1, sizeof(@TYPE@)),
+ gr_make_io_signature(1, 1, sizeof(@TYPE@))),
+ d_data(data),
+ d_offset(offset),
+ d_periodicity(periodicity)
+ {
+ //printf("INITIAL: periodicity = %d, offset = %d\n", periodicity, offset);
+ // some sanity checks
+ assert(offset < periodicity);
+ assert(offset >= 0);
+ assert((size_t)periodicity > data.size());
+ }
+
+ @NAME_IMPL@::~@NAME_IMPL@()
+ {}
+
+ int
+ @NAME_IMPL@::general_work(int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ @TYPE@ *out = (@TYPE@ *)output_items[0];
+ const @TYPE@ *in = (const @TYPE@ *)input_items[0];
+
+ int ii(0), oo(0);
+
+ while((oo < noutput_items) && (ii < ninput_items[0])) {
+ //printf("oo = %d, ii = %d, d_offset = %d, noutput_items = %d, ninput_items[0] = %d", oo, ii, d_offset, noutput_items, ninput_items[0]);
+ //printf(", d_periodicity = %d\n", d_periodicity);
+
+ if(d_offset >= ((int)d_data.size())) { // if we are in the copy region
+ int max_copy = std::min(std::min(noutput_items - oo, ninput_items[0] - ii),
+ d_periodicity - d_offset);
+ //printf("copy %d from input\n", max_copy);
+ memcpy( &out[oo], &in[ii], sizeof(@TYPE@)*max_copy );
+ //printf(" * memcpy returned.\n");
+ ii += max_copy;
+ oo += max_copy;
+ d_offset = (d_offset + max_copy)%d_periodicity;
+ }
+ else { // if we are in the insertion region
+ int max_copy = std::min(noutput_items - oo, ((int)d_data.size()) - d_offset);
+ //printf("copy %d from d_data[%d] to out[%d]\n", max_copy, d_offset, oo);
+ memcpy(&out[oo], &d_data[d_offset], sizeof(@TYPE@)*max_copy);
+ //printf(" * memcpy returned.\n");
+ oo += max_copy;
+ d_offset = (d_offset + max_copy)%d_periodicity;
+ //printf(" ## (inelse) oo = %d, d_offset = %d\n", oo, d_offset);
+ }
+
+ //printf(" # exit else, on to next loop.\n");
+ }
+ //printf(" # got out of loop\n");
+
+ //printf("consume = %d, produce = %d\n", ii, oo);
+ consume_each(ii);
+ return oo;
+ }
+
+ } /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/vector_insert_X_impl.h.t b/gr-blocks/lib/vector_insert_X_impl.h.t
new file mode 100644
index 0000000000..f447ef1e80
--- /dev/null
+++ b/gr-blocks/lib/vector_insert_X_impl.h.t
@@ -0,0 +1,58 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2012,2013 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.
+ */
+
+// @WARNING@
+
+#ifndef @GUARD_NAME_IMPL@
+#define @GUARD_NAME_IMPL@
+
+#include <blocks/@NAME@.h>
+
+namespace gr {
+ namespace blocks {
+
+ class @NAME_IMPL@ : public @NAME@
+ {
+ private:
+ std::vector<@TYPE@> d_data;
+ int d_offset;
+ int d_periodicity;
+
+ public:
+ @NAME_IMPL@(const std::vector<@TYPE@> &data,
+ int periodicity, int offset);
+ ~@NAME_IMPL@();
+
+ void rewind() { d_offset=0; }
+ void set_data(const std::vector<@TYPE@> &data) {
+ d_data = data; rewind(); }
+
+ int general_work(int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* @GUARD_NAME_IMPL@ */
diff --git a/gr-blocks/lib/vector_map_impl.cc b/gr-blocks/lib/vector_map_impl.cc
new file mode 100644
index 0000000000..cefaaeea35
--- /dev/null
+++ b/gr-blocks/lib/vector_map_impl.cc
@@ -0,0 +1,127 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2012,2013 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "vector_map_impl.h"
+#include <gr_io_signature.h>
+#include <string.h>
+
+namespace gr {
+ namespace blocks {
+
+ std::vector<int>
+ get_in_sizeofs(size_t item_size, std::vector<size_t> in_vlens)
+ {
+ std::vector<int> in_sizeofs;
+ for(unsigned int i = 0; i < in_vlens.size(); i++) {
+ in_sizeofs.push_back(in_vlens[i]*item_size);
+ }
+ return in_sizeofs;
+ }
+
+ std::vector<int>
+ get_out_sizeofs(size_t item_size,
+ std::vector< std::vector< std::vector<size_t> > > mapping)
+ {
+ std::vector<int> out_sizeofs;
+ for(unsigned int i = 0; i < mapping.size(); i++) {
+ out_sizeofs.push_back(mapping[i].size()*item_size);
+ }
+ return out_sizeofs;
+ }
+
+ vector_map::sptr
+ vector_map::make(size_t item_size, std::vector<size_t> in_vlens,
+ std::vector< std::vector< std::vector<size_t> > > mapping)
+ {
+ return gnuradio::get_initial_sptr
+ (new vector_map_impl(item_size, in_vlens, mapping));
+ }
+
+ vector_map_impl::vector_map_impl(size_t item_size, std::vector<size_t> in_vlens,
+ std::vector< std::vector< std::vector<size_t> > > mapping)
+ : gr_sync_block("vector_map",
+ gr_make_io_signaturev(in_vlens.size(), in_vlens.size(),
+ get_in_sizeofs(item_size, in_vlens)),
+ gr_make_io_signaturev(mapping.size(), mapping.size(),
+ get_out_sizeofs(item_size, mapping))),
+ d_item_size(item_size), d_in_vlens(in_vlens)
+ {
+ set_mapping(mapping);
+ }
+
+ vector_map_impl::~vector_map_impl()
+ {
+ }
+
+ void
+ vector_map_impl::set_mapping(std::vector< std::vector< std::vector<size_t> > > mapping)
+ {
+ // Make sure the contents of the mapping vectors are possible.
+ for(unsigned int i=0; i<mapping.size(); i++) {
+ for(unsigned int j=0; j<mapping[i].size(); j++) {
+ if(mapping[i][j].size() != 2) {
+ throw std::runtime_error("Mapping must be of the form (out_mapping_stream1, out_mapping_stream2, ...), where out_mapping_stream1 is of the form (mapping_element1, mapping_element2, ...), where mapping_element1 is of the form (input_stream, input_element). This error is raised because a mapping_element vector does not contain exactly 2 items.");
+ }
+ unsigned int s = mapping[i][j][0];
+ unsigned int index = mapping[i][j][1];
+ if(s >= d_in_vlens.size()) {
+ throw std::runtime_error("Stream numbers in mapping must be less than the number of input streams.");
+ }
+ if((index < 0) || (index >= d_in_vlens[s])) {
+ throw std::runtime_error ("Indices in mapping must be greater than 0 and less than the input vector lengths.");
+ }
+ }
+ }
+ gruel::scoped_lock guard(d_mutex);
+ d_mapping = mapping;
+ }
+
+ int
+ vector_map_impl::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ const char **inv = (const char**)&input_items[0];
+ char **outv = (char**)&output_items[0];
+
+ for(unsigned int n = 0; n < (unsigned int)(noutput_items); n++) {
+ for(unsigned int i = 0; i < d_mapping.size(); i++) {
+ unsigned int out_vlen = d_mapping[i].size();
+ for(unsigned int j = 0; j < out_vlen; j++) {
+ unsigned int s = d_mapping[i][j][0];
+ unsigned int k = d_mapping[i][j][1];
+ memcpy(outv[i] + out_vlen*d_item_size*n +
+ d_item_size*j, inv[s] + d_in_vlens[s]*d_item_size*n +
+ k*d_item_size, d_item_size);
+ }
+ }
+ }
+
+ return noutput_items;
+ }
+
+ } /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/vector_map_impl.h b/gr-blocks/lib/vector_map_impl.h
new file mode 100644
index 0000000000..e27b3b9cec
--- /dev/null
+++ b/gr-blocks/lib/vector_map_impl.h
@@ -0,0 +1,55 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2012,2013 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_VECTOR_MAP_IMPL_H
+#define INCLUDED_GR_VECTOR_MAP_IMPL_H
+
+#include <blocks/vector_map.h>
+#include <gruel/thread.h>
+
+namespace gr {
+ namespace blocks {
+
+ class vector_map_impl : public vector_map
+ {
+ private:
+ size_t d_item_size;
+ std::vector<size_t> d_in_vlens;
+ std::vector< std::vector< std::vector<size_t> > > d_mapping;
+ gruel::mutex d_mutex; // mutex to protect set/work access
+
+ public:
+ vector_map_impl(size_t item_size, std::vector<size_t> in_vlens,
+ std::vector< std::vector< std::vector<size_t> > > mapping);
+ ~vector_map_impl();
+
+ void set_mapping(std::vector< std::vector< std::vector<size_t> > > mapping);
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_GR_VECTOR_MAP_IMPL_H */
diff --git a/gr-blocks/lib/vector_sink_X_impl.cc.t b/gr-blocks/lib/vector_sink_X_impl.cc.t
new file mode 100644
index 0000000000..3be2861025
--- /dev/null
+++ b/gr-blocks/lib/vector_sink_X_impl.cc.t
@@ -0,0 +1,83 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2008,2010,2013 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.
+ */
+
+// @WARNING@
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <@NAME_IMPL@.h>
+#include <gr_io_signature.h>
+#include <algorithm>
+#include <iostream>
+
+namespace gr {
+ namespace blocks {
+
+ @NAME@::sptr
+ @BASE_NAME@::make(int vlen)
+ {
+ return gnuradio::get_initial_sptr
+ (new @NAME_IMPL@(vlen));
+ }
+
+ @NAME_IMPL@::@NAME_IMPL@(int vlen)
+ : gr_sync_block("@NAME@",
+ gr_make_io_signature(1, 1, sizeof(@TYPE@) * vlen),
+ gr_make_io_signature(0, 0, 0)),
+ d_vlen(vlen)
+ {
+ }
+
+ @NAME_IMPL@::~@NAME_IMPL@()
+ {}
+
+ std::vector<@TYPE@>
+ @NAME_IMPL@::data() const
+ {
+ return d_data;
+ }
+
+ std::vector<gr_tag_t>
+ @NAME_IMPL@::tags() const
+ {
+ return d_tags;
+ }
+
+ int
+ @NAME_IMPL@::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ @TYPE@ *iptr = (@TYPE@*)input_items[0];
+
+ for(int i = 0; i < noutput_items * d_vlen; i++)
+ d_data.push_back (iptr[i]);
+ std::vector<gr_tag_t> tags;
+ get_tags_in_range(tags, 0, nitems_read(0), nitems_read(0) + noutput_items);
+ d_tags.insert(d_tags.end(), tags.begin(), tags.end());
+ return noutput_items;
+ }
+
+ } /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/vector_sink_X_impl.h.t b/gr-blocks/lib/vector_sink_X_impl.h.t
new file mode 100644
index 0000000000..60d21e0c8c
--- /dev/null
+++ b/gr-blocks/lib/vector_sink_X_impl.h.t
@@ -0,0 +1,56 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2008,2009,2013 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.
+ */
+
+// @WARNING@
+
+#ifndef @GUARD_NAME_IMPL@
+#define @GUARD_NAME_IMPL@
+
+#include <blocks/@NAME@.h>
+
+namespace gr {
+ namespace blocks {
+
+ class @NAME_IMPL@ : public @NAME@
+ {
+ private:
+ std::vector<@TYPE@> d_data;
+ std::vector<gr_tag_t> d_tags;
+ int d_vlen;
+
+ public:
+ @NAME_IMPL@(int vlen);
+ ~@NAME_IMPL@();
+
+ void reset() { d_data.clear(); }
+ std::vector<@TYPE@> data() const;
+ std::vector<gr_tag_t> tags() const;
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* @GUARD_NAME_IMPL@ */
diff --git a/gr-blocks/lib/vector_source_X_impl.cc.t b/gr-blocks/lib/vector_source_X_impl.cc.t
new file mode 100644
index 0000000000..9c1c63a213
--- /dev/null
+++ b/gr-blocks/lib/vector_source_X_impl.cc.t
@@ -0,0 +1,144 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2008,2010,2013 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.
+ */
+
+// @WARNING@
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <@NAME_IMPL@.h>
+#include <algorithm>
+#include <gr_io_signature.h>
+#include <stdexcept>
+
+namespace gr {
+ namespace blocks {
+
+ @NAME@::sptr
+ @NAME@::make(const std::vector<@TYPE@> &data,
+ bool repeat, int vlen,
+ const std::vector<gr_tag_t> &tags)
+ {
+ return gnuradio::get_initial_sptr
+ (new @NAME_IMPL@(data, repeat, vlen, tags));
+ }
+
+ @NAME_IMPL@::@NAME_IMPL@(const std::vector<@TYPE@> &data,
+ bool repeat, int vlen,
+ const std::vector<gr_tag_t> &tags)
+ : gr_sync_block("@BASE_NAME@",
+ gr_make_io_signature(0, 0, 0),
+ gr_make_io_signature(1, 1, sizeof(@TYPE@) * vlen)),
+ d_data(data),
+ d_repeat(repeat),
+ d_offset(0),
+ d_vlen(vlen),
+ d_tags(tags),
+ d_tagpos(0)
+ {
+ if(tags.size() == 0) {
+ d_settags = 0;
+ }
+ else {
+ d_settags = 1;
+ set_output_multiple(data.size() / vlen);
+ }
+ if((data.size() % vlen) != 0)
+ throw std::invalid_argument("data length must be a multiple of vlen");
+ }
+
+ @NAME_IMPL@::~@NAME_IMPL@()
+ {}
+
+ void
+ @NAME_IMPL@::set_data (const std::vector<@TYPE@> &data,
+ const std::vector<gr_tag_t> &tags)
+ {
+ d_data = data;
+ d_tags = tags;
+ rewind();
+ if(tags.size() == 0) {
+ d_settags = false;
+ }
+ else {
+ d_settags = true;
+ }
+ }
+
+ int
+ @NAME_IMPL@::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ @TYPE@ *optr = (@TYPE@ *) output_items[0];
+
+ if(d_repeat) {
+ unsigned int size = d_data.size ();
+ unsigned int offset = d_offset;
+ if(size == 0)
+ return -1;
+
+ if(d_settags) {
+ int n_outputitems_per_vector = d_data.size() / d_vlen;
+ for(int i = 0; i < noutput_items; i += n_outputitems_per_vector) {
+ // FIXME do proper vector copy
+ memcpy((void *) optr, (const void*)&d_data[0], size*sizeof (@TYPE@));
+ optr += size;
+ for(unsigned t = 0; t < d_tags.size(); t++) {
+ add_item_tag(0, nitems_written(0)+i+d_tags[t].offset,
+ d_tags[t].key, d_tags[t].value);
+ }
+ }
+ }
+ else {
+ for(int i = 0; i < noutput_items*d_vlen; i++) {
+ optr[i] = d_data[offset++];
+ if(offset >= size) {
+ offset = 0;
+ }
+ }
+ }
+
+ d_offset = offset;
+ return noutput_items;
+ }
+ else {
+ if(d_offset >= d_data.size ())
+ return -1; // Done!
+
+ unsigned n = std::min((unsigned)d_data.size() - d_offset,
+ (unsigned)noutput_items*d_vlen);
+ for(unsigned i = 0; i < n; i++) {
+ optr[i] = d_data[d_offset + i];
+ }
+ for(unsigned t = 0; t < d_tags.size(); t++) {
+ if((d_tags[t].offset >= d_offset) && (d_tags[t].offset < d_offset+n))
+ add_item_tag(0, d_tags[t].offset, d_tags[t].key, d_tags[t].value);
+ }
+ d_offset += n;
+ return n/d_vlen;
+ }
+ }
+
+ } /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/vector_source_X_impl.h.t b/gr-blocks/lib/vector_source_X_impl.h.t
new file mode 100644
index 0000000000..78ec52bacf
--- /dev/null
+++ b/gr-blocks/lib/vector_source_X_impl.h.t
@@ -0,0 +1,62 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2008,2012-2013 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.
+ */
+
+// @WARNING@
+
+#ifndef @GUARD_NAME_IMPL@
+#define @GUARD_NAME_IMPL@
+
+#include <blocks/@NAME@.h>
+
+namespace gr {
+ namespace blocks {
+
+ class @NAME_IMPL@ : public @NAME@
+ {
+ private:
+ std::vector<@TYPE@> d_data;
+ bool d_repeat;
+ unsigned int d_offset;
+ int d_vlen;
+ bool d_settags;
+ std::vector<gr_tag_t> d_tags;
+ unsigned int d_tagpos;
+
+ public:
+ @NAME_IMPL@(const std::vector<@TYPE@> &data,
+ bool repeat, int vlen,
+ const std::vector<gr_tag_t> &tags);
+ ~@NAME_IMPL@();
+
+ void rewind() { d_offset=0; }
+ void set_data(const std::vector<@TYPE@> &data,
+ const std::vector<gr_tag_t> &tags);
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* @GUARD_NAME_IMPL@ */
diff --git a/gr-blocks/lib/wavfile.cc b/gr-blocks/lib/wavfile.cc
new file mode 100644
index 0000000000..16d80adc83
--- /dev/null
+++ b/gr-blocks/lib/wavfile.cc
@@ -0,0 +1,258 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2008,2012-2013 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <blocks/wavfile.h>
+#include <cstring>
+#include <stdint.h>
+#include <boost/detail/endian.hpp> //BOOST_BIG_ENDIAN
+
+namespace gr {
+ namespace blocks {
+
+#define VALID_COMPRESSION_TYPE 0x0001
+
+ // Basically, this is the opposite of htonx() and ntohx()
+ // Define host to/from worknet (little endian) short and long
+#ifdef BOOST_BIG_ENDIAN
+
+ static inline uint16_t __wav_bs16(uint16_t x)
+ {
+ return (x>>8) | (x<<8);
+ }
+
+ static inline uint32_t __wav_bs32(uint32_t x)
+ {
+ return (uint32_t(__wav_bs16(uint16_t(x&0xfffful)))<<16) | (__wav_bs16(uint16_t(x>>16)));
+ }
+
+ #define htowl(x) __gri_wav_bs32(x)
+ #define wtohl(x) __gri_wav_bs32(x)
+ #define htows(x) __gri_wav_bs16(x)
+ #define wtohs(x) __gri_wav_bs16(x)
+
+#else
+
+ #define htowl(x) uint32_t(x)
+ #define wtohl(x) uint32_t(x)
+ #define htows(x) uint16_t(x)
+ #define wtohs(x) uint16_t(x)
+
+#endif // BOOST_BIG_ENDIAN
+
+ // WAV files are always little-endian, so we need some byte switching macros
+ static inline uint32_t host_to_wav(uint32_t x) { return htowl(x); }
+ static inline uint16_t host_to_wav(uint16_t x) { return htows(x); }
+ static inline int16_t host_to_wav(int16_t x) { return htows(x); }
+ static inline uint32_t wav_to_host(uint32_t x) { return wtohl(x); }
+ static inline uint16_t wav_to_host(uint16_t x) { return wtohs(x); }
+ static inline int16_t wav_to_host(int16_t x) { return wtohs(x); }
+
+ bool
+ wavheader_parse(FILE *fp,
+ unsigned int &sample_rate_o,
+ int &nchans_o,
+ int &bytes_per_sample_o,
+ int &first_sample_pos_o,
+ unsigned int &samples_per_chan_o)
+ {
+ // _o variables take return values
+ char str_buf[8] = {0};
+
+ uint32_t file_size;
+ uint32_t fmt_hdr_skip;
+ uint16_t compression_type;
+ uint16_t nchans;
+ uint32_t sample_rate;
+ uint32_t avg_bytes_per_sec;
+ uint16_t block_align;
+ uint16_t bits_per_sample;
+ uint32_t chunk_size;
+
+ size_t fresult;
+
+ fresult = fread(str_buf, 1, 4, fp);
+ if(fresult != 4 || strncmp(str_buf, "RIFF", 4) || feof(fp)) {
+ return false;
+ }
+
+ fresult = fread(&file_size, 1, 4, fp);
+
+ fresult = fread(str_buf, 1, 8, fp);
+ if(fresult != 8 || strncmp(str_buf, "WAVEfmt ", 8) || feof(fp)) {
+ return false;
+ }
+
+ fresult = fread(&fmt_hdr_skip, 1, 4, fp);
+
+ fresult = fread(&compression_type, 1, 2, fp);
+ if(wav_to_host(compression_type) != VALID_COMPRESSION_TYPE) {
+ return false;
+ }
+
+ fresult = fread(&nchans, 1, 2, fp);
+ fresult = fread(&sample_rate, 1, 4, fp);
+ fresult = fread(&avg_bytes_per_sec, 1, 4, fp);
+ fresult = fread(&block_align, 1, 2, fp);
+ fresult = fread(&bits_per_sample, 1, 2, fp);
+
+ if(ferror(fp)) {
+ return false;
+ }
+
+ fmt_hdr_skip = wav_to_host(fmt_hdr_skip);
+ nchans = wav_to_host(nchans);
+ sample_rate = wav_to_host(sample_rate);
+ bits_per_sample = wav_to_host(bits_per_sample);
+
+ if(bits_per_sample != 8 && bits_per_sample != 16) {
+ return false;
+ }
+
+ fmt_hdr_skip -= 16;
+ if(fmt_hdr_skip) {
+ fseek(fp, fmt_hdr_skip, SEEK_CUR);
+ }
+
+ // data chunk
+ fresult = fread(str_buf, 1, 4, fp);
+ if(strncmp(str_buf, "data", 4)) {
+ return false;
+ }
+
+ fresult = fread(&chunk_size, 1, 4, fp);
+ if(ferror(fp)) {
+ return false;
+ }
+
+ // More byte swapping
+ chunk_size = wav_to_host(chunk_size);
+
+ // Output values
+ sample_rate_o = (unsigned)sample_rate;
+ nchans_o = (int)nchans;
+ bytes_per_sample_o = (int)(bits_per_sample / 8);
+ first_sample_pos_o = (int)ftell(fp);
+ samples_per_chan_o = (unsigned)(chunk_size / (bytes_per_sample_o * nchans));
+ return true;
+ }
+
+
+ short int
+ wav_read_sample(FILE *fp, int bytes_per_sample)
+ {
+ int16_t buf_16bit;
+
+ if(!fread(&buf_16bit, bytes_per_sample, 1, fp)) {
+ return 0;
+ }
+ if(bytes_per_sample == 1) {
+ return (short)buf_16bit;
+ }
+ return (short)wav_to_host(buf_16bit);
+ }
+
+
+ bool
+ wavheader_write(FILE *fp,
+ unsigned int sample_rate,
+ int nchans,
+ int bytes_per_sample)
+ {
+ const int header_len = 44;
+ char wav_hdr[header_len] = "RIFF\0\0\0\0WAVEfmt \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0data\0\0\0";
+ uint16_t nchans_f = (uint16_t) nchans;
+ uint32_t sample_rate_f = (uint32_t) sample_rate;
+ uint16_t block_align = bytes_per_sample * nchans;
+ uint32_t avg_bytes = sample_rate * block_align;
+ uint16_t bits_per_sample = bytes_per_sample * 8;
+
+ nchans_f = host_to_wav(nchans_f);
+ sample_rate_f = host_to_wav(sample_rate_f);
+ block_align = host_to_wav(block_align);
+ avg_bytes = host_to_wav(avg_bytes);
+ bits_per_sample = host_to_wav(bits_per_sample);
+
+ wav_hdr[16] = 0x10; // no extra bytes
+ wav_hdr[20] = 0x01; // no compression
+ memcpy((void*)(wav_hdr + 22), (void*)&nchans_f, 2);
+ memcpy((void*)(wav_hdr + 24), (void*)&sample_rate_f, 4);
+ memcpy((void*)(wav_hdr + 28), (void*)&avg_bytes, 4);
+ memcpy((void*)(wav_hdr + 32), (void*)&block_align, 2);
+ memcpy((void*)(wav_hdr + 34), (void*)&bits_per_sample, 2);
+
+ fwrite(&wav_hdr, 1, header_len, fp);
+ if(ferror(fp)) {
+ return false;
+ }
+
+ return true;
+ }
+
+
+ void
+ wav_write_sample(FILE *fp, short int sample, int bytes_per_sample)
+ {
+ void *data_ptr;
+ unsigned char buf_8bit;
+ int16_t buf_16bit;
+
+ if(bytes_per_sample == 1) {
+ buf_8bit = (unsigned char)sample;
+ data_ptr = (void*)&buf_8bit;
+ }
+ else {
+ buf_16bit = host_to_wav((int16_t) sample);
+ data_ptr = (void *) &buf_16bit;
+ }
+
+ fwrite(data_ptr, 1, bytes_per_sample, fp);
+ }
+
+
+ bool
+ wavheader_complete(FILE *fp, unsigned int byte_count)
+ {
+ uint32_t chunk_size = (uint32_t)byte_count;
+ chunk_size = host_to_wav(chunk_size);
+
+ fseek(fp, 40, SEEK_SET);
+ fwrite(&chunk_size, 1, 4, fp);
+
+ chunk_size = (uint32_t)byte_count + 36; // fmt chunk and data header
+ chunk_size = host_to_wav(chunk_size);
+ fseek(fp, 4, SEEK_SET);
+
+ fwrite(&chunk_size, 1, 4, fp);
+
+ if(ferror(fp)) {
+ return false;
+ }
+
+ return true;
+ }
+
+ } /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/wavfile_sink_impl.cc b/gr-blocks/lib/wavfile_sink_impl.cc
new file mode 100644
index 0000000000..f8b09a114b
--- /dev/null
+++ b/gr-blocks/lib/wavfile_sink_impl.cc
@@ -0,0 +1,293 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2006-2011,2013 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "wavfile_sink_impl.h"
+#include <blocks/wavfile.h>
+#include <gr_io_signature.h>
+#include <stdexcept>
+#include <climits>
+#include <cstring>
+#include <cmath>
+#include <fcntl.h>
+#include <gruel/thread.h>
+#include <boost/math/special_functions/round.hpp>
+
+// win32 (mingw/msvc) specific
+#ifdef HAVE_IO_H
+#include <io.h>
+#endif
+#ifdef O_BINARY
+#define OUR_O_BINARY O_BINARY
+#else
+#define OUR_O_BINARY 0
+#endif
+
+// should be handled via configure
+#ifdef O_LARGEFILE
+#define OUR_O_LARGEFILE O_LARGEFILE
+#else
+#define OUR_O_LARGEFILE 0
+#endif
+
+namespace gr {
+ namespace blocks {
+
+ wavfile_sink::sptr
+ wavfile_sink::make(const char *filename,
+ int n_channels,
+ unsigned int sample_rate,
+ int bits_per_sample)
+ {
+ return gnuradio::get_initial_sptr
+ (new wavfile_sink_impl(filename, n_channels,
+ sample_rate, bits_per_sample));
+ }
+
+ wavfile_sink_impl::wavfile_sink_impl(const char *filename,
+ int n_channels,
+ unsigned int sample_rate,
+ int bits_per_sample)
+ : gr_sync_block("wavfile_sink",
+ gr_make_io_signature(1, n_channels, sizeof(float)),
+ gr_make_io_signature(0, 0, 0)),
+ d_sample_rate(sample_rate), d_nchans(n_channels),
+ d_fp(0), d_new_fp(0), d_updated(false)
+ {
+ if(bits_per_sample != 8 && bits_per_sample != 16) {
+ throw std::runtime_error("Invalid bits per sample (supports 8 and 16)");
+ }
+ d_bytes_per_sample = bits_per_sample / 8;
+ d_bytes_per_sample_new = d_bytes_per_sample;
+
+ if(!open(filename)) {
+ throw std::runtime_error("can't open file");
+ }
+
+ if(bits_per_sample == 8) {
+ d_max_sample_val = 0xFF;
+ d_min_sample_val = 0;
+ d_normalize_fac = d_max_sample_val/2;
+ d_normalize_shift = 1;
+ }
+ else {
+ d_max_sample_val = 0x7FFF;
+ d_min_sample_val = -0x7FFF;
+ d_normalize_fac = d_max_sample_val;
+ d_normalize_shift = 0;
+ if(bits_per_sample != 16) {
+ fprintf(stderr, "Invalid bits per sample value requested, using 16");
+ }
+ }
+ }
+
+ bool
+ wavfile_sink_impl::open(const char* filename)
+ {
+ gruel::scoped_lock guard(d_mutex);
+
+ // we use the open system call to get access to the O_LARGEFILE flag.
+ int fd;
+ if((fd = ::open(filename,
+ O_WRONLY|O_CREAT|O_TRUNC|OUR_O_LARGEFILE|OUR_O_BINARY,
+ 0664)) < 0) {
+ perror(filename);
+ return false;
+ }
+
+ if(d_new_fp) { // if we've already got a new one open, close it
+ fclose(d_new_fp);
+ d_new_fp = 0;
+ }
+
+ if((d_new_fp = fdopen (fd, "wb")) == NULL) {
+ perror(filename);
+ ::close(fd); // don't leak file descriptor if fdopen fails.
+ return false;
+ }
+ d_updated = true;
+
+ if(!wavheader_write(d_new_fp,
+ d_sample_rate,
+ d_nchans,
+ d_bytes_per_sample_new)) {
+ fprintf(stderr, "[%s] could not write to WAV file\n", __FILE__);
+ exit(-1);
+ }
+
+ return true;
+ }
+
+ void
+ wavfile_sink_impl::close()
+ {
+ gruel::scoped_lock guard(d_mutex);
+
+ if(!d_fp)
+ return;
+
+ close_wav();
+ }
+
+ void
+ wavfile_sink_impl::close_wav()
+ {
+ unsigned int byte_count = d_sample_count * d_bytes_per_sample;
+
+ wavheader_complete(d_fp, byte_count);
+
+ fclose(d_fp);
+ d_fp = NULL;
+ }
+
+ wavfile_sink_impl::~wavfile_sink_impl()
+ {
+ if(d_new_fp) {
+ fclose(d_new_fp);
+ }
+
+ close();
+ }
+
+ int
+ wavfile_sink_impl::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ float **in = (float**)&input_items[0];
+ int n_in_chans = input_items.size();
+
+ short int sample_buf_s;
+
+ int nwritten;
+
+ gruel::scoped_lock guard(d_mutex); // hold mutex for duration of this block
+ do_update(); // update: d_fp is reqd
+ if(!d_fp) // drop output on the floor
+ return noutput_items;
+
+ for(nwritten = 0; nwritten < noutput_items; nwritten++) {
+ for(int chan = 0; chan < d_nchans; chan++) {
+ // Write zeros to channels which are in the WAV file
+ // but don't have any inputs here
+ if(chan < n_in_chans) {
+ sample_buf_s =
+ convert_to_short(in[chan][nwritten]);
+ }
+ else {
+ sample_buf_s = 0;
+ }
+
+ wav_write_sample(d_fp, sample_buf_s, d_bytes_per_sample);
+
+ if(feof(d_fp) || ferror(d_fp)) {
+ fprintf(stderr, "[%s] file i/o error\n", __FILE__);
+ close();
+ exit(-1);
+ }
+ d_sample_count++;
+ }
+ }
+
+ return nwritten;
+ }
+
+ short int
+ wavfile_sink_impl::convert_to_short(float sample)
+ {
+ sample += d_normalize_shift;
+ sample *= d_normalize_fac;
+ if(sample > d_max_sample_val) {
+ sample = d_max_sample_val;
+ }
+ else if(sample < d_min_sample_val) {
+ sample = d_min_sample_val;
+ }
+
+ return (short int)boost::math::iround(sample);
+ }
+
+ void
+ wavfile_sink_impl::set_bits_per_sample(int bits_per_sample)
+ {
+ gruel::scoped_lock guard(d_mutex);
+ if(bits_per_sample == 8 || bits_per_sample == 16) {
+ d_bytes_per_sample_new = bits_per_sample / 8;
+ }
+ }
+
+ void
+ wavfile_sink_impl::set_sample_rate(unsigned int sample_rate)
+ {
+ gruel::scoped_lock guard(d_mutex);
+ d_sample_rate = sample_rate;
+ }
+
+ int
+ wavfile_sink_impl::bits_per_sample()
+ {
+ return d_bytes_per_sample_new;
+ }
+
+ unsigned int
+ wavfile_sink_impl::sample_rate()
+ {
+ return d_sample_rate;
+ }
+
+ void
+ wavfile_sink_impl::do_update()
+ {
+ if(!d_updated) {
+ return;
+ }
+
+ if(d_fp) {
+ close_wav();
+ }
+
+ d_fp = d_new_fp; // install new file pointer
+ d_new_fp = 0;
+ d_sample_count = 0;
+ d_bytes_per_sample = d_bytes_per_sample_new;
+
+ if(d_bytes_per_sample == 1) {
+ d_max_sample_val = UCHAR_MAX;
+ d_min_sample_val = 0;
+ d_normalize_fac = d_max_sample_val/2;
+ d_normalize_shift = 1;
+ }
+ else if(d_bytes_per_sample == 2) {
+ d_max_sample_val = SHRT_MAX;
+ d_min_sample_val = SHRT_MIN;
+ d_normalize_fac = d_max_sample_val;
+ d_normalize_shift = 0;
+ }
+
+ d_updated = false;
+ }
+
+ } /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/wavfile_sink_impl.h b/gr-blocks/lib/wavfile_sink_impl.h
new file mode 100644
index 0000000000..8a364f2b90
--- /dev/null
+++ b/gr-blocks/lib/wavfile_sink_impl.h
@@ -0,0 +1,95 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008,2009,2013 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_WAVFILE_SINK_IMPL_H
+#define INCLUDED_GR_WAVFILE_SINK_IMPL_H
+
+#include <blocks/wavfile_sink.h>
+#include <gr_file_sink_base.h>
+
+namespace gr {
+ namespace blocks {
+
+ class wavfile_sink_impl : public wavfile_sink
+ {
+ private:
+ unsigned d_sample_rate;
+ int d_nchans;
+ unsigned d_sample_count;
+ int d_bytes_per_sample;
+ int d_bytes_per_sample_new;
+ int d_max_sample_val;
+ int d_min_sample_val;
+ int d_normalize_shift;
+ int d_normalize_fac;
+
+ FILE *d_fp;
+ FILE *d_new_fp;
+ bool d_updated;
+ boost::mutex d_mutex;
+
+ /*!
+ * \brief Convert a sample value within [-1;+1] to a corresponding
+ * short integer value
+ */
+ short convert_to_short(float sample);
+
+ /*!
+ * \brief If any file changes have occurred, update now. This is called
+ * internally by work() and thus doesn't usually need to be called by
+ * hand.
+ */
+ void do_update();
+
+ /*!
+ * \brief Writes information to the WAV header which is not available
+ * a-priori (chunk size etc.) and closes the file. Not thread-safe and
+ * assumes d_fp is a valid file pointer, should thus only be called by
+ * other methods.
+ */
+ void close_wav();
+
+ public:
+ wavfile_sink_impl(const char *filename,
+ int n_channels,
+ unsigned int sample_rate,
+ int bits_per_sample);
+ ~wavfile_sink_impl();
+
+ bool open(const char* filename);
+ void close();
+
+ void set_sample_rate(unsigned int sample_rate);
+ void set_bits_per_sample(int bits_per_sample);
+
+ int bits_per_sample();
+ unsigned int sample_rate();
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_GR_WAVFILE_SINK_IMPL_H */
diff --git a/gr-blocks/lib/wavfile_source_impl.cc b/gr-blocks/lib/wavfile_source_impl.cc
new file mode 100644
index 0000000000..2e3b0e240c
--- /dev/null
+++ b/gr-blocks/lib/wavfile_source_impl.cc
@@ -0,0 +1,174 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2008,2010,2013 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "wavfile_source_impl.h"
+#include <gr_io_signature.h>
+#include <blocks/wavfile.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include <stdexcept>
+
+// win32 (mingw/msvc) specific
+#ifdef HAVE_IO_H
+#include <io.h>
+#endif
+#ifdef O_BINARY
+#define OUR_O_BINARY O_BINARY
+#else
+#define OUR_O_BINARY 0
+#endif
+// should be handled via configure
+#ifdef O_LARGEFILE
+#define OUR_O_LARGEFILE O_LARGEFILE
+#else
+#define OUR_O_LARGEFILE 0
+#endif
+
+namespace gr {
+ namespace blocks {
+
+ wavfile_source::sptr
+ wavfile_source::make(const char *filename, bool repeat)
+ {
+ return gnuradio::get_initial_sptr
+ (new wavfile_source_impl(filename, repeat));
+ }
+
+ wavfile_source_impl::wavfile_source_impl (const char *filename, bool repeat)
+ : gr_sync_block("wavfile_source",
+ gr_make_io_signature(0, 0, 0),
+ gr_make_io_signature(1, 2, sizeof(float))),
+ d_fp(NULL), d_repeat(repeat),
+ d_sample_rate(1), d_nchans(1), d_bytes_per_sample(2), d_first_sample_pos(0),
+ d_samples_per_chan(0), d_sample_idx(0)
+ {
+ // we use "open" to use to the O_LARGEFILE flag
+
+ int fd;
+ if((fd = open (filename, O_RDONLY | OUR_O_LARGEFILE | OUR_O_BINARY)) < 0) {
+ perror(filename);
+ throw std::runtime_error("can't open file");
+ }
+
+ if((d_fp = fdopen(fd, "rb")) == NULL) {
+ perror(filename);
+ throw std::runtime_error("can't open file");
+ }
+
+ // Scan headers, check file validity
+ if(!wavheader_parse(d_fp,
+ d_sample_rate,
+ d_nchans,
+ d_bytes_per_sample,
+ d_first_sample_pos,
+ d_samples_per_chan)) {
+ throw std::runtime_error("is not a valid wav file");
+ }
+
+ if(d_samples_per_chan == 0) {
+ throw std::runtime_error("WAV file does not contain any samples");
+ }
+
+ if(d_bytes_per_sample == 1) {
+ d_normalize_fac = 128;
+ d_normalize_shift = 1;
+ }
+ else {
+ d_normalize_fac = 0x7FFF;
+ d_normalize_shift = 0;
+ }
+
+ // Re-set the output signature
+ set_output_signature(gr_make_io_signature(1, d_nchans, sizeof(float)));
+ }
+
+ wavfile_source_impl::~wavfile_source_impl ()
+ {
+ fclose(d_fp);
+ }
+
+ float
+ wavfile_source_impl::convert_to_float(short int sample)
+ {
+ float sample_out = (float)sample;
+ sample_out /= d_normalize_fac;
+ sample_out -= d_normalize_shift;
+ return sample_out;
+ }
+
+ int
+ wavfile_source_impl::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ float **out = (float**)&output_items[0];
+ int n_out_chans = output_items.size();
+
+ int i;
+ short sample;
+
+ for(i = 0; i < noutput_items; i++) {
+ if(d_sample_idx >= d_samples_per_chan) {
+ if(!d_repeat) {
+ // if nothing was read at all, say we're done.
+ return i ? i : -1;
+ }
+
+ if(fseek (d_fp, d_first_sample_pos, SEEK_SET) == -1) {
+ fprintf(stderr, "[%s] fseek failed\n", __FILE__);
+ exit(-1);
+ }
+
+ d_sample_idx = 0;
+ }
+
+ for(int chan = 0; chan < d_nchans; chan++) {
+ sample = wav_read_sample(d_fp, d_bytes_per_sample);
+
+ if(chan < n_out_chans) {
+ out[chan][i] = convert_to_float(sample);
+ }
+ }
+
+ d_sample_idx++;
+
+ // OK, EOF is not necessarily an error. But we're not going to
+ // deal with handling corrupt wav files, so if they give us any
+ // trouble they won't be processed. Serves them bloody right.
+ if(feof(d_fp) || ferror(d_fp)) {
+ if(i == 0) {
+ fprintf(stderr, "[%s] WAV file has corrupted header or i/o error\n", __FILE__);
+ return -1;
+ }
+ return i;
+ }
+ }
+
+ return noutput_items;
+ }
+
+ } /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/wavfile_source_impl.h b/gr-blocks/lib/wavfile_source_impl.h
new file mode 100644
index 0000000000..4875731a08
--- /dev/null
+++ b/gr-blocks/lib/wavfile_source_impl.h
@@ -0,0 +1,70 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2008,2013 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_WAVFILE_SOURCE_IMPL_H
+#define INCLUDED_GR_WAVFILE_SOURCE_IMPL_H
+
+#include <blocks/wavfile_source.h>
+#include <cstdio> // for FILE
+
+namespace gr {
+ namespace blocks {
+
+ class wavfile_source_impl : public wavfile_source
+ {
+ private:
+ FILE *d_fp;
+ bool d_repeat;
+
+ unsigned d_sample_rate;
+ int d_nchans;
+ int d_bytes_per_sample;
+ int d_first_sample_pos;
+ unsigned d_samples_per_chan;
+ unsigned d_sample_idx;
+ int d_normalize_shift;
+ int d_normalize_fac;
+
+ /*!
+ * \brief Convert an integer sample value to a float value within [-1;1]
+ */
+ float convert_to_float(short int sample);
+
+ public:
+ wavfile_source_impl(const char *filename, bool repeat);
+ ~wavfile_source_impl();
+
+ unsigned int sample_rate() const { return d_sample_rate; };
+
+ int bits_per_sample() const { return d_bytes_per_sample * 8; };
+
+ int channels() const { return d_nchans; };
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_GR_WAVFILE_SOURCE_IMPL_H */
diff --git a/gr-blocks/python/qa_argmax.py b/gr-blocks/python/qa_argmax.py
new file mode 100644
index 0000000000..ec82b71cd4
--- /dev/null
+++ b/gr-blocks/python/qa_argmax.py
@@ -0,0 +1,73 @@
+#!/usr/bin/env python
+#
+# Copyright 2007,2010,2013 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.
+#
+
+from gnuradio import gr, gr_unittest
+import blocks_swig as blocks
+import math
+
+class test_arg_max(gr_unittest.TestCase):
+
+ def setUp(self):
+ self.tb = gr.top_block()
+
+ def tearDown(self):
+ self.tb = None
+
+ def test_001(self):
+ tb = self.tb
+
+ src1_data = (0,0.2,-0.3,0,12,0)
+ src2_data = (0,0.0,3.0,0,10,0)
+ src3_data = (0,0.0,3.0,0,1,0)
+
+ src1 = gr.vector_source_f(src1_data)
+ s2v1 = blocks.stream_to_vector(gr.sizeof_float, len(src1_data))
+ tb.connect(src1, s2v1)
+
+ src2 = gr.vector_source_f(src2_data)
+ s2v2 = blocks.stream_to_vector(gr.sizeof_float, len(src1_data))
+ tb.connect(src2, s2v2)
+
+ src3 = gr.vector_source_f(src3_data)
+ s2v3 = blocks.stream_to_vector(gr.sizeof_float, len(src1_data))
+ tb.connect(src3, s2v3)
+
+ dst1 = gr.vector_sink_s()
+ dst2 = gr.vector_sink_s()
+ argmax = blocks.argmax_fs(len(src1_data))
+
+ tb.connect(s2v1, (argmax, 0))
+ tb.connect(s2v2, (argmax, 1))
+ tb.connect(s2v3, (argmax, 2))
+
+ tb.connect((argmax,0), dst1)
+ tb.connect((argmax,1), dst2)
+
+ tb.run()
+ index = dst1.data()
+ source = dst2.data()
+ self.assertEqual(index, (4,))
+ self.assertEqual(source, (0,))
+
+if __name__ == '__main__':
+ gr_unittest.run(test_arg_max, "test_arg_max.xml")
+
diff --git a/gr-blocks/python/qa_bin_statistics.py b/gr-blocks/python/qa_bin_statistics.py
new file mode 100755
index 0000000000..c1b3072530
--- /dev/null
+++ b/gr-blocks/python/qa_bin_statistics.py
@@ -0,0 +1,227 @@
+#!/usr/bin/env python
+#
+# Copyright 2006,2007,2010,2013 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.
+#
+
+from gnuradio import gr, gr_unittest
+import blocks_swig as blocks
+import random
+import struct
+
+"""
+Note: There has been an issue with this block in the past, see Issue
+#199. This looks like it might have fixed itself over the years. I am
+leaving these tests disabled on our master branch for v3.6 for now,
+though, just in case. TWR.
+"""
+
+class counter(gr.feval_dd):
+ def __init__(self, step_size=1):
+ gr.feval_dd.__init__(self)
+ self.step_size = step_size
+ self.count = 0
+
+ def eval(self, input):
+ #print "eval: self.count =", self.count
+ t = self.count
+ self.count = self.count + self.step_size
+ return t
+
+
+class counter3(gr.feval_dd):
+ def __init__(self, f, step_size):
+ gr.feval_dd.__init__(self)
+ self.f = f
+ self.step_size = step_size
+ self.count = 0
+
+ def eval(self, input):
+ try:
+ #print "eval: self.count =", self.count
+ t = self.count
+ self.count = self.count + self.step_size
+ self.f(self.count)
+ except Exception, e:
+ print "Exception: ", e
+ return t
+
+def foobar3(new_t):
+ #print "foobar3: new_t =", new_t
+ pass
+
+
+class counter4(gr.feval_dd):
+ def __init__(self, obj_instance, step_size):
+ gr.feval_dd.__init__(self)
+ self.obj_instance = obj_instance
+ self.step_size = step_size
+ self.count = 0
+
+ def eval(self, input):
+ try:
+ #print "eval: self.count =", self.count
+ t = self.count
+ self.count = self.count + self.step_size
+ self.obj_instance.foobar4(self.count)
+ except Exception, e:
+ print "Exception: ", e
+ return t
+
+
+class parse_msg(object):
+ def __init__(self, msg):
+ self.center_freq = msg.arg1()
+ self.vlen = int(msg.arg2())
+ assert(msg.length() == self.vlen * gr.sizeof_float)
+ self.data = struct.unpack('%df' % (self.vlen,), msg.to_string())
+
+class test_bin_statistics(gr_unittest.TestCase):
+
+ def setUp(self):
+ self.tb = gr.top_block ()
+
+ def tearDown(self):
+ self.tb = None
+
+ def xtest_001(self):
+ vlen = 4
+ tune = counter(1)
+ tune_delay = 0
+ dwell_delay = 1
+ msgq = gr.msg_queue()
+
+ src_data = tuple([float(x) for x in
+ ( 1, 2, 3, 4,
+ 5, 6, 7, 8,
+ 9, 10, 11, 12,
+ 13, 14, 15, 16
+ )])
+
+ expected_results = tuple([float(x) for x in
+ ( 1, 2, 3, 4,
+ 5, 6, 7, 8,
+ 9, 10, 11, 12,
+ 13, 14, 15, 16
+ )])
+
+ src = gr.vector_source_f(src_data, False)
+ s2v = blocks.stream_to_vector(gr.sizeof_float, vlen)
+ stats = blocks.bin_statistics_f(vlen, msgq, tune, tune_delay, dwell_delay)
+ self.tb.connect(src, s2v, stats)
+ self.tb.run()
+ self.assertEqual(4, msgq.count())
+ for i in range(4):
+ m = parse_msg(msgq.delete_head())
+ #print "m =", m.center_freq, m.data
+ self.assertEqual(expected_results[vlen*i:vlen*i + vlen], m.data)
+
+ def xtest_002(self):
+ vlen = 4
+ tune = counter(1)
+ tune_delay = 1
+ dwell_delay = 2
+ msgq = gr.msg_queue()
+
+ src_data = tuple([float(x) for x in
+ ( 1, 2, 3, 4,
+ 9, 6, 11, 8,
+ 5, 10, 7, 12,
+ 13, 14, 15, 16
+ )])
+
+ expected_results = tuple([float(x) for x in
+ ( 9, 10, 11, 12)])
+
+ src = gr.vector_source_f(src_data, False)
+ s2v = blocks.stream_to_vector(gr.sizeof_float, vlen)
+ stats = blocks.bin_statistics_f(vlen, msgq, tune, tune_delay, dwell_delay)
+ self.tb.connect(src, s2v, stats)
+ self.tb.run()
+ self.assertEqual(1, msgq.count())
+ for i in range(1):
+ m = parse_msg(msgq.delete_head())
+ #print "m =", m.center_freq, m.data
+ self.assertEqual(expected_results[vlen*i:vlen*i + vlen], m.data)
+
+
+
+ def xtest_003(self):
+ vlen = 4
+ tune = counter3(foobar3, 1)
+ tune_delay = 1
+ dwell_delay = 2
+ msgq = gr.msg_queue()
+
+ src_data = tuple([float(x) for x in
+ ( 1, 2, 3, 4,
+ 9, 6, 11, 8,
+ 5, 10, 7, 12,
+ 13, 14, 15, 16
+ )])
+
+ expected_results = tuple([float(x) for x in
+ ( 9, 10, 11, 12)])
+
+ src = gr.vector_source_f(src_data, False)
+ s2v = blocks.stream_to_vector(gr.sizeof_float, vlen)
+ stats = blocks.bin_statistics_f(vlen, msgq, tune, tune_delay, dwell_delay)
+ self.tb.connect(src, s2v, stats)
+ self.tb.run()
+ self.assertEqual(1, msgq.count())
+ for i in range(1):
+ m = parse_msg(msgq.delete_head())
+ #print "m =", m.center_freq, m.data
+ self.assertEqual(expected_results[vlen*i:vlen*i + vlen], m.data)
+
+ def foobar4(self, new_t):
+ #print "foobar4: new_t =", new_t
+ pass
+
+ def xtest_004(self):
+ vlen = 4
+ tune = counter4(self, 1)
+ tune_delay = 1
+ dwell_delay = 2
+ msgq = gr.msg_queue()
+
+ src_data = tuple([float(x) for x in
+ ( 1, 2, 3, 4,
+ 9, 6, 11, 8,
+ 5, 10, 7, 12,
+ 13, 14, 15, 16
+ )])
+
+ expected_results = tuple([float(x) for x in
+ ( 9, 10, 11, 12)])
+
+ src = gr.vector_source_f(src_data, False)
+ s2v = blocks.stream_to_vector(gr.sizeof_float, vlen)
+ stats = blocks.bin_statistics_f(vlen, msgq, tune, tune_delay, dwell_delay)
+ self.tb.connect(src, s2v, stats)
+ self.tb.run()
+ self.assertEqual(1, msgq.count())
+ for i in range(1):
+ m = parse_msg(msgq.delete_head())
+ #print "m =", m.center_freq, m.data
+ self.assertEqual(expected_results[vlen*i:vlen*i + vlen], m.data)
+
+
+if __name__ == '__main__':
+ gr_unittest.run(test_bin_statistics, "test_bin_statistics.xml")
diff --git a/gr-blocks/python/qa_burst_tagger.py b/gr-blocks/python/qa_burst_tagger.py
new file mode 100644
index 0000000000..c89ece4e15
--- /dev/null
+++ b/gr-blocks/python/qa_burst_tagger.py
@@ -0,0 +1,59 @@
+#!/usr/bin/env python
+#
+# Copyright 2013 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.
+#
+
+from gnuradio import gr, gr_unittest
+import blocks_swig as blocks
+import pmt
+
+class test_burst_tagger(gr_unittest.TestCase):
+
+ def setUp(self):
+ self.tb = gr.top_block()
+
+ def tearDown(self):
+ self.tb = None
+
+ def test_001(self):
+ src_data = ( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
+ trg_data = (-1, -1, 1, 1, -1, -1, 1, 1, -1, -1)
+ src = gr.vector_source_i(src_data)
+ trg = gr.vector_source_s(trg_data)
+ op = blocks.burst_tagger(gr.sizeof_int)
+ snk = blocks.tag_debug(gr.sizeof_int, "burst tagger QA")
+ self.tb.connect(src, (op,0))
+ self.tb.connect(trg, (op,1))
+ self.tb.connect(op, snk)
+ self.tb.run()
+
+ x = snk.current_tags()
+ self.assertEqual(2, x[0].offset)
+ self.assertEqual(4, x[1].offset)
+ self.assertEqual(6, x[2].offset)
+ self.assertEqual(8, x[3].offset)
+
+ self.assertEqual(True, pmt.pmt_to_bool(x[0].value))
+ self.assertEqual(False, pmt.pmt_to_bool(x[1].value))
+ self.assertEqual(True, pmt.pmt_to_bool(x[2].value))
+ self.assertEqual(False, pmt.pmt_to_bool(x[3].value))
+
+if __name__ == '__main__':
+ gr_unittest.run(test_burst_tagger, "test_burst_tagger.xml")
diff --git a/gr-blocks/python/qa_copy.py b/gr-blocks/python/qa_copy.py
new file mode 100755
index 0000000000..012d790609
--- /dev/null
+++ b/gr-blocks/python/qa_copy.py
@@ -0,0 +1,58 @@
+#!/usr/bin/env python
+#
+# Copyright 2009,2010,2013 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.
+#
+
+from gnuradio import gr, gr_unittest
+import blocks_swig as blocks
+
+class test_copy(gr_unittest.TestCase):
+
+ def setUp(self):
+ self.tb = gr.top_block()
+
+ def tearDown(self):
+ self.tb = None
+
+ def test_copy(self):
+ src_data = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
+ expected_result = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
+ src = blocks.vector_source_b(src_data)
+ op = blocks.copy(gr.sizeof_char)
+ dst = blocks.vector_sink_b()
+ self.tb.connect(src, op, dst)
+ self.tb.run()
+ dst_data = dst.data()
+ self.assertEqual(expected_result, dst_data)
+
+ def test_copy_drop (self):
+ src_data = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
+ expected_result = ()
+ src = blocks.vector_source_b(src_data)
+ op = gr.copy(gr.sizeof_char)
+ op.set_enabled(False)
+ dst = blocks.vector_sink_b()
+ self.tb.connect(src, op, dst)
+ self.tb.run()
+ dst_data = dst.data()
+ self.assertEqual(expected_result, dst_data)
+
+if __name__ == '__main__':
+ gr_unittest.run(test_copy, "test_copy.xml")
diff --git a/gr-blocks/python/qa_endian_swap.py b/gr-blocks/python/qa_endian_swap.py
new file mode 100644
index 0000000000..5180293052
--- /dev/null
+++ b/gr-blocks/python/qa_endian_swap.py
@@ -0,0 +1,66 @@
+#!/usr/bin/env python
+#
+# Copyright 2011-2013 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.
+#
+
+from gnuradio import gr, gr_unittest
+import blocks_swig as blocks
+import ctypes
+
+class test_endian_swap(gr_unittest.TestCase):
+
+ def setUp(self):
+ self.tb = gr.top_block()
+
+ def tearDown(self):
+ self.tb = None
+
+ def test_001(self):
+ src_data = [1,2,3,4]
+ expected_result = [256, 512, 768, 1024];
+
+ src = blocks.vector_source_s(src_data)
+ op = blocks.endian_swap(2)
+ dst = blocks.vector_sink_s()
+
+ self.tb.connect(src, op, dst)
+ self.tb.run()
+ result_data = list(dst.data())
+
+ self.assertEqual(expected_result, result_data)
+
+ def test_002(self):
+
+ src_data = [1,2,3,4]
+ expected_result = [16777216, 33554432, 50331648, 67108864];
+
+ src = blocks.vector_source_i(src_data)
+ op = blocks.endian_swap(4)
+ dst = blocks.vector_sink_i()
+
+ self.tb.connect(src, op, dst)
+ self.tb.run()
+ result_data = list(dst.data())
+
+ self.assertEqual(expected_result, result_data)
+
+if __name__ == '__main__':
+ gr_unittest.run(test_endian_swap, "test_endian_swap.xml")
+
diff --git a/gr-blocks/python/qa_file_source_sink.py b/gr-blocks/python/qa_file_source_sink.py
new file mode 100644
index 0000000000..d1d67074d5
--- /dev/null
+++ b/gr-blocks/python/qa_file_source_sink.py
@@ -0,0 +1,93 @@
+#!/usr/bin/env python
+#
+# Copyright 2013 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.
+#
+
+from gnuradio import gr, gr_unittest
+import blocks_swig as blocks
+import os
+
+class test_file_source_sink(gr_unittest.TestCase):
+
+ def setUp (self):
+ self.tb = gr.top_block ()
+
+ def tearDown (self):
+ self.tb = None
+
+ def test_001(self):
+ src_data = range(1000)
+ expected_result = range(1000)
+
+ filename = "tmp.32f"
+ src = gr.vector_source_f(src_data)
+ snk = blocks.file_sink(gr.sizeof_float, filename)
+ snk.set_unbuffered(True)
+
+ src2 = blocks.file_source(gr.sizeof_float, filename)
+ snk2 = gr.vector_sink_f()
+
+ self.tb.connect(src, snk)
+ self.tb.run()
+
+ self.tb.disconnect(src, snk)
+ self.tb.connect(src2, snk2)
+ self.tb.run()
+
+ os.remove(filename)
+
+ result_data = snk2.data()
+ self.assertFloatTuplesAlmostEqual(expected_result, result_data)
+
+ def test_descriptor_001(self):
+ src_data = range(1000)
+ expected_result = range(1000)
+
+ filename = "tmp.32f"
+ fhandle0 = open(filename, "wb")
+ fd0 = fhandle0.fileno()
+
+ src = gr.vector_source_f(src_data)
+ snk = blocks.file_descriptor_sink(gr.sizeof_float, fd0)
+
+ self.tb.connect(src, snk)
+ self.tb.run()
+ os.fsync(fd0)
+ fhandle0.close()
+
+ fhandle1 = open(filename, "rb")
+ fd1 = fhandle1.fileno()
+ src2 = blocks.file_descriptor_source(gr.sizeof_float, fd1, False)
+ snk2 = gr.vector_sink_f()
+
+ self.tb.disconnect(src, snk)
+ self.tb.connect(src2, snk2)
+ self.tb.run()
+ os.fsync(fd1)
+ fhandle1.close()
+
+ os.remove(filename)
+
+ result_data = snk2.data()
+ self.assertFloatTuplesAlmostEqual(expected_result, result_data)
+
+if __name__ == '__main__':
+ gr_unittest.run(test_file_source_sink, "test_file_source_sink.xml")
+
diff --git a/gr-blocks/python/qa_head.py b/gr-blocks/python/qa_head.py
new file mode 100755
index 0000000000..39b1255978
--- /dev/null
+++ b/gr-blocks/python/qa_head.py
@@ -0,0 +1,47 @@
+#!/usr/bin/env python
+#
+# Copyright 2004,2007,2010,2013 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.
+#
+
+from gnuradio import gr, gr_unittest
+import blocks_swig as blocks
+
+class test_head(gr_unittest.TestCase):
+
+ def setUp(self):
+ self.tb = gr.top_block()
+
+ def tearDown(self):
+ self.tb = None
+
+ def test_head(self):
+ src_data = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
+ expected_result = (1, 2, 3, 4)
+ src1 = blocks.vector_source_i(src_data)
+ op = blocks.head(gr.sizeof_int, 4)
+ dst1 = blocks.vector_sink_i()
+ self.tb.connect(src1, op)
+ self.tb.connect(op, dst1)
+ self.tb.run()
+ dst_data = dst1.data()
+ self.assertEqual(expected_result, dst_data)
+
+if __name__ == '__main__':
+ gr_unittest.run(test_head, "test_head.xml")
diff --git a/gr-blocks/python/qa_max.py b/gr-blocks/python/qa_max.py
new file mode 100755
index 0000000000..4af70bd4be
--- /dev/null
+++ b/gr-blocks/python/qa_max.py
@@ -0,0 +1,65 @@
+#!/usr/bin/env python
+#
+# Copyright 2007,2010,2013 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.
+#
+
+from gnuradio import gr, gr_unittest
+import blocks_swig as blocks
+import math
+
+class test_max(gr_unittest.TestCase):
+
+ def setUp(self):
+ self.tb = gr.top_block()
+
+ def tearDown(self):
+ self.tb = None
+
+ def test_001(self):
+ src_data = (0,0.2,-0.3,0,12,0)
+ expected_result = (float(max(src_data)),)
+
+ src = gr.vector_source_f(src_data)
+ s2v = blocks.stream_to_vector(gr.sizeof_float, len(src_data))
+ op = blocks.max_ff(len(src_data))
+ dst = gr.vector_sink_f()
+
+ self.tb.connect(src, s2v, op, dst)
+ self.tb.run()
+ result_data = dst.data()
+ self.assertEqual(expected_result, result_data)
+
+ def test_002(self):
+ src_data=(-100,-99,-98,-97,-96,-1)
+ expected_result = (float(max(src_data)),)
+
+ src = gr.vector_source_f(src_data)
+ s2v = blocks.stream_to_vector(gr.sizeof_float, len(src_data))
+ op = blocks.max_ff(len(src_data))
+ dst = gr.vector_sink_f()
+
+ self.tb.connect(src, s2v, op, dst)
+ self.tb.run()
+ result_data = dst.data()
+ self.assertEqual(expected_result, result_data)
+
+if __name__ == '__main__':
+ gr_unittest.run(test_max, "test_max.xml")
+
diff --git a/gr-blocks/python/qa_message.py b/gr-blocks/python/qa_message.py
new file mode 100755
index 0000000000..551fdd6259
--- /dev/null
+++ b/gr-blocks/python/qa_message.py
@@ -0,0 +1,149 @@
+#!/usr/bin/env python
+#
+# Copyright 2004,2010,2013 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.
+#
+
+from gnuradio import gr, gr_unittest
+import blocks_swig as blocks
+import pmt
+import time
+
+def all_counts():
+ return (gr.block_ncurrently_allocated(),
+ gr.block_detail_ncurrently_allocated(),
+ gr.buffer_ncurrently_allocated(),
+ gr.buffer_reader_ncurrently_allocated(),
+ gr.message_ncurrently_allocated())
+
+
+class test_message(gr_unittest.TestCase):
+
+ def setUp(self):
+ self.msgq = gr.msg_queue()
+
+ def tearDown(self):
+ self.msgq = None
+
+ def leak_check(self, fct):
+ begin = all_counts()
+ fct()
+ # tear down early so we can check for leaks
+ self.tearDown()
+ end = all_counts()
+ self.assertEqual(begin, end)
+
+ def test_100(self):
+ msg = gr.message(0, 1.5, 2.3)
+ self.assertEquals(0, msg.type())
+ self.assertAlmostEqual(1.5, msg.arg1())
+ self.assertAlmostEqual(2.3, msg.arg2())
+ self.assertEquals(0, msg.length())
+
+ def test_101(self):
+ s = 'This is a test'
+ msg = gr.message_from_string(s)
+ self.assertEquals(s, msg.to_string())
+
+ def test_200(self):
+ self.leak_check(self.body_200)
+
+ def body_200(self):
+ self.msgq.insert_tail(gr.message(0))
+ self.assertEquals(1, self.msgq.count())
+ self.msgq.insert_tail(gr.message(1))
+ self.assertEquals(2, self.msgq.count())
+ msg0 = self.msgq.delete_head()
+ self.assertEquals(0, msg0.type())
+ msg1 = self.msgq.delete_head()
+ self.assertEquals(1, msg1.type())
+ self.assertEquals(0, self.msgq.count())
+
+ def test_201(self):
+ self.leak_check(self.body_201)
+
+ def body_201(self):
+ self.msgq.insert_tail(gr.message(0))
+ self.assertEquals(1, self.msgq.count())
+ self.msgq.insert_tail(gr.message(1))
+ self.assertEquals(2, self.msgq.count())
+
+ def test_202(self):
+ self.leak_check(self.body_202)
+
+ def body_202(self):
+ # global msg
+ msg = gr.message(666)
+
+ def test_300(self):
+ input_data = (0,1,2,3,4,5,6,7,8,9)
+ src = gr.vector_source_b(input_data)
+ dst = gr.vector_sink_b()
+ tb = gr.top_block()
+ tb.connect(src, dst)
+ tb.run()
+ self.assertEquals(input_data, dst.data())
+
+ def test_301(self):
+ # Use itemsize, limit constructor
+ src = blocks.message_source(gr.sizeof_char)
+ dst = gr.vector_sink_b()
+ tb = gr.top_block()
+ tb.connect(src, dst)
+ src.msgq().insert_tail(gr.message_from_string('01234'))
+ src.msgq().insert_tail(gr.message_from_string('5'))
+ src.msgq().insert_tail(gr.message_from_string(''))
+ src.msgq().insert_tail(gr.message_from_string('6789'))
+ src.msgq().insert_tail(gr.message(1)) # send EOF
+ tb.run()
+ self.assertEquals(tuple(map(ord, '0123456789')), dst.data())
+
+ def test_302(self):
+ # Use itemsize, msgq constructor
+ msgq = gr.msg_queue()
+ src = blocks.message_source(gr.sizeof_char, msgq)
+ dst = gr.vector_sink_b()
+ tb = gr.top_block()
+ tb.connect(src, dst)
+ src.msgq().insert_tail(gr.message_from_string('01234'))
+ src.msgq().insert_tail(gr.message_from_string('5'))
+ src.msgq().insert_tail(gr.message_from_string(''))
+ src.msgq().insert_tail(gr.message_from_string('6789'))
+ src.msgq().insert_tail(gr.message(1)) # send EOF
+ tb.run()
+ self.assertEquals(tuple(map(ord, '0123456789')), dst.data())
+
+ def test_debug_401(self):
+ msg = pmt.pmt_intern("TESTING")
+ src = blocks.message_strobe(msg, 500)
+ snk = blocks.message_debug()
+
+ tb = gr.top_block()
+ tb.msg_connect(src, "strobe", snk, "store")
+ tb.start()
+ time.sleep(1)
+ tb.stop()
+ tb.wait()
+
+ rec_msg = snk.get_message(0)
+ self.assertTrue(pmt.pmt_eqv(rec_msg, msg))
+
+
+if __name__ == '__main__':
+ gr_unittest.run(test_message, "test_message.xml")
diff --git a/gr-blocks/python/qa_moving_average.py b/gr-blocks/python/qa_moving_average.py
new file mode 100644
index 0000000000..169b4746c2
--- /dev/null
+++ b/gr-blocks/python/qa_moving_average.py
@@ -0,0 +1,91 @@
+#!/usr/bin/env python
+#
+# Copyright 2013 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.
+#
+
+from gnuradio import gr, gr_unittest
+import blocks_swig as blocks
+import math, random
+
+def make_random_complex_tuple(L, scale=1):
+ result = []
+ for x in range(L):
+ result.append(scale*complex(2*random.random()-1,
+ 2*random.random()-1))
+ return tuple(result)
+
+def make_random_float_tuple(L, scale=1):
+ result = []
+ for x in range(L):
+ result.append(scale*(2*random.random()-1))
+ return tuple(result)
+
+class test_moving_average(gr_unittest.TestCase):
+
+ def setUp(self):
+ self.tb = gr.top_block()
+
+ def tearDown(self):
+ self.tb = None
+
+ def test_01(self):
+ tb = self.tb
+
+ N = 10000
+ seed = 0
+ data = make_random_float_tuple(N, 1)
+ expected_result = N*[0,]
+
+ src = gr.vector_source_f(data, False)
+ op = blocks.moving_average_ff(100, 0.001)
+ dst = gr.vector_sink_f()
+
+ tb.connect(src, op)
+ tb.connect(op, dst)
+ tb.run()
+
+ dst_data = dst.data()
+
+ # make sure result is close to zero
+ self.assertFloatTuplesAlmostEqual(expected_result, dst_data, 1)
+
+ def test_02(self):
+ tb = self.tb
+
+ N = 10000
+ seed = 0
+ data = make_random_complex_tuple(N, 1)
+ expected_result = N*[0,]
+
+ src = gr.vector_source_c(data, False)
+ op = blocks.moving_average_cc(100, 0.001)
+ dst = gr.vector_sink_c()
+
+ tb.connect(src, op)
+ tb.connect(op, dst)
+ tb.run()
+
+ dst_data = dst.data()
+
+ # make sure result is close to zero
+ self.assertComplexTuplesAlmostEqual(expected_result, dst_data, 1)
+
+if __name__ == '__main__':
+ gr_unittest.run(test_moving_average, "test_moving_average.xml")
diff --git a/gr-blocks/python/qa_mute.py b/gr-blocks/python/qa_mute.py
new file mode 100755
index 0000000000..96c57b2ed1
--- /dev/null
+++ b/gr-blocks/python/qa_mute.py
@@ -0,0 +1,89 @@
+#!/usr/bin/env python
+#
+# Copyright 2004,2005,2007,2010,2013 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.
+#
+
+from gnuradio import gr, gr_unittest
+import blocks_swig as blocks
+
+class test_mute(gr_unittest.TestCase):
+
+ def setUp(self):
+ self.tb = gr.top_block()
+
+ def tearDown(self):
+ self.tb = None
+
+ def help_ii(self, src_data, exp_data, op):
+ for s in zip(range(len(src_data)), src_data):
+ src = gr.vector_source_i(s[1])
+ self.tb.connect(src, (op, s[0]))
+ dst = gr.vector_sink_i()
+ self.tb.connect(op, dst)
+ self.tb.run()
+ result_data = dst.data()
+ self.assertEqual(exp_data, result_data)
+
+ def help_ff(self, src_data, exp_data, op):
+ for s in zip(range(len(src_data)), src_data):
+ src = gr.vector_source_f(s[1])
+ self.tb.connect(src, (op, s[0]))
+ dst = gr.vector_sink_f()
+ self.tb.connect(op, dst)
+ self.tb.run()
+ result_data = dst.data()
+ self.assertEqual(exp_data, result_data)
+
+ def help_cc(self, src_data, exp_data, op):
+ for s in zip(range(len(src_data)), src_data):
+ src = gr.vector_source_c(s[1])
+ self.tb.connect(src, (op, s[0]))
+ dst = gr.vector_sink_c()
+ self.tb.connect(op, dst)
+ self.tb.run()
+ result_data = dst.data()
+ self.assertEqual(exp_data, result_data)
+
+ def test_unmute_ii(self):
+ src_data = (1, 2, 3, 4, 5)
+ expected_result = (1, 2, 3, 4, 5)
+ op = blocks.mute_ii(False)
+ self.help_ii((src_data,), expected_result, op)
+
+ def test_mute_ii(self):
+ src_data = (1, 2, 3, 4, 5)
+ expected_result = (0, 0, 0, 0, 0)
+ op = blocks.mute_ii(True)
+ self.help_ii((src_data,), expected_result, op)
+
+ def test_unmute_cc(self):
+ src_data = (1+5j, 2+5j, 3+5j, 4+5j, 5+5j)
+ expected_result = (1+5j, 2+5j, 3+5j, 4+5j, 5+5j)
+ op = blocks.mute_cc(False)
+ self.help_cc((src_data,), expected_result, op)
+
+ def test_unmute_cc(self):
+ src_data = (1+5j, 2+5j, 3+5j, 4+5j, 5+5j)
+ expected_result =(0+0j, 0+0j, 0+0j, 0+0j, 0+0j)
+ op = blocks.mute_cc(True)
+ self.help_cc((src_data,), expected_result, op)
+
+if __name__ == '__main__':
+ gr_unittest.run(test_mute, "test_mute.xml")
diff --git a/gr-blocks/python/qa_null_sink_source.py b/gr-blocks/python/qa_null_sink_source.py
new file mode 100644
index 0000000000..60552cb207
--- /dev/null
+++ b/gr-blocks/python/qa_null_sink_source.py
@@ -0,0 +1,46 @@
+#!/usr/bin/env python
+#
+# Copyright 2013 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.
+#
+
+from gnuradio import gr, gr_unittest
+import blocks_swig as blocks
+import math
+
+class test_null_sink_source(gr_unittest.TestCase):
+
+ def setUp(self):
+ self.tb = gr.top_block()
+
+ def tearDown(self):
+ self.tb = None
+
+ def test_001(self):
+ # Just running some data through null source/sink
+ src = blocks.null_source(gr.sizeof_float)
+ hed = blocks.head(gr.sizeof_float, 100)
+ dst = blocks.null_sink(gr.sizeof_float)
+
+ self.tb.connect(src, hed, dst)
+ self.tb.run()
+
+if __name__ == '__main__':
+ gr_unittest.run(test_null_sink_source, "test_null_sink_source.xml")
+
diff --git a/gr-blocks/python/qa_pack_k_bits.py b/gr-blocks/python/qa_pack_k_bits.py
new file mode 100755
index 0000000000..cd55d2f200
--- /dev/null
+++ b/gr-blocks/python/qa_pack_k_bits.py
@@ -0,0 +1,68 @@
+#!/usr/bin/env python
+#
+# Copyright 2006,2010,2013 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.
+#
+
+from gnuradio import gr, gr_unittest
+import blocks_swig as blocks
+import random
+
+class test_pack(gr_unittest.TestCase):
+
+ def setUp(self):
+ self.tb = gr.top_block()
+
+ def tearDown(self):
+ self.tb = None
+
+ def test_001(self):
+ src_data = (1,0,1,1,0,1,1,0)
+ expected_results = (1,0,1,1,0,1,1,0)
+ src = gr.vector_source_b(src_data,False)
+ op = blocks.pack_k_bits_bb(1)
+ dst = gr.vector_sink_b()
+ self.tb.connect(src, op, dst)
+ self.tb.run()
+ self.assertEqual(expected_results, dst.data())
+
+ def test_002(self):
+ src_data = (1,0,1,1,0,0,0,1)
+ expected_results = ( 2, 3, 0, 1)
+ src = gr.vector_source_b(src_data,False)
+ op = blocks.pack_k_bits_bb(2)
+ dst = gr.vector_sink_b()
+ self.tb.connect(src, op, dst)
+ self.tb.run()
+ #self.assertEqual(expected_results, dst.data())
+ self.assertEqual(expected_results, dst.data())
+
+ def test_003(self):
+ src_data = expected_results = map(lambda x: random.randint(0,3), range(10));
+ src = gr.vector_source_b( src_data );
+ pack = blocks.pack_k_bits_bb(2);
+ unpack = blocks.unpack_k_bits_bb(2);
+ snk = gr.vector_sink_b();
+ self.tb.connect(src,unpack,pack,snk);
+ self.tb.run()
+ self.assertEqual(list(expected_results), list(snk.data()));
+
+if __name__ == '__main__':
+ gr_unittest.run(test_pack, "test_pack.xml")
+
diff --git a/gr-blocks/python/qa_pdu.py b/gr-blocks/python/qa_pdu.py
new file mode 100755
index 0000000000..3f7675ce4a
--- /dev/null
+++ b/gr-blocks/python/qa_pdu.py
@@ -0,0 +1,91 @@
+#!/usr/bin/env python
+#
+# Copyright 2013 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.
+#
+
+from gnuradio import gr, gr_unittest
+import blocks_swig as blocks
+import pmt
+import time
+
+class test_pdu(gr_unittest.TestCase):
+
+ def setUp(self):
+ self.tb = gr.top_block()
+
+ def tearDown(self):
+ self.tb = None
+
+ def test_000(self):
+ # Just run some data through and make sure it doesn't puke.
+ src_data = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
+
+ src = blocks.pdu_to_tagged_stream(blocks.byte_t)
+ snk3 = blocks.tagged_stream_to_pdu(blocks.byte_t)
+ snk2 = gr.vector_sink_b()
+ snk = gr.tag_debug(1, "test")
+ snk.set_display(False)
+
+ dbg = gr.message_debug()
+
+ # Test that the right number of ports exist.
+ pi = snk3.message_ports_in()
+ po = snk3.message_ports_out()
+ self.assertEqual(pmt.pmt_length(pi), 0)
+ self.assertEqual(pmt.pmt_length(po), 1)
+
+ self.tb.connect(src, snk)
+ self.tb.connect(src, snk2)
+ self.tb.connect(src, snk3)
+ self.tb.msg_connect(snk3, "pdus", dbg, "store")
+ self.tb.start()
+
+ # make our reference and message pmts
+ port = pmt.pmt_intern("pdus")
+ msg = pmt.pmt_cons( pmt.PMT_NIL, pmt.pmt_make_u8vector(16, 0xFF))
+
+ # post the message
+ src.to_basic_block()._post(port, msg) # eww, what's that smell?
+
+ while dbg.num_messages() < 1:
+ time.sleep(0.1)
+ self.tb.stop()
+ self.tb.wait()
+
+ # Get the vector of data from the vector sink
+ result_data = snk2.data()
+
+ # Get the vector of data from the message sink
+ # Convert the message PMT as a pair into its vector
+ result_msg = dbg.get_message(0)
+ msg_vec = pmt.pmt_cdr(result_msg)
+ #pmt.pmt_print(msg_vec)
+
+ # Convert the PMT vector into a Python list
+ msg_data = []
+ for i in xrange(16):
+ msg_data.append(pmt.pmt_u8vector_ref(msg_vec, i))
+
+ actual_data = 16*[0xFF,]
+ self.assertEqual(actual_data, list(result_data))
+ self.assertEqual(actual_data, msg_data)
+
+if __name__ == '__main__':
+ gr_unittest.run(test_pdu, "test_pdu.xml")
diff --git a/gr-blocks/python/qa_peak_detector.py b/gr-blocks/python/qa_peak_detector.py
new file mode 100644
index 0000000000..c3ff2548c4
--- /dev/null
+++ b/gr-blocks/python/qa_peak_detector.py
@@ -0,0 +1,98 @@
+#!/usr/bin/env python
+#
+# Copyright 2013 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.
+#
+
+from gnuradio import gr, gr_unittest
+import blocks_swig as blocks
+
+class test_peak_detector(gr_unittest.TestCase):
+
+ def setUp(self):
+ self.tb = gr.top_block()
+
+ def tearDown(self):
+ self.tb = None
+
+ def test_01(self):
+ tb = self.tb
+
+ data = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
+ 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]
+
+ expected_result = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
+
+ src = gr.vector_source_f(data, False)
+ regen = blocks.peak_detector_fb()
+ dst = gr.vector_sink_b()
+
+ tb.connect(src, regen)
+ tb.connect(regen, dst)
+ tb.run()
+
+ dst_data = dst.data()
+
+ self.assertEqual(expected_result, dst_data)
+
+ def test_02(self):
+ tb = self.tb
+
+ data = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
+ 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]
+
+ expected_result = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
+
+ src = gr.vector_source_i(data, False)
+ regen = blocks.peak_detector_ib()
+ dst = gr.vector_sink_b()
+
+ tb.connect(src, regen)
+ tb.connect(regen, dst)
+ tb.run()
+
+ dst_data = dst.data()
+
+ self.assertEqual(expected_result, dst_data)
+
+ def test_03(self):
+ tb = self.tb
+
+ data = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
+ 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]
+
+ expected_result = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
+
+ src = gr.vector_source_s(data, False)
+ regen = blocks.peak_detector_sb()
+ dst = gr.vector_sink_b()
+
+ tb.connect(src, regen)
+ tb.connect(regen, dst)
+ tb.run()
+
+ dst_data = dst.data()
+
+ self.assertEqual(expected_result, dst_data)
+
+if __name__ == '__main__':
+ gr_unittest.run(test_peak_detector, "test_peak_detector.xml")
diff --git a/gr-blocks/python/qa_peak_detector2.py b/gr-blocks/python/qa_peak_detector2.py
index 4b864e4d70..b2d8e318dd 100644
--- a/gr-blocks/python/qa_peak_detector2.py
+++ b/gr-blocks/python/qa_peak_detector2.py
@@ -50,7 +50,6 @@ class test_peak_detector2(gr_unittest.TestCase):
tb.run()
dst_data = dst.data()
- print dst_data
self.assertEqual(expected_result, dst_data)
diff --git a/gr-blocks/python/qa_plateau_detector_fb.py b/gr-blocks/python/qa_plateau_detector_fb.py
new file mode 100755
index 0000000000..e45fe028dd
--- /dev/null
+++ b/gr-blocks/python/qa_plateau_detector_fb.py
@@ -0,0 +1,46 @@
+#!/usr/bin/env python
+#
+# Copyright 2012-2013 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.
+#
+
+from gnuradio import gr, gr_unittest
+import blocks_swig as blocks
+
+class qa_plateau_detector_fb (gr_unittest.TestCase):
+
+ def setUp (self):
+ self.tb = gr.top_block ()
+
+ def tearDown (self):
+ self.tb = None
+
+ def test_001_t (self):
+ # | Spur spike 1 | Plateau | Spur spike 2
+ test_signal = (0, 1, .2, .4, .6, .8, 1, 1, 1, 1, 1, .8, .6, .4, 1, 0)
+ expected_sig = (0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0)
+ # | Center of Plateau
+ sink = gr.vector_sink_b()
+ self.tb.connect(gr.vector_source_f(test_signal), blocks.plateau_detector_fb(5), sink)
+ self.tb.run ()
+ self.assertEqual(expected_sig, sink.data())
+
+
+if __name__ == '__main__':
+ gr_unittest.run(qa_plateau_detector_fb, "qa_plateau_detector_fb.xml")
diff --git a/gr-blocks/python/qa_probe_signal.py b/gr-blocks/python/qa_probe_signal.py
new file mode 100644
index 0000000000..a420df71e5
--- /dev/null
+++ b/gr-blocks/python/qa_probe_signal.py
@@ -0,0 +1,65 @@
+#!/usr/bin/env python
+#
+# Copyright 2012-2013 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.
+#
+
+import time
+from gnuradio import gr, gr_unittest
+import blocks_swig as blocks
+
+class test_probe_signal(gr_unittest.TestCase):
+
+ def setUp(self):
+ self.tb = gr.top_block()
+
+ def tearDown(self):
+ self.tb = None
+
+ def test_001(self):
+ value = 12.3
+ repeats = 100
+ src_data = [value] * repeats
+
+ src = gr.vector_source_f(src_data)
+ dst = blocks.probe_signal_f()
+
+ self.tb.connect(src, dst)
+ self.tb.run()
+ output = dst.level()
+ self.assertAlmostEqual(value, output, places=6)
+
+ def test_002(self):
+ vector_length = 10
+ repeats = 10
+ value = [0.5+i for i in range(0, vector_length)]
+ src_data = value * repeats
+
+ src = gr.vector_source_f(src_data)
+ s2v = blocks.stream_to_vector(gr.sizeof_float, vector_length)
+ dst = blocks.probe_signal_vf(vector_length)
+
+ self.tb.connect(src, s2v, dst)
+ self.tb.run()
+ output = dst.level()
+ self.assertEqual(len(output), vector_length)
+ self.assertAlmostEqual(value[3], output[3], places=6)
+
+if __name__ == '__main__':
+ gr_unittest.run(test_probe_signal, "test_probe_signal.xml")
diff --git a/gr-blocks/python/qa_repack_bits_bb.py b/gr-blocks/python/qa_repack_bits_bb.py
new file mode 100755
index 0000000000..e71f7621e3
--- /dev/null
+++ b/gr-blocks/python/qa_repack_bits_bb.py
@@ -0,0 +1,127 @@
+#!/usr/bin/env python
+#
+# Copyright 2013 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.
+#
+
+import random
+from gnuradio import gr, gr_unittest
+import pmt
+import blocks_swig as blocks
+
+class qa_repack_bits_bb (gr_unittest.TestCase):
+
+ def setUp (self):
+ self.tb = gr.top_block ()
+
+ def tearDown (self):
+ self.tb = None
+
+ def test_001_simple (self):
+ """ Very simple test, 2 bits -> 1 """
+ src_data = (0b11, 0b01, 0b10)
+ expected_data = (0b1, 0b1, 0b1, 0b0, 0b0, 0b1)
+ k = 2
+ l = 1
+ src = gr.vector_source_b(src_data, False, 1)
+ repack = blocks.repack_bits_bb(k, l)
+ sink = gr.vector_sink_b()
+ self.tb.connect(src, repack, sink)
+ self.tb.run ()
+ self.assertEqual(sink.data(), expected_data)
+
+ def test_002_three (self):
+ """ 8 -> 3 """
+ src_data = (0b11111101, 0b11111111, 0b11111111)
+ expected_data = (0b101,) + (0b111,) * 7
+ k = 8
+ l = 3
+ src = gr.vector_source_b(src_data, False, 1)
+ repack = blocks.repack_bits_bb(k, l)
+ sink = gr.vector_sink_b()
+ self.tb.connect(src, repack, sink)
+ self.tb.run ()
+ self.assertEqual(sink.data(), expected_data)
+
+ def test_003_lots_of_bytes (self):
+ """ Lots and lots of bytes, multiple packer stages """
+ src_data = tuple([random.randint(0, 255) for x in range(3*5*7*8 * 10)])
+ src = gr.vector_source_b(src_data, False, 1)
+ repack1 = blocks.repack_bits_bb(8, 3)
+ repack2 = blocks.repack_bits_bb(3, 5)
+ repack3 = blocks.repack_bits_bb(5, 7)
+ repack4 = blocks.repack_bits_bb(7, 8)
+ sink = gr.vector_sink_b()
+ self.tb.connect(src, repack1, repack2, repack3, repack4, sink)
+ self.tb.run ()
+ self.assertEqual(sink.data(), src_data)
+
+ def test_004_three_with_tags (self):
+ """ 8 -> 3 """
+ src_data = (0b11111101, 0b11111111)
+ expected_data = (0b101,) + (0b111,) * 4 + (0b001,)
+ k = 8
+ l = 3
+ tag_name = "len"
+ tag = gr.gr_tag_t()
+ tag.offset = 0
+ tag.key = pmt.pmt_string_to_symbol(tag_name)
+ tag.value = pmt.pmt_from_long(len(src_data))
+ src = gr.vector_source_b(src_data, False, 1, (tag,))
+ repack = blocks.repack_bits_bb(k, l, tag_name)
+ sink = gr.vector_sink_b()
+ self.tb.connect(src, repack, sink)
+ self.tb.run ()
+ self.assertEqual(sink.data(), expected_data)
+ try:
+ out_tag = sink.tags()[0]
+ except:
+ self.assertFail()
+ self.assertEqual(out_tag.offset, 0)
+ self.assertEqual(pmt.pmt_symbol_to_string(out_tag.key), tag_name)
+ self.assertEqual(pmt.pmt_to_long(out_tag.value), len(expected_data))
+
+ def test_005_three_with_tags_trailing (self):
+ """ 3 -> 8, trailing bits """
+ src_data = (0b101,) + (0b111,) * 4 + (0b001,)
+ expected_data = (0b11111101, 0b11111111)
+ k = 3
+ l = 8
+ tag_name = "len"
+ tag = gr.gr_tag_t()
+ tag.offset = 0
+ tag.key = pmt.pmt_string_to_symbol(tag_name)
+ tag.value = pmt.pmt_from_long(len(src_data))
+ src = gr.vector_source_b(src_data, False, 1, (tag,))
+ repack = blocks.repack_bits_bb(k, l, tag_name, True)
+ sink = gr.vector_sink_b()
+ self.tb.connect(src, repack, sink)
+ self.tb.run ()
+ self.assertEqual(sink.data(), expected_data)
+ try:
+ out_tag = sink.tags()[0]
+ except:
+ self.assertFail()
+ self.assertEqual(out_tag.offset, 0)
+ self.assertEqual(pmt.pmt_symbol_to_string(out_tag.key), tag_name)
+ self.assertEqual(pmt.pmt_to_long(out_tag.value), len(expected_data))
+
+if __name__ == '__main__':
+ gr_unittest.run(qa_repack_bits_bb, "qa_repack_bits_bb.xml")
+
diff --git a/gr-blocks/python/qa_sample_and_hold.py b/gr-blocks/python/qa_sample_and_hold.py
new file mode 100644
index 0000000000..59628090d1
--- /dev/null
+++ b/gr-blocks/python/qa_sample_and_hold.py
@@ -0,0 +1,54 @@
+#!/usr/bin/env python
+#
+# Copyright 2013 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.
+#
+
+import time
+from gnuradio import gr, gr_unittest
+import blocks_swig as blocks
+
+class test_sample_and_hold(gr_unittest.TestCase):
+
+ def setUp(self):
+ self.tb = gr.top_block()
+
+ def tearDown(self):
+ self.tb = None
+
+ def test_001(self):
+ src_data = 10*[0,1,2,3,4,5,6,7,8,9,8,7,6,5,4,3,2,1]
+ ctrl_data = 10*[1,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,0]
+ expected_result = 10*(0,0,0,0,4,5,6,7,8,9,9,9,9,9,9,9,9,9)
+
+ src = gr.vector_source_f(src_data)
+ ctrl = gr.vector_source_b(ctrl_data)
+ op = blocks.sample_and_hold_ff()
+ dst = gr.vector_sink_f()
+
+ self.tb.connect(src, (op,0))
+ self.tb.connect(ctrl, (op,1))
+ self.tb.connect(op, dst)
+ self.tb.run()
+
+ result = dst.data()
+ self.assertFloatTuplesAlmostEqual(expected_result, result, places=6)
+
+if __name__ == '__main__':
+ gr_unittest.run(test_sample_and_hold, "test_sample_and_hold.xml")
diff --git a/gr-blocks/python/qa_skiphead.py b/gr-blocks/python/qa_skiphead.py
new file mode 100755
index 0000000000..50a9bbc639
--- /dev/null
+++ b/gr-blocks/python/qa_skiphead.py
@@ -0,0 +1,103 @@
+#!/usr/bin/env python
+#
+# Copyright 2007,2010,2013 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.
+#
+
+from gnuradio import gr, gr_unittest
+import blocks_swig as blocks
+
+class test_skiphead(gr_unittest.TestCase):
+
+ def setUp(self):
+ self.tb = gr.top_block()
+ self.src_data = [int(x) for x in range(65536)]
+
+ def tearDown(self):
+ self.tb = None
+
+ def test_skip_0(self):
+ skip_cnt = 0
+ expected_result = tuple(self.src_data[skip_cnt:])
+ src1 = blocks.vector_source_i(self.src_data)
+ op = blocks.skiphead(gr.sizeof_int, skip_cnt)
+ dst1 = blocks.vector_sink_i()
+ self.tb.connect(src1, op, dst1)
+ self.tb.run()
+ dst_data = dst1.data()
+ self.assertEqual(expected_result, dst_data)
+
+ def test_skip_1(self):
+ skip_cnt = 1
+ expected_result = tuple(self.src_data[skip_cnt:])
+ src1 = blocks.vector_source_i(self.src_data)
+ op = blocks.skiphead(gr.sizeof_int, skip_cnt)
+ dst1 = blocks.vector_sink_i()
+ self.tb.connect(src1, op, dst1)
+ self.tb.run()
+ dst_data = dst1.data()
+ self.assertEqual(expected_result, dst_data)
+
+ def test_skip_1023(self):
+ skip_cnt = 1023
+ expected_result = tuple(self.src_data[skip_cnt:])
+ src1 = blocks.vector_source_i(self.src_data)
+ op = blocks.skiphead(gr.sizeof_int, skip_cnt)
+ dst1 = blocks.vector_sink_i()
+ self.tb.connect(src1, op, dst1)
+ self.tb.run()
+ dst_data = dst1.data()
+ self.assertEqual(expected_result, dst_data)
+
+ def test_skip_6339(self):
+ skip_cnt = 6339
+ expected_result = tuple(self.src_data[skip_cnt:])
+ src1 = blocks.vector_source_i(self.src_data)
+ op = blocks.skiphead(gr.sizeof_int, skip_cnt)
+ dst1 = blocks.vector_sink_i()
+ self.tb.connect(src1, op, dst1)
+ self.tb.run()
+ dst_data = dst1.data()
+ self.assertEqual(expected_result, dst_data)
+
+ def test_skip_12678(self):
+ skip_cnt = 12678
+ expected_result = tuple(self.src_data[skip_cnt:])
+ src1 = blocks.vector_source_i(self.src_data)
+ op = blocks.skiphead(gr.sizeof_int, skip_cnt)
+ dst1 = blocks.vector_sink_i()
+ self.tb.connect(src1, op, dst1)
+ self.tb.run()
+ dst_data = dst1.data()
+ self.assertEqual(expected_result, dst_data)
+
+ def test_skip_all(self):
+ skip_cnt = len(self.src_data)
+ expected_result = tuple(self.src_data[skip_cnt:])
+ src1 = blocks.vector_source_i(self.src_data)
+ op = blocks.skiphead(gr.sizeof_int, skip_cnt)
+ dst1 = blocks.vector_sink_i()
+ self.tb.connect(src1, op, dst1)
+ self.tb.run()
+ dst_data = dst1.data()
+ self.assertEqual(expected_result, dst_data)
+
+
+if __name__ == '__main__':
+ gr_unittest.run(test_skiphead, "test_skiphead.xml")
diff --git a/gr-blocks/python/qa_tag_debug.py b/gr-blocks/python/qa_tag_debug.py
new file mode 100755
index 0000000000..ad85daebcc
--- /dev/null
+++ b/gr-blocks/python/qa_tag_debug.py
@@ -0,0 +1,44 @@
+#!/usr/bin/env python
+#
+# Copyright 2012-2013 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.
+#
+
+from gnuradio import gr, gr_unittest
+import blocks_swig as blocks
+
+class test_tag_debug(gr_unittest.TestCase):
+
+ def setUp(self):
+ self.tb = gr.top_block()
+
+ def tearDown(self):
+ self.tb = None
+
+ def test_001(self):
+ # Just run some data through and make sure it doesn't puke.
+ src_data = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
+ src = gr.vector_source_i(src_data)
+ op = blocks.tag_debug(gr.sizeof_int, "tag QA")
+ self.tb.connect(src, op)
+ self.tb.run()
+ x = op.current_tags()
+
+if __name__ == '__main__':
+ gr_unittest.run(test_tag_debug, "test_tag_debug.xml")
diff --git a/gr-blocks/python/qa_tag_file_sink.py b/gr-blocks/python/qa_tag_file_sink.py
new file mode 100644
index 0000000000..80e41a7dd0
--- /dev/null
+++ b/gr-blocks/python/qa_tag_file_sink.py
@@ -0,0 +1,72 @@
+#!/usr/bin/env python
+#
+# Copyright 2013 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.
+#
+
+from gnuradio import gr, gr_unittest
+import blocks_swig as blocks
+import os, struct
+
+class test_tag_file_sink(gr_unittest.TestCase):
+
+ def setUp(self):
+ self.tb = gr.top_block()
+
+ def tearDown(self):
+ self.tb = None
+
+ def test_001(self):
+ src_data = ( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
+ trg_data = (-1, -1, 1, 1, -1, -1, 1, 1, -1, -1)
+ src = gr.vector_source_i(src_data)
+ trg = gr.vector_source_s(trg_data)
+ op = blocks.burst_tagger(gr.sizeof_int)
+ snk = blocks.tagged_file_sink(gr.sizeof_int, 1)
+ self.tb.connect(src, (op,0))
+ self.tb.connect(trg, (op,1))
+ self.tb.connect(op, snk)
+ self.tb.run()
+
+ # Tagged file sink gets 2 burst tags at index 2 and index 5.
+ # Creates two new files, each with two integers in them from
+ # src_data at these indexes (3,4) and (7,8).
+ file0 = "file{0}_0_2.00000000.dat".format(snk.unique_id())
+ file1 = "file{0}_1_6.00000000.dat".format(snk.unique_id())
+
+ # Open the files and read in the data, then remove the files
+ # to clean up the directory.
+ outfile0 = file(file0, 'rb')
+ outfile1 = file(file1, 'rb')
+ data0 = outfile0.read(8)
+ data1 = outfile1.read(8)
+ outfile0.close()
+ outfile1.close()
+ os.remove(file0)
+ os.remove(file1)
+
+ # Convert the 8 bytes from the files into a tuple of 2 ints.
+ idata0 = struct.unpack('ii', data0)
+ idata1 = struct.unpack('ii', data1)
+
+ self.assertEqual(idata0, (3, 4))
+ self.assertEqual(idata1, (7, 8))
+
+if __name__ == '__main__':
+ gr_unittest.run(test_tag_file_sink, "test_tag_file_sink.xml")
diff --git a/gr-blocks/python/qa_tagged_stream_mux.py b/gr-blocks/python/qa_tagged_stream_mux.py
new file mode 100755
index 0000000000..ac0731756b
--- /dev/null
+++ b/gr-blocks/python/qa_tagged_stream_mux.py
@@ -0,0 +1,111 @@
+#!/usr/bin/env python
+#
+# Copyright 2013 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.
+#
+
+from gnuradio import gr, gr_unittest
+import pmt
+import blocks_swig as blocks
+import numpy
+
+def make_len_tags(tupl, key):
+ tags = []
+ tag = gr.gr_tag_t()
+ tag.key = pmt.pmt_string_to_symbol(key)
+ n_read = 0
+ for element in tupl:
+ tag.offset = n_read
+ n_read += len(element)
+ tag.value = pmt.to_pmt(len(element))
+ tags.append(tag)
+ return tags
+
+def make_len_tag(offset, key, value):
+ tag = gr.gr_tag_t()
+ tag.offset = offset
+ tag.key = pmt.pmt_string_to_symbol(key)
+ tag.value = pmt.to_pmt(value)
+ return tag
+
+
+class qa_tagged_stream_mux (gr_unittest.TestCase):
+
+ def setUp(self):
+ self.tb = gr.top_block()
+
+ def tearDown(self):
+ self.tb = None
+
+ def test_1(self):
+ datas = (
+ 0, 1, 2, 5, 6, 10, 14, 15, 16,
+ 3, 4, 7, 8, 9, 11, 12, 13, 17
+ )
+ expected = tuple(range(18))
+
+ tagname = "packet_length"
+ len_tags_0 = (
+ make_len_tag(0, tagname, 3),
+ make_len_tag(3, tagname, 2),
+ make_len_tag(5, tagname, 1),
+ make_len_tag(6, tagname, 3)
+ )
+ len_tags_1 = (
+ make_len_tag(0, tagname, 2),
+ make_len_tag(2, tagname, 3),
+ make_len_tag(5, tagname, 3),
+ make_len_tag(8, tagname, 1)
+ )
+ test_tag_0 = gr.gr_tag_t()
+ test_tag_0.key = pmt.pmt_string_to_symbol('spam')
+ test_tag_0.offset = 4 # On the second '1'
+ test_tag_0.value = pmt.to_pmt(42)
+ test_tag_1 = gr.gr_tag_t()
+ test_tag_1.key = pmt.pmt_string_to_symbol('eggs')
+ test_tag_1.offset = 3 # On the first '3' of the 2nd stream
+ test_tag_1.value = pmt.to_pmt(23)
+
+ src0 = gr.vector_source_b(datas[0:9], False, 1, len_tags_0 + (test_tag_0,))
+ src1 = gr.vector_source_b(datas[9:], False, 1, len_tags_1 + (test_tag_1,))
+ tagged_stream_mux = blocks.tagged_stream_mux(gr.sizeof_char, tagname)
+ snk = gr.vector_sink_b()
+ self.tb.connect(src0, (tagged_stream_mux, 0))
+ self.tb.connect(src1, (tagged_stream_mux, 1))
+ self.tb.connect(tagged_stream_mux, snk)
+ self.tb.run()
+
+ self.assertEqual(expected, snk.data())
+
+ tags = [gr.tag_to_python(x) for x in snk.tags()]
+ tags = sorted([(x.offset, x.key, x.value) for x in tags])
+ tags_expected = [
+ (0, 'packet_length', 5),
+ (5, 'packet_length', 5),
+ (6, 'spam', 42),
+ (8, 'eggs', 23),
+ (10, 'packet_length', 4),
+ (14, 'packet_length', 4)
+ ]
+ self.assertEqual(tags, tags_expected)
+
+
+if __name__ == '__main__':
+ gr_unittest.run(qa_tagged_stream_mux, "qa_tagged_stream_mux.xml")
+
diff --git a/gr-blocks/python/qa_udp_source_sink.py b/gr-blocks/python/qa_udp_source_sink.py
new file mode 100644
index 0000000000..4ab1430b09
--- /dev/null
+++ b/gr-blocks/python/qa_udp_source_sink.py
@@ -0,0 +1,121 @@
+#!/usr/bin/env python
+#
+# Copyright 2008,2010,2013 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.
+#
+
+from gnuradio import gr, gr_unittest
+import blocks_swig as blocks
+import os
+
+from threading import Timer
+
+class test_udp_sink_source(gr_unittest.TestCase):
+
+ def setUp(self):
+ self.tb_snd = gr.top_block()
+ self.tb_rcv = gr.top_block()
+
+ def tearDown(self):
+ self.tb_rcv = None
+ self.tb_snd = None
+
+ def test_001(self):
+ # Tests calling disconnect/reconnect.
+
+ port = 65500
+
+ n_data = 16
+ src_data = [x for x in range(n_data)]
+ expected_result = tuple(src_data)
+ src = gr.vector_source_s(src_data, False)
+ udp_snd = blocks.udp_sink(gr.sizeof_short, 'localhost', port)
+ self.tb_snd.connect(src, udp_snd)
+
+ self.tb_snd.run()
+ udp_snd.disconnect()
+
+ udp_snd.connect('localhost', port+1)
+ src.rewind()
+ self.tb_snd.run()
+
+ def test_002(self):
+ port = 65500
+
+ n_data = 100
+ src_data = [float(x) for x in range(n_data)]
+ expected_result = tuple(src_data)
+ src = gr.vector_source_f(src_data, False)
+ udp_snd = blocks.udp_sink(gr.sizeof_float, 'localhost', port)
+ self.tb_snd.connect(src, udp_snd)
+
+ udp_rcv = blocks.udp_source(gr.sizeof_float, 'localhost', port)
+ dst = gr.vector_sink_f()
+ self.tb_rcv.connect(udp_rcv, dst)
+
+ self.tb_rcv.start()
+ self.tb_snd.run()
+ udp_snd.disconnect()
+ self.timeout = False
+ q = Timer(2.0,self.stop_rcv)
+ q.start()
+ self.tb_rcv.wait()
+ q.cancel()
+
+ result_data = dst.data()
+ self.assertEqual(expected_result, result_data)
+ self.assert_(not self.timeout)
+
+ def test_003(self):
+ udp_rcv = blocks.udp_source(gr.sizeof_float, '0.0.0.0', 0, eof=False)
+ rcv_port = udp_rcv.get_port()
+
+ udp_snd = blocks.udp_sink(gr.sizeof_float, '127.0.0.1', 65500)
+ udp_snd.connect('localhost', rcv_port)
+
+ n_data = 16
+ src_data = [float(x) for x in range(n_data)]
+ expected_result = tuple(src_data)
+ src = gr.vector_source_f(src_data)
+ dst = gr.vector_sink_f()
+
+ self.tb_snd.connect(src, udp_snd)
+ self.tb_rcv.connect(udp_rcv, dst)
+
+ self.tb_rcv.start()
+ self.tb_snd.run()
+ udp_snd.disconnect()
+ self.timeout = False
+ q = Timer(2.0,self.stop_rcv)
+ q.start()
+ self.tb_rcv.wait()
+ q.cancel()
+
+ result_data = dst.data()
+ self.assertEqual(expected_result, result_data)
+ self.assert_(self.timeout) # source ignores EOF?
+
+ def stop_rcv(self):
+ self.timeout = True
+ self.tb_rcv.stop()
+ #print "tb_rcv stopped by Timer"
+
+if __name__ == '__main__':
+ gr_unittest.run(test_udp_sink_source, "test_udp_sink_source.xml")
+
diff --git a/gr-blocks/python/qa_unpack_k_bits.py b/gr-blocks/python/qa_unpack_k_bits.py
new file mode 100755
index 0000000000..e038d5a03a
--- /dev/null
+++ b/gr-blocks/python/qa_unpack_k_bits.py
@@ -0,0 +1,57 @@
+#!/usr/bin/env python
+#
+# Copyright 2006,2010,2013 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.
+#
+
+from gnuradio import gr, gr_unittest
+import blocks_swig as blocks
+import random
+
+class test_unpack(gr_unittest.TestCase):
+
+ def setUp(self):
+ self.tb = gr.top_block ()
+
+ def tearDown(self):
+ self.tb = None
+
+ def test_001(self):
+ src_data = (1,0,1,1,0,1,1,0)
+ expected_results = (1,0,1,1,0,1,1,0)
+ src = gr.vector_source_b(src_data,False)
+ op = blocks.unpack_k_bits_bb(1)
+ dst = gr.vector_sink_b()
+ self.tb.connect(src, op, dst)
+ self.tb.run()
+ self.assertEqual(expected_results, dst.data())
+
+ def test_002(self):
+ src_data = ( 2, 3, 0, 1)
+ expected_results = (1,0,1,1,0,0,0,1)
+ src = gr.vector_source_b(src_data,False)
+ op = blocks.unpack_k_bits_bb(2)
+ dst = gr.vector_sink_b()
+ self.tb.connect(src, op, dst)
+ self.tb.run()
+ self.assertEqual(expected_results, dst.data())
+
+if __name__ == '__main__':
+ gr_unittest.run(test_unpack, "test_unpack.xml")
+
diff --git a/gr-blocks/python/qa_vco.py b/gr-blocks/python/qa_vco.py
new file mode 100644
index 0000000000..721eb9471b
--- /dev/null
+++ b/gr-blocks/python/qa_vco.py
@@ -0,0 +1,59 @@
+#!/usr/bin/env python
+#
+# Copyright 2013 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.
+#
+
+from gnuradio import gr, gr_unittest
+import blocks_swig
+import math
+
+def sig_source_f(samp_rate, freq, amp, N):
+ t = map(lambda x: float(x)/samp_rate, xrange(N))
+ y = map(lambda x: amp*math.cos(2.*math.pi*freq*x), t)
+ return y
+
+class test_vco(gr_unittest.TestCase):
+
+ def setUp (self):
+ self.tb = gr.top_block ()
+
+ def tearDown (self):
+ self.tb = None
+
+ def test_001(self):
+ src_data = 200*[0,] + 200*[0.5,] + 200*[1,]
+ expected_result = 200*[1,] + \
+ sig_source_f(1, 0.125, 1, 200) + \
+ sig_source_f(1, 0.25, 1, 200)
+
+ src = gr.vector_source_f(src_data)
+ op = blocks_swig.vco_f(1, math.pi/2.0, 1)
+ dst = gr.vector_sink_f()
+
+ self.tb.connect(src, op, dst)
+ self.tb.run()
+
+ result_data = dst.data()
+ self.assertFloatTuplesAlmostEqual(expected_result, result_data, 5)
+
+
+if __name__ == '__main__':
+ gr_unittest.run(test_vco, "test_vco.xml")
+
diff --git a/gr-blocks/python/qa_vector_insert.py b/gr-blocks/python/qa_vector_insert.py
new file mode 100755
index 0000000000..428a0031ba
--- /dev/null
+++ b/gr-blocks/python/qa_vector_insert.py
@@ -0,0 +1,59 @@
+#!/usr/bin/env python
+#
+# Copyright 2012-2013 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.
+#
+
+from gnuradio import gr, gr_unittest
+import blocks_swig as blocks
+import math
+
+class test_vector_insert(gr_unittest.TestCase):
+
+ def setUp(self):
+ self.tb = gr.top_block()
+
+ def tearDown(self):
+ self.tb = None
+
+ def test_001(self):
+ src_data = [float(x) for x in range(16)]
+ expected_result = tuple(src_data)
+
+ period = 9177;
+ offset = 0;
+
+ src = gr.null_source(1)
+ head = gr.head(1, 10000000);
+ ins = blocks.vector_insert_b([1], period, offset);
+ dst = blocks.vector_sink_b()
+
+ self.tb.connect(src, head, ins, dst)
+ self.tb.run()
+ result_data = dst.data()
+
+ for i in range(10000):
+ if(i%period == offset):
+ self.assertEqual(1, result_data[i])
+ else:
+ self.assertEqual(0, result_data[i])
+
+if __name__ == '__main__':
+ gr_unittest.run(test_vector_insert, "test_vector_insert.xml")
+
diff --git a/gr-blocks/python/qa_vector_map.py b/gr-blocks/python/qa_vector_map.py
new file mode 100644
index 0000000000..54565fe443
--- /dev/null
+++ b/gr-blocks/python/qa_vector_map.py
@@ -0,0 +1,104 @@
+#!/usr/bin/env python
+#
+# Copyright 2012,2013 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.
+#
+
+from gnuradio import gr, gr_unittest
+import blocks_swig as blocks
+import math
+
+class test_vector_map(gr_unittest.TestCase):
+
+ def setUp(self):
+ self.tb = gr.top_block()
+
+ def tearDown(self):
+ self.tb = None
+
+ def test_reversing(self):
+ # Chunk data in blocks of N and reverse the block contents.
+ N = 5
+ src_data = range(0, 20)
+ expected_result = []
+ for i in range(N-1, len(src_data), N):
+ for j in range(0, N):
+ expected_result.append(1.0*(i-j))
+ mapping = [list(reversed([(0, i) for i in range(0, N)]))]
+ src = blocks.vector_source_f(src_data, False, N)
+ vmap = blocks.vector_map(gr.sizeof_float, (N, ), mapping)
+ dst = blocks.vector_sink_f(N)
+ self.tb.connect(src, vmap, dst)
+ self.tb.run()
+ result_data = list(dst.data())
+ self.assertEqual(expected_result, result_data)
+
+ def test_vector_to_streams(self):
+ # Split an input vector into N streams.
+ N = 5
+ M = 20
+ src_data = range(0, M)
+ expected_results = []
+ for n in range(0, N):
+ expected_results.append(range(n, M, N))
+ mapping = [[(0, n)] for n in range(0, N)]
+ src = blocks.vector_source_f(src_data, False, N)
+ vmap = blocks.vector_map(gr.sizeof_float, (N, ), mapping)
+ dsts = [blocks.vector_sink_f(1) for n in range(0, N)]
+ self.tb.connect(src, vmap)
+ for n in range(0, N):
+ self.tb.connect((vmap, n), dsts[n])
+ self.tb.run()
+ for n in range(0, N):
+ result_data = list(dsts[n].data())
+ self.assertEqual(expected_results[n], result_data)
+
+ def test_interleaving(self):
+ # Takes 3 streams (a, b and c)
+ # Outputs 2 streams.
+ # First (d) is interleaving of a and b.
+ # Second (e) is interleaving of a and b and c. c is taken in
+ # chunks of 2 which are reversed.
+ A = (1, 2, 3, 4, 5)
+ B = (11, 12, 13, 14, 15)
+ C = (99, 98, 97, 96, 95, 94, 93, 92, 91, 90)
+ expected_D = (1, 11, 2, 12, 3, 13, 4, 14, 5, 15)
+ expected_E = (1, 11, 98, 99, 2, 12, 96, 97, 3, 13, 94, 95,
+ 4, 14, 92, 93, 5, 15, 90, 91)
+ mapping = [[(0, 0), (1, 0)], # mapping to produce D
+ [(0, 0), (1, 0), (2, 1), (2, 0)], # mapping to produce E
+ ]
+ srcA = blocks.vector_source_f(A, False, 1)
+ srcB = blocks.vector_source_f(B, False, 1)
+ srcC = blocks.vector_source_f(C, False, 2)
+ vmap = blocks.vector_map(gr.sizeof_int, (1, 1, 2), mapping)
+ dstD = blocks.vector_sink_f(2)
+ dstE = blocks.vector_sink_f(4)
+ self.tb.connect(srcA, (vmap, 0))
+ self.tb.connect(srcB, (vmap, 1))
+ self.tb.connect(srcC, (vmap, 2))
+ self.tb.connect((vmap, 0), dstD)
+ self.tb.connect((vmap, 1), dstE)
+ self.tb.run()
+ self.assertEqual(expected_D, dstD.data())
+ self.assertEqual(expected_E, dstE.data())
+
+if __name__ == '__main__':
+ gr_unittest.run(test_vector_map, "test_vector_map.xml")
+
diff --git a/gr-blocks/python/qa_vector_sink_source.py b/gr-blocks/python/qa_vector_sink_source.py
new file mode 100755
index 0000000000..169e6a4450
--- /dev/null
+++ b/gr-blocks/python/qa_vector_sink_source.py
@@ -0,0 +1,66 @@
+#!/usr/bin/env python
+#
+# Copyright 2008,2010,2013 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.
+#
+
+from gnuradio import gr, gr_unittest
+import blocks_swig as blocks
+import math
+
+class test_vector_sink_source(gr_unittest.TestCase):
+
+ def setUp(self):
+ self.tb = gr.top_block()
+
+ def tearDown(self):
+ self.tb = None
+
+ def test_001(self):
+ src_data = [float(x) for x in range(16)]
+ expected_result = tuple(src_data)
+
+ src = blocks.vector_source_f(src_data)
+ dst = blocks.vector_sink_f()
+
+ self.tb.connect(src, dst)
+ self.tb.run()
+ result_data = dst.data()
+ self.assertEqual(expected_result, result_data)
+
+ def test_002(self):
+ src_data = [float(x) for x in range(16)]
+ expected_result = tuple(src_data)
+
+ src = blocks.vector_source_f(src_data, False, 2)
+ dst = blocks.vector_sink_f(2)
+
+ self.tb.connect(src, dst)
+ self.tb.run()
+ result_data = dst.data()
+ self.assertEqual(expected_result, result_data)
+
+ def test_003(self):
+ src_data = [float(x) for x in range(16)]
+ expected_result = tuple(src_data)
+ self.assertRaises(RuntimeError, lambda : blocks.vector_source_f(src_data, False, 3))
+
+if __name__ == '__main__':
+ gr_unittest.run(test_vector_sink_source, "test_vector_sink_source.xml")
+
diff --git a/gr-blocks/python/qa_wavfile.py b/gr-blocks/python/qa_wavfile.py
new file mode 100755
index 0000000000..b40b9b7ec3
--- /dev/null
+++ b/gr-blocks/python/qa_wavfile.py
@@ -0,0 +1,69 @@
+#!/usr/bin/env python
+#
+# Copyright 2008,2010,2013 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.
+#
+
+from gnuradio import gr, gr_unittest
+import blocks_swig as blocks
+
+import os
+from os.path import getsize
+
+g_in_file = os.path.join(os.getenv("srcdir"), "test_16bit_1chunk.wav")
+
+class test_wavefile(gr_unittest.TestCase):
+
+ def setUp(self):
+ self.tb = gr.top_block()
+
+ def tearDown(self):
+ self.tb = None
+
+ def test_001_checkwavread(self):
+ wf = blocks.wavfile_source(g_in_file)
+ self.assertEqual(wf.sample_rate(), 8000)
+
+ def test_002_checkwavcopy(self):
+ infile = g_in_file
+ outfile = "test_out.wav"
+
+ wf_in = blocks.wavfile_source(infile)
+ wf_out = blocks.wavfile_sink(outfile,
+ wf_in.channels(),
+ wf_in.sample_rate(),
+ wf_in.bits_per_sample())
+ self.tb.connect(wf_in, wf_out)
+ self.tb.run()
+ wf_out.close()
+
+ self.assertEqual(getsize(infile), getsize(outfile))
+
+ in_f = file(infile, 'rb')
+ out_f = file(outfile, 'rb')
+
+ in_data = in_f.read()
+ out_data = out_f.read()
+ out_f.close()
+ os.remove(outfile)
+
+ self.assertEqual(in_data, out_data)
+
+if __name__ == '__main__':
+ gr_unittest.run(test_wavefile, "test_wavefile.xml")
diff --git a/gr-blocks/python/test_16bit_1chunk.wav b/gr-blocks/python/test_16bit_1chunk.wav
new file mode 100644
index 0000000000..0fe12a7a13
--- /dev/null
+++ b/gr-blocks/python/test_16bit_1chunk.wav
Binary files differ
diff --git a/gr-blocks/swig/blocks_swig.i b/gr-blocks/swig/blocks_swig.i
index db8af34368..7aa087192d 100644
--- a/gr-blocks/swig/blocks_swig.i
+++ b/gr-blocks/swig/blocks_swig.i
@@ -23,12 +23,16 @@
#define BLOCKS_API
%include "gnuradio.i"
+%include "blocks/pdu.h"
//load generated python docstrings
%include "blocks_swig_doc.i"
%include <gr_endianness.h>
+%template() std::vector<size_t>;
+%template() std::vector< std::vector< std::vector<size_t> > >;
+
%{
#include "blocks/add_ff.h"
#include "blocks/add_ss.h"
@@ -48,8 +52,14 @@
#include "blocks/and_const_bb.h"
#include "blocks/and_const_ss.h"
#include "blocks/and_const_ii.h"
+#include "blocks/argmax_fs.h"
+#include "blocks/argmax_is.h"
+#include "blocks/argmax_ss.h"
+#include "blocks/bin_statistics_f.h"
+#include "blocks/burst_tagger.h"
#include "blocks/char_to_float.h"
#include "blocks/char_to_short.h"
+#include "blocks/check_lfsr_32k_s.h"
#include "blocks/complex_to_interleaved_short.h"
#include "blocks/complex_to_float.h"
#include "blocks/complex_to_real.h"
@@ -58,12 +68,18 @@
#include "blocks/complex_to_mag_squared.h"
#include "blocks/complex_to_arg.h"
#include "blocks/conjugate_cc.h"
+#include "blocks/copy.h"
#include "blocks/deinterleave.h"
#include "blocks/delay.h"
#include "blocks/divide_ff.h"
#include "blocks/divide_ss.h"
#include "blocks/divide_ii.h"
#include "blocks/divide_cc.h"
+#include "blocks/endian_swap.h"
+#include "blocks/file_descriptor_sink.h"
+#include "blocks/file_descriptor_source.h"
+#include "blocks/file_sink_base.h"
+#include "blocks/file_sink.h"
#include "blocks/file_source.h"
#include "blocks/file_meta_sink.h"
#include "blocks/file_meta_source.h"
@@ -72,6 +88,7 @@
#include "blocks/float_to_int.h"
#include "blocks/float_to_short.h"
#include "blocks/float_to_uchar.h"
+#include "blocks/head.h"
#include "blocks/int_to_float.h"
#include "blocks/integrate_ss.h"
#include "blocks/integrate_ii.h"
@@ -81,6 +98,19 @@
#include "blocks/interleaved_short_to_complex.h"
#include "blocks/keep_m_in_n.h"
#include "blocks/keep_one_in_n.h"
+#include "blocks/lfsr_32k_source_s.h"
+#include "blocks/max_ff.h"
+#include "blocks/max_ii.h"
+#include "blocks/max_ss.h"
+#include "blocks/message_debug.h"
+#include "blocks/message_sink.h"
+#include "blocks/message_source.h"
+#include "blocks/message_strobe.h"
+#include "blocks/message_burst_source.h"
+#include "blocks/moving_average_cc.h"
+#include "blocks/moving_average_ff.h"
+#include "blocks/moving_average_ii.h"
+#include "blocks/moving_average_ss.h"
#include "blocks/multiply_ss.h"
#include "blocks/multiply_ii.h"
#include "blocks/multiply_ff.h"
@@ -94,24 +124,55 @@
#include "blocks/multiply_const_vii.h"
#include "blocks/multiply_const_vff.h"
#include "blocks/multiply_const_vcc.h"
+#include "blocks/mute_ss.h"
+#include "blocks/mute_ii.h"
+#include "blocks/mute_ff.h"
+#include "blocks/mute_cc.h"
#include "blocks/nlog10_ff.h"
+#include "blocks/nop.h"
#include "blocks/not_bb.h"
#include "blocks/not_ss.h"
#include "blocks/not_ii.h"
+#include "blocks/null_sink.h"
+#include "blocks/null_source.h"
#include "blocks/patterned_interleaver.h"
+#include "blocks/pack_k_bits_bb.h"
#include "blocks/packed_to_unpacked_bb.h"
#include "blocks/packed_to_unpacked_ss.h"
#include "blocks/packed_to_unpacked_ii.h"
+#include "blocks/pdu_to_tagged_stream.h"
+#include "blocks/peak_detector_fb.h"
+#include "blocks/peak_detector_ib.h"
+#include "blocks/peak_detector_sb.h"
#include "blocks/peak_detector2_fb.h"
+#include "blocks/plateau_detector_fb.h"
+#include "blocks/probe_rate.h"
+#include "blocks/probe_signal_b.h"
+#include "blocks/probe_signal_s.h"
+#include "blocks/probe_signal_i.h"
+#include "blocks/probe_signal_f.h"
+#include "blocks/probe_signal_c.h"
+#include "blocks/probe_signal_vb.h"
+#include "blocks/probe_signal_vs.h"
+#include "blocks/probe_signal_vi.h"
+#include "blocks/probe_signal_vf.h"
+#include "blocks/probe_signal_vc.h"
#include "blocks/or_bb.h"
#include "blocks/or_ss.h"
#include "blocks/or_ii.h"
#include "blocks/regenerate_bb.h"
+#include "blocks/repack_bits_bb.h"
#include "blocks/repeat.h"
#include "blocks/rms_cf.h"
#include "blocks/rms_ff.h"
+#include "blocks/sample_and_hold_bb.h"
+#include "blocks/sample_and_hold_ss.h"
+#include "blocks/sample_and_hold_ii.h"
+#include "blocks/sample_and_hold_ff.h"
#include "blocks/short_to_char.h"
#include "blocks/short_to_float.h"
+#include "blocks/skiphead.h"
+#include "blocks/socket_pdu.h"
#include "blocks/stream_mux.h"
#include "blocks/stream_to_streams.h"
#include "blocks/stream_to_vector.h"
@@ -122,15 +183,42 @@
#include "blocks/sub_ss.h"
#include "blocks/sub_ii.h"
#include "blocks/sub_cc.h"
+#include "blocks/tag_debug.h"
+#include "blocks/tagged_file_sink.h"
+#include "blocks/tagged_stream_mux.h"
+#include "blocks/tagged_stream_to_pdu.h"
#include "blocks/threshold_ff.h"
#include "blocks/throttle.h"
#include "blocks/transcendental.h"
+#include "blocks/tuntap_pdu.h"
#include "blocks/uchar_to_float.h"
+#include "blocks/udp_sink.h"
+#include "blocks/udp_source.h"
+#include "blocks/unpack_k_bits_bb.h"
#include "blocks/unpacked_to_packed_bb.h"
#include "blocks/unpacked_to_packed_ss.h"
#include "blocks/unpacked_to_packed_ii.h"
+#include "blocks/vco_f.h"
+#include "blocks/vector_map.h"
#include "blocks/vector_to_stream.h"
#include "blocks/vector_to_streams.h"
+#include "blocks/vector_insert_b.h"
+#include "blocks/vector_insert_s.h"
+#include "blocks/vector_insert_i.h"
+#include "blocks/vector_insert_f.h"
+#include "blocks/vector_insert_c.h"
+#include "blocks/vector_sink_b.h"
+#include "blocks/vector_sink_s.h"
+#include "blocks/vector_sink_i.h"
+#include "blocks/vector_sink_f.h"
+#include "blocks/vector_sink_c.h"
+#include "blocks/vector_source_b.h"
+#include "blocks/vector_source_s.h"
+#include "blocks/vector_source_i.h"
+#include "blocks/vector_source_f.h"
+#include "blocks/vector_source_c.h"
+#include "blocks/wavfile_sink.h"
+#include "blocks/wavfile_source.h"
#include "blocks/xor_bb.h"
#include "blocks/xor_ss.h"
#include "blocks/xor_ii.h"
@@ -154,8 +242,14 @@
%include "blocks/and_const_bb.h"
%include "blocks/and_const_ss.h"
%include "blocks/and_const_ii.h"
+%include "blocks/argmax_fs.h"
+%include "blocks/argmax_is.h"
+%include "blocks/argmax_ss.h"
%include "blocks/char_to_float.h"
+%include "blocks/bin_statistics_f.h"
+%include "blocks/burst_tagger.h"
%include "blocks/char_to_short.h"
+%include "blocks/check_lfsr_32k_s.h"
%include "blocks/complex_to_interleaved_short.h"
%include "blocks/complex_to_float.h"
%include "blocks/complex_to_real.h"
@@ -164,8 +258,13 @@
%include "blocks/complex_to_mag_squared.h"
%include "blocks/complex_to_arg.h"
%include "blocks/conjugate_cc.h"
+%include "blocks/copy.h"
%include "blocks/deinterleave.h"
%include "blocks/delay.h"
+%include "blocks/file_descriptor_sink.h"
+%include "blocks/file_descriptor_source.h"
+%include "blocks/file_sink_base.h"
+%include "blocks/file_sink.h"
%include "blocks/file_source.h"
%include "blocks/file_meta_sink.h"
%include "blocks/file_meta_source.h"
@@ -173,11 +272,13 @@
%include "blocks/divide_ss.h"
%include "blocks/divide_ii.h"
%include "blocks/divide_cc.h"
+%include "blocks/endian_swap.h"
%include "blocks/float_to_char.h"
%include "blocks/float_to_complex.h"
%include "blocks/float_to_int.h"
%include "blocks/float_to_short.h"
%include "blocks/float_to_uchar.h"
+%include "blocks/head.h"
%include "blocks/int_to_float.h"
%include "blocks/integrate_ss.h"
%include "blocks/integrate_ii.h"
@@ -187,6 +288,19 @@
%include "blocks/interleaved_short_to_complex.h"
%include "blocks/keep_m_in_n.h"
%include "blocks/keep_one_in_n.h"
+%include "blocks/lfsr_32k_source_s.h"
+%include "blocks/max_ff.h"
+%include "blocks/max_ii.h"
+%include "blocks/max_ss.h"
+%include "blocks/message_debug.h"
+%include "blocks/message_sink.h"
+%include "blocks/message_source.h"
+%include "blocks/message_strobe.h"
+%include "blocks/message_burst_source.h"
+%include "blocks/moving_average_cc.h"
+%include "blocks/moving_average_ff.h"
+%include "blocks/moving_average_ii.h"
+%include "blocks/moving_average_ss.h"
%include "blocks/multiply_ss.h"
%include "blocks/multiply_ii.h"
%include "blocks/multiply_ff.h"
@@ -200,24 +314,56 @@
%include "blocks/multiply_const_vii.h"
%include "blocks/multiply_const_vff.h"
%include "blocks/multiply_const_vcc.h"
+%include "blocks/mute_ss.h"
+%include "blocks/mute_ii.h"
+%include "blocks/mute_ff.h"
+%include "blocks/mute_cc.h"
%include "blocks/nlog10_ff.h"
+%include "blocks/nop.h"
%include "blocks/not_bb.h"
%include "blocks/not_ss.h"
%include "blocks/not_ii.h"
-%include "blocks/patterned_interleaver.h"
+%include "blocks/null_sink.h"
+%include "blocks/null_source.h"
+%include "blocks/probe_signal_b.h"
+%include "blocks/probe_signal_s.h"
+%include "blocks/probe_signal_i.h"
+%include "blocks/probe_signal_f.h"
+%include "blocks/probe_signal_c.h"
+%include "blocks/probe_signal_vb.h"
+%include "blocks/probe_signal_vs.h"
+%include "blocks/probe_signal_vi.h"
+%include "blocks/probe_signal_vf.h"
+%include "blocks/probe_signal_vc.h"
+%include "blocks/or_bb.h"
+%include "blocks/or_ss.h"
+%include "blocks/or_ii.h"
+%include "blocks/pack_k_bits_bb.h"
%include "blocks/packed_to_unpacked_bb.h"
%include "blocks/packed_to_unpacked_ss.h"
%include "blocks/packed_to_unpacked_ii.h"
+%include "blocks/patterned_interleaver.h"
+%include "blocks/tag_debug.h"
+%include "blocks/pdu_to_tagged_stream.h"
+%include "blocks/peak_detector_fb.h"
+%include "blocks/peak_detector_ib.h"
+%include "blocks/peak_detector_sb.h"
%include "blocks/peak_detector2_fb.h"
-%include "blocks/or_bb.h"
-%include "blocks/or_ss.h"
-%include "blocks/or_ii.h"
+%include "blocks/plateau_detector_fb.h"
+%include "blocks/probe_rate.h"
%include "blocks/regenerate_bb.h"
+%include "blocks/repack_bits_bb.h"
%include "blocks/repeat.h"
%include "blocks/rms_cf.h"
%include "blocks/rms_ff.h"
+%include "blocks/sample_and_hold_bb.h"
+%include "blocks/sample_and_hold_ss.h"
+%include "blocks/sample_and_hold_ii.h"
+%include "blocks/sample_and_hold_ff.h"
%include "blocks/short_to_char.h"
%include "blocks/short_to_float.h"
+%include "blocks/skiphead.h"
+%include "blocks/socket_pdu.h"
%include "blocks/stream_mux.h"
%include "blocks/stream_to_streams.h"
%include "blocks/stream_to_vector.h"
@@ -228,15 +374,41 @@
%include "blocks/sub_ss.h"
%include "blocks/sub_ii.h"
%include "blocks/sub_cc.h"
+%include "blocks/tagged_file_sink.h"
+%include "blocks/tagged_stream_mux.h"
+%include "blocks/tagged_stream_to_pdu.h"
%include "blocks/threshold_ff.h"
%include "blocks/throttle.h"
%include "blocks/transcendental.h"
+%include "blocks/tuntap_pdu.h"
%include "blocks/uchar_to_float.h"
+%include "blocks/udp_sink.h"
+%include "blocks/udp_source.h"
+%include "blocks/unpack_k_bits_bb.h"
%include "blocks/unpacked_to_packed_bb.h"
%include "blocks/unpacked_to_packed_ss.h"
%include "blocks/unpacked_to_packed_ii.h"
+%include "blocks/vco_f.h"
+%include "blocks/vector_map.h"
%include "blocks/vector_to_stream.h"
%include "blocks/vector_to_streams.h"
+%include "blocks/vector_insert_b.h"
+%include "blocks/vector_insert_s.h"
+%include "blocks/vector_insert_i.h"
+%include "blocks/vector_insert_f.h"
+%include "blocks/vector_insert_c.h"
+%include "blocks/vector_sink_b.h"
+%include "blocks/vector_sink_s.h"
+%include "blocks/vector_sink_i.h"
+%include "blocks/vector_sink_f.h"
+%include "blocks/vector_sink_c.h"
+%include "blocks/vector_source_b.h"
+%include "blocks/vector_source_s.h"
+%include "blocks/vector_source_i.h"
+%include "blocks/vector_source_f.h"
+%include "blocks/vector_source_c.h"
+%include "blocks/wavfile_sink.h"
+%include "blocks/wavfile_source.h"
%include "blocks/xor_bb.h"
%include "blocks/xor_ss.h"
%include "blocks/xor_ii.h"
@@ -259,8 +431,14 @@ GR_SWIG_BLOCK_MAGIC2(blocks, and_ii);
GR_SWIG_BLOCK_MAGIC2(blocks, and_const_bb);
GR_SWIG_BLOCK_MAGIC2(blocks, and_const_ss);
GR_SWIG_BLOCK_MAGIC2(blocks, and_const_ii);
+GR_SWIG_BLOCK_MAGIC2(blocks, argmax_fs);
+GR_SWIG_BLOCK_MAGIC2(blocks, argmax_is);
+GR_SWIG_BLOCK_MAGIC2(blocks, argmax_ss);
+GR_SWIG_BLOCK_MAGIC2(blocks, bin_statistics_f);
+GR_SWIG_BLOCK_MAGIC2(blocks, burst_tagger);
GR_SWIG_BLOCK_MAGIC2(blocks, char_to_float);
GR_SWIG_BLOCK_MAGIC2(blocks, char_to_short);
+GR_SWIG_BLOCK_MAGIC2(blocks, check_lfsr_32k_s);
GR_SWIG_BLOCK_MAGIC2(blocks, complex_to_interleaved_short);
GR_SWIG_BLOCK_MAGIC2(blocks, complex_to_float);
GR_SWIG_BLOCK_MAGIC2(blocks, complex_to_real);
@@ -269,12 +447,17 @@ GR_SWIG_BLOCK_MAGIC2(blocks, complex_to_mag);
GR_SWIG_BLOCK_MAGIC2(blocks, complex_to_mag_squared);
GR_SWIG_BLOCK_MAGIC2(blocks, complex_to_arg);
GR_SWIG_BLOCK_MAGIC2(blocks, conjugate_cc);
+GR_SWIG_BLOCK_MAGIC2(blocks, copy);
GR_SWIG_BLOCK_MAGIC2(blocks, deinterleave);
GR_SWIG_BLOCK_MAGIC2(blocks, delay);
+GR_SWIG_BLOCK_MAGIC2(blocks, endian_swap);
GR_SWIG_BLOCK_MAGIC2(blocks, divide_ff);
GR_SWIG_BLOCK_MAGIC2(blocks, divide_ss);
GR_SWIG_BLOCK_MAGIC2(blocks, divide_ii);
GR_SWIG_BLOCK_MAGIC2(blocks, divide_cc);
+GR_SWIG_BLOCK_MAGIC2(blocks, file_descriptor_sink);
+GR_SWIG_BLOCK_MAGIC2(blocks, file_descriptor_source);
+GR_SWIG_BLOCK_MAGIC2(blocks, file_sink);
GR_SWIG_BLOCK_MAGIC2(blocks, file_source);
GR_SWIG_BLOCK_MAGIC2(blocks, file_meta_sink);
GR_SWIG_BLOCK_MAGIC2(blocks, file_meta_source);
@@ -283,6 +466,7 @@ GR_SWIG_BLOCK_MAGIC2(blocks, float_to_complex);
GR_SWIG_BLOCK_MAGIC2(blocks, float_to_int);
GR_SWIG_BLOCK_MAGIC2(blocks, float_to_short);
GR_SWIG_BLOCK_MAGIC2(blocks, float_to_uchar);
+GR_SWIG_BLOCK_MAGIC2(blocks, head);
GR_SWIG_BLOCK_MAGIC2(blocks, int_to_float);
GR_SWIG_BLOCK_MAGIC2(blocks, integrate_ss);
GR_SWIG_BLOCK_MAGIC2(blocks, integrate_ii);
@@ -292,6 +476,19 @@ GR_SWIG_BLOCK_MAGIC2(blocks, interleave);
GR_SWIG_BLOCK_MAGIC2(blocks, interleaved_short_to_complex);
GR_SWIG_BLOCK_MAGIC2(blocks, keep_m_in_n);
GR_SWIG_BLOCK_MAGIC2(blocks, keep_one_in_n);
+GR_SWIG_BLOCK_MAGIC2(blocks, lfsr_32k_source_s);
+GR_SWIG_BLOCK_MAGIC2(blocks, max_ff);
+GR_SWIG_BLOCK_MAGIC2(blocks, max_ii);
+GR_SWIG_BLOCK_MAGIC2(blocks, max_ss);
+GR_SWIG_BLOCK_MAGIC2(blocks, message_debug);
+GR_SWIG_BLOCK_MAGIC2(blocks, message_sink);
+GR_SWIG_BLOCK_MAGIC2(blocks, message_source);
+GR_SWIG_BLOCK_MAGIC2(blocks, message_strobe);
+GR_SWIG_BLOCK_MAGIC2(blocks, message_burst_source);
+GR_SWIG_BLOCK_MAGIC2(blocks, moving_average_cc);
+GR_SWIG_BLOCK_MAGIC2(blocks, moving_average_ff);
+GR_SWIG_BLOCK_MAGIC2(blocks, moving_average_ii);
+GR_SWIG_BLOCK_MAGIC2(blocks, moving_average_ss);
GR_SWIG_BLOCK_MAGIC2(blocks, multiply_ss);
GR_SWIG_BLOCK_MAGIC2(blocks, multiply_ii);
GR_SWIG_BLOCK_MAGIC2(blocks, multiply_ff);
@@ -305,24 +502,55 @@ GR_SWIG_BLOCK_MAGIC2(blocks, multiply_const_vss);
GR_SWIG_BLOCK_MAGIC2(blocks, multiply_const_vii);
GR_SWIG_BLOCK_MAGIC2(blocks, multiply_const_vff);
GR_SWIG_BLOCK_MAGIC2(blocks, multiply_const_vcc);
+GR_SWIG_BLOCK_MAGIC2(blocks, mute_ss);
+GR_SWIG_BLOCK_MAGIC2(blocks, mute_ii);
+GR_SWIG_BLOCK_MAGIC2(blocks, mute_ff);
+GR_SWIG_BLOCK_MAGIC2(blocks, mute_cc);
GR_SWIG_BLOCK_MAGIC2(blocks, nlog10_ff);
+GR_SWIG_BLOCK_MAGIC2(blocks, nop);
GR_SWIG_BLOCK_MAGIC2(blocks, not_bb);
GR_SWIG_BLOCK_MAGIC2(blocks, not_ss);
GR_SWIG_BLOCK_MAGIC2(blocks, not_ii);
+GR_SWIG_BLOCK_MAGIC2(blocks, null_sink);
+GR_SWIG_BLOCK_MAGIC2(blocks, null_source);
GR_SWIG_BLOCK_MAGIC2(blocks, patterned_interleaver);
+GR_SWIG_BLOCK_MAGIC2(blocks, pack_k_bits_bb);
GR_SWIG_BLOCK_MAGIC2(blocks, packed_to_unpacked_bb);
GR_SWIG_BLOCK_MAGIC2(blocks, packed_to_unpacked_ss);
GR_SWIG_BLOCK_MAGIC2(blocks, packed_to_unpacked_ii);
+GR_SWIG_BLOCK_MAGIC2(blocks, peak_detector_fb);
+GR_SWIG_BLOCK_MAGIC2(blocks, peak_detector_ib);
+GR_SWIG_BLOCK_MAGIC2(blocks, peak_detector_sb);
GR_SWIG_BLOCK_MAGIC2(blocks, peak_detector2_fb);
+GR_SWIG_BLOCK_MAGIC2(blocks, plateau_detector_fb);
+GR_SWIG_BLOCK_MAGIC2(blocks, pdu_to_tagged_stream);
+GR_SWIG_BLOCK_MAGIC2(blocks, probe_rate);
GR_SWIG_BLOCK_MAGIC2(blocks, or_bb);
GR_SWIG_BLOCK_MAGIC2(blocks, or_ss);
GR_SWIG_BLOCK_MAGIC2(blocks, or_ii);
+GR_SWIG_BLOCK_MAGIC2(blocks, probe_signal_b);
+GR_SWIG_BLOCK_MAGIC2(blocks, probe_signal_s);
+GR_SWIG_BLOCK_MAGIC2(blocks, probe_signal_i);
+GR_SWIG_BLOCK_MAGIC2(blocks, probe_signal_f);
+GR_SWIG_BLOCK_MAGIC2(blocks, probe_signal_c);
+GR_SWIG_BLOCK_MAGIC2(blocks, probe_signal_vb);
+GR_SWIG_BLOCK_MAGIC2(blocks, probe_signal_vs);
+GR_SWIG_BLOCK_MAGIC2(blocks, probe_signal_vi);
+GR_SWIG_BLOCK_MAGIC2(blocks, probe_signal_vf);
+GR_SWIG_BLOCK_MAGIC2(blocks, probe_signal_vc);
GR_SWIG_BLOCK_MAGIC2(blocks, regenerate_bb);
+GR_SWIG_BLOCK_MAGIC2(blocks, repack_bits_bb);
GR_SWIG_BLOCK_MAGIC2(blocks, repeat);
GR_SWIG_BLOCK_MAGIC2(blocks, rms_cf);
GR_SWIG_BLOCK_MAGIC2(blocks, rms_ff);
+GR_SWIG_BLOCK_MAGIC2(blocks, sample_and_hold_bb);
+GR_SWIG_BLOCK_MAGIC2(blocks, sample_and_hold_ss);
+GR_SWIG_BLOCK_MAGIC2(blocks, sample_and_hold_ii);
+GR_SWIG_BLOCK_MAGIC2(blocks, sample_and_hold_ff);
GR_SWIG_BLOCK_MAGIC2(blocks, short_to_char);
GR_SWIG_BLOCK_MAGIC2(blocks, short_to_float);
+GR_SWIG_BLOCK_MAGIC2(blocks, skiphead);
+GR_SWIG_BLOCK_MAGIC2(blocks, socket_pdu);
GR_SWIG_BLOCK_MAGIC2(blocks, stream_mux);
GR_SWIG_BLOCK_MAGIC2(blocks, stream_to_streams);
GR_SWIG_BLOCK_MAGIC2(blocks, stream_to_vector);
@@ -333,15 +561,42 @@ GR_SWIG_BLOCK_MAGIC2(blocks, sub_ff);
GR_SWIG_BLOCK_MAGIC2(blocks, sub_ss);
GR_SWIG_BLOCK_MAGIC2(blocks, sub_ii);
GR_SWIG_BLOCK_MAGIC2(blocks, sub_cc);
+GR_SWIG_BLOCK_MAGIC2(blocks, tag_debug);
+GR_SWIG_BLOCK_MAGIC2(blocks, tagged_file_sink);
+GR_SWIG_BLOCK_MAGIC2(blocks, tagged_stream_mux);
+GR_SWIG_BLOCK_MAGIC2(blocks, tagged_stream_to_pdu);
GR_SWIG_BLOCK_MAGIC2(blocks, threshold_ff);
GR_SWIG_BLOCK_MAGIC2(blocks, throttle);
GR_SWIG_BLOCK_MAGIC2(blocks, transcendental);
+GR_SWIG_BLOCK_MAGIC2(blocks, tuntap_pdu);
GR_SWIG_BLOCK_MAGIC2(blocks, uchar_to_float);
+GR_SWIG_BLOCK_MAGIC2(blocks, udp_sink);
+GR_SWIG_BLOCK_MAGIC2(blocks, udp_source);
+GR_SWIG_BLOCK_MAGIC2(blocks, unpack_k_bits_bb);
GR_SWIG_BLOCK_MAGIC2(blocks, unpacked_to_packed_bb);
GR_SWIG_BLOCK_MAGIC2(blocks, unpacked_to_packed_ss);
GR_SWIG_BLOCK_MAGIC2(blocks, unpacked_to_packed_ii);
+GR_SWIG_BLOCK_MAGIC2(blocks, vco_f);
+GR_SWIG_BLOCK_MAGIC2(blocks, vector_map);
GR_SWIG_BLOCK_MAGIC2(blocks, vector_to_stream);
GR_SWIG_BLOCK_MAGIC2(blocks, vector_to_streams);
+GR_SWIG_BLOCK_MAGIC2(blocks, vector_insert_b);
+GR_SWIG_BLOCK_MAGIC2(blocks, vector_insert_s);
+GR_SWIG_BLOCK_MAGIC2(blocks, vector_insert_i);
+GR_SWIG_BLOCK_MAGIC2(blocks, vector_insert_f);
+GR_SWIG_BLOCK_MAGIC2(blocks, vector_insert_c);
+GR_SWIG_BLOCK_MAGIC2(blocks, vector_sink_b);
+GR_SWIG_BLOCK_MAGIC2(blocks, vector_sink_s);
+GR_SWIG_BLOCK_MAGIC2(blocks, vector_sink_i);
+GR_SWIG_BLOCK_MAGIC2(blocks, vector_sink_f);
+GR_SWIG_BLOCK_MAGIC2(blocks, vector_sink_c);
+GR_SWIG_BLOCK_MAGIC2(blocks, vector_source_b);
+GR_SWIG_BLOCK_MAGIC2(blocks, vector_source_s);
+GR_SWIG_BLOCK_MAGIC2(blocks, vector_source_i);
+GR_SWIG_BLOCK_MAGIC2(blocks, vector_source_f);
+GR_SWIG_BLOCK_MAGIC2(blocks, vector_source_c);
+GR_SWIG_BLOCK_MAGIC2(blocks, wavfile_sink);
+GR_SWIG_BLOCK_MAGIC2(blocks, wavfile_source);
GR_SWIG_BLOCK_MAGIC2(blocks, xor_bb);
GR_SWIG_BLOCK_MAGIC2(blocks, xor_ss);
GR_SWIG_BLOCK_MAGIC2(blocks, xor_ii);
diff --git a/gr-blocks/tests/CMakeLists.txt b/gr-blocks/tests/CMakeLists.txt
new file mode 100644
index 0000000000..ec17c017f1
--- /dev/null
+++ b/gr-blocks/tests/CMakeLists.txt
@@ -0,0 +1,56 @@
+# Copyright 2010-2013 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.
+
+########################################################################
+include(GrMiscUtils) #check n def
+GR_CHECK_HDR_N_DEF(sys/resource.h HAVE_SYS_RESOURCE_H)
+
+########################################################################
+# Setup the include and linker paths
+########################################################################
+include_directories(
+ ${GR_BLOCKS_INCLUDE_DIRS}
+ ${GNURADIO_CORE_INCLUDE_DIRS}
+ ${GRUEL_INCLUDE_DIRS}
+ ${Boost_INCLUDE_DIRS}
+ ${CPPUNIT_INCLUDE_DIRS}
+)
+
+link_directories(
+ ${Boost_LIBRARY_DIRS}
+ ${CPPUNIT_LIBRARY_DIRS}
+)
+
+include_directories(${LOG4CPP_INCLUDE_DIRS})
+link_directories(${LOG4CPP_LIBRARY_DIRS})
+
+########################################################################
+# Build benchmarks and non-registered tests
+########################################################################
+set(tests_not_run #single source per test
+ benchmark_nco.cc
+ benchmark_vco.cc
+)
+
+foreach(test_not_run_src ${tests_not_run})
+ get_filename_component(name ${test_not_run_src} NAME_WE)
+ add_executable(${name} ${test_not_run_src})
+ target_link_libraries(${name} test-gnuradio-core gnuradio-blocks ${LOG4CPP_LIBRARIES})
+endforeach(test_not_run_src)
+
diff --git a/gr-blocks/tests/benchmark_nco.cc b/gr-blocks/tests/benchmark_nco.cc
new file mode 100644
index 0000000000..4c2ed120db
--- /dev/null
+++ b/gr-blocks/tests/benchmark_nco.cc
@@ -0,0 +1,225 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2002,2004,2013 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/time.h>
+
+#ifdef HAVE_SYS_RESOURCE_H
+#include <sys/resource.h>
+#endif
+
+#include <unistd.h>
+#include <blocks/nco.h>
+#include <blocks/fxpt_nco.h>
+#include <string.h>
+
+#define ITERATIONS 20000000
+#define BLOCK_SIZE (10 * 1000) // fits in cache
+
+#define FREQ 5003.123
+
+static double
+timeval_to_double(const struct timeval *tv)
+{
+ return (double)tv->tv_sec + (double)tv->tv_usec * 1e-6;
+}
+
+
+static void
+benchmark(void test (float *x, float *y), const char *implementation_name)
+{
+#ifdef HAVE_SYS_RESOURCE_H
+ struct rusage rusage_start;
+ struct rusage rusage_stop;
+#else
+ double clock_start;
+ double clock_end;
+#endif
+ float output[2*BLOCK_SIZE];
+ float *x = &output[0], *y = &output[BLOCK_SIZE];
+
+ // touch memory
+ memset(output, 0, 2*BLOCK_SIZE*sizeof(float));
+
+ // get starting CPU usage
+#ifdef HAVE_SYS_RESOURCE_H
+ if(getrusage(RUSAGE_SELF, &rusage_start) < 0) {
+ perror("getrusage");
+ exit(1);
+ }
+#else
+ clock_start = (double)clock() * (1000000. / CLOCKS_PER_SEC);
+#endif
+ // do the actual work
+
+ test(x, y);
+
+ // get ending CPU usage
+
+#ifdef HAVE_SYS_RESOURCE_H
+ if(getrusage(RUSAGE_SELF, &rusage_stop) < 0) {
+ perror("getrusage");
+ exit(1);
+ }
+
+ // compute results
+
+ double user =
+ timeval_to_double(&rusage_stop.ru_utime)
+ - timeval_to_double(&rusage_start.ru_utime);
+
+ double sys =
+ timeval_to_double(&rusage_stop.ru_stime)
+ - timeval_to_double(&rusage_start.ru_stime);
+
+ double total = user + sys;
+#else
+ clock_end = (double)clock() * (1000000. / CLOCKS_PER_SEC);
+ double total = clock_end - clock_start;
+#endif
+
+ printf("%18s: cpu: %6.3f steps/sec: %10.3e\n",
+ implementation_name, total, ITERATIONS / total);
+}
+
+// ----------------------------------------------------------------
+// Don't compare the _vec with other functions since memory store's
+// are involved.
+
+void basic_sincos_vec(float *x, float *y)
+{
+ gr::blocks::nco<float,float> nco;
+
+ nco.set_freq(2 * M_PI / FREQ);
+
+ for(int i = 0; i < ITERATIONS/BLOCK_SIZE; i++) {
+ for(int j = 0; j < BLOCK_SIZE; j++) {
+ nco.sincos(&x[2*j+1], &x[2*j]);
+ nco.step();
+ }
+ }
+}
+
+void native_sincos_vec(float *x, float *y)
+{
+ gr::blocks::nco<float,float> nco;
+
+ nco.set_freq(2 * M_PI / FREQ);
+
+ for(int i = 0; i < ITERATIONS/BLOCK_SIZE; i++) {
+ nco.sincos((gr_complex*)x, BLOCK_SIZE);
+ }
+}
+
+void fxpt_sincos_vec(float *x, float *y)
+{
+ gr::blocks::fxpt_nco nco;
+
+ nco.set_freq (2 * M_PI / FREQ);
+
+ for(int i = 0; i < ITERATIONS/BLOCK_SIZE; i++) {
+ nco.sincos((gr_complex*)x, BLOCK_SIZE);
+ }
+}
+
+// ----------------------------------------------------------------
+
+void native_sincos(float *x, float *y)
+{
+ gr::blocks::nco<float,float> nco;
+
+ nco.set_freq(2 * M_PI / FREQ);
+
+ for(int i = 0; i < ITERATIONS; i++) {
+ nco.sincos(x, y);
+ nco.step();
+ }
+}
+
+void fxpt_sincos(float *x, float *y)
+{
+ gr::blocks::fxpt_nco nco;
+
+ nco.set_freq(2 * M_PI / FREQ);
+
+ for(int i = 0; i < ITERATIONS; i++) {
+ nco.sincos(x, y);
+ nco.step();
+ }
+}
+
+// ----------------------------------------------------------------
+
+void native_sin(float *x, float *y)
+{
+ gr::blocks::nco<float,float> nco;
+
+ nco.set_freq(2 * M_PI / FREQ);
+
+ for(int i = 0; i < ITERATIONS; i++) {
+ *x = nco.sin();
+ nco.step();
+ }
+}
+
+void fxpt_sin(float *x, float *y)
+{
+ gr::blocks::fxpt_nco nco;
+
+ nco.set_freq(2 * M_PI / FREQ);
+
+ for(int i = 0; i < ITERATIONS; i++) {
+ *x = nco.sin();
+ nco.step();
+ }
+}
+
+// ----------------------------------------------------------------
+
+void nop_fct(float *x, float *y)
+{
+}
+
+void nop_loop(float *x, float *y)
+{
+ for(int i = 0; i < ITERATIONS; i++) {
+ nop_fct(x, y);
+ }
+}
+
+int
+main(int argc, char **argv)
+{
+ benchmark(nop_loop, "nop loop");
+ benchmark(native_sin, "native sine");
+ benchmark(fxpt_sin, "fxpt sine");
+ benchmark(native_sincos, "native sin/cos");
+ benchmark(fxpt_sincos, "fxpt sin/cos");
+ benchmark(basic_sincos_vec, "basic sin/cos vec");
+ benchmark(native_sincos_vec, "native sin/cos vec");
+ benchmark(fxpt_sincos_vec, "fxpt sin/cos vec");
+}
diff --git a/gr-blocks/tests/benchmark_vco.cc b/gr-blocks/tests/benchmark_vco.cc
new file mode 100644
index 0000000000..955dc08051
--- /dev/null
+++ b/gr-blocks/tests/benchmark_vco.cc
@@ -0,0 +1,172 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2002,2004,2005,2013 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/time.h>
+
+#ifdef HAVE_SYS_RESOURCE_H
+#include <sys/resource.h>
+#endif
+
+#include <unistd.h>
+#include <blocks/vco.h>
+#include <blocks/fxpt_vco.h>
+#include <string.h>
+
+#define ITERATIONS 5000000
+#define BLOCK_SIZE (10 * 1000) // fits in cache
+
+#define FREQ 5003.123
+#define K 4.9999999
+#define AMPLITUDE 2.444444444
+
+
+static double
+timeval_to_double(const struct timeval *tv)
+{
+ return (double) tv->tv_sec + (double) tv->tv_usec * 1e-6;
+}
+
+
+static void
+benchmark(void test (float *x, const float *y), const char *implementation_name)
+{
+#ifdef HAVE_SYS_RESOURCE_H
+ struct rusage rusage_start;
+ struct rusage rusage_stop;
+#else
+ double clock_start;
+ double clock_end;
+#endif
+ float output[BLOCK_SIZE];
+ float input[BLOCK_SIZE];
+
+ // touch memory
+ memset(output, 0, BLOCK_SIZE*sizeof(float));
+ for(int i = 0; i<BLOCK_SIZE; i++)
+ input[i] = sin(double(i));
+
+ // get starting CPU usage
+#ifdef HAVE_SYS_RESOURCE_H
+ if(getrusage (RUSAGE_SELF, &rusage_start) < 0) {
+ perror("getrusage");
+ exit(1);
+ }
+#else
+ clock_start = (double)clock() * (1000000. / CLOCKS_PER_SEC);
+#endif
+ // do the actual work
+
+ test(output, input);
+
+ // get ending CPU usage
+
+#ifdef HAVE_SYS_RESOURCE_H
+ if(getrusage (RUSAGE_SELF, &rusage_stop) < 0) {
+ perror("getrusage");
+ exit(1);
+ }
+
+ // compute results
+
+ double user =
+ timeval_to_double(&rusage_stop.ru_utime)
+ - timeval_to_double(&rusage_start.ru_utime);
+
+ double sys =
+ timeval_to_double(&rusage_stop.ru_stime)
+ - timeval_to_double(&rusage_start.ru_stime);
+
+ double total = user + sys;
+#else
+ clock_end = (double)clock() * (1000000. / CLOCKS_PER_SEC);
+ double total = clock_end - clock_start;
+#endif
+
+ printf("%18s: cpu: %6.3f steps/sec: %10.3e\n",
+ implementation_name, total, ITERATIONS / total);
+}
+
+// ----------------------------------------------------------------
+
+void basic_vco(float *output, const float *input)
+{
+ double phase = 0;
+
+ for(int j = 0; j < ITERATIONS/BLOCK_SIZE; j++) {
+ for(int i = 0; i < BLOCK_SIZE; i++) {
+ output[i] = cos(phase) * AMPLITUDE;
+ phase += input[i] * K;
+
+ while(phase > 2 * M_PI)
+ phase -= 2 * M_PI;
+
+ while(phase < -2 * M_PI)
+ phase += 2 * M_PI;
+ }
+ }
+}
+
+void native_vco(float *output, const float *input)
+{
+ gr::blocks::vco<float,float> vco;
+
+ for(int j = 0; j < ITERATIONS/BLOCK_SIZE; j++) {
+ vco.cos(output, input, BLOCK_SIZE, K, AMPLITUDE);
+ }
+}
+
+void fxpt_vco(float *output, const float *input)
+{
+ gr::blocks::fxpt_vco vco;
+
+ for(int j = 0; j < ITERATIONS/BLOCK_SIZE; j++) {
+ vco.cos(output, input, BLOCK_SIZE, K, AMPLITUDE);
+ }
+}
+
+// ----------------------------------------------------------------
+
+void nop_fct(float *x, const float *y)
+{
+}
+
+void nop_loop(float *x, const float *y)
+{
+ for(int i = 0; i < ITERATIONS; i++) {
+ nop_fct(x, y);
+ }
+}
+
+int
+main(int argc, char **argv)
+{
+ benchmark(nop_loop, "nop loop");
+ benchmark(basic_vco, "basic vco");
+ benchmark(native_vco, "native vco");
+ benchmark(fxpt_vco, "fxpt vco");
+}
diff --git a/gr-blocks/tests/nco_results b/gr-blocks/tests/nco_results
new file mode 100644
index 0000000000..5bdf5dd1cb
--- /dev/null
+++ b/gr-blocks/tests/nco_results
@@ -0,0 +1,48 @@
+================================================================
+These are on a 1.4 GHz Pentium M using g++ 3.4.1
+================================================================
+
+Default compiler options -O2
+
+ nop loop: cpu: 0.015 steps/sec: 6.668e+08
+ native sine: cpu: 0.900 steps/sec: 1.111e+07
+ fxpt sine: cpu: 0.281 steps/sec: 3.559e+07
+ native sin/cos: cpu: 1.138 steps/sec: 8.789e+06
+ fxpt sin/cos: cpu: 0.550 steps/sec: 1.818e+07
+
+-O2 -march=pentium-m -fomit-frame-pointer
+
+ nop loop: cpu: 0.015 steps/sec: 6.668e+08
+ native sine: cpu: 0.903 steps/sec: 1.108e+07
+ fxpt sine: cpu: 0.271 steps/sec: 3.691e+07
+ native sin/cos: cpu: 1.092 steps/sec: 9.159e+06
+ fxpt sin/cos: cpu: 0.542 steps/sec: 1.845e+07
+
+Inlined fxpt::sin & cos
+-O2 -march=pentium-m -fomit-frame-pointer
+
+ nop loop: cpu: 0.015 steps/sec: 6.668e+08
+ native sine: cpu: 0.904 steps/sec: 1.106e+07
+ fxpt sine: cpu: 0.187 steps/sec: 5.348e+07
+ native sin/cos: cpu: 1.091 steps/sec: 9.167e+06
+ fxpt sin/cos: cpu: 0.373 steps/sec: 2.681e+07
+
+================================================================
+These are on a 1.5 GHz Athon MP 1800+
+================================================================
+
+Default compiler options: -O2
+
+ nop loop: cpu: 0.013 steps/sec: 7.693e+08
+ native sine: cpu: 0.733 steps/sec: 1.364e+07
+ fxpt sine: cpu: 0.210 steps/sec: 4.763e+07
+ native sin/cos: cpu: 1.183 steps/sec: 8.454e+06
+ fxpt sin/cos: cpu: 0.420 steps/sec: 2.381e+07
+
+-O2 -fomit-frame-pointer -march=athlon-mp
+
+ nop loop: cpu: 0.013 steps/sec: 7.693e+08
+ native sine: cpu: 0.679 steps/sec: 1.473e+07
+ fxpt sine: cpu: 0.200 steps/sec: 5.001e+07
+ native sin/cos: cpu: 1.147 steps/sec: 8.720e+06
+ fxpt sin/cos: cpu: 0.444 steps/sec: 2.253e+07
diff --git a/gr-comedi/src/CMakeLists.txt b/gr-comedi/src/CMakeLists.txt
index 1d9dac2c48..0dc0960016 100644
--- a/gr-comedi/src/CMakeLists.txt
+++ b/gr-comedi/src/CMakeLists.txt
@@ -33,6 +33,9 @@ link_directories(
${COMEDI_LIBRARY_DIRS}
)
+include_directories(${LOG4CPP_INCLUDE_DIRS})
+link_directories(${LOG4CPP_LIBRARY_DIRS})
+
########################################################################
# Setup library
########################################################################
@@ -46,6 +49,7 @@ list(APPEND comedi_libs
gnuradio-core
${Boost_LIBRARIES}
${COMEDI_LIBRARIES}
+ ${LOG4CPP_LIBRARIES}
)
add_library(gnuradio-comedi SHARED ${gr_comedi_sources})
diff --git a/gr-digital/CMakeLists.txt b/gr-digital/CMakeLists.txt
index 864cd673a9..12918bbfb3 100644
--- a/gr-digital/CMakeLists.txt
+++ b/gr-digital/CMakeLists.txt
@@ -30,6 +30,8 @@ GR_REGISTER_COMPONENT("gr-digital" ENABLE_GR_DIGITAL
Boost_FOUND
ENABLE_GR_CORE
ENABLE_GR_ANALOG
+ ENABLE_GR_BLOCKS
+ ENABLE_GR_FILTER
)
GR_SET_GLOBAL(GR_DIGITAL_INCLUDE_DIRS
@@ -85,6 +87,7 @@ CPACK_COMPONENT("digital_swig"
# Add subdirectories
########################################################################
add_subdirectory(include)
+add_subdirectory(include/digital)
add_subdirectory(lib)
add_subdirectory(doc)
if(ENABLE_PYTHON)
diff --git a/gr-digital/examples/ofdm/rx_ofdm.grc b/gr-digital/examples/ofdm/rx_ofdm.grc
new file mode 100644
index 0000000000..766fd9dc2b
--- /dev/null
+++ b/gr-digital/examples/ofdm/rx_ofdm.grc
@@ -0,0 +1,1092 @@
+<?xml version='1.0' encoding='ASCII'?>
+<flow_graph>
+ <timestamp>Thu Feb 14 15:49:35 2013</timestamp>
+ <block>
+ <key>options</key>
+ <param>
+ <key>id</key>
+ <value>rx_ofdm</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>title</key>
+ <value>OFDM Rx</value>
+ </param>
+ <param>
+ <key>author</key>
+ <value></value>
+ </param>
+ <param>
+ <key>description</key>
+ <value>Example of an OFDM receiver</value>
+ </param>
+ <param>
+ <key>window_size</key>
+ <value>1280, 1024</value>
+ </param>
+ <param>
+ <key>generate_options</key>
+ <value>wx_gui</value>
+ </param>
+ <param>
+ <key>category</key>
+ <value>Custom</value>
+ </param>
+ <param>
+ <key>run_options</key>
+ <value>prompt</value>
+ </param>
+ <param>
+ <key>run</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>max_nouts</key>
+ <value>0</value>
+ </param>
+ <param>
+ <key>realtime_scheduling</key>
+ <value></value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(0, -1)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>variable</key>
+ <param>
+ <key>id</key>
+ <value>pilot_symbols_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>value</key>
+ <value>((100,),)</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(762, 64)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>variable</key>
+ <param>
+ <key>id</key>
+ <value>pilot_carriers</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>value</key>
+ <value>((0,),)</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(557, 64)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>variable</key>
+ <param>
+ <key>id</key>
+ <value>header_formatter</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>value</key>
+ <value>digital.packet_header_ofdm(occupied_carriers, 1, length_tag_name)</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(876, 64)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>variable</key>
+ <param>
+ <key>id</key>
+ <value>pilot_symbols</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>value</key>
+ <value>((100,),)</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(659, 64)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>variable</key>
+ <param>
+ <key>id</key>
+ <value>occupied_carriers</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>value</key>
+ <value>(range(-26, -21) + range(-20, -7) + range(-6, 0) + range(1, 7) + range(8, 21) + range(22, 27),)</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(404, 64)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>analog_noise_source_x</key>
+ <param>
+ <key>id</key>
+ <value>analog_noise_source_x_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>type</key>
+ <value>complex</value>
+ </param>
+ <param>
+ <key>noise_type</key>
+ <value>analog.GR_GAUSSIAN</value>
+ </param>
+ <param>
+ <key>amp</key>
+ <value>1</value>
+ </param>
+ <param>
+ <key>seed</key>
+ <value>0</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(-1, 185)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>digital_ofdm_sync_sc_cfb</key>
+ <param>
+ <key>id</key>
+ <value>digital_ofdm_sync_sc_cfb_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>fft_len</key>
+ <value>fft_len</value>
+ </param>
+ <param>
+ <key>cp_len</key>
+ <value>fft_len/4</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(368, 178)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>analog_frequency_modulator_fc</key>
+ <param>
+ <key>id</key>
+ <value>analog_frequency_modulator_fc_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>sensitivity</key>
+ <value>-2.0/fft_len</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(692, 175)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>blocks_multiply_xx</key>
+ <param>
+ <key>id</key>
+ <value>blocks_multiply_xx_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>type</key>
+ <value>complex</value>
+ </param>
+ <param>
+ <key>num_inputs</key>
+ <value>2</value>
+ </param>
+ <param>
+ <key>vlen</key>
+ <value>1</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(885, 223)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>gr_delay</key>
+ <param>
+ <key>id</key>
+ <value>gr_delay_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>type</key>
+ <value>complex</value>
+ </param>
+ <param>
+ <key>delay</key>
+ <value>fft_len+fft_len/4</value>
+ </param>
+ <param>
+ <key>num_ports</key>
+ <value>1</value>
+ </param>
+ <param>
+ <key>vlen</key>
+ <value>1</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(368, 253)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>variable</key>
+ <param>
+ <key>id</key>
+ <value>samp_rate</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>value</key>
+ <value>3200000</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(0, 91)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>import</key>
+ <param>
+ <key>id</key>
+ <value>import_1</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>import</key>
+ <value>from gnuradio.digital.utils import tagged_streams</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(163, 0)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>variable</key>
+ <param>
+ <key>id</key>
+ <value>sync_word</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>value</key>
+ <value>[0, 0, 0, 0, 0, 0, 0, -1.0, 0, 1.0, 0, 1.0, 0, -1.0, 0, 1.0, 0, -1.0, 0, 1.0, 0, -1.0, 0, -1.0, 0, 1.0, 0, 1.0, 0, 1.0, 0, -1.0, 0, 1.0, 0, -1.0, 0, 1.0, 0, -1.0, 0, -1.0, 0, -1.0, 0, 1.0, 0, -1.0, 0, 1.0, 0, 1.0, 0, -1.0, 0, 1.0, 0, -1.0, 0, 0, 0, 0, 0, 0]</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(165, 46)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>variable</key>
+ <param>
+ <key>id</key>
+ <value>header_mod</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>value</key>
+ <value>digital.constellation_bpsk()</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(655, 0)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>variable</key>
+ <param>
+ <key>id</key>
+ <value>payload_mod</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>value</key>
+ <value>digital.constellation_qpsk()</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(813, 0)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>variable</key>
+ <param>
+ <key>id</key>
+ <value>n_sync_symbols</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>value</key>
+ <value>1</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(168, 108)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>gr_throttle</key>
+ <param>
+ <key>id</key>
+ <value>gr_throttle_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>type</key>
+ <value>complex</value>
+ </param>
+ <param>
+ <key>samples_per_second</key>
+ <value>samp_rate</value>
+ </param>
+ <param>
+ <key>vlen</key>
+ <value>1</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(181, 200)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>digital_constellation_decoder_cb</key>
+ <param>
+ <key>id</key>
+ <value>digital_constellation_decoder_cb_0_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>constellation</key>
+ <value>header_mod.base()</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(854, 343)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>digital_ofdm_frame_equalizer_vcvc</key>
+ <param>
+ <key>id</key>
+ <value>digital_ofdm_frame_equalizer_vcvc_0_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>fft_len</key>
+ <value>fft_len</value>
+ </param>
+ <param>
+ <key>equalizer</key>
+ <value>digital.ofdm_equalizer_simpledfe(fft_len, header_mod.base(), occupied_carriers, pilot_carriers, pilot_symbols).base()</value>
+ </param>
+ <param>
+ <key>len_tag_key</key>
+ <value>length_tag_name</value>
+ </param>
+ <param>
+ <key>propagate_channel_state</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(421, 320)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>digital_packet_headerparser_b</key>
+ <param>
+ <key>id</key>
+ <value>digital_packet_headerparser_b_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>header_formatter</key>
+ <value>header_formatter.formatter()</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(651, 466)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>180</value>
+ </param>
+ </block>
+ <block>
+ <key>fft_vxx</key>
+ <param>
+ <key>id</key>
+ <value>fft_vxx_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>type</key>
+ <value>complex</value>
+ </param>
+ <param>
+ <key>fft_size</key>
+ <value>fft_len</value>
+ </param>
+ <param>
+ <key>forward</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>window</key>
+ <value></value>
+ </param>
+ <param>
+ <key>shift</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>nthreads</key>
+ <value>1</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(53, 429)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>180</value>
+ </param>
+ </block>
+ <block>
+ <key>variable</key>
+ <param>
+ <key>id</key>
+ <value>fft_len</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>value</key>
+ <value>64</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(301, -1)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>variable</key>
+ <param>
+ <key>id</key>
+ <value>length_tag_name</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>value</key>
+ <value>"frame_len"</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(367, -1)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>digital_constellation_decoder_cb</key>
+ <param>
+ <key>id</key>
+ <value>digital_constellation_decoder_cb_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>constellation</key>
+ <value>payload_mod.base()</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(718, 635)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>gr_null_sink</key>
+ <param>
+ <key>id</key>
+ <value>gr_null_sink_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>type</key>
+ <value>byte</value>
+ </param>
+ <param>
+ <key>vlen</key>
+ <value>1</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(938, 638)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>digital_ofdm_frame_equalizer_vcvc</key>
+ <param>
+ <key>id</key>
+ <value>digital_ofdm_frame_equalizer_vcvc_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>fft_len</key>
+ <value>fft_len</value>
+ </param>
+ <param>
+ <key>equalizer</key>
+ <value>digital.ofdm_equalizer_simpledfe(fft_len, header_mod.base(), occupied_carriers, pilot_carriers, pilot_symbols, n_sync_symbols).base()</value>
+ </param>
+ <param>
+ <key>len_tag_key</key>
+ <value>length_tag_key</value>
+ </param>
+ <param>
+ <key>propagate_channel_state</key>
+ <value>False</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(265, 612)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>fft_vxx</key>
+ <param>
+ <key>id</key>
+ <value>fft_vxx_0_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>type</key>
+ <value>complex</value>
+ </param>
+ <param>
+ <key>fft_size</key>
+ <value>fft_len</value>
+ </param>
+ <param>
+ <key>forward</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>window</key>
+ <value></value>
+ </param>
+ <param>
+ <key>shift</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>nthreads</key>
+ <value>1</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(57, 605)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>digital_ofdm_serializer_vcc</key>
+ <param>
+ <key>id</key>
+ <value>digital_ofdm_serializer_vcc_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>fft_len</key>
+ <value>fft_len</value>
+ </param>
+ <param>
+ <key>occupied_carriers</key>
+ <value>occupied_carriers</value>
+ </param>
+ <param>
+ <key>len_tag_key</key>
+ <value>length_tag_name</value>
+ </param>
+ <param>
+ <key>packet_len_tag_key</key>
+ <value>""</value>
+ </param>
+ <param>
+ <key>symbols_skipped</key>
+ <value>0</value>
+ </param>
+ <param>
+ <key>input_is_shifted</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(649, 305)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>digital_ofdm_serializer_vcc</key>
+ <param>
+ <key>id</key>
+ <value>digital_ofdm_serializer_vcc_1</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>fft_len</key>
+ <value>fft_len</value>
+ </param>
+ <param>
+ <key>occupied_carriers</key>
+ <value>occupied_carriers</value>
+ </param>
+ <param>
+ <key>len_tag_key</key>
+ <value>length_tag_key</value>
+ </param>
+ <param>
+ <key>packet_len_tag_key</key>
+ <value>""</value>
+ </param>
+ <param>
+ <key>symbols_skipped</key>
+ <value>1</value>
+ </param>
+ <param>
+ <key>input_is_shifted</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(496, 597)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>digital_ofdm_chanest_vcvc</key>
+ <param>
+ <key>id</key>
+ <value>digital_ofdm_chanest_vcvc_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>sync_symbol1</key>
+ <value>sync_word</value>
+ </param>
+ <param>
+ <key>sync_symbol2</key>
+ <value>()</value>
+ </param>
+ <param>
+ <key>n_data_symbols</key>
+ <value>n_sync_symbols</value>
+ </param>
+ <param>
+ <key>eq_noise_red_len</key>
+ <value>0</value>
+ </param>
+ <param>
+ <key>max_carr_offset</key>
+ <value>-1</value>
+ </param>
+ <param>
+ <key>force_one_symbol</key>
+ <value>False</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(52, 305)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>digital_header_payload_demux</key>
+ <param>
+ <key>id</key>
+ <value>digital_header_payload_demux_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>header_len</key>
+ <value>2</value>
+ </param>
+ <param>
+ <key>items_per_symbol</key>
+ <value>fft_len</value>
+ </param>
+ <param>
+ <key>guard_interval</key>
+ <value>fft_len/4</value>
+ </param>
+ <param>
+ <key>length_tag_key</key>
+ <value>length_tag_name</value>
+ </param>
+ <param>
+ <key>trigger_tag_key</key>
+ <value>""</value>
+ </param>
+ <param>
+ <key>output_symbols</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>type</key>
+ <value>complex</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(340, 461)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>180</value>
+ </param>
+ </block>
+ <connection>
+ <source_block_id>fft_vxx_0</source_block_id>
+ <sink_block_id>digital_ofdm_chanest_vcvc_0</sink_block_id>
+ <source_key>0</source_key>
+ <sink_key>0</sink_key>
+ </connection>
+ <connection>
+ <source_block_id>analog_frequency_modulator_fc_0</source_block_id>
+ <sink_block_id>blocks_multiply_xx_0</sink_block_id>
+ <source_key>0</source_key>
+ <sink_key>0</sink_key>
+ </connection>
+ <connection>
+ <source_block_id>digital_ofdm_sync_sc_cfb_0</source_block_id>
+ <sink_block_id>analog_frequency_modulator_fc_0</sink_block_id>
+ <source_key>0</source_key>
+ <sink_key>0</sink_key>
+ </connection>
+ <connection>
+ <source_block_id>analog_noise_source_x_0</source_block_id>
+ <sink_block_id>gr_throttle_0</sink_block_id>
+ <source_key>0</source_key>
+ <sink_key>0</sink_key>
+ </connection>
+ <connection>
+ <source_block_id>gr_throttle_0</source_block_id>
+ <sink_block_id>digital_ofdm_sync_sc_cfb_0</sink_block_id>
+ <source_key>0</source_key>
+ <sink_key>0</sink_key>
+ </connection>
+ <connection>
+ <source_block_id>gr_throttle_0</source_block_id>
+ <sink_block_id>gr_delay_0</sink_block_id>
+ <source_key>0</source_key>
+ <sink_key>0</sink_key>
+ </connection>
+ <connection>
+ <source_block_id>gr_delay_0</source_block_id>
+ <sink_block_id>blocks_multiply_xx_0</sink_block_id>
+ <source_key>0</source_key>
+ <sink_key>1</sink_key>
+ </connection>
+ <connection>
+ <source_block_id>digital_constellation_decoder_cb_0_0</source_block_id>
+ <sink_block_id>digital_packet_headerparser_b_0</sink_block_id>
+ <source_key>0</source_key>
+ <sink_key>0</sink_key>
+ </connection>
+ <connection>
+ <source_block_id>digital_ofdm_serializer_vcc_0</source_block_id>
+ <sink_block_id>digital_constellation_decoder_cb_0_0</sink_block_id>
+ <source_key>0</source_key>
+ <sink_key>0</sink_key>
+ </connection>
+ <connection>
+ <source_block_id>digital_ofdm_sync_sc_cfb_0</source_block_id>
+ <sink_block_id>digital_header_payload_demux_0</sink_block_id>
+ <source_key>1</source_key>
+ <sink_key>1</sink_key>
+ </connection>
+ <connection>
+ <source_block_id>digital_ofdm_chanest_vcvc_0</source_block_id>
+ <sink_block_id>digital_ofdm_frame_equalizer_vcvc_0_0</sink_block_id>
+ <source_key>0</source_key>
+ <sink_key>0</sink_key>
+ </connection>
+ <connection>
+ <source_block_id>digital_ofdm_frame_equalizer_vcvc_0_0</source_block_id>
+ <sink_block_id>digital_ofdm_serializer_vcc_0</sink_block_id>
+ <source_key>0</source_key>
+ <sink_key>0</sink_key>
+ </connection>
+ <connection>
+ <source_block_id>digital_packet_headerparser_b_0</source_block_id>
+ <sink_block_id>digital_header_payload_demux_0</sink_block_id>
+ <source_key>0</source_key>
+ <sink_key>2</sink_key>
+ </connection>
+ <connection>
+ <source_block_id>digital_header_payload_demux_0</source_block_id>
+ <sink_block_id>fft_vxx_0</sink_block_id>
+ <source_key>0</source_key>
+ <sink_key>0</sink_key>
+ </connection>
+ <connection>
+ <source_block_id>digital_header_payload_demux_0</source_block_id>
+ <sink_block_id>fft_vxx_0_0</sink_block_id>
+ <source_key>1</source_key>
+ <sink_key>0</sink_key>
+ </connection>
+ <connection>
+ <source_block_id>blocks_multiply_xx_0</source_block_id>
+ <sink_block_id>digital_header_payload_demux_0</sink_block_id>
+ <source_key>0</source_key>
+ <sink_key>0</sink_key>
+ </connection>
+ <connection>
+ <source_block_id>digital_constellation_decoder_cb_0</source_block_id>
+ <sink_block_id>gr_null_sink_0</sink_block_id>
+ <source_key>0</source_key>
+ <sink_key>0</sink_key>
+ </connection>
+ <connection>
+ <source_block_id>digital_ofdm_frame_equalizer_vcvc_0</source_block_id>
+ <sink_block_id>digital_ofdm_serializer_vcc_1</sink_block_id>
+ <source_key>0</source_key>
+ <sink_key>0</sink_key>
+ </connection>
+ <connection>
+ <source_block_id>digital_ofdm_serializer_vcc_1</source_block_id>
+ <sink_block_id>digital_constellation_decoder_cb_0</sink_block_id>
+ <source_key>0</source_key>
+ <sink_key>0</sink_key>
+ </connection>
+ <connection>
+ <source_block_id>fft_vxx_0_0</source_block_id>
+ <sink_block_id>digital_ofdm_frame_equalizer_vcvc_0</sink_block_id>
+ <source_key>0</source_key>
+ <sink_key>0</sink_key>
+ </connection>
+</flow_graph>
diff --git a/gr-digital/examples/ofdm/tx_ofdm.grc b/gr-digital/examples/ofdm/tx_ofdm.grc
new file mode 100644
index 0000000000..62472ebbce
--- /dev/null
+++ b/gr-digital/examples/ofdm/tx_ofdm.grc
@@ -0,0 +1,1143 @@
+<?xml version='1.0' encoding='ASCII'?>
+<flow_graph>
+ <timestamp>Tue Feb 5 14:47:32 2013</timestamp>
+ <block>
+ <key>options</key>
+ <param>
+ <key>id</key>
+ <value>tx_ofdm</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>title</key>
+ <value>OFDM Tx</value>
+ </param>
+ <param>
+ <key>author</key>
+ <value></value>
+ </param>
+ <param>
+ <key>description</key>
+ <value>Example of an OFDM Transmitter</value>
+ </param>
+ <param>
+ <key>window_size</key>
+ <value>1280, 1024</value>
+ </param>
+ <param>
+ <key>generate_options</key>
+ <value>no_gui</value>
+ </param>
+ <param>
+ <key>category</key>
+ <value>Custom</value>
+ </param>
+ <param>
+ <key>run_options</key>
+ <value>run</value>
+ </param>
+ <param>
+ <key>run</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>max_nouts</key>
+ <value>0</value>
+ </param>
+ <param>
+ <key>realtime_scheduling</key>
+ <value></value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(0, -1)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>import</key>
+ <param>
+ <key>id</key>
+ <value>import_1</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>import</key>
+ <value>from gnuradio.digital.utils import tagged_streams</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(164, 45)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>variable</key>
+ <param>
+ <key>id</key>
+ <value>length_tag_name</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>value</key>
+ <value>"packet_len"</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(399, 0)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>variable</key>
+ <param>
+ <key>id</key>
+ <value>pilot_symbols_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>value</key>
+ <value>((100,),)</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(735, 63)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>variable</key>
+ <param>
+ <key>id</key>
+ <value>occupied_carriers</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>value</key>
+ <value>(range(-26, -21) + range(-20, -7) + range(-6, 0) + range(1, 7) + range(8, 21) + range(22, 27),)</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(377, 63)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>variable</key>
+ <param>
+ <key>id</key>
+ <value>pilot_symbols</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>value</key>
+ <value>((100,),)</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(632, 63)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>variable</key>
+ <param>
+ <key>id</key>
+ <value>pilot_carriers</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>value</key>
+ <value>((0,),)</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(530, 63)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>variable</key>
+ <param>
+ <key>id</key>
+ <value>fft_len</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>value</key>
+ <value>64</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(311, 63)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>variable</key>
+ <param>
+ <key>id</key>
+ <value>header_mod</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>value</key>
+ <value>digital.constellation_bpsk()</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(620, 0)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>variable</key>
+ <param>
+ <key>id</key>
+ <value>payload_mod</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>value</key>
+ <value>digital.constellation_qpsk()</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(783, 0)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>gr_throttle</key>
+ <param>
+ <key>id</key>
+ <value>gr_throttle_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>type</key>
+ <value>byte</value>
+ </param>
+ <param>
+ <key>samples_per_second</key>
+ <value>bit_rate/8</value>
+ </param>
+ <param>
+ <key>vlen</key>
+ <value>1</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(234, 167)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>import</key>
+ <param>
+ <key>id</key>
+ <value>import_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>import</key>
+ <value>import numpy</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(164, 0)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>import</key>
+ <param>
+ <key>id</key>
+ <value>import_0_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>import</key>
+ <value>import random</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(-1, 90)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>variable</key>
+ <param>
+ <key>id</key>
+ <value>sync_word</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>value</key>
+ <value>[0, 0, 0, 0, 0, 0, 0, -1.0, 0, 1.0, 0, 1.0, 0, -1.0, 0, 1.0, 0, -1.0, 0, 1.0, 0, -1.0, 0, -1.0, 0, 1.0, 0, 1.0, 0, 1.0, 0, -1.0, 0, 1.0, 0, -1.0, 0, 1.0, 0, -1.0, 0, -1.0, 0, -1.0, 0, 1.0, 0, -1.0, 0, 1.0, 0, 1.0, 0, -1.0, 0, 1.0, 0, -1.0, 0, 0, 0, 0, 0, 0]</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(95, 90)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>variable</key>
+ <param>
+ <key>id</key>
+ <value>rolloff</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>value</key>
+ <value>0</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(234, 91)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>variable</key>
+ <param>
+ <key>id</key>
+ <value>header_formatter</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>value</key>
+ <value>digital.packet_header_ofdm(occupied_carriers, 1, length_tag_name)</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(849, 63)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>gr_vector_source_x</key>
+ <param>
+ <key>id</key>
+ <value>gr_vector_source_x_1</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>type</key>
+ <value>byte</value>
+ </param>
+ <param>
+ <key>vector</key>
+ <value>range(packet_len)</value>
+ </param>
+ <param>
+ <key>tags</key>
+ <value>tagged_streams.make_lengthtags((packet_len,), (0,), length_tag_name)</value>
+ </param>
+ <param>
+ <key>repeat</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>vlen</key>
+ <value>1</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(-1, 152)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>variable</key>
+ <param>
+ <key>id</key>
+ <value>packet_len</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>value</key>
+ <value>96</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(528, 0)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>digital_packet_headergenerator_bb</key>
+ <param>
+ <key>id</key>
+ <value>digital_packet_headergenerator_bb_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>header_formatter</key>
+ <value>header_formatter.formatter()</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(761, 167)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>variable</key>
+ <param>
+ <key>id</key>
+ <value>bit_rate</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>value</key>
+ <value>3200000</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(311, 0)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>blocks_repack_bits_bb</key>
+ <param>
+ <key>id</key>
+ <value>blocks_repack_bits_bb_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>k</key>
+ <value>8</value>
+ </param>
+ <param>
+ <key>l</key>
+ <value>payload_mod.bits_per_symbol()</value>
+ </param>
+ <param>
+ <key>len_tag_key</key>
+ <value>length_tag_name</value>
+ </param>
+ <param>
+ <key>align_output</key>
+ <value>False</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(516, 228)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>180</value>
+ </param>
+ </block>
+ <block>
+ <key>digital_chunks_to_symbols_xx</key>
+ <param>
+ <key>id</key>
+ <value>digital_chunks_to_symbols_xx_0_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>in_type</key>
+ <value>byte</value>
+ </param>
+ <param>
+ <key>out_type</key>
+ <value>complex</value>
+ </param>
+ <param>
+ <key>symbol_table</key>
+ <value>payload_mod.points()</value>
+ </param>
+ <param>
+ <key>dimension</key>
+ <value>1</value>
+ </param>
+ <param>
+ <key>num_ports</key>
+ <value>1</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(279, 243)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>180</value>
+ </param>
+ </block>
+ <block>
+ <key>digital_chunks_to_symbols_xx</key>
+ <param>
+ <key>id</key>
+ <value>digital_chunks_to_symbols_xx_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>in_type</key>
+ <value>byte</value>
+ </param>
+ <param>
+ <key>out_type</key>
+ <value>complex</value>
+ </param>
+ <param>
+ <key>symbol_table</key>
+ <value>header_mod.points()</value>
+ </param>
+ <param>
+ <key>dimension</key>
+ <value>1</value>
+ </param>
+ <param>
+ <key>num_ports</key>
+ <value>1</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(319, 305)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>180</value>
+ </param>
+ </block>
+ <block>
+ <key>blocks_tagged_stream_mux</key>
+ <param>
+ <key>id</key>
+ <value>blocks_tagged_stream_mux_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>type</key>
+ <value>complex</value>
+ </param>
+ <param>
+ <key>ninputs</key>
+ <value>2</value>
+ </param>
+ <param>
+ <key>lengthtagname</key>
+ <value>length_tag_name</value>
+ </param>
+ <param>
+ <key>vlen</key>
+ <value>1</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(44, 254)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>180</value>
+ </param>
+ </block>
+ <block>
+ <key>digital_ofdm_carrier_allocator_cvc</key>
+ <param>
+ <key>id</key>
+ <value>digital_ofdm_carrier_allocator_cvc_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>fft_len</key>
+ <value>fft_len</value>
+ </param>
+ <param>
+ <key>occupied_carriers</key>
+ <value>occupied_carriers</value>
+ </param>
+ <param>
+ <key>pilot_carriers</key>
+ <value>pilot_carriers</value>
+ </param>
+ <param>
+ <key>pilot_symbols</key>
+ <value>pilot_symbols</value>
+ </param>
+ <param>
+ <key>len_tag_key</key>
+ <value>length_tag_name</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(56, 453)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>gr_vector_source_x</key>
+ <param>
+ <key>id</key>
+ <value>sync_word_source</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>type</key>
+ <value>complex</value>
+ </param>
+ <param>
+ <key>vector</key>
+ <value>numpy.array(sync_word) * numpy.sqrt(2)</value>
+ </param>
+ <param>
+ <key>tags</key>
+ <value>tagged_streams.make_lengthtags((len(sync_word)/fft_len,), (0,), length_tag_name)</value>
+ </param>
+ <param>
+ <key>repeat</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>vlen</key>
+ <value>fft_len</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(56, 356)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>blocks_tagged_stream_mux</key>
+ <param>
+ <key>id</key>
+ <value>blocks_tagged_stream_mux_1</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>type</key>
+ <value>complex</value>
+ </param>
+ <param>
+ <key>ninputs</key>
+ <value>2</value>
+ </param>
+ <param>
+ <key>lengthtagname</key>
+ <value>length_tag_name</value>
+ </param>
+ <param>
+ <key>vlen</key>
+ <value>fft_len</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(374, 382)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>fft_vxx</key>
+ <param>
+ <key>id</key>
+ <value>fft_vxx_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>type</key>
+ <value>complex</value>
+ </param>
+ <param>
+ <key>fft_size</key>
+ <value>fft_len</value>
+ </param>
+ <param>
+ <key>forward</key>
+ <value>False</value>
+ </param>
+ <param>
+ <key>window</key>
+ <value></value>
+ </param>
+ <param>
+ <key>shift</key>
+ <value>False</value>
+ </param>
+ <param>
+ <key>nthreads</key>
+ <value>1</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(765, 498)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>180</value>
+ </param>
+ </block>
+ <block>
+ <key>digital_ofdm_cyclic_prefixer</key>
+ <param>
+ <key>id</key>
+ <value>digital_ofdm_cyclic_prefixer_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>input_size</key>
+ <value>fft_len</value>
+ </param>
+ <param>
+ <key>output_size</key>
+ <value>fft_len+fft_len/4</value>
+ </param>
+ <param>
+ <key>rolloff</key>
+ <value>rolloff</value>
+ </param>
+ <param>
+ <key>tagname</key>
+ <value>length_tag_name</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(488, 505)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>180</value>
+ </param>
+ </block>
+ <block>
+ <key>wxgui_fftsink2</key>
+ <param>
+ <key>id</key>
+ <value>wxgui_fftsink2_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>False</value>
+ </param>
+ <param>
+ <key>type</key>
+ <value>complex</value>
+ </param>
+ <param>
+ <key>title</key>
+ <value>FFT Plot</value>
+ </param>
+ <param>
+ <key>samp_rate</key>
+ <value>1.0</value>
+ </param>
+ <param>
+ <key>baseband_freq</key>
+ <value>0</value>
+ </param>
+ <param>
+ <key>y_per_div</key>
+ <value>10</value>
+ </param>
+ <param>
+ <key>y_divs</key>
+ <value>10</value>
+ </param>
+ <param>
+ <key>ref_level</key>
+ <value>50</value>
+ </param>
+ <param>
+ <key>ref_scale</key>
+ <value>2.0</value>
+ </param>
+ <param>
+ <key>fft_size</key>
+ <value>1024</value>
+ </param>
+ <param>
+ <key>fft_rate</key>
+ <value>15</value>
+ </param>
+ <param>
+ <key>peak_hold</key>
+ <value>False</value>
+ </param>
+ <param>
+ <key>average</key>
+ <value>False</value>
+ </param>
+ <param>
+ <key>avg_alpha</key>
+ <value>0</value>
+ </param>
+ <param>
+ <key>win</key>
+ <value>None</value>
+ </param>
+ <param>
+ <key>win_size</key>
+ <value></value>
+ </param>
+ <param>
+ <key>grid_pos</key>
+ <value></value>
+ </param>
+ <param>
+ <key>notebook</key>
+ <value></value>
+ </param>
+ <param>
+ <key>freqvar</key>
+ <value>None</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(291, 460)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>180</value>
+ </param>
+ </block>
+ <block>
+ <key>gr_null_sink</key>
+ <param>
+ <key>id</key>
+ <value>gr_null_sink_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>type</key>
+ <value>complex</value>
+ </param>
+ <param>
+ <key>vlen</key>
+ <value>1</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(438, 633)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>180</value>
+ </param>
+ </block>
+ <block>
+ <key>digital_crc32_bb</key>
+ <param>
+ <key>id</key>
+ <value>digital_crc32_bb_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>check</key>
+ <value>False</value>
+ </param>
+ <param>
+ <key>lengthtagname</key>
+ <value>length_tag_name</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(472, 159)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>gr_tag_debug</key>
+ <param>
+ <key>id</key>
+ <value>gr_tag_debug_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>type</key>
+ <value>byte</value>
+ </param>
+ <param>
+ <key>name</key>
+ <value>tdb</value>
+ </param>
+ <param>
+ <key>num_inputs</key>
+ <value>1</value>
+ </param>
+ <param>
+ <key>vlen</key>
+ <value>1</value>
+ </param>
+ <param>
+ <key>display</key>
+ <value>False</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(819, 232)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <connection>
+ <source_block_id>gr_vector_source_x_1</source_block_id>
+ <sink_block_id>gr_throttle_0</sink_block_id>
+ <source_key>0</source_key>
+ <sink_key>0</sink_key>
+ </connection>
+ <connection>
+ <source_block_id>gr_throttle_0</source_block_id>
+ <sink_block_id>digital_crc32_bb_0</sink_block_id>
+ <source_key>0</source_key>
+ <sink_key>0</sink_key>
+ </connection>
+ <connection>
+ <source_block_id>digital_crc32_bb_0</source_block_id>
+ <sink_block_id>digital_packet_headergenerator_bb_0</sink_block_id>
+ <source_key>0</source_key>
+ <sink_key>0</sink_key>
+ </connection>
+ <connection>
+ <source_block_id>blocks_tagged_stream_mux_0</source_block_id>
+ <sink_block_id>digital_ofdm_carrier_allocator_cvc_0</sink_block_id>
+ <source_key>0</source_key>
+ <sink_key>0</sink_key>
+ </connection>
+ <connection>
+ <source_block_id>digital_ofdm_carrier_allocator_cvc_0</source_block_id>
+ <sink_block_id>blocks_tagged_stream_mux_1</sink_block_id>
+ <source_key>0</source_key>
+ <sink_key>1</sink_key>
+ </connection>
+ <connection>
+ <source_block_id>sync_word_source</source_block_id>
+ <sink_block_id>blocks_tagged_stream_mux_1</sink_block_id>
+ <source_key>0</source_key>
+ <sink_key>0</sink_key>
+ </connection>
+ <connection>
+ <source_block_id>digital_packet_headergenerator_bb_0</source_block_id>
+ <sink_block_id>digital_chunks_to_symbols_xx_0</sink_block_id>
+ <source_key>0</source_key>
+ <sink_key>0</sink_key>
+ </connection>
+ <connection>
+ <source_block_id>blocks_repack_bits_bb_0</source_block_id>
+ <sink_block_id>digital_chunks_to_symbols_xx_0_0</sink_block_id>
+ <source_key>0</source_key>
+ <sink_key>0</sink_key>
+ </connection>
+ <connection>
+ <source_block_id>digital_chunks_to_symbols_xx_0</source_block_id>
+ <sink_block_id>blocks_tagged_stream_mux_0</sink_block_id>
+ <source_key>0</source_key>
+ <sink_key>0</sink_key>
+ </connection>
+ <connection>
+ <source_block_id>digital_chunks_to_symbols_xx_0_0</source_block_id>
+ <sink_block_id>blocks_tagged_stream_mux_0</sink_block_id>
+ <source_key>0</source_key>
+ <sink_key>1</sink_key>
+ </connection>
+ <connection>
+ <source_block_id>digital_crc32_bb_0</source_block_id>
+ <sink_block_id>blocks_repack_bits_bb_0</sink_block_id>
+ <source_key>0</source_key>
+ <sink_key>0</sink_key>
+ </connection>
+ <connection>
+ <source_block_id>blocks_tagged_stream_mux_1</source_block_id>
+ <sink_block_id>fft_vxx_0</sink_block_id>
+ <source_key>0</source_key>
+ <sink_key>0</sink_key>
+ </connection>
+ <connection>
+ <source_block_id>digital_ofdm_cyclic_prefixer_0</source_block_id>
+ <sink_block_id>wxgui_fftsink2_0</sink_block_id>
+ <source_key>0</source_key>
+ <sink_key>0</sink_key>
+ </connection>
+ <connection>
+ <source_block_id>fft_vxx_0</source_block_id>
+ <sink_block_id>digital_ofdm_cyclic_prefixer_0</sink_block_id>
+ <source_key>0</source_key>
+ <sink_key>0</sink_key>
+ </connection>
+ <connection>
+ <source_block_id>digital_ofdm_cyclic_prefixer_0</source_block_id>
+ <sink_block_id>gr_null_sink_0</sink_block_id>
+ <source_key>0</source_key>
+ <sink_key>0</sink_key>
+ </connection>
+ <connection>
+ <source_block_id>digital_crc32_bb_0</source_block_id>
+ <sink_block_id>gr_tag_debug_0</sink_block_id>
+ <source_key>0</source_key>
+ <sink_key>0</sink_key>
+ </connection>
+</flow_graph>
diff --git a/gr-digital/grc/CMakeLists.txt b/gr-digital/grc/CMakeLists.txt
index bace20847f..9888247ca2 100644
--- a/gr-digital/grc/CMakeLists.txt
+++ b/gr-digital/grc/CMakeLists.txt
@@ -18,4 +18,6 @@
# Boston, MA 02110-1301, USA.
file(GLOB xml_files "*.xml")
-install(FILES ${xml_files} DESTINATION ${GRC_BLOCKS_DIR} COMPONENT "digital_python")
+install(FILES ${xml_files}
+ DESTINATION ${GRC_BLOCKS_DIR} COMPONENT "digital_python"
+)
diff --git a/gr-digital/grc/digital_block_tree.xml b/gr-digital/grc/digital_block_tree.xml
index 36827028e9..26c316bfd8 100644
--- a/gr-digital/grc/digital_block_tree.xml
+++ b/gr-digital/grc/digital_block_tree.xml
@@ -1,7 +1,6 @@
<?xml version="1.0"?>
-
<!--
- Copyright 2011 Free Software Foundation, Inc.
+ Copyright 2011,2012 Free Software Foundation, Inc.
This file is part of GNU Radio
@@ -40,14 +39,20 @@
<block>digital_constellation_receiver_cb</block>
<block>digital_correlate_access_code_bb</block>
<block>digital_costas_loop_cc</block>
+ <block>digital_crc32_bb</block>
<block>digital_descrambler_bb</block>
<block>digital_fll_band_edge_cc</block>
<block>digital_glfsr_source_x</block>
+ <block>digital_header_payload_demux</block>
<block>digital_kurtotic_equalizer_cc</block>
<block>digital_lms_dd_equalizer_cc</block>
<block>digital_map_bb</block>
<block>digital_mpsk_receiver_cc</block>
<block>digital_mpsk_snr_est_cc</block>
+ <block>digital_packet_headergenerator_bb</block>
+ <block>digital_packet_headergenerator_bb_default</block>
+ <block>digital_packet_headerparser_b</block>
+ <block>digital_packet_headerparser_b_default</block>
<block>digital_pfb_clock_sync_xxx</block>
<block>digital_pn_correlator_cc</block>
<block>digital_probe_density_b</block>
@@ -75,13 +80,19 @@
<block>digital_gmsk_demod</block>
</cat>
<cat>
- <name>OFDM</name>
+ <name>OFDM</name>
<block>digital_ofdm_mod</block>
+ <block>digital_ofdm_mod2</block>
<block>digital_ofdm_demod</block>
+ <block>digital_ofdm_carrier_allocator_cvc</block>
+ <block>digital_ofdm_chanest_vcvc</block>
<block>digital_ofdm_cyclic_prefixer</block>
<block>digital_ofdm_frame_acquisition</block>
+ <block>digital_ofdm_frame_equalizer_vcvc</block>
<block>digital_ofdm_insert_preamble</block>
<block>digital_ofdm_sampler</block>
+ <block>digital_ofdm_serializer_vcc</block>
<block>digital_ofdm_sync_pn</block>
+ <block>digital_ofdm_sync_sc_cfb</block>
</cat>
</cat>
diff --git a/gr-digital/grc/digital_crc32_bb.xml b/gr-digital/grc/digital_crc32_bb.xml
new file mode 100644
index 0000000000..d60f08f814
--- /dev/null
+++ b/gr-digital/grc/digital_crc32_bb.xml
@@ -0,0 +1,33 @@
+<block>
+ <name>Stream CRC32</name>
+ <key>digital_crc32_bb</key>
+ <import>from gnuradio import digital</import>
+ <make>digital.crc32_bb($check, $lengthtagname)</make>
+ <param>
+ <name>Mode</name>
+ <key>check</key>
+ <type>enum</type>
+ <option>
+ <name>Generate CRC</name>
+ <key>False</key>
+ </option>
+ <option>
+ <name>Check CRC</name>
+ <key>True</key>
+ </option>
+ </param>
+ <param>
+ <name>Length tag name</name>
+ <key>lengthtagname</key>
+ <value>"packet_len"</value>
+ <type>string</type>
+ </param>
+ <sink>
+ <name>in</name>
+ <type>byte</type>
+ </sink>
+ <source>
+ <name>out</name>
+ <type>byte</type>
+ </source>
+</block>
diff --git a/gr-digital/grc/digital_header_payload_demux.xml b/gr-digital/grc/digital_header_payload_demux.xml
new file mode 100644
index 0000000000..b29d86435b
--- /dev/null
+++ b/gr-digital/grc/digital_header_payload_demux.xml
@@ -0,0 +1,94 @@
+<block>
+ <name>Header payload demux</name>
+ <key>digital_header_payload_demux</key>
+ <import>from gnuradio import digital</import>
+ <make>digital.header_payload_demux($header_len, $items_per_symbol, $guard_interval, $length_tag_key, $trigger_tag_key, $output_symbols, $(type.itemsize))</make>
+ <param>
+ <name>Header Length (Symbols)</name>
+ <key>header_len</key>
+ <type>int</type>
+ </param>
+ <param>
+ <name>Items per symbol</name>
+ <key>items_per_symbol</key>
+ <type>int</type>
+ </param>
+ <param>
+ <name>Guard Interval (items)</name>
+ <key>guard_interval</key>
+ <value>0</value>
+ <type>int</type>
+ </param>
+ <param>
+ <name>Length tag key</name>
+ <key>length_tag_key</key>
+ <value>"frame_len"</value>
+ <type>string</type>
+ </param>
+ <param>
+ <name>Trigger tag key</name>
+ <key>trigger_tag_key</key>
+ <value>""</value>
+ <type>string</type>
+ </param>
+ <param>
+ <name>Output Format</name>
+ <key>output_symbols</key>
+ <type>enum</type>
+ <option>
+ <name>Items</name>
+ <key>False</key>
+ </option>
+ <option>
+ <name>Symbols</name>
+ <key>True</key>
+ </option>
+ </param>
+ <param>
+ <name>IO Type</name>
+ <key>type</key>
+ <type>enum</type>
+ <option>
+ <name>Complex</name>
+ <key>complex</key>
+ <opt>itemsize:gr.sizeof_gr_complex</opt>
+ </option>
+ <option>
+ <name>Float</name>
+ <key>float</key>
+ <opt>itemsize:gr.sizeof_float</opt>
+ </option>
+ <option>
+ <name>Int</name>
+ <key>int</key>
+ <opt>itemsize:gr.sizeof_int</opt>
+ </option>
+ <option>
+ <name>Short</name>
+ <key>short</key>
+ <opt>itemsize:gr.sizeof_short</opt>
+ </option>
+ </param>
+ <sink>
+ <name>in</name>
+ <type>$type</type>
+ </sink>
+ <sink>
+ <name>trigger</name>
+ <type>byte</type>
+ </sink>
+ <sink>
+ <name>header_data</name>
+ <type>message</type>
+ </sink>
+ <source>
+ <name>out_hdr</name>
+ <type>$type</type>
+ <vlen>{True: $items_per_symbol, False: 1}[$output_symbols]</vlen>
+ </source>
+ <source>
+ <name>out_payload</name>
+ <type>$type</type>
+ <vlen>{True: $items_per_symbol, False: 1}[$output_symbols]</vlen>
+ </source>
+</block>
diff --git a/gr-digital/grc/digital_ofdm_carrier_allocator_cvc.xml b/gr-digital/grc/digital_ofdm_carrier_allocator_cvc.xml
new file mode 100644
index 0000000000..826778ff37
--- /dev/null
+++ b/gr-digital/grc/digital_ofdm_carrier_allocator_cvc.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0"?>
+<block>
+ <name>OFDM Carrier Allocator</name>
+ <key>digital_ofdm_carrier_allocator_cvc</key>
+ <import>from gnuradio import digital</import>
+ <make>digital.ofdm_carrier_allocator_cvc($fft_len, $occupied_carriers, $pilot_carriers, $pilot_symbols, $len_tag_key)</make>
+ <param>
+ <name>FFT length</name>
+ <key>fft_len</key>
+ <value>fft_len</value>
+ <type>int</type>
+ </param>
+ <param>
+ <name>Occupied Carriers</name>
+ <key>occupied_carriers</key>
+ <type>raw</type>
+ </param>
+ <param>
+ <name>Pilot Carriers</name>
+ <key>pilot_carriers</key>
+ <value>()</value>
+ <type>raw</type>
+ </param>
+ <param>
+ <name>Pilot Symbols</name>
+ <key>pilot_symbols</key>
+ <value>()</value>
+ <type>raw</type>
+ </param>
+ <param>
+ <name>Length tag key</name>
+ <key>len_tag_key</key>
+ <value>"packet_len"</value>
+ <type>string</type>
+ </param>
+ <sink>
+ <name>in</name>
+ <type>complex</type>
+ </sink>
+ <source>
+ <name>out</name>
+ <type>complex</type>
+ <vlen>$fft_len</vlen>
+ </source>
+</block>
diff --git a/gr-digital/grc/digital_ofdm_chanest_vcvc.xml b/gr-digital/grc/digital_ofdm_chanest_vcvc.xml
new file mode 100644
index 0000000000..e8b1571eb6
--- /dev/null
+++ b/gr-digital/grc/digital_ofdm_chanest_vcvc.xml
@@ -0,0 +1,61 @@
+<?xml version="1.0"?>
+<block>
+ <name>OFDM channel &amp; coarse frequency offset estimation</name>
+ <key>digital_ofdm_chanest_vcvc</key>
+ <import>from gnuradio import digital</import>
+ <make>digital.ofdm_chanest_vcvc($sync_symbol1, $sync_symbol2, $n_data_symbols, $eq_noise_red_len, $max_carr_offset, $force_one_symbol)</make>
+ <param>
+ <name>Synchronisation preamble symbol 1</name>
+ <key>sync_symbol1</key>
+ <type>complex_vector</type>
+ </param>
+ <param>
+ <name>Synchronisation preamble symbol 2</name>
+ <key>sync_symbol2</key>
+ <value>()</value>
+ <type>complex_vector</type>
+ </param>
+ <param>
+ <name>Number of data symbols</name>
+ <key>n_data_symbols</key>
+ <value>1</value>
+ <type>int</type>
+ </param>
+ <param>
+ <name>Channel taps noise reduction length</name>
+ <key>eq_noise_red_len</key>
+ <value>0</value>
+ <type>int</type>
+ </param>
+ <param>
+ <name>Maximum carrier offset</name>
+ <key>max_carr_offset</key>
+ <value>-1</value>
+ <type>int</type>
+ </param>
+ <param>
+ <name>Force One Synchronisation Symbol</name>
+ <key>force_one_symbol</key>
+ <type>enum</type>
+ <option>
+ <name>No</name>
+ <key>False</key>
+ </option>
+ <option>
+ <name>Yes</name>
+ <key>True</key>
+ </option>
+ </param>
+ <check>len($sync_symbol1)</check>
+ <check>len($sync_symbol2) == 0 or len($sync_symbol2) == len($sync_symbol1)</check>
+ <sink>
+ <name>in</name>
+ <type>complex</type>
+ <vlen>len($sync_symbol1)</vlen>
+ </sink>
+ <source>
+ <name>out</name>
+ <type>complex</type>
+ <vlen>len($sync_symbol1)</vlen>
+ </source>
+</block>
diff --git a/gr-digital/grc/digital_ofdm_cyclic_prefixer.xml b/gr-digital/grc/digital_ofdm_cyclic_prefixer.xml
index d5e5d38940..80bf339cbe 100644
--- a/gr-digital/grc/digital_ofdm_cyclic_prefixer.xml
+++ b/gr-digital/grc/digital_ofdm_cyclic_prefixer.xml
@@ -29,17 +29,31 @@
<name>OFDM Cyclic Prefixer</name>
<key>digital_ofdm_cyclic_prefixer</key>
<import>from gnuradio import digital</import>
- <make>digital.ofdm_cyclic_prefixer($input_size, $output_size)</make>
+ <make>digital.ofdm_cyclic_prefixer($input_size, $output_size, $rolloff, $tagname)</make>
<param>
- <name>Input Size</name>
+ <name>FFT Length</name>
<key>input_size</key>
+ <value>fft_len</value>
<type>int</type>
</param>
<param>
- <name>Output Size</name>
+ <name>Output Size (FFT length + CP length)</name>
<key>output_size</key>
+ <value>fft_len+fft_len/4</value>
<type>int</type>
</param>
+ <param>
+ <name>Rolloff</name>
+ <key>rolloff</key>
+ <value>0</value>
+ <type>int</type>
+ </param>
+ <param>
+ <name>Length Tag Key</name>
+ <key>tagname</key>
+ <value>"frame_len"</value>
+ <type>string</type>
+ </param>
<sink>
<name>in</name>
<type>complex</type>
diff --git a/gr-digital/grc/digital_ofdm_frame_equalizer_vcvc.xml b/gr-digital/grc/digital_ofdm_frame_equalizer_vcvc.xml
new file mode 100644
index 0000000000..330b29a2fb
--- /dev/null
+++ b/gr-digital/grc/digital_ofdm_frame_equalizer_vcvc.xml
@@ -0,0 +1,45 @@
+<block>
+ <name>OFDM Frame Equalizer</name>
+ <key>digital_ofdm_frame_equalizer_vcvc</key>
+ <import>from gnuradio import digital</import>
+ <make>digital.ofdm_frame_equalizer_vcvc($equalizer, $len_tag_key, $propagate_channel_state)</make>
+ <param>
+ <name>FFT length</name>
+ <key>fft_len</key>
+ <value>fft_len</value>
+ <type>int</type>
+ </param>
+ <param>
+ <name>Equalizer</name>
+ <key>equalizer</key>
+ <type>raw</type>
+ </param>
+ <param>
+ <name>Length Tag Key</name>
+ <key>len_tag_key</key>
+ <type>string</type>
+ </param>
+ <param>
+ <name>Propagate Channel State</name>
+ <key>propagate_channel_state</key>
+ <type>enum</type>
+ <option>
+ <name>Yes</name>
+ <key>True</key>
+ </option>
+ <option>
+ <name>No</name>
+ <key>False</key>
+ </option>
+ </param>
+ <sink>
+ <name>in</name>
+ <type>complex</type>
+ <vlen>$fft_len</vlen>
+ </sink>
+ <source>
+ <name>out</name>
+ <type>complex</type>
+ <vlen>$fft_len</vlen>
+ </source>
+</block>
diff --git a/gr-digital/grc/digital_ofdm_mod2.xml b/gr-digital/grc/digital_ofdm_mod2.xml
new file mode 100644
index 0000000000..7de9ff7865
--- /dev/null
+++ b/gr-digital/grc/digital_ofdm_mod2.xml
@@ -0,0 +1,65 @@
+<block>
+ <name>OFDM Mod 2</name>
+ <key>digital_ofdm_mod2</key>
+ <category>OFDM</category>
+ <import>from gnuradio import digital</import>
+ <make>digital.ofdm_mod2(fft_len=$fft_len,
+ cp_len=$cp_len,
+ length_tag_name=$length_tag_name,
+ occupied_carriers=$occupied_carriers,
+ pilot_carriers=$pilot_carriers,
+ pilot_symbols=$pilot_symbols,
+ sync_sequence=$sync_sequence,
+ )
+ </make>
+ <param>
+ <name>Cyclic Prefix Length</name>
+ <key>cp_len</key>
+ <value>16</value>
+ <type>int</type>
+ </param>
+ <param>
+ <name>FFT Length</name>
+ <key>fft_len</key>
+ <value>64</value>
+ <type>int</type>
+ </param>
+ <param>
+ <name>Length Tag Name</name>
+ <key>length_tag_name</key>
+ <value>length</value>
+ <type>string</type>
+ </param>
+ <param>
+ <name>Occupied Carriers</name>
+ <key>occupied_carriers</key>
+ <value>(range(1, 27) + range(38, 64),)</value>
+ <type>raw</type>
+ </param>
+ <param>
+ <name>Pilot Carriers</name>
+ <key>pilot_carriers</key>
+ <value>((0,),)</value>
+ <type>raw</type>
+ </param>
+ <param>
+ <name>Pilot Symbols</name>
+ <key>pilot_symbols</key>
+ <value>((100,),)</value>
+ <type>raw</type>
+ </param>
+ <param>
+ <name>Synchronization Sequence</name>
+ <key>sync_sequence</key>
+ <value>None</value>
+ <type>raw</type>
+ </param>
+ <sink>
+ <name>in</name>
+ <type>byte</type>
+ </sink>
+ <source>
+ <name>out</name>
+ <type>complex</type>
+ </source>
+</block>
diff --git a/gr-digital/grc/digital_ofdm_serializer_vcc.xml b/gr-digital/grc/digital_ofdm_serializer_vcc.xml
new file mode 100644
index 0000000000..c7596bbb0d
--- /dev/null
+++ b/gr-digital/grc/digital_ofdm_serializer_vcc.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0"?>
+<block>
+ <name>OFDM Serializer</name>
+ <key>digital_ofdm_serializer_vcc</key>
+ <import>from gnuradio import digital</import>
+ <make>digital.ofdm_serializer_vcc($fft_len, $occupied_carriers, $len_tag_key, $packet_len_tag_key, $symbols_skipped, $input_is_shifted)</make>
+ <param>
+ <name>FFT length</name>
+ <key>fft_len</key>
+ <value>fft_len</value>
+ <type>int</type>
+ </param>
+ <param>
+ <name>Occupied Carriers</name>
+ <key>occupied_carriers</key>
+ <type>raw</type>
+ </param>
+ <param>
+ <name>Length Tag Key</name>
+ <key>len_tag_key</key>
+ <type>string</type>
+ </param>
+ <param>
+ <name>Packet Length Tag Key</name>
+ <key>packet_len_tag_key</key>
+ <value>""</value>
+ <type>string</type>
+ </param>
+ <param>
+ <name>Symbols skipped</name>
+ <key>symbols_skipped</key>
+ <value>0</value>
+ <type>int</type>
+ </param>
+ <param>
+ <name>Input is shifted</name>
+ <key>input_is_shifted</key>
+ <value>True</value>
+ <type>bool</type>
+ </param>
+ <sink>
+ <name>in</name>
+ <type>complex</type>
+ <vlen>$fft_len</vlen>
+ </sink>
+ <source>
+ <name>out</name>
+ <type>complex</type>
+ </source>
+</block>
diff --git a/gr-digital/grc/digital_ofdm_sync_sc_cfb.xml b/gr-digital/grc/digital_ofdm_sync_sc_cfb.xml
new file mode 100644
index 0000000000..7865d248d5
--- /dev/null
+++ b/gr-digital/grc/digital_ofdm_sync_sc_cfb.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0"?>
+<block>
+ <name>Schmidl &amp; Cox OFDM synchronisation</name>
+ <key>digital_ofdm_sync_sc_cfb</key>
+ <import>from gnuradio import digital</import>
+ <make>digital.ofdm_sync_sc_cfb($fft_len, $cp_len)</make>
+ <param>
+ <name>FFT length</name>
+ <key>fft_len</key>
+ <type>int</type>
+ </param>
+ <param>
+ <name>Cyclic Prefix length</name>
+ <key>cp_len</key>
+ <type>int</type>
+ </param>
+ <sink>
+ <name>in</name>
+ <type>complex</type>
+ </sink>
+ <source>
+ <name>freq_offset</name>
+ <type>float</type>
+ </source>
+ <source>
+ <name>detect</name>
+ <type>byte</type>
+ </source>
+</block>
diff --git a/gr-digital/grc/digital_packet_headergenerator_bb.xml b/gr-digital/grc/digital_packet_headergenerator_bb.xml
new file mode 100644
index 0000000000..a0ec14ae80
--- /dev/null
+++ b/gr-digital/grc/digital_packet_headergenerator_bb.xml
@@ -0,0 +1,19 @@
+<block>
+ <name>Packet Header Generator</name>
+ <key>digital_packet_headergenerator_bb</key>
+ <import>from gnuradio import digital</import>
+ <make>digital.packet_headergenerator_bb($header_formatter)</make>
+ <param>
+ <name>Formatter Object</name>
+ <key>header_formatter</key>
+ <type>raw</type>
+ </param>
+ <sink>
+ <name>in</name>
+ <type>byte</type>
+ </sink>
+ <source>
+ <name>out</name>
+ <type>byte</type>
+ </source>
+</block>
diff --git a/gr-digital/grc/digital_packet_headergenerator_bb_default.xml b/gr-digital/grc/digital_packet_headergenerator_bb_default.xml
new file mode 100644
index 0000000000..645b4cd250
--- /dev/null
+++ b/gr-digital/grc/digital_packet_headergenerator_bb_default.xml
@@ -0,0 +1,26 @@
+<block>
+ <name>Packet Header Generator</name>
+ <key>digital_packet_headergenerator_bb_default</key>
+ <import>from gnuradio import digital</import>
+ <make>digital.packet_headergenerator_bb($header_len, $len_tag_key)</make>
+ <param>
+ <name>Header Length</name>
+ <key>header_len</key>
+ <type>int</type>
+ </param>
+ <param>
+ <name>Length Tag Name</name>
+ <key>len_tag_key</key>
+ <value>"packet_len"</value>
+ <type>string</type>
+ </param>
+ <sink>
+ <name>in</name>
+ <type>byte</type>
+ </sink>
+ <source>
+ <name>out</name>
+ <type>byte</type>
+ </source>
+</block>
+
diff --git a/gr-digital/grc/digital_packet_headerparser_b.xml b/gr-digital/grc/digital_packet_headerparser_b.xml
new file mode 100644
index 0000000000..bab6bd22ed
--- /dev/null
+++ b/gr-digital/grc/digital_packet_headerparser_b.xml
@@ -0,0 +1,19 @@
+<block>
+ <name>Packet Header Parser</name>
+ <key>digital_packet_headerparser_b</key>
+ <import>from gnuradio import digital</import>
+ <make>digital.packet_headerparser_b($header_formatter)</make>
+ <param>
+ <name>Formatter Object</name>
+ <key>header_formatter</key>
+ <type>raw</type>
+ </param>
+ <sink>
+ <name>in</name>
+ <type>byte</type>
+ </sink>
+ <source>
+ <name>header_data</name>
+ <type>message</type>
+ </source>
+</block>
diff --git a/gr-digital/grc/digital_packet_headerparser_b_default.xml b/gr-digital/grc/digital_packet_headerparser_b_default.xml
new file mode 100644
index 0000000000..415f4839f4
--- /dev/null
+++ b/gr-digital/grc/digital_packet_headerparser_b_default.xml
@@ -0,0 +1,26 @@
+<block>
+ <name>Packet Header Parser (Default)</name>
+ <key>digital_packet_headerparser_b_default</key>
+ <import>from gnuradio import digital</import>
+ <make>digital.packet_headerparser_b($header_len, $len_tag_key)</make>
+ <param>
+ <name>Header Length</name>
+ <key>header_len</key>
+ <type>int</type>
+ </param>
+ <param>
+ <name>Length Tag Name</name>
+ <key>len_tag_key</key>
+ <value>"packet_len"</value>
+ <type>string</type>
+ </param>
+ <sink>
+ <name>in</name>
+ <type>byte</type>
+ </sink>
+ <source>
+ <name>out</name>
+ <type>message</type>
+ </source>
+</block>
+
diff --git a/gr-digital/include/CMakeLists.txt b/gr-digital/include/CMakeLists.txt
index ad5baec87e..06300cc27b 100644
--- a/gr-digital/include/CMakeLists.txt
+++ b/gr-digital/include/CMakeLists.txt
@@ -123,6 +123,13 @@ install(FILES
digital_scrambler_bb.h
digital_simple_framer.h
digital_simple_framer_sync.h
+ digital_ofdm_sync_sc_cfb.h
+ digital_ofdm_chanest_vcvc.h
+ digital_crc32_bb.h
+ digital_ofdm_carrier_allocator_cvc.h
+ digital_ofdm_equalizer_base.h
+ digital_ofdm_equalizer_static.h
+ digital_ofdm_equalizer_simpledfe.h
digital_simple_correlator.h
DESTINATION ${GR_INCLUDE_DIR}/gnuradio
COMPONENT "digital_devel"
diff --git a/gr-digital/include/digital/CMakeLists.txt b/gr-digital/include/digital/CMakeLists.txt
new file mode 100644
index 0000000000..1042517294
--- /dev/null
+++ b/gr-digital/include/digital/CMakeLists.txt
@@ -0,0 +1,40 @@
+# Copyright 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.
+
+########################################################################
+# generate helper scripts to expand templated files
+########################################################################
+include(GrPython)
+
+########################################################################
+# Install header files
+########################################################################
+install(FILES
+ api.h
+ ofdm_frame_equalizer_vcvc.h
+ ofdm_serializer_vcc.h
+ packet_header_default.h
+ packet_header_ofdm.h
+ packet_headergenerator_bb.h
+ packet_headerparser_b.h
+ header_payload_demux.h
+ DESTINATION ${GR_INCLUDE_DIR}/gnuradio/digital
+ COMPONENT "digital_devel"
+)
+
diff --git a/gr-digital/include/digital/api.h b/gr-digital/include/digital/api.h
new file mode 100644
index 0000000000..0912f7e0d4
--- /dev/null
+++ b/gr-digital/include/digital/api.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright 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_DIGITAL_API_H
+#define INCLUDED_DIGITAL_API_H
+
+#include <gruel/attributes.h>
+
+#ifdef gnuradio_digital_EXPORTS
+# define DIGITAL_API __GR_ATTR_EXPORT
+#else
+# define DIGITAL_API __GR_ATTR_IMPORT
+#endif
+
+#endif /* INCLUDED_DIGITAL_API_H */
diff --git a/gr-digital/include/digital/header_payload_demux.h b/gr-digital/include/digital/header_payload_demux.h
new file mode 100644
index 0000000000..014e0304a2
--- /dev/null
+++ b/gr-digital/include/digital/header_payload_demux.h
@@ -0,0 +1,90 @@
+/* -*- c++ -*- */
+/* Copyright 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_DIGITAL_HEADER_PAYLOAD_DEMUX_H
+#define INCLUDED_DIGITAL_HEADER_PAYLOAD_DEMUX_H
+
+#include <digital/api.h>
+#include <gr_block.h>
+
+namespace gr {
+ namespace digital {
+
+ /*!
+ * \brief Header/Payload demuxer.
+ * \ingroup digital
+ *
+ * This block is designed to handle packets from a bursty transmission.
+ * Input 0 takes a continuous transmission of samples.
+ * If used, input 1 is a trigger signal. In this case, a 1 on input 1
+ * is a trigger. Otherwise, a tag with the key specified in \p trigger_tag_key
+ * is used as a trigger (its value is irrelevant).
+ *
+ * Until a trigger signal is detected, all samples are dropped onto the floor.
+ * Once a trigger is detected, a total of \p header_len items are copied to output 0.
+ * The block then stalls until it receives a message on the message port
+ * \p header_data. The message must be a PMT dictionary; all key/value pairs are
+ * copied as tags to the first item of the payload (which is assumed to be the
+ * first item after the header).
+ * The value corresponding to the key specified in \p length_tag_key is read
+ * and taken as the payload length. The payload, together with the header data
+ * as tags, is then copied to output 1.
+ *
+ * If specified, \p guard_interval items are discarded before every symbol.
+ * This is useful for demuxing bursts of OFDM signals.
+ *
+ * Any tags on the input stream are copied to the corresponding output *if* they're
+ * on an item that is propagated. Note that a tag on the header items is copied to the
+ * header stream; that means the header-parsing block must handle these tags if they
+ * should go on the payload.
+ * A special case are tags on items that make up the guard interval. These are copied
+ * to the first item of the following symbol.
+ */
+ class DIGITAL_API header_payload_demux : virtual public gr_block
+ {
+ public:
+ typedef boost::shared_ptr<header_payload_demux> sptr;
+
+ /*!
+ * \param header_len Number of symbols per header
+ * \param items_per_symbol Number of items per symbol
+ * \param guard_interval Number of items between two consecutive symbols
+ * \param length_tag_key Key of the frame length tag
+ * \param trigger_tag_key Key of the trigger tag
+ * \param output_symbols Output symbols (true) or items (false)?
+ * \param itemsize Item size (bytes per item)
+ */
+ static sptr make(
+ int header_len,
+ int items_per_symbol,
+ int guard_interval=0,
+ const std::string &length_tag_key="frame_len",
+ const std::string &trigger_tag_key="",
+ bool output_symbols=false,
+ size_t itemsize=sizeof(gr_complex)
+ );
+ };
+
+ } // namespace digital
+} // namespace gr
+
+#endif /* INCLUDED_DIGITAL_HEADER_PAYLOAD_DEMUX_H */
+
diff --git a/gr-digital/include/digital/ofdm_frame_equalizer_vcvc.h b/gr-digital/include/digital/ofdm_frame_equalizer_vcvc.h
new file mode 100644
index 0000000000..d5d526ddc3
--- /dev/null
+++ b/gr-digital/include/digital/ofdm_frame_equalizer_vcvc.h
@@ -0,0 +1,63 @@
+/* -*- c++ -*- */
+/* Copyright 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_OFDM_FRAME_EQUALIZER_VCVC_H
+#define INCLUDED_OFDM_FRAME_EQUALIZER_VCVC_H
+
+#include <digital_ofdm_equalizer_base.h>
+#include <digital/api.h>
+#include <gr_tagged_stream_block.h>
+
+namespace gr {
+ namespace digital {
+
+ /*!
+ * \brief OFDM frame equalizer
+ * \ingroup ofdm
+ *
+ * Performs equalization in one or two dimensions on a tagged OFDM frame.
+ * Input: a tagged series of OFDM symbols.
+ * Output: The same as the input, but equalized.
+ */
+ class DIGITAL_API ofdm_frame_equalizer_vcvc : virtual public gr_tagged_stream_block
+ {
+ public:
+ typedef boost::shared_ptr<ofdm_frame_equalizer_vcvc> sptr;
+
+ /*
+ * \param equalizer The equalizer object that will do the actual work
+ * \param len_tag_key Length tag key
+ * \param propagate_channel_state If true, the channel state after the last symbol
+ * will be added to the first symbol as a tag
+ */
+ static sptr make(
+ digital_ofdm_equalizer_base_sptr equalizer,
+ const std::string &len_tag_key = "frame_len",
+ bool propagate_channel_state=false
+ );
+ };
+
+ } // namespace digital
+} // namespace gr
+
+#endif /* INCLUDED_OFDM_FRAME_EQUALIZER_VCVC_H */
+
diff --git a/gr-digital/include/digital/ofdm_serializer_vcc.h b/gr-digital/include/digital/ofdm_serializer_vcc.h
new file mode 100644
index 0000000000..3893d6674e
--- /dev/null
+++ b/gr-digital/include/digital/ofdm_serializer_vcc.h
@@ -0,0 +1,91 @@
+/* -*- c++ -*- */
+/* Copyright 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_DIGITAL_OFDM_SERIALIZER_VCC_H
+#define INCLUDED_DIGITAL_OFDM_SERIALIZER_VCC_H
+
+#include <digital/api.h>
+#include <gr_tagged_stream_block.h>
+#include <digital_ofdm_carrier_allocator_cvc.h>
+
+namespace gr {
+ namespace digital {
+
+ /*!
+ * \brief Serializes complex modulations symbols from OFDM sub-carriers
+ * \ingroup ofdm_blk
+ *
+ * This is the inverse block to the carrier_allocator_cvc. It outputs the
+ * complex data symbols as a tagged stream, discarding the pilot symbols.
+ *
+ * If given, two different tags are parsed: The first key (\p len_tag_key)
+ * specifies the number of OFDM symbols in the frame at the input. The
+ * second key (\p packet_len_tag_key) specifies the number of complex symbols
+ * that are coded into this frame. If given, this second key is then used
+ * at the output, otherwise, \p len_tag_key is used.
+ * If both are given, the packet length specifies the maximum number of
+ * output items, and the frame length specifies the exact number of
+ * consumed input items.
+ *
+ * Input: Complex vectors of length \p fft_len
+ * Output: Complex scalars, in the same order as specified in occupied_carriers.
+ */
+ class DIGITAL_API ofdm_serializer_vcc : virtual public gr_tagged_stream_block
+ {
+ public:
+ typedef boost::shared_ptr<ofdm_serializer_vcc> sptr;
+
+ /*!
+ * \param fft_len FFT length
+ * \param occupied_carriers See ofdm_carrier_allocator_cvc.
+ * \param len_tag_key The key of the tag identifying the length of the input frame in OFDM symbols.
+ * \param packet_len_tag_key The key of the tag identifying the number of complex symbols in this packet.
+ * \param symbols_skipped If the first symbol is not allocated as in \p occupied_carriers[0], set this
+ * \param input_is_shifted If the input has the DC carrier on index 0 (i.e. it is not FFT shifted), set this to false
+ */
+ static sptr make(
+ int fft_len,
+ const std::vector<std::vector<int> > &occupied_carriers,
+ const std::string &len_tag_key="frame_len",
+ const std::string &packet_len_tag_key="",
+ int symbols_skipped=0,
+ bool input_is_shifted=true
+ );
+
+ /*!
+ * \param allocator The carrier allocator block of which this shall be the inverse
+ * \param packet_len_tag_key The key of the tag identifying the number of complex symbols in this packet.
+ * \param symbols_skipped If the first symbol is not allocated as in \p occupied_carriers[0], set this
+ * \param input_is_shifted If the input has the DC carrier on index 0 (i.e. it is not FFT shifted), set this to false
+ */
+ static sptr make(
+ const digital_ofdm_carrier_allocator_cvc_sptr &allocator,
+ const std::string &packet_len_tag_key="",
+ int symbols_skipped=0,
+ bool input_is_shifted=true
+ );
+ };
+
+ } // namespace digital
+} // namespace gr
+
+#endif /* INCLUDED_DIGITAL_OFDM_SERIALIZER_VCC_H */
+
diff --git a/gr-digital/include/digital/packet_header_default.h b/gr-digital/include/digital/packet_header_default.h
new file mode 100644
index 0000000000..a4158e728c
--- /dev/null
+++ b/gr-digital/include/digital/packet_header_default.h
@@ -0,0 +1,101 @@
+/* -*- c++ -*- */
+/* Copyright 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_DIGITAL_PACKET_HEADER_DEFAULT_H
+#define INCLUDED_DIGITAL_PACKET_HEADER_DEFAULT_H
+
+#include <gr_tags.h>
+#include <digital/api.h>
+#include <boost/enable_shared_from_this.hpp>
+
+namespace gr {
+ namespace digital {
+
+ /*!
+ * \brief <+description of block+>
+ * \ingroup digital
+ *
+ */
+ class DIGITAL_API packet_header_default : public boost::enable_shared_from_this<gr::digital::packet_header_default>
+ {
+ public:
+ typedef boost::shared_ptr<packet_header_default> sptr;
+
+ packet_header_default(
+ long header_len,
+ const std::string &len_tag_key="packet_len",
+ const std::string &num_tag_key="packet_num",
+ int bits_per_byte=1);
+ ~packet_header_default();
+
+ sptr base() { return shared_from_this(); };
+ sptr formatter() { return shared_from_this(); };
+
+ void set_header_num(unsigned header_num) { d_header_number = header_num; };
+ long header_len() { return d_header_len; };
+ pmt::pmt_t len_tag_key() { return d_len_tag_key; };
+
+ /* \brief Encodes the header information in the given tags into bits and places them into \p out
+ *
+ * Uses the following header format:
+ * Bits 0-11: The packet length (what was stored in the tag with key \p len_tag_key)
+ * Bits 12-27: The header number (counts up everytime this function is called)
+ * Bit 28: Even parity bit
+ * All other bits: Are set to zero
+ *
+ * If the header length is smaller than 29, bits are simply left out. For this
+ * reason, they always start with the LSB.
+ */
+ bool header_formatter(
+ long packet_len,
+ unsigned char *out,
+ const std::vector<gr_tag_t> &tags=std::vector<gr_tag_t>()
+ );
+
+ /* \brief Inverse function to header_formatter().
+ *
+ * Reads the bit stream in \in and writes a corresponding tag into \p tags.
+ *
+ */
+ bool header_parser(
+ const unsigned char *header,
+ std::vector<gr_tag_t> &tags);
+
+ static sptr make(
+ long header_len,
+ const std::string &len_tag_key="packet_len",
+ const std::string &num_tag_key="packet_num",
+ int bits_per_byte=1);
+
+ protected:
+ long d_header_len;
+ pmt::pmt_t d_len_tag_key;
+ pmt::pmt_t d_num_tag_key;
+ int d_bits_per_byte;
+ unsigned d_header_number;
+ unsigned d_mask;
+ };
+
+ } // namespace digital
+} // namespace gr
+
+#endif /* INCLUDED_DIGITAL_PACKET_HEADER_DEFAULT_H */
+
diff --git a/gr-digital/include/digital/packet_header_ofdm.h b/gr-digital/include/digital/packet_header_ofdm.h
new file mode 100644
index 0000000000..6c3453ed1d
--- /dev/null
+++ b/gr-digital/include/digital/packet_header_ofdm.h
@@ -0,0 +1,83 @@
+/* -*- c++ -*- */
+/* Copyright 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_DIGITAL_PACKET_HEADER_OFDM_H
+#define INCLUDED_DIGITAL_PACKET_HEADER_OFDM_H
+
+#include <vector>
+#include <digital/api.h>
+#include <digital/packet_header_default.h>
+
+namespace gr {
+ namespace digital {
+
+ /*!
+ * \brief Header utility for OFDM signals.
+ * \ingroup ofdm_blk
+ *
+ */
+ class DIGITAL_API packet_header_ofdm : public packet_header_default
+ {
+ public:
+ typedef boost::shared_ptr<packet_header_ofdm> sptr;
+
+ packet_header_ofdm(
+ const std::vector<std::vector<int> > &occupied_carriers,
+ int n_syms,
+ const std::string &len_tag_key="packet_len",
+ const std::string &frame_len_tag_key="frame_len",
+ const std::string &num_tag_key="packet_num",
+ int bits_per_sym=1);
+ ~packet_header_ofdm();
+
+ /* \brief Inverse function to header_formatter().
+ *
+ * Does the same as packet_header_default::header_parser(), but
+ * adds another tag that stores the number of OFDM symbols in the
+ * packet.
+ * Note that there is usually no linear connection between the number
+ * of OFDM symbols and the packet length, because, a packet might
+ * finish mid-OFDM-symbol.
+ */
+ bool header_parser(
+ const unsigned char *header,
+ std::vector<gr_tag_t> &tags);
+
+ static sptr make(
+ const std::vector<std::vector<int> > &occupied_carriers,
+ int n_syms,
+ const std::string &len_tag_key="packet_len",
+ const std::string &frame_len_tag_key="frame_len",
+ const std::string &num_tag_key="packet_num",
+ int bits_per_sym=1);
+
+
+ protected:
+ pmt::pmt_t d_frame_len_tag_key;
+ const std::vector<std::vector<int> > d_occupied_carriers; //! Which carriers/symbols carry data
+ int d_syms_per_set; //! Helper variable: Total number of elements in d_occupied_carriers
+ };
+
+ } // namespace digital
+} // namespace gr
+
+#endif /* INCLUDED_DIGITAL_PACKET_HEADER_OFDM_H */
+
diff --git a/gr-digital/include/digital/packet_headergenerator_bb.h b/gr-digital/include/digital/packet_headergenerator_bb.h
new file mode 100644
index 0000000000..8d92bf84ed
--- /dev/null
+++ b/gr-digital/include/digital/packet_headergenerator_bb.h
@@ -0,0 +1,57 @@
+/* -*- c++ -*- */
+/* Copyright 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_PACKET_HEADERGENERATOR_BB_H
+#define INCLUDED_PACKET_HEADERGENERATOR_BB_H
+
+#include <digital/api.h>
+#include <gr_tagged_stream_block.h>
+#include <digital/packet_header_default.h>
+
+namespace gr {
+ namespace digital {
+
+ /*!
+ * \brief Generates a header for a tagged, streamed packet.
+ * \ingroup digital
+ *
+ * Input: A tagged stream. The first element must have a tag with the key
+ * specified in len_tag_key, which hold the exact number of elements
+ * in the PDU.
+ * Output: An tagged stream of length header_len. The output is determined
+ * by a header formatter.
+ */
+ class DIGITAL_API packet_headergenerator_bb : virtual public gr_tagged_stream_block
+ {
+ public:
+ typedef boost::shared_ptr<packet_headergenerator_bb> sptr;
+
+ static sptr make(const packet_header_default::sptr &header_formatter);
+ static sptr make(
+ long header_len,
+ const std::string &len_tag_key = "packet_len");
+ };
+
+ } // namespace digital
+} // namespace gr
+
+#endif /* INCLUDED_PACKET_HEADERGENERATOR_BB_H */
+
diff --git a/gr-digital/include/digital/packet_headerparser_b.h b/gr-digital/include/digital/packet_headerparser_b.h
new file mode 100644
index 0000000000..a3db069cbd
--- /dev/null
+++ b/gr-digital/include/digital/packet_headerparser_b.h
@@ -0,0 +1,65 @@
+/* -*- c++ -*- */
+/* Copyright 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_DIGITAL_PACKET_HEADERPARSER_B_H
+#define INCLUDED_DIGITAL_PACKET_HEADERPARSER_B_H
+
+#include <digital/api.h>
+#include <gr_sync_block.h>
+#include <digital/packet_header_default.h>
+
+namespace gr {
+ namespace digital {
+
+ /*!
+ * \brief Post header metadata as a PMT
+ * \ingroup digital
+ *
+ * In a sense, this is the inverse block to packet_headergenerator_bb.
+ * The difference is, the parsed header is not output as a stream,
+ * but as a message.
+ *
+ * If only a header length is given, this block uses the default header
+ * format.
+ */
+ class DIGITAL_API packet_headerparser_b : virtual public gr_sync_block
+ {
+ public:
+ typedef boost::shared_ptr<packet_headerparser_b> sptr;
+
+ /*!
+ * \param header_formatter Header object. This should be the same as used for
+ * packet_headergenerator_bb.
+ */
+ static sptr make(const gr::digital::packet_header_default::sptr &header_formatter);
+
+ /*!
+ * \param header_len Number of bytes per header
+ * \param len_tag_key Length Tag Key
+ */
+ static sptr make(long header_len, const std::string &len_tag_key);
+ };
+
+ } // namespace digital
+} // namespace gr
+
+#endif /* INCLUDED_DIGITAL_PACKET_HEADERPARSER_B_H */
+
diff --git a/gr-digital/include/digital_constellation.h b/gr-digital/include/digital_constellation.h
index 76cd30b25f..b9c27bbc44 100644
--- a/gr-digital/include/digital_constellation.h
+++ b/gr-digital/include/digital_constellation.h
@@ -276,6 +276,80 @@ class DIGITAL_API digital_constellation_rect : public digital_constellation_sect
};
+/************************************************************/
+/* digital_constellation_expl_rect */
+/************************************************************/
+
+/*!
+ * \brief Rectangular digital constellation
+ * \ingroup digital
+ *
+ * Only implemented for 1-(complex)dimensional constellation.
+ *
+ * Constellation space is divided into rectangular sectors. Each
+ * sector is associated with the nearest constellation point.
+ *
+ * This class is different from constellation_rect in that the mapping
+ * from sector to constellation point is explicitly passed into the
+ * constructor as sector_values. Usually we do not need this, since
+ * we want each sector to be automatically mapped to the closest
+ * constellation point, however sometimes it's nice to have the
+ * flexibility.
+ */
+
+class digital_constellation_expl_rect;
+typedef boost::shared_ptr<digital_constellation_expl_rect> digital_constellation_expl_rect_sptr;
+
+// public constructor
+DIGITAL_API digital_constellation_expl_rect_sptr
+digital_make_constellation_expl_rect (
+ std::vector<gr_complex> constellation,
+ std::vector<unsigned int> pre_diff_code,
+ unsigned int rotational_symmetry,
+ unsigned int real_sectors,
+ unsigned int imag_sectors,
+ float width_real_sectors,
+ float width_imag_sectors,
+ std::vector<unsigned int> sector_values
+);
+
+class DIGITAL_API digital_constellation_expl_rect : public digital_constellation_rect
+{
+ public:
+
+ digital_constellation_expl_rect (
+ std::vector<gr_complex> constellation,
+ std::vector<unsigned int> pre_diff_code,
+ unsigned int rotational_symmetry,
+ unsigned int real_sectors,
+ unsigned int imag_sectors,
+ float width_real_sectors,
+ float width_imag_sectors,
+ std::vector<unsigned int> sector_values
+ );
+
+ protected:
+ unsigned int calc_sector_value (unsigned int sector) {
+ return d_sector_values[sector];
+ }
+
+ private:
+ std::vector<unsigned int> d_sector_values;
+
+ friend DIGITAL_API digital_constellation_expl_rect_sptr
+ digital_make_constellation_expl_rect (
+ std::vector<gr_complex> constellation,
+ std::vector<unsigned int> pre_diff_code,
+ unsigned int rotational_symmetry,
+ unsigned int real_sectors,
+ unsigned int imag_sectors,
+ float width_real_sectors,
+ float width_imag_sectors,
+ std::vector<unsigned int> sector_values
+ );
+
+};
+
/************************************************************/
/* digital_constellation_psk */
diff --git a/gr-digital/include/digital_crc32_bb.h b/gr-digital/include/digital_crc32_bb.h
new file mode 100644
index 0000000000..1f4771e861
--- /dev/null
+++ b/gr-digital/include/digital_crc32_bb.h
@@ -0,0 +1,67 @@
+/* -*- c++ -*- */
+/* Copyright 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_DIGITAL_CRC32_BB_H
+#define INCLUDED_DIGITAL_CRC32_BB_H
+
+#include <digital_api.h>
+#include <gr_tagged_stream_block.h>
+
+class digital_crc32_bb;
+
+typedef boost::shared_ptr<digital_crc32_bb> digital_crc32_bb_sptr;
+
+DIGITAL_API digital_crc32_bb_sptr digital_make_crc32_bb (bool check=false, const std::string& lengthtagname="packet_len");
+
+/*!
+ * \brief Byte-stream CRC block
+ * \ingroup digital
+ *
+ * Input: stream of bytes, which form a packet. The first byte of the packet
+ * has a tag with key "length" and the value being the number of bytes in the
+ * packet.
+ *
+ * Output: The same bytes as incoming, but trailing a CRC32 of the packet.
+ * The tag is re-set to the new length.
+ */
+class DIGITAL_API digital_crc32_bb : public gr_tagged_stream_block
+{
+ private:
+ friend DIGITAL_API digital_crc32_bb_sptr digital_make_crc32_bb (bool check, const std::string& lengthtagname);
+
+ bool d_check;
+
+ digital_crc32_bb(bool check, const std::string& lengthtagname);
+
+ public:
+ ~digital_crc32_bb();
+
+ int calculate_output_stream_length(const std::vector<int> &ninput_items);
+
+ int work (int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+};
+
+#endif /* INCLUDED_DIGITAL_CRC32_BB_H */
+
diff --git a/gr-digital/include/digital_ofdm_carrier_allocator_cvc.h b/gr-digital/include/digital_ofdm_carrier_allocator_cvc.h
new file mode 100644
index 0000000000..c1efcead22
--- /dev/null
+++ b/gr-digital/include/digital_ofdm_carrier_allocator_cvc.h
@@ -0,0 +1,116 @@
+/* -*- c++ -*- */
+/* Copyright 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_DIGITAL_OFDM_CARRIER_ALLOCATOR_CVC_H
+#define INCLUDED_DIGITAL_OFDM_CARRIER_ALLOCATOR_CVC_H
+
+#include <digital_api.h>
+#include <gr_tagged_stream_block.h>
+
+class digital_ofdm_carrier_allocator_cvc;
+typedef boost::shared_ptr<digital_ofdm_carrier_allocator_cvc> digital_ofdm_carrier_allocator_cvc_sptr;
+
+/*
+ * \param occupied_carriers A vector of vectors of indexes. Example: if
+ * occupied_carriers = ((1, 2, 3), (1, 2, 4)), the first
+ * three input symbols will be mapped to carriers 1, 2
+ * and 3. After that, a new OFDM symbol is started. The next
+ * three input symbols will be placed onto carriers 1, 2
+ * and 4 of the second OFDM symbol. The allocation then
+ * starts from the beginning.
+ * Order matters! The first input symbol is always mapped
+ * onto occupied_carriers[0][0].
+ * \param pilot_carriers The position of the pilot symbols. Same as occupied_carriers,
+ * but the actual symbols are taken from pilot_symbols instead
+ * of the input stream.
+ * \param pilot_symbols The pilot symbols which are placed onto the pilot carriers.
+ * pilot_symbols[0][0] is placed onto the first OFDM symbol, on
+ * carrier index pilot_carriers[0][0] etc.
+ * \param len_tag_key The key of the tag identifying the length of the input packet.
+ */
+DIGITAL_API digital_ofdm_carrier_allocator_cvc_sptr
+digital_make_ofdm_carrier_allocator_cvc (
+ int fft_len,
+ const std::vector<std::vector<int> > &occupied_carriers,
+ const std::vector<std::vector<int> > &pilot_carriers,
+ const std::vector<std::vector<gr_complex> > &pilot_symbols,
+ const std::string &len_tag_key = "packet_len");
+
+/*!
+ * \brief Create frequency domain OFDM symbols from complex values, add pilots.
+ * \ingroup ofdm_blk
+ *
+ * This block turns a stream of complex, scalar modulation symbols into vectors
+ * which are the input for an IFFT in an OFDM transmitter. It also supports the
+ * possibility of placing pilot symbols onto the carriers.
+ *
+ * The carriers can be allocated freely, if a carrier is not allocated, it is set
+ * to zero. This allows doing OFDMA-style carrier allocations.
+ *
+ * Input: A tagged stream of complex scalars. The first item must have a tag
+ * containing the number of complex symbols in this frame.
+ * Output: A tagged stream of complex vectors of length fft_len. This can directly
+ * be connected to an FFT block. Make sure to set this block to 'reverse'
+ * for the IFFT and to deactivate FFT shifting.
+ *
+ * Carrier indexes are always such that index 0 is the DC carrier (note: you should
+ * not allocate this carrier). The carriers below the DC carrier are either indexed
+ * with negative numbers, or with indexes larger than fft_len/2. Index -1 and index
+ * fft_len-1 both identify the carrier below the DC carrier.
+ *
+ */
+class DIGITAL_API digital_ofdm_carrier_allocator_cvc : public gr_tagged_stream_block
+{
+ private:
+ friend DIGITAL_API digital_ofdm_carrier_allocator_cvc_sptr digital_make_ofdm_carrier_allocator_cvc (int fft_len, const std::vector<std::vector<int> > &occupied_carriers, const std::vector<std::vector<int> > &pilot_carriers, const std::vector<std::vector<gr_complex> > &pilot_symbols, const std::string &len_tag_key);
+
+ digital_ofdm_carrier_allocator_cvc(int fft_len, const std::vector<std::vector<int> > &occupied_carriers, const std::vector<std::vector<int> > &pilot_carriers, const std::vector<std::vector<gr_complex> > &pilot_symbols, const std::string &len_tag_key);
+
+ //! FFT length
+ const int d_fft_len;
+ //! Which carriers/symbols carry data
+ std::vector<std::vector<int> > d_occupied_carriers;
+ //! Which carriers/symbols carry pilots symbols
+ std::vector<std::vector<int> > d_pilot_carriers;
+ //! Value of said pilot symbols
+ const std::vector<std::vector<gr_complex> > d_pilot_symbols;
+ int d_symbols_per_set;
+
+ protected:
+ int calculate_output_stream_length(const gr_vector_int &ninput_items);
+
+ public:
+ ~digital_ofdm_carrier_allocator_cvc();
+
+ std::string len_tag_key() { return d_length_tag_key_str; };
+
+ const int fft_len() { return d_fft_len; };
+ std::vector<std::vector<int> > occupied_carriers() { return d_occupied_carriers; };
+
+ int work (int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+};
+
+#endif /* INCLUDED_DIGITAL_OFDM_CARRIER_ALLOCATOR_CVC_H */
+
diff --git a/gr-digital/include/digital_ofdm_chanest_vcvc.h b/gr-digital/include/digital_ofdm_chanest_vcvc.h
new file mode 100644
index 0000000000..74454a63b2
--- /dev/null
+++ b/gr-digital/include/digital_ofdm_chanest_vcvc.h
@@ -0,0 +1,133 @@
+/* -*- c++ -*- */
+/* Copyright 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_DIGITAL_OFDM_CHANEST_VCVC_H
+#define INCLUDED_DIGITAL_OFDM_CHANEST_VCVC_H
+
+#include <digital_api.h>
+#include <gr_block.h>
+
+class digital_ofdm_chanest_vcvc;
+
+typedef boost::shared_ptr<digital_ofdm_chanest_vcvc> digital_ofdm_chanest_vcvc_sptr;
+
+/*
+ * \param sync_symbol1 First synchronisation symbol in the frequency domain. Its length must be
+ * the FFT length. For Schmidl & Cox synchronisation, every second sub-carrier
+ * has to be zero.
+ * \param sync_symbol2 Second synchronisation symbol in the frequency domain. Must be equal to
+ * the FFT length, or zero length if only one synchronisation symbol is used.
+ * Using this symbol is how synchronisation is described in [1]. Leaving this
+ * empty forces us to interpolate the equalizer taps.
+ * If you are using an unusual sub-carrier configuration (e.g. because of OFDMA),
+ * this sync symbol is used to identify the active sub-carriers. If you only
+ * have one synchronisation symbol, set the active sub-carriers to a non-zero
+ * value in here, and also set \p force_one_sync_symbol parameter to true.
+ * \param n_data_symbols The number of data symbols following each set of synchronisation symbols.
+ * Must be at least 1.
+ * \param eq_noise_red_len If non-zero, noise reduction for the equalizer taps is done according
+ * to [2]. In this case, it is the channel influence time in number of
+ * samples. A good value is usually the length of the cyclic prefix.
+ * \param max_carr_offset Limit the number of sub-carriers the frequency offset can maximally be.
+ * Leave this zero to try all possibilities.
+ * \param force_one_sync_symbol See \p sync_symbol2.
+ */
+DIGITAL_API digital_ofdm_chanest_vcvc_sptr
+digital_make_ofdm_chanest_vcvc (
+ const std::vector<gr_complex> &sync_symbol1,
+ const std::vector<gr_complex> &sync_symbol2,
+ int n_data_symbols,
+ int eq_noise_red_len=0,
+ int max_carr_offset=-1,
+ bool force_one_sync_symbol=false);
+
+/*!
+ * \brief Estimate channel and coarse frequency offset for OFDM from preambles
+ * \ingroup ofdm_blk
+ * \ingroup sync_blk
+ *
+ * Input: OFDM symbols (in frequency domain). The first one (or two) symbols are expected
+ * to be synchronisation symbols, which are used to estimate the coarse freq offset
+ * and the initial equalizer taps (these symbols are removed from the stream).
+ * The following \p n_data_symbols are passed through unmodified (the actual equalisation
+ * must be done elsewhere).
+ * Output: The data symbols, without the synchronisation symbols.
+ * The first data symbol passed through has two tags:
+ * 'ofdm_sync_carr_offset' (integer), the coarse frequency offset as number of carriers,
+ * and 'ofdm_sync_eq_taps' (complex vector).
+ * Any tags attached to the synchronisation symbols are attached to the first data
+ * symbol. All other tags are propagated normally.
+ *
+ * This block assumes the frequency offset is even (i.e. an integer multiple of 2).
+ *
+ * [1] Schmidl, T.M. and Cox, D.C., "Robust frequency and timing synchronization for OFDM",
+ * Communications, IEEE Transactions on, 1997.
+ * [2] K.D. Kammeyer, "Nachrichtenuebertragung," Chapter. 16.3.2.
+ */
+class DIGITAL_API digital_ofdm_chanest_vcvc : public gr_block
+{
+ private:
+ friend DIGITAL_API digital_ofdm_chanest_vcvc_sptr digital_make_ofdm_chanest_vcvc (const std::vector<gr_complex> &sync_symbol1, const std::vector<gr_complex> &sync_symbol2, int n_data_symbols, int eq_noise_red_len, int max_carr_offset, bool force_one_sync_symbol);
+
+ int d_fft_len; //! FFT length
+ int d_n_data_syms; //! Number of data symbols following the sync symbol(s)
+ int d_n_sync_syms; //! Number of sync symbols (1 or 2)
+ //! 0 if no noise reduction is done for the initial channel state estimation. Otherwise, the maximum length of the channel delay in samples.
+ int d_eq_noise_red_len;
+ //! Is sync_symbol1 if d_n_sync_syms == 1, otherwise sync_symbol2. Used as a reference symbol to estimate the channel.
+ std::vector<gr_complex> d_ref_sym;
+ //! If d_n_sync_syms == 2 this is used as a differential correlation vector (called 'v' in [1]).
+ std::vector<gr_complex> d_corr_v;
+ //! If d_n_sync_syms == 1 we use this instead of d_corr_v to estimate the coarse freq. offset
+ std::vector<float> d_known_symbol_diffs;
+ //! If d_n_sync_syms == 1 we use this instead of d_corr_v to estimate the coarse freq. offset (temp. variable)
+ std::vector<float> d_new_symbol_diffs;
+ //! The index of the first carrier with data (index 0 is not DC here, but the lowest frequency)
+ int d_first_active_carrier;
+ //! The index of the last carrier with data
+ int d_last_active_carrier;
+ //! If true, the channel estimation must be interpolated
+ bool d_interpolate;
+ //! Maximum carrier offset (negative value!)
+ int d_max_neg_carr_offset;
+ //! Maximum carrier offset (positive value!)
+ int d_max_pos_carr_offset;
+
+
+ digital_ofdm_chanest_vcvc(const std::vector<gr_complex> &sync_symbol1, const std::vector<gr_complex> &sync_symbol2, int n_data_symbols, int eq_noise_red_len, int max_carr_offset, bool force_one_sync_symbol);
+
+ //! Calculate the coarse frequency offset in number of carriers
+ int get_carr_offset(const gr_complex *sync_sym1, const gr_complex *sync_sym2);
+ //! Estimate the channel (phase and amplitude offset per carrier)
+ void get_chan_taps(const gr_complex *sync_sym1, const gr_complex *sync_sym2, int carr_offset, std::vector<gr_complex> &taps);
+
+ public:
+ ~digital_ofdm_chanest_vcvc();
+
+ 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_DIGITAL_OFDM_CHANEST_VCVC_H */
+
diff --git a/gr-digital/include/digital_ofdm_cyclic_prefixer.h b/gr-digital/include/digital_ofdm_cyclic_prefixer.h
index 1b9682bb35..e6c36b4c14 100644
--- a/gr-digital/include/digital_ofdm_cyclic_prefixer.h
+++ b/gr-digital/include/digital_ofdm_cyclic_prefixer.h
@@ -24,36 +24,72 @@
#define INCLUDED_DIGITAL_OFDM_CYCLIC_PREFIXER_H
#include <digital_api.h>
-#include <gr_sync_interpolator.h>
-#include <stdio.h>
+#include <gr_tagged_stream_block.h>
class digital_ofdm_cyclic_prefixer;
typedef boost::shared_ptr<digital_ofdm_cyclic_prefixer> digital_ofdm_cyclic_prefixer_sptr;
-DIGITAL_API digital_ofdm_cyclic_prefixer_sptr
-digital_make_ofdm_cyclic_prefixer (size_t input_size, size_t output_size);
+/*!
+ * \param input_size FFT length (i.e. length of the OFDM symbols)
+ * \param output_size FFT length + cyclic prefix length (in samples)
+ * \param rolloff_len Length of the rolloff flank in samples
+ * \param len_tag_key For framed processing the key of the length tag
+ */
+DIGITAL_API digital_ofdm_cyclic_prefixer_sptr
+digital_make_ofdm_cyclic_prefixer (size_t input_size,
+ size_t output_size,
+ int rolloff_len=0,
+ const std::string &len_tag_key="");
/*!
- * \brief adds a cyclic prefix vector to an input size long ofdm
- * symbol(vector) and converts vector to a stream output_size long.
+ * \brief Adds a cyclic prefix and performs pulse shaping on OFDM symbols.
* \ingroup ofdm_blk
+ *
+ * Input: OFDM symbols (in the time domain, i.e. after the IFFT). Optionally,
+ * entire frames can be processed. In this case, \p len_tag_key must be
+ * specified which holds the key of the tag that denotes how
+ * many OFDM symbols are in a frame.
+ * Output: A stream of (scalar) complex symbols, which include the cyclic prefix
+ * and the pulse shaping.
+ * Note: If complete frames are processed, and \p rolloff_len is greater
+ * than zero, the final OFDM symbol is followed by the delay line of
+ * the pulse shaping.
+ *
+ * The pulse shape is a raised cosine in the time domain.
*/
-class DIGITAL_API digital_ofdm_cyclic_prefixer : public gr_sync_interpolator
+class DIGITAL_API digital_ofdm_cyclic_prefixer : public gr_tagged_stream_block
{
friend DIGITAL_API digital_ofdm_cyclic_prefixer_sptr
- digital_make_ofdm_cyclic_prefixer (size_t input_size, size_t output_size);
+ digital_make_ofdm_cyclic_prefixer (size_t input_size, size_t output_size, int rolloff_len, const std::string &len_tag_key);
+
protected:
- digital_ofdm_cyclic_prefixer (size_t input_size, size_t output_size);
+ digital_ofdm_cyclic_prefixer (size_t input_size, size_t output_size, int rolloff_len, const std::string &len_tag_key);
+
+ //! Return the number of complex samples from the number of OFDM symbols (includes rolloff)
+ int calculate_output_stream_length(const gr_vector_int &ninput_items);
public:
- int work (int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
+ int work(int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+
private:
- size_t d_input_size;
+ size_t d_fft_len;
+ //! FFT length + CP length in samples
size_t d_output_size;
+ //! Length of the cyclic prefix in samples
+ int d_cp_size;
+ //! Length of pulse rolloff in samples
+ int d_rolloff_len;
+ //! Buffers the up-flank (at the beginning of the cyclic prefix)
+ std::vector<float> d_up_flank;
+ //! Buffers the down-flank (which trails the symbol)
+ std::vector<float> d_down_flank;
+ std::vector<gr_complex> d_delay_line; // We do this explicitly to avoid outputting zeroes (i.e. no history!)
};
#endif /* INCLUDED_DIGITAL_OFDM_CYCLIC_PREFIXER_H */
+
diff --git a/gr-digital/include/digital_ofdm_equalizer_base.h b/gr-digital/include/digital_ofdm_equalizer_base.h
new file mode 100644
index 0000000000..178806a886
--- /dev/null
+++ b/gr-digital/include/digital_ofdm_equalizer_base.h
@@ -0,0 +1,102 @@
+/* -*- c++ -*- */
+/* Copyright 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_DIGITAL_OFDM_EQUALIZER_BASE_H
+#define INCLUDED_DIGITAL_OFDM_EQUALIZER_BASE_H
+
+#include <digital_api.h>
+#include <gr_tags.h>
+#include <gr_complex.h>
+#include <boost/enable_shared_from_this.hpp>
+
+class digital_ofdm_equalizer_base;
+typedef boost::shared_ptr<digital_ofdm_equalizer_base> digital_ofdm_equalizer_base_sptr;
+
+class digital_ofdm_equalizer_1d_pilots;
+typedef boost::shared_ptr<digital_ofdm_equalizer_1d_pilots> digital_ofdm_equalizer_1d_pilots_sptr;
+
+/* \brief Base class for implementation details of frequency-domain OFDM equalizers.
+ * \ingroup ofdm_blk
+ * \ingroup eq_blk
+ *
+ */
+class DIGITAL_API digital_ofdm_equalizer_base : public boost::enable_shared_from_this<digital_ofdm_equalizer_base>
+{
+ protected:
+ int d_fft_len;
+ int d_carr_offset;
+
+ public:
+ digital_ofdm_equalizer_base(int fft_len);
+ ~digital_ofdm_equalizer_base();
+
+ virtual void reset() = 0;
+ void set_carrier_offset(int offset) { d_carr_offset = offset; };
+ virtual void equalize(
+ gr_complex *frame,
+ int n_sym,
+ const std::vector<gr_complex> &initial_taps = std::vector<gr_complex>(),
+ const std::vector<gr_tag_t> &tags = std::vector<gr_tag_t>()) = 0;
+ virtual void get_channel_state(std::vector<gr_complex> &taps) = 0;
+ int fft_len() { return d_fft_len; };
+ digital_ofdm_equalizer_base_sptr base() { return shared_from_this(); };
+};
+
+
+/* \brief Base class for implementation details of 1-dimensional OFDM FDEs which use pilot tones.
+ * \ingroup digital
+ *
+ */
+class DIGITAL_API digital_ofdm_equalizer_1d_pilots : public digital_ofdm_equalizer_base
+{
+ protected:
+ //! If \p d_occupied_carriers[k][l] is true, symbol k, carrier l is carrying data.
+ // (this is a different format than occupied_carriers!)
+ std::vector<bool> d_occupied_carriers;
+ //! If \p d_pilot_carriers[k][l] is true, symbol k, carrier l is carrying data.
+ // (this is a different format than pilot_carriers!)
+ std::vector<std::vector<bool> > d_pilot_carriers;
+ //! If \p d_pilot_carriers[k][l] is true, d_pilot_symbols[k][l] is its tx'd value.
+ // (this is a different format than pilot_symbols!)
+ std::vector<std::vector<gr_complex> > d_pilot_symbols;
+ //! In case the frame doesn't begin with OFDM symbol 0, this is the index of the first symbol
+ int d_symbols_skipped;
+ //! The current position in the set of pilot symbols
+ int d_pilot_carr_set;
+ //! Vector of length d_fft_len saving the current channel state (on the occupied carriers)
+ std::vector<gr_complex> d_channel_state;
+
+ public:
+ digital_ofdm_equalizer_1d_pilots(
+ int fft_len,
+ const std::vector<std::vector<int> > &occupied_carriers,
+ const std::vector<std::vector<int> > &pilot_carriers,
+ const std::vector<std::vector<gr_complex> > &pilot_symbols,
+ int symbols_skipped,
+ bool input_is_shifted);
+ ~digital_ofdm_equalizer_1d_pilots();
+
+ void reset();
+ void get_channel_state(std::vector<gr_complex> &taps);
+};
+
+#endif /* INCLUDED_DIGITAL_OFDM_EQUALIZER_BASE_H */
+
diff --git a/gr-digital/include/digital_ofdm_equalizer_simpledfe.h b/gr-digital/include/digital_ofdm_equalizer_simpledfe.h
new file mode 100644
index 0000000000..9fd6395904
--- /dev/null
+++ b/gr-digital/include/digital_ofdm_equalizer_simpledfe.h
@@ -0,0 +1,126 @@
+/* -*- c++ -*- */
+/* Copyright 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_DIGITAL_OFDM_EQUALIZER_SIMPLEDFE_H
+#define INCLUDED_DIGITAL_OFDM_EQUALIZER_SIMPLEDFE_H
+
+#include <digital_api.h>
+#include <digital_constellation.h>
+#include <digital_ofdm_equalizer_base.h>
+
+class digital_ofdm_equalizer_simpledfe;
+typedef boost::shared_ptr<digital_ofdm_equalizer_simpledfe> digital_ofdm_equalizer_simpledfe_sptr;
+
+/*
+ * \param fft_len FFT length
+ * \param constellation The constellation object describing the modulation used
+ * on the subcarriers (e.g. QPSK). This is used to decode
+ * the individual symbols.
+ * \param occupied_carriers List of occupied carriers, see ofdm_carrier_allocator
+ * for a description.
+ * \param pilot_carriers Position of pilot symbols, see ofdm_carrier_allocator
+ * for a description.
+ * \param pilot_symbols Value of pilot symbols, see ofdm_carrier_allocator
+ * for a description.
+ * \param alpha Averaging coefficient (in a nutshell, if \f$H_{i,k}\f$ is the channel
+ * state for carrier i and symbol k,
+ * \f$H_{i,k+1} = \alpha H_{i,k} + (1 - \alpha) H_{i,k+1}\f$. Make this
+ * larger if there's more noise, but keep in mind that larger values
+ * of alpha mean slower response to channel changes).
+ * \param symbols_skipped Starting position within occupied_carriers and pilot_carriers.
+ * If the first symbol of the frame was removed (e.g. to decode the
+ * header), set this make sure the pilot symbols are correctly
+ * identified.
+ * \param input_is_shifted Set this to false if the input signal is not shifted, i.e.
+ * the first input items is on the DC carrier.
+ * Note that a lot of the OFDM receiver blocks operate on shifted
+ * signals!
+ */
+DIGITAL_API digital_ofdm_equalizer_simpledfe_sptr
+digital_make_ofdm_equalizer_simpledfe(
+ int fft_len,
+ const digital_constellation_sptr &constellation,
+ const std::vector<std::vector<int> > &occupied_carriers = std::vector<std::vector<int> >(),
+ const std::vector<std::vector<int> > &pilot_carriers = std::vector<std::vector<int> >(),
+ const std::vector<std::vector<gr_complex> > &pilot_symbols = std::vector<std::vector<gr_complex> >(),
+ int symbols_skipped = 0,
+ float alpha = 0.1,
+ bool input_is_shifted = true);
+
+/* \brief Simple decision feedback equalizer for OFDM.
+ * \ingroup ofdm_blk
+ * \ingroup eq_blk
+ *
+ * Equalizes an OFDM signal symbol by symbol using knowledge of the
+ * complex modulations symbols.
+ * For every symbol, the following steps are performed:
+ * - On every sub-carrier, decode the modulation symbol
+ * - Use the difference between the decoded symbol and the received symbol
+ * to update the channel state on this carrier
+ * - Whenever a pilot symbol is found, it uses the known pilot symbol to
+ * update the channel state.
+ *
+ * This equalizer makes a lot of assumptions:
+ * - The initial channel state is good enough to decode the first
+ * symbol without error (unless the first symbol only consists of pilot
+ * tones)
+ * - The channel changes only very slowly, such that the channel state
+ * from one symbol is enough to decode the next
+ * - SNR low enough that equalization will always suffice to correctly
+ * decode a symbol
+ * If these assumptions are not met, the most common error is that the
+ * channel state is estimated incorrectly during equalization; after that,
+ * all subsequent symbols will be completely wrong.
+ *
+ * Note that the equalized symbols are *exact points* on the constellation.
+ * This means soft information of the modulation symbols is lost after the
+ * equalization, which is suboptimal for channel codes that use soft decision.
+ *
+ */
+class DIGITAL_API digital_ofdm_equalizer_simpledfe : public digital_ofdm_equalizer_1d_pilots
+{
+ public:
+ digital_ofdm_equalizer_simpledfe(
+ int fft_len,
+ const digital_constellation_sptr &constellation,
+ const std::vector<std::vector<int> > &occupied_carriers = std::vector<std::vector<int> >(),
+ const std::vector<std::vector<int> > &pilot_carriers = std::vector<std::vector<int> >(),
+ const std::vector<std::vector<gr_complex> > &pilot_symbols = std::vector<std::vector<gr_complex> >(),
+ int symbols_skipped = 0,
+ float alpha = 0.1,
+ bool input_is_shifted = true);
+
+ ~digital_ofdm_equalizer_simpledfe();
+
+ void equalize(gr_complex *frame,
+ int n_sym,
+ const std::vector<gr_complex> &initial_taps = std::vector<gr_complex>(),
+ const std::vector<gr_tag_t> &tags = std::vector<gr_tag_t>());
+
+ private:
+ digital_constellation_sptr d_constellation;
+ //! Averaging coefficient
+ float d_alpha;
+
+};
+
+#endif /* INCLUDED_DIGITAL_OFDM_EQUALIZER_SIMPLEDFE_H */
+
diff --git a/gr-digital/include/digital_ofdm_equalizer_static.h b/gr-digital/include/digital_ofdm_equalizer_static.h
new file mode 100644
index 0000000000..21f76fbc6a
--- /dev/null
+++ b/gr-digital/include/digital_ofdm_equalizer_static.h
@@ -0,0 +1,97 @@
+/* -*- c++ -*- */
+/* Copyright 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_DIGITAL_OFDM_EQUALIZER_STATIC_H
+#define INCLUDED_DIGITAL_OFDM_EQUALIZER_STATIC_H
+
+#include <digital_api.h>
+#include <digital_constellation.h>
+#include <digital_ofdm_equalizer_base.h>
+
+class digital_ofdm_equalizer_static;
+typedef boost::shared_ptr<digital_ofdm_equalizer_static> digital_ofdm_equalizer_static_sptr;
+
+/*
+ * \param fft_len FFT length
+ * \param occupied_carriers List of occupied carriers, see ofdm_carrier_allocator
+ * for a description.
+ * \param pilot_carriers Position of pilot symbols, see ofdm_carrier_allocator
+ * for a description.
+ * \param pilot_symbols Value of pilot symbols, see ofdm_carrier_allocator
+ * for a description.
+ * \param symbols_skipped Starting position within occupied_carriers and pilot_carriers.
+ * If the first symbol of the frame was removed (e.g. to decode the
+ * header), set this make sure the pilot symbols are correctly
+ * identified.
+ * \param input_is_shifted Set this to false if the input signal is not shifted, i.e.
+ * the first input items is on the DC carrier.
+ * Note that a lot of the OFDM receiver blocks operate on shifted
+ * signals!
+ */
+DIGITAL_API digital_ofdm_equalizer_static_sptr
+digital_make_ofdm_equalizer_static(
+ int fft_len,
+ const std::vector<std::vector<int> > &occupied_carriers = std::vector<std::vector<int> >(),
+ const std::vector<std::vector<int> > &pilot_carriers = std::vector<std::vector<int> >(),
+ const std::vector<std::vector<gr_complex> > &pilot_symbols = std::vector<std::vector<gr_complex> >(),
+ int symbols_skipped = 0,
+ bool input_is_shifted = true);
+
+/* \brief Very simple static equalizer for OFDM.
+ * \ingroup ofdm_blk
+ * \ingroup eq_blk
+ *
+ * This is an extremely simple equalizer. It will only work for high-SNR, very, very
+ * slowly changing channels.
+ * It simply divides the signal with the currently known channel state. Whenever
+ * a pilot symbol comes around, it updates the channel state on that particular
+ * carrier by dividing the received symbol with the known pilot symbol.
+ */
+class DIGITAL_API digital_ofdm_equalizer_static : public digital_ofdm_equalizer_1d_pilots
+{
+ public:
+ digital_ofdm_equalizer_static(
+ int fft_len,
+ const std::vector<std::vector<int> > &occupied_carriers = std::vector<std::vector<int> >(),
+ const std::vector<std::vector<int> > &pilot_carriers = std::vector<std::vector<int> >(),
+ const std::vector<std::vector<gr_complex> > &pilot_symbols = std::vector<std::vector<gr_complex> >(),
+ int symbols_skipped = 0,
+ bool input_is_shifted = true);
+ ~digital_ofdm_equalizer_static();
+
+ /*! \brief Divide the input signal with the current channel state.
+ *
+ * Does the following (and nothing else):
+ * - Divide every OFDM symbol with the current channel state
+ * - If a pilot symbol is found, re-set the channel state by dividing the received
+ * symbol with the known pilot symbol
+ */
+ void equalize(gr_complex *frame,
+ int n_sym,
+ const std::vector<gr_complex> &initial_taps = std::vector<gr_complex>(),
+ const std::vector<gr_tag_t> &tags = std::vector<gr_tag_t>());
+
+ private:
+
+};
+
+#endif /* INCLUDED_DIGITAL_OFDM_EQUALIZER_STATIC_H */
+
diff --git a/gr-digital/include/digital_ofdm_sync_sc_cfb.h b/gr-digital/include/digital_ofdm_sync_sc_cfb.h
new file mode 100644
index 0000000000..36ea1b22fd
--- /dev/null
+++ b/gr-digital/include/digital_ofdm_sync_sc_cfb.h
@@ -0,0 +1,79 @@
+/* -*- c++ -*- */
+/* Copyright 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_DIGITAL_OFDM_SYNC_SC_CFB_H
+#define INCLUDED_DIGITAL_OFDM_SYNC_SC_CFB_H
+
+#include <digital_api.h>
+#include <gr_hier_block2.h>
+
+class digital_ofdm_sync_sc_cfb;
+typedef boost::shared_ptr<digital_ofdm_sync_sc_cfb> digital_ofdm_sync_sc_cfb_sptr;
+
+/*! \param fft_len FFT length
+ * \param cp_len Length of the guard interval (cyclic prefix) in samples
+ */
+DIGITAL_API digital_ofdm_sync_sc_cfb_sptr
+digital_make_ofdm_sync_sc_cfb (int fft_len, int cp_len);
+
+/*!
+ * \brief Schmidl & Cox synchronisation for OFDM
+ * \ingroup ofdm_blk
+ * \ingroup sync_blk
+ *
+ * Input: complex samples.
+ * Output 0: Fine frequency offset, scaled by the OFDM symbol duration.
+ * This is \f$\hat{\varphi}\f$ in [1]. The normalized frequency
+ * offset is then 2.0*output0/fft_len.
+ * Output 1: Beginning of the first OFDM symbol after the first (doubled) OFDM
+ * symbol. The beginning is marked with a 1 (it's 0 everywhere else).
+ *
+ * The evaluation of the coarse frequency offset is *not* done in this block.
+ * Also, the initial equalizer taps are not calculated here.
+ *
+ * Note that we use a different normalization factor in the timing metric than
+ * the authors do in their original work[1]. If the timing metric (8) is
+ * \f[
+ * M(d) = \frac{|P(d)|^2}{(R(d))^2},
+ * \f]
+ * we calculate the normalization as
+ * \f[
+ * R(d) = \frac{1}{2} \sum_{k=0}^{N-1} |r_{k+d}|^2,
+ * \f]
+ * i.e., we estimate the energy from *both* half-symbols. This avoids spurious detects
+ * at the end of a burst, when the energy level suddenly drops.
+ *
+ * [1] Schmidl, T.M. and Cox, D.C., "Robust frequency and timing synchronization for OFDM",
+ * Communications, IEEE Transactions on, 1997.
+ */
+class DIGITAL_API digital_ofdm_sync_sc_cfb : public gr_hier_block2
+{
+ private:
+ friend DIGITAL_API digital_ofdm_sync_sc_cfb_sptr digital_make_ofdm_sync_sc_cfb (int fft_len, int cp_len);
+ digital_ofdm_sync_sc_cfb(int fft_len, int cp_len);
+
+ public:
+ ~digital_ofdm_sync_sc_cfb();
+
+};
+
+#endif /* INCLUDED_DIGITAL_OFDM_SYNC_SC_CFB_H */
+
diff --git a/gr-digital/lib/CMakeLists.txt b/gr-digital/lib/CMakeLists.txt
index 7ac16602c7..42340b6c2a 100644
--- a/gr-digital/lib/CMakeLists.txt
+++ b/gr-digital/lib/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright 2011,2012 Free Software Foundation, Inc.
+# Copyright 2011-2013 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -24,12 +24,16 @@ include_directories(
${CMAKE_CURRENT_BINARY_DIR}/../include
${GR_DIGITAL_INCLUDE_DIRS}
${GR_ANALOG_INCLUDE_DIRS}
+ ${GR_FILTER_INCLUDE_DIRS}
+ ${GR_BLOCKS_INCLUDE_DIRS}
${GNURADIO_CORE_INCLUDE_DIRS}
${GRUEL_INCLUDE_DIRS}
+ ${LOG4CPP_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS}
)
link_directories(${Boost_LIBRARY_DIRS})
+link_directories(${LOG4CPP_LIBRARY_DIRS})
########################################################################
# generate helper scripts to expand templated files
@@ -90,6 +94,7 @@ expand_cc(digital_chunks_to_symbols_XX bf bc sf sc if ic)
########################################################################
# Setup library
########################################################################
+
list(APPEND gr_digital_sources
${generated_sources}
digital_impl_glfsr.cc
@@ -136,16 +141,54 @@ list(APPEND gr_digital_sources
digital_probe_mpsk_snr_est_c.cc
digital_scrambler_bb.cc
digital_simple_framer.cc
+ digital_ofdm_sync_sc_cfb.cc
+ digital_ofdm_chanest_vcvc.cc
+ digital_crc32_bb.cc
+ digital_ofdm_carrier_allocator_cvc.cc
+ digital_ofdm_equalizer_base.cc
+ digital_ofdm_equalizer_static.cc
+ digital_ofdm_equalizer_simpledfe.cc
+ ofdm_frame_equalizer_vcvc_impl.cc
+ ofdm_serializer_vcc_impl.cc
+ packet_header_default.cc
+ packet_header_ofdm.cc
+ packet_headergenerator_bb_impl.cc
+ packet_headerparser_b_impl.cc
+ header_payload_demux_impl.cc
digital_simple_correlator.cc
)
+#Add Windows DLL resource file if using MSVC
+IF(MSVC)
+ include(${CMAKE_SOURCE_DIR}/cmake/Modules/GrVersion.cmake)
+
+ configure_file(
+ ${CMAKE_CURRENT_SOURCE_DIR}/gnuradio-digital.rc.in
+ ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-digital.rc
+ @ONLY)
+
+ list(APPEND gr_digital_sources
+ ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-digital.rc
+ )
+ENDIF(MSVC)
+
list(APPEND digital_libs
gnuradio-core
+ gnuradio-blocks
+ gnuradio-analog
+ gnuradio-filter
${Boost_LIBRARIES}
+ ${LOG4CPP_LIBRARIES}
)
add_library(gnuradio-digital SHARED ${gr_digital_sources})
target_link_libraries(gnuradio-digital ${digital_libs})
GR_LIBRARY_FOO(gnuradio-digital RUNTIME_COMPONENT "digital_runtime" DEVEL_COMPONENT "digital_devel")
+add_dependencies(gnuradio-digital
+ digital_generated_includes
+ digital_generated_swigs
+ gnuradio-analog
+ gnuradio-blocks
+ gnuradio-filter
+)
-add_dependencies(gnuradio-digital digital_generated_includes digital_generated_swigs gnuradio-analog)
diff --git a/gr-digital/lib/digital_constellation.cc b/gr-digital/lib/digital_constellation.cc
index da79f2caa4..0d4b88b047 100644
--- a/gr-digital/lib/digital_constellation.cc
+++ b/gr-digital/lib/digital_constellation.cc
@@ -345,6 +345,37 @@ digital_constellation_rect::calc_sector_value (unsigned int sector)
return closest_point;
}
+digital_constellation_expl_rect_sptr
+digital_make_constellation_expl_rect(
+ std::vector<gr_complex> constellation,
+ std::vector<unsigned int> pre_diff_code,
+ unsigned int rotational_symmetry,
+ unsigned int real_sectors,
+ unsigned int imag_sectors,
+ float width_real_sectors,
+ float width_imag_sectors,
+ std::vector<unsigned int> sector_values
+)
+{
+ return digital_constellation_expl_rect_sptr(
+ new digital_constellation_expl_rect(
+ constellation, pre_diff_code, rotational_symmetry, real_sectors, imag_sectors,
+ width_real_sectors, width_imag_sectors, sector_values));
+}
+
+digital_constellation_expl_rect::digital_constellation_expl_rect (
+ std::vector<gr_complex> constellation,
+ std::vector<unsigned int> pre_diff_code,
+ unsigned int rotational_symmetry,
+ unsigned int real_sectors,
+ unsigned int imag_sectors,
+ float width_real_sectors,
+ float width_imag_sectors,
+ std::vector<unsigned int> sector_values
+ ) : digital_constellation_rect(
+ constellation, pre_diff_code, rotational_symmetry, real_sectors, imag_sectors,
+ width_real_sectors, width_imag_sectors),
+ d_sector_values(sector_values) {};
digital_constellation_psk_sptr
digital_make_constellation_psk(std::vector<gr_complex> constellation,
diff --git a/gr-digital/lib/digital_crc32_bb.cc b/gr-digital/lib/digital_crc32_bb.cc
new file mode 100644
index 0000000000..89d9e42151
--- /dev/null
+++ b/gr-digital/lib/digital_crc32_bb.cc
@@ -0,0 +1,102 @@
+/* -*- c++ -*- */
+/* Copyright 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gr_io_signature.h>
+#include <digital_crc32.h>
+#include "digital_crc32_bb.h"
+
+digital_crc32_bb_sptr
+digital_make_crc32_bb (bool check, const std::string& lengthtagname)
+{
+ return gnuradio::get_initial_sptr (new digital_crc32_bb(check, lengthtagname));
+}
+
+
+digital_crc32_bb::digital_crc32_bb (bool check, const std::string& lengthtagname)
+ : gr_tagged_stream_block ("crc32_bb",
+ gr_make_io_signature(1, 1, sizeof (char)),
+ gr_make_io_signature(1, 1, sizeof (char)),
+ lengthtagname),
+ d_check(check)
+{
+ set_tag_propagation_policy(TPP_DONT);
+}
+
+
+digital_crc32_bb::~digital_crc32_bb()
+{
+}
+
+
+int
+digital_crc32_bb::calculate_output_stream_length(const std::vector<int> &ninput_items)
+{
+ if (d_check) {
+ return ninput_items[0] - 4;
+ } else {
+ return ninput_items[0] + 4;
+ }
+}
+
+
+int
+digital_crc32_bb::work (int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+{
+ const unsigned char *in = (const unsigned char *) input_items[0];
+ unsigned char *out = (unsigned char *) output_items[0];
+ long packet_length = ninput_items[0];
+ int packet_size_diff = d_check ? -4 : 4;
+ unsigned int crc;
+
+ if (d_check) {
+ crc = digital_crc32(in, packet_length-4);
+ if (crc != *(unsigned int *)(in+packet_length-4)) { // Drop package
+ return 0;
+ }
+ memcpy((void *) out, (const void *) in, packet_length-4);
+ } else {
+ crc = digital_crc32(in, packet_length);
+ memcpy((void *) out, (const void *) in, packet_length);
+ memcpy((void *) (out + packet_length), &crc, 4); // FIXME big-endian/little-endian, this might be wrong
+ }
+
+ std::vector<gr_tag_t> tags;
+ get_tags_in_range(tags, 0, nitems_read(0), nitems_read(0)+packet_length);
+ for (unsigned i = 0; i < tags.size(); i++) {
+ tags[i].offset -= nitems_read(0);
+ if (d_check && tags[i].offset > packet_length+packet_size_diff) {
+ tags[i].offset = packet_length-5;
+ }
+ add_item_tag(0, nitems_written(0) + tags[i].offset,
+ tags[i].key,
+ tags[i].value);
+ }
+
+ return packet_length + packet_size_diff;
+}
+
diff --git a/gr-digital/lib/digital_ofdm_carrier_allocator_cvc.cc b/gr-digital/lib/digital_ofdm_carrier_allocator_cvc.cc
new file mode 100644
index 0000000000..e5b3013302
--- /dev/null
+++ b/gr-digital/lib/digital_ofdm_carrier_allocator_cvc.cc
@@ -0,0 +1,156 @@
+/* -*- c++ -*- */
+/* Copyright 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gr_io_signature.h>
+#include "digital_ofdm_carrier_allocator_cvc.h"
+
+digital_ofdm_carrier_allocator_cvc_sptr
+digital_make_ofdm_carrier_allocator_cvc (
+ int fft_len,
+ const std::vector<std::vector<int> > &occupied_carriers,
+ const std::vector<std::vector<int> > &pilot_carriers,
+ const std::vector<std::vector<gr_complex> > &pilot_symbols,
+ const std::string &len_tag_key)
+{
+ return gnuradio::get_initial_sptr (new digital_ofdm_carrier_allocator_cvc(fft_len, occupied_carriers, pilot_carriers, pilot_symbols, len_tag_key));
+}
+
+
+digital_ofdm_carrier_allocator_cvc::digital_ofdm_carrier_allocator_cvc (
+ int fft_len,
+ const std::vector<std::vector<int> > &occupied_carriers,
+ const std::vector<std::vector<int> > &pilot_carriers,
+ const std::vector<std::vector<gr_complex> > &pilot_symbols,
+ const std::string &len_tag_key)
+ : gr_tagged_stream_block ("ofdm_carrier_allocator_cvc",
+ gr_make_io_signature(1, 1, sizeof (gr_complex)),
+ gr_make_io_signature(1, 1, sizeof (gr_complex) * fft_len), len_tag_key),
+ d_fft_len(fft_len),
+ d_occupied_carriers(occupied_carriers),
+ d_pilot_carriers(pilot_carriers),
+ d_pilot_symbols(pilot_symbols),
+ d_symbols_per_set(0)
+{
+ for (unsigned i = 0; i < d_occupied_carriers.size(); i++) {
+ for (unsigned j = 0; j < d_occupied_carriers[i].size(); j++) {
+ if (occupied_carriers[i][j] < 0) {
+ d_occupied_carriers[i][j] += d_fft_len;
+ }
+ if (d_occupied_carriers[i][j] > d_fft_len || d_occupied_carriers[i][j] < 0) {
+ throw std::invalid_argument("data carrier index out of bounds");
+ }
+ }
+ }
+ for (unsigned i = 0; i < d_pilot_carriers.size(); i++) {
+ if (d_pilot_carriers[i].size() != pilot_symbols[i].size()) {
+ throw std::invalid_argument("pilot_carriers do not match pilot_symbols");
+ }
+ for (unsigned j = 0; j < d_pilot_carriers[i].size(); j++) {
+ if (d_pilot_carriers[i][j] < 0) {
+ d_pilot_carriers[i][j] += d_fft_len;
+ }
+ if (d_pilot_carriers[i][j] > d_fft_len || d_pilot_carriers[i][j] < 0) {
+ throw std::invalid_argument("pilot carrier index out of bounds");
+ }
+ }
+ }
+
+ for (unsigned i = 0; i < d_occupied_carriers.size(); i++) {
+ d_symbols_per_set += d_occupied_carriers[i].size();
+ }
+ set_tag_propagation_policy(TPP_DONT);
+ set_relative_rate((double) d_symbols_per_set / d_occupied_carriers.size());
+}
+
+
+digital_ofdm_carrier_allocator_cvc::~digital_ofdm_carrier_allocator_cvc()
+{
+}
+
+
+int
+digital_ofdm_carrier_allocator_cvc::calculate_output_stream_length(const gr_vector_int &ninput_items)
+{
+ int nin = ninput_items[0];
+ int nout = (nin / d_symbols_per_set) * d_occupied_carriers.size();
+ int k = 0;
+ for (int i = 0; i < nin % d_symbols_per_set; k++) {
+ nout++;
+ i += d_occupied_carriers[k % d_occupied_carriers.size()].size();
+ }
+ return nout;
+}
+
+
+int
+digital_ofdm_carrier_allocator_cvc::work (int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+{
+ const gr_complex *in = (const gr_complex *) input_items[0];
+ gr_complex *out = (gr_complex *) output_items[0];
+
+ std::vector<gr_tag_t> tags;
+
+ memset((void *) out, 0x00, sizeof(gr_complex) * d_fft_len * noutput_items);
+ long n_ofdm_symbols = 0;
+ int curr_set = 0;
+ int symbols_to_allocate = d_occupied_carriers[0].size();
+ int symbols_allocated = 0;
+ for (int i = 0; i < ninput_items[0]; i++) {
+ if (symbols_allocated == 0) {
+ // Copy all tags associated with these input symbols onto this OFDM symbol
+ get_tags_in_range(tags, 0,
+ nitems_read(0)+i,
+ nitems_read(0)+std::min(i+symbols_to_allocate, (int) ninput_items[0])
+ );
+ for (unsigned t = 0; t < tags.size(); t++) {
+ add_item_tag(0, nitems_written(0)+n_ofdm_symbols,
+ tags[t].key,
+ tags[t].value);
+ }
+ n_ofdm_symbols++;
+ }
+ out[(n_ofdm_symbols-1) * d_fft_len + d_occupied_carriers[curr_set][symbols_allocated]] = in[i];
+ symbols_allocated++;
+ if (symbols_allocated == symbols_to_allocate) {
+ curr_set = (curr_set + 1) % d_occupied_carriers.size();
+ symbols_to_allocate = d_occupied_carriers[curr_set].size();
+ symbols_allocated = 0;
+ }
+ }
+ // 2) Copy pilot symbols
+ curr_set = 0;
+ for (int i = 0; i < n_ofdm_symbols; i++) {
+ for (unsigned k = 0; k < d_pilot_carriers[curr_set].size(); k++) {
+ out[i * d_fft_len + d_pilot_carriers[curr_set][k]] = d_pilot_symbols[curr_set][k];
+ }
+ curr_set = (curr_set + 1) % d_pilot_carriers.size();
+ }
+
+ return n_ofdm_symbols;
+}
+
diff --git a/gr-digital/lib/digital_ofdm_chanest_vcvc.cc b/gr-digital/lib/digital_ofdm_chanest_vcvc.cc
new file mode 100644
index 0000000000..f38017e00b
--- /dev/null
+++ b/gr-digital/lib/digital_ofdm_chanest_vcvc.cc
@@ -0,0 +1,281 @@
+/* -*- c++ -*- */
+// vim: set sw=2:
+/* Copyright 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gr_io_signature.h>
+#include "digital_ofdm_chanest_vcvc.h"
+
+digital_ofdm_chanest_vcvc_sptr
+digital_make_ofdm_chanest_vcvc (
+ const std::vector<gr_complex> &sync_symbol1,
+ const std::vector<gr_complex> &sync_symbol2,
+ int n_data_symbols,
+ int eq_noise_red_len,
+ int max_carr_offset,
+ bool force_one_sync_symbol)
+{
+ return gnuradio::get_initial_sptr (new digital_ofdm_chanest_vcvc(
+ sync_symbol1, sync_symbol2, n_data_symbols, eq_noise_red_len, max_carr_offset, force_one_sync_symbol));
+}
+
+
+digital_ofdm_chanest_vcvc::digital_ofdm_chanest_vcvc (
+ const std::vector<gr_complex> &sync_symbol1,
+ const std::vector<gr_complex> &sync_symbol2,
+ int n_data_symbols,
+ int eq_noise_red_len,
+ int max_carr_offset,
+ bool force_one_sync_symbol)
+ : gr_block ("ofdm_chanest_vcvc",
+ gr_make_io_signature(1, 1, sizeof (gr_complex) * sync_symbol1.size()),
+ gr_make_io_signature(1, 1, sizeof (gr_complex) * sync_symbol1.size())),
+ d_fft_len(sync_symbol1.size()),
+ d_n_data_syms(n_data_symbols),
+ d_n_sync_syms(1),
+ d_eq_noise_red_len(eq_noise_red_len),
+ d_ref_sym((sync_symbol2.size() && !force_one_sync_symbol) ? sync_symbol2 : sync_symbol1),
+ d_corr_v(sync_symbol2),
+ d_known_symbol_diffs(0, 0),
+ d_new_symbol_diffs(0, 0),
+ d_interpolate(false)
+{
+ // Set index of first and last active carrier
+ for (int i = 0; i < d_fft_len; i++) {
+ if (d_ref_sym[i] != gr_complex(0, 0)) {
+ d_first_active_carrier = i;
+ break;
+ }
+ }
+ for (int i = d_fft_len-1; i >= 0; i--) {
+ if (d_ref_sym[i] != gr_complex(0, 0)) {
+ d_last_active_carrier = i;
+ break;
+ }
+ }
+
+ // Sanity checks
+ if (sync_symbol2.size()) {
+ if (sync_symbol1.size() != sync_symbol2.size()) {
+ throw std::invalid_argument("sync symbols must have equal length.");
+ }
+ if (!force_one_sync_symbol) {
+ d_n_sync_syms = 2;
+ }
+ } else {
+ if (sync_symbol1[d_first_active_carrier+1] == gr_complex(0, 0)) {
+ d_last_active_carrier++;
+ d_interpolate = true;
+ }
+ }
+
+ // Set up coarse freq estimation info
+ // Allow all possible values:
+ d_max_neg_carr_offset = -d_first_active_carrier;
+ d_max_pos_carr_offset = d_fft_len - d_last_active_carrier - 1;
+ if (max_carr_offset != -1) {
+ d_max_neg_carr_offset = std::max(-max_carr_offset, d_max_neg_carr_offset);
+ d_max_pos_carr_offset = std::min(max_carr_offset, d_max_pos_carr_offset);
+ }
+ // Carrier offsets must be even
+ if (d_max_neg_carr_offset % 2)
+ d_max_neg_carr_offset++;
+ if (d_max_pos_carr_offset % 2)
+ d_max_pos_carr_offset--;
+
+ if (d_n_sync_syms == 2) {
+ for (int i = 0; i < d_fft_len; i++) {
+ if (sync_symbol1[i] == gr_complex(0, 0)) {
+ d_corr_v[i] = gr_complex(0, 0);
+ } else {
+ d_corr_v[i] /= sync_symbol1[i];
+ }
+ }
+ } else {
+ d_corr_v.resize(0, 0);
+ d_known_symbol_diffs.resize(d_fft_len, 0);
+ d_new_symbol_diffs.resize(d_fft_len, 0);
+ for (int i = d_first_active_carrier; i < d_last_active_carrier-2 && i < d_fft_len-2; i += 2) {
+ d_known_symbol_diffs[i] = std::norm(sync_symbol1[i] - sync_symbol1[i+2]);
+ }
+ }
+
+ set_relative_rate((double) n_data_symbols / (n_data_symbols + d_n_sync_syms));
+ set_tag_propagation_policy(TPP_DONT);
+}
+
+
+digital_ofdm_chanest_vcvc::~digital_ofdm_chanest_vcvc()
+{
+}
+
+void
+digital_ofdm_chanest_vcvc::forecast (int noutput_items, gr_vector_int &ninput_items_required)
+{
+ ninput_items_required[0] = (noutput_items/d_n_data_syms) * (d_n_data_syms + d_n_sync_syms);
+}
+
+
+int
+digital_ofdm_chanest_vcvc::get_carr_offset(const gr_complex *sync_sym1, const gr_complex *sync_sym2)
+{
+ int carr_offset = 0;
+ if (d_corr_v.size()) {
+ // Use Schmidl & Cox method
+ float Bg_max = 0;
+ // g here is 2g in the paper
+ for (int g = d_max_neg_carr_offset; g <= d_max_pos_carr_offset; g += 2) {
+ gr_complex tmp = gr_complex(0, 0);
+ for (int k = 0; k < d_fft_len; k++) {
+ if (d_corr_v[k] != gr_complex(0, 0)) {
+ tmp += std::conj(sync_sym1[k+g]) * std::conj(d_corr_v[k]) * sync_sym2[k+g];
+ }
+ }
+ if (std::abs(tmp) > Bg_max) {
+ Bg_max = std::abs(tmp);
+ carr_offset = g;
+ }
+ }
+ } else {
+ // Correlate
+ std::fill(d_new_symbol_diffs.begin(), d_new_symbol_diffs.end(), 0);
+ for(int i = 0; i < d_fft_len-2; i++) {
+ d_new_symbol_diffs[i] = std::norm(sync_sym1[i] - sync_sym1[i+2]);
+ }
+
+ float sum;
+ float max = 0;
+ for (int g = d_max_neg_carr_offset; g <= d_max_pos_carr_offset; g += 2) {
+ sum = 0;
+ for (int j = 0; j < d_fft_len; j++) {
+ if (d_known_symbol_diffs[j]) {
+ sum += (d_known_symbol_diffs[j] * d_new_symbol_diffs[j + g]);
+ }
+ if(sum > max) {
+ max = sum;
+ carr_offset = g;
+ }
+ }
+ }
+ }
+ return carr_offset;
+}
+
+
+void
+digital_ofdm_chanest_vcvc::get_chan_taps(
+ const gr_complex *sync_sym1,
+ const gr_complex *sync_sym2,
+ int carr_offset,
+ std::vector<gr_complex> &taps)
+{
+ const gr_complex *sym = ((d_n_sync_syms == 2) ? sync_sym2 : sync_sym1);
+ std::fill(taps.begin(), taps.end(), gr_complex(0, 0));
+ int loop_start = 0;
+ int loop_end = d_fft_len;
+ if (carr_offset > 0) {
+ loop_start = carr_offset;
+ } else if (carr_offset < 0) {
+ loop_end = d_fft_len + carr_offset;
+ }
+ for (int i = loop_start; i < loop_end; i++) {
+ if ((d_ref_sym[i-carr_offset] != gr_complex(0, 0))) {
+ taps[i] = sym[i] / d_ref_sym[i-carr_offset];
+ }
+ }
+
+ if (d_interpolate) {
+ for (int i = d_first_active_carrier + 1; i < d_last_active_carrier; i += 2) {
+ taps[i] = (taps[i-1] + taps[i+1]) / gr_complex(2.0, 0);
+ }
+ taps[d_last_active_carrier] = taps[d_last_active_carrier-1];
+ }
+
+ if (d_eq_noise_red_len) {
+ // TODO
+ // 1) IFFT
+ // 2) Set all elements > d_eq_noise_red_len to zero
+ // 3) FFT
+ }
+}
+
+
+// 1) Go through all the frames available on the input buffer
+// 2) Estimate the coarse freq. offset and the eq. taps from the
+// input symbol(s)
+// 3) Copy the data symbols to the output
+// 4) Copy all other tags onto the output. A tag that was on
+// a sync symbol is copied onto the first data symbol.
+// 5) Add the new tags for carrier offset and eq. taps
+int
+digital_ofdm_chanest_vcvc::general_work (int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+{
+ const gr_complex *in = (const gr_complex *) input_items[0];
+ gr_complex *out = (gr_complex *) output_items[0];
+ int n_frames = noutput_items/d_n_data_syms;
+ const int framesize = d_n_sync_syms + d_n_data_syms;
+
+ for (int i = 0; i < n_frames; i++) {
+ int carr_offset = 0;
+ if (d_max_neg_carr_offset || d_max_pos_carr_offset)
+ carr_offset = get_carr_offset(in, in+d_fft_len);
+ std::vector<gr_complex> chan_taps(d_fft_len, 0);
+ get_chan_taps(in, in+d_fft_len, carr_offset, chan_taps);
+
+ memcpy((void *) out,
+ (void *) &in[d_n_sync_syms * d_fft_len],
+ sizeof(gr_complex) * d_fft_len * d_n_data_syms);
+ in += framesize * d_fft_len;
+ out += d_n_data_syms * d_fft_len;
+
+ std::vector<gr_tag_t> tags;
+ this->get_tags_in_range(tags, 0,
+ this->nitems_read(0)+i*framesize,
+ this->nitems_read(0)+(i+1)*framesize);
+ for (unsigned t = 0; t < tags.size(); t++) {
+ int offset = tags[t].offset - (this->nitems_read(0) + i*framesize);
+ if (offset < d_n_sync_syms) {
+ offset = 0;
+ } else {
+ offset -= d_n_sync_syms;
+ }
+ tags[t].offset = offset + this->nitems_written(0) + i*d_n_data_syms;
+ this->add_item_tag(0, tags[t]);
+ }
+
+ this->add_item_tag(0, this->nitems_written(0) + i*d_n_data_syms,
+ pmt::pmt_string_to_symbol("ofdm_sync_carr_offset"),
+ pmt::pmt_from_long(carr_offset));
+ this->add_item_tag(0, this->nitems_written(0) + i*d_n_data_syms,
+ pmt::pmt_string_to_symbol("ofdm_sync_chan_taps"),
+ pmt::pmt_init_c32vector(d_fft_len, chan_taps));
+ }
+
+ consume_each(n_frames * framesize);
+ return n_frames * d_n_data_syms;
+}
+
diff --git a/gr-digital/lib/digital_ofdm_cyclic_prefixer.cc b/gr-digital/lib/digital_ofdm_cyclic_prefixer.cc
index 192af2591d..ada5742a51 100644
--- a/gr-digital/lib/digital_ofdm_cyclic_prefixer.cc
+++ b/gr-digital/lib/digital_ofdm_cyclic_prefixer.cc
@@ -24,47 +24,139 @@
#include "config.h"
#endif
+#include <cmath>
#include <digital_ofdm_cyclic_prefixer.h>
#include <gr_io_signature.h>
digital_ofdm_cyclic_prefixer_sptr
-digital_make_ofdm_cyclic_prefixer (size_t input_size, size_t output_size)
+digital_make_ofdm_cyclic_prefixer (size_t input_size,
+ size_t output_size,
+ int rolloff_len,
+ const std::string &len_tag_key)
{
return gnuradio::get_initial_sptr(new digital_ofdm_cyclic_prefixer (input_size,
- output_size));
+ output_size,
+ rolloff_len,
+ len_tag_key));
}
digital_ofdm_cyclic_prefixer::digital_ofdm_cyclic_prefixer (size_t input_size,
- size_t output_size)
- : gr_sync_interpolator ("ofdm_cyclic_prefixer",
- gr_make_io_signature (1, 1, input_size*sizeof(gr_complex)),
- gr_make_io_signature (1, 1, sizeof(gr_complex)),
- output_size),
- d_input_size(input_size),
- d_output_size(output_size)
+ size_t output_size,
+ int rolloff_len,
+ const std::string &len_tag_key)
+ : gr_tagged_stream_block ("ofdm_cyclic_prefixer",
+ gr_make_io_signature (1, 1, input_size*sizeof(gr_complex)),
+ gr_make_io_signature (1, 1, sizeof(gr_complex)),
+ len_tag_key),
+ d_fft_len(input_size),
+ d_output_size(output_size),
+ d_cp_size(output_size - input_size),
+ d_rolloff_len(rolloff_len),
+ d_up_flank((rolloff_len ? rolloff_len-1 : 0), 0),
+ d_down_flank((rolloff_len ? rolloff_len-1 : 0), 0),
+ d_delay_line(0, 0)
+{
+ set_relative_rate(d_output_size);
+
+ // Flank of length 1 would just be rectangular
+ if (d_rolloff_len == 1) {
+ d_rolloff_len = 0;
+ }
+ if (d_rolloff_len) {
+ d_delay_line.resize(d_rolloff_len-1, 0);
+ if (rolloff_len > d_cp_size) {
+ throw std::invalid_argument("cyclic prefixer: rolloff len must smaller than the cyclic prefix.");
+ }
+ // The actual flanks are one sample shorter than d_rolloff_len, because the
+ // first sample of the up- and down flank is always zero and one, respectively
+ for (int i = 1; i < d_rolloff_len; i++) {
+ d_up_flank[i-1] = 0.5 * (1 + cos(M_PI * i/rolloff_len - M_PI));
+ d_down_flank[i-1] = 0.5 * (1 + cos(M_PI * (rolloff_len-i)/rolloff_len - M_PI));
+ }
+ }
+ if (len_tag_key.empty()) {
+ set_output_multiple(d_output_size);
+ } else {
+ set_tag_propagation_policy(TPP_DONT);
+ }
+}
+
+int
+digital_ofdm_cyclic_prefixer::calculate_output_stream_length(const gr_vector_int &ninput_items)
{
+ int nout = ninput_items[0] * d_output_size + d_delay_line.size();
+ return nout;
}
+// Operates in two ways:
+// - When there's a length tag name specified, operates in packet mode.
+// Here, an entire OFDM frame is processed at once. The final OFDM symbol
+// is postfixed with the delay line of the pulse shape.
+// We manually propagate tags.
+// - Otherwise, we're in freewheeling mode. Process as many OFDM symbols as
+// are space for in the output buffer. The delay line is never flushed.
+// Tags are propagated by the scheduler.
int
digital_ofdm_cyclic_prefixer::work (int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
{
gr_complex *in = (gr_complex *) input_items[0];
gr_complex *out = (gr_complex *) output_items[0];
- size_t cp_size = d_output_size - d_input_size;
- unsigned int i=0, j=0;
+ int symbols_to_read = 0;
- j = cp_size;
- for(i=0; i < d_input_size; i++,j++) {
- out[j] = in[i];
+ // 1) Figure out if we're in freewheeling or packet mode
+ if (!d_length_tag_key_str.empty()) {
+ symbols_to_read = ninput_items[0];
+ noutput_items = symbols_to_read * d_output_size + d_delay_line.size();
+ } else {
+ symbols_to_read = std::min(noutput_items / (int) d_output_size, ninput_items[0]);
+ noutput_items = symbols_to_read * d_output_size;
}
- j = d_input_size - cp_size;
- for(i=0; i < cp_size; i++, j++) {
- out[i] = in[j];
+ // 2) Do the cyclic prefixing and, optionally, the pulse shaping
+ for (int sym_idx = 0; sym_idx < symbols_to_read; sym_idx++) {
+ memcpy((void *)(out + d_cp_size), (void *) in, d_fft_len * sizeof(gr_complex));
+ memcpy((void *) out, (void *) (in + d_fft_len - d_cp_size), d_cp_size * sizeof(gr_complex));
+ if (d_rolloff_len) {
+ for (int i = 0; i < d_rolloff_len-1; i++) {
+ out[i] = out[i] * d_up_flank[i] + d_delay_line[i];
+ d_delay_line[i] = in[i] * d_down_flank[i];
+ }
+ }
+ in += d_fft_len;
+ out += d_output_size;
}
- return d_output_size;
+ // 3) If we're in packet mode:
+ // - flush the delay line, if applicable
+ // - Propagate tags
+ if (!d_length_tag_key_str.empty()) {
+ if (d_rolloff_len) {
+ for (unsigned i = 0; i < d_delay_line.size(); i++) {
+ *out++ = d_delay_line[i];
+ }
+ d_delay_line.assign(d_delay_line.size(), 0);
+ }
+ std::vector<gr_tag_t> tags;
+ get_tags_in_range(
+ tags, 0,
+ nitems_read(0), nitems_read(0)+symbols_to_read
+ );
+ for (unsigned i = 0; i < tags.size(); i++) {
+ tags[i].offset = ((tags[i].offset - nitems_read(0)) * d_output_size) + nitems_written(0);
+ add_item_tag(0,
+ tags[i].offset,
+ tags[i].key,
+ tags[i].value
+ );
+ }
+ } else {
+ consume_each(symbols_to_read);
+ }
+
+ return noutput_items;
}
+
diff --git a/gr-digital/lib/digital_ofdm_equalizer_base.cc b/gr-digital/lib/digital_ofdm_equalizer_base.cc
new file mode 100644
index 0000000000..b4fa5df87e
--- /dev/null
+++ b/gr-digital/lib/digital_ofdm_equalizer_base.cc
@@ -0,0 +1,116 @@
+/* -*- c++ -*- */
+/* Copyright 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "digital_ofdm_equalizer_base.h"
+
+// *** Base class ****************************************************
+digital_ofdm_equalizer_base::digital_ofdm_equalizer_base(int fft_len) :
+ d_fft_len(fft_len),
+ d_carr_offset(0)
+{
+}
+
+
+digital_ofdm_equalizer_base::~digital_ofdm_equalizer_base()
+{
+}
+
+
+// *** Sub-Base class for 1D equalizers using pilot tones *************
+digital_ofdm_equalizer_1d_pilots::digital_ofdm_equalizer_1d_pilots(
+ int fft_len,
+ const std::vector<std::vector<int> > &occupied_carriers,
+ const std::vector<std::vector<int> > &pilot_carriers,
+ const std::vector<std::vector<gr_complex> > &pilot_symbols,
+ int symbols_skipped,
+ bool input_is_shifted)
+ : digital_ofdm_equalizer_base(fft_len),
+ d_occupied_carriers(fft_len, false),
+ d_pilot_carriers(pilot_carriers.size(), std::vector<bool>(fft_len, false)),
+ d_pilot_symbols(pilot_symbols.size(), std::vector<gr_complex>(fft_len, gr_complex(0, 0))),
+ d_symbols_skipped(symbols_skipped),
+ d_pilot_carr_set(symbols_skipped),
+ d_channel_state(fft_len, gr_complex(1, 0))
+{
+ int fft_shift_width = 0;
+ if (input_is_shifted) {
+ fft_shift_width = fft_len/2;
+ }
+ if (!occupied_carriers.size()) {
+ std::fill(d_occupied_carriers.begin(), d_occupied_carriers.end(), true);
+ } else {
+ for (unsigned i = 0; i < occupied_carriers.size(); i++) {
+ for (unsigned k = 0; k < occupied_carriers[i].size(); k++) {
+ int carr_index = occupied_carriers[i][k];
+ if (occupied_carriers[i][k] < 0) {
+ carr_index += fft_len;
+ }
+ if (carr_index >= fft_len || carr_index < 0) {
+ throw std::invalid_argument("data carrier index out of bounds.");
+ }
+ d_occupied_carriers[(carr_index + fft_shift_width) % fft_len] = true;
+ }
+ }
+ }
+ if (pilot_carriers.size()) {
+ for (unsigned i = 0; i < pilot_carriers.size(); i++) {
+ if (pilot_carriers[i].size() != pilot_symbols[i].size()) {
+ throw std::invalid_argument("pilot carriers and -symbols do not match.");
+ }
+ for (unsigned k = 0; k < pilot_carriers[i].size(); k++) {
+ int carr_index = pilot_carriers[i][k];
+ if (pilot_carriers[i][k] < 0) {
+ carr_index += fft_len;
+ }
+ if (carr_index >= fft_len || carr_index < 0) {
+ throw std::invalid_argument("pilot carrier index out of bounds.");
+ }
+ d_pilot_carriers[i][(carr_index + fft_shift_width) % fft_len] = true;
+ d_pilot_symbols[i][(carr_index + fft_shift_width) % fft_len] = pilot_symbols[i][k];
+ }
+ }
+ }
+}
+
+
+digital_ofdm_equalizer_1d_pilots::~digital_ofdm_equalizer_1d_pilots()
+{
+}
+
+
+void
+digital_ofdm_equalizer_1d_pilots::reset()
+{
+ std::fill(d_channel_state.begin(), d_channel_state.end(), gr_complex(1, 0));
+ d_pilot_carr_set = d_symbols_skipped;
+}
+
+
+void digital_ofdm_equalizer_1d_pilots::get_channel_state(std::vector<gr_complex> &taps)
+{
+ taps = d_channel_state;
+}
+
+
diff --git a/gr-digital/lib/digital_ofdm_equalizer_simpledfe.cc b/gr-digital/lib/digital_ofdm_equalizer_simpledfe.cc
new file mode 100644
index 0000000000..9abab8c1dd
--- /dev/null
+++ b/gr-digital/lib/digital_ofdm_equalizer_simpledfe.cc
@@ -0,0 +1,101 @@
+/* -*- c++ -*- */
+/* Copyright 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "digital_ofdm_equalizer_simpledfe.h"
+
+digital_ofdm_equalizer_simpledfe_sptr
+digital_make_ofdm_equalizer_simpledfe(
+ int fft_len,
+ const digital_constellation_sptr &constellation,
+ const std::vector<std::vector<int> > &occupied_carriers,
+ const std::vector<std::vector<int> > &pilot_carriers,
+ const std::vector<std::vector<gr_complex> > &pilot_symbols,
+ int symbols_skipped,
+ float alpha,
+ bool input_is_shifted)
+{
+ return digital_ofdm_equalizer_simpledfe_sptr(new digital_ofdm_equalizer_simpledfe(
+ fft_len,
+ constellation,
+ occupied_carriers,
+ pilot_carriers,
+ pilot_symbols,
+ symbols_skipped,
+ alpha,
+ input_is_shifted));
+}
+
+digital_ofdm_equalizer_simpledfe::digital_ofdm_equalizer_simpledfe(
+ int fft_len,
+ const digital_constellation_sptr &constellation,
+ const std::vector<std::vector<int> > &occupied_carriers,
+ const std::vector<std::vector<int> > &pilot_carriers,
+ const std::vector<std::vector<gr_complex> > &pilot_symbols,
+ int symbols_skipped,
+ float alpha,
+ bool input_is_shifted)
+ : digital_ofdm_equalizer_1d_pilots(fft_len, occupied_carriers, pilot_carriers, pilot_symbols, symbols_skipped, input_is_shifted),
+ d_constellation(constellation),
+ d_alpha(alpha)
+{
+}
+
+
+digital_ofdm_equalizer_simpledfe::~digital_ofdm_equalizer_simpledfe()
+{
+}
+
+
+void
+digital_ofdm_equalizer_simpledfe::equalize(gr_complex *frame,
+ int n_sym,
+ const std::vector<gr_complex> &initial_taps,
+ const std::vector<gr_tag_t> &tags)
+{
+ if (!initial_taps.empty()) {
+ d_channel_state = initial_taps;
+ }
+ gr_complex sym_eq, sym_est;
+
+ for (int i = 0; i < n_sym; i++) {
+ for (int k = 0; k < d_fft_len; k++) {
+ if (!d_occupied_carriers[k]) {
+ continue;
+ }
+ if (d_pilot_carriers.size() && d_pilot_carriers[d_pilot_carr_set][k-d_carr_offset]) {
+ d_channel_state[k] = d_alpha * d_channel_state[k]
+ + (1-d_alpha) * frame[i*d_fft_len + k] / d_pilot_symbols[d_pilot_carr_set][k-d_carr_offset];
+ frame[i*d_fft_len+k] = d_pilot_symbols[d_pilot_carr_set][k-d_carr_offset];
+ } else {
+ sym_eq = frame[i*d_fft_len+k] / d_channel_state[k];
+ d_constellation->map_to_points(d_constellation->decision_maker(&sym_eq), &sym_est);
+ d_channel_state[k] = d_alpha * d_channel_state[k] + frame[i*d_fft_len+k] / sym_est;
+ frame[i*d_fft_len+k] = sym_est;
+ }
+ }
+ d_pilot_carr_set = (d_pilot_carr_set + 1) % d_pilot_carriers.size();
+ }
+}
+
diff --git a/gr-digital/lib/digital_ofdm_equalizer_static.cc b/gr-digital/lib/digital_ofdm_equalizer_static.cc
new file mode 100644
index 0000000000..66903fa90a
--- /dev/null
+++ b/gr-digital/lib/digital_ofdm_equalizer_static.cc
@@ -0,0 +1,90 @@
+/* -*- c++ -*- */
+/* Copyright 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "digital_ofdm_equalizer_static.h"
+
+#include <iostream>
+
+digital_ofdm_equalizer_static_sptr
+digital_make_ofdm_equalizer_static(
+ int fft_len,
+ const std::vector<std::vector<int> > &occupied_carriers,
+ const std::vector<std::vector<int> > &pilot_carriers,
+ const std::vector<std::vector<gr_complex> > &pilot_symbols,
+ int symbols_skipped,
+ bool input_is_shifted)
+{
+ return digital_ofdm_equalizer_static_sptr(new digital_ofdm_equalizer_static(
+ fft_len,
+ occupied_carriers,
+ pilot_carriers,
+ pilot_symbols,
+ symbols_skipped,
+ input_is_shifted));
+}
+
+digital_ofdm_equalizer_static::digital_ofdm_equalizer_static(
+ int fft_len,
+ const std::vector<std::vector<int> > &occupied_carriers,
+ const std::vector<std::vector<int> > &pilot_carriers,
+ const std::vector<std::vector<gr_complex> > &pilot_symbols,
+ int symbols_skipped,
+ bool input_is_shifted)
+ : digital_ofdm_equalizer_1d_pilots(fft_len, occupied_carriers, pilot_carriers, pilot_symbols, symbols_skipped, input_is_shifted)
+{
+}
+
+
+digital_ofdm_equalizer_static::~digital_ofdm_equalizer_static()
+{
+}
+
+
+void
+digital_ofdm_equalizer_static::equalize(gr_complex *frame,
+ int n_sym,
+ const std::vector<gr_complex> &initial_taps,
+ const std::vector<gr_tag_t> &tags)
+{
+ d_channel_state = initial_taps;
+
+ for (int i = 0; i < n_sym; i++) {
+ for (int k = 0; k < d_fft_len; k++) {
+ if (!d_occupied_carriers[k]) {
+ continue;
+ }
+ if (d_pilot_carriers.size() && d_pilot_carriers[d_pilot_carr_set][k-d_carr_offset]) {
+ d_channel_state[k] = frame[i*d_fft_len + k] / d_pilot_symbols[d_pilot_carr_set][k-d_carr_offset];
+ frame[i*d_fft_len+k] = d_pilot_symbols[d_pilot_carr_set][k-d_carr_offset];
+ } else {
+ frame[i*d_fft_len+k] /= d_channel_state[k];
+ }
+ }
+ if (!d_pilot_carriers.empty()) {
+ d_pilot_carr_set = (d_pilot_carr_set + 1) % d_pilot_carriers.size();
+ }
+ }
+}
+
diff --git a/gr-digital/lib/digital_ofdm_sync_sc_cfb.cc b/gr-digital/lib/digital_ofdm_sync_sc_cfb.cc
new file mode 100644
index 0000000000..1085662e1f
--- /dev/null
+++ b/gr-digital/lib/digital_ofdm_sync_sc_cfb.cc
@@ -0,0 +1,109 @@
+/* -*- c++ -*- */
+/* Copyright 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gr_io_signature.h>
+#include "digital_ofdm_sync_sc_cfb.h"
+
+#include <gr_delay.h>
+#include <blocks/conjugate_cc.h>
+#include <blocks/multiply_cc.h>
+#include <filter/fir_filter_ccf.h>
+#include <blocks/complex_to_mag_squared.h>
+#include <filter/fir_filter_fff.h>
+#include <blocks/multiply_ff.h>
+#include <blocks/divide_ff.h>
+#include <blocks/complex_to_arg.h>
+#include <blocks/plateau_detector_fb.h>
+#include <gr_sample_and_hold_ff.h>
+
+// Define this to add a third output for debugging
+//#define SYNC_ADD_DEBUG_OUTPUT
+
+digital_ofdm_sync_sc_cfb_sptr
+digital_make_ofdm_sync_sc_cfb (int fft_len, int cp_len)
+{
+ return gnuradio::get_initial_sptr (new digital_ofdm_sync_sc_cfb(fft_len, cp_len));
+}
+
+
+digital_ofdm_sync_sc_cfb::digital_ofdm_sync_sc_cfb (int fft_len, int cp_len)
+ : gr_hier_block2 ("ofdm_sync_sc_cfb",
+ gr_make_io_signature(1, 1, sizeof (gr_complex)),
+#ifndef SYNC_ADD_DEBUG_OUTPUT
+ gr_make_io_signature2(2, 2, sizeof (float), sizeof (unsigned char)))
+#else
+ gr_make_io_signature3(3, 3, sizeof (float), sizeof (unsigned char), sizeof (float)))
+#endif
+{
+ std::vector<float> ma_taps(fft_len/2, 1.0);
+ gr_delay_sptr delay(gr_make_delay(sizeof(gr_complex), fft_len/2));
+ gr::blocks::conjugate_cc::sptr delay_conjugate(gr::blocks::conjugate_cc::make());
+ gr::blocks::multiply_cc::sptr delay_corr(gr::blocks::multiply_cc::make());
+ gr::filter::fir_filter_ccf::sptr delay_ma(gr::filter::fir_filter_ccf::make(1, std::vector<float>(fft_len/2, 1.0)));
+ gr::blocks::complex_to_mag_squared::sptr delay_magsquare(gr::blocks::complex_to_mag_squared::make());
+ gr::blocks::divide_ff::sptr delay_normalize(gr::blocks::divide_ff::make());
+
+ gr::blocks::complex_to_mag_squared::sptr normalizer_magsquare(gr::blocks::complex_to_mag_squared::make());
+ gr::filter::fir_filter_fff::sptr normalizer_ma(gr::filter::fir_filter_fff::make(1, std::vector<float>(fft_len, 0.5)));
+ gr::blocks::multiply_ff::sptr normalizer_square(gr::blocks::multiply_ff::make());
+
+ gr::blocks::complex_to_arg::sptr peak_to_angle(gr::blocks::complex_to_arg::make());
+ gr_sample_and_hold_ff_sptr sample_and_hold(gr_make_sample_and_hold_ff());
+
+ gr::blocks::plateau_detector_fb::sptr plateau_detector(gr::blocks::plateau_detector_fb::make(cp_len));
+
+ // Delay Path
+ connect(self(), 0, delay, 0);
+ connect(delay, 0, delay_conjugate, 0);
+ connect(delay_conjugate, 0, delay_corr, 1);
+ connect(self(), 0, delay_corr, 0);
+ connect(delay_corr, 0, delay_ma, 0);
+ connect(delay_ma, 0, delay_magsquare, 0);
+ connect(delay_magsquare, 0, delay_normalize, 0);
+ // Energy Path
+ connect(self(), 0, normalizer_magsquare, 0);
+ connect(normalizer_magsquare, 0, normalizer_ma, 0);
+ connect(normalizer_ma, 0, normalizer_square, 0);
+ connect(normalizer_ma, 0, normalizer_square, 1);
+ connect(normalizer_square, 0, delay_normalize, 1);
+ // Fine frequency estimate (output 0)
+ connect(delay_ma, 0, peak_to_angle, 0);
+ connect(peak_to_angle, 0, sample_and_hold, 0);
+ connect(sample_and_hold, 0, self(), 0);
+ // Peak detect (output 1)
+ connect(delay_normalize, 0, plateau_detector, 0);
+ connect(plateau_detector, 0, sample_and_hold, 1);
+ connect(plateau_detector, 0, self(), 1);
+#ifdef SYNC_ADD_DEBUG_OUTPUT
+ // Debugging: timing metric (output 2)
+ connect(delay_normalize, 0, self(), 2);
+#endif
+}
+
+
+digital_ofdm_sync_sc_cfb::~digital_ofdm_sync_sc_cfb()
+{
+}
+
diff --git a/gr-digital/lib/gnuradio-digital.rc.in b/gr-digital/lib/gnuradio-digital.rc.in
new file mode 100644
index 0000000000..3b287f9d62
--- /dev/null
+++ b/gr-digital/lib/gnuradio-digital.rc.in
@@ -0,0 +1,55 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2013 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.
+ */
+
+#include <afxres.h>
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@
+ PRODUCTVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@
+ FILEFLAGSMASK 0x3fL
+#ifndef NDEBUG
+ FILEFLAGS 0x0L
+#else
+ FILEFLAGS 0x1L
+#endif
+ FILEOS VOS__WINDOWS32
+ FILETYPE VFT_DLL
+ FILESUBTYPE VFT2_DRV_INSTALLABLE
+ BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904b0"
+ BEGIN
+ VALUE "FileDescription", "gnuradio-digital"
+ VALUE "FileVersion", "@VERSION@"
+ VALUE "InternalName", "gnuradio-digital.dll"
+ VALUE "LegalCopyright", "Licensed under GPLv3 or any later version"
+ VALUE "OriginalFilename", "gnuradio-digital.dll"
+ VALUE "ProductName", "gnuradio-digital"
+ VALUE "ProductVersion", "@VERSION@"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+ END
diff --git a/gr-digital/lib/header_payload_demux_impl.cc b/gr-digital/lib/header_payload_demux_impl.cc
new file mode 100644
index 0000000000..f79678e903
--- /dev/null
+++ b/gr-digital/lib/header_payload_demux_impl.cc
@@ -0,0 +1,292 @@
+/* -*- c++ -*- */
+/* Copyright 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <climits>
+#include <gr_io_signature.h>
+#include "header_payload_demux_impl.h"
+
+namespace gr {
+ namespace digital {
+
+ enum demux_states_t {
+ STATE_IDLE,
+ STATE_HEADER,
+ STATE_WAIT_FOR_MSG,
+ STATE_PAYLOAD
+ };
+
+#define msg_port_id pmt::mp("header_data")
+
+ header_payload_demux::sptr
+ header_payload_demux::make(
+ int header_len,
+ int items_per_symbol,
+ int guard_interval,
+ const std::string &length_tag_key,
+ const std::string &trigger_tag_key,
+ bool output_symbols,
+ size_t itemsize)
+ {
+ return gnuradio::get_initial_sptr (
+ new header_payload_demux_impl(
+ header_len,
+ items_per_symbol,
+ guard_interval,
+ length_tag_key,
+ trigger_tag_key,
+ output_symbols,
+ itemsize
+ )
+ );
+ }
+
+ header_payload_demux_impl::header_payload_demux_impl(
+ int header_len,
+ int items_per_symbol,
+ int guard_interval,
+ const std::string &length_tag_key,
+ const std::string &trigger_tag_key,
+ bool output_symbols,
+ size_t itemsize
+ ) : gr_block("header_payload_demux",
+ gr_make_io_signature2(1, 2, itemsize, sizeof(char)),
+ gr_make_io_signature(2, 2, (output_symbols ? itemsize * items_per_symbol : itemsize))),
+ d_header_len(header_len),
+ d_items_per_symbol(items_per_symbol),
+ d_gi(guard_interval),
+ d_len_tag_key(pmt::pmt_string_to_symbol(length_tag_key)),
+ d_trigger_tag_key(pmt::pmt_string_to_symbol(trigger_tag_key)),
+ d_output_symbols(output_symbols),
+ d_itemsize(itemsize),
+ d_uses_trigger_tag(!trigger_tag_key.empty()),
+ d_state(STATE_IDLE)
+ {
+ if (d_header_len < 1) {
+ throw std::invalid_argument("Header length must be at least 1 symbol.");
+ }
+ if (d_items_per_symbol < 1 || d_gi < 0 || d_itemsize < 1) {
+ throw std::invalid_argument("Items and symbol sizes must be at least 1.");
+ }
+ set_output_multiple(d_items_per_symbol);
+ message_port_register_in(msg_port_id);
+ }
+
+ header_payload_demux_impl::~header_payload_demux_impl()
+ {
+ }
+
+ void
+ header_payload_demux_impl::forecast (int noutput_items, gr_vector_int &ninput_items_required)
+ {
+ // noutput_items is an integer multiple of d_items_per_symbol!
+ for (unsigned i = 0; i < ninput_items_required.size(); i++) {
+ ninput_items_required[i] =
+ noutput_items / d_items_per_symbol * (d_items_per_symbol + d_gi);
+ }
+ }
+
+ int
+ header_payload_demux_impl::general_work (int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ const unsigned char *in = (const unsigned char *) input_items[0];
+ unsigned char *out_header = (unsigned char *) output_items[0];
+ unsigned char *out_payload = (unsigned char *) output_items[1];
+
+ int nread = 0;
+ bool exit_loop = false;
+
+ int produced_hdr = 0;
+ int produced_payload = 0;
+
+ while (nread < noutput_items && !exit_loop) {
+ switch (d_state) {
+ case STATE_IDLE:
+ // 1) Search for a trigger signal on input 1 (if present)
+ // 2) Search for a trigger tag, make sure it's the first one
+ // The first trigger to be found is used!
+ // 3) Make sure the right number of items is skipped
+ // 4) If trigger found, switch to STATE_HEADER
+ if (find_trigger_signal(nread, noutput_items, input_items)) {
+ d_remaining_symbols = d_header_len;
+ d_state = STATE_HEADER;
+ in += nread * d_itemsize;
+ }
+ break;
+
+ case STATE_HEADER:
+ copy_symbol(in, out_header, 0, nread, produced_hdr);
+ if (d_remaining_symbols == 0) {
+ d_state = STATE_WAIT_FOR_MSG;
+ exit_loop = true;
+ }
+ break;
+
+ case STATE_WAIT_FOR_MSG:
+ // If we're in this state, nread is zero (because previous state exits loop)
+ // 1) Wait for msg (blocking call)
+ // 2) set d_remaining_symbols
+ // 3) Write tags
+ // 4) fall through to next state
+ d_remaining_symbols = -1;
+ if (!parse_header_data_msg()) {
+ exit_loop = true;
+ break;
+ }
+ d_state = STATE_PAYLOAD;
+
+ case STATE_PAYLOAD:
+ copy_symbol(in, out_payload, 1, nread, produced_payload);
+ if (d_remaining_symbols == 0) {
+ d_state = STATE_IDLE;
+ exit_loop = true;
+ }
+ break;
+
+ default:
+ throw std::runtime_error("invalid state");
+ } /* switch */
+ } /* while(nread < noutput_items) */
+
+ if (!d_output_symbols) {
+ produced_hdr *= d_items_per_symbol;
+ produced_payload *= d_items_per_symbol;
+ }
+ produce(0, produced_hdr);
+ produce(1, produced_payload);
+ consume_each (nread);
+ return WORK_CALLED_PRODUCE;
+ } /* general_work() */
+
+
+ bool
+ header_payload_demux_impl::find_trigger_signal(
+ int &pos,
+ int noutput_items,
+ gr_vector_const_void_star &input_items)
+ {
+ if (input_items.size() == 2) {
+ unsigned char *in_trigger = (unsigned char *) input_items[1];
+ for (int i = 0; i < noutput_items; i++) {
+ if (in_trigger[i]) {
+ pos = i;
+ return true;
+ }
+ }
+ }
+ if (d_uses_trigger_tag) {
+ std::vector<gr_tag_t> tags;
+ get_tags_in_range(tags, 0, nitems_read(0), nitems_read(0)+noutput_items);
+ uint64_t min_offset = ULLONG_MAX;
+ int tag_index = -1;
+ for (unsigned i = 0; i < tags.size(); i++) {
+ if (tags[i].key == d_trigger_tag_key && tags[i].offset < min_offset) {
+ tag_index = (int) i;
+ min_offset = tags[i].offset;
+ }
+ }
+ if (tag_index != -1) {
+ pos = min_offset - nitems_read(0);
+ return true;
+ }
+ }
+ pos += noutput_items;
+ return false;
+ }
+
+
+ bool
+ header_payload_demux_impl::parse_header_data_msg()
+ {
+ pmt::pmt_t msg(delete_head_blocking(msg_port_id));
+ if (pmt::pmt_is_integer(msg)) {
+ d_remaining_symbols = pmt::pmt_to_long(msg);
+ add_item_tag(1, nitems_written(1), d_len_tag_key, msg);
+ } else if (pmt::pmt_is_dict(msg)) {
+ pmt::pmt_t dict_items(pmt::pmt_dict_items(msg));
+ while (!pmt::pmt_is_null(dict_items)) {
+ pmt::pmt_t this_item(pmt::pmt_car(dict_items));
+ add_item_tag(1, nitems_written(1), pmt::pmt_car(this_item), pmt::pmt_cdr(this_item));
+ if (pmt::pmt_equal(pmt::pmt_car(this_item), d_len_tag_key)) {
+ d_remaining_symbols = pmt::pmt_to_long(pmt::pmt_cdr(this_item));
+ }
+ dict_items = pmt::pmt_cdr(dict_items);
+ }
+ if (d_remaining_symbols == -1) {
+ throw std::runtime_error("no length tag passed from header data");
+ }
+ } else if (pmt::pmt_is_null(msg)) { // Blocking call was interrupted
+ return false;
+ } else {
+ throw std::runtime_error("Received illegal header data");
+ }
+ return true;
+ }
+
+ void
+ header_payload_demux_impl::copy_symbol(const unsigned char *&in, unsigned char *&out, int port, int &nread, int &nproduced)
+ {
+ std::vector<gr_tag_t> tags;
+ memcpy((void *) out,
+ (void *) (in + d_gi * d_itemsize),
+ d_itemsize * d_items_per_symbol
+ );
+ // Tags on GI
+ get_tags_in_range(tags, 0,
+ nitems_read(0) + nread,
+ nitems_read(0) + nread + d_gi
+ );
+ for (unsigned t = 0; t < tags.size(); t++) {
+ add_item_tag(port,
+ nitems_written(port)+nproduced,
+ tags[t].key,
+ tags[t].value
+ );
+ }
+ // Tags on symbol
+ get_tags_in_range(
+ tags, 0,
+ nitems_read(port) + nread + d_gi,
+ nitems_read(port) + nread + d_gi + d_items_per_symbol
+ );
+ for (unsigned t = 0; t < tags.size(); t++) {
+ add_item_tag(0,
+ tags[t].offset - nitems_read(0)-nread + nitems_written(port)+nproduced,
+ tags[t].key,
+ tags[t].value
+ );
+ }
+ in += d_itemsize * (d_items_per_symbol + d_gi);
+ out += d_items_per_symbol * d_itemsize;
+ nread += d_items_per_symbol + d_gi;
+ nproduced++;
+ d_remaining_symbols--;
+ }
+
+ } /* namespace digital */
+} /* namespace gr */
+
diff --git a/gr-digital/lib/header_payload_demux_impl.h b/gr-digital/lib/header_payload_demux_impl.h
new file mode 100644
index 0000000000..ceab9a8629
--- /dev/null
+++ b/gr-digital/lib/header_payload_demux_impl.h
@@ -0,0 +1,85 @@
+/* -*- c++ -*- */
+/* Copyright 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_DIGITAL_HEADER_PAYLOAD_DEMUX_IMPL_H
+#define INCLUDED_DIGITAL_HEADER_PAYLOAD_DEMUX_IMPL_H
+
+#include <digital/header_payload_demux.h>
+
+namespace gr {
+ namespace digital {
+
+ class header_payload_demux_impl : public header_payload_demux
+ {
+ private:
+ int d_header_len; //! Number of bytes per header
+ int d_items_per_symbol; //! Bytes per symbol
+ int d_gi; //! Bytes per guard interval
+ pmt::pmt_t d_len_tag_key; //! Key of length tag
+ pmt::pmt_t d_trigger_tag_key; //! Key of trigger tag (if used)
+ bool d_output_symbols; //! If true, output is symbols, not items
+ size_t d_itemsize; //! Bytes per item
+ bool d_uses_trigger_tag; //! If a trigger tag is used
+ int d_ninput_items_reqd; //! Helper for forecast()
+ int d_state; //! Current read state
+ int d_remaining_symbols; //! When in payload or header state, the number of symbols still to transmit
+
+ // Helpers to make the state machine more readable
+
+ //! Helper function that does the reading from the msg port
+ bool parse_header_data_msg();
+
+ //! Helper function that returns true if a trigger signal is detected.
+ // Searches input 1 (if active), then the tags. Sets \p pos to the position
+ // of the first tag.
+ bool find_trigger_signal(
+ int &pos,
+ int noutput_items,
+ gr_vector_const_void_star &input_items);
+
+ //! Helper function, copies one symbol from in to out and updates all pointers and counters
+ void copy_symbol(const unsigned char *&in, unsigned char *&out, int port, int &nread, int &nproduced);
+
+ public:
+
+ header_payload_demux_impl(
+ int header_len,
+ int items_per_symbol,
+ int guard_interval,
+ const std::string &length_tag_key,
+ const std::string &trigger_tag_key,
+ bool output_symbols,
+ size_t itemsize);
+ ~header_payload_demux_impl();
+
+ 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);
+ };
+
+ } // namespace digital
+} // namespace gr
+
+#endif /* INCLUDED_DIGITAL_HEADER_PAYLOAD_DEMUX_IMPL_H */
+
diff --git a/gr-digital/lib/ofdm_frame_equalizer_vcvc_impl.cc b/gr-digital/lib/ofdm_frame_equalizer_vcvc_impl.cc
new file mode 100644
index 0000000000..e9391658b6
--- /dev/null
+++ b/gr-digital/lib/ofdm_frame_equalizer_vcvc_impl.cc
@@ -0,0 +1,89 @@
+/* -*- c++ -*- */
+/* Copyright 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gr_io_signature.h>
+#include "ofdm_frame_equalizer_vcvc_impl.h"
+
+namespace gr {
+ namespace digital {
+
+ ofdm_frame_equalizer_vcvc::sptr
+ ofdm_frame_equalizer_vcvc::make(digital_ofdm_equalizer_base_sptr equalizer, const std::string &len_tag_key, bool propagate_channel_state)
+ {
+ return gnuradio::get_initial_sptr (new ofdm_frame_equalizer_vcvc_impl(equalizer, len_tag_key, propagate_channel_state));
+ }
+
+ ofdm_frame_equalizer_vcvc_impl::ofdm_frame_equalizer_vcvc_impl(digital_ofdm_equalizer_base_sptr equalizer, const std::string &len_tag_key, bool propagate_channel_state)
+ : gr_tagged_stream_block("ofdm_frame_equalizer_vcvc",
+ gr_make_io_signature(1, 1, sizeof (gr_complex) * equalizer->fft_len()),
+ gr_make_io_signature(1, 1, sizeof (gr_complex) * equalizer->fft_len()),
+ len_tag_key),
+ d_fft_len(equalizer->fft_len()),
+ d_eq(equalizer),
+ d_propagate_channel_state(propagate_channel_state),
+ d_channel_state(equalizer->fft_len(), gr_complex(1, 0))
+ {}
+
+ ofdm_frame_equalizer_vcvc_impl::~ofdm_frame_equalizer_vcvc_impl()
+ {
+ }
+
+
+ int
+ ofdm_frame_equalizer_vcvc_impl::work(int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ const gr_complex *in = (const gr_complex *) input_items[0];
+ gr_complex *out = (gr_complex *) output_items[0];
+ int carrier_offset = 0;
+
+ std::vector<gr_tag_t> tags;
+ get_tags_in_range(tags, 0, nitems_read(0), nitems_read(0)+1);
+ for (unsigned i = 0; i < tags.size(); i++) {
+ if (pmt::pmt_symbol_to_string(tags[i].key) == "ofdm_sync_chan_taps") {
+ d_channel_state = pmt::pmt_c32vector_elements(tags[i].value);
+ remove_item_tag(0, tags[i]);
+ }
+ }
+
+ memcpy((void *) out, (void *) in, sizeof(gr_complex) * d_fft_len * ninput_items[0]);
+ d_eq->reset();
+ d_eq->set_carrier_offset(carrier_offset);
+ d_eq->equalize(out, ninput_items[0], d_channel_state);
+ d_eq->get_channel_state(d_channel_state);
+ if (d_propagate_channel_state) {
+ add_item_tag(0, nitems_written(0),
+ pmt::pmt_string_to_symbol("ofdm_sync_chan_taps"),
+ pmt::pmt_init_c32vector(d_fft_len, d_channel_state));
+ }
+
+ return ninput_items[0];
+ }
+
+ } /* namespace digital */
+} /* namespace gr */
+
diff --git a/gr-digital/lib/ofdm_frame_equalizer_vcvc_impl.h b/gr-digital/lib/ofdm_frame_equalizer_vcvc_impl.h
new file mode 100644
index 0000000000..cba2d513ea
--- /dev/null
+++ b/gr-digital/lib/ofdm_frame_equalizer_vcvc_impl.h
@@ -0,0 +1,57 @@
+/* -*- c++ -*- */
+/* Copyright 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_DIGITAL_OFDM_FRAME_EQUALIZER_VCVC_IMPL_H
+#define INCLUDED_DIGITAL_OFDM_FRAME_EQUALIZER_VCVC_IMPL_H
+
+#include <digital/ofdm_frame_equalizer_vcvc.h>
+
+namespace gr {
+ namespace digital {
+
+ class ofdm_frame_equalizer_vcvc_impl : public ofdm_frame_equalizer_vcvc
+ {
+ private:
+ const int d_fft_len;
+ digital_ofdm_equalizer_base_sptr d_eq;
+ bool d_propagate_channel_state;
+ std::vector<gr_complex> d_channel_state;
+
+ protected:
+ // This aren't really necessary, so let's override them with nuthin'
+ void remove_length_tags(const std::vector<std::vector<gr_tag_t> > &tags) {};
+ void update_length_tags(int n_produced, int n_ports) {};
+
+ public:
+ ofdm_frame_equalizer_vcvc_impl(digital_ofdm_equalizer_base_sptr equalizer, const std::string &len_tag_key, bool propagate_channel_state);
+ ~ofdm_frame_equalizer_vcvc_impl();
+
+ int work(int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } // namespace digital
+} // namespace gr
+
+#endif /* INCLUDED_DIGITAL_OFDM_FRAME_EQUALIZER_VCVC_IMPL_H */
+
diff --git a/gr-digital/lib/ofdm_serializer_vcc_impl.cc b/gr-digital/lib/ofdm_serializer_vcc_impl.cc
new file mode 100644
index 0000000000..2fdb9bd0e8
--- /dev/null
+++ b/gr-digital/lib/ofdm_serializer_vcc_impl.cc
@@ -0,0 +1,205 @@
+/* -*- c++ -*- */
+/* Copyright 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gr_io_signature.h>
+#include "ofdm_serializer_vcc_impl.h"
+
+namespace gr {
+ namespace digital {
+
+ ofdm_serializer_vcc::sptr
+ ofdm_serializer_vcc::make(
+ int fft_len,
+ const std::vector<std::vector<int> > &occupied_carriers,
+ const std::string &len_tag_key,
+ const std::string &packet_len_tag_key,
+ int symbols_skipped,
+ bool input_is_shifted
+ )
+ {
+ return gnuradio::get_initial_sptr (
+ new ofdm_serializer_vcc_impl(
+ fft_len, occupied_carriers,
+ len_tag_key, packet_len_tag_key,
+ symbols_skipped, input_is_shifted
+ )
+ );
+ }
+
+ ofdm_serializer_vcc::sptr
+ ofdm_serializer_vcc::make(
+ const digital_ofdm_carrier_allocator_cvc_sptr &allocator,
+ const std::string &packet_len_tag_key,
+ int symbols_skipped,
+ bool input_is_shifted
+ )
+ {
+ return gnuradio::get_initial_sptr(
+ new ofdm_serializer_vcc_impl(
+ allocator->fft_len(),
+ allocator->occupied_carriers(),
+ allocator->len_tag_key(),
+ packet_len_tag_key,
+ symbols_skipped,
+ input_is_shifted
+ )
+ );
+ }
+
+ ofdm_serializer_vcc_impl::ofdm_serializer_vcc_impl (
+ int fft_len,
+ const std::vector<std::vector<int> > &occupied_carriers,
+ const std::string &len_tag_key,
+ const std::string &packet_len_tag_key,
+ int symbols_skipped,
+ bool input_is_shifted)
+ : gr_tagged_stream_block ("ofdm_serializer_vcc",
+ gr_make_io_signature(1, 1, sizeof (gr_complex) * fft_len),
+ gr_make_io_signature(1, 1, sizeof (gr_complex)),
+ len_tag_key),
+ d_fft_len(fft_len),
+ d_occupied_carriers(occupied_carriers),
+ d_packet_len_tag_key(pmt::pmt_string_to_symbol(packet_len_tag_key)),
+ d_out_len_tag_key(pmt::pmt_string_to_symbol((packet_len_tag_key.empty() ? len_tag_key : packet_len_tag_key))),
+ d_symbols_skipped(symbols_skipped % occupied_carriers.size()),
+ d_curr_set(symbols_skipped % occupied_carriers.size()),
+ d_symbols_per_set(0)
+ {
+ for (unsigned i = 0; i < d_occupied_carriers.size(); i++) {
+ for (unsigned k = 0; k < d_occupied_carriers[i].size(); k++) {
+ if (d_occupied_carriers[i][k] < 0) {
+ d_occupied_carriers[i][k] += fft_len;
+ }
+ if (d_occupied_carriers[i][k] >= fft_len || d_occupied_carriers[i][k] < 0) {
+ throw std::invalid_argument("ofdm_serializer_vcc: trying to occupy a carrier outside the fft length.");
+ }
+ if (input_is_shifted) {
+ d_occupied_carriers[i][k] = (d_occupied_carriers[i][k] + fft_len) % fft_len;
+ }
+ }
+ }
+
+ for (unsigned i = 0; i < d_occupied_carriers.size(); i++) {
+ d_symbols_per_set += d_occupied_carriers[i].size();
+ }
+ set_relative_rate((double) d_symbols_per_set / d_occupied_carriers.size());
+ set_tag_propagation_policy(TPP_DONT);
+ }
+
+ ofdm_serializer_vcc_impl::~ofdm_serializer_vcc_impl()
+ {
+ }
+
+ int
+ ofdm_serializer_vcc_impl::calculate_output_stream_length(const gr_vector_int &ninput_items)
+ {
+ int nout = (ninput_items[0] / d_occupied_carriers.size()) * d_symbols_per_set;
+ for (unsigned i = 0; i < ninput_items[0] % d_occupied_carriers.size(); i++) {
+ nout += d_occupied_carriers[(i + d_curr_set) % d_occupied_carriers.size()].size();
+ }
+ return nout;
+ }
+
+ void
+ ofdm_serializer_vcc_impl::update_length_tags(int n_produced, int n_ports)
+ {
+ add_item_tag(0, nitems_written(0),
+ d_out_len_tag_key,
+ pmt::pmt_from_long(n_produced)
+ );
+ }
+
+ int
+ ofdm_serializer_vcc_impl::work (int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ const gr_complex *in = (const gr_complex *) input_items[0];
+ gr_complex *out = (gr_complex *) output_items[0];
+ long frame_length = ninput_items[0]; // Input frame
+ long packet_length = 0; // Output frame
+ int carr_offset = 0;
+
+ std::vector<gr_tag_t> tags;
+ // Packet mode
+ if (!d_length_tag_key_str.empty()) {
+ get_tags_in_range(tags, 0, nitems_read(0), nitems_read(0)+1);
+ for (unsigned i = 0; i < tags.size(); i++) {
+ if (pmt::pmt_symbol_to_string(tags[i].key) == "ofdm_sync_carr_offset") {
+ carr_offset = pmt::pmt_to_long(tags[i].value);
+ }
+ if (tags[i].key == d_packet_len_tag_key) {
+ packet_length = pmt::pmt_to_long(tags[i].value);
+ remove_item_tag(0, tags[i]);
+ }
+ }
+ } else {
+ // recalc frame length from noutput_items
+ frame_length = 0;
+ int sym_per_frame = 0;
+ while ((sym_per_frame + d_occupied_carriers[(frame_length + 1) % d_occupied_carriers.size()].size()) < noutput_items) {
+ frame_length++;
+ sym_per_frame += d_occupied_carriers[(frame_length + 1) % d_occupied_carriers.size()].size();
+ }
+ }
+
+ // Copy symbols
+ int n_out_symbols = 0;
+ for (int i = 0; i < frame_length; i++) {
+ // Copy all tags associated with this input OFDM symbol onto the first output symbol
+ get_tags_in_range(tags, 0,
+ nitems_read(0)+i,
+ nitems_read(0)+i+1
+ );
+ for (unsigned t = 0; t < tags.size(); t++) {
+ add_item_tag(0, nitems_written(0)+n_out_symbols,
+ tags[i].key,
+ tags[i].value
+ );
+ }
+ for (unsigned k = 0; k < d_occupied_carriers[d_curr_set].size(); k++) {
+ out[n_out_symbols++] = in[i * d_fft_len + d_occupied_carriers[d_curr_set][k] + carr_offset];
+ }
+ if (packet_length && n_out_symbols > packet_length) {
+ n_out_symbols = packet_length;
+ break;
+ }
+ d_curr_set = (d_curr_set + 1) % d_occupied_carriers.size();
+ }
+
+ // Housekeeping
+ if (d_length_tag_key_str.empty()) {
+ consume_each(frame_length);
+ } else {
+ d_curr_set = d_symbols_skipped;
+ }
+
+ return n_out_symbols;
+ }
+
+ } /* namespace digital */
+} /* namespace gr */
+
diff --git a/gr-digital/lib/ofdm_serializer_vcc_impl.h b/gr-digital/lib/ofdm_serializer_vcc_impl.h
new file mode 100644
index 0000000000..ef2f1c83b1
--- /dev/null
+++ b/gr-digital/lib/ofdm_serializer_vcc_impl.h
@@ -0,0 +1,69 @@
+/* -*- c++ -*- */
+/* Copyright 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_DIGITAL_OFDM_SERIALIZER_VCC_IMPL_H
+#define INCLUDED_DIGITAL_OFDM_SERIALIZER_VCC_IMPL_H
+
+#include <digital/ofdm_serializer_vcc.h>
+
+namespace gr {
+ namespace digital {
+
+ class ofdm_serializer_vcc_impl : public ofdm_serializer_vcc
+ {
+ private:
+ int d_fft_len; //! FFT length
+ std::vector<std::vector<int> > d_occupied_carriers; //! Which carriers/symbols carry data
+ pmt::pmt_t d_packet_len_tag_key; //! Key of the length tag
+ pmt::pmt_t d_out_len_tag_key; //! Key of the length tag
+ const int d_symbols_skipped; //! Start position in d_occupied_carriers
+ int d_curr_set; //! Current position in d_occupied_carriers
+ int d_symbols_per_set;
+
+ protected:
+ /* Calculate the number of scalar complex symbols given a number of
+ * OFDM symbols.
+ */
+ int calculate_output_stream_length(const gr_vector_int &ninput_items);
+ void update_length_tags(int n_produced, int n_ports);
+
+ public:
+ ofdm_serializer_vcc_impl(
+ int fft_len,
+ const std::vector<std::vector<int> > &occupied_carriers,
+ const std::string &len_tag_key,
+ const std::string &packet_len_tag_key,
+ int symbols_skipped,
+ bool input_is_shifted
+ );
+ ~ofdm_serializer_vcc_impl();
+
+ int work(int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } // namespace digital
+} // namespace gr
+
+#endif /* INCLUDED_DIGITAL_OFDM_SERIALIZER_VCC_IMPL_H */
+
diff --git a/gr-digital/lib/packet_header_default.cc b/gr-digital/lib/packet_header_default.cc
new file mode 100644
index 0000000000..dac57512d3
--- /dev/null
+++ b/gr-digital/lib/packet_header_default.cc
@@ -0,0 +1,128 @@
+/* -*- c++ -*- */
+/* Copyright 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <digital/packet_header_default.h>
+
+namespace gr {
+ namespace digital {
+
+ packet_header_default::sptr
+ packet_header_default::make(
+ long header_len,
+ const std::string &len_tag_key,
+ const std::string &num_tag_key,
+ int bits_per_byte)
+ {
+ return packet_header_default::sptr(new packet_header_default(header_len, len_tag_key, num_tag_key, bits_per_byte));
+ }
+
+ const unsigned MASK_LUT[9] = {0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x2F, 0x7F, 0xFF};
+ packet_header_default::packet_header_default(
+ long header_len,
+ const std::string &len_tag_key,
+ const std::string &num_tag_key,
+ int bits_per_byte)
+ : d_header_len(header_len),
+ d_len_tag_key(pmt::pmt_string_to_symbol(len_tag_key)),
+ d_num_tag_key(pmt::pmt_string_to_symbol(num_tag_key)),
+ d_bits_per_byte(bits_per_byte),
+ d_header_number(0)
+ {
+ if (d_bits_per_byte < 1 || d_bits_per_byte > 8) {
+ throw std::invalid_argument("bits_per_byte must be in [1, 8]");
+ }
+ d_mask = MASK_LUT[d_bits_per_byte];
+ }
+
+ packet_header_default::~packet_header_default()
+ {
+ }
+
+ bool packet_header_default::header_formatter(
+ long packet_len,
+ unsigned char *out,
+ const std::vector<gr_tag_t> &tags
+ )
+ {
+ packet_len &= 0x0FFF;
+
+ memset(out, 0x00, d_header_len);
+ int parity = 0;
+ int k = 0; // Position in out
+ for (int i = 0; i < 12 && k < d_header_len; i += d_bits_per_byte, k++) {
+ out[k] = (unsigned char) ((packet_len >> i) & d_mask);
+ parity += out[k];
+ }
+ for (int i = 0; i < 16 && k < d_header_len; i += d_bits_per_byte, k++) {
+ out[k] = (unsigned char) ((d_header_number >> i) & d_mask);
+ parity += out[k];
+ }
+ if (k < d_header_len) {
+ out[k] = (unsigned char) (parity % 2);
+ }
+ d_header_number++;
+
+ return true;
+ }
+
+
+ bool packet_header_default::header_parser(
+ const unsigned char *in,
+ std::vector<gr_tag_t> &tags)
+ {
+ unsigned header_len = 0;
+ unsigned header_num = 0;
+ gr_tag_t tag;
+
+ int k = 0; // Position in "in"
+ for (int i = 0; i < 12 && k < d_header_len; i += d_bits_per_byte, k++) {
+ header_len |= (((int) in[k]) & d_mask) << i;
+ }
+ tag.key = d_len_tag_key;
+ tag.value = pmt::pmt_from_long(header_len);
+ tags.push_back(tag);
+ if (k >= d_header_len) {
+ return true;
+ }
+ for (int i = 0; i < 16 && k < d_header_len; i += d_bits_per_byte, k++) {
+ header_num |= (((int) in[k]) & d_mask) << i;
+ }
+ tag.key = d_num_tag_key;
+ tag.value = pmt::pmt_from_long(header_num);
+ tags.push_back(tag);
+ if (k >= d_header_len) {
+ return true;
+ }
+
+ int parity = in[k];
+ for (int i = 0; i < 28; i++) {
+ parity += in[i];
+ }
+ return !(parity % 2);
+ }
+
+ } /* namespace digital */
+} /* namespace gr */
+
diff --git a/gr-digital/lib/packet_header_ofdm.cc b/gr-digital/lib/packet_header_ofdm.cc
new file mode 100644
index 0000000000..db190c13bb
--- /dev/null
+++ b/gr-digital/lib/packet_header_ofdm.cc
@@ -0,0 +1,115 @@
+/* -*- c++ -*- */
+/* Copyright 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <digital/packet_header_ofdm.h>
+
+namespace gr {
+ namespace digital {
+
+ int _get_header_len_from_occupied_carriers(const std::vector<std::vector<int> > &occupied_carriers, int n_syms)
+ {
+ int header_len = 0;
+ for (int i = 0; i < n_syms; i++) {
+ header_len += occupied_carriers[i].size();
+ }
+
+ return header_len;
+ }
+
+ packet_header_ofdm::sptr
+ packet_header_ofdm::make(
+ const std::vector<std::vector<int> > &occupied_carriers,
+ int n_syms,
+ const std::string &len_tag_key,
+ const std::string &frame_len_tag_key,
+ const std::string &num_tag_key,
+ int bits_per_sym)
+ {
+ return packet_header_ofdm::sptr(
+ new packet_header_ofdm(
+ occupied_carriers, n_syms, len_tag_key, frame_len_tag_key, num_tag_key, bits_per_sym
+ )
+ );
+ }
+
+ packet_header_ofdm::packet_header_ofdm(
+ const std::vector<std::vector<int> > &occupied_carriers,
+ int n_syms,
+ const std::string &len_tag_key,
+ const std::string &frame_len_tag_key,
+ const std::string &num_tag_key,
+ int bits_per_sym)
+ : packet_header_default(
+ _get_header_len_from_occupied_carriers(occupied_carriers, n_syms),
+ len_tag_key,
+ num_tag_key,
+ bits_per_sym),
+ d_frame_len_tag_key(pmt::pmt_string_to_symbol(frame_len_tag_key)),
+ d_occupied_carriers(occupied_carriers),
+ d_syms_per_set(0)
+ {
+ for (unsigned i = 0; i < d_occupied_carriers.size(); i++) {
+ d_syms_per_set += d_occupied_carriers[i].size();
+ }
+ }
+
+ packet_header_ofdm::~packet_header_ofdm()
+ {
+ }
+
+
+ bool packet_header_ofdm::header_parser(
+ const unsigned char *in,
+ std::vector<gr_tag_t> &tags)
+ {
+ if (!packet_header_default::header_parser(in, tags)) {
+ return false;
+ }
+ int packet_len = 0; // # of OFDM symbols
+ for (unsigned i = 0; i < tags.size(); i++) {
+ if (pmt::pmt_equal(tags[i].key, d_len_tag_key)) {
+ packet_len = pmt::pmt_to_long(tags[i].value);
+ break;
+ }
+ }
+
+ int frame_len = packet_len / d_syms_per_set;
+ int k = 0;
+ int i = frame_len * d_syms_per_set;
+ while (i < packet_len) {
+ frame_len++;
+ i += d_occupied_carriers[k].size();
+ }
+ gr_tag_t tag;
+ tag.key = d_frame_len_tag_key;
+ tag.value = pmt::pmt_from_long(frame_len);
+ tags.push_back(tag);
+
+ return true;
+ }
+
+ } /* namespace digital */
+} /* namespace gr */
+
diff --git a/gr-digital/lib/packet_headergenerator_bb_impl.cc b/gr-digital/lib/packet_headergenerator_bb_impl.cc
new file mode 100644
index 0000000000..2698977728
--- /dev/null
+++ b/gr-digital/lib/packet_headergenerator_bb_impl.cc
@@ -0,0 +1,90 @@
+/* -*- c++ -*- */
+/* Copyright 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gr_io_signature.h>
+#include "packet_headergenerator_bb_impl.h"
+
+namespace gr {
+ namespace digital {
+
+ packet_headergenerator_bb::sptr
+ packet_headergenerator_bb::make(const packet_header_default::sptr &header_formatter)
+ {
+ return gnuradio::get_initial_sptr (new packet_headergenerator_bb_impl(header_formatter));
+ }
+
+
+ packet_headergenerator_bb::sptr
+ packet_headergenerator_bb::make(
+ long header_len,
+ const std::string &len_tag_key
+ )
+ {
+ const packet_header_default::sptr header_formatter(
+ new packet_header_default(header_len, len_tag_key)
+ );
+ return gnuradio::get_initial_sptr (new packet_headergenerator_bb_impl(header_formatter));
+ }
+
+
+ packet_headergenerator_bb_impl::packet_headergenerator_bb_impl(
+ const gr::digital::packet_header_default::sptr &header_formatter
+ )
+ : gr_tagged_stream_block("packet_headergenerator_bb_impl",
+ gr_make_io_signature(1, 1, sizeof (char)),
+ gr_make_io_signature(1, 1, sizeof (char)),
+ pmt::pmt_symbol_to_string(header_formatter->len_tag_key())),
+ d_formatter(header_formatter),
+ d_input_size(1),
+ d_header_len(header_formatter->header_len()),
+ d_len_tag_value(pmt::pmt_from_long(d_header_len))
+ {
+ set_output_multiple(d_header_len);
+ // This is the worst case rate, because we don't know the true value, of course
+ set_relative_rate(d_header_len);
+ set_tag_propagation_policy(TPP_DONT);
+ }
+
+ packet_headergenerator_bb_impl::~packet_headergenerator_bb_impl()
+ {
+ }
+
+ int
+ packet_headergenerator_bb_impl::work (int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ unsigned char *out = (unsigned char *) output_items[0];
+ if (!d_formatter->header_formatter(ninput_items[0], out)) {
+ throw std::runtime_error("header formatter returned false.");
+ }
+
+ return d_header_len;
+ }
+
+ } /* namespace digital */
+} /* namespace gr */
+
diff --git a/gr-digital/lib/packet_headergenerator_bb_impl.h b/gr-digital/lib/packet_headergenerator_bb_impl.h
new file mode 100644
index 0000000000..7d2494cf8b
--- /dev/null
+++ b/gr-digital/lib/packet_headergenerator_bb_impl.h
@@ -0,0 +1,55 @@
+/* -*- c++ -*- */
+/* Copyright 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_DIGITAL_PACKET_HEADERGENERATOR_BB_IMPL_H
+#define INCLUDED_DIGITAL_PACKET_HEADERGENERATOR_BB_IMPL_H
+
+#include <digital/packet_headergenerator_bb.h>
+
+namespace gr {
+ namespace digital {
+
+ class packet_headergenerator_bb_impl : public packet_headergenerator_bb
+ {
+ private:
+ gr::digital::packet_header_default::sptr d_formatter;
+ int d_input_size;
+ int d_header_len;
+ pmt::pmt_t d_len_tag_value;
+
+ public:
+ packet_headergenerator_bb_impl(const packet_header_default::sptr &header_formatter);
+ ~packet_headergenerator_bb_impl();
+
+ void remove_length_tags(const std::vector<std::vector<gr_tag_t> > &tags) {};
+ int calculate_output_stream_length(const gr_vector_int &ninput_items) { return d_header_len; };
+
+ int work(int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } // namespace digital
+} // namespace gr
+
+#endif /* INCLUDED_DIGITAL_PACKET_HEADERGENERATOR_BB_IMPL_H */
+
diff --git a/gr-digital/lib/packet_headerparser_b_impl.cc b/gr-digital/lib/packet_headerparser_b_impl.cc
new file mode 100644
index 0000000000..65883f5515
--- /dev/null
+++ b/gr-digital/lib/packet_headerparser_b_impl.cc
@@ -0,0 +1,90 @@
+/* -*- c++ -*- */
+/* Copyright 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gr_io_signature.h>
+#include "packet_headerparser_b_impl.h"
+
+#define msg_port_id pmt::mp("header_data")
+
+namespace gr {
+ namespace digital {
+
+ packet_headerparser_b::sptr
+ packet_headerparser_b::make(long header_len, const std::string &len_tag_key)
+ {
+ const packet_header_default::sptr header_formatter(
+ new packet_header_default(header_len, len_tag_key)
+ );
+ return gnuradio::get_initial_sptr (new packet_headerparser_b_impl(header_formatter));
+ }
+
+ packet_headerparser_b::sptr
+ packet_headerparser_b::make(const gr::digital::packet_header_default::sptr &header_formatter)
+ {
+ return gnuradio::get_initial_sptr (new packet_headerparser_b_impl(header_formatter));
+ }
+
+ packet_headerparser_b_impl::packet_headerparser_b_impl(const gr::digital::packet_header_default::sptr &header_formatter)
+ : gr_sync_block("packet_headerparser_b",
+ gr_make_io_signature(1, 1, sizeof (unsigned char)),
+ gr_make_io_signature(0, 0, 0)),
+ d_header_formatter(header_formatter)
+ {
+ message_port_register_out(msg_port_id);
+ set_output_multiple(header_formatter->header_len());
+ }
+
+ packet_headerparser_b_impl::~packet_headerparser_b_impl()
+ {
+ }
+
+ int
+ packet_headerparser_b_impl::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ const unsigned char *in = (const unsigned char *) input_items[0];
+
+ if (noutput_items < d_header_formatter->header_len()) {
+ return 0;
+ }
+
+ std::vector<gr_tag_t> tags;
+ if (!d_header_formatter->header_parser(in, tags)) {
+ message_port_pub(msg_port_id, pmt::PMT_F);
+ } else {
+ pmt::pmt_t dict(pmt::pmt_make_dict());
+ for (unsigned i = 0; i < tags.size(); i++) {
+ pmt::pmt_dict_add(dict, tags[i].key, tags[i].value);
+ }
+ message_port_pub(msg_port_id, dict);
+ }
+
+ return d_header_formatter->header_len();
+ }
+
+ } /* namespace digital */
+} /* namespace gr */
+
diff --git a/gr-digital/lib/packet_headerparser_b_impl.h b/gr-digital/lib/packet_headerparser_b_impl.h
new file mode 100644
index 0000000000..a7ded1143f
--- /dev/null
+++ b/gr-digital/lib/packet_headerparser_b_impl.h
@@ -0,0 +1,48 @@
+/* -*- c++ -*- */
+/* Copyright 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_DIGITAL_PACKET_HEADERPARSER_B_IMPL_H
+#define INCLUDED_DIGITAL_PACKET_HEADERPARSER_B_IMPL_H
+
+#include <digital/packet_headerparser_b.h>
+
+namespace gr {
+ namespace digital {
+
+ class packet_headerparser_b_impl : public packet_headerparser_b
+ {
+ private:
+ packet_header_default::sptr d_header_formatter;
+
+ public:
+ packet_headerparser_b_impl(const gr::digital::packet_header_default::sptr &header_formatter);
+ ~packet_headerparser_b_impl();
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } // namespace digital
+} // namespace gr
+
+#endif /* INCLUDED_DIGITAL_PACKET_HEADERPARSER_B_IMPL_H */
+
diff --git a/gr-digital/python/CMakeLists.txt b/gr-digital/python/CMakeLists.txt
index 8f2af0664d..f820736c2f 100644
--- a/gr-digital/python/CMakeLists.txt
+++ b/gr-digital/python/CMakeLists.txt
@@ -39,10 +39,12 @@ GR_PYTHON_INSTALL(
ofdm_sync_ml.py
ofdm_sync_pnac.py
ofdm_sync_pn.py
+ ofdm_txrx.py
packet_utils.py
pkt.py
psk.py
qam.py
+ qamlike.py
qpsk.py
DESTINATION ${GR_PYTHON_DIR}/gnuradio/digital
COMPONENT "digital_python"
@@ -54,6 +56,7 @@ GR_PYTHON_INSTALL(
utils/gray_code.py
utils/mod_codes.py
utils/alignment.py
+ utils/tagged_streams.py
DESTINATION ${GR_PYTHON_DIR}/gnuradio/digital/utils
COMPONENT "digital_python"
)
@@ -66,6 +69,12 @@ if(ENABLE_TESTING)
list(APPEND GR_TEST_PYTHON_DIRS
${CMAKE_BINARY_DIR}/gr-digital/python
${CMAKE_BINARY_DIR}/gr-digital/swig
+ ${CMAKE_BINARY_DIR}/gr-fft/python
+ ${CMAKE_BINARY_DIR}/gr-fft/swig
+ ${CMAKE_BINARY_DIR}/gr-blocks/python
+ ${CMAKE_BINARY_DIR}/gr-blocks/swig
+ ${CMAKE_BINARY_DIR}/gr-analog/python
+ ${CMAKE_BINARY_DIR}/gr-analog/swig
)
list(APPEND GR_TEST_TARGET_DEPS gnuradio-digital gnuradio-filter gnuradio-fft)
diff --git a/gr-digital/python/__init__.py b/gr-digital/python/__init__.py
index 3fdbca769a..1c7958f178 100644
--- a/gr-digital/python/__init__.py
+++ b/gr-digital/python/__init__.py
@@ -42,6 +42,7 @@ from ofdm_sync_fixed import *
from ofdm_sync_ml import *
from ofdm_sync_pnac import *
from ofdm_sync_pn import *
+from ofdm_txrx import ofdm_tx, ofdm_rx
import packet_utils
import ofdm_packet_utils
diff --git a/gr-digital/python/ofdm_txrx.py b/gr-digital/python/ofdm_txrx.py
new file mode 100644
index 0000000000..2734e9cc1c
--- /dev/null
+++ b/gr-digital/python/ofdm_txrx.py
@@ -0,0 +1,268 @@
+#
+# Copyright 2005,2006,2007 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.
+#
+"""
+OFDM Transmitter / Receiver hier blocks.
+
+For simple configurations, no need to connect all the relevant OFDM blocks
+to form an OFDM Tx/Rx--simply use these.
+"""
+
+import numpy
+from gnuradio import gr
+import digital_swig as digital
+from utils import tagged_streams
+
+try:
+ # This will work when feature #505 is added.
+ from gnuradio import fft
+ from gnuradio import blocks
+ from gnuradio import analog
+except ImportError:
+ # Until then this will work.
+ import fft_swig as fft
+ import blocks_swig as blocks
+ import analog_swig as analog
+
+_def_fft_len = 64
+_def_cp_len = 16
+_def_frame_length_tag_key = "frame_length"
+_def_packet_length_tag_key = "frame_length"
+_def_packet_num_tag_key = ""
+_def_occupied_carriers=(range(1, 27) + range(38, 64),)
+_def_pilot_carriers=((0,),)
+_def_pilot_symbols=((100,),)
+_seq_seed = 42
+
+def _make_sync_word(fft_len, occupied_carriers, constellation):
+ """ Makes a random sync sequence """
+ occupied_carriers = list(occupied_carriers[0])
+ occupied_carriers = [occupied_carriers[x] + fft_len if occupied_carriers[x] < 0 else occupied_carriers[x] for x in range(len(occupied_carriers))]
+ numpy.random.seed(_seq_seed)
+ sync_sequence = [constellation.map_to_points_v(numpy.random.randint(constellation.arity()))[0] * numpy.sqrt(2) if x in occupied_carriers and x % 3 else 0 for x in range(fft_len)]
+ return sync_sequence
+
+def _get_constellation(bps):
+ """ Returns a modulator block for a given number of bits per symbol """
+ constellation = {
+ 1: digital.constellation_bpsk(),
+ 2: digital.constellation_qpsk(),
+ 3: digital.constellation_8psk()
+ }
+ try:
+ return constellation[bps]
+ except KeyError:
+ print 'Modulation not supported.'
+ exit(1)
+
+class ofdm_tx(gr.hier_block2):
+ """
+ Hierarchical block for OFDM modulation.
+
+ The input is a byte stream (unsigned char) and the
+ output is the complex modulated signal at baseband.
+
+ Args:
+ fft_len: The length of FFT (integer).
+ cp_len: The length of cyclic prefix (integer).
+ occupied_carriers: ??
+ pilot_carriers: ??
+ pilot_symbols: ??
+ length_tag_key: The name of the tag giving packet length.
+ """
+ def __init__(self, fft_len=_def_fft_len, cp_len=_def_cp_len,
+ frame_length_tag_key=_def_frame_length_tag_key,
+ occupied_carriers=_def_occupied_carriers,
+ pilot_carriers=_def_pilot_carriers,
+ pilot_symbols=_def_pilot_symbols,
+ bps_header=1,
+ bps_payload=1,
+ sync_word1=None,
+ sync_word2=None,
+ rolloff=0
+ ):
+ gr.hier_block2.__init__(self, "ofdm_tx",
+ gr.io_signature(1, 1, gr.sizeof_char),
+ gr.io_signature(1, 1, gr.sizeof_gr_complex))
+ self.fft_len = fft_len
+ self.cp_len = cp_len
+ self.frame_length_tag_key = frame_length_tag_key
+ self.occupied_carriers = occupied_carriers
+ self.pilot_carriers = pilot_carriers
+ self.pilot_symbols = pilot_symbols
+ self.bps_header = bps_header
+ self.bps_payload = bps_payload
+ n_sync_words = 1
+ header_constellation = _get_constellation(bps_header)
+ header_mod = digital.chunks_to_symbols_bc(header_constellation.points())
+ self.sync_word1 = sync_word1
+ if sync_word1 is None:
+ self.sync_word1 = _make_sync_word(fft_len, occupied_carriers, header_constellation)
+ else:
+ if len(sync_word1) != self.fft_len:
+ raise ValueError("Length of sync sequence(s) must be FFT length.")
+ total_sync_word = self.sync_word1
+ self.sync_word2 = ()
+ if sync_word2 is not None:
+ if len(sync_word2) != fft_len:
+ raise ValueError("Length of sync sequence(s) must be FFT length.")
+ self.sync_word2 = sync_word2
+ n_sync_words = 2
+ total_sync_word = sync_word1 + sync_word2
+ crc = digital.crc32_bb(False, self.frame_length_tag_key)
+ formatter_object = digital.packet_header_ofdm(
+ occupied_carriers, 1, "", "", "",
+ bps_header
+ )
+ header_gen = digital.packet_headergenerator_bb(formatter_object.base())
+ header_payload_mux = blocks.tagged_stream_mux(gr.sizeof_gr_complex*1, self.frame_length_tag_key)
+ self.connect(self, crc, header_gen, header_mod, (header_payload_mux, 0))
+ payload_constellation = _get_constellation(bps_payload)
+ payload_mod = digital.chunks_to_symbols_bc(payload_constellation.points())
+ self.connect(
+ crc,
+ blocks.repack_bits_bb(8, bps_payload, frame_length_tag_key),
+ payload_mod,
+ (header_payload_mux, 1)
+ )
+ self.connect(payload_mod, gr.tag_debug(gr.sizeof_gr_complex, "pmod"))
+ sync_word_gen = gr.vector_source_c(
+ total_sync_word, True, self.fft_len,
+ tagged_streams.make_lengthtags((n_sync_words,), (0,), self.frame_length_tag_key)
+ )
+ allocator = digital.ofdm_carrier_allocator_cvc(
+ self.fft_len,
+ occupied_carriers=self.occupied_carriers,
+ pilot_carriers=self.pilot_carriers,
+ pilot_symbols=self.pilot_symbols,
+ len_tag_key=self.frame_length_tag_key
+ )
+ syncword_data_mux = blocks.tagged_stream_mux(gr.sizeof_gr_complex*self.fft_len, self.frame_length_tag_key)
+ self.connect(sync_word_gen, (syncword_data_mux, 0))
+ self.connect(header_payload_mux, allocator, (syncword_data_mux, 1))
+ ffter = fft.fft_vcc(self.fft_len, False, (), False)
+ cyclic_prefixer = digital.ofdm_cyclic_prefixer(
+ self.fft_len,
+ self.fft_len+self.cp_len,
+ rolloff,
+ self.frame_length_tag_key
+ )
+ self.connect(syncword_data_mux, ffter, cyclic_prefixer, self)
+
+
+class ofdm_rx(gr.hier_block2):
+ """
+ Hierarchical block for OFDM demodulation.
+
+ The input is a byte stream (unsigned char) and the
+ output is the complex modulated signal at baseband.
+
+ Args:
+ fft_len: The length of FFT (integer).
+ cp_len: The length of cyclic prefix (integer).
+ occupied_carriers: ??
+ pilot_carriers: ??
+ pilot_symbols: ??
+ length_tag_key: The name of the tag giving packet length.
+ """
+ def __init__(self, fft_len=_def_fft_len, cp_len=_def_cp_len,
+ frame_length_tag_key=_def_frame_length_tag_key,
+ packet_length_tag_key=_def_packet_length_tag_key,
+ packet_num_tag_key=_def_packet_num_tag_key,
+ occupied_carriers=_def_occupied_carriers,
+ pilot_carriers=_def_pilot_carriers,
+ pilot_symbols=_def_pilot_symbols,
+ bps_header=1,
+ bps_payload=1,
+ sync_word1=None,
+ sync_word2=None
+ ):
+ gr.hier_block2.__init__(self, "ofdm_rx",
+ gr.io_signature(1, 1, gr.sizeof_gr_complex),
+ gr.io_signature(1, 1, gr.sizeof_char))
+ self.fft_len = fft_len
+ self.cp_len = cp_len
+ self.frame_length_tag_key = frame_length_tag_key
+ self.packet_length_tag_key = packet_length_tag_key
+ self.occupied_carriers = occupied_carriers
+ self.bps_header = bps_header
+ self.bps_payload = bps_payload
+ n_sync_words = 1
+ header_constellation = _get_constellation(bps_header)
+ if sync_word1 is None:
+ self.sync_word1 = _make_sync_word(fft_len, occupied_carriers, header_constellation)
+ else:
+ if len(sync_word1) != self.fft_len:
+ raise ValueError("Length of sync sequence(s) must be FFT length.")
+ self.sync_word1 = sync_word1
+ self.sync_word2 = ()
+ if sync_word2 is not None:
+ if len(sync_word2) != fft_len:
+ raise ValueError("Length of sync sequence(s) must be FFT length.")
+ self.sync_word2 = sync_word2
+ n_sync_words = 2
+ else:
+ sync_word2 = ()
+ # Receiver path
+ sync_detect = digital.ofdm_sync_sc_cfb(fft_len, cp_len)
+ oscillator = analog.frequency_modulator_fc(-2.0 / fft_len)
+ delay = gr.delay(gr.sizeof_gr_complex, fft_len+cp_len)
+ mixer = gr.multiply_cc()
+ hpd = digital.header_payload_demux(n_sync_words, fft_len, cp_len,
+ frame_length_tag_key, "", True)
+ self.connect(self, sync_detect)
+ self.connect((sync_detect, 0), oscillator, (mixer, 0))
+ self.connect(self, delay, (mixer, 1))
+ self.connect(mixer, (hpd, 0))
+ self.connect((sync_detect, 1), (hpd, 1))
+ # Header demodulation
+ header_fft = fft.fft_vcc(self.fft_len, True, (), True)
+ chanest = digital.ofdm_chanest_vcvc(self.sync_word1, self.sync_word2, 1)
+ header_equalizer = digital.ofdm_equalizer_simpledfe(
+ fft_len, header_constellation.base(),
+ occupied_carriers, pilot_carriers, pilot_symbols
+ )
+ header_eq = digital.ofdm_frame_equalizer_vcvc(header_equalizer.base(), frame_length_tag_key, True)
+ header_serializer = digital.ofdm_serializer_vcc(fft_len, occupied_carriers)
+ header_constellation = _get_constellation(bps_header)
+ header_demod = digital.constellation_decoder_cb(header_constellation.base())
+ header_formatter = digital.packet_header_ofdm(
+ occupied_carriers, 1,
+ packet_length_tag_key,
+ frame_length_tag_key,
+ packet_num_tag_key,
+ bps_header
+ )
+ header_parser = digital.packet_headerparser_b(header_formatter.formatter())
+ self.connect((hpd, 0), header_fft, chanest, header_eq, header_serializer, header_demod, header_parser)
+ self.msg_connect(header_parser, "header_data", hpd, "header_data")
+ # Payload demodulation
+ payload_fft = fft.fft_vcc(self.fft_len, True, (), True)
+ payload_equalizer = digital.ofdm_equalizer_simpledfe(
+ fft_len, header_constellation.base(),
+ occupied_carriers, pilot_carriers, pilot_symbols, 1
+ )
+ payload_eq = digital.ofdm_frame_equalizer_vcvc(payload_equalizer.base(), frame_length_tag_key)
+ payload_serializer = digital.ofdm_serializer_vcc(fft_len, occupied_carriers)
+ payload_constellation = _get_constellation(bps_payload)
+ payload_demod = digital.constellation_decoder_cb(payload_constellation.base())
+ bit_packer = blocks.repack_bits_bb(bps_payload, 8, packet_length_tag_key, True)
+ self.connect((hpd, 1), payload_fft, payload_eq, payload_serializer, payload_demod, bit_packer, self)
+
diff --git a/gr-digital/python/qa_constellation.py b/gr-digital/python/qa_constellation.py
index 6962ec6338..ddd8c71e64 100755
--- a/gr-digital/python/qa_constellation.py
+++ b/gr-digital/python/qa_constellation.py
@@ -30,6 +30,7 @@ import digital_swig
# import from local folder
import psk
import qam
+import qamlike
tested_mod_codes = (mod_codes.NO_CODE, mod_codes.GRAY_CODE)
@@ -64,14 +65,19 @@ def threed_constell():
dim = 3
return digital_swig.constellation_calcdist(points, [], rot_sym, dim)
-tested_constellation_info = (
+# A list of tuples for constellation testing. The contents of the
+# tuples are (constructor, poss_args, differential, diff_argname).
+
+# These constellations should lock on well.
+easy_constellation_info = (
(psk.psk_constellation,
- {'m': (2, 4, 8, 16, 32, 64),
+ {'m': (2, 4, 8, 16, ),
'mod_code': tested_mod_codes, },
True, None),
(qam.qam_constellation,
- {'constellation_points': (4, 16, 64),
- 'mod_code': tested_mod_codes, },
+ {'constellation_points': (4,),
+ 'mod_code': tested_mod_codes,
+ 'large_ampls_to_corners': [False],},
True, None),
(digital_swig.constellation_bpsk, {}, True, None),
(digital_swig.constellation_qpsk, {}, False, None),
@@ -81,11 +87,44 @@ tested_constellation_info = (
(threed_constell, {}, True, None),
)
-def tested_constellations():
+# These constellations don't work nicely.
+# We have a lower required error rate.
+medium_constellation_info = (
+ (psk.psk_constellation,
+ {'m': (32, 64),
+ 'mod_code': tested_mod_codes, },
+ True, None),
+ (qam.qam_constellation,
+ {'constellation_points': (16 ,),
+ 'mod_code': tested_mod_codes,
+ 'large_ampls_to_corners': [False, True],},
+ True, None),
+ (qamlike.qam32_holeinside_constellation,
+ {'large_ampls_to_corners': [True]},
+ True, None),
+)
+
+# These constellation are basically broken in our test
+difficult_constellation_info = (
+ (qam.qam_constellation,
+ {'constellation_points': (64,),
+ 'mod_code': tested_mod_codes,
+ 'large_ampls_to_corners': [False, True],},
+ True, None),
+)
+
+def tested_constellations(easy=True, medium=True, difficult=True):
"""
Generator to produce (constellation, differential) tuples for testing purposes.
"""
- for constructor, poss_args, differential, diff_argname in tested_constellation_info:
+ constellation_info = []
+ if easy:
+ constellation_info += easy_constellation_info
+ if medium:
+ constellation_info += medium_constellation_info
+ if difficult:
+ constellation_info += difficult_constellation_info
+ for constructor, poss_args, differential, diff_argname in constellation_info:
if differential:
diff_poss = (True, False)
else:
diff --git a/gr-digital/python/qa_constellation_receiver.py b/gr-digital/python/qa_constellation_receiver.py
index 2d25433b92..37e56b4cf7 100755
--- a/gr-digital/python/qa_constellation_receiver.py
+++ b/gr-digital/python/qa_constellation_receiver.py
@@ -39,7 +39,9 @@ SEED = 1239
# We need this many to let the frequency recovery block converge.
DATA_LENGTH = 2000
# Test fails if fraction of output that is correct is less than this.
-REQ_CORRECT = 0.7
+EASY_REQ_CORRECT = 0.9
+# For constellations that aren't expected to work so well.
+MEDIUM_REQ_CORRECT = 0.8
# CHANNEL PARAMETERS
NOISE_VOLTAGE = 0.01
@@ -78,25 +80,33 @@ class test_constellation_receiver (gr_unittest.TestCase):
self.indices = alignment.random_sample(
self.max_data_length, self.max_num_samples, SEED)
- for constellation, differential in tested_constellations():
- # The constellation_receiver doesn't work for constellations
- # of multple dimensions (i.e. multiple complex numbers to a
- # single symbol).
- # That is not implemented since the receiver has no way of
- # knowing where the beginning of a symbol is.
- # It also doesn't work for non-differential modulation.
- if constellation.dimensionality() != 1 or not differential:
- continue
- data_length = DATA_LENGTH * constellation.bits_per_symbol()
- tb = rec_test_tb(constellation, differential,
- src_data=self.src_data[:data_length])
- tb.run()
- data = tb.dst.data()
- d1 = tb.src_data[:int(len(tb.src_data)*self.ignore_fraction)]
- d2 = data[:int(len(data)*self.ignore_fraction)]
- correct, overlap, offset, indices = alignment.align_sequences(
- d1, d2, indices=self.indices)
- self.assertTrue(correct > REQ_CORRECT)
+ requirements = (
+ (EASY_REQ_CORRECT, tested_constellations(easy=True, medium=False, difficult=False)),
+ (MEDIUM_REQ_CORRECT, tested_constellations(easy=False, medium=True, difficult=False)),
+ )
+ for req_correct, tcs in requirements:
+ for constellation, differential in tcs:
+ # The constellation_receiver doesn't work for constellations
+ # of multple dimensions (i.e. multiple complex numbers to a
+ # single symbol).
+ # That is not implemented since the receiver has no way of
+ # knowing where the beginning of a symbol is.
+ # It also doesn't work for non-differential modulation.
+ if constellation.dimensionality() != 1 or not differential:
+ continue
+ data_length = DATA_LENGTH * constellation.bits_per_symbol()
+ tb = rec_test_tb(constellation, differential,
+ src_data=self.src_data[:data_length])
+ tb.run()
+ data = tb.dst.data()
+ d1 = tb.src_data[:int(len(tb.src_data)*self.ignore_fraction)]
+ d2 = data[:int(len(data)*self.ignore_fraction)]
+ correct, overlap, offset, indices = alignment.align_sequences(
+ d1, d2, indices=self.indices)
+ if correct <= req_correct:
+ print("Constellation is {0}. Differential is {1}. Required correct is {2}. Correct is {3}. FAIL.".
+ format(constellation, differential, req_correct, correct))
+ self.assertTrue(correct > req_correct)
class rec_test_tb (gr.top_block):
diff --git a/gr-digital/python/qa_crc32_bb.py b/gr-digital/python/qa_crc32_bb.py
new file mode 100755
index 0000000000..d63b5e1222
--- /dev/null
+++ b/gr-digital/python/qa_crc32_bb.py
@@ -0,0 +1,149 @@
+#!/usr/bin/env python
+# Copyright 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.
+#
+
+from gnuradio import gr, gr_unittest
+import digital_swig as digital
+try: import pmt
+except: from gruel import pmt
+
+class qa_crc32_bb (gr_unittest.TestCase):
+
+ def setUp (self):
+ self.tb = gr.top_block ()
+
+ def tearDown (self):
+ self.tb = None
+
+ def test_001_crc_len (self):
+ """ Make sure the output of a CRC set is 4 bytes longer than the input. """
+ data = range(16)
+ tag_name = "len"
+ tag = gr.gr_tag_t()
+ tag.offset = 0
+ tag.key = pmt.pmt_string_to_symbol(tag_name)
+ tag.value = pmt.pmt_from_long(len(data))
+ src = gr.vector_source_b(data, False, 1, (tag,))
+ crc = digital.crc32_bb(False, tag_name)
+ sink = gr.vector_sink_b()
+ self.tb.connect(src, crc, sink)
+ self.tb.run()
+ # Check that the packets before crc_check are 4 bytes longer that the input.
+ self.assertEqual(len(data)+4, len(sink.data()))
+
+ def test_002_crc_equal (self):
+ """ Go through CRC set / CRC check and make sure the output
+ is the same as the input. """
+ data = (0, 1, 2, 3, 4, 5, 6, 7, 8)
+ tag_name = "len"
+ tag = gr.gr_tag_t()
+ tag.offset = 0
+ tag.key = pmt.pmt_string_to_symbol(tag_name)
+ tag.value = pmt.pmt_from_long(len(data))
+ src = gr.vector_source_b(data, False, 1, (tag,))
+ crc = digital.crc32_bb(False, tag_name)
+ crc_check = digital.crc32_bb(True, tag_name)
+ sink = gr.vector_sink_b()
+ self.tb.connect(src, crc, crc_check, sink)
+ self.tb.run()
+ # Check that the packets after crc_check are the same as input.
+ self.assertEqual(data, sink.data())
+
+ def test_003_crc_correct_lentag (self):
+ tag_name = "length"
+ pack_len = 8
+ packets = range(pack_len*2)
+ tag1 = gr.gr_tag_t()
+ tag1.offset = 0
+ tag1.key = pmt.pmt_string_to_symbol(tag_name)
+ tag1.value = pmt.pmt_from_long(pack_len)
+ tag2 = gr.gr_tag_t()
+ tag2.offset = pack_len
+ tag2.key = pmt.pmt_string_to_symbol(tag_name)
+ tag2.value = pmt.pmt_from_long(pack_len)
+ testtag1 = gr.gr_tag_t()
+ testtag1.offset = 1
+ testtag1.key = pmt.pmt_string_to_symbol("tag1")
+ testtag1.value = pmt.pmt_from_long(0)
+ testtag2 = gr.gr_tag_t()
+ testtag2.offset = pack_len
+ testtag2.key = pmt.pmt_string_to_symbol("tag2")
+ testtag2.value = pmt.pmt_from_long(0)
+ testtag3 = gr.gr_tag_t()
+ testtag3.offset = len(packets)-1
+ testtag3.key = pmt.pmt_string_to_symbol("tag3")
+ testtag3.value = pmt.pmt_from_long(0)
+ src = gr.vector_source_b(packets, False, 1, (tag1, tag2, testtag1, testtag2, testtag3))
+ crc = digital.crc32_bb(False, tag_name)
+ sink = gr.vector_sink_b()
+ self.tb.connect(src, crc, sink)
+ self.tb.run()
+ self.assertEqual(len(sink.data()), 2*(pack_len+4))
+ correct_offsets = {'tag1': 1, 'tag2': 12, 'tag3': 19}
+ tags_found = {'tag1': False, 'tag2': False, 'tag3': False}
+ for tag in sink.tags():
+ key = pmt.pmt_symbol_to_string(tag.key)
+ if key in correct_offsets.keys():
+ tags_found[key] = True
+ self.assertEqual(correct_offsets[key], tag.offset)
+ if key == tag_name:
+ self.assertTrue(tag.offset == 0 or tag.offset == pack_len+4)
+ self.assertTrue(all(tags_found.values()))
+
+
+ def test_004_fail (self):
+ """ Corrupt the data and make sure it fails CRC test. """
+ data = (0, 1, 2, 3, 4, 5, 6, 7)
+ tag_name = "len"
+ tag = gr.gr_tag_t()
+ tag.offset = 0
+ tag.key = pmt.pmt_string_to_symbol(tag_name)
+ tag.value = pmt.pmt_from_long(len(data))
+ src = gr.vector_source_b(data, False, 1, (tag,))
+ crc = digital.crc32_bb(False, tag_name)
+ crc_check = digital.crc32_bb(True, tag_name)
+ corruptor = gr.add_const_bb(1)
+ sink = gr.vector_sink_b()
+ self.tb.connect(src, crc, corruptor, crc_check, sink)
+ self.tb.run()
+ # crc_check will drop invalid packets
+ self.assertEqual(len(sink.data()), 0)
+
+ def test_005_tag_propagation (self):
+ """ Make sure tags on the CRC aren't lost. """
+ data = (0, 1, 2, 3, 4, 5, 6, 7, 8, 230, 166, 39, 8)
+ tag_name = "len"
+ tag = gr.gr_tag_t()
+ tag.offset = 0
+ tag.key = pmt.pmt_string_to_symbol(tag_name)
+ tag.value = pmt.pmt_from_long(len(data))
+ testtag = gr.gr_tag_t()
+ testtag.offset = len(data)-1
+ testtag.key = pmt.pmt_string_to_symbol('tag1')
+ testtag.value = pmt.pmt_from_long(0)
+ src = gr.vector_source_b(data, False, 1, (tag, testtag))
+ crc_check = digital.crc32_bb(True, tag_name)
+ sink = gr.vector_sink_b()
+ self.tb.connect(src, crc_check, sink)
+ self.tb.run()
+ self.assertEqual([len(data)-5,], [tag.offset for tag in sink.tags() if pmt.pmt_symbol_to_string(tag.key) == 'tag1'])
+
+if __name__ == '__main__':
+ gr_unittest.run(qa_crc32_bb, "qa_crc32_bb.xml")
diff --git a/gr-digital/python/qa_header_payload_demux.py b/gr-digital/python/qa_header_payload_demux.py
new file mode 100755
index 0000000000..15b3eadcf8
--- /dev/null
+++ b/gr-digital/python/qa_header_payload_demux.py
@@ -0,0 +1,78 @@
+#!/usr/bin/env python
+# Copyright 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.
+#
+
+from gnuradio import gr, gr_unittest
+try: import pmt
+except: from gruel import pmt
+import digital_swig as digital
+import time
+
+class qa_header_payload_demux (gr_unittest.TestCase):
+
+ def setUp (self):
+ self.tb = gr.top_block ()
+
+ def tearDown (self):
+ self.tb = None
+
+ def test_001_t (self):
+ """ Simplest possible test: put in zeros, then header,
+ then payload, trigger signal, try to demux.
+ The return signal from the header parser is faked via _post()
+ """
+ n_zeros = 100
+ header = (1, 2, 3)
+ payload = tuple(range(17))
+ data_signal = (0,) * n_zeros + header + payload
+ trigger_signal = [0,] * len(data_signal)
+ trigger_signal[n_zeros] = 1
+
+ data_src = gr.vector_source_f(data_signal, False)
+ trigger_src = gr.vector_source_b(trigger_signal, False)
+ hpd = digital.header_payload_demux(
+ len(header), 1, 0, "frame_len", "detect", False, gr.sizeof_float
+ )
+ self.assertEqual(pmt.pmt_length(hpd.message_ports_in()), 1)
+ header_sink = gr.vector_sink_f()
+ payload_sink = gr.vector_sink_f()
+
+ self.tb.connect(data_src, (hpd, 0))
+ self.tb.connect(trigger_src, (hpd, 1))
+ self.tb.connect((hpd, 0), header_sink)
+ self.tb.connect((hpd, 1), payload_sink)
+ self.tb.start()
+ time.sleep(.2) # Need this, otherwise, the next message is ignored
+ hpd.to_basic_block()._post(
+ pmt.pmt_intern('header_data'),
+ pmt.pmt_from_long(len(payload))
+ )
+ while len(payload_sink.data()) < len(payload):
+ time.sleep(.2)
+ self.tb.stop()
+ self.tb.wait()
+
+ self.assertEqual(header_sink.data(), header)
+ self.assertEqual(payload_sink.data(), payload)
+
+
+if __name__ == '__main__':
+ gr_unittest.run(qa_header_payload_demux, "qa_header_payload_demux.xml")
+
diff --git a/gr-digital/python/qa_ofdm_carrier_allocator_cvc.py b/gr-digital/python/qa_ofdm_carrier_allocator_cvc.py
new file mode 100755
index 0000000000..1b013865f4
--- /dev/null
+++ b/gr-digital/python/qa_ofdm_carrier_allocator_cvc.py
@@ -0,0 +1,154 @@
+#!/usr/bin/env python
+# Copyright 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.
+#
+
+from gnuradio import gr, gr_unittest
+try: import pmt
+except: from gruel import pmt
+import digital_swig as digital
+
+class qa_digital_carrier_allocator_cvc (gr_unittest.TestCase):
+
+ def setUp (self):
+ self.tb = gr.top_block ()
+
+ def tearDown (self):
+ self.tb = None
+
+ def test_001_t (self):
+ """
+ pretty simple
+ """
+ fft_len = 6
+ tx_symbols = (1, 2, 3)
+ pilot_symbols = ((1j,),)
+ occupied_carriers = ((0, 1, 2),)
+ pilot_carriers = ((3,),)
+ expected_result = (1, 2, 3, 1j, 0, 0)
+ tag_name = "len"
+ tag = gr.gr_tag_t()
+ tag.offset = 0
+ tag.key = pmt.pmt_string_to_symbol(tag_name)
+ tag.value = pmt.pmt_from_long(len(tx_symbols))
+ src = gr.vector_source_c(tx_symbols, False, 1, (tag,))
+ alloc = digital.ofdm_carrier_allocator_cvc(fft_len,
+ occupied_carriers,
+ pilot_carriers,
+ pilot_symbols,
+ tag_name)
+ sink = gr.vector_sink_c(fft_len)
+ self.tb.connect(src, alloc, sink)
+ self.tb.run ()
+ self.assertEqual(sink.data(), expected_result)
+
+ def test_002_t (self):
+ """
+ same, but using negative carrier indices
+ """
+ fft_len = 6
+ tx_symbols = (1, 2, 3)
+ pilot_symbols = ((1j,),)
+ occupied_carriers = ((-1, 1, 2),)
+ pilot_carriers = ((3,),)
+ expected_result = (0, 2, 3, 1j, 0, 1)
+ tag_name = "len"
+ tag = gr.gr_tag_t()
+ tag.offset = 0
+ tag.key = pmt.pmt_string_to_symbol(tag_name)
+ tag.value = pmt.pmt_from_long(len(tx_symbols))
+ src = gr.vector_source_c(tx_symbols, False, 1, (tag,))
+ alloc = digital.ofdm_carrier_allocator_cvc(fft_len,
+ occupied_carriers,
+ pilot_carriers,
+ pilot_symbols,
+ tag_name)
+ sink = gr.vector_sink_c(fft_len)
+ self.tb.connect(src, alloc, sink)
+ self.tb.run ()
+ self.assertEqual(sink.data(), expected_result)
+
+ def test_003_t (self):
+ """
+ more advanced:
+ - 6 symbols per carrier
+ - 2 pilots per carrier
+ - have enough data for nearly 3 OFDM symbols
+ - send that twice
+ - add some random tags
+ """
+ tx_symbols = range(1, 16); # 15 symbols
+ pilot_symbols = ((1j, 2j), (3j, 4j))
+ occupied_carriers = ((1, 3, 4, 11, 12, 14), (1, 2, 4, 11, 13, 14),)
+ pilot_carriers = ((2, 13), (3, 12))
+ expected_result = (0, 1, 1j, 2, 3, 0, 0, 0, 0, 0, 0, 4, 5, 2j, 6, 0,
+ 0, 7, 8, 3j, 9, 0, 0, 0, 0, 0, 0, 10, 4j, 11, 12, 0,
+ 0, 13, 1j, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 2j, 0, 0)
+ fft_len = 16
+ tag_name = "len"
+ tag1 = gr.gr_tag_t()
+ tag1.offset = 0
+ tag1.key = pmt.pmt_string_to_symbol(tag_name)
+ tag1.value = pmt.pmt_from_long(len(tx_symbols))
+ tag2 = gr.gr_tag_t()
+ tag2.offset = len(tx_symbols)
+ tag2.key = pmt.pmt_string_to_symbol(tag_name)
+ tag2.value = pmt.pmt_from_long(len(tx_symbols))
+ testtag1 = gr.gr_tag_t()
+ testtag1.offset = 0
+ testtag1.key = pmt.pmt_string_to_symbol('tag1')
+ testtag1.value = pmt.pmt_from_long(0)
+ testtag2 = gr.gr_tag_t()
+ testtag2.offset = 7 # On the 2nd OFDM symbol
+ testtag2.key = pmt.pmt_string_to_symbol('tag2')
+ testtag2.value = pmt.pmt_from_long(0)
+ testtag3 = gr.gr_tag_t()
+ testtag3.offset = len(tx_symbols)+1 # First OFDM symbol of packet 2
+ testtag3.key = pmt.pmt_string_to_symbol('tag3')
+ testtag3.value = pmt.pmt_from_long(0)
+ testtag4 = gr.gr_tag_t()
+ testtag4.offset = 2*len(tx_symbols)-1 # Last OFDM symbol of packet 2
+ testtag4.key = pmt.pmt_string_to_symbol('tag4')
+ testtag4.value = pmt.pmt_from_long(0)
+ src = gr.vector_source_c(tx_symbols * 2, False, 1, (tag1, tag2, testtag1, testtag2, testtag3, testtag4))
+ alloc = digital.ofdm_carrier_allocator_cvc(fft_len,
+ occupied_carriers,
+ pilot_carriers,
+ pilot_symbols,
+ tag_name)
+ sink = gr.vector_sink_c(fft_len)
+ self.tb.connect(src, alloc, sink)
+ self.tb.run ()
+ self.assertEqual(sink.data(), expected_result * 2)
+ tags_found = {'tag1': False, 'tag2': False, 'tag3': False, 'tag4': False}
+ correct_offsets = {'tag1': 0, 'tag2': 1, 'tag3': 3, 'tag4': 5}
+ for tag in sink.tags():
+ key = pmt.pmt_symbol_to_string(tag.key)
+ if key in tags_found.keys():
+ tags_found[key] = True
+ self.assertEqual(correct_offsets[key], tag.offset)
+ if key == tag_name:
+ self.assertTrue(tag.offset == 0 or tag.offset == 3)
+ self.assertTrue(pmt.pmt_to_long(tag.value) == 3)
+ self.assertTrue(all(tags_found.values()))
+
+
+if __name__ == '__main__':
+ gr_unittest.run(qa_digital_carrier_allocator_cvc, "qa_digital_carrier_allocator_cvc.xml")
+
diff --git a/gr-digital/python/qa_ofdm_chanest_vcvc.py b/gr-digital/python/qa_ofdm_chanest_vcvc.py
new file mode 100755
index 0000000000..c78f8fccfc
--- /dev/null
+++ b/gr-digital/python/qa_ofdm_chanest_vcvc.py
@@ -0,0 +1,282 @@
+#!/usr/bin/env python
+# Copyright 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.
+#
+
+from gnuradio import gr, gr_unittest
+try: import pmt
+except: from gruel import pmt
+import digital_swig as digital
+import sys
+import numpy
+import random
+
+def shift_tuple(vec, N):
+ """ Shifts a vector by N elements. Fills up with zeros. """
+ if N > 0:
+ return (0,) * N + tuple(vec[0:-N])
+ else:
+ N = -N
+ return tuple(vec[N:]) + (0,) * N
+
+def rand_range(min_val, max_val):
+ """ Returns a random value (uniform) from the interval min_val, max_val """
+ return random.random() * (max_val - min_val) + min_val
+
+
+class qa_ofdm_sync_eqinit_vcvc (gr_unittest.TestCase):
+
+ def setUp (self):
+ self.tb = gr.top_block ()
+
+ def tearDown (self):
+ self.tb = None
+
+ def test_001_offset_2sym (self):
+ """ Add a frequency offset, check if it's correctly detected.
+ Also add some random tags and see if they come out at the correct
+ position. """
+ fft_len = 16
+ carr_offset = -2
+ sync_symbol1 = (0, 0, 0, 1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, 0)
+ sync_symbol2 = (0, 0, 0, 1, -1, 1, -1, 1, 0, 1, -1, -1, -1, 1, 0, 0)
+ data_symbol = (0, 0, 0, 1, -1, 1, -1, 1, 0, 1, -1, -1, -1, 1, 0, 0)
+ tx_data = shift_tuple(sync_symbol1, carr_offset) + \
+ shift_tuple(sync_symbol2, carr_offset) + \
+ shift_tuple(data_symbol, carr_offset)
+ tag1 = gr.gr_tag_t()
+ tag1.offset = 0
+ tag1.key = pmt.pmt_string_to_symbol("test_tag_1")
+ tag1.value = pmt.pmt_from_long(23)
+ tag2 = gr.gr_tag_t()
+ tag2.offset = 2
+ tag2.key = pmt.pmt_string_to_symbol("test_tag_2")
+ tag2.value = pmt.pmt_from_long(42)
+ src = gr.vector_source_c(tx_data, False, fft_len, (tag1, tag2))
+ chanest = digital.ofdm_chanest_vcvc(sync_symbol1, sync_symbol2, 1)
+ sink = gr.vector_sink_c(fft_len)
+ self.tb.connect(src, chanest, sink)
+ self.tb.run()
+ self.assertEqual(shift_tuple(sink.data(), -carr_offset), data_symbol)
+ tags = sink.tags()
+ detected_tags = {
+ 'ofdm_sync_carr_offset': False,
+ 'test_tag_1': False,
+ 'test_tag_2': False
+ }
+ for tag in tags:
+ if pmt.pmt_symbol_to_string(tag.key) == 'ofdm_sync_carr_offset':
+ carr_offset_hat = pmt.pmt_to_long(tag.value)
+ self.assertEqual(pmt.pmt_to_long(tag.value), carr_offset)
+ if pmt.pmt_symbol_to_string(tag.key) == 'test_tag_1':
+ self.assertEqual(tag.offset, 0)
+ if pmt.pmt_symbol_to_string(tag.key) == 'test_tag_2':
+ self.assertEqual(tag.offset, 0)
+ detected_tags[pmt.pmt_symbol_to_string(tag.key)] = True
+ self.assertTrue(all(detected_tags.values()))
+
+ def test_002_offset_1sym (self):
+ """ Add a frequency offset, check if it's correctly detected.
+ Difference to previous test is, it only uses one synchronisation symbol. """
+ fft_len = 16
+ carr_offset = -2
+ # This will not correct for +2 because it thinks carrier 14 is used
+ # (because of interpolation)
+ sync_symbol = (0, 0, 0, 1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, 0)
+ data_symbol = (0, 0, 0, 1, -1, 1, -1, 1, 0, 1, -1, -1, -1, 1, 0, 0)
+ tx_data = shift_tuple(sync_symbol, carr_offset) + \
+ shift_tuple(data_symbol, carr_offset)
+ src = gr.vector_source_c(tx_data, False, fft_len)
+ # 17 is out of bounds!
+ chanest = digital.ofdm_chanest_vcvc(sync_symbol, (), 1, 0, 17)
+ sink = gr.vector_sink_c(fft_len)
+ self.tb.connect(src, chanest, sink)
+ self.tb.run()
+ self.assertEqual(shift_tuple(sink.data(), -carr_offset), data_symbol)
+ tags = sink.tags()
+ for tag in tags:
+ if pmt.pmt_symbol_to_string(tag.key) == 'ofdm_sync_carr_offset':
+ carr_offset_hat = pmt.pmt_to_long(tag.value)
+ self.assertEqual(pmt.pmt_to_long(tag.value), carr_offset)
+
+ def test_003_channel_no_carroffset (self):
+ """ Add a channel, check if it's correctly estimated """
+ fft_len = 16
+ carr_offset = 0
+ sync_symbol1 = (0, 0, 0, 1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, 0)
+ sync_symbol2 = (0, 0, 0, 1j, -1, 1, -1j, 1j, 0, 1, -1j, -1, -1j, 1, 0, 0)
+ data_symbol = (0, 0, 0, 1, -1, 1, -1, 1, 0, 1, -1, -1, -1, 1, 0, 0)
+ tx_data = sync_symbol1 + sync_symbol2 + data_symbol
+ channel = (0, 0, 0, 2, -2, 2, 3j, 2, 0, 2, 2, 2, 2, 3, 0, 0)
+ src = gr.vector_source_c(tx_data, False, fft_len)
+ chan = gr.multiply_const_vcc(channel)
+ chanest = digital.ofdm_chanest_vcvc(sync_symbol1, sync_symbol2, 1)
+ sink = gr.vector_sink_c(fft_len)
+ self.tb.connect(src, chan, chanest, sink)
+ self.tb.run()
+ tags = sink.tags()
+ self.assertEqual(shift_tuple(sink.data(), -carr_offset), tuple(numpy.multiply(data_symbol, channel)))
+ for tag in tags:
+ if pmt.pmt_symbol_to_string(tag.key) == 'ofdm_sync_carr_offset':
+ self.assertEqual(pmt.pmt_to_long(tag.value), carr_offset)
+ if pmt.pmt_symbol_to_string(tag.key) == 'ofdm_sync_chan_taps':
+ self.assertEqual(pmt.pmt_c32vector_elements(tag.value), channel)
+
+ def test_004_channel_no_carroffset_1sym (self):
+ """ Add a channel, check if it's correctly estimated.
+ Only uses 1 synchronisation symbol. """
+ fft_len = 16
+ carr_offset = 0
+ sync_symbol = (0, 0, 0, 1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, 0)
+ data_symbol = (0, 0, 0, 1, -1, 1, -1, 1, 0, 1, -1, -1, -1, 1, 0, 0)
+ tx_data = sync_symbol + data_symbol
+ channel = (0, 0, 0, 2, 2, 2, 2.5, 3, 2.5, 2, 2.5, 3, 2, 1, 1, 0)
+ src = gr.vector_source_c(tx_data, False, fft_len)
+ chan = gr.multiply_const_vcc(channel)
+ chanest = digital.ofdm_chanest_vcvc(sync_symbol, (), 1)
+ sink = gr.vector_sink_c(fft_len)
+ self.tb.connect(src, chan, chanest, sink)
+ self.tb.run()
+ tags = sink.tags()
+ for tag in tags:
+ if pmt.pmt_symbol_to_string(tag.key) == 'ofdm_sync_carr_offset':
+ self.assertEqual(pmt.pmt_to_long(tag.value), carr_offset)
+ if pmt.pmt_symbol_to_string(tag.key) == 'ofdm_sync_chan_taps':
+ self.assertEqual(pmt.pmt_c32vector_elements(tag.value), channel)
+
+ def test_005_both_1sym_force (self):
+ """ Add a channel, check if it's correctly estimated.
+ Only uses 1 synchronisation symbol. """
+ fft_len = 16
+ carr_offset = 0
+ sync_symbol = (0, 0, 0, 1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, 0)
+ ref_symbol = (0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0)
+ data_symbol = (0, 0, 0, 1, -1, 1, -1, 1, 0, 1, -1, -1, -1, 1, 0, 0)
+ tx_data = sync_symbol + data_symbol
+ channel = (0, 0, 0, 2, 2, 2, 2.5, 3, 2.5, 2, 2.5, 3, 2, 1, 1, 0)
+ src = gr.vector_source_c(tx_data, False, fft_len)
+ chan = gr.multiply_const_vcc(channel)
+ chanest = digital.ofdm_chanest_vcvc(sync_symbol, ref_symbol, 1)
+ sink = gr.vector_sink_c(fft_len)
+ self.tb.connect(src, chan, chanest, sink)
+ self.tb.run()
+ tags = sink.tags()
+ for tag in tags:
+ if pmt.pmt_symbol_to_string(tag.key) == 'ofdm_sync_carr_offset':
+ self.assertEqual(pmt.pmt_to_long(tag.value), carr_offset)
+ if pmt.pmt_symbol_to_string(tag.key) == 'ofdm_sync_chan_taps':
+ self.assertEqual(pmt.pmt_c32vector_elements(tag.value), channel)
+
+ def test_006_channel_and_carroffset (self):
+ """ Add a channel, check if it's correctly estimated """
+ fft_len = 16
+ carr_offset = 2
+ # Index 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
+ sync_symbol1 = (0, 0, 0, 1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, 0)
+ sync_symbol2 = (0, 0, 0, 1j, -1, 1, -1j, 1j, 0, 1, -1j, -1, -1j, 1, 0, 0)
+ data_symbol = (0, 0, 0, 1, -1, 1, -1, 1, 0, 1, -1, -1, -1, 1, 0, 0)
+ # Channel 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
+ # Shifted (0, 0, 0, 0, 0, 1j, -1, 1, -1j, 1j, 0, 1, -1j, -1, -1j, 1)
+ tx_data = shift_tuple(sync_symbol1, carr_offset) + \
+ shift_tuple(sync_symbol2, carr_offset) + \
+ shift_tuple(data_symbol, carr_offset)
+ channel = range(fft_len)
+ src = gr.vector_source_c(tx_data, False, fft_len)
+ chan = gr.multiply_const_vcc(channel)
+ chanest = digital.ofdm_chanest_vcvc(sync_symbol1, sync_symbol2, 1)
+ sink = gr.vector_sink_c(fft_len)
+ self.tb.connect(src, chan, chanest, sink)
+ self.tb.run()
+ tags = sink.tags()
+ chan_est = None
+ for tag in tags:
+ if pmt.pmt_symbol_to_string(tag.key) == 'ofdm_sync_carr_offset':
+ self.assertEqual(pmt.pmt_to_long(tag.value), carr_offset)
+ if pmt.pmt_symbol_to_string(tag.key) == 'ofdm_sync_chan_taps':
+ chan_est = pmt.pmt_c32vector_elements(tag.value)
+ for i in range(fft_len):
+ if shift_tuple(sync_symbol2, carr_offset)[i]: # Only here the channel can be estimated
+ self.assertEqual(chan_est[i], channel[i])
+ self.assertEqual(sink.data(), tuple(numpy.multiply(shift_tuple(data_symbol, carr_offset), channel)))
+
+
+ def test_999_all_at_once(self):
+ """docstring for test_999_all_at_once"""
+ fft_len = 32
+ # 6 carriers empty, 10 carriers full, 1 DC carrier, 10 carriers full, 5 carriers empty
+ syncsym_mask = (0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0)
+ carrier_mask = (0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0)
+ max_offset = 4
+ wgn_amplitude = 0.05
+ min_chan_ampl = 0.1
+ max_chan_ampl = 5
+ n_iter = 100
+ def run_flow_graph(sync_sym1, sync_sym2, data_sym):
+ top_block = gr.top_block()
+ carr_offset = random.randint(-max_offset/2, max_offset/2) * 2
+ tx_data = shift_tuple(sync_sym1, carr_offset) + \
+ shift_tuple(sync_sym2, carr_offset) + \
+ shift_tuple(data_sym, carr_offset)
+ channel = [rand_range(min_chan_ampl, max_chan_ampl) * numpy.exp(1j * rand_range(0, 2 * numpy.pi)) for x in range(fft_len)]
+ src = gr.vector_source_c(tx_data, False, fft_len)
+ chan = gr.multiply_const_vcc(channel)
+ noise = gr.noise_source_c(gr.GR_GAUSSIAN, wgn_amplitude)
+ add = gr.add_cc(fft_len)
+ chanest = digital.ofdm_chanest_vcvc(sync_sym1, sync_sym2, 1)
+ sink = gr.vector_sink_c(fft_len)
+ top_block.connect(src, chan, (add, 0), chanest, sink)
+ top_block.connect(noise, gr.stream_to_vector(gr.sizeof_gr_complex, fft_len), (add, 1))
+ top_block.run()
+ channel_est = None
+ carr_offset_hat = 0
+ rx_sym_est = [0,] * fft_len
+ tags = sink.tags()
+ for tag in tags:
+ if pmt.pmt_symbol_to_string(tag.key) == 'ofdm_sync_carr_offset':
+ carr_offset_hat = pmt.pmt_to_long(tag.value)
+ self.assertEqual(carr_offset, carr_offset_hat)
+ if pmt.pmt_symbol_to_string(tag.key) == 'ofdm_sync_chan_taps':
+ channel_est = pmt.pmt_c32vector_elements(tag.value)
+ shifted_carrier_mask = shift_tuple(carrier_mask, carr_offset)
+ for i in range(fft_len):
+ if shifted_carrier_mask[i] and channel_est[i]:
+ self.assertAlmostEqual(channel[i], channel_est[i], places=0)
+ rx_sym_est[i] = (sink.data()[i] / channel_est[i]).real
+ return (carr_offset, list(shift_tuple(rx_sym_est, -carr_offset_hat)))
+ bit_errors = 0
+ for k in xrange(n_iter):
+ sync_sym = [(random.randint(0, 1) * 2 - 1) * syncsym_mask[i] for i in range(fft_len)]
+ ref_sym = [(random.randint(0, 1) * 2 - 1) * carrier_mask[i] for i in range(fft_len)]
+ data_sym = [(random.randint(0, 1) * 2 - 1) * carrier_mask[i] for i in range(fft_len)]
+ data_sym[26] = 1
+ (carr_offset, rx_sym) = run_flow_graph(sync_sym, ref_sym, data_sym)
+ rx_sym_est = [0,] * fft_len
+ for i in xrange(fft_len):
+ if carrier_mask[i] == 0:
+ continue
+ rx_sym_est[i] = {True: 1, False: -1}[rx_sym[i] > 0]
+ if rx_sym_est[i] != data_sym[i]:
+ bit_errors += 1
+ # This is much more than we could allow
+ self.assertTrue(bit_errors < n_iter)
+
+
+if __name__ == '__main__':
+ gr_unittest.run(qa_ofdm_sync_eqinit_vcvc, "qa_ofdm_sync_eqinit_vcvc.xml")
+
diff --git a/gr-digital/python/qa_ofdm_cyclic_prefixer.py b/gr-digital/python/qa_ofdm_cyclic_prefixer.py
new file mode 100755
index 0000000000..838e992d02
--- /dev/null
+++ b/gr-digital/python/qa_ofdm_cyclic_prefixer.py
@@ -0,0 +1,95 @@
+#!/usr/bin/env python
+#
+# Copyright 2007,2010,2011 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.
+#
+
+from gnuradio import gr, gr_unittest
+try: import pmt
+except: from gruel import pmt
+import digital_swig as digital
+
+class test_ofdm_cyclic_prefixer (gr_unittest.TestCase):
+
+ def setUp (self):
+ self.tb = gr.top_block ()
+
+ def tearDown (self):
+ self.tb = None
+
+ def test_wo_tags_no_rolloff(self):
+ " The easiest test: make sure the CP is added correctly. "
+ fft_len = 8
+ cp_len = 2
+ expected_result = (6, 7, 0, 1, 2, 3, 4, 5, 6, 7,
+ 6, 7, 0, 1, 2, 3, 4, 5, 6, 7)
+ src = gr.vector_source_c(range(fft_len) * 2, False, fft_len)
+ cp = digital.ofdm_cyclic_prefixer(fft_len, fft_len + cp_len)
+ sink = gr.vector_sink_c()
+ self.tb.connect(src, cp, sink)
+ self.tb.run()
+ self.assertEqual(sink.data(), expected_result)
+
+ def test_wo_tags_2s_rolloff(self):
+ " No tags, but have a 2-sample rolloff "
+ fft_len = 8
+ cp_len = 2
+ rolloff = 2
+ expected_result = (7.0/2, 8, 1, 2, 3, 4, 5, 6, 7, 8, # 1.0/2
+ 7.0/2+1.0/2, 8, 1, 2, 3, 4, 5, 6, 7, 8)
+ src = gr.vector_source_c(range(1, fft_len+1) * 2, False, fft_len)
+ cp = digital.ofdm_cyclic_prefixer(fft_len, fft_len + cp_len, rolloff)
+ sink = gr.vector_sink_c()
+ self.tb.connect(src, cp, sink)
+ self.tb.run()
+ self.assertEqual(sink.data(), expected_result)
+
+ def test_with_tags_2s_rolloff(self):
+ " With tags and a 2-sample rolloff "
+ fft_len = 8
+ cp_len = 2
+ tag_name = "length"
+ expected_result = (7.0/2, 8, 1, 2, 3, 4, 5, 6, 7, 8, # 1.0/2
+ 7.0/2+1.0/2, 8, 1, 2, 3, 4, 5, 6, 7, 8, 1.0/2)
+ tag = gr.gr_tag_t()
+ tag.offset = 0
+ tag.key = pmt.pmt_string_to_symbol(tag_name)
+ tag.value = pmt.pmt_from_long(2)
+ tag2 = gr.gr_tag_t()
+ tag2.offset = 1
+ tag2.key = pmt.pmt_string_to_symbol("random_tag")
+ tag2.value = pmt.pmt_from_long(42)
+ src = gr.vector_source_c(range(1, fft_len+1) * 2, False, fft_len, (tag, tag2))
+ cp = digital.ofdm_cyclic_prefixer(fft_len, fft_len + cp_len, 2, tag_name)
+ sink = gr.vector_sink_c()
+ self.tb.connect(src, cp, sink)
+ self.tb.run()
+ self.assertEqual(sink.data(), expected_result)
+ tags = [gr.tag_to_python(x) for x in sink.tags()]
+ tags = sorted([(x.offset, x.key, x.value) for x in tags])
+ expected_tags = [
+ (0, tag_name, len(expected_result)),
+ (fft_len+cp_len, "random_tag", 42)
+ ]
+ self.assertEqual(tags, expected_tags)
+
+
+if __name__ == '__main__':
+ gr_unittest.run(test_ofdm_cyclic_prefixer, "test_ofdm_cyclic_prefixer.xml")
+
diff --git a/gr-digital/python/qa_ofdm_frame_equalizer_vcvc.py b/gr-digital/python/qa_ofdm_frame_equalizer_vcvc.py
new file mode 100755
index 0000000000..6f44fd00fb
--- /dev/null
+++ b/gr-digital/python/qa_ofdm_frame_equalizer_vcvc.py
@@ -0,0 +1,161 @@
+#!/usr/bin/env python
+# Copyright 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.
+#
+
+import numpy
+from gnuradio import gr, gr_unittest
+try: import pmt
+except: from gruel import pmt
+import digital_swig as digital
+
+class qa_ofdm_frame_equalizer_vcvc (gr_unittest.TestCase):
+
+ def setUp (self):
+ self.tb = gr.top_block ()
+
+ def tearDown (self):
+ self.tb = None
+
+ def test_001_simple (self):
+ """ Very simple functionality testing """
+ fft_len = 8
+ equalizer = digital.ofdm_equalizer_static(fft_len)
+ n_syms = 3
+ len_tag_key = "frame_len"
+ tx_data = (1,) * fft_len * n_syms
+ len_tag = gr.gr_tag_t()
+ len_tag.offset = 0
+ len_tag.key = pmt.pmt_string_to_symbol(len_tag_key)
+ len_tag.value = pmt.pmt_from_long(n_syms)
+ chan_tag = gr.gr_tag_t()
+ chan_tag.offset = 0
+ chan_tag.key = pmt.pmt_string_to_symbol("ofdm_sync_chan_taps")
+ chan_tag.value = pmt.pmt_init_c32vector(fft_len, (1,) * fft_len)
+ src = gr.vector_source_c(tx_data, False, fft_len, (len_tag, chan_tag))
+ eq = digital.ofdm_frame_equalizer_vcvc(equalizer.base(), len_tag_key)
+ sink = gr.vector_sink_c(fft_len)
+ self.tb.connect(src, eq, sink)
+ self.tb.run ()
+ # Check data
+ self.assertEqual(tx_data, sink.data())
+ for tag in sink.tags():
+ self.assertEqual(pmt.pmt_symbol_to_string(tag.key), len_tag_key)
+ self.assertEqual(pmt.pmt_to_long(tag.value), n_syms)
+
+ def test_002_static (self):
+ fft_len = 8
+ # 4 5 6 7 0 1 2 3
+ tx_data = [-1, -1, 1, 2, -1, 3, 0, -1, # 0
+ -1, -1, 0, 2, -1, 2, 0, -1, # 8
+ -1, -1, 3, 0, -1, 1, 0, -1, # 16 (Pilot symbols)
+ -1, -1, 1, 1, -1, 0, 2, -1] # 24
+ cnst = digital.constellation_qpsk()
+ tx_signal = [cnst.map_to_points_v(x)[0] if x != -1 else 0 for x in tx_data]
+ occupied_carriers = ((1, 2, 6, 7),)
+ pilot_carriers = ((), (), (1, 2, 6, 7), ())
+ pilot_symbols = (
+ [], [], [cnst.map_to_points_v(x)[0] for x in (1, 0, 3, 0)], []
+ )
+ equalizer = digital.ofdm_equalizer_static(fft_len, occupied_carriers, pilot_carriers, pilot_symbols)
+ channel = [
+ 0, 0, 1, 1, 0, 1, 1, 0,
+ 0, 0, 1, 1, 0, 1, 1, 0, # These coefficients will be rotated slightly...
+ 0, 0, 1j, 1j, 0, 1j, 1j, 0, # Go crazy here!
+ 0, 0, 1j, 1j, 0, 1j, 1j, 0 # ...and again here.
+ ]
+ for idx in range(fft_len, 2*fft_len):
+ channel[idx] = channel[idx-fft_len] * numpy.exp(1j * .1 * numpy.pi * (numpy.random.rand()-.5))
+ idx2 = idx+2*fft_len
+ channel[idx2] = channel[idx2] * numpy.exp(1j * 0 * numpy.pi * (numpy.random.rand()-.5))
+ len_tag_key = "frame_len"
+ len_tag = gr.gr_tag_t()
+ len_tag.offset = 0
+ len_tag.key = pmt.pmt_string_to_symbol(len_tag_key)
+ len_tag.value = pmt.pmt_from_long(4)
+ chan_tag = gr.gr_tag_t()
+ chan_tag.offset = 0
+ chan_tag.key = pmt.pmt_string_to_symbol("ofdm_sync_chan_taps")
+ chan_tag.value = pmt.pmt_init_c32vector(fft_len, channel[:fft_len])
+ src = gr.vector_source_c(numpy.multiply(tx_signal, channel), False, fft_len, (len_tag, chan_tag))
+ eq = digital.ofdm_frame_equalizer_vcvc(equalizer.base(), len_tag_key, True)
+ sink = gr.vector_sink_c(fft_len)
+ self.tb.connect(src, eq, sink)
+ self.tb.run ()
+ rx_data = [cnst.decision_maker_v((x,)) if x != 0 else -1 for x in sink.data()]
+ self.assertEqual(tx_data, rx_data)
+ for tag in sink.tags():
+ if pmt.pmt_symbol_to_string(tag.key) == len_tag_key:
+ self.assertEqual(pmt.pmt_to_long(tag.value), 4)
+ if pmt.pmt_symbol_to_string(tag.key) == "ofdm_sync_chan_taps":
+ self.assertEqual(list(pmt.pmt_c32vector_elements(tag.value)), channel[-fft_len:])
+
+ def test_002_simpledfe (self):
+ fft_len = 8
+ # 4 5 6 7 0 1 2 3
+ tx_data = [-1, -1, 1, 2, -1, 3, 0, -1, # 0
+ -1, -1, 0, 2, -1, 2, 0, -1, # 8
+ -1, -1, 3, 0, -1, 1, 0, -1, # 16 (Pilot symbols)
+ -1, -1, 1, 1, -1, 0, 2, -1] # 24
+ cnst = digital.constellation_qpsk()
+ tx_signal = [cnst.map_to_points_v(x)[0] if x != -1 else 0 for x in tx_data]
+ occupied_carriers = ((1, 2, 6, 7),)
+ pilot_carriers = ((), (), (1, 2, 6, 7), ())
+ pilot_symbols = (
+ [], [], [cnst.map_to_points_v(x)[0] for x in (1, 0, 3, 0)], []
+ )
+ equalizer = digital.ofdm_equalizer_simpledfe(
+ fft_len, cnst.base(), occupied_carriers, pilot_carriers, pilot_symbols, 0, 0.01
+ )
+ channel = [
+ 0, 0, 1, 1, 0, 1, 1, 0,
+ 0, 0, 1, 1, 0, 1, 1, 0, # These coefficients will be rotated slightly...
+ 0, 0, 1j, 1j, 0, 1j, 1j, 0, # Go crazy here!
+ 0, 0, 1j, 1j, 0, 1j, 1j, 0 # ...and again here.
+ ]
+ for idx in range(fft_len, 2*fft_len):
+ channel[idx] = channel[idx-fft_len] * numpy.exp(1j * .1 * numpy.pi * (numpy.random.rand()-.5))
+ idx2 = idx+2*fft_len
+ channel[idx2] = channel[idx2] * numpy.exp(1j * 0 * numpy.pi * (numpy.random.rand()-.5))
+ len_tag_key = "frame_len"
+ len_tag = gr.gr_tag_t()
+ len_tag.offset = 0
+ len_tag.key = pmt.pmt_string_to_symbol(len_tag_key)
+ len_tag.value = pmt.pmt_from_long(4)
+ chan_tag = gr.gr_tag_t()
+ chan_tag.offset = 0
+ chan_tag.key = pmt.pmt_string_to_symbol("ofdm_sync_chan_taps")
+ chan_tag.value = pmt.pmt_init_c32vector(fft_len, channel[:fft_len])
+ src = gr.vector_source_c(numpy.multiply(tx_signal, channel), False, fft_len, (len_tag, chan_tag))
+ eq = digital.ofdm_frame_equalizer_vcvc(equalizer.base(), len_tag_key, True)
+ sink = gr.vector_sink_c(fft_len)
+ self.tb.connect(src, eq, sink)
+ self.tb.run ()
+ rx_data = [cnst.decision_maker_v((x,)) if x != 0 else -1 for x in sink.data()]
+ self.assertEqual(tx_data, rx_data)
+ for tag in sink.tags():
+ if pmt.pmt_symbol_to_string(tag.key) == len_tag_key:
+ self.assertEqual(pmt.pmt_to_long(tag.value), 4)
+ if pmt.pmt_symbol_to_string(tag.key) == "ofdm_sync_chan_taps":
+ self.assertComplexTuplesAlmostEqual(list(pmt.pmt_c32vector_elements(tag.value)), channel[-fft_len:], places=1)
+
+
+if __name__ == '__main__':
+ gr_unittest.run(qa_ofdm_frame_equalizer_vcvc, "qa_ofdm_frame_equalizer_vcvc.xml")
+
diff --git a/gr-digital/python/qa_ofdm_serializer_vcc.py b/gr-digital/python/qa_ofdm_serializer_vcc.py
new file mode 100755
index 0000000000..537e19b593
--- /dev/null
+++ b/gr-digital/python/qa_ofdm_serializer_vcc.py
@@ -0,0 +1,212 @@
+#!/usr/bin/env python
+#
+# Copyright 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.
+#
+
+from gnuradio import gr, gr_unittest
+import fft_swig as fft
+import digital_swig as digital
+try: import pmt
+except: from gruel import pmt
+import numpy
+
+class qa_ofdm_serializer_vcc (gr_unittest.TestCase):
+
+ def setUp (self):
+ self.tb = gr.top_block ()
+
+ def tearDown (self):
+ self.tb = None
+
+ def test_001_simple (self):
+ """ Standard test """
+ fft_len = 16
+ tx_symbols = range(1, 16);
+ tx_symbols = (0, 1, 1j, 2, 3, 0, 0, 0, 0, 0, 0, 4, 5, 2j, 6, 0,
+ 0, 7, 8, 3j, 9, 0, 0, 0, 0, 0, 0, 10, 4j, 11, 12, 0,
+ 0, 13, 1j, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 2j, 0, 0)
+ expected_result = tuple(range(1, 16)) + (0, 0, 0)
+ occupied_carriers = ((1, 3, 4, 11, 12, 14), (1, 2, 4, 11, 13, 14),)
+ n_syms = len(tx_symbols)/fft_len
+ tag_name = "len"
+ tag = gr.gr_tag_t()
+ tag.offset = 0
+ tag.key = pmt.pmt_string_to_symbol(tag_name)
+ tag.value = pmt.pmt_from_long(n_syms)
+ src = gr.vector_source_c(tx_symbols, False, fft_len, (tag,))
+ serializer = digital.ofdm_serializer_vcc(fft_len, occupied_carriers, tag_name, "", 0, False)
+ sink = gr.vector_sink_c()
+ self.tb.connect(src, serializer, sink)
+ self.tb.run ()
+ self.assertEqual(sink.data(), expected_result)
+ self.assertEqual(len(sink.tags()), 1)
+ result_tag = sink.tags()[0]
+ self.assertEqual(pmt.pmt_symbol_to_string(result_tag.key), tag_name)
+ self.assertEqual(pmt.pmt_to_long(result_tag.value), n_syms * len(occupied_carriers[0]))
+
+ def test_002_with_offset (self):
+ """ Standard test, carrier offset """
+ fft_len = 16
+ tx_symbols = range(1, 16);
+ tx_symbols = (0, 0, 1, 1j, 2, 3, 0, 0, 0, 0, 0, 0, 4, 5, 2j, 6,
+ 0, 0, 7, 8, 3j, 9, 0, 0, 0, 0, 0, 0, 10, 4j, 11, 12,
+ 0, 0, 13, 1j, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 2j, 0)
+ carr_offset = 1 # Compare this with tx_symbols from the previous test
+ expected_result = tuple(range(1, 16)) + (0, 0, 0)
+ occupied_carriers = ((1, 3, 4, 11, 12, 14), (1, 2, 4, 11, 13, 14),)
+ n_syms = len(tx_symbols)/fft_len
+ tag_name = "len"
+ tag = gr.gr_tag_t()
+ tag.offset = 0
+ tag.key = pmt.pmt_string_to_symbol(tag_name)
+ tag.value = pmt.pmt_from_long(n_syms)
+ offsettag = gr.gr_tag_t()
+ offsettag.offset = 0
+ offsettag.key = pmt.pmt_string_to_symbol("ofdm_sync_carr_offset")
+ offsettag.value = pmt.pmt_from_long(carr_offset)
+ src = gr.vector_source_c(tx_symbols, False, fft_len, (tag, offsettag))
+ serializer = digital.ofdm_serializer_vcc(fft_len, occupied_carriers, tag_name, "", 0, False)
+ sink = gr.vector_sink_c()
+ self.tb.connect(src, serializer, sink)
+ self.tb.run ()
+ self.assertEqual(sink.data(), expected_result)
+ self.assertEqual(len(sink.tags()), 2)
+ for tag in sink.tags():
+ if pmt.pmt_symbol_to_string(tag.key) == tag_name:
+ self.assertEqual(pmt.pmt_to_long(tag.value), n_syms * len(occupied_carriers[0]))
+
+ def test_003_connect (self):
+ """ Connect carrier_allocator to ofdm_serializer,
+ make sure output==input """
+ fft_len = 8
+ n_syms = 10
+ occupied_carriers = ((1, 2, 6, 7),)
+ pilot_carriers = ((3,),(5,))
+ pilot_symbols = ((1j,),(-1j,))
+ tx_data = tuple([numpy.random.randint(0, 10) for x in range(4 * n_syms)])
+ tag_name = "len"
+ tag = gr.gr_tag_t()
+ tag.offset = 0
+ tag.key = pmt.pmt_string_to_symbol(tag_name)
+ tag.value = pmt.pmt_from_long(len(tx_data))
+ src = gr.vector_source_c(tx_data, False, 1, (tag,))
+ alloc = digital.ofdm_carrier_allocator_cvc(fft_len,
+ occupied_carriers,
+ pilot_carriers,
+ pilot_symbols,
+ tag_name)
+ serializer = digital.ofdm_serializer_vcc(alloc)
+ sink = gr.vector_sink_c()
+ self.tb.connect(src, alloc, serializer, sink)
+ self.tb.run ()
+ self.assertEqual(sink.data(), tx_data)
+
+ def test_004_connect (self):
+ """
+ Advanced test:
+ - Allocator -> IFFT -> Frequency offset -> FFT -> Serializer
+ - FFT does shift (moves DC to middle)
+ - Make sure input == output
+ - Frequency offset is -2 carriers
+ """
+ fft_len = 8
+ n_syms = 2
+ carr_offset = -2
+ freq_offset = 2 * numpy.pi * carr_offset / fft_len # If the sampling rate == 1
+ occupied_carriers = ((1, 2, -2, -1),)
+ pilot_carriers = ((3,),(5,))
+ pilot_symbols = ((1j,),(-1j,))
+ tx_data = tuple([numpy.random.randint(0, 10) for x in range(4 * n_syms)])
+ #tx_data = (1,) * occupied_carriers[0] * n_syms
+ tag_name = "len"
+ tag = gr.gr_tag_t()
+ tag.offset = 0
+ tag.key = pmt.pmt_string_to_symbol(tag_name)
+ tag.value = pmt.pmt_from_long(len(tx_data))
+ offsettag = gr.gr_tag_t()
+ offsettag.offset = 0
+ offsettag.key = pmt.pmt_string_to_symbol("ofdm_sync_carr_offset")
+ offsettag.value = pmt.pmt_from_long(carr_offset)
+ src = gr.vector_source_c(tx_data, False, 1, (tag, offsettag))
+ alloc = digital.ofdm_carrier_allocator_cvc(fft_len,
+ occupied_carriers,
+ pilot_carriers,
+ pilot_symbols,
+ tag_name)
+ tx_ifft = fft.fft_vcc(fft_len, False, ())
+ offset_sig = gr.sig_source_c(1.0, gr.GR_COS_WAVE, freq_offset, 1.0)
+ mixer = gr.multiply_cc()
+ rx_fft = fft.fft_vcc(fft_len, True, (), True)
+ serializer = digital.ofdm_serializer_vcc(alloc)
+ sink = gr.vector_sink_c()
+ self.tb.connect(
+ src, alloc, tx_ifft,
+ gr.vector_to_stream(gr.sizeof_gr_complex, fft_len),
+ (mixer, 0),
+ gr.stream_to_vector(gr.sizeof_gr_complex, fft_len),
+ rx_fft, serializer, sink
+ )
+ self.tb.connect(offset_sig, (mixer, 1))
+ self.tb.run ()
+ # FIXME check this
+ #self.assertEqual(sink.data(), tx_data)
+
+ def test_005_packet_len_tag (self):
+ """ Standard test """
+ fft_len = 16
+ tx_symbols = range(1, 16);
+ tx_symbols = (0, 1, 1j, 2, 3, 0, 0, 0, 0, 0, 0, 4, 5, 2j, 6, 0,
+ 0, 7, 8, 3j, 9, 0, 0, 0, 0, 0, 0, 10, 4j, 11, 12, 0,
+ 0, 13, 1j, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 2j, 0, 0)
+ expected_result = tuple(range(1, 16))
+ occupied_carriers = ((1, 3, 4, 11, 12, 14), (1, 2, 4, 11, 13, 14),)
+ n_syms = len(tx_symbols)/fft_len
+ tag_name = "len"
+ tag = gr.gr_tag_t()
+ tag.offset = 0
+ tag.key = pmt.pmt_string_to_symbol(tag_name)
+ tag.value = pmt.pmt_from_long(n_syms)
+ tag2 = gr.gr_tag_t()
+ tag2.offset = 0
+ tag2.key = pmt.pmt_string_to_symbol("packet_len")
+ tag2.value = pmt.pmt_from_long(len(expected_result))
+ src = gr.vector_source_c(tx_symbols, False, fft_len, (tag, tag2))
+ serializer = digital.ofdm_serializer_vcc(fft_len, occupied_carriers, tag_name, "packet_len", 0, False)
+ sink = gr.vector_sink_c()
+ self.tb.connect(src, serializer, sink)
+ self.tb.run ()
+ self.assertEqual(sink.data(), expected_result)
+ self.assertEqual(len(sink.tags()), 1)
+ result_tag = sink.tags()[0]
+ self.assertEqual(pmt.pmt_symbol_to_string(result_tag.key), "packet_len")
+ self.assertEqual(pmt.pmt_to_long(result_tag.value), len(expected_result))
+
+ def test_099 (self):
+ """ Make sure it fails if it should """
+ fft_len = 16
+ occupied_carriers = ((1, 3, 4, 11, 12, 17),)
+ tag_name = "len"
+ self.assertRaises(RuntimeError, digital.ofdm_serializer_vcc, fft_len, occupied_carriers, tag_name)
+
+
+if __name__ == '__main__':
+ #gr_unittest.run(qa_ofdm_serializer_vcc, "qa_ofdm_serializer_vcc.xml")
+ gr_unittest.run(qa_ofdm_serializer_vcc)
+
diff --git a/gr-digital/python/qa_ofdm_sync_sc_cfb.py b/gr-digital/python/qa_ofdm_sync_sc_cfb.py
new file mode 100755
index 0000000000..bed8e9c3ae
--- /dev/null
+++ b/gr-digital/python/qa_ofdm_sync_sc_cfb.py
@@ -0,0 +1,197 @@
+#!/usr/bin/env python
+#
+# Copyright 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.
+#
+
+import numpy
+import random
+
+from gnuradio import gr, gr_unittest
+try:
+ # This will work when feature #505 is added.
+ from gnuradio import digital
+ from gnuradio.digital.utils import tagged_streams
+ from gnuradio.digital.ofdm_txrx import ofdm_tx
+except ImportError:
+ # Until then this will work.
+ import digital_swig as digital
+ from utils import tagged_streams
+ from ofdm_txrx import ofdm_tx
+
+class qa_ofdm_sync_sc_cfb (gr_unittest.TestCase):
+
+ def setUp (self):
+ self.tb = gr.top_block ()
+
+ def tearDown (self):
+ self.tb = None
+
+ def test_001_detect (self):
+ """ Send two bursts, with zeros in between, and check
+ they are both detected at the correct position and no
+ false alarms occur """
+ n_zeros = 15
+ fft_len = 32
+ cp_len = 4
+ sig_len = (fft_len + cp_len) * 10
+ sync_symbol = [(random.randint(0, 1)*2)-1 for x in range(fft_len/2)] * 2
+ tx_signal = [0,] * n_zeros + \
+ sync_symbol[-cp_len:] + \
+ sync_symbol + \
+ [(random.randint(0, 1)*2)-1 for x in range(sig_len)]
+ tx_signal = tx_signal * 2
+ add = gr.add_cc()
+ sync = digital.ofdm_sync_sc_cfb(fft_len, cp_len)
+ sink_freq = gr.vector_sink_f()
+ sink_detect = gr.vector_sink_b()
+ self.tb.connect(gr.vector_source_c(tx_signal), (add, 0))
+ self.tb.connect(gr.noise_source_c(gr.GR_GAUSSIAN, .01), (add, 1))
+ self.tb.connect(add, sync)
+ self.tb.connect((sync, 0), sink_freq)
+ self.tb.connect((sync, 1), sink_detect)
+ self.tb.run()
+ sig1_detect = sink_detect.data()[0:len(tx_signal)/2]
+ sig2_detect = sink_detect.data()[len(tx_signal)/2:]
+ self.assertTrue(abs(sig1_detect.index(1) - (n_zeros + fft_len + cp_len)) < cp_len)
+ self.assertTrue(abs(sig2_detect.index(1) - (n_zeros + fft_len + cp_len)) < cp_len)
+ self.assertEqual(numpy.sum(sig1_detect), 1)
+ self.assertEqual(numpy.sum(sig2_detect), 1)
+
+
+ def test_002_freq (self):
+ """ Add a fine frequency offset and see if that get's detected properly """
+ fft_len = 32
+ cp_len = 4
+ freq_offset = 0.1 # Must stay < 2*pi/fft_len = 0.196 (otherwise, it's coarse)
+ sig_len = (fft_len + cp_len) * 10
+ sync_symbol = [(random.randint(0, 1)*2)-1 for x in range(fft_len/2)] * 2
+ tx_signal = sync_symbol[-cp_len:] + \
+ sync_symbol + \
+ [(random.randint(0, 1)*2)-1 for x in range(sig_len)]
+ mult = gr.multiply_cc()
+ add = gr.add_cc()
+ sync = digital.ofdm_sync_sc_cfb(fft_len, cp_len)
+ sink_freq = gr.vector_sink_f()
+ sink_detect = gr.vector_sink_b()
+ self.tb.connect(gr.vector_source_c(tx_signal), (mult, 0), (add, 0))
+ self.tb.connect(gr.sig_source_c(2 * numpy.pi, gr.GR_SIN_WAVE, freq_offset, 1.0), (mult, 1))
+ self.tb.connect(gr.noise_source_c(gr.GR_GAUSSIAN, .01), (add, 1))
+ self.tb.connect(add, sync)
+ self.tb.connect((sync, 0), sink_freq)
+ self.tb.connect((sync, 1), sink_detect)
+ self.tb.run()
+ phi_hat = sink_freq.data()[sink_detect.data().index(1)]
+ est_freq_offset = 2 * phi_hat / fft_len
+ self.assertAlmostEqual(est_freq_offset, freq_offset, places=2)
+
+
+ def test_003_multiburst (self):
+ """ Send several bursts, see if the number of detects is correct.
+ Burst lengths and content are random.
+ """
+ n_bursts = 42
+ fft_len = 32
+ cp_len = 4
+ tx_signal = []
+ for i in xrange(n_bursts):
+ sync_symbol = [(random.randint(0, 1)*2)-1 for x in range(fft_len/2)] * 2
+ tx_signal += [0,] * random.randint(0, 2*fft_len) + \
+ sync_symbol[-cp_len:] + \
+ sync_symbol + \
+ [(random.randint(0, 1)*2)-1 for x in range(fft_len * random.randint(5,23))]
+ add = gr.add_cc()
+ sync = digital.ofdm_sync_sc_cfb(fft_len, cp_len)
+ sink_freq = gr.vector_sink_f()
+ sink_detect = gr.vector_sink_b()
+ self.tb.connect(gr.vector_source_c(tx_signal), (add, 0))
+ self.tb.connect(gr.noise_source_c(gr.GR_GAUSSIAN, .005), (add, 1))
+ self.tb.connect(add, sync)
+ self.tb.connect((sync, 0), sink_freq)
+ self.tb.connect((sync, 1), sink_detect)
+ self.tb.run()
+ self.assertEqual(numpy.sum(sink_detect.data()), n_bursts,
+ msg="""Because of statistics, it is possible (though unlikely)
+that the number of detected bursts differs slightly. If the number of detects is
+off by one or two, run the test again and see what happen.
+Detection error was: %d """ % (numpy.sum(sink_detect.data()) - n_bursts)
+ )
+
+ # FIXME ofdm_mod is currently not working
+ #def test_004_ofdm_packets (self):
+ #"""
+ #Send several bursts, see if the number of detects is correct.
+ #Burst lengths and content are random.
+ #"""
+ #n_bursts = 42
+ #fft_len = 64
+ #cp_len = 12
+ #tx_signal = []
+ #packets = []
+ #tagname = "length"
+ #min_packet_length = 100
+ #max_packet_length = 100
+ #sync_sequence = [random.randint(0, 1)*2-1 for x in range(fft_len/2)]
+ #for i in xrange(n_bursts):
+ #packet_length = random.randint(min_packet_length,
+ #max_packet_length+1)
+ #packet = [random.randint(0, 255) for i in range(packet_length)]
+ #packets.append(packet)
+ #data, tags = tagged_streams.packets_to_vectors(
+ #packets, tagname, vlen=1)
+ #total_length = len(data)
+
+ #src = gr.vector_source_b(data, False, 1, tags)
+ #mod = ofdm_tx(
+ #fft_len=fft_len,
+ #cp_len=cp_len,
+ #length_tag_name=tagname,
+ #occupied_carriers=(range(1, 27) + range(38, 64),),
+ #pilot_carriers=((0,),),
+ #pilot_symbols=((100,),),
+ #)
+ #rate_in = 16000
+ #rate_out = 48000
+ #ratio = float(rate_out) / rate_in
+ #throttle1 = gr.throttle(gr.sizeof_gr_complex, rate_in)
+ #sink_countbursts = gr.vector_sink_c()
+ #head = gr.head(gr.sizeof_gr_complex, int(total_length * ratio*2))
+ #add = gr.add_cc()
+ #sync = digital.ofdm_sync_sc_cfb(fft_len, cp_len)
+ #sink_freq = gr.vector_sink_f()
+ #sink_detect = gr.vector_sink_b()
+ #noise_level = 0.01
+ #noise = gr.noise_source_c(gr.GR_GAUSSIAN, noise_level)
+ #self.tb.connect(src, mod, gr.null_sink(gr.sizeof_gr_complex))
+ #self.tb.connect(insert_zeros, sink_countbursts)
+ #self.tb.connect(noise, (add, 1))
+ #self.tb.connect(add, sync)
+ #self.tb.connect((sync, 0), sink_freq)
+ #self.tb.connect((sync, 1), sink_detect)
+ #self.tb.run()
+ #count_data = sink_countbursts.data()
+ #count_tags = sink_countbursts.tags()
+ #burstcount = tagged_streams.count_bursts(count_data, count_tags, tagname)
+ #self.assertEqual(numpy.sum(sink_detect.data()), burstcount)
+
+
+if __name__ == '__main__':
+ #gr_unittest.run(qa_ofdm_sync_sc_cfb, "qa_ofdm_sync_sc_cfb.xml")
+ gr_unittest.run(qa_ofdm_sync_sc_cfb)
+
diff --git a/gr-digital/python/qa_ofdm_txrx.py b/gr-digital/python/qa_ofdm_txrx.py
new file mode 100755
index 0000000000..778f03f515
--- /dev/null
+++ b/gr-digital/python/qa_ofdm_txrx.py
@@ -0,0 +1,58 @@
+#!/usr/bin/env python
+#
+# Copyright 2013 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.
+#
+
+import numpy
+from gnuradio import gr, gr_unittest
+import digital_swig
+
+class test_ofdm_txrx (gr_unittest.TestCase):
+
+ def setUp (self):
+ self.tb = gr.top_block ()
+
+ def tearDown (self):
+ self.tb = None
+
+ def test_001 (self):
+ pass
+ #len_tag_key = 'frame_len'
+ #n_bytes = 100
+ #test_data = [random.randint(0, 255) for x in range(n_bytes)]
+ #tx_data, tags = tagged_streams.packets_to_vectors((test_data,), len_tag_key)
+ #src = gr.vector_source_b(test_data, False, 1, tags)
+ #tx = ofdm_tx(frame_length_tag_key=len_tag_key)
+ #rx = ofdm_rx(frame_length_tag_key=len_tag_key)
+ #self.assertEqual(tx.sync_word1, rx.sync_word1)
+ #self.assertEqual(tx.sync_word2, rx.sync_word2)
+ #delay = gr.delay(gr.sizeof_gr_complex, 100)
+ #noise = gr.noise_source_c(gr.GR_GAUSSIAN, 0.05)
+ #add = gr.add_cc()
+ #sink = gr.vector_sink_b()
+ ##self.tb.connect(src, tx, add, rx, sink)
+ ##self.tb.connect(noise, (add, 1))
+ #self.tb.connect(src, tx, gr.null_sink(gr.sizeof_gr_complex))
+ #self.tb.run()
+
+
+if __name__ == '__main__':
+ gr_unittest.run(test_ofdm_txrx, "test_ofdm_txrx.xml")
+
diff --git a/gr-digital/python/qa_packet_headergenerator_bb.py b/gr-digital/python/qa_packet_headergenerator_bb.py
new file mode 100755
index 0000000000..1aeaa86063
--- /dev/null
+++ b/gr-digital/python/qa_packet_headergenerator_bb.py
@@ -0,0 +1,157 @@
+#!/usr/bin/env python
+# Copyright 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.
+#
+
+from gnuradio import gr, gr_unittest
+import digital_swig as digital
+try: import pmt
+except: from gruel import pmt
+
+class qa_packet_headergenerator_bb (gr_unittest.TestCase):
+
+ def setUp (self):
+ self.tb = gr.top_block ()
+
+ def tearDown (self):
+ self.tb = None
+
+ def test_001_12bits (self):
+ # 3 PDUs: | | | |
+ data = (1, 2, 3, 4, 1, 2, 1, 2, 3, 4)
+ tagname = "packet_len"
+ tag1 = gr.gr_tag_t()
+ tag1.offset = 0
+ tag1.key = pmt.pmt_string_to_symbol(tagname)
+ tag1.value = pmt.pmt_from_long(4)
+ tag2 = gr.gr_tag_t()
+ tag2.offset = 4
+ tag2.key = pmt.pmt_string_to_symbol(tagname)
+ tag2.value = pmt.pmt_from_long(2)
+ tag3 = gr.gr_tag_t()
+ tag3.offset = 6
+ tag3.key = pmt.pmt_string_to_symbol(tagname)
+ tag3.value = pmt.pmt_from_long(4)
+ src = gr.vector_source_b(data, False, 1, (tag1, tag2, tag3))
+ header = digital.packet_headergenerator_bb(12, tagname)
+ sink = gr.vector_sink_b()
+ self.tb.connect(src, header, sink)
+ self.tb.run()
+ expected_data = (
+ 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0
+ )
+ self.assertEqual(sink.data(), expected_data)
+
+
+ def test_002_32bits (self):
+ # 3 PDUs: | | | |
+ data = (1, 2, 3, 4, 1, 2, 1, 2, 3, 4)
+ tagname = "packet_len"
+ tag1 = gr.gr_tag_t()
+ tag1.offset = 0
+ tag1.key = pmt.pmt_string_to_symbol(tagname)
+ tag1.value = pmt.pmt_from_long(4)
+ tag2 = gr.gr_tag_t()
+ tag2.offset = 4
+ tag2.key = pmt.pmt_string_to_symbol(tagname)
+ tag2.value = pmt.pmt_from_long(2)
+ tag3 = gr.gr_tag_t()
+ tag3.offset = 6
+ tag3.key = pmt.pmt_string_to_symbol(tagname)
+ tag3.value = pmt.pmt_from_long(4)
+ src = gr.vector_source_b(data, False, 1, (tag1, tag2, tag3))
+ header = digital.packet_headergenerator_bb(32, tagname)
+ sink = gr.vector_sink_b()
+ self.tb.connect(src, header, sink)
+ self.tb.run()
+ expected_data = (
+ # | Number of symbols | Packet number | Parity
+ 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0,
+ 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+ )
+ self.assertEqual(sink.data(), expected_data)
+
+
+ def test_003_12bits_formatter_object (self):
+ # 3 PDUs: | | | |
+ data = (1, 2, 3, 4, 1, 2, 1, 2, 3, 4)
+ tagname = "packet_len"
+ tag1 = gr.gr_tag_t()
+ tag1.offset = 0
+ tag1.key = pmt.pmt_string_to_symbol(tagname)
+ tag1.value = pmt.pmt_from_long(4)
+ tag2 = gr.gr_tag_t()
+ tag2.offset = 4
+ tag2.key = pmt.pmt_string_to_symbol(tagname)
+ tag2.value = pmt.pmt_from_long(2)
+ tag3 = gr.gr_tag_t()
+ tag3.offset = 6
+ tag3.key = pmt.pmt_string_to_symbol(tagname)
+ tag3.value = pmt.pmt_from_long(4)
+ src = gr.vector_source_b(data, False, 1, (tag1, tag2, tag3))
+ formatter_object = digital.packet_header_default(12, tagname)
+ header = digital.packet_headergenerator_bb(formatter_object.formatter())
+ sink = gr.vector_sink_b()
+ self.tb.connect(src, header, sink)
+ self.tb.run()
+ expected_data = (
+ 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0
+ )
+ self.assertEqual(sink.data(), expected_data)
+
+ def test_004_8bits_formatter_ofdm (self):
+ occupied_carriers = ((1, 2, 3, 5, 6, 7),)
+ # 3 PDUs: | | | |
+ data = (1, 2, 3, 4, 1, 2, 1, 2, 3, 4)
+ tagname = "packet_len"
+ tag1 = gr.gr_tag_t()
+ tag1.offset = 0
+ tag1.key = pmt.pmt_string_to_symbol(tagname)
+ tag1.value = pmt.pmt_from_long(4)
+ tag2 = gr.gr_tag_t()
+ tag2.offset = 4
+ tag2.key = pmt.pmt_string_to_symbol(tagname)
+ tag2.value = pmt.pmt_from_long(2)
+ tag3 = gr.gr_tag_t()
+ tag3.offset = 6
+ tag3.key = pmt.pmt_string_to_symbol(tagname)
+ tag3.value = pmt.pmt_from_long(4)
+ src = gr.vector_source_b(data, False, 1, (tag1, tag2, tag3))
+ formatter_object = digital.packet_header_ofdm(occupied_carriers, 1, tagname)
+ self.assertEqual(formatter_object.header_len(), 6)
+ self.assertEqual(pmt.pmt_symbol_to_string(formatter_object.len_tag_key()), tagname)
+ header = digital.packet_headergenerator_bb(formatter_object.formatter())
+ sink = gr.vector_sink_b()
+ self.tb.connect(src, header, sink)
+ self.tb.run()
+ expected_data = (
+ 0, 0, 1, 0, 0, 0,
+ 0, 1, 0, 0, 0, 0,
+ 0, 0, 1, 0, 0, 0
+ )
+ self.assertEqual(sink.data(), expected_data)
+
+if __name__ == '__main__':
+ gr_unittest.run(qa_packet_headergenerator_bb, "qa_packet_headergenerator_bb.xml")
+
diff --git a/gr-digital/python/qa_packet_headerparser_b.py b/gr-digital/python/qa_packet_headerparser_b.py
new file mode 100755
index 0000000000..13dc46f9e3
--- /dev/null
+++ b/gr-digital/python/qa_packet_headerparser_b.py
@@ -0,0 +1,71 @@
+#!/usr/bin/env python
+# Copyright 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.
+#
+
+import time
+from gnuradio import gr, gr_unittest
+try: import pmt
+except: from gruel import pmt
+import digital_swig as digital
+
+class qa_packet_headerparser_b (gr_unittest.TestCase):
+
+ def setUp (self):
+ self.tb = gr.top_block ()
+
+ def tearDown (self):
+ self.tb = None
+
+ def test_001_t (self):
+ expected_data = (
+ # | Number of symbols | Packet number | Parity
+ 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0,
+ 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0
+ )
+ tagname = "packet_len"
+
+ src = gr.vector_source_b(expected_data)
+ parser = digital.packet_headerparser_b(32, tagname)
+ sink = gr.message_debug()
+
+ self.tb.connect(src, parser)
+ self.tb.msg_connect(parser, "header_data", sink, "store")
+ self.tb.start ()
+ time.sleep(1)
+ self.tb.stop()
+ self.tb.wait()
+
+ self.assertEqual(sink.num_messages(), 3)
+ msg = sink.get_message(0)
+ #try:
+ #self.assertEqual(4, pmt.pmt_to_long(pmt.pmt_dict_ref(msg, pmt.pmt_string_to_symbol(tagname), pmt.PMT_F)))
+ #self.assertEqual(0, pmt.pmt_to_long(pmt.pmt_dict_ref(msg, pmt.pmt_string_to_symbol("packet_num"), pmt.PMT_F)))
+
+ #except:
+ #self.fail()
+ # msg1: length 4, number 0
+ # msg2: length 2, number 1
+ # msg3: PMT_F because parity fail
+
+
+
+if __name__ == '__main__':
+ gr_unittest.run(qa_packet_headerparser_b, "qa_packet_headerparser_b.xml")
diff --git a/gr-digital/python/qam.py b/gr-digital/python/qam.py
index 5b1f7683b8..6834e1945a 100644
--- a/gr-digital/python/qam.py
+++ b/gr-digital/python/qam.py
@@ -146,9 +146,17 @@ def make_non_differential_constellation(m, gray_coded):
def qam_constellation(constellation_points=_def_constellation_points,
differential=_def_differential,
- mod_code=_def_mod_code):
+ mod_code=_def_mod_code,
+ large_ampls_to_corners=False):
"""
Creates a QAM constellation object.
+
+ If large_ampls_to_corners=True then sectors that are probably
+ occupied due to a phase offset, are not mapped to the closest
+ constellation point. Rather we take into account the fact that a
+ phase offset is probably the problem and map them to the closest
+ corner point. It's a bit hackish but it seems to improve
+ frequency locking.
"""
if mod_code == mod_codes.GRAY_CODE:
gray_coded = True
@@ -165,10 +173,85 @@ def qam_constellation(constellation_points=_def_constellation_points,
# No pre-diff code
# Should add one so that we can gray-code the quadrant bits too.
pre_diff_code = []
- constellation = digital_swig.constellation_rect(points, pre_diff_code, 4,
- side, side, width, width)
+ if not large_ampls_to_corners:
+ constellation = digital_swig.constellation_rect(points, pre_diff_code, 4,
+ side, side, width, width)
+ else:
+ sector_values = large_ampls_to_corners_mapping(side, points, width)
+ constellation = digital_swig.constellation_expl_rect(
+ points, pre_diff_code, 4, side, side, width, width, sector_values)
return constellation
+def find_closest_point(p, qs):
+ """
+ Return in index of the closest point in 'qs' to 'p'.
+ """
+ min_dist = None
+ min_i = None
+ for i, q in enumerate(qs):
+ dist = abs(q-p)
+ if min_dist is None or dist < min_dist:
+ min_dist = dist
+ min_i = i
+ return min_i
+
+def large_ampls_to_corners_mapping(side, points, width):
+ """
+ We have a grid that we use for decision making. One additional row/column
+ is placed on each side of the grid. Points in these additional rows/columns
+ are mapped to the corners rather than the closest constellation points.
+
+ Args:
+ side: The number of rows/columns in the grid that we use to do
+ decision making.
+ points: The list of constellation points.
+ width: The width of the rows/columns.
+
+ Returns:
+ sector_values maps the sector index to the constellation
+ point index.
+ """
+ # First find the indices of the corner points.
+ # Assume the corner points are the 4 points with the largest magnitudes.
+ corner_indices = []
+ corner_points = []
+ max_mag = 0
+ for i, p in enumerate(points):
+ if abs(p) > max_mag:
+ corner_indices = [i]
+ corner_points = [p]
+ max_mag = abs(p)
+ elif abs(p) == max_mag:
+ corner_indices.append(i)
+ corner_points.append(p)
+ if len(corner_indices) != 4:
+ raise ValueError("Found {0} corner indices. Expected 4."
+ .format(len(corner_indices)))
+ # We want an additional layer around the constellation
+ # Value in this extra layer will be mapped to the closest corner rather
+ # than the closest constellation point.
+ extra_layers = 1
+ side = side + extra_layers*2
+ # Calculate sector values
+ sector_values = []
+ for real_x in range(side):
+ for imag_x in range(side):
+ sector = real_x * side + imag_x
+ # If this sector is a normal constellation sector then
+ # use the center point.
+ c = ((real_x-side/2.0+0.5)*width +
+ (imag_x-side/2.0+0.5)*width*1j)
+ if (real_x >= extra_layers and real_x < side-extra_layers
+ and imag_x >= extra_layers and imag_x < side-extra_layers):
+ # This is not an edge row/column. Find closest point.
+ index = find_closest_point(c, points)
+ else:
+ # This is an edge. Find closest corner point.
+ index = corner_indices[find_closest_point(c, corner_points)]
+ sector_values.append(index)
+ return sector_values
+
+
# /////////////////////////////////////////////////////////////////////////////
# QAM modulator
# /////////////////////////////////////////////////////////////////////////////
@@ -186,12 +269,19 @@ class qam_mod(generic_mod):
The input is a byte stream (unsigned char) and the
output is the complex modulated signal at baseband.
- See generic_mod block for list of parameters.
+ Args:
+ constellation_points: Number of constellation points.
+ Must be a power of 4.
+ mod_code: Specifies an encoding to use (typically used to indicated
+ if we want gray coding, see digital.utils.mod_codes)
+
+ See generic_mod block for list of additional parameters.
"""
- constellation = qam_constellation(constellation_points, differential, mod_code)
- # We take care of the gray coding in the constellation generation so it doesn't
- # need to be done in the block.
+ constellation = qam_constellation(constellation_points, differential,
+ mod_code)
+ # We take care of the gray coding in the constellation
+ # generation so it doesn't need to be done in the block.
super(qam_mod, self).__init__(constellation, differential=differential,
*args, **kwargs)
@@ -205,6 +295,7 @@ class qam_demod(generic_demod):
def __init__(self, constellation_points=_def_constellation_points,
differential=_def_differential,
mod_code=_def_mod_code,
+ large_ampls_to_corner = False,
*args, **kwargs):
"""
@@ -213,11 +304,23 @@ class qam_demod(generic_demod):
The input is a byte stream (unsigned char) and the
output is the complex modulated signal at baseband.
- See generic_demod block for list of parameters.
+ Args:
+ constellation_points: Number of constellation points.
+ Must be a power of 4.
+ mod_code: Specifies an encoding to use (typically used to indicated
+ if we want gray coding, see digital.utils.mod_codes)
+ large_ampls_to_corners: If this is set to True then when the
+ constellation is making decisions, points that are far outside
+ the constellation are mapped to the closest corner rather than
+ the closet constellation point. This can help with phase
+ locking.
+
+ See generic_demod block for list of additional parameters.
"""
- constellation = qam_constellation(constellation_points, differential, mod_code)
- # We take care of the gray coding in the constellation generation so it doesn't
- # need to be done in the block.
+ constellation = qam_constellation(constellation_points, differential,
+ mod_code)
+ # We take care of the gray coding in the constellation
+ # generation so it doesn't need to be done in the block.
super(qam_demod, self).__init__(constellation, differential=differential,
*args, **kwargs)
diff --git a/gr-digital/python/qamlike.py b/gr-digital/python/qamlike.py
new file mode 100644
index 0000000000..2f8c855339
--- /dev/null
+++ b/gr-digital/python/qamlike.py
@@ -0,0 +1,75 @@
+# Copyright 2013 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.
+#
+
+"""
+This file contains constellations that are similar to QAM, but are not perfect squares.
+"""
+
+import digital_swig
+from qam import large_ampls_to_corners_mapping
+
+def qam32_holeinside_constellation(large_ampls_to_corners=False):
+ # First make constellation for one quadrant.
+ # 0 1 2
+ # 2 - 010 111 110
+ # 1 - 011 101 100
+ # 0 - 000 001
+
+ # Have put hole in the side rather than corner.
+ # Corner point is helpful for frequency locking.
+
+ # It has an attempt at some gray-coding, but not
+ # a very good one.
+
+ # Indices are (horizontal, vertical).
+ indices_and_numbers = (
+ ((0, 0), 0b000),
+ ((0, 1), 0b011),
+ ((0, 2), 0b010),
+ ((1, 0), 0b001),
+ ((1, 1), 0b101),
+ ((1, 2), 0b111),
+ ((2, 1), 0b100),
+ ((2, 2), 0b110),
+ )
+ points = [None]*32
+ for indices, number in indices_and_numbers:
+ p_in_quadrant = 0.5+indices[0] + 1j*(0.5+indices[1])
+ for quadrant in range(4):
+ index = number + 8 * quadrant
+ rotation = pow(1j, quadrant)
+ p = p_in_quadrant * rotation
+ points[index] = p
+ side = 6
+ width = 1
+ # Double number of boxes on side
+ # This is so that points in the 'hole' get assigned correctly.
+ side = 12
+ width = 0.5
+ pre_diff_code = []
+ if not large_ampls_to_corners:
+ constellation = digital_swig.constellation_rect(points, pre_diff_code, 4,
+ side, side, width, width)
+ else:
+ sector_values = large_ampls_to_corners_mapping(side, points, width)
+ constellation = digital_swig.constellation_expl_rect(
+ points, pre_diff_code, 4, side, side, width, width, sector_values)
+ return constellation
+
diff --git a/gr-digital/python/utils/tagged_streams.py b/gr-digital/python/utils/tagged_streams.py
new file mode 100644
index 0000000000..7e69aa20be
--- /dev/null
+++ b/gr-digital/python/utils/tagged_streams.py
@@ -0,0 +1,112 @@
+from gnuradio import gr
+try: import pmt
+except: from gruel import pmt
+
+def make_lengthtags(lengths, offsets, tagname='length', vlen=1):
+ tags = []
+ assert(len(offsets) == len(lengths))
+ for offset, length in zip(offsets, lengths):
+ tag = gr.gr_tag_t()
+ tag.offset = offset/vlen
+ tag.key = pmt.pmt_string_to_symbol(tagname)
+ tag.value = pmt.pmt_from_long(length/vlen)
+ tags.append(tag)
+ return tags
+
+def string_to_vector(string):
+ v = []
+ for s in string:
+ v.append(ord(s))
+ return v
+
+def strings_to_vectors(strings, lengthtagname):
+ vs = [string_to_vector(string) for string in strings]
+ return packets_to_vectors(vs, lengthtagname)
+
+def vector_to_string(v):
+ s = []
+ for d in v:
+ s.append(chr(d))
+ return ''.join(s)
+
+def vectors_to_strings(data, tags, lengthtagname):
+ packets = vectors_to_packets(data, tags, lengthtagname)
+ return [vector_to_string(packet) for packet in packets]
+
+def count_bursts(data, tags, lengthtagname, vlen=1):
+ lengthtags = [t for t in tags
+ if pmt.pmt_symbol_to_string(t.key) == lengthtagname]
+ lengths = {}
+ for tag in lengthtags:
+ if tag.offset in lengths:
+ raise ValueError(
+ "More than one tags with key {0} with the same offset={1}."
+ .format(lengthtagname, tag.offset))
+ lengths[tag.offset] = pmt.pmt_to_long(tag.value)*vlen
+ in_burst = False
+ in_packet = False
+ packet_length = None
+ packet_pos = None
+ burst_count = 0
+ for pos in range(len(data)):
+ if pos in lengths:
+ if in_packet:
+ print("Got tag at pos {0} current packet_pos is {1}".format(pos, packet_pos))
+ raise StandardError("Received packet tag while in packet.")
+ packet_pos = -1
+ packet_length = lengths[pos]
+ in_packet = True
+ if not in_burst:
+ burst_count += 1
+ in_burst = True
+ elif not in_packet:
+ in_burst = False
+ if in_packet:
+ packet_pos += 1
+ if packet_pos == packet_length-1:
+ in_packet = False
+ packet_pos = None
+ return burst_count
+
+def vectors_to_packets(data, tags, lengthtagname, vlen=1):
+ lengthtags = [t for t in tags
+ if pmt.pmt_symbol_to_string(t.key) == lengthtagname]
+ lengths = {}
+ for tag in lengthtags:
+ if tag.offset in lengths:
+ raise ValueError(
+ "More than one tags with key {0} with the same offset={1}."
+ .format(lengthtagname, tag.offset))
+ lengths[tag.offset] = pmt.pmt_to_long(tag.value)*vlen
+ if 0 not in lengths:
+ raise ValueError("There is no tag with key {0} and an offset of 0"
+ .format(lengthtagname))
+ pos = 0
+ packets = []
+ while pos < len(data):
+ if pos not in lengths:
+ raise ValueError("There is no tag with key {0} and an offset of {1}."
+ "We were expecting one."
+ .format(lengthtagname, pos))
+ length = lengths[pos]
+ if length == 0:
+ raise ValueError("Packets cannot have zero length.")
+ if pos+length > len(data):
+ raise ValueError("The final packet is incomplete.")
+ packets.append(data[pos: pos+length])
+ pos += length
+ return packets
+
+def packets_to_vectors(packets, lengthtagname, vlen=1):
+ tags = []
+ data = []
+ offset = 0
+ for packet in packets:
+ data.extend(packet)
+ tag = gr.gr_tag_t()
+ tag.offset = offset/vlen
+ tag.key = pmt.pmt_string_to_symbol(lengthtagname)
+ tag.value = pmt.pmt_from_long(len(packet)/vlen)
+ tags.append(tag)
+ offset = offset + len(packet)
+ return data, tags
diff --git a/gr-digital/swig/CMakeLists.txt b/gr-digital/swig/CMakeLists.txt
index 4107116bce..5e693af896 100644
--- a/gr-digital/swig/CMakeLists.txt
+++ b/gr-digital/swig/CMakeLists.txt
@@ -162,8 +162,8 @@ install(
digital_map_bb.i
digital_mpsk_receiver_cc.i
digital_mpsk_snr_est_cc.i
- digital_ofdm_cyclic_prefixer.i
digital_ofdm_frame_acquisition.i
+ digital_ofdm_cyclic_prefixer.i
digital_ofdm_frame_sink.i
digital_ofdm_insert_preamble.i
digital_ofdm_mapper_bcv.i
diff --git a/gr-digital/swig/digital_constellation.i b/gr-digital/swig/digital_constellation.i
index 248f900149..4c4f8aa01d 100644
--- a/gr-digital/swig/digital_constellation.i
+++ b/gr-digital/swig/digital_constellation.i
@@ -102,6 +102,33 @@ public:
float width_real_sectors, float width_imag_sectors);
};
+class digital_constellation_expl_rect;
+typedef boost::shared_ptr<digital_constellation_expl_rect> digital_constellation_expl_rect_sptr;
+%template(digital_constellation_expl_rect_sptr) boost::shared_ptr<digital_constellation_expl_rect>;
+%rename(constellation_expl_rect) digital_make_constellation_expl_rect;
+digital_constellation_expl_rect_sptr digital_make_constellation_expl_rect(
+ std::vector<gr_complex> constellation,
+ std::vector<unsigned int> pre_diff_code,
+ unsigned int rotational_symmetry,
+ unsigned int real_sectors, unsigned int imag_sectors,
+ float width_real_sectors, float width_imag_sectors,
+ std::vector<unsigned int> sector_values
+);
+%ignore digital_constellation_expl_rect;
+
+class digital_constellation_expl_rect : public digital_constellation_rect
+{
+public:
+ digital_constellation_expl_rect (
+ std::vector<gr_complex> constellation,
+ std::vector<unsigned int> pre_diff_code,
+ unsigned int rotational_symmetry,
+ unsigned int real_sectors, unsigned int imag_sectors,
+ float width_real_sectors, float width_imag_sectors,
+ std::vector<unsigned int> sector_values
+ );
+};
+
class digital_constellation_psk;
typedef boost::shared_ptr<digital_constellation_psk> digital_constellation_psk_sptr;
%template(digital_constellation_psk_sptr) boost::shared_ptr<digital_constellation_psk>;
@@ -198,6 +225,7 @@ public:
digital_constellation_calcdist_sptr.__repr__ = lambda self: '<constellation calcdist (m=%s)>' % str(len(self.points()))
digital_constellation_rect_sptr.__repr__ = lambda self: '<constellation rect (m=%s)>' % str(len(self.points()))
+digital_constellation_expl_rect_sptr.__repr__ = lambda self: '<constellation expl_rect (m=%s)>' % str(len(self.points()))
digital_constellation_psk_sptr.__repr__ = lambda self: '<constellation psk (m=%s)>' % str(len(self.points()))
digital_constellation_bpsk_sptr.__repr__ = lambda self: '<constellation bpsk>'
digital_constellation_qpsk_sptr.__repr__ = lambda self: '<constellation qpsk>'
diff --git a/gr-digital/swig/digital_crc32_bb.i b/gr-digital/swig/digital_crc32_bb.i
new file mode 100644
index 0000000000..45b240793d
--- /dev/null
+++ b/gr-digital/swig/digital_crc32_bb.i
@@ -0,0 +1,32 @@
+/* -*- c++ -*- */
+/* Copyright 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.
+ */
+
+GR_SWIG_BLOCK_MAGIC(digital, crc32_bb)
+
+digital_crc32_bb_sptr
+digital_make_crc32_bb (bool check=false, const std::string& lengthtagname="packet_len");
+
+class digital_crc32_bb : public gr_block
+{
+ private:
+ digital_crc32_bb(bool check, const std::string& lengthtagname);
+};
+
diff --git a/gr-digital/swig/digital_ofdm_carrier_allocator_cvc.i b/gr-digital/swig/digital_ofdm_carrier_allocator_cvc.i
new file mode 100644
index 0000000000..1663a4de3d
--- /dev/null
+++ b/gr-digital/swig/digital_ofdm_carrier_allocator_cvc.i
@@ -0,0 +1,37 @@
+/* -*- c++ -*- */
+/* Copyright 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.
+ */
+
+GR_SWIG_BLOCK_MAGIC(digital, ofdm_carrier_allocator_cvc);
+
+digital_ofdm_carrier_allocator_cvc_sptr
+digital_make_ofdm_carrier_allocator_cvc (
+ int fft_len,
+ const std::vector<std::vector<int> > &occupied_carriers,
+ const std::vector<std::vector<int> > &pilot_carriers,
+ const std::vector<std::vector<gr_complex> > &pilot_symbols,
+ const std::string &len_tag_key = "packet_len");
+
+class digital_ofdm_carrier_allocator_cvc : public gr_tagged_stream_block
+{
+ private:
+ digital_ofdm_carrier_allocator_cvc(int fft_len, const std::vector<std::vector<int> > &occupied_carriers, const std::vector<std::vector<int> > &pilot_carriers, const std::vector<std::vector<gr_complex> > &pilot_symbols, const std::string &len_tag_key);
+};
+
diff --git a/gr-digital/swig/digital_ofdm_chanest_vcvc.i b/gr-digital/swig/digital_ofdm_chanest_vcvc.i
new file mode 100644
index 0000000000..aa6e79b5c2
--- /dev/null
+++ b/gr-digital/swig/digital_ofdm_chanest_vcvc.i
@@ -0,0 +1,40 @@
+/* -*- c++ -*- */
+/* Copyright 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.
+ */
+
+GR_SWIG_BLOCK_MAGIC(digital, ofdm_chanest_vcvc);
+
+digital_ofdm_chanest_vcvc_sptr
+digital_make_ofdm_chanest_vcvc (
+ const std::vector<gr_complex> &sync_symbol1,
+ const std::vector<gr_complex> &sync_symbol2,
+ int n_data_symbols,
+ int eq_noise_red_len=0,
+ int max_carr_offset=-1,
+ bool force_one_sync_symbol=false);
+
+class digital_ofdm_chanest_vcvc : public gr_block
+{
+ private:
+ digital_ofdm_chanest_vcvc(const std::vector<gr_complex> &sync_symbol1, const std::vector<gr_complex> &sync_symbol2, int n_data_symbols, int eq_noise_red_len, int max_carr_offset, bool force_one_sync_symbol);
+
+ public:
+};
+
diff --git a/gr-digital/swig/digital_ofdm_cyclic_prefixer.i b/gr-digital/swig/digital_ofdm_cyclic_prefixer.i
index 56d1629a8a..19ffd6a12b 100644
--- a/gr-digital/swig/digital_ofdm_cyclic_prefixer.i
+++ b/gr-digital/swig/digital_ofdm_cyclic_prefixer.i
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2006,2009,2011 Free Software Foundation, Inc.
+ * Copyright 2004-2006,2011 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -20,15 +20,16 @@
* Boston, MA 02110-1301, USA.
*/
-GR_SWIG_BLOCK_MAGIC(digital,ofdm_cyclic_prefixer)
+GR_SWIG_BLOCK_MAGIC(digital,ofdm_cyclic_prefixer);
-digital_ofdm_cyclic_prefixer_sptr
-digital_make_ofdm_cyclic_prefixer (size_t input_size, size_t output_size);
+digital_ofdm_cyclic_prefixer_sptr
+digital_make_ofdm_cyclic_prefixer (size_t input_size,
+ size_t output_size,
+ int rolloff_len=0,
+ const std::string &len_tag_key="");
-class digital_ofdm_cyclic_prefixer : public gr_sync_interpolator
-{
- protected:
- digital_ofdm_cyclic_prefixer (size_t input_size, size_t output_size);
- public:
+class digital_ofdm_cyclic_prefixer : public gr_tagged_stream_block
+{
};
+
diff --git a/gr-digital/swig/digital_ofdm_equalizer_base.i b/gr-digital/swig/digital_ofdm_equalizer_base.i
new file mode 100644
index 0000000000..c862fed09d
--- /dev/null
+++ b/gr-digital/swig/digital_ofdm_equalizer_base.i
@@ -0,0 +1,64 @@
+/* -*- c++ -*- */
+/* Copyright 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.
+ */
+
+
+
+class digital_ofdm_equalizer_base;
+typedef boost::shared_ptr<digital_ofdm_equalizer_base> digital_ofdm_equalizer_base_sptr;
+%template(digital_ofdm_equalizer_base_sptr) boost::shared_ptr<digital_ofdm_equalizer_base>;
+%ignore digital_ofdm_equalizer_base;
+
+class digital_ofdm_equalizer_1d_pilots;
+typedef boost::shared_ptr<digital_ofdm_equalizer_1d_pilots> digital_ofdm_equalizer_1d_pilots_sptr;
+%template(digital_ofdm_equalizer_1d_pilots_sptr) boost::shared_ptr<digital_ofdm_equalizer_1d_pilots>;
+%ignore digital_ofdm_equalizer_1d_pilots;
+
+class digital_ofdm_equalizer_base
+{
+ public:
+ digital_ofdm_equalizer_base(int fft_len);
+
+ virtual void reset() = 0;
+ void set_carrier_offset(int offset) { d_carr_offset = offset; };
+ virtual void equalize(
+ gr_complex *frame,
+ int n_sym,
+ const std::vector<gr_complex> &initial_taps = std::vector<gr_complex>(),
+ const std::vector<gr_tag_t> &tags = std::vector<gr_tag_t>()) = 0;
+ virtual void get_channel_state(std::vector<gr_complex> &taps) = 0;
+ digital_ofdm_equalizer_base_sptr base();
+};
+
+
+class digital_ofdm_equalizer_1d_pilots : public digital_ofdm_equalizer_base
+{
+ public:
+ digital_ofdm_equalizer_1d_pilots(
+ int fft_len,
+ const std::vector<std::vector<int> > &occupied_carriers,
+ const std::vector<std::vector<int> > &pilot_carriers,
+ const std::vector<std::vector<gr_complex> > &pilot_symbols,
+ int symbols_skipped,
+ bool input_is_shifted);
+
+ void reset();
+};
+
diff --git a/gr-digital/swig/digital_ofdm_equalizer_simpledfe.i b/gr-digital/swig/digital_ofdm_equalizer_simpledfe.i
new file mode 100644
index 0000000000..b9a26e246f
--- /dev/null
+++ b/gr-digital/swig/digital_ofdm_equalizer_simpledfe.i
@@ -0,0 +1,58 @@
+/* -*- c++ -*- */
+/* Copyright 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.
+ */
+
+
+class digital_ofdm_equalizer_simpledfe;
+typedef boost::shared_ptr<digital_ofdm_equalizer_simpledfe> digital_ofdm_equalizer_simpledfe_sptr;
+%template(digital_ofdm_equalizer_simpledfe_sptr) boost::shared_ptr<digital_ofdm_equalizer_simpledfe>;
+%rename(ofdm_equalizer_simpledfe) digital_make_ofdm_equalizer_simpledfe;
+digital_ofdm_equalizer_simpledfe_sptr
+digital_make_ofdm_equalizer_simpledfe(
+ int fft_len,
+ const digital_constellation_sptr &constellation,
+ const std::vector<std::vector<int> > &occupied_carriers = std::vector<std::vector<int> >(),
+ const std::vector<std::vector<int> > &pilot_carriers = std::vector<std::vector<int> >(),
+ const std::vector<std::vector<gr_complex> > &pilot_symbols = std::vector<std::vector<gr_complex> >(),
+ int symbols_skipped = 0,
+ float alpha = 0.1,
+ bool input_is_shifted = true);
+%ignore digital_ofdm_equalizer_simpledfe;
+
+class digital_ofdm_equalizer_simpledfe : public digital_ofdm_equalizer_1d_pilots
+{
+ public:
+ digital_ofdm_equalizer_simpledfe(
+ int fft_len,
+ const digital_constellation_sptr &constellation,
+ const std::vector<std::vector<int> > &occupied_carriers = std::vector<std::vector<int> >(),
+ const std::vector<std::vector<int> > &pilot_carriers = std::vector<std::vector<int> >(),
+ const std::vector<std::vector<gr_complex> > &pilot_symbols = std::vector<std::vector<gr_complex> >(),
+ int symbols_skipped = 0,
+ float alpha = 0.1,
+ bool input_is_shifted = true);
+
+ void equalize(gr_complex *frame,
+ int n_sym,
+ const std::vector<gr_complex> &initial_taps = std::vector<gr_complex>(),
+ const std::vector<gr_tag_t> &tags = std::vector<gr_tag_t>());
+ void get_channel_state(std::vector<gr_complex> &taps);
+};
+
diff --git a/gr-digital/swig/digital_ofdm_equalizer_static.i b/gr-digital/swig/digital_ofdm_equalizer_static.i
new file mode 100644
index 0000000000..3e99403ff7
--- /dev/null
+++ b/gr-digital/swig/digital_ofdm_equalizer_static.i
@@ -0,0 +1,55 @@
+/* -*- c++ -*- */
+/* Copyright 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.
+ */
+
+
+class digital_ofdm_equalizer_static;
+typedef boost::shared_ptr<digital_ofdm_equalizer_static> digital_ofdm_equalizer_static_sptr;
+%template(digital_ofdm_equalizer_static_sptr) boost::shared_ptr<digital_ofdm_equalizer_static>;
+%rename(ofdm_equalizer_static) digital_make_ofdm_equalizer_static;
+digital_ofdm_equalizer_static_sptr
+digital_make_ofdm_equalizer_static(
+ int fft_len,
+ const std::vector<std::vector<int> > &occupied_carriers = std::vector<std::vector<int> >(),
+ const std::vector<std::vector<int> > &pilot_carriers = std::vector<std::vector<int> >(),
+ const std::vector<std::vector<gr_complex> > &pilot_symbols = std::vector<std::vector<gr_complex> >(),
+ int symbols_skipped = 0,
+ bool input_is_shifted = true);
+%ignore digital_ofdm_equalizer_static;
+
+class digital_ofdm_equalizer_static : public digital_ofdm_equalizer_1d_pilots
+{
+ public:
+ digital_ofdm_equalizer_static(
+ int fft_len,
+ const std::vector<std::vector<int> > &occupied_carriers = std::vector<std::vector<int> >(),
+ const std::vector<std::vector<int> > &pilot_carriers = std::vector<std::vector<int> >(),
+ const std::vector<std::vector<gr_complex> > &pilot_symbols = std::vector<std::vector<gr_complex> >(),
+ int symbols_skipped = 0,
+ bool input_is_shifted = true);
+ ~digital_ofdm_equalizer_static();
+
+ void equalize(gr_complex *frame,
+ int n_sym,
+ const std::vector<gr_complex> &initial_taps = std::vector<gr_complex>(),
+ const std::vector<gr_tag_t> &tags = std::vector<gr_tag_t>());
+ void get_channel_state(std::vector<gr_complex> &taps);
+};
+
diff --git a/gr-digital/swig/digital_ofdm_sync_sc_cfb.i b/gr-digital/swig/digital_ofdm_sync_sc_cfb.i
new file mode 100644
index 0000000000..6a863ca3f9
--- /dev/null
+++ b/gr-digital/swig/digital_ofdm_sync_sc_cfb.i
@@ -0,0 +1,33 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 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.
+ */
+
+GR_SWIG_BLOCK_MAGIC(digital, ofdm_sync_sc_cfb)
+
+digital_ofdm_sync_sc_cfb_sptr
+digital_make_ofdm_sync_sc_cfb (int fft_len, int cp_len);
+
+class digital_ofdm_sync_sc_cfb : public gr_hier_block2
+{
+ private:
+ digital_ofdm_sync_sc_cfb(int fft_len, int cp_len);
+};
+
diff --git a/gr-digital/swig/digital_swig.i b/gr-digital/swig/digital_swig.i
index a5f0251a43..2f36e13c8e 100644
--- a/gr-digital/swig/digital_swig.i
+++ b/gr-digital/swig/digital_swig.i
@@ -19,6 +19,8 @@
* Boston, MA 02110-1301, USA.
*/
+#define DIGITAL_API
+
%include "gnuradio.i"
//load generated python docstrings
@@ -81,6 +83,20 @@ enum snr_est_type_t {
#include "digital_probe_mpsk_snr_est_c.h"
#include "digital_scrambler_bb.h"
#include "digital_simple_framer.h"
+#include "digital_ofdm_sync_sc_cfb.h"
+#include "digital_ofdm_chanest_vcvc.h"
+#include "digital_crc32_bb.h"
+#include "digital_ofdm_carrier_allocator_cvc.h"
+#include "digital_ofdm_equalizer_base.h"
+#include "digital_ofdm_equalizer_simpledfe.h"
+#include "digital_ofdm_equalizer_static.h"
+#include "digital/ofdm_frame_equalizer_vcvc.h"
+#include "digital/packet_header_default.h"
+#include "digital/packet_header_ofdm.h"
+#include "digital/packet_headergenerator_bb.h"
+#include "digital/ofdm_serializer_vcc.h"
+#include "digital/packet_headerparser_b.h"
+#include "digital/header_payload_demux.h"
#include "digital_simple_correlator.h"
%}
@@ -126,4 +142,28 @@ enum snr_est_type_t {
%include "digital_probe_mpsk_snr_est_c.i"
%include "digital_scrambler_bb.i"
%include "digital_simple_framer.i"
+%include "digital_ofdm_sync_sc_cfb.i"
+%include "digital_ofdm_chanest_vcvc.i"
+%include "digital_crc32_bb.i"
+%include "digital_ofdm_carrier_allocator_cvc.i"
+%include "digital_ofdm_equalizer_base.i"
+%include "digital_ofdm_equalizer_simpledfe.i"
+%include "digital_ofdm_equalizer_static.i"
+%include "digital/ofdm_frame_equalizer_vcvc.h"
+GR_SWIG_BLOCK_MAGIC2(digital, ofdm_frame_equalizer_vcvc);
+
+%include "digital/packet_header_default.h"
+%include "digital/packet_header_ofdm.h"
+%include "packet_header.i"
+
+%include "digital/packet_headergenerator_bb.h"
+GR_SWIG_BLOCK_MAGIC2(digital, packet_headergenerator_bb);
+
+%include "digital/ofdm_serializer_vcc.h"
+GR_SWIG_BLOCK_MAGIC2(digital, ofdm_serializer_vcc);
+
+%include "digital/packet_headerparser_b.h"
+GR_SWIG_BLOCK_MAGIC2(digital, packet_headerparser_b);
+%include "digital/header_payload_demux.h"
+GR_SWIG_BLOCK_MAGIC2(digital, header_payload_demux);
%include "digital_simple_correlator.i"
diff --git a/gr-digital/swig/packet_header.i b/gr-digital/swig/packet_header.i
new file mode 100644
index 0000000000..7c06d19f71
--- /dev/null
+++ b/gr-digital/swig/packet_header.i
@@ -0,0 +1,34 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 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.
+ */
+
+%template(packet_header_default_sptr) boost::shared_ptr<gr::digital::packet_header_default>;
+%pythoncode %{
+packet_header_default_sptr.__repr__ = lambda self: "<packet_header_default>"
+packet_header_default = packet_header_default .make;
+%}
+
+%template(packet_header_ofdm_sptr) boost::shared_ptr<gr::digital::packet_header_ofdm>;
+%pythoncode %{
+packet_header_ofdm_sptr.__repr__ = lambda self: "<packet_header_ofdm>"
+packet_header_ofdm = packet_header_ofdm .make;
+%}
+
diff --git a/gr-fcd/lib/CMakeLists.txt b/gr-fcd/lib/CMakeLists.txt
index a5c95ceb7d..8e4afafdb1 100644
--- a/gr-fcd/lib/CMakeLists.txt
+++ b/gr-fcd/lib/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright 2012 Free Software Foundation, Inc.
+# Copyright 2012-2013 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -36,6 +36,9 @@ include_directories(
link_directories(${Boost_LIBRARY_DIRS})
+include_directories(${LOG4CPP_INCLUDE_DIRS})
+link_directories(${LOG4CPP_LIBRARY_DIRS})
+
########################################################################
# Setup library
########################################################################
@@ -51,6 +54,18 @@ list(APPEND fcd_libs
if (WIN32)
list(APPEND fcd_libs setupapi)
+
+ #Add Windows DLL resource file if using MSVC
+ if(MSVC)
+ include(${CMAKE_SOURCE_DIR}/cmake/Modules/GrVersion.cmake)
+
+ configure_file(
+ ${CMAKE_CURRENT_SOURCE_DIR}/gnuradio-fcd.rc.in
+ ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-fcd.rc
+ @ONLY)
+
+ list(APPEND gr_fcd_sources ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-fcd.rc)
+ endif(MSVC)
endif()
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
@@ -67,7 +82,7 @@ add_library(gnuradio-fcd SHARED ${gr_fcd_sources})
if (LINUX)
list(APPEND fcd_libs rt)
endif()
-target_link_libraries(gnuradio-fcd ${fcd_libs})
+target_link_libraries(gnuradio-fcd ${fcd_libs} ${LOG4CPP_LIBRARIES})
GR_LIBRARY_FOO(gnuradio-fcd RUNTIME_COMPONENT "fcd_runtime" DEVEL_COMPONENT "fcd_devel")
diff --git a/gr-fcd/lib/gnuradio-fcd.rc.in b/gr-fcd/lib/gnuradio-fcd.rc.in
new file mode 100644
index 0000000000..01c502c4dd
--- /dev/null
+++ b/gr-fcd/lib/gnuradio-fcd.rc.in
@@ -0,0 +1,55 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2013 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.
+ */
+
+#include <afxres.h>
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@
+ PRODUCTVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@
+ FILEFLAGSMASK 0x3fL
+#ifndef NDEBUG
+ FILEFLAGS 0x0L
+#else
+ FILEFLAGS 0x1L
+#endif
+ FILEOS VOS__WINDOWS32
+ FILETYPE VFT_DLL
+ FILESUBTYPE VFT2_DRV_INSTALLABLE
+ BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904b0"
+ BEGIN
+ VALUE "FileDescription", "gnuradio-fcd"
+ VALUE "FileVersion", "@VERSION@"
+ VALUE "InternalName", "gnuradio-fcd.dll"
+ VALUE "LegalCopyright", "Licensed under GPLv3 or any later version"
+ VALUE "OriginalFilename", "gnuradio-fcd.dll"
+ VALUE "ProductName", "gnuradio-fcd"
+ VALUE "ProductVersion", "@VERSION@"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+ END
diff --git a/gr-fft/lib/CMakeLists.txt b/gr-fft/lib/CMakeLists.txt
index 26fcaa7cde..9382a48c3b 100644
--- a/gr-fft/lib/CMakeLists.txt
+++ b/gr-fft/lib/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright 2012 Free Software Foundation, Inc.
+# Copyright 2012-2013 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -50,6 +50,20 @@ list(APPEND fft_libs
${FFTW3F_LIBRARIES}
)
+#Add Windows DLL resource file if using MSVC
+if(MSVC)
+ include(${CMAKE_SOURCE_DIR}/cmake/Modules/GrVersion.cmake)
+
+ configure_file(
+ ${CMAKE_CURRENT_SOURCE_DIR}/gnuradio-fft.rc.in
+ ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-fft.rc
+ @ONLY)
+
+ list(APPEND fft_sources
+ ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-fft.rc
+ )
+endif(MSVC)
+
if(FFTW3F_THREADS_LIBRARIES)
list(APPEND fft_libs ${FFTW3F_THREADS_LIBRARIES})
add_definitions("-DFFTW3F_THREADS")
diff --git a/gr-fft/lib/gnuradio-fft.rc.in b/gr-fft/lib/gnuradio-fft.rc.in
new file mode 100644
index 0000000000..0c12bc91e7
--- /dev/null
+++ b/gr-fft/lib/gnuradio-fft.rc.in
@@ -0,0 +1,55 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2013 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.
+ */
+
+#include <afxres.h>
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@
+ PRODUCTVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@
+ FILEFLAGSMASK 0x3fL
+#ifndef NDEBUG
+ FILEFLAGS 0x0L
+#else
+ FILEFLAGS 0x1L
+#endif
+ FILEOS VOS__WINDOWS32
+ FILETYPE VFT_DLL
+ FILESUBTYPE VFT2_DRV_INSTALLABLE
+ BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904b0"
+ BEGIN
+ VALUE "FileDescription", "gnuradio-fft"
+ VALUE "FileVersion", "@VERSION@"
+ VALUE "InternalName", "gnuradio-fft.dll"
+ VALUE "LegalCopyright", "Licensed under GPLv3 or any later version"
+ VALUE "OriginalFilename", "gnuradio-fft.dll"
+ VALUE "ProductName", "gnuradio-fft"
+ VALUE "ProductVersion", "@VERSION@"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+ END
diff --git a/gr-filter/grc/pfb_arb_resampler.xml b/gr-filter/grc/pfb_arb_resampler.xml
index f3048000ac..b2065ede0b 100644
--- a/gr-filter/grc/pfb_arb_resampler.xml
+++ b/gr-filter/grc/pfb_arb_resampler.xml
@@ -14,7 +14,8 @@
$taps,
$nfilts)
</make>
- <callback>set_taps($taps)</callback>
+ <callback>set_taps($taps)</callback>
+ <callback>set_rate($rrate)</callback>
<param>
<name>Type</name>
<key>type</key>
diff --git a/gr-filter/lib/CMakeLists.txt b/gr-filter/lib/CMakeLists.txt
index 626f5521f2..f9937fa18d 100644
--- a/gr-filter/lib/CMakeLists.txt
+++ b/gr-filter/lib/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright 2012 Free Software Foundation, Inc.
+# Copyright 2012-2013 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -97,10 +97,14 @@ include_directories(
${GNURADIO_CORE_INCLUDE_DIRS}
${VOLK_INCLUDE_DIRS}
${GRUEL_INCLUDE_DIRS}
+ ${LOG4CPP_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS}
)
-link_directories(${Boost_LIBRARY_DIRS})
+link_directories(
+ ${Boost_LIBRARY_DIRS}
+ ${LOG4CPP_LIBRARIES}
+)
########################################################################
# Setup library
@@ -137,6 +141,20 @@ list(APPEND filter_sources
channel_model_impl.cc
)
+#Add Windows DLL resource file if using MSVC
+if(MSVC)
+ include(${CMAKE_SOURCE_DIR}/cmake/Modules/GrVersion.cmake)
+
+ configure_file(
+ ${CMAKE_CURRENT_SOURCE_DIR}/gnuradio-filter.rc.in
+ ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-filter.rc
+ @ONLY)
+
+ list(APPEND filter_sources
+ ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-filter.rc
+ )
+endif(MSVC)
+
list(APPEND filter_libs
gnuradio-core
gnuradio-fft
diff --git a/gr-filter/lib/gnuradio-filter.rc.in b/gr-filter/lib/gnuradio-filter.rc.in
new file mode 100644
index 0000000000..8fae9746e9
--- /dev/null
+++ b/gr-filter/lib/gnuradio-filter.rc.in
@@ -0,0 +1,55 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2013 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.
+ */
+
+#include <afxres.h>
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@
+ PRODUCTVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@
+ FILEFLAGSMASK 0x3fL
+#ifndef NDEBUG
+ FILEFLAGS 0x0L
+#else
+ FILEFLAGS 0x1L
+#endif
+ FILEOS VOS__WINDOWS32
+ FILETYPE VFT_DLL
+ FILESUBTYPE VFT2_DRV_INSTALLABLE
+ BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904b0"
+ BEGIN
+ VALUE "FileDescription", "gnuradio-filter"
+ VALUE "FileVersion", "@VERSION@"
+ VALUE "InternalName", "gnuradio-filter.dll"
+ VALUE "LegalCopyright", "Licensed under GPLv3 or any later version"
+ VALUE "OriginalFilename", "gnuradio-filter.dll"
+ VALUE "ProductName", "gnuradio-filter"
+ VALUE "ProductVersion", "@VERSION@"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+ END
diff --git a/gr-howto-write-a-block/CMakeLists.txt b/gr-howto-write-a-block/CMakeLists.txt
index 02b13c6b69..1a9f403dd2 100644
--- a/gr-howto-write-a-block/CMakeLists.txt
+++ b/gr-howto-write-a-block/CMakeLists.txt
@@ -94,6 +94,10 @@ if(NOT GNURADIO_CORE_FOUND)
message(FATAL_ERROR "GnuRadio Core required to compile howto")
endif()
+# Handle gr_log enable/disable
+include(GrMiscUtils) #define LIB_SUFFIX
+GR_LOGGING()
+
########################################################################
# Setup the include and linker paths
########################################################################
@@ -101,12 +105,14 @@ include_directories(
${CMAKE_SOURCE_DIR}/include
${GNURADIO_CORE_INCLUDE_DIRS}
${GRUEL_INCLUDE_DIRS}
+ ${LOG4CPP_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS}
)
link_directories(
${GNURADIO_CORE_LIBRARY_DIRS}
${GRUEL_LIBRARY_DIRS}
+ ${LOG4CPP_LIBRARY_DIRS}
${Boost_LIBRARY_DIRS}
)
diff --git a/gr-howto-write-a-block/cmake/Modules/FindLog4cpp.cmake b/gr-howto-write-a-block/cmake/Modules/FindLog4cpp.cmake
new file mode 100644
index 0000000000..0b7208630f
--- /dev/null
+++ b/gr-howto-write-a-block/cmake/Modules/FindLog4cpp.cmake
@@ -0,0 +1,58 @@
+# - Find Log4cpp
+# Find the native LOG4CPP includes and library
+#
+# LOG4CPP_INCLUDE_DIR - where to find LOG4CPP.h, etc.
+# LOG4CPP_LIBRARIES - List of libraries when using LOG4CPP.
+# LOG4CPP_FOUND - True if LOG4CPP found.
+
+
+if (LOG4CPP_INCLUDE_DIR)
+ # Already in cache, be silent
+ set(LOG4CPP_FIND_QUIETLY TRUE)
+endif ()
+
+find_path(LOG4CPP_INCLUDE_DIR log4cpp/Category.hh
+ /opt/local/include
+ /usr/local/include
+ /usr/include
+)
+
+set(LOG4CPP_NAMES log4cpp)
+find_library(LOG4CPP_LIBRARY
+ NAMES ${LOG4CPP_NAMES}
+ PATHS /usr/lib /usr/local/lib /opt/local/lib
+)
+
+message("#####################")
+message("LOG INCLEUDE :${LOG4CPP_INCLUDE_DIR}")
+message("LOG LIBRARY :${LOG4CPP_LIBRARY}")
+
+
+message("#####################")
+
+if (LOG4CPP_INCLUDE_DIR AND LOG4CPP_LIBRARY)
+ set(LOG4CPP_FOUND TRUE)
+ set(LOG4CPP_LIBRARIES ${LOG4CPP_LIBRARY} )
+else ()
+ set(LOG4CPP_FOUND FALSE)
+ set(LOG4CPP_LIBRARIES )
+endif ()
+
+if (LOG4CPP_FOUND)
+ if (NOT LOG4CPP_FIND_QUIETLY)
+ message(STATUS "Found LOG4CPP: ${LOG4CPP_LIBRARIES}")
+ endif ()
+else ()
+ if (LOG4CPP_FIND_REQUIRED)
+ message(STATUS "Looked for LOG4CPP libraries named ${LOG4CPPS_NAMES}.")
+ message(FATAL_ERROR "Could NOT find LOG4CPP library")
+ endif ()
+endif ()
+
+message("internal libs: ${LOG4CPP_LIBRARIES}")
+
+mark_as_advanced(
+ LOG4CPP_LIBRARY
+ LOG4CPP_LIBRARIES
+ LOG4CPP_INCLUDE_DIR
+ )
diff --git a/gr-howto-write-a-block/cmake/Modules/GrMiscUtils.cmake b/gr-howto-write-a-block/cmake/Modules/GrMiscUtils.cmake
index 9331d5debc..876e71687f 100644
--- a/gr-howto-write-a-block/cmake/Modules/GrMiscUtils.cmake
+++ b/gr-howto-write-a-block/cmake/Modules/GrMiscUtils.cmake
@@ -208,3 +208,46 @@ function(GR_GEN_TARGET_DEPS name var)
set(${var} "DEPENDS;${name};COMMAND;${name}" PARENT_SCOPE)
endif()
endfunction(GR_GEN_TARGET_DEPS)
+
+
+########################################################################
+# Control use of gr_logger
+# Usage:
+# GR_LOGGING()
+#
+# Will set ENABLE_GR_LOG to 1 by default.
+# Can manually set with -DENABLE_GR_LOG=0|1
+########################################################################
+function(GR_LOGGING)
+ find_package(Log4cpp)
+
+ OPTION(ENABLE_GR_LOG "Use gr_logger" ON)
+ if(ENABLE_GR_LOG)
+ # If gr_logger is enabled, make it usable
+ add_definitions( -DENABLE_GR_LOG )
+
+ # also test LOG4CPP; if we have it, use this version of the logger
+ # otherwise, default to the stdout/stderr model.
+ if(LOG4CPP_FOUND)
+ SET(HAVE_LOG4CPP True)
+ add_definitions( -DHAVE_LOG4CPP )
+ else(LOG4CPP_FOUND)
+ SET(HAVE_LOG4CPP False)
+ SET(LOG4CPP_INCLUDE_DIRS "")
+ SET(LOG4CPP_LIBRARY_DIRS "")
+ SET(LOG4CPP_LIBRARIES "")
+ endif(LOG4CPP_FOUND)
+
+ SET(ENABLE_GR_LOG ${ENABLE_GR_LOG} CACHE INTERNAL "" FORCE)
+
+ else(ENABLE_GR_LOG)
+ SET(HAVE_LOG4CPP False)
+ SET(LOG4CPP_INCLUDE_DIRS)
+ SET(LOG4CPP_LIBRARY_DIRS)
+ SET(LOG4CPP_LIBRARIES)
+ endif(ENABLE_GR_LOG)
+
+ message(STATUS "ENABLE_GR_LOG set to ${ENABLE_GR_LOG}.")
+ message(STATUS "HAVE_LOG4CPP set to ${HAVE_LOG4CPP}.")
+
+endfunction(GR_LOGGING)
diff --git a/gr-howto-write-a-block/lib/CMakeLists.txt b/gr-howto-write-a-block/lib/CMakeLists.txt
index 835ae02d60..dee02f08c7 100644
--- a/gr-howto-write-a-block/lib/CMakeLists.txt
+++ b/gr-howto-write-a-block/lib/CMakeLists.txt
@@ -23,7 +23,11 @@
include(GrPlatform) #define LIB_SUFFIX
add_library(gnuradio-howto SHARED howto_square_ff.cc howto_square2_ff.cc)
-target_link_libraries(gnuradio-howto ${Boost_LIBRARIES} ${GRUEL_LIBRARIES} ${GNURADIO_CORE_LIBRARIES})
+target_link_libraries(gnuradio-howto
+ ${Boost_LIBRARIES}
+ ${GRUEL_LIBRARIES}
+ ${GNURADIO_CORE_LIBRARIES}
+ ${LOG4CPP_LIBRARIES})
set_target_properties(gnuradio-howto PROPERTIES DEFINE_SYMBOL "gnuradio_howto_EXPORTS")
########################################################################
diff --git a/gr-noaa/lib/CMakeLists.txt b/gr-noaa/lib/CMakeLists.txt
index 3f369f8aff..4830fe4f95 100644
--- a/gr-noaa/lib/CMakeLists.txt
+++ b/gr-noaa/lib/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright 2011 Free Software Foundation, Inc.
+# Copyright 2011,2013 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -29,6 +29,9 @@ include_directories(
link_directories(${Boost_LIBRARY_DIRS})
+include_directories(${LOG4CPP_INCLUDE_DIRS})
+link_directories(${LOG4CPP_LIBRARY_DIRS})
+
########################################################################
# Setup library
########################################################################
@@ -38,9 +41,24 @@ list(APPEND gr_noaa_sources
noaa_hrpt_pll_cf.cc
)
+#Add Windows DLL resource file if using MSVC
+if(MSVC)
+ include(${CMAKE_SOURCE_DIR}/cmake/Modules/GrVersion.cmake)
+
+ configure_file(
+ ${CMAKE_CURRENT_SOURCE_DIR}/gnuradio-noaa.rc.in
+ ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-noaa.rc
+ @ONLY)
+
+ list(APPEND gr_noaa_sources
+ ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-noaa.rc
+ )
+endif(MSVC)
+
list(APPEND noaa_libs
gnuradio-core
${Boost_LIBRARIES}
+ ${LOG4CPP_LIBRARIES}
)
add_library(gnuradio-noaa SHARED ${gr_noaa_sources})
diff --git a/gr-noaa/lib/gnuradio-noaa.rc.in b/gr-noaa/lib/gnuradio-noaa.rc.in
new file mode 100644
index 0000000000..2f19f110b7
--- /dev/null
+++ b/gr-noaa/lib/gnuradio-noaa.rc.in
@@ -0,0 +1,55 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2013 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.
+ */
+
+#include <afxres.h>
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@
+ PRODUCTVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@
+ FILEFLAGSMASK 0x3fL
+#ifndef NDEBUG
+ FILEFLAGS 0x0L
+#else
+ FILEFLAGS 0x1L
+#endif
+ FILEOS VOS__WINDOWS32
+ FILETYPE VFT_DLL
+ FILESUBTYPE VFT2_DRV_INSTALLABLE
+ BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904b0"
+ BEGIN
+ VALUE "FileDescription", "gnuradio-noaa"
+ VALUE "FileVersion", "@VERSION@"
+ VALUE "InternalName", "gnuradio-noaa.dll"
+ VALUE "LegalCopyright", "Licensed under GPLv3 or any later version"
+ VALUE "OriginalFilename", "gnuradio-noaa.dll"
+ VALUE "ProductName", "gnuradio-noaa"
+ VALUE "ProductVersion", "@VERSION@"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+ END
diff --git a/gr-pager/lib/CMakeLists.txt b/gr-pager/lib/CMakeLists.txt
index cb62bcc752..68c60ed16d 100644
--- a/gr-pager/lib/CMakeLists.txt
+++ b/gr-pager/lib/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright 2011 Free Software Foundation, Inc.
+# Copyright 2011,2013 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -29,6 +29,9 @@ include_directories(
link_directories(${Boost_LIBRARY_DIRS})
+include_directories(${LOG4CPP_INCLUDE_DIRS})
+link_directories(${LOG4CPP_LIBRARY_DIRS})
+
########################################################################
# Setup library
########################################################################
@@ -43,9 +46,24 @@ list(APPEND gr_pager_sources
pageri_util.cc
)
+#Add Windows DLL resource file if using MSVC
+if(MSVC)
+ include(${CMAKE_SOURCE_DIR}/cmake/Modules/GrVersion.cmake)
+
+ configure_file(
+ ${CMAKE_CURRENT_SOURCE_DIR}/gnuradio-pager.rc.in
+ ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-pager.rc
+ @ONLY)
+
+ list(APPEND gr_pager_sources
+ ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-pager.rc
+ )
+endif(MSVC)
+
list(APPEND pager_libs
gnuradio-core
${Boost_LIBRARIES}
+ ${LOG4CPP_LIBRARIES}
)
add_library(gnuradio-pager SHARED ${gr_pager_sources})
diff --git a/gr-pager/lib/gnuradio-pager.rc.in b/gr-pager/lib/gnuradio-pager.rc.in
new file mode 100644
index 0000000000..cf9d85b24f
--- /dev/null
+++ b/gr-pager/lib/gnuradio-pager.rc.in
@@ -0,0 +1,55 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2013 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.
+ */
+
+#include <afxres.h>
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@
+ PRODUCTVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@
+ FILEFLAGSMASK 0x3fL
+#ifndef NDEBUG
+ FILEFLAGS 0x0L
+#else
+ FILEFLAGS 0x1L
+#endif
+ FILEOS VOS__WINDOWS32
+ FILETYPE VFT_DLL
+ FILESUBTYPE VFT2_DRV_INSTALLABLE
+ BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904b0"
+ BEGIN
+ VALUE "FileDescription", "gnuradio-pager"
+ VALUE "FileVersion", "@VERSION@"
+ VALUE "InternalName", "gnuradio-pager.dll"
+ VALUE "LegalCopyright", "Licensed under GPLv3 or any later version"
+ VALUE "OriginalFilename", "gnuradio-pager.dll"
+ VALUE "ProductName", "gnuradio-pager"
+ VALUE "ProductVersion", "@VERSION@"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+ END
diff --git a/gr-qtgui/lib/CMakeLists.txt b/gr-qtgui/lib/CMakeLists.txt
index 49fa525d7e..955db49e72 100644
--- a/gr-qtgui/lib/CMakeLists.txt
+++ b/gr-qtgui/lib/CMakeLists.txt
@@ -58,6 +58,20 @@ set(qtgui_srcs
qtgui_util.cc
)
+#Add Windows DLL resource file if using MSVC
+if(MSVC)
+ include(${CMAKE_SOURCE_DIR}/cmake/Modules/GrVersion.cmake)
+
+ configure_file(
+ ${CMAKE_CURRENT_SOURCE_DIR}/gnuradio-qtgui.rc.in
+ ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-qtgui.rc
+ @ONLY)
+
+ list(APPEND qtgui_srcs
+ ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-qtgui.rc
+ )
+endif(MSVC)
+
########################################################################
# Setup the include and linker paths
########################################################################
@@ -67,12 +81,14 @@ include_directories(
${GRUEL_INCLUDE_DIRS}
${QWT_INCLUDE_DIRS}
${QT_INCLUDE_DIRS}
+ ${LOG4CPP_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS}
${PYTHON_INCLUDE_DIRS}
)
link_directories(
${QWT_LIBRARY_DIRS}
+ ${LOG4CPP_LIBRARY_DIRS}
${Boost_LIBRARY_DIRS}
)
@@ -86,6 +102,7 @@ list(APPEND qtgui_libs
${QWT_LIBRARIES}
${QT_LIBRARIES}
${PYTHON_LIBRARIES}
+ ${LOG4CPP_LIBRARIES}
)
add_definitions(-DQWT_DLL) #setup QWT library linkage
diff --git a/gr-qtgui/lib/gnuradio-qtgui.rc.in b/gr-qtgui/lib/gnuradio-qtgui.rc.in
new file mode 100644
index 0000000000..1e1e0725e1
--- /dev/null
+++ b/gr-qtgui/lib/gnuradio-qtgui.rc.in
@@ -0,0 +1,55 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2013 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.
+ */
+
+#include <afxres.h>
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@
+ PRODUCTVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@
+ FILEFLAGSMASK 0x3fL
+#ifndef NDEBUG
+ FILEFLAGS 0x0L
+#else
+ FILEFLAGS 0x1L
+#endif
+ FILEOS VOS__WINDOWS32
+ FILETYPE VFT_DLL
+ FILESUBTYPE VFT2_DRV_INSTALLABLE
+ BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904b0"
+ BEGIN
+ VALUE "FileDescription", "gnuradio-qtgui"
+ VALUE "FileVersion", "@VERSION@"
+ VALUE "InternalName", "gnuradio-qtgui.dll"
+ VALUE "LegalCopyright", "Licensed under GPLv3 or any later version"
+ VALUE "OriginalFilename", "gnuradio-qtgui.dll"
+ VALUE "ProductName", "gnuradio-qtgui"
+ VALUE "ProductVersion", "@VERSION@"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+ END
diff --git a/gr-shd/lib/CMakeLists.txt b/gr-shd/lib/CMakeLists.txt
index 38154755c1..bb98d8ce8b 100644
--- a/gr-shd/lib/CMakeLists.txt
+++ b/gr-shd/lib/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright 2011 Free Software Foundation, Inc.
+# Copyright 2011,2013 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -31,6 +31,9 @@ include_directories(
link_directories(${SHD_LIBRARY_DIRS})
link_directories(${Boost_LIBRARY_DIRS})
+include_directories(${LOG4CPP_INCLUDE_DIRS})
+link_directories(${LOG4CPP_LIBRARY_DIRS})
+
########################################################################
# Setup library
########################################################################
@@ -39,10 +42,25 @@ list(APPEND gr_shd_sources
gr_shd_smini_sink.cc
)
+#Add Windows DLL resource file if using MSVC
+if(MSVC)
+ include(${CMAKE_SOURCE_DIR}/cmake/Modules/GrVersion.cmake)
+
+ configure_file(
+ ${CMAKE_CURRENT_SOURCE_DIR}/gnuradio-shd.rc.in
+ ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-shd.rc
+ @ONLY)
+
+ list(APPEND gr_shd_sources
+ ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-shd.rc
+ )
+endif(MSVC)
+
list(APPEND shd_libs
gnuradio-core
${Boost_LIBRARIES}
${SHD_LIBRARIES}
+ ${LOG4CPP_LIBRARIES}
)
add_library(gnuradio-shd SHARED ${gr_shd_sources})
diff --git a/gr-shd/lib/gnuradio-shd.rc.in b/gr-shd/lib/gnuradio-shd.rc.in
new file mode 100644
index 0000000000..4a3313b0ff
--- /dev/null
+++ b/gr-shd/lib/gnuradio-shd.rc.in
@@ -0,0 +1,55 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2013 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.
+ */
+
+#include <afxres.h>
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@
+ PRODUCTVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@
+ FILEFLAGSMASK 0x3fL
+#ifndef NDEBUG
+ FILEFLAGS 0x0L
+#else
+ FILEFLAGS 0x1L
+#endif
+ FILEOS VOS__WINDOWS32
+ FILETYPE VFT_DLL
+ FILESUBTYPE VFT2_DRV_INSTALLABLE
+ BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904b0"
+ BEGIN
+ VALUE "FileDescription", "gnuradio-shd"
+ VALUE "FileVersion", "@VERSION@"
+ VALUE "InternalName", "gnuradio-shd.dll"
+ VALUE "LegalCopyright", "Licensed under GPLv3 or any later version"
+ VALUE "OriginalFilename", "gnuradio-shd.dll"
+ VALUE "ProductName", "gnuradio-shd"
+ VALUE "ProductVersion", "@VERSION@"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+ END
diff --git a/gr-trellis/src/lib/CMakeLists.txt b/gr-trellis/src/lib/CMakeLists.txt
index e2abf0238f..074a9741ed 100644
--- a/gr-trellis/src/lib/CMakeLists.txt
+++ b/gr-trellis/src/lib/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright 2011 Free Software Foundation, Inc.
+# Copyright 2011,2013 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -32,6 +32,9 @@ include_directories(
link_directories(${Boost_LIBRARY_DIRS})
+include_directories(${LOG4CPP_INCLUDE_DIRS})
+link_directories(${LOG4CPP_LIBRARY_DIRS})
+
########################################################################
# generate the python helper script which calls into the build utils
########################################################################
@@ -147,9 +150,24 @@ list(APPEND gr_trellis_sources
${generated_trellis_sources}
)
+#Add Windows DLL resource file if using MSVC
+if(MSVC)
+ include(${CMAKE_SOURCE_DIR}/cmake/Modules/GrVersion.cmake)
+
+ configure_file(
+ ${CMAKE_CURRENT_SOURCE_DIR}/gnuradio-trellis.rc.in
+ ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-trellis.rc
+ @ONLY)
+
+ list(APPEND gr_trellis_sources
+ ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-trellis.rc
+ )
+endif(MSVC)
+
list(APPEND trellis_libs
gnuradio-core
${Boost_LIBRARIES}
+ ${LOG4CPP_LIBRARIES}
)
add_library(gnuradio-trellis SHARED ${gr_trellis_sources})
diff --git a/gr-trellis/src/lib/gnuradio-trellis.rc.in b/gr-trellis/src/lib/gnuradio-trellis.rc.in
new file mode 100644
index 0000000000..db9f187947
--- /dev/null
+++ b/gr-trellis/src/lib/gnuradio-trellis.rc.in
@@ -0,0 +1,55 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2013 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.
+ */
+
+#include <afxres.h>
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@
+ PRODUCTVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@
+ FILEFLAGSMASK 0x3fL
+#ifndef NDEBUG
+ FILEFLAGS 0x0L
+#else
+ FILEFLAGS 0x1L
+#endif
+ FILEOS VOS__WINDOWS32
+ FILETYPE VFT_DLL
+ FILESUBTYPE VFT2_DRV_INSTALLABLE
+ BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904b0"
+ BEGIN
+ VALUE "FileDescription", "gnuradio-trellis"
+ VALUE "FileVersion", "@VERSION@"
+ VALUE "InternalName", "gnuradio-trellis.dll"
+ VALUE "LegalCopyright", "Licensed under GPLv3 or any later version"
+ VALUE "OriginalFilename", "gnuradio-trellis.dll"
+ VALUE "ProductName", "gnuradio-trellis"
+ VALUE "ProductVersion", "@VERSION@"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+ END
diff --git a/gr-uhd/lib/CMakeLists.txt b/gr-uhd/lib/CMakeLists.txt
index c494fddad5..15ba1e7f1c 100644
--- a/gr-uhd/lib/CMakeLists.txt
+++ b/gr-uhd/lib/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright 2011-2012 Free Software Foundation, Inc.
+# Copyright 2011-2013 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -34,6 +34,9 @@ link_directories(
${Boost_LIBRARY_DIRS}
)
+include_directories(${LOG4CPP_INCLUDE_DIRS})
+link_directories(${LOG4CPP_LIBRARY_DIRS})
+
########################################################################
# Setup library
########################################################################
@@ -43,10 +46,25 @@ list(APPEND gr_uhd_sources
gr_uhd_amsg_source.cc
)
+#Add Windows DLL resource file if using MSVC
+if(MSVC)
+ include(${CMAKE_SOURCE_DIR}/cmake/Modules/GrVersion.cmake)
+
+ configure_file(
+ ${CMAKE_CURRENT_SOURCE_DIR}/gnuradio-uhd.rc.in
+ ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-uhd.rc
+ @ONLY)
+
+ list(APPEND gr_uhd_sources
+ ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-uhd.rc
+ )
+endif(MSVC)
+
list(APPEND uhd_libs
gnuradio-core
${Boost_LIBRARIES}
${UHD_LIBRARIES}
+ ${LOG4CPP_LIBRARIES}
)
add_library(gnuradio-uhd SHARED ${gr_uhd_sources})
diff --git a/gr-uhd/lib/gnuradio-uhd.rc.in b/gr-uhd/lib/gnuradio-uhd.rc.in
new file mode 100644
index 0000000000..80fb29b9fb
--- /dev/null
+++ b/gr-uhd/lib/gnuradio-uhd.rc.in
@@ -0,0 +1,55 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2013 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.
+ */
+
+#include <afxres.h>
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@
+ PRODUCTVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@
+ FILEFLAGSMASK 0x3fL
+#ifndef NDEBUG
+ FILEFLAGS 0x0L
+#else
+ FILEFLAGS 0x1L
+#endif
+ FILEOS VOS__WINDOWS32
+ FILETYPE VFT_DLL
+ FILESUBTYPE VFT2_DRV_INSTALLABLE
+ BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904b0"
+ BEGIN
+ VALUE "FileDescription", "gnuradio-uhd"
+ VALUE "FileVersion", "@VERSION@"
+ VALUE "InternalName", "gnuradio-uhd.dll"
+ VALUE "LegalCopyright", "Licensed under GPLv3 or any later version"
+ VALUE "OriginalFilename", "gnuradio-uhd.dll"
+ VALUE "ProductName", "gnuradio-uhd"
+ VALUE "ProductVersion", "@VERSION@"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+ END
diff --git a/gr-utils/src/python/modtool/code_generator.py b/gr-utils/src/python/modtool/code_generator.py
index 525b3d1e9a..fbe9aa92c2 100644
--- a/gr-utils/src/python/modtool/code_generator.py
+++ b/gr-utils/src/python/modtool/code_generator.py
@@ -37,6 +37,7 @@ class GRMTemplate(Cheetah.Template.Template):
'decimator': 'gr_sync_decimator',
'interpolator': 'gr_sync_interpolator',
'general': 'gr_block',
+ 'tagged_stream': 'gr_tagged_stream_block',
'hier': 'gr_hier_block2',
'noblock': ''}
searchList['str_to_fancyc_comment'] = str_to_fancyc_comment
diff --git a/gr-utils/src/python/modtool/modtool_add.py b/gr-utils/src/python/modtool/modtool_add.py
index e1d61cf0fb..81103e460d 100644
--- a/gr-utils/src/python/modtool/modtool_add.py
+++ b/gr-utils/src/python/modtool/modtool_add.py
@@ -37,7 +37,7 @@ class ModToolAdd(ModTool):
name = 'add'
aliases = ('insert',)
_block_types = ('sink', 'source', 'sync', 'decimator', 'interpolator',
- 'general', 'hier', 'noblock')
+ 'general', 'tagged_stream', 'hier', 'noblock')
def __init__(self):
ModTool.__init__(self)
self._add_cc_qa = False
@@ -208,7 +208,7 @@ class ModToolAdd(ModTool):
fname_h = self._info['blockname'] + '.h'
fname_cc = self._info['blockname'] + '.cc'
if self._info['blocktype'] in ('source', 'sink', 'sync', 'decimator',
- 'interpolator', 'general', 'hier'):
+ 'interpolator', 'general', 'hier', 'tagged_stream'):
fname_cc = self._info['blockname'] + '_impl.cc'
self._write_tpl('block_impl_h', 'lib', self._info['blockname'] + '_impl.h')
self._write_tpl('block_impl_cpp', 'lib', fname_cc)
diff --git a/gr-utils/src/python/modtool/templates.py b/gr-utils/src/python/modtool/templates.py
index 87eb9f470c..289903348d 100644
--- a/gr-utils/src/python/modtool/templates.py
+++ b/gr-utils/src/python/modtool/templates.py
@@ -57,25 +57,34 @@ namespace gr {
class ${blockname}_impl : public ${blockname}
{
- private:
+ private:
// Nothing to declare in this block.
- public:
+#if $blocktype == 'tagged_stream'
+ protected:
+ int calculate_output_stream_length(const gr_vector_int &ninput_items);
+
+#end if
+ public:
${blockname}_impl(${strip_default_values($arglist)});
~${blockname}_impl();
+ // Where all the action really happens
#if $blocktype == 'general'
void forecast (int noutput_items, gr_vector_int &ninput_items_required);
- // Where all the action really happens
int general_work(int noutput_items,
gr_vector_int &ninput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items);
+#else if $blocktype == 'tagged_stream'
+ int work(int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
#else if $blocktype == 'hier'
#silent pass
#else
- // Where all the action really happens
int work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items);
@@ -125,6 +134,8 @@ namespace gr {
#set $decimation = ', <+decimation+>'
#else if $blocktype == 'interpolator'
#set $decimation = ', <+interpolation+>'
+#else if $blocktype == 'tagged_stream'
+#set $decimation = ', <+len_tag_key+>'
#else
#set $decimation = ''
#end if
@@ -186,6 +197,28 @@ namespace gr {
// Tell runtime system how many output items we produced.
return noutput_items;
}
+#else if $blocktype == 'tagged_stream'
+ int
+ ${blockname}_impl::calculate_output_stream_length(const gr_vector_int &ninput_items)
+ {
+ int noutput_items = /* <+set this+> */;
+ return noutput_items ;
+ }
+
+ int
+ ${blockname}_impl::work (int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ const float *in = (const float *) input_items[0];
+ float *out = (float *) output_items[0];
+
+ // Do <+signal processing+>
+
+ // Tell runtime system how many output items we produced.
+ return noutput_items;
+ }
#else if $blocktype == 'hier'
#silent pass
#else
@@ -230,9 +263,9 @@ namespace gr {
*/
class ${modname.upper()}_API $blockname
{
- ${blockname}(${arglist});
- ~${blockname}();
- private:
+ ${blockname}(${arglist});
+ ~${blockname}();
+ private:
};
#else
/*!
@@ -242,18 +275,18 @@ namespace gr {
*/
class ${modname.upper()}_API ${blockname} : virtual public $grblocktype
{
- public:
- typedef boost::shared_ptr<${blockname}> sptr;
-
- /*!
- * \\brief Return a shared_ptr to a new instance of ${modname}::${blockname}.
- *
- * To avoid accidental use of raw pointers, ${modname}::${blockname}'s
- * constructor is in a private implementation
- * class. ${modname}::${blockname}::make is the public interface for
- * creating new instances.
- */
- static sptr make($arglist);
+ public:
+ typedef boost::shared_ptr<${blockname}> sptr;
+
+ /*!
+ * \\brief Return a shared_ptr to a new instance of ${modname}::${blockname}.
+ *
+ * To avoid accidental use of raw pointers, ${modname}::${blockname}'s
+ * constructor is in a private implementation
+ * class. ${modname}::${blockname}::make is the public interface for
+ * creating new instances.
+ */
+ static sptr make($arglist);
};
#end if
diff --git a/gr-video-sdl/src/CMakeLists.txt b/gr-video-sdl/src/CMakeLists.txt
index 3050926bd7..8053182239 100644
--- a/gr-video-sdl/src/CMakeLists.txt
+++ b/gr-video-sdl/src/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright 2011-2012 Free Software Foundation, Inc.
+# Copyright 2011-2013 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -25,6 +25,7 @@ include_directories(
${GNURADIO_CORE_INCLUDE_DIRS}
${GRUEL_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS}
+ ${LOG4CPP_INCLUDE_DIRS}
${SDL_INCLUDE_DIR}
)
@@ -38,10 +39,25 @@ list(APPEND gr_video_sdl_sources
video_sdl_sink_s.cc
)
+#Add Windows DLL resource file if using MSVC
+if(MSVC)
+ include(${CMAKE_SOURCE_DIR}/cmake/Modules/GrVersion.cmake)
+
+ configure_file(
+ ${CMAKE_CURRENT_SOURCE_DIR}/gnuradio-video-sdl.rc.in
+ ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-video-sdl.rc
+ @ONLY)
+
+ list(APPEND gr_uhd_sources
+ ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-video-sdl.rc
+ )
+endif(MSVC)
+
list(APPEND video_sdl_libs
gnuradio-core
${Boost_LIBRARIES}
${SDL_LIBRARY}
+ ${LOG4CPP_LIBRARIES}
)
add_library(gnuradio-video-sdl SHARED ${gr_video_sdl_sources})
diff --git a/gr-video-sdl/src/gnuradio-video-sdl.rc.in b/gr-video-sdl/src/gnuradio-video-sdl.rc.in
new file mode 100644
index 0000000000..c876b0f08a
--- /dev/null
+++ b/gr-video-sdl/src/gnuradio-video-sdl.rc.in
@@ -0,0 +1,55 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2013 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.
+ */
+
+#include <afxres.h>
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@
+ PRODUCTVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@
+ FILEFLAGSMASK 0x3fL
+#ifndef NDEBUG
+ FILEFLAGS 0x0L
+#else
+ FILEFLAGS 0x1L
+#endif
+ FILEOS VOS__WINDOWS32
+ FILETYPE VFT_DLL
+ FILESUBTYPE VFT2_DRV_INSTALLABLE
+ BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904b0"
+ BEGIN
+ VALUE "FileDescription", "gnuradio-video-sdl"
+ VALUE "FileVersion", "@VERSION@"
+ VALUE "InternalName", "gnuradio-video-sdl.dll"
+ VALUE "LegalCopyright", "Licensed under GPLv3 or any later version"
+ VALUE "OriginalFilename", "gnuradio-video-sdl.dll"
+ VALUE "ProductName", "gnuradio-video-sdl"
+ VALUE "ProductVersion", "@VERSION@"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+ END
diff --git a/gr-vocoder/lib/CMakeLists.txt b/gr-vocoder/lib/CMakeLists.txt
index 43a4156d06..e00fd09b8b 100644
--- a/gr-vocoder/lib/CMakeLists.txt
+++ b/gr-vocoder/lib/CMakeLists.txt
@@ -29,6 +29,9 @@ include_directories(
link_directories(${Boost_LIBRARY_DIRS})
+include_directories(${LOG4CPP_INCLUDE_DIRS})
+link_directories(${LOG4CPP_LIBRARY_DIRS})
+
########################################################################
# Setup library
########################################################################
@@ -51,6 +54,20 @@ list(APPEND gr_vocoder_sources
vocoder_ulaw_encode_sb.cc
)
+#Add Windows DLL resource file if using MSVC
+if(MSVC)
+ include(${CMAKE_SOURCE_DIR}/cmake/Modules/GrVersion.cmake)
+
+ configure_file(
+ ${CMAKE_CURRENT_SOURCE_DIR}/gnuradio-vocoder.rc.in
+ ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-vocoder.rc
+ @ONLY)
+
+ list(APPEND gr_uhd_sources
+ ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-vocoder.rc
+ )
+endif(MSVC)
+
########################################################################
# Include subdirs rather to populate to the sources lists.
########################################################################
@@ -61,6 +78,7 @@ GR_INCLUDE_SUBDIRECTORY(gsm)
list(APPEND vocoder_libs
gnuradio-core
${Boost_LIBRARIES}
+ ${LOG4CPP_LIBRARIES}
)
add_library(gnuradio-vocoder SHARED ${gr_vocoder_sources})
diff --git a/gr-vocoder/lib/gnuradio-vocoder.rc.in b/gr-vocoder/lib/gnuradio-vocoder.rc.in
new file mode 100644
index 0000000000..c80be446e3
--- /dev/null
+++ b/gr-vocoder/lib/gnuradio-vocoder.rc.in
@@ -0,0 +1,33 @@
+#include <afxres.h>
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@
+ PRODUCTVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@
+ FILEFLAGSMASK 0x3fL
+#ifndef NDEBUG
+ FILEFLAGS 0x0L
+#else
+ FILEFLAGS 0x1L
+#endif
+ FILEOS VOS__WINDOWS32
+ FILETYPE VFT_DLL
+ FILESUBTYPE VFT2_DRV_INSTALLABLE
+ BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904b0"
+ BEGIN
+ VALUE "FileDescription", "gnuradio-vocoder"
+ VALUE "FileVersion", "@VERSION@"
+ VALUE "InternalName", "gnuradio-vocoder.dll"
+ VALUE "LegalCopyright", "Licensed under GPLv3 or any later version"
+ VALUE "OriginalFilename", "gnuradio-vocoder.dll"
+ VALUE "ProductName", "gnuradio-vocoder"
+ VALUE "ProductVersion", "@VERSION@"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+ END
diff --git a/gr-wavelet/lib/CMakeLists.txt b/gr-wavelet/lib/CMakeLists.txt
index f446adb9c2..2b5ce093d4 100644
--- a/gr-wavelet/lib/CMakeLists.txt
+++ b/gr-wavelet/lib/CMakeLists.txt
@@ -35,6 +35,9 @@ link_directories(${Boost_LIBRARY_DIRS})
link_directories(${GSL_LIBRARY_DIRS})
add_definitions(${GSL_DEFINITIONS})
+include_directories(${LOG4CPP_INCLUDE_DIRS})
+link_directories(${LOG4CPP_LIBRARY_DIRS})
+
########################################################################
# Setup library
########################################################################
@@ -44,11 +47,26 @@ list(APPEND gr_wavelet_sources
wavelet_wvps_ff_impl.cc
)
+#Add Windows DLL resource file if using MSVC
+if(MSVC)
+ include(${CMAKE_SOURCE_DIR}/cmake/Modules/GrVersion.cmake)
+
+ configure_file(
+ ${CMAKE_CURRENT_SOURCE_DIR}/gnuradio-wavelet.rc.in
+ ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-wavelet.rc
+ @ONLY)
+
+ list(APPEND gr_wavelet_sources
+ ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-wavelet.rc
+ )
+endif(MSVC)
+
list(APPEND wavelet_libs
gnuradio-core
${Boost_LIBRARIES}
${WAVELET_LIBRARIES}
${GSL_LIBRARIES}
+ ${LOG4CPP_LIBRARIES}
)
add_library(gnuradio-wavelet SHARED ${gr_wavelet_sources})
diff --git a/gr-wavelet/lib/gnuradio-wavelet.rc.in b/gr-wavelet/lib/gnuradio-wavelet.rc.in
new file mode 100644
index 0000000000..7c3c0674f9
--- /dev/null
+++ b/gr-wavelet/lib/gnuradio-wavelet.rc.in
@@ -0,0 +1,33 @@
+#include <afxres.h>
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@
+ PRODUCTVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@
+ FILEFLAGSMASK 0x3fL
+#ifndef NDEBUG
+ FILEFLAGS 0x0L
+#else
+ FILEFLAGS 0x1L
+#endif
+ FILEOS VOS__WINDOWS32
+ FILETYPE VFT_DLL
+ FILESUBTYPE VFT2_DRV_INSTALLABLE
+ BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904b0"
+ BEGIN
+ VALUE "FileDescription", "gnuradio-wavelet"
+ VALUE "FileVersion", "@VERSION@"
+ VALUE "InternalName", "gnuradio-wavelet.dll"
+ VALUE "LegalCopyright", "Licensed under GPLv3 or any later version"
+ VALUE "OriginalFilename", "gnuradio-wavelet.dll"
+ VALUE "ProductName", "gnuradio-wavelet"
+ VALUE "ProductVersion", "@VERSION@"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+ END
diff --git a/gr-wxgui/src/python/fftsink_nongl.py b/gr-wxgui/src/python/fftsink_nongl.py
index c38abbb22e..473cc424c4 100644
--- a/gr-wxgui/src/python/fftsink_nongl.py
+++ b/gr-wxgui/src/python/fftsink_nongl.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
-# Copyright 2003,2004,2005,2006,2007,2009,2010 Free Software Foundation, Inc.
+# Copyright 2003-2007,2009,2010 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -99,6 +99,8 @@ class fft_sink_base(object):
def _set_n(self):
self.one_in_n.set_n(max(1, int(self.sample_rate/self.fft_size/self.fft_rate)))
+ def set_callback(self, callb):
+ return
class fft_sink_f(gr.hier_block2, fft_sink_base):
def __init__(self, parent, baseband_freq=0, ref_scale=2.0,
diff --git a/gr-wxgui/src/python/waterfallsink_nongl.py b/gr-wxgui/src/python/waterfallsink_nongl.py
index 213415c82c..bf77b4b131 100644
--- a/gr-wxgui/src/python/waterfallsink_nongl.py
+++ b/gr-wxgui/src/python/waterfallsink_nongl.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
-# Copyright 2003,2004,2005,2007,2008 Free Software Foundation, Inc.
+# Copyright 2003-2005,2007,2008 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -71,6 +71,9 @@ class waterfall_sink_base(object):
def _set_n(self):
self.one_in_n.set_n(max(1, int(self.sample_rate/self.fft_size/self.fft_rate)))
+ def set_callback(self, callb):
+ return
+
class waterfall_sink_f(gr.hier_block2, waterfall_sink_base):
def __init__(self, parent, baseband_freq=0,
y_per_div=10, ref_level=50, sample_rate=1, fft_size=512,
diff --git a/grc/blocks/gr_vector_source_x.xml b/grc/blocks/gr_vector_source_x.xml
index 7a6a3aeff8..b3e595a453 100644
--- a/grc/blocks/gr_vector_source_x.xml
+++ b/grc/blocks/gr_vector_source_x.xml
@@ -8,7 +8,8 @@
<name>Vector Source</name>
<key>gr_vector_source_x</key>
<import>from gnuradio import gr</import>
- <make>gr.vector_source_$(type.fcn)($vector, $repeat, $vlen)</make>
+ <make>gr.vector_source_$(type.fcn)($vector, $repeat, $vlen, $tags)
+ </make>
<param>
<name>Output Type</name>
<key>type</key>
@@ -47,8 +48,14 @@
<param>
<name>Vector</name>
<key>vector</key>
- <value>0, 0, 0</value>
- <type>$type.vec_type</type>
+ <value>[0, 0, 0]</value>
+ <type>raw</type>
+ </param>
+ <param>
+ <name>Tags</name>
+ <key>tags</key>
+ <value>[]</value>
+ <type>raw</type>
</param>
<param>
<name>Repeat</name>
diff --git a/gruel/src/lib/CMakeLists.txt b/gruel/src/lib/CMakeLists.txt
index 717d566601..a08e67d99a 100644
--- a/gruel/src/lib/CMakeLists.txt
+++ b/gruel/src/lib/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright 2010-2011 Free Software Foundation, Inc.
+# Copyright 2010-2011,2013 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -81,6 +81,20 @@ list(APPEND gruel_sources
thread_group.cc
)
+#Add Windows DLL resource file if using MSVC
+if(MSVC)
+ include(${CMAKE_SOURCE_DIR}/cmake/Modules/GrVersion.cmake)
+
+ configure_file(
+ ${CMAKE_CURRENT_SOURCE_DIR}/gruel.rc.in
+ ${CMAKE_CURRENT_BINARY_DIR}/gruel.rc
+ @ONLY)
+
+ list(APPEND gruel_sources
+ ${CMAKE_CURRENT_BINARY_DIR}/gruel.rc
+ )
+endif(MSVC)
+
list(APPEND gruel_libs ${Boost_LIBRARIES})
if(HAVE_PTHREAD_SETSCHEDPARAM)
diff --git a/gruel/src/lib/gruel.rc.in b/gruel/src/lib/gruel.rc.in
new file mode 100644
index 0000000000..906b7d61c2
--- /dev/null
+++ b/gruel/src/lib/gruel.rc.in
@@ -0,0 +1,55 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2013 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.
+ */
+
+#include <afxres.h>
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@
+ PRODUCTVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@
+ FILEFLAGSMASK 0x3fL
+#ifndef NDEBUG
+ FILEFLAGS 0x0L
+#else
+ FILEFLAGS 0x1L
+#endif
+ FILEOS VOS__WINDOWS32
+ FILETYPE VFT_DLL
+ FILESUBTYPE VFT2_DRV_INSTALLABLE
+ BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904b0"
+ BEGIN
+ VALUE "FileDescription", "gruel"
+ VALUE "FileVersion", "@VERSION@"
+ VALUE "InternalName", "gruel.dll"
+ VALUE "LegalCopyright", "Licensed under GPLv3 or any later version"
+ VALUE "OriginalFilename", "gruel.dll"
+ VALUE "ProductName", "gruel"
+ VALUE "ProductVersion", "@VERSION@"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+ END