summaryrefslogtreecommitdiff
path: root/gr-blocks
diff options
context:
space:
mode:
Diffstat (limited to 'gr-blocks')
-rw-r--r--gr-blocks/include/gnuradio/blocks/abs_blk.h41
-rw-r--r--gr-blocks/include/gnuradio/blocks/add_blk.h45
-rw-r--r--gr-blocks/include/gnuradio/blocks/add_const_bb.h57
-rw-r--r--gr-blocks/include/gnuradio/blocks/add_const_cc.h57
-rw-r--r--gr-blocks/include/gnuradio/blocks/add_const_ff.h57
-rw-r--r--gr-blocks/include/gnuradio/blocks/add_const_ii.h57
-rw-r--r--gr-blocks/include/gnuradio/blocks/add_const_ss.h57
-rw-r--r--gr-blocks/include/gnuradio/blocks/add_const_v.h61
-rw-r--r--gr-blocks/include/gnuradio/blocks/and_blk.h39
-rw-r--r--gr-blocks/include/gnuradio/blocks/and_const.h59
-rw-r--r--gr-blocks/include/gnuradio/blocks/annotator_1to1.h64
-rw-r--r--gr-blocks/include/gnuradio/blocks/annotator_alltoall.h64
-rw-r--r--gr-blocks/include/gnuradio/blocks/annotator_raw.h54
-rw-r--r--gr-blocks/include/gnuradio/blocks/api.h4
-rw-r--r--gr-blocks/include/gnuradio/blocks/argmax.h58
-rw-r--r--gr-blocks/include/gnuradio/blocks/bin_statistics_f.h72
-rw-r--r--gr-blocks/include/gnuradio/blocks/burst_tagger.h74
-rw-r--r--gr-blocks/include/gnuradio/blocks/char_to_float.h63
-rw-r--r--gr-blocks/include/gnuradio/blocks/char_to_short.h39
-rw-r--r--gr-blocks/include/gnuradio/blocks/check_lfsr_32k_s.h50
-rw-r--r--gr-blocks/include/gnuradio/blocks/complex_to_arg.h34
-rw-r--r--gr-blocks/include/gnuradio/blocks/complex_to_float.h44
-rw-r--r--gr-blocks/include/gnuradio/blocks/complex_to_imag.h34
-rw-r--r--gr-blocks/include/gnuradio/blocks/complex_to_interleaved_char.h48
-rw-r--r--gr-blocks/include/gnuradio/blocks/complex_to_interleaved_short.h48
-rw-r--r--gr-blocks/include/gnuradio/blocks/complex_to_mag.h58
-rw-r--r--gr-blocks/include/gnuradio/blocks/complex_to_mag_squared.h58
-rw-r--r--gr-blocks/include/gnuradio/blocks/complex_to_magphase.h40
-rw-r--r--gr-blocks/include/gnuradio/blocks/complex_to_real.h34
-rw-r--r--gr-blocks/include/gnuradio/blocks/conjugate_cc.h27
-rw-r--r--gr-blocks/include/gnuradio/blocks/control_loop.h575
-rw-r--r--gr-blocks/include/gnuradio/blocks/copy.h58
-rw-r--r--gr-blocks/include/gnuradio/blocks/count_bits.h20
-rw-r--r--gr-blocks/include/gnuradio/blocks/ctrlport_probe2_b.h61
-rw-r--r--gr-blocks/include/gnuradio/blocks/ctrlport_probe2_c.h61
-rw-r--r--gr-blocks/include/gnuradio/blocks/ctrlport_probe2_f.h61
-rw-r--r--gr-blocks/include/gnuradio/blocks/ctrlport_probe2_i.h61
-rw-r--r--gr-blocks/include/gnuradio/blocks/ctrlport_probe2_s.h61
-rw-r--r--gr-blocks/include/gnuradio/blocks/ctrlport_probe_c.h51
-rw-r--r--gr-blocks/include/gnuradio/blocks/deinterleave.h80
-rw-r--r--gr-blocks/include/gnuradio/blocks/delay.h64
-rw-r--r--gr-blocks/include/gnuradio/blocks/divide.h39
-rw-r--r--gr-blocks/include/gnuradio/blocks/endian_swap.h36
-rw-r--r--gr-blocks/include/gnuradio/blocks/exponentiate_const_cci.h57
-rw-r--r--gr-blocks/include/gnuradio/blocks/file_descriptor_sink.h38
-rw-r--r--gr-blocks/include/gnuradio/blocks/file_descriptor_source.h52
-rw-r--r--gr-blocks/include/gnuradio/blocks/file_meta_sink.h148
-rw-r--r--gr-blocks/include/gnuradio/blocks/file_meta_source.h88
-rw-r--r--gr-blocks/include/gnuradio/blocks/file_sink.h39
-rw-r--r--gr-blocks/include/gnuradio/blocks/file_sink_base.h80
-rw-r--r--gr-blocks/include/gnuradio/blocks/file_source.h121
-rw-r--r--gr-blocks/include/gnuradio/blocks/float_to_char.h52
-rw-r--r--gr-blocks/include/gnuradio/blocks/float_to_complex.h34
-rw-r--r--gr-blocks/include/gnuradio/blocks/float_to_int.h52
-rw-r--r--gr-blocks/include/gnuradio/blocks/float_to_short.h52
-rw-r--r--gr-blocks/include/gnuradio/blocks/float_to_uchar.h31
-rw-r--r--gr-blocks/include/gnuradio/blocks/head.h47
-rw-r--r--gr-blocks/include/gnuradio/blocks/int_to_float.h52
-rw-r--r--gr-blocks/include/gnuradio/blocks/integrate.h29
-rw-r--r--gr-blocks/include/gnuradio/blocks/interleave.h82
-rw-r--r--gr-blocks/include/gnuradio/blocks/interleaved_char_to_complex.h30
-rw-r--r--gr-blocks/include/gnuradio/blocks/interleaved_short_to_complex.h32
-rw-r--r--gr-blocks/include/gnuradio/blocks/keep_m_in_n.h51
-rw-r--r--gr-blocks/include/gnuradio/blocks/keep_one_in_n.h39
-rw-r--r--gr-blocks/include/gnuradio/blocks/lfsr_15_1_0.h58
-rw-r--r--gr-blocks/include/gnuradio/blocks/lfsr_32k.h84
-rw-r--r--gr-blocks/include/gnuradio/blocks/lfsr_32k_source_s.h38
-rw-r--r--gr-blocks/include/gnuradio/blocks/log2_const.h83
-rw-r--r--gr-blocks/include/gnuradio/blocks/magphase_to_complex.h34
-rw-r--r--gr-blocks/include/gnuradio/blocks/max_blk.h50
-rw-r--r--gr-blocks/include/gnuradio/blocks/message_debug.h100
-rw-r--r--gr-blocks/include/gnuradio/blocks/message_strobe.h82
-rw-r--r--gr-blocks/include/gnuradio/blocks/message_strobe_random.h162
-rw-r--r--gr-blocks/include/gnuradio/blocks/min_blk.h48
-rw-r--r--gr-blocks/include/gnuradio/blocks/moving_average.h86
-rw-r--r--gr-blocks/include/gnuradio/blocks/multiply.h39
-rw-r--r--gr-blocks/include/gnuradio/blocks/multiply_by_tag_value_cc.h63
-rw-r--r--gr-blocks/include/gnuradio/blocks/multiply_conjugate_cc.h35
-rw-r--r--gr-blocks/include/gnuradio/blocks/multiply_const.h55
-rw-r--r--gr-blocks/include/gnuradio/blocks/multiply_const_v.h61
-rw-r--r--gr-blocks/include/gnuradio/blocks/multiply_matrix.h122
-rw-r--r--gr-blocks/include/gnuradio/blocks/mute.h31
-rw-r--r--gr-blocks/include/gnuradio/blocks/nlog10_ff.h37
-rw-r--r--gr-blocks/include/gnuradio/blocks/nop.h48
-rw-r--r--gr-blocks/include/gnuradio/blocks/not_blk.h31
-rw-r--r--gr-blocks/include/gnuradio/blocks/null_sink.h38
-rw-r--r--gr-blocks/include/gnuradio/blocks/null_source.h34
-rw-r--r--gr-blocks/include/gnuradio/blocks/or_blk.h43
-rw-r--r--gr-blocks/include/gnuradio/blocks/pack_k_bits.h96
-rw-r--r--gr-blocks/include/gnuradio/blocks/pack_k_bits_bb.h54
-rw-r--r--gr-blocks/include/gnuradio/blocks/packed_to_unpacked.h73
-rw-r--r--gr-blocks/include/gnuradio/blocks/patterned_interleaver.h37
-rw-r--r--gr-blocks/include/gnuradio/blocks/pdu.h20
-rw-r--r--gr-blocks/include/gnuradio/blocks/pdu_filter.h38
-rw-r--r--gr-blocks/include/gnuradio/blocks/pdu_remove.h34
-rw-r--r--gr-blocks/include/gnuradio/blocks/pdu_set.h36
-rw-r--r--gr-blocks/include/gnuradio/blocks/pdu_to_tagged_stream.h38
-rw-r--r--gr-blocks/include/gnuradio/blocks/peak_detector.h168
-rw-r--r--gr-blocks/include/gnuradio/blocks/peak_detector2_fb.h120
-rw-r--r--gr-blocks/include/gnuradio/blocks/plateau_detector_fb.h69
-rw-r--r--gr-blocks/include/gnuradio/blocks/probe_rate.h45
-rw-r--r--gr-blocks/include/gnuradio/blocks/probe_signal.h30
-rw-r--r--gr-blocks/include/gnuradio/blocks/probe_signal_v.h50
-rw-r--r--gr-blocks/include/gnuradio/blocks/random_pdu.h33
-rw-r--r--gr-blocks/include/gnuradio/blocks/regenerate_bb.h82
-rw-r--r--gr-blocks/include/gnuradio/blocks/repack_bits_bb.h108
-rw-r--r--gr-blocks/include/gnuradio/blocks/repeat.h67
-rw-r--r--gr-blocks/include/gnuradio/blocks/rms_cf.h38
-rw-r--r--gr-blocks/include/gnuradio/blocks/rms_ff.h38
-rw-r--r--gr-blocks/include/gnuradio/blocks/rotator.h48
-rw-r--r--gr-blocks/include/gnuradio/blocks/rotator_cc.h38
-rw-r--r--gr-blocks/include/gnuradio/blocks/sample_and_hold.h40
-rw-r--r--gr-blocks/include/gnuradio/blocks/short_to_char.h52
-rw-r--r--gr-blocks/include/gnuradio/blocks/short_to_float.h52
-rw-r--r--gr-blocks/include/gnuradio/blocks/skiphead.h37
-rw-r--r--gr-blocks/include/gnuradio/blocks/socket_pdu.h44
-rw-r--r--gr-blocks/include/gnuradio/blocks/stream_mux.h59
-rw-r--r--gr-blocks/include/gnuradio/blocks/stream_to_streams.h42
-rw-r--r--gr-blocks/include/gnuradio/blocks/stream_to_tagged_stream.h65
-rw-r--r--gr-blocks/include/gnuradio/blocks/stream_to_vector.h36
-rw-r--r--gr-blocks/include/gnuradio/blocks/streams_to_stream.h42
-rw-r--r--gr-blocks/include/gnuradio/blocks/streams_to_vector.h36
-rw-r--r--gr-blocks/include/gnuradio/blocks/stretch_ff.h50
-rw-r--r--gr-blocks/include/gnuradio/blocks/sub.h39
-rw-r--r--gr-blocks/include/gnuradio/blocks/tag_debug.h126
-rw-r--r--gr-blocks/include/gnuradio/blocks/tag_gate.h65
-rw-r--r--gr-blocks/include/gnuradio/blocks/tag_share.h62
-rw-r--r--gr-blocks/include/gnuradio/blocks/tagged_file_sink.h60
-rw-r--r--gr-blocks/include/gnuradio/blocks/tagged_stream_align.h38
-rw-r--r--gr-blocks/include/gnuradio/blocks/tagged_stream_multiply_length.h47
-rw-r--r--gr-blocks/include/gnuradio/blocks/tagged_stream_mux.h67
-rw-r--r--gr-blocks/include/gnuradio/blocks/tagged_stream_to_pdu.h48
-rw-r--r--gr-blocks/include/gnuradio/blocks/tags_strobe.h113
-rw-r--r--gr-blocks/include/gnuradio/blocks/tcp_server_sink.h57
-rw-r--r--gr-blocks/include/gnuradio/blocks/test_tag_variable_rate_ff.h83
-rw-r--r--gr-blocks/include/gnuradio/blocks/threshold_ff.h62
-rw-r--r--gr-blocks/include/gnuradio/blocks/throttle.h62
-rw-r--r--gr-blocks/include/gnuradio/blocks/transcendental.h43
-rw-r--r--gr-blocks/include/gnuradio/blocks/tsb_vector_sink.h62
-rw-r--r--gr-blocks/include/gnuradio/blocks/tuntap_pdu.h36
-rw-r--r--gr-blocks/include/gnuradio/blocks/uchar_to_float.h30
-rw-r--r--gr-blocks/include/gnuradio/blocks/udp_sink.h86
-rw-r--r--gr-blocks/include/gnuradio/blocks/udp_source.h89
-rw-r--r--gr-blocks/include/gnuradio/blocks/unpack_k_bits.h98
-rw-r--r--gr-blocks/include/gnuradio/blocks/unpack_k_bits_bb.h50
-rw-r--r--gr-blocks/include/gnuradio/blocks/unpacked_to_packed.h71
-rw-r--r--gr-blocks/include/gnuradio/blocks/vco_c.h42
-rw-r--r--gr-blocks/include/gnuradio/blocks/vco_f.h42
-rw-r--r--gr-blocks/include/gnuradio/blocks/vector_insert.h45
-rw-r--r--gr-blocks/include/gnuradio/blocks/vector_map.h67
-rw-r--r--gr-blocks/include/gnuradio/blocks/vector_sink.h52
-rw-r--r--gr-blocks/include/gnuradio/blocks/vector_source.h97
-rw-r--r--gr-blocks/include/gnuradio/blocks/vector_to_stream.h36
-rw-r--r--gr-blocks/include/gnuradio/blocks/vector_to_streams.h38
-rw-r--r--gr-blocks/include/gnuradio/blocks/wavfile.h121
-rw-r--r--gr-blocks/include/gnuradio/blocks/wavfile_sink.h96
-rw-r--r--gr-blocks/include/gnuradio/blocks/wavfile_source.h64
-rw-r--r--gr-blocks/include/gnuradio/blocks/xor_blk.h33
-rw-r--r--gr-blocks/lib/abs_blk_impl.cc53
-rw-r--r--gr-blocks/lib/abs_blk_impl.h26
-rw-r--r--gr-blocks/lib/add_blk_impl.cc108
-rw-r--r--gr-blocks/lib/add_blk_impl.h26
-rw-r--r--gr-blocks/lib/add_const_bb_impl.cc125
-rw-r--r--gr-blocks/lib/add_const_bb_impl.h32
-rw-r--r--gr-blocks/lib/add_const_cc_impl.cc121
-rw-r--r--gr-blocks/lib/add_const_cc_impl.h30
-rw-r--r--gr-blocks/lib/add_const_ff_impl.cc121
-rw-r--r--gr-blocks/lib/add_const_ff_impl.h30
-rw-r--r--gr-blocks/lib/add_const_ii_impl.cc121
-rw-r--r--gr-blocks/lib/add_const_ii_impl.h30
-rw-r--r--gr-blocks/lib/add_const_ss_impl.cc125
-rw-r--r--gr-blocks/lib/add_const_ss_impl.h32
-rw-r--r--gr-blocks/lib/add_const_v_impl.cc65
-rw-r--r--gr-blocks/lib/add_const_v_impl.h28
-rw-r--r--gr-blocks/lib/and_blk_impl.cc59
-rw-r--r--gr-blocks/lib/and_blk_impl.h24
-rw-r--r--gr-blocks/lib/and_const_impl.cc75
-rw-r--r--gr-blocks/lib/and_const_impl.h28
-rw-r--r--gr-blocks/lib/annotator_1to1_impl.cc121
-rw-r--r--gr-blocks/lib/annotator_1to1_impl.h47
-rw-r--r--gr-blocks/lib/annotator_alltoall_impl.cc137
-rw-r--r--gr-blocks/lib/annotator_alltoall_impl.h47
-rw-r--r--gr-blocks/lib/annotator_raw_impl.cc137
-rw-r--r--gr-blocks/lib/annotator_raw_impl.h36
-rw-r--r--gr-blocks/lib/argmax_impl.cc81
-rw-r--r--gr-blocks/lib/argmax_impl.h28
-rw-r--r--gr-blocks/lib/bin_statistics_f_impl.cc224
-rw-r--r--gr-blocks/lib/bin_statistics_f_impl.h75
-rw-r--r--gr-blocks/lib/burst_tagger_impl.cc119
-rw-r--r--gr-blocks/lib/burst_tagger_impl.h42
-rw-r--r--gr-blocks/lib/char_to_float_impl.cc55
-rw-r--r--gr-blocks/lib/char_to_float_impl.h28
-rw-r--r--gr-blocks/lib/char_to_short_impl.cc64
-rw-r--r--gr-blocks/lib/char_to_short_impl.h22
-rw-r--r--gr-blocks/lib/check_lfsr_32k_s_impl.cc220
-rw-r--r--gr-blocks/lib/check_lfsr_32k_s_impl.h82
-rw-r--r--gr-blocks/lib/complex_to_arg_impl.cc62
-rw-r--r--gr-blocks/lib/complex_to_arg_impl.h22
-rw-r--r--gr-blocks/lib/complex_to_float_impl.cc73
-rw-r--r--gr-blocks/lib/complex_to_float_impl.h22
-rw-r--r--gr-blocks/lib/complex_to_imag_impl.cc66
-rw-r--r--gr-blocks/lib/complex_to_imag_impl.h22
-rw-r--r--gr-blocks/lib/complex_to_interleaved_char_impl.cc60
-rw-r--r--gr-blocks/lib/complex_to_interleaved_char_impl.h25
-rw-r--r--gr-blocks/lib/complex_to_interleaved_short_impl.cc58
-rw-r--r--gr-blocks/lib/complex_to_interleaved_short_impl.h25
-rw-r--r--gr-blocks/lib/complex_to_mag_impl.cc56
-rw-r--r--gr-blocks/lib/complex_to_mag_impl.h22
-rw-r--r--gr-blocks/lib/complex_to_mag_squared_impl.cc66
-rw-r--r--gr-blocks/lib/complex_to_mag_squared_impl.h22
-rw-r--r--gr-blocks/lib/complex_to_magphase_impl.cc66
-rw-r--r--gr-blocks/lib/complex_to_magphase_impl.h22
-rw-r--r--gr-blocks/lib/complex_to_real_impl.cc66
-rw-r--r--gr-blocks/lib/complex_to_real_impl.h22
-rw-r--r--gr-blocks/lib/conjugate_cc_impl.cc62
-rw-r--r--gr-blocks/lib/conjugate_cc_impl.h20
-rw-r--r--gr-blocks/lib/control_loop.cc243
-rw-r--r--gr-blocks/lib/copy_impl.cc112
-rw-r--r--gr-blocks/lib/copy_impl.h42
-rw-r--r--gr-blocks/lib/count_bits.cc67
-rw-r--r--gr-blocks/lib/ctrlport_probe2_b_impl.cc194
-rw-r--r--gr-blocks/lib/ctrlport_probe2_b_impl.h52
-rw-r--r--gr-blocks/lib/ctrlport_probe2_c_impl.cc201
-rw-r--r--gr-blocks/lib/ctrlport_probe2_c_impl.h52
-rw-r--r--gr-blocks/lib/ctrlport_probe2_f_impl.cc199
-rw-r--r--gr-blocks/lib/ctrlport_probe2_f_impl.h52
-rw-r--r--gr-blocks/lib/ctrlport_probe2_i_impl.cc200
-rw-r--r--gr-blocks/lib/ctrlport_probe2_i_impl.h52
-rw-r--r--gr-blocks/lib/ctrlport_probe2_s_impl.cc197
-rw-r--r--gr-blocks/lib/ctrlport_probe2_s_impl.h52
-rw-r--r--gr-blocks/lib/ctrlport_probe_c_impl.cc105
-rw-r--r--gr-blocks/lib/ctrlport_probe_c_impl.h39
-rw-r--r--gr-blocks/lib/deinterleave_impl.cc91
-rw-r--r--gr-blocks/lib/deinterleave_impl.h37
-rw-r--r--gr-blocks/lib/delay_impl.cc146
-rw-r--r--gr-blocks/lib/delay_impl.h39
-rw-r--r--gr-blocks/lib/divide_impl.cc161
-rw-r--r--gr-blocks/lib/divide_impl.h24
-rw-r--r--gr-blocks/lib/endian_swap_impl.cc81
-rw-r--r--gr-blocks/lib/endian_swap_impl.h25
-rw-r--r--gr-blocks/lib/exponentiate_const_cci_impl.cc112
-rw-r--r--gr-blocks/lib/exponentiate_const_cci_impl.h43
-rw-r--r--gr-blocks/lib/file_descriptor_sink_impl.cc76
-rw-r--r--gr-blocks/lib/file_descriptor_sink_impl.h28
-rw-r--r--gr-blocks/lib/file_descriptor_source_impl.cc175
-rw-r--r--gr-blocks/lib/file_descriptor_source_impl.h42
-rw-r--r--gr-blocks/lib/file_meta_sink_impl.cc747
-rw-r--r--gr-blocks/lib/file_meta_sink_impl.h99
-rw-r--r--gr-blocks/lib/file_meta_source_impl.cc702
-rw-r--r--gr-blocks/lib/file_meta_source_impl.h94
-rw-r--r--gr-blocks/lib/file_sink_base.cc125
-rw-r--r--gr-blocks/lib/file_sink_impl.cc81
-rw-r--r--gr-blocks/lib/file_sink_impl.h26
-rw-r--r--gr-blocks/lib/file_source_impl.cc322
-rw-r--r--gr-blocks/lib/file_source_impl.h67
-rw-r--r--gr-blocks/lib/float_array_to_int.cc23
-rw-r--r--gr-blocks/lib/float_array_to_int.h2
-rw-r--r--gr-blocks/lib/float_array_to_uchar.cc21
-rw-r--r--gr-blocks/lib/float_array_to_uchar.h2
-rw-r--r--gr-blocks/lib/float_to_char_impl.cc65
-rw-r--r--gr-blocks/lib/float_to_char_impl.h28
-rw-r--r--gr-blocks/lib/float_to_complex_impl.cc83
-rw-r--r--gr-blocks/lib/float_to_complex_impl.h22
-rw-r--r--gr-blocks/lib/float_to_int_impl.cc63
-rw-r--r--gr-blocks/lib/float_to_int_impl.h28
-rw-r--r--gr-blocks/lib/float_to_short_impl.cc65
-rw-r--r--gr-blocks/lib/float_to_short_impl.h28
-rw-r--r--gr-blocks/lib/float_to_uchar_impl.cc57
-rw-r--r--gr-blocks/lib/float_to_uchar_impl.h20
-rw-r--r--gr-blocks/lib/head_impl.cc60
-rw-r--r--gr-blocks/lib/head_impl.h32
-rw-r--r--gr-blocks/lib/int_to_float_impl.cc63
-rw-r--r--gr-blocks/lib/int_to_float_impl.h28
-rw-r--r--gr-blocks/lib/integrate_impl.cc61
-rw-r--r--gr-blocks/lib/integrate_impl.h26
-rw-r--r--gr-blocks/lib/interleave_impl.cc123
-rw-r--r--gr-blocks/lib/interleave_impl.h43
-rw-r--r--gr-blocks/lib/interleaved_char_to_complex_impl.cc64
-rw-r--r--gr-blocks/lib/interleaved_char_to_complex_impl.h22
-rw-r--r--gr-blocks/lib/interleaved_short_array_to_complex.cc8
-rw-r--r--gr-blocks/lib/interleaved_short_array_to_complex.h3
-rw-r--r--gr-blocks/lib/interleaved_short_to_complex_impl.cc67
-rw-r--r--gr-blocks/lib/interleaved_short_to_complex_impl.h27
-rw-r--r--gr-blocks/lib/keep_m_in_n_impl.cc159
-rw-r--r--gr-blocks/lib/keep_m_in_n_impl.h38
-rw-r--r--gr-blocks/lib/keep_one_in_n_impl.cc116
-rw-r--r--gr-blocks/lib/keep_one_in_n_impl.h30
-rw-r--r--gr-blocks/lib/lfsr_32k_source_s_impl.cc65
-rw-r--r--gr-blocks/lib/lfsr_32k_source_s_impl.h30
-rw-r--r--gr-blocks/lib/magphase_to_complex_impl.cc60
-rw-r--r--gr-blocks/lib/magphase_to_complex_impl.h22
-rw-r--r--gr-blocks/lib/max_blk_impl.cc128
-rw-r--r--gr-blocks/lib/max_blk_impl.h28
-rw-r--r--gr-blocks/lib/message_debug_impl.cc130
-rw-r--r--gr-blocks/lib/message_debug_impl.h95
-rw-r--r--gr-blocks/lib/message_strobe_impl.cc95
-rw-r--r--gr-blocks/lib/message_strobe_impl.h58
-rw-r--r--gr-blocks/lib/message_strobe_random_impl.cc172
-rw-r--r--gr-blocks/lib/message_strobe_random_impl.h79
-rw-r--r--gr-blocks/lib/min_blk_impl.cc104
-rw-r--r--gr-blocks/lib/min_blk_impl.h28
-rw-r--r--gr-blocks/lib/moving_average_impl.cc173
-rw-r--r--gr-blocks/lib/moving_average_impl.h57
-rw-r--r--gr-blocks/lib/multiply_by_tag_value_cc_impl.cc147
-rw-r--r--gr-blocks/lib/multiply_by_tag_value_cc_impl.h36
-rw-r--r--gr-blocks/lib/multiply_conjugate_cc_impl.cc56
-rw-r--r--gr-blocks/lib/multiply_conjugate_cc_impl.h22
-rw-r--r--gr-blocks/lib/multiply_const_impl.cc194
-rw-r--r--gr-blocks/lib/multiply_const_impl.h30
-rw-r--r--gr-blocks/lib/multiply_const_v_impl.cc188
-rw-r--r--gr-blocks/lib/multiply_const_v_impl.h28
-rw-r--r--gr-blocks/lib/multiply_impl.cc159
-rw-r--r--gr-blocks/lib/multiply_impl.h24
-rw-r--r--gr-blocks/lib/multiply_matrix_impl.cc441
-rw-r--r--gr-blocks/lib/multiply_matrix_impl.h48
-rw-r--r--gr-blocks/lib/mute_impl.cc94
-rw-r--r--gr-blocks/lib/mute_impl.h34
-rw-r--r--gr-blocks/lib/nlog10_ff_impl.cc72
-rw-r--r--gr-blocks/lib/nlog10_ff_impl.h26
-rw-r--r--gr-blocks/lib/nop_impl.cc111
-rw-r--r--gr-blocks/lib/nop_impl.h42
-rw-r--r--gr-blocks/lib/not_blk_impl.cc53
-rw-r--r--gr-blocks/lib/not_blk_impl.h24
-rw-r--r--gr-blocks/lib/null_sink_impl.cc53
-rw-r--r--gr-blocks/lib/null_sink_impl.h22
-rw-r--r--gr-blocks/lib/null_source_impl.cc55
-rw-r--r--gr-blocks/lib/null_source_impl.h22
-rw-r--r--gr-blocks/lib/or_blk_impl.cc22
-rw-r--r--gr-blocks/lib/or_blk_impl.h24
-rw-r--r--gr-blocks/lib/pack_k_bits.cc59
-rw-r--r--gr-blocks/lib/pack_k_bits_bb_impl.cc54
-rw-r--r--gr-blocks/lib/pack_k_bits_bb_impl.h28
-rw-r--r--gr-blocks/lib/packed_to_unpacked_impl.cc202
-rw-r--r--gr-blocks/lib/packed_to_unpacked_impl.h59
-rw-r--r--gr-blocks/lib/patterned_interleaver_impl.cc92
-rw-r--r--gr-blocks/lib/patterned_interleaver_impl.h42
-rw-r--r--gr-blocks/lib/pdu.cc120
-rw-r--r--gr-blocks/lib/pdu_filter_impl.cc62
-rw-r--r--gr-blocks/lib/pdu_filter_impl.h30
-rw-r--r--gr-blocks/lib/pdu_remove_impl.cc53
-rw-r--r--gr-blocks/lib/pdu_remove_impl.h22
-rw-r--r--gr-blocks/lib/pdu_set_impl.cc53
-rw-r--r--gr-blocks/lib/pdu_set_impl.h26
-rw-r--r--gr-blocks/lib/pdu_to_tagged_stream_impl.cc112
-rw-r--r--gr-blocks/lib/pdu_to_tagged_stream_impl.h34
-rw-r--r--gr-blocks/lib/peak_detector2_fb_impl.cc192
-rw-r--r--gr-blocks/lib/peak_detector2_fb_impl.h53
-rw-r--r--gr-blocks/lib/peak_detector_impl.cc156
-rw-r--r--gr-blocks/lib/peak_detector_impl.h57
-rw-r--r--gr-blocks/lib/plateau_detector_fb_impl.cc120
-rw-r--r--gr-blocks/lib/plateau_detector_fb_impl.h31
-rw-r--r--gr-blocks/lib/probe_rate_impl.cc175
-rw-r--r--gr-blocks/lib/probe_rate_impl.h60
-rw-r--r--gr-blocks/lib/probe_signal_impl.cc57
-rw-r--r--gr-blocks/lib/probe_signal_impl.h30
-rw-r--r--gr-blocks/lib/probe_signal_v_impl.cc70
-rw-r--r--gr-blocks/lib/probe_signal_v_impl.h32
-rw-r--r--gr-blocks/lib/qa_block_tags.cc741
-rw-r--r--gr-blocks/lib/qa_gr_block.cc94
-rw-r--r--gr-blocks/lib/qa_gr_flowgraph.cc299
-rw-r--r--gr-blocks/lib/qa_gr_hier_block2.cc16
-rw-r--r--gr-blocks/lib/qa_gr_hier_block2_derived.cc45
-rw-r--r--gr-blocks/lib/qa_gr_top_block.cc328
-rw-r--r--gr-blocks/lib/qa_rotator.cc87
-rw-r--r--gr-blocks/lib/qa_set_msg_handler.cc40
-rw-r--r--gr-blocks/lib/random_pdu_impl.cc93
-rw-r--r--gr-blocks/lib/random_pdu_impl.h49
-rw-r--r--gr-blocks/lib/regenerate_bb_impl.cc106
-rw-r--r--gr-blocks/lib/regenerate_bb_impl.h40
-rw-r--r--gr-blocks/lib/repack_bits_bb_impl.cc251
-rw-r--r--gr-blocks/lib/repack_bits_bb_impl.h62
-rw-r--r--gr-blocks/lib/repeat_impl.cc97
-rw-r--r--gr-blocks/lib/repeat_impl.h33
-rw-r--r--gr-blocks/lib/rms_cf_impl.cc70
-rw-r--r--gr-blocks/lib/rms_cf_impl.h37
-rw-r--r--gr-blocks/lib/rms_ff_impl.cc70
-rw-r--r--gr-blocks/lib/rms_ff_impl.h36
-rw-r--r--gr-blocks/lib/rotator_cc_impl.cc60
-rw-r--r--gr-blocks/lib/rotator_cc_impl.h37
-rw-r--r--gr-blocks/lib/sample_and_hold_impl.cc63
-rw-r--r--gr-blocks/lib/sample_and_hold_impl.h28
-rw-r--r--gr-blocks/lib/short_to_char_impl.cc64
-rw-r--r--gr-blocks/lib/short_to_char_impl.h22
-rw-r--r--gr-blocks/lib/short_to_float_impl.cc65
-rw-r--r--gr-blocks/lib/short_to_float_impl.h28
-rw-r--r--gr-blocks/lib/skiphead_impl.cc113
-rw-r--r--gr-blocks/lib/skiphead_impl.h40
-rw-r--r--gr-blocks/lib/socket_pdu_impl.cc335
-rw-r--r--gr-blocks/lib/socket_pdu_impl.h75
-rw-r--r--gr-blocks/lib/stream_mux_impl.cc129
-rw-r--r--gr-blocks/lib/stream_mux_impl.h34
-rw-r--r--gr-blocks/lib/stream_pdu_base.cc127
-rw-r--r--gr-blocks/lib/stream_pdu_base.h52
-rw-r--r--gr-blocks/lib/stream_to_streams_impl.cc63
-rw-r--r--gr-blocks/lib/stream_to_streams_impl.h20
-rw-r--r--gr-blocks/lib/stream_to_tagged_stream_impl.cc104
-rw-r--r--gr-blocks/lib/stream_to_tagged_stream_impl.h54
-rw-r--r--gr-blocks/lib/stream_to_vector_impl.cc48
-rw-r--r--gr-blocks/lib/stream_to_vector_impl.h20
-rw-r--r--gr-blocks/lib/streams_to_stream_impl.cc65
-rw-r--r--gr-blocks/lib/streams_to_stream_impl.h20
-rw-r--r--gr-blocks/lib/streams_to_vector_impl.cc59
-rw-r--r--gr-blocks/lib/streams_to_vector_impl.h20
-rw-r--r--gr-blocks/lib/stretch_ff_impl.cc74
-rw-r--r--gr-blocks/lib/stretch_ff_impl.h34
-rw-r--r--gr-blocks/lib/sub_impl.cc117
-rw-r--r--gr-blocks/lib/sub_impl.h24
-rw-r--r--gr-blocks/lib/tag_debug_impl.cc201
-rw-r--r--gr-blocks/lib/tag_debug_impl.h51
-rw-r--r--gr-blocks/lib/tag_gate_impl.cc102
-rw-r--r--gr-blocks/lib/tag_gate_impl.h39
-rw-r--r--gr-blocks/lib/tag_share_impl.cc91
-rw-r--r--gr-blocks/lib/tag_share_impl.h49
-rw-r--r--gr-blocks/lib/tagged_file_sink_impl.cc355
-rw-r--r--gr-blocks/lib/tagged_file_sink_impl.h55
-rw-r--r--gr-blocks/lib/tagged_stream_align_impl.cc75
-rw-r--r--gr-blocks/lib/tagged_stream_align_impl.h41
-rw-r--r--gr-blocks/lib/tagged_stream_multiply_length_impl.cc100
-rw-r--r--gr-blocks/lib/tagged_stream_multiply_length_impl.h44
-rw-r--r--gr-blocks/lib/tagged_stream_mux_impl.cc114
-rw-r--r--gr-blocks/lib/tagged_stream_mux_impl.h47
-rw-r--r--gr-blocks/lib/tagged_stream_to_pdu_impl.cc78
-rw-r--r--gr-blocks/lib/tagged_stream_to_pdu_impl.h41
-rw-r--r--gr-blocks/lib/tags_strobe_impl.cc97
-rw-r--r--gr-blocks/lib/tags_strobe_impl.h63
-rw-r--r--gr-blocks/lib/tcp_connection.cc125
-rw-r--r--gr-blocks/lib/tcp_connection.h48
-rw-r--r--gr-blocks/lib/tcp_server_sink_impl.cc196
-rw-r--r--gr-blocks/lib/tcp_server_sink_impl.h64
-rw-r--r--gr-blocks/lib/test_tag_variable_rate_ff_impl.cc177
-rw-r--r--gr-blocks/lib/test_tag_variable_rate_ff_impl.h51
-rw-r--r--gr-blocks/lib/threshold_ff_impl.cc74
-rw-r--r--gr-blocks/lib/threshold_ff_impl.h51
-rw-r--r--gr-blocks/lib/throttle_impl.cc193
-rw-r--r--gr-blocks/lib/throttle_impl.h44
-rw-r--r--gr-blocks/lib/transcendental_impl.cc213
-rw-r--r--gr-blocks/lib/transcendental_impl.h29
-rw-r--r--gr-blocks/lib/tsb_vector_sink_impl.cc92
-rw-r--r--gr-blocks/lib/tsb_vector_sink_impl.h51
-rw-r--r--gr-blocks/lib/tuntap_pdu_impl.cc235
-rw-r--r--gr-blocks/lib/tuntap_pdu_impl.h26
-rw-r--r--gr-blocks/lib/uchar_array_to_float.cc25
-rw-r--r--gr-blocks/lib/uchar_array_to_float.h2
-rw-r--r--gr-blocks/lib/uchar_to_float_impl.cc57
-rw-r--r--gr-blocks/lib/uchar_to_float_impl.h20
-rw-r--r--gr-blocks/lib/udp_sink_impl.cc164
-rw-r--r--gr-blocks/lib/udp_sink_impl.h49
-rw-r--r--gr-blocks/lib/udp_source_impl.cc277
-rw-r--r--gr-blocks/lib/udp_source_impl.h79
-rw-r--r--gr-blocks/lib/unpack_k_bits.cc67
-rw-r--r--gr-blocks/lib/unpack_k_bits_bb_impl.cc54
-rw-r--r--gr-blocks/lib/unpack_k_bits_bb_impl.h28
-rw-r--r--gr-blocks/lib/unpacked_to_packed_impl.cc186
-rw-r--r--gr-blocks/lib/unpacked_to_packed_impl.h56
-rw-r--r--gr-blocks/lib/vco_c_impl.cc56
-rw-r--r--gr-blocks/lib/vco_c_impl.h42
-rw-r--r--gr-blocks/lib/vco_f_impl.cc56
-rw-r--r--gr-blocks/lib/vco_f_impl.h42
-rw-r--r--gr-blocks/lib/vector_insert_impl.cc145
-rw-r--r--gr-blocks/lib/vector_insert_impl.h52
-rw-r--r--gr-blocks/lib/vector_map_impl.cc163
-rw-r--r--gr-blocks/lib/vector_map_impl.h47
-rw-r--r--gr-blocks/lib/vector_sink_impl.cc117
-rw-r--r--gr-blocks/lib/vector_sink_impl.h50
-rw-r--r--gr-blocks/lib/vector_source_impl.cc159
-rw-r--r--gr-blocks/lib/vector_source_impl.h60
-rw-r--r--gr-blocks/lib/vector_to_stream_impl.cc48
-rw-r--r--gr-blocks/lib/vector_to_stream_impl.h20
-rw-r--r--gr-blocks/lib/vector_to_streams_impl.cc59
-rw-r--r--gr-blocks/lib/vector_to_streams_impl.h20
-rw-r--r--gr-blocks/lib/wavfile.cc409
-rw-r--r--gr-blocks/lib/wavfile_sink_impl.cc396
-rw-r--r--gr-blocks/lib/wavfile_sink_impl.h132
-rw-r--r--gr-blocks/lib/wavfile_source_impl.cc231
-rw-r--r--gr-blocks/lib/wavfile_source_impl.h60
-rw-r--r--gr-blocks/lib/xor_blk_impl.cc59
-rw-r--r--gr-blocks/lib/xor_blk_impl.h24
-rw-r--r--gr-blocks/tests/benchmark_nco.cc203
-rw-r--r--gr-blocks/tests/benchmark_vco.cc146
479 files changed, 18347 insertions, 18742 deletions
diff --git a/gr-blocks/include/gnuradio/blocks/abs_blk.h b/gr-blocks/include/gnuradio/blocks/abs_blk.h
index 83e3307e50..231b380a25 100644
--- a/gr-blocks/include/gnuradio/blocks/abs_blk.h
+++ b/gr-blocks/include/gnuradio/blocks/abs_blk.h
@@ -29,34 +29,33 @@
#include <cstdint>
namespace gr {
- namespace blocks {
+namespace blocks {
- /*!
- * \brief output[m] = abs(input[m]) for all M streams.
- * \ingroup boolean_operators_blk
- *
- * \details
- * absolute value of data stream (Strip sign)
- */
-template<class T>
- class BLOCKS_API abs_blk : virtual public sync_block
- {
-
- public:
+/*!
+ * \brief output[m] = abs(input[m]) for all M streams.
+ * \ingroup boolean_operators_blk
+ *
+ * \details
+ * absolute value of data stream (Strip sign)
+ */
+template <class T>
+class BLOCKS_API abs_blk : virtual public sync_block
+{
- // gr::blocks::abs_blk::sptr
- typedef boost::shared_ptr< abs_blk<T> > sptr;
+public:
+ // gr::blocks::abs_blk::sptr
+ typedef boost::shared_ptr<abs_blk<T>> sptr;
- /*!
- * \brief Create an instance of abs_blk
- */
- static sptr make(size_t vlen=1);
- };
+ /*!
+ * \brief Create an instance of abs_blk
+ */
+ static sptr make(size_t vlen = 1);
+};
typedef abs_blk<std::int16_t> abs_ss;
typedef abs_blk<std::int32_t> abs_ii;
typedef abs_blk<float> abs_ff;
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* ABS_BLK_H */
diff --git a/gr-blocks/include/gnuradio/blocks/add_blk.h b/gr-blocks/include/gnuradio/blocks/add_blk.h
index 40408f7836..4025170a43 100644
--- a/gr-blocks/include/gnuradio/blocks/add_blk.h
+++ b/gr-blocks/include/gnuradio/blocks/add_blk.h
@@ -29,36 +29,35 @@
#include <cstdint>
namespace gr {
- namespace blocks {
+namespace blocks {
- /*!
- * \brief output = sum(input[0], input[1], ..., input[M-1])
- * \ingroup math_operators_blk
- *
- * \details
- * Add samples across all input streams. For all \f$n\f$ samples
- * on all \f$M\f$ input streams \f$x_m\f$:
- *
- * \f[
- * y[n] = \sum_{m=0}^{M-1} x_m[n]
- * \f]
- */
-template<class T>
- class BLOCKS_API add_blk : virtual public sync_block
- {
- public:
-
- // gr::blocks::add_blk::sptr
- typedef boost::shared_ptr< add_blk<T> > sptr;
+/*!
+ * \brief output = sum(input[0], input[1], ..., input[M-1])
+ * \ingroup math_operators_blk
+ *
+ * \details
+ * Add samples across all input streams. For all \f$n\f$ samples
+ * on all \f$M\f$ input streams \f$x_m\f$:
+ *
+ * \f[
+ * y[n] = \sum_{m=0}^{M-1} x_m[n]
+ * \f]
+ */
+template <class T>
+class BLOCKS_API add_blk : virtual public sync_block
+{
+public:
+ // gr::blocks::add_blk::sptr
+ typedef boost::shared_ptr<add_blk<T>> sptr;
- static sptr make(size_t vlen=1);
- };
+ static sptr make(size_t vlen = 1);
+};
typedef add_blk<std::int16_t> add_ss;
typedef add_blk<std::int32_t> add_ii;
typedef add_blk<gr_complex> add_cc;
typedef add_blk<float> add_ff;
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* ADD_BLK_H */
diff --git a/gr-blocks/include/gnuradio/blocks/add_const_bb.h b/gr-blocks/include/gnuradio/blocks/add_const_bb.h
index 6d4875d75a..06d14649dd 100644
--- a/gr-blocks/include/gnuradio/blocks/add_const_bb.h
+++ b/gr-blocks/include/gnuradio/blocks/add_const_bb.h
@@ -27,37 +27,36 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief output = input + constant
+ * \ingroup math_operators_blk
+ */
+class BLOCKS_API add_const_bb : virtual public sync_block
+{
+public:
+ // gr::blocks::add_const_bb::sptr
+ typedef boost::shared_ptr<add_const_bb> sptr;
+
+ /*!
+ * \brief Create an instance of add_const_bb
+ * \param k additive constant
+ */
+ static sptr make(unsigned char k);
/*!
- * \brief output = input + constant
- * \ingroup math_operators_blk
+ * \brief Return additive constant
*/
- class BLOCKS_API add_const_bb : virtual public sync_block
- {
- public:
-
- // gr::blocks::add_const_bb::sptr
- typedef boost::shared_ptr<add_const_bb> sptr;
-
- /*!
- * \brief Create an instance of add_const_bb
- * \param k additive constant
- */
- static sptr make(unsigned char k);
-
- /*!
- * \brief Return additive constant
- */
- virtual unsigned char k() const = 0;
-
- /*!
- * \brief Set additive constant
- */
- virtual void set_k(unsigned char k) = 0;
- };
-
- }
-}
+ virtual unsigned char k() const = 0;
+
+ /*!
+ * \brief Set additive constant
+ */
+ virtual void set_k(unsigned char k) = 0;
+};
+
+} // namespace blocks
+} // namespace gr
#endif /* ADD_CONST_BB */
diff --git a/gr-blocks/include/gnuradio/blocks/add_const_cc.h b/gr-blocks/include/gnuradio/blocks/add_const_cc.h
index 35a15f72a8..810f04133e 100644
--- a/gr-blocks/include/gnuradio/blocks/add_const_cc.h
+++ b/gr-blocks/include/gnuradio/blocks/add_const_cc.h
@@ -27,37 +27,36 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief output = input + constant
+ * \ingroup math_operators_blk
+ */
+class BLOCKS_API add_const_cc : virtual public sync_block
+{
+public:
+ // gr::blocks::add_const_cc::sptr
+ typedef boost::shared_ptr<add_const_cc> sptr;
+
+ /*!
+ * \brief Create an instance of add_const_cc
+ * \param k additive constant
+ */
+ static sptr make(gr_complex k);
/*!
- * \brief output = input + constant
- * \ingroup math_operators_blk
+ * \brief Return additive constant
*/
- class BLOCKS_API add_const_cc : virtual public sync_block
- {
- public:
-
- // gr::blocks::add_const_cc::sptr
- typedef boost::shared_ptr<add_const_cc> sptr;
-
- /*!
- * \brief Create an instance of add_const_cc
- * \param k additive constant
- */
- static sptr make(gr_complex k);
-
- /*!
- * \brief Return additive constant
- */
- virtual gr_complex k() const = 0;
-
- /*!
- * \brief Set additive constant
- */
- virtual void set_k(gr_complex k) = 0;
- };
-
- }
-}
+ virtual gr_complex k() const = 0;
+
+ /*!
+ * \brief Set additive constant
+ */
+ virtual void set_k(gr_complex k) = 0;
+};
+
+} // namespace blocks
+} // namespace gr
#endif /* ADD_CONST_CC */
diff --git a/gr-blocks/include/gnuradio/blocks/add_const_ff.h b/gr-blocks/include/gnuradio/blocks/add_const_ff.h
index 66be094dab..66fb9e5d07 100644
--- a/gr-blocks/include/gnuradio/blocks/add_const_ff.h
+++ b/gr-blocks/include/gnuradio/blocks/add_const_ff.h
@@ -27,37 +27,36 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief output = input + constant
+ * \ingroup math_operators_blk
+ */
+class BLOCKS_API add_const_ff : virtual public sync_block
+{
+public:
+ // gr::blocks::add_const_ff::sptr
+ typedef boost::shared_ptr<add_const_ff> sptr;
+
+ /*!
+ * \brief Create an instance of add_const_ff
+ * \param k additive constant
+ */
+ static sptr make(float k);
/*!
- * \brief output = input + constant
- * \ingroup math_operators_blk
+ * \brief Return additive constant
*/
- class BLOCKS_API add_const_ff : virtual public sync_block
- {
- public:
-
- // gr::blocks::add_const_ff::sptr
- typedef boost::shared_ptr<add_const_ff> sptr;
-
- /*!
- * \brief Create an instance of add_const_ff
- * \param k additive constant
- */
- static sptr make(float k);
-
- /*!
- * \brief Return additive constant
- */
- virtual float k() const = 0;
-
- /*!
- * \brief Set additive constant
- */
- virtual void set_k(float k) = 0;
- };
-
- }
-}
+ virtual float k() const = 0;
+
+ /*!
+ * \brief Set additive constant
+ */
+ virtual void set_k(float k) = 0;
+};
+
+} // namespace blocks
+} // namespace gr
#endif /* ADD_CONST_FF */
diff --git a/gr-blocks/include/gnuradio/blocks/add_const_ii.h b/gr-blocks/include/gnuradio/blocks/add_const_ii.h
index 246902caf4..341d44d0bb 100644
--- a/gr-blocks/include/gnuradio/blocks/add_const_ii.h
+++ b/gr-blocks/include/gnuradio/blocks/add_const_ii.h
@@ -27,37 +27,36 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief output = input + constant
+ * \ingroup math_operators_blk
+ */
+class BLOCKS_API add_const_ii : virtual public sync_block
+{
+public:
+ // gr::blocks::add_const_ii::sptr
+ typedef boost::shared_ptr<add_const_ii> sptr;
+
+ /*!
+ * \brief Create an instance of add_const_ii
+ * \param k additive constant
+ */
+ static sptr make(int k);
/*!
- * \brief output = input + constant
- * \ingroup math_operators_blk
+ * \brief Return additive constant
*/
- class BLOCKS_API add_const_ii : virtual public sync_block
- {
- public:
-
- // gr::blocks::add_const_ii::sptr
- typedef boost::shared_ptr<add_const_ii> sptr;
-
- /*!
- * \brief Create an instance of add_const_ii
- * \param k additive constant
- */
- static sptr make(int k);
-
- /*!
- * \brief Return additive constant
- */
- virtual int k() const = 0;
-
- /*!
- * \brief Set additive constant
- */
- virtual void set_k(int k) = 0;
- };
-
- }
-}
+ virtual int k() const = 0;
+
+ /*!
+ * \brief Set additive constant
+ */
+ virtual void set_k(int k) = 0;
+};
+
+} // namespace blocks
+} // namespace gr
#endif /* ADD_CONST_II */
diff --git a/gr-blocks/include/gnuradio/blocks/add_const_ss.h b/gr-blocks/include/gnuradio/blocks/add_const_ss.h
index f9beee1b7b..cfb4c353ab 100644
--- a/gr-blocks/include/gnuradio/blocks/add_const_ss.h
+++ b/gr-blocks/include/gnuradio/blocks/add_const_ss.h
@@ -27,37 +27,36 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief output = input + constant
+ * \ingroup math_operators_blk
+ */
+class BLOCKS_API add_const_ss : virtual public sync_block
+{
+public:
+ // gr::blocks::add_const_ss::sptr
+ typedef boost::shared_ptr<add_const_ss> sptr;
+
+ /*!
+ * \brief Create an instance of add_const_ss
+ * \param k additive constant
+ */
+ static sptr make(short k);
/*!
- * \brief output = input + constant
- * \ingroup math_operators_blk
+ * \brief Return additive constant
*/
- class BLOCKS_API add_const_ss : virtual public sync_block
- {
- public:
-
- // gr::blocks::add_const_ss::sptr
- typedef boost::shared_ptr<add_const_ss> sptr;
-
- /*!
- * \brief Create an instance of add_const_ss
- * \param k additive constant
- */
- static sptr make(short k);
-
- /*!
- * \brief Return additive constant
- */
- virtual short k() const = 0;
-
- /*!
- * \brief Set additive constant
- */
- virtual void set_k(short k) = 0;
- };
-
- }
-}
+ virtual short k() const = 0;
+
+ /*!
+ * \brief Set additive constant
+ */
+ virtual void set_k(short k) = 0;
+};
+
+} // namespace blocks
+} // namespace gr
#endif /* ADD_CONST_SS */
diff --git a/gr-blocks/include/gnuradio/blocks/add_const_v.h b/gr-blocks/include/gnuradio/blocks/add_const_v.h
index f33393c668..3ed66bff2e 100644
--- a/gr-blocks/include/gnuradio/blocks/add_const_v.h
+++ b/gr-blocks/include/gnuradio/blocks/add_const_v.h
@@ -28,44 +28,43 @@
#include <cstdint>
namespace gr {
- namespace blocks {
+namespace blocks {
- /*!
- * \brief output[m] = input[m] + constant vector for all M streams.
- * \ingroup math_operators_blk
- */
- template <class T>
- class BLOCKS_API add_const_v : virtual public sync_block
- {
-
- public:
+/*!
+ * \brief output[m] = input[m] + constant vector for all M streams.
+ * \ingroup math_operators_blk
+ */
+template <class T>
+class BLOCKS_API add_const_v : virtual public sync_block
+{
- typedef boost::shared_ptr<add_const_v <T> > sptr;
+public:
+ typedef boost::shared_ptr<add_const_v<T>> sptr;
- /*!
- * \brief Create an instance of add_const_v
- * \param k additive constant vector
- */
- static sptr make(std::vector<T> k);
+ /*!
+ * \brief Create an instance of add_const_v
+ * \param k additive constant vector
+ */
+ static sptr make(std::vector<T> k);
- /*!
- * \brief Return additive constant vector
- */
- virtual std::vector<T> k() const = 0;
+ /*!
+ * \brief Return additive constant vector
+ */
+ virtual std::vector<T> k() const = 0;
- /*!
- * \brief Set additive constant vector
- */
- virtual void set_k(std::vector<T> k) = 0;
- };
+ /*!
+ * \brief Set additive constant vector
+ */
+ virtual void set_k(std::vector<T> k) = 0;
+};
- typedef add_const_v<std::uint8_t> add_const_vbb;
- typedef add_const_v<std::int16_t> add_const_vss;
- typedef add_const_v<std::int32_t> add_const_vii;
- typedef add_const_v<float> add_const_vff;
- typedef add_const_v<gr_complex> add_const_vcc;
+typedef add_const_v<std::uint8_t> add_const_vbb;
+typedef add_const_v<std::int16_t> add_const_vss;
+typedef add_const_v<std::int32_t> add_const_vii;
+typedef add_const_v<float> add_const_vff;
+typedef add_const_v<gr_complex> add_const_vcc;
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* ADD_CONST_V_H */
diff --git a/gr-blocks/include/gnuradio/blocks/and_blk.h b/gr-blocks/include/gnuradio/blocks/and_blk.h
index d24781b0f4..bdfa82a5dd 100644
--- a/gr-blocks/include/gnuradio/blocks/and_blk.h
+++ b/gr-blocks/include/gnuradio/blocks/and_blk.h
@@ -29,30 +29,29 @@
#include <cstdint>
namespace gr {
- namespace blocks {
-
- /*!
- * \brief output = input[0] & input[1] & ... & input[M-1]
- * \ingroup boolean_operators_blk
- *
- * \details
- * bitwise boolean AND across all input streams.
- */
-template<class T>
- class BLOCKS_API and_blk : virtual public sync_block
- {
- public:
-
- // gr::blocks::and_blk::sptr
- typedef boost::shared_ptr< and_blk<T> > sptr;
-
- static sptr make(size_t vlen=1);
- };
+namespace blocks {
+
+/*!
+ * \brief output = input[0] & input[1] & ... & input[M-1]
+ * \ingroup boolean_operators_blk
+ *
+ * \details
+ * bitwise boolean AND across all input streams.
+ */
+template <class T>
+class BLOCKS_API and_blk : virtual public sync_block
+{
+public:
+ // gr::blocks::and_blk::sptr
+ typedef boost::shared_ptr<and_blk<T>> sptr;
+
+ static sptr make(size_t vlen = 1);
+};
typedef and_blk<std::uint8_t> and_bb;
typedef and_blk<std::int16_t> and_ss;
typedef and_blk<std::int32_t> and_ii;
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* AND_BLK_H */
diff --git a/gr-blocks/include/gnuradio/blocks/and_const.h b/gr-blocks/include/gnuradio/blocks/and_const.h
index dbc664d170..f86e594f68 100644
--- a/gr-blocks/include/gnuradio/blocks/and_const.h
+++ b/gr-blocks/include/gnuradio/blocks/and_const.h
@@ -29,45 +29,44 @@
#include <cstdint>
namespace gr {
- namespace blocks {
+namespace blocks {
- /*!
- * \brief output[m] = input[m] & value for all M streams.
- * \ingroup boolean_operators_blk
- *
- * \details
- * Bitwise boolean AND of constant \p k with the data stream.
- */
-template<class T>
- class BLOCKS_API and_const : virtual public sync_block
- {
-
- public:
+/*!
+ * \brief output[m] = input[m] & value for all M streams.
+ * \ingroup boolean_operators_blk
+ *
+ * \details
+ * Bitwise boolean AND of constant \p k with the data stream.
+ */
+template <class T>
+class BLOCKS_API and_const : virtual public sync_block
+{
- // gr::blocks::and_const::sptr
- typedef boost::shared_ptr< and_const<T> > sptr;
+public:
+ // gr::blocks::and_const::sptr
+ typedef boost::shared_ptr<and_const<T>> sptr;
- /*!
- * \brief Create an instance of and_const
- * \param k AND constant
- */
- static sptr make(T k);
+ /*!
+ * \brief Create an instance of and_const
+ * \param k AND constant
+ */
+ static sptr make(T k);
- /*!
- * \brief Return AND constant
- */
- virtual T k() const = 0;
+ /*!
+ * \brief Return AND constant
+ */
+ virtual T k() const = 0;
- /*!
- * \brief Set AND constant
- */
- virtual void set_k(T k) = 0;
- };
+ /*!
+ * \brief Set AND constant
+ */
+ virtual void set_k(T k) = 0;
+};
typedef and_const<std::uint8_t> and_const_bb;
typedef and_const<std::int16_t> and_const_ss;
typedef and_const<std::int32_t> and_const_ii;
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* AND_CONST_H */
diff --git a/gr-blocks/include/gnuradio/blocks/annotator_1to1.h b/gr-blocks/include/gnuradio/blocks/annotator_1to1.h
index 4ae23b1201..60bb4d6875 100644
--- a/gr-blocks/include/gnuradio/blocks/annotator_1to1.h
+++ b/gr-blocks/include/gnuradio/blocks/annotator_1to1.h
@@ -21,43 +21,43 @@
*/
#ifndef INCLUDED_GR_ANNOTATOR_1TO1_H
-#define INCLUDED_GR_ANNOTATOR_1TO1_H
+#define INCLUDED_GR_ANNOTATOR_1TO1_H
#include <gnuradio/blocks/api.h>
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
-
- /*!
- * \brief 1-to-1 stream annotator testing block. FOR TESTING PURPOSES ONLY.
- * \ingroup debug_tools_blk
- *
- * \details
- * 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.
- *
- * Warning: This block is only meant for testing and showing how to use the
- * tags.
- */
- class BLOCKS_API annotator_1to1 : virtual public 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<tag_t> data() const = 0;
- };
-
- } /* namespace blocks */
+namespace blocks {
+
+/*!
+ * \brief 1-to-1 stream annotator testing block. FOR TESTING PURPOSES ONLY.
+ * \ingroup debug_tools_blk
+ *
+ * \details
+ * 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.
+ *
+ * Warning: This block is only meant for testing and showing how to use the
+ * tags.
+ */
+class BLOCKS_API annotator_1to1 : virtual public 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<tag_t> data() const = 0;
+};
+
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_GR_ANNOTATOR_1TO1_H */
diff --git a/gr-blocks/include/gnuradio/blocks/annotator_alltoall.h b/gr-blocks/include/gnuradio/blocks/annotator_alltoall.h
index 499c5f36b6..e13d32fde8 100644
--- a/gr-blocks/include/gnuradio/blocks/annotator_alltoall.h
+++ b/gr-blocks/include/gnuradio/blocks/annotator_alltoall.h
@@ -21,43 +21,43 @@
*/
#ifndef INCLUDED_GR_ANNOTATOR_ALLTOALL_H
-#define INCLUDED_GR_ANNOTATOR_ALLTOALL_H
+#define INCLUDED_GR_ANNOTATOR_ALLTOALL_H
#include <gnuradio/blocks/api.h>
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
-
- /*!
- * \brief All-to-all stream annotator testing block. FOR TESTING PURPOSES ONLY.
- * \ingroup debug_tools_blk
- *
- * \details
- * 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 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<tag_t> data() const = 0;
- };
-
- } /* namespace blocks */
+namespace blocks {
+
+/*!
+ * \brief All-to-all stream annotator testing block. FOR TESTING PURPOSES ONLY.
+ * \ingroup debug_tools_blk
+ *
+ * \details
+ * 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 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<tag_t> data() const = 0;
+};
+
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_GR_ANNOTATOR_ALLTOALL_H */
diff --git a/gr-blocks/include/gnuradio/blocks/annotator_raw.h b/gr-blocks/include/gnuradio/blocks/annotator_raw.h
index 5e9c702602..4d0f7a64af 100644
--- a/gr-blocks/include/gnuradio/blocks/annotator_raw.h
+++ b/gr-blocks/include/gnuradio/blocks/annotator_raw.h
@@ -21,39 +21,39 @@
*/
#ifndef INCLUDED_GR_ANNOTATOR_RAW_H
-#define INCLUDED_GR_ANNOTATOR_RAW_H
+#define INCLUDED_GR_ANNOTATOR_RAW_H
#include <gnuradio/blocks/api.h>
#include <gnuradio/sync_block.h>
#include <gnuradio/tags.h>
namespace gr {
- namespace blocks {
-
- /*!
- * \brief raw stream annotator testing block.
- * \ingroup debug_tools_blk
- *
- * \details
- * This block creates arbitrary tags to be sent downstream gnuradio/blocks
- * to be sent are set manually via accessor methods and are sent
- * only once.
- *
- * This block is intended for testing of tag related gnuradio/blocks
- */
- class BLOCKS_API annotator_raw : virtual public 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
- virtual void add_tag(uint64_t offset, pmt::pmt_t key, pmt::pmt_t val) = 0;
- };
-
- } /* namespace blocks */
+namespace blocks {
+
+/*!
+ * \brief raw stream annotator testing block.
+ * \ingroup debug_tools_blk
+ *
+ * \details
+ * This block creates arbitrary tags to be sent downstream gnuradio/blocks
+ * to be sent are set manually via accessor methods and are sent
+ * only once.
+ *
+ * This block is intended for testing of tag related gnuradio/blocks
+ */
+class BLOCKS_API annotator_raw : virtual public 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
+ virtual void add_tag(uint64_t offset, pmt::pmt_t key, pmt::pmt_t val) = 0;
+};
+
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_GR_ANNOTATOR_RAW_H */
diff --git a/gr-blocks/include/gnuradio/blocks/api.h b/gr-blocks/include/gnuradio/blocks/api.h
index fd4e605b56..a16a2c7a6a 100644
--- a/gr-blocks/include/gnuradio/blocks/api.h
+++ b/gr-blocks/include/gnuradio/blocks/api.h
@@ -25,9 +25,9 @@
#include <gnuradio/attributes.h>
#ifdef gnuradio_blocks_EXPORTS
-# define BLOCKS_API __GR_ATTR_EXPORT
+#define BLOCKS_API __GR_ATTR_EXPORT
#else
-# define BLOCKS_API __GR_ATTR_IMPORT
+#define BLOCKS_API __GR_ATTR_IMPORT
#endif
#endif /* INCLUDED_BLOCKS_API_H */
diff --git a/gr-blocks/include/gnuradio/blocks/argmax.h b/gr-blocks/include/gnuradio/blocks/argmax.h
index fe4d750e7b..5661e83599 100644
--- a/gr-blocks/include/gnuradio/blocks/argmax.h
+++ b/gr-blocks/include/gnuradio/blocks/argmax.h
@@ -28,38 +28,38 @@
#include <cstdint>
namespace gr {
- namespace blocks {
+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_operators_blk
- *
- * \details
- * 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:
- *
- * \li Stream 0 will contain the index value in the vector where
- * the maximum value occurred.
- *
- * \li Stream 1 will contain the number of the input stream that
- * held the maximum value.
- */
- template <class T>
- class BLOCKS_API argmax : virtual public sync_block
- {
- public:
- typedef boost::shared_ptr< argmax<T> > sptr;
+/*!
+ * \brief Compares vectors from multiple streams and determines
+ * the index in the vector and stream number where the maximum
+ * value occurred.
+ * \ingroup math_operators_blk
+ *
+ * \details
+ * 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:
+ *
+ * \li Stream 0 will contain the index value in the vector where
+ * the maximum value occurred.
+ *
+ * \li Stream 1 will contain the number of the input stream that
+ * held the maximum value.
+ */
+template <class T>
+class BLOCKS_API argmax : virtual public sync_block
+{
+public:
+ typedef boost::shared_ptr<argmax<T>> sptr;
- static sptr make(size_t vlen);
- };
+ static sptr make(size_t vlen);
+};
- typedef argmax<float> argmax_fs;
- typedef argmax<std::int32_t> argmax_is;
- typedef argmax<std::int16_t> argmax_ss;
- } /* namespace blocks */
+typedef argmax<float> argmax_fs;
+typedef argmax<std::int32_t> argmax_is;
+typedef argmax<std::int16_t> argmax_ss;
+} /* namespace blocks */
} /* namespace gr */
#endif /* ARGMAX_H */
diff --git a/gr-blocks/include/gnuradio/blocks/bin_statistics_f.h b/gr-blocks/include/gnuradio/blocks/bin_statistics_f.h
index 5bd6022568..2330af5cef 100644
--- a/gr-blocks/include/gnuradio/blocks/bin_statistics_f.h
+++ b/gr-blocks/include/gnuradio/blocks/bin_statistics_f.h
@@ -29,48 +29,48 @@
#include <gnuradio/feval.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- /*!
- * \brief control scanning and record frequency domain statistics
- * \ingroup misc_blk
- */
- class BLOCKS_API bin_statistics_f : virtual public sync_block
- {
- protected:
- std::vector<float> d_max; // per bin maxima
+/*!
+ * \brief control scanning and record frequency domain statistics
+ * \ingroup misc_blk
+ */
+class BLOCKS_API bin_statistics_f : virtual public 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 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;
+ 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;
+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 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,
- feval_dd *tune, // callback
- size_t tune_delay, // samples
- size_t dwell_delay); // samples
- };
+ /*!
+ * 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 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,
+ feval_dd* tune, // callback
+ size_t tune_delay, // samples
+ size_t dwell_delay); // samples
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_GR_BIN_STATISTICS_F_H */
diff --git a/gr-blocks/include/gnuradio/blocks/burst_tagger.h b/gr-blocks/include/gnuradio/blocks/burst_tagger.h
index c5c1dc3eac..7956c7a20d 100644
--- a/gr-blocks/include/gnuradio/blocks/burst_tagger.h
+++ b/gr-blocks/include/gnuradio/blocks/burst_tagger.h
@@ -27,50 +27,50 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief Sets a burst on/off tag based on the value of the trigger input.
+ * \ingroup peak_detectors_blk
+ * \ingroup stream_tag_tools_blk
+ *
+ * \details
+ * 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 sync_block
+{
+public:
+ // gr::blocks::burst_tagger::sptr
+ typedef boost::shared_ptr<burst_tagger> sptr;
/*!
- * \brief Sets a burst on/off tag based on the value of the trigger input.
- * \ingroup peak_detectors_blk
- * \ingroup stream_tag_tools_blk
- *
- * \details
- * 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.
+ * Build a burst tagger gnuradio/blocks.
*
- * The signal on stream 0 is retransmitted to output stream 0.
+ * \param itemsize itemsize of the signal stream on input 0.
*/
- class BLOCKS_API burst_tagger : virtual public sync_block
- {
- public:
- // gr::blocks::burst_tagger::sptr
- typedef boost::shared_ptr<burst_tagger> sptr;
+ static sptr make(size_t itemsize);
- /*!
- * Build a burst tagger gnuradio/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 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;
- };
+ /*!
+ * 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 blocks */
} /* namespace gr */
#endif /* INCLUDED_GR_BURST_TAGGER_H */
diff --git a/gr-blocks/include/gnuradio/blocks/char_to_float.h b/gr-blocks/include/gnuradio/blocks/char_to_float.h
index 1fce660427..0dfeb26d88 100644
--- a/gr-blocks/include/gnuradio/blocks/char_to_float.h
+++ b/gr-blocks/include/gnuradio/blocks/char_to_float.h
@@ -27,45 +27,44 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief Convert stream of chars to a stream of float.
+ * \ingroup type_converters_blk
+ *
+ * \details
+ * Converts \p vlen length vectors of input char samples to floats
+ * and applies a scaling factor of \p scale:
+ *
+ * \li output[0][m:m+vlen] = static_cast<float>(input[0][m:m+vlen]) / scale
+ */
+class BLOCKS_API char_to_float : virtual public sync_block
+{
+public:
+ // gr::blocks::char_to_float_ff::sptr
+ typedef boost::shared_ptr<char_to_float> sptr;
/*!
- * \brief Convert stream of chars to a stream of float.
- * \ingroup type_converters_blk
- *
- * \details
- * Converts \p vlen length vectors of input char samples to floats
- * and applies a scaling factor of \p scale:
+ * Build a chars to float stream converter block.
*
- * \li output[0][m:m+vlen] = static_cast<float>(input[0][m:m+vlen]) / scale
+ * \param vlen vector length of data streams.
+ * \param scale a scalar divider to change the output signal scale.
*/
- class BLOCKS_API char_to_float : virtual public sync_block
- {
- public:
-
- // gr::blocks::char_to_float_ff::sptr
- typedef boost::shared_ptr<char_to_float> sptr;
+ static sptr make(size_t vlen = 1, float scale = 1.0);
- /*!
- * Build a chars to float stream converter block.
- *
- * \param vlen vector length of data streams.
- * \param scale a scalar divider to change the output signal scale.
- */
- static sptr make(size_t vlen=1, float scale=1.0);
-
- /*!
- * Get the scalar divider value.
- */
- virtual float scale() const = 0;
+ /*!
+ * Get the scalar divider value.
+ */
+ virtual float scale() const = 0;
- /*!
- * Set the scalar divider value.
- */
- virtual void set_scale(float scale) = 0;
- };
+ /*!
+ * Set the scalar divider value.
+ */
+ virtual void set_scale(float scale) = 0;
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_BLOCKS_CHAR_TO_FLOAT_H */
diff --git a/gr-blocks/include/gnuradio/blocks/char_to_short.h b/gr-blocks/include/gnuradio/blocks/char_to_short.h
index aa45810eee..69109c7f57 100644
--- a/gr-blocks/include/gnuradio/blocks/char_to_short.h
+++ b/gr-blocks/include/gnuradio/blocks/char_to_short.h
@@ -27,29 +27,28 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- /*!
- * \brief Convert stream of chars to a stream of shorts.
- * \ingroup type_converters_blk
- *
- * \details
- * Converts \p vlen length vectors of input char samples to shorts,
- * multiplying each element by 256:
- *
- * \li output[0][m:m+vlen] = 256 * static_cast<short>(input[0][m:m+vlen])
- */
- class BLOCKS_API char_to_short : virtual public sync_block
- {
- public:
-
- // gr::blocks::char_to_short_ff::sptr
- typedef boost::shared_ptr<char_to_short> sptr;
+/*!
+ * \brief Convert stream of chars to a stream of shorts.
+ * \ingroup type_converters_blk
+ *
+ * \details
+ * Converts \p vlen length vectors of input char samples to shorts,
+ * multiplying each element by 256:
+ *
+ * \li output[0][m:m+vlen] = 256 * static_cast<short>(input[0][m:m+vlen])
+ */
+class BLOCKS_API char_to_short : virtual public sync_block
+{
+public:
+ // gr::blocks::char_to_short_ff::sptr
+ typedef boost::shared_ptr<char_to_short> sptr;
- static sptr make(size_t vlen=1);
- };
+ static sptr make(size_t vlen = 1);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_BLOCKS_CHAR_TO_SHORT_H */
diff --git a/gr-blocks/include/gnuradio/blocks/check_lfsr_32k_s.h b/gr-blocks/include/gnuradio/blocks/check_lfsr_32k_s.h
index 379155bcb4..33ce9f91d5 100644
--- a/gr-blocks/include/gnuradio/blocks/check_lfsr_32k_s.h
+++ b/gr-blocks/include/gnuradio/blocks/check_lfsr_32k_s.h
@@ -27,31 +27,31 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
-
- /*!
- * \brief sink that checks if its input stream consists of a lfsr_32k sequence.
- * \ingroup misc_blk
- *
- * \details
- * 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 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 blocks {
+
+/*!
+ * \brief sink that checks if its input stream consists of a lfsr_32k sequence.
+ * \ingroup misc_blk
+ *
+ * \details
+ * 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 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/gnuradio/blocks/complex_to_arg.h b/gr-blocks/include/gnuradio/blocks/complex_to_arg.h
index 2ea14aba63..374aa2c290 100644
--- a/gr-blocks/include/gnuradio/blocks/complex_to_arg.h
+++ b/gr-blocks/include/gnuradio/blocks/complex_to_arg.h
@@ -27,27 +27,27 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief complex in, arg (arctan) out (float)
+ * \ingroup type_converters_blk
+ */
+class BLOCKS_API complex_to_arg : virtual public sync_block
+{
+public:
+ // gr::blocks::complex_to_arg_ff::sptr
+ typedef boost::shared_ptr<complex_to_arg> sptr;
/*!
- * \brief complex in, arg (arctan) out (float)
- * \ingroup type_converters_blk
+ * Build a complex to arg block.
+ *
+ * \param vlen vector len (default 1)
*/
- class BLOCKS_API complex_to_arg : virtual public sync_block
- {
- public:
- // gr::blocks::complex_to_arg_ff::sptr
- typedef boost::shared_ptr<complex_to_arg> sptr;
-
- /*!
- * Build a complex to arg block.
- *
- * \param vlen vector len (default 1)
- */
- static sptr make(size_t vlen=1);
- };
+ static sptr make(size_t vlen = 1);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_BLOCKS_COMPLEX_TO_ARG_H */
diff --git a/gr-blocks/include/gnuradio/blocks/complex_to_float.h b/gr-blocks/include/gnuradio/blocks/complex_to_float.h
index 40fcb729b4..11be9785ce 100644
--- a/gr-blocks/include/gnuradio/blocks/complex_to_float.h
+++ b/gr-blocks/include/gnuradio/blocks/complex_to_float.h
@@ -27,33 +27,33 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief Convert a stream of gr_complex to 1 or 2 streams of float.
+ * \ingroup type_converters_blk
+ *
+ * \details
+ * If a single output stream is attached, this will output the
+ * real part of the input complex samples. If a second output
+ * stream is connected, output[0] is the real part and output[1]
+ * is the imaginary part.
+ */
+class BLOCKS_API complex_to_float : virtual public sync_block
+{
+public:
+ // gr::blocks::complex_to_float_ff::sptr
+ typedef boost::shared_ptr<complex_to_float> sptr;
/*!
- * \brief Convert a stream of gr_complex to 1 or 2 streams of float.
- * \ingroup type_converters_blk
+ * Build a complex to float block.
*
- * \details
- * If a single output stream is attached, this will output the
- * real part of the input complex samples. If a second output
- * stream is connected, output[0] is the real part and output[1]
- * is the imaginary part.
+ * \param vlen vector len (default 1)
*/
- class BLOCKS_API complex_to_float : virtual public sync_block
- {
- public:
- // gr::blocks::complex_to_float_ff::sptr
- typedef boost::shared_ptr<complex_to_float> sptr;
-
- /*!
- * Build a complex to float block.
- *
- * \param vlen vector len (default 1)
- */
- static sptr make(size_t vlen=1);
- };
+ static sptr make(size_t vlen = 1);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_BLOCKS_COMPLEX_TO_FLOAT_H */
diff --git a/gr-blocks/include/gnuradio/blocks/complex_to_imag.h b/gr-blocks/include/gnuradio/blocks/complex_to_imag.h
index 1311fa4dc2..95a060f8ea 100644
--- a/gr-blocks/include/gnuradio/blocks/complex_to_imag.h
+++ b/gr-blocks/include/gnuradio/blocks/complex_to_imag.h
@@ -27,27 +27,27 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief Produces the imaginary part (as a float0 of a complex stream.
+ * \ingroup type_converters_blk
+ */
+class BLOCKS_API complex_to_imag : virtual public sync_block
+{
+public:
+ // gr::blocks::complex_to_imag_ff::sptr
+ typedef boost::shared_ptr<complex_to_imag> sptr;
/*!
- * \brief Produces the imaginary part (as a float0 of a complex stream.
- * \ingroup type_converters_blk
+ * Build a complex to imaginary part block.
+ *
+ * \param vlen vector len (default 1)
*/
- class BLOCKS_API complex_to_imag : virtual public sync_block
- {
- public:
- // gr::blocks::complex_to_imag_ff::sptr
- typedef boost::shared_ptr<complex_to_imag> sptr;
-
- /*!
- * Build a complex to imaginary part block.
- *
- * \param vlen vector len (default 1)
- */
- static sptr make(size_t vlen=1);
- };
+ static sptr make(size_t vlen = 1);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_BLOCKS_COMPLEX_TO_IMAG_H */
diff --git a/gr-blocks/include/gnuradio/blocks/complex_to_interleaved_char.h b/gr-blocks/include/gnuradio/blocks/complex_to_interleaved_char.h
index edf96f7186..5fd7912a15 100644
--- a/gr-blocks/include/gnuradio/blocks/complex_to_interleaved_char.h
+++ b/gr-blocks/include/gnuradio/blocks/complex_to_interleaved_char.h
@@ -27,34 +27,34 @@
#include <gnuradio/sync_interpolator.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief Convert stream of complex to a stream of interleaved chars.
+ * \ingroup type_converters_blk
+ *
+ * \details
+ * The output stream contains chars with twice as many output
+ * items as input items. For every complex input item, we produce
+ * two output chars that contain the real part and imaginary part
+ * converted to chars:
+ *
+ * \li output[0][n] = static_cast<char>(input[0][m].real());
+ * \li output[0][n+1] = static_cast<char>(input[0][m].imag());
+ */
+class BLOCKS_API complex_to_interleaved_char : virtual public sync_interpolator
+{
+public:
+ // gr::blocks::complex_to_interleaved_char::sptr
+ typedef boost::shared_ptr<complex_to_interleaved_char> sptr;
/*!
- * \brief Convert stream of complex to a stream of interleaved chars.
- * \ingroup type_converters_blk
- *
- * \details
- * The output stream contains chars with twice as many output
- * items as input items. For every complex input item, we produce
- * two output chars that contain the real part and imaginary part
- * converted to chars:
- *
- * \li output[0][n] = static_cast<char>(input[0][m].real());
- * \li output[0][n+1] = static_cast<char>(input[0][m].imag());
+ * Build a complex to interleaved chars block.
*/
- class BLOCKS_API complex_to_interleaved_char : virtual public sync_interpolator
- {
- public:
- // gr::blocks::complex_to_interleaved_char::sptr
- typedef boost::shared_ptr<complex_to_interleaved_char> sptr;
-
- /*!
- * Build a complex to interleaved chars block.
- */
- static sptr make(bool vector=false);
- };
+ static sptr make(bool vector = false);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_BLOCKS_COMPLEX_TO_INTERLEAVED_CHAR_H */
diff --git a/gr-blocks/include/gnuradio/blocks/complex_to_interleaved_short.h b/gr-blocks/include/gnuradio/blocks/complex_to_interleaved_short.h
index d68482c448..447016b29f 100644
--- a/gr-blocks/include/gnuradio/blocks/complex_to_interleaved_short.h
+++ b/gr-blocks/include/gnuradio/blocks/complex_to_interleaved_short.h
@@ -27,34 +27,34 @@
#include <gnuradio/sync_interpolator.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief Convert stream of complex to a stream of interleaved shorts.
+ * \ingroup type_converters_blk
+ *
+ * \details
+ * The output stream contains shorts with twice as many output
+ * items as input items. For every complex input item, we produce
+ * two output shorts that contain the real part and imaginary part
+ * converted to shorts:
+ *
+ * \li output[0][n] = static_cast<short>(input[0][m].real());
+ * \li output[0][n+1] = static_cast<short>(input[0][m].imag());
+ */
+class BLOCKS_API complex_to_interleaved_short : virtual public sync_interpolator
+{
+public:
+ // gr::blocks::complex_to_interleaved_short::sptr
+ typedef boost::shared_ptr<complex_to_interleaved_short> sptr;
/*!
- * \brief Convert stream of complex to a stream of interleaved shorts.
- * \ingroup type_converters_blk
- *
- * \details
- * The output stream contains shorts with twice as many output
- * items as input items. For every complex input item, we produce
- * two output shorts that contain the real part and imaginary part
- * converted to shorts:
- *
- * \li output[0][n] = static_cast<short>(input[0][m].real());
- * \li output[0][n+1] = static_cast<short>(input[0][m].imag());
+ * Build a complex to interleaved shorts block.
*/
- class BLOCKS_API complex_to_interleaved_short : virtual public sync_interpolator
- {
- public:
- // gr::blocks::complex_to_interleaved_short::sptr
- typedef boost::shared_ptr<complex_to_interleaved_short> sptr;
-
- /*!
- * Build a complex to interleaved shorts block.
- */
- static sptr make(bool vector=false);
- };
+ static sptr make(bool vector = false);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_BLOCKS_COMPLEX_TO_INTERLEAVED_SHORT_H */
diff --git a/gr-blocks/include/gnuradio/blocks/complex_to_mag.h b/gr-blocks/include/gnuradio/blocks/complex_to_mag.h
index d6023a7681..d549d7db1e 100644
--- a/gr-blocks/include/gnuradio/blocks/complex_to_mag.h
+++ b/gr-blocks/include/gnuradio/blocks/complex_to_mag.h
@@ -27,40 +27,40 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief complex in, magnitude out (float)
+ * \ingroup type_converters_blk
+ *
+ * \details
+ * Calculates the magnitude of the complex samples:
+ *
+ * \li output[0][m] = |input[0][m]|
+ *
+ * Or:
+ * \li output[0][m] = sqrt(Re{input[0][m]}^2 + Im{input[0][m]}^2)
+ *
+ * The input stream can be a vector of length \p vlen, and for
+ * each vector, each item is converted using the above
+ * function. So above, m is from 0 to noutput_items*vlen for each
+ * call to work.
+ */
+class BLOCKS_API complex_to_mag : virtual public sync_block
+{
+public:
+ // gr::blocks::complex_to_mag_ff::sptr
+ typedef boost::shared_ptr<complex_to_mag> sptr;
/*!
- * \brief complex in, magnitude out (float)
- * \ingroup type_converters_blk
- *
- * \details
- * Calculates the magnitude of the complex samples:
- *
- * \li output[0][m] = |input[0][m]|
+ * Build a complex to magnitude block.
*
- * Or:
- * \li output[0][m] = sqrt(Re{input[0][m]}^2 + Im{input[0][m]}^2)
- *
- * The input stream can be a vector of length \p vlen, and for
- * each vector, each item is converted using the above
- * function. So above, m is from 0 to noutput_items*vlen for each
- * call to work.
+ * \param vlen vector len (default 1)
*/
- class BLOCKS_API complex_to_mag : virtual public sync_block
- {
- public:
- // gr::blocks::complex_to_mag_ff::sptr
- typedef boost::shared_ptr<complex_to_mag> sptr;
-
- /*!
- * Build a complex to magnitude block.
- *
- * \param vlen vector len (default 1)
- */
- static sptr make(size_t vlen=1);
- };
+ static sptr make(size_t vlen = 1);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_BLOCKS_COMPLEX_TO_MAG_H */
diff --git a/gr-blocks/include/gnuradio/blocks/complex_to_mag_squared.h b/gr-blocks/include/gnuradio/blocks/complex_to_mag_squared.h
index 2165a5c521..67dd37eb70 100644
--- a/gr-blocks/include/gnuradio/blocks/complex_to_mag_squared.h
+++ b/gr-blocks/include/gnuradio/blocks/complex_to_mag_squared.h
@@ -27,40 +27,40 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief complex in, magnitude squared out (float)
+ * \ingroup type_converters_blk
+ *
+ * \details
+ * Calculates the magnitude squared of the complex samples:
+ *
+ * \li output[0][m] = |input[0][m]|^2
+ *
+ * Or:
+ * \li output[0][m] = Re{input[0][m]}^2 + Im{input[0][m]}^2
+ *
+ * The input stream can be a vector of length \p vlen, and for
+ * each vector, each item is converted using the above
+ * function. So above, m is from 0 to noutput_items*vlen for each
+ * call to work.
+ */
+class BLOCKS_API complex_to_mag_squared : virtual public sync_block
+{
+public:
+ // gr::blocks::complex_to_mag_squared_ff::sptr
+ typedef boost::shared_ptr<complex_to_mag_squared> sptr;
/*!
- * \brief complex in, magnitude squared out (float)
- * \ingroup type_converters_blk
- *
- * \details
- * Calculates the magnitude squared of the complex samples:
- *
- * \li output[0][m] = |input[0][m]|^2
+ * Build a complex to magnitude squared block.
*
- * Or:
- * \li output[0][m] = Re{input[0][m]}^2 + Im{input[0][m]}^2
- *
- * The input stream can be a vector of length \p vlen, and for
- * each vector, each item is converted using the above
- * function. So above, m is from 0 to noutput_items*vlen for each
- * call to work.
+ * \param vlen vector len (default 1)
*/
- class BLOCKS_API complex_to_mag_squared : virtual public sync_block
- {
- public:
- // gr::blocks::complex_to_mag_squared_ff::sptr
- typedef boost::shared_ptr<complex_to_mag_squared> sptr;
-
- /*!
- * Build a complex to magnitude squared block.
- *
- * \param vlen vector len (default 1)
- */
- static sptr make(size_t vlen=1);
- };
+ static sptr make(size_t vlen = 1);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_BLOCKS_COMPLEX_TO_MAG_SQUARED_H */
diff --git a/gr-blocks/include/gnuradio/blocks/complex_to_magphase.h b/gr-blocks/include/gnuradio/blocks/complex_to_magphase.h
index 6e0dfef27e..9ba96098ad 100644
--- a/gr-blocks/include/gnuradio/blocks/complex_to_magphase.h
+++ b/gr-blocks/include/gnuradio/blocks/complex_to_magphase.h
@@ -27,31 +27,31 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief Convert a stream of gr_complex to magnitude and phase (both floats)
+ * \ingroup type_converters_blk
+ *
+ * \details
+ * output[0] is the magnitude
+ * output[1] is the phase (in radians)
+ */
+class BLOCKS_API complex_to_magphase : virtual public sync_block
+{
+public:
+ // gr::blocks::complex_to_magphase_ff::sptr
+ typedef boost::shared_ptr<complex_to_magphase> sptr;
/*!
- * \brief Convert a stream of gr_complex to magnitude and phase (both floats)
- * \ingroup type_converters_blk
+ * Build a complex to magnitude and phase block.
*
- * \details
- * output[0] is the magnitude
- * output[1] is the phase (in radians)
+ * \param vlen vector len (default 1)
*/
- class BLOCKS_API complex_to_magphase : virtual public sync_block
- {
- public:
- // gr::blocks::complex_to_magphase_ff::sptr
- typedef boost::shared_ptr<complex_to_magphase> sptr;
-
- /*!
- * Build a complex to magnitude and phase block.
- *
- * \param vlen vector len (default 1)
- */
- static sptr make(size_t vlen=1);
- };
+ static sptr make(size_t vlen = 1);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_BLOCKS_COMPLEX_TO_MAGPHASE_H */
diff --git a/gr-blocks/include/gnuradio/blocks/complex_to_real.h b/gr-blocks/include/gnuradio/blocks/complex_to_real.h
index 2b8bcbe2a7..580c3039de 100644
--- a/gr-blocks/include/gnuradio/blocks/complex_to_real.h
+++ b/gr-blocks/include/gnuradio/blocks/complex_to_real.h
@@ -27,27 +27,27 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief Produces the real part (as a float0 of a complex stream.
+ * \ingroup type_converters_blk
+ */
+class BLOCKS_API complex_to_real : virtual public sync_block
+{
+public:
+ // gr::blocks::complex_to_real_ff::sptr
+ typedef boost::shared_ptr<complex_to_real> sptr;
/*!
- * \brief Produces the real part (as a float0 of a complex stream.
- * \ingroup type_converters_blk
+ * Build a complex to real part block.
+ *
+ * \param vlen vector len (default 1)
*/
- class BLOCKS_API complex_to_real : virtual public sync_block
- {
- public:
- // gr::blocks::complex_to_real_ff::sptr
- typedef boost::shared_ptr<complex_to_real> sptr;
-
- /*!
- * Build a complex to real part block.
- *
- * \param vlen vector len (default 1)
- */
- static sptr make(size_t vlen=1);
- };
+ static sptr make(size_t vlen = 1);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_BLOCKS_COMPLEX_TO_REAL_H */
diff --git a/gr-blocks/include/gnuradio/blocks/conjugate_cc.h b/gr-blocks/include/gnuradio/blocks/conjugate_cc.h
index 6be3219e70..ae83571afc 100644
--- a/gr-blocks/include/gnuradio/blocks/conjugate_cc.h
+++ b/gr-blocks/include/gnuradio/blocks/conjugate_cc.h
@@ -27,23 +27,22 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- /*!
- * \brief output = complex conjugate of input
- * \ingroup math_operators_blk
- */
- class BLOCKS_API conjugate_cc : virtual public sync_block
- {
- public:
-
- // gr::blocks::conjugate_cc_ff::sptr
- typedef boost::shared_ptr<conjugate_cc> sptr;
+/*!
+ * \brief output = complex conjugate of input
+ * \ingroup math_operators_blk
+ */
+class BLOCKS_API conjugate_cc : virtual public sync_block
+{
+public:
+ // gr::blocks::conjugate_cc_ff::sptr
+ typedef boost::shared_ptr<conjugate_cc> sptr;
- static sptr make();
- };
+ static sptr make();
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_BLOCKS_CONJUGATE_CC_H */
diff --git a/gr-blocks/include/gnuradio/blocks/control_loop.h b/gr-blocks/include/gnuradio/blocks/control_loop.h
index 3826d711fa..e654320fab 100644
--- a/gr-blocks/include/gnuradio/blocks/control_loop.h
+++ b/gr-blocks/include/gnuradio/blocks/control_loop.h
@@ -26,330 +26,321 @@
#include <gnuradio/blocks/api.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- /*!
- * \brief A second-order control loop implementation class.
+/*!
+ * \brief A second-order control loop implementation class.
+ *
+ * \details
+ * This class implements a second order control loop and is
+ * intended to act as a parent class to blocks which need a control
+ * loop (e.g., gr::digital::costas_loop_cc,
+ * gr::analog::pll_refout_cc, etc.). It takes in a loop bandwidth
+ * as well as a max and min frequency and provides the functions
+ * that control the update of the loop.
+ *
+ * The loop works of alpha and beta gains. These gains are
+ * calculated using the input loop bandwidth and a pre-set damping
+ * factor. The damping factor can be changed using the
+ * #set_damping_factor after the block is
+ * constructed. The alpha and beta values can be set using their
+ * respective #set_alpha or #set_beta functions if very precise
+ * control over these is required.
+ *
+ * The class tracks both phase and frequency of a signal based on
+ * an error signal. The error calculation is unique for each
+ * algorithm and is calculated externally and passed to the
+ * advance_loop function, which uses this to update its phase and
+ * frequency estimates.
+ *
+ * This class also provides the functions #phase_wrap and
+ * #frequency_limit to easily keep the phase and frequency
+ * estimates within our set bounds (phase_wrap keeps it within
+ * +/-2pi).
+ */
+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(void) {}
+ 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.
*
* \details
- * This class implements a second order control loop and is
- * intended to act as a parent class to blocks which need a control
- * loop (e.g., gr::digital::costas_loop_cc,
- * gr::analog::pll_refout_cc, etc.). It takes in a loop bandwidth
- * as well as a max and min frequency and provides the functions
- * that control the update of the loop.
- *
- * The loop works of alpha and beta gains. These gains are
- * calculated using the input loop bandwidth and a pre-set damping
- * factor. The damping factor can be changed using the
- * #set_damping_factor after the block is
- * constructed. The alpha and beta values can be set using their
- * respective #set_alpha or #set_beta functions if very precise
- * control over these is required.
- *
- * The class tracks both phase and frequency of a signal based on
- * an error signal. The error calculation is unique for each
- * algorithm and is calculated externally and passed to the
- * advance_loop function, which uses this to update its phase and
- * frequency estimates.
- *
- * This class also provides the functions #phase_wrap and
- * #frequency_limit to easily keep the phase and frequency
- * estimates within our set bounds (phase_wrap keeps it within
- * +/-2pi).
+ * 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.
*/
- 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;
+ void update_gains();
- public:
- control_loop(void) {}
- 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.
- *
- * \details
- * 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.
- *
- * \details
- * 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.
- *
- * \details
- * 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();
+ /*! \brief Advance the control loop based on the current gain
+ * settings and the inputted error signal.
+ */
+ void advance_loop(float error);
- /*******************************************************************
- * SET FUNCTIONS
- *******************************************************************/
+ /*! \brief Keep the phase between -2pi and 2pi.
+ *
+ * \details
+ * 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 Set the loop bandwidth.
- *
- * \details
- * 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
- */
- virtual void set_loop_bandwidth(float bw);
+ /*! \brief Keep the frequency between d_min_freq and d_max_freq.
+ *
+ * \details
+ * 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();
- /*!
- * \brief Set the loop damping factor.
- *
- * \details
- * 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);
+ /*******************************************************************
+ * SET FUNCTIONS
+ *******************************************************************/
- /*!
- * \brief Set the loop gain alpha.
- *
- * \details
- * Sets 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 bandwidth.
+ *
+ * \details
+ * 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
+ */
+ virtual void set_loop_bandwidth(float bw);
- /*!
- * \brief Set the loop gain beta.
- *
- * \details
- * Sets 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 loop damping factor.
+ *
+ * \details
+ * 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 control loop's frequency.
- *
- * \details
- * Sets 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 loop gain alpha.
+ *
+ * \details
+ * Sets 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 control loop's phase.
- *
- * \details
- * Sets 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 loop gain beta.
+ *
+ * \details
+ * Sets 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 maximum frequency.
- *
- * \details
- * 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 frequency.
+ *
+ * \details
+ * Sets 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 minimum frequency.
- *
- * \details
- * Set the minimum frequency the control loop can track.
- *
- * \param freq (float) new min frequency
- */
- void set_min_freq(float freq);
+ /*!
+ * \brief Set the control loop's phase.
+ *
+ * \details
+ * Sets 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);
- /*******************************************************************
- * GET FUNCTIONS
- *******************************************************************/
+ /*!
+ * \brief Set the control loop's maximum frequency.
+ *
+ * \details
+ * Set the maximum frequency the control loop can track.
+ *
+ * \param freq (float) new max frequency
+ */
+ void set_max_freq(float freq);
- /*!
- * \brief Returns the loop bandwidth.
- */
- float get_loop_bandwidth() const;
+ /*!
+ * \brief Set the control loop's minimum frequency.
+ *
+ * \details
+ * Set the minimum frequency the control loop can track.
+ *
+ * \param freq (float) new min frequency
+ */
+ void set_min_freq(float freq);
- /*!
- * \brief Returns the loop damping factor.
- */
- float get_damping_factor() const;
+ /*******************************************************************
+ * GET FUNCTIONS
+ *******************************************************************/
- /*!
- * \brief Returns the loop gain alpha.
- */
- float get_alpha() const;
+ /*!
+ * \brief Returns the loop bandwidth.
+ */
+ float get_loop_bandwidth() const;
- /*!
- * \brief Returns the loop gain beta.
- */
- float get_beta() const;
+ /*!
+ * \brief Returns the loop damping factor.
+ */
+ float get_damping_factor() const;
- /*!
- * \brief Get the control loop's frequency estimate.
- */
- float get_frequency() const;
+ /*!
+ * \brief Returns the loop gain alpha.
+ */
+ float get_alpha() const;
- /*!
- * \brief Get the control loop's phase estimate.
- */
- float get_phase() const;
+ /*!
+ * \brief Returns the loop gain beta.
+ */
+ float get_beta() const;
- /*!
- * \brief Get the control loop's maximum frequency.
- */
- float get_max_freq() const;
+ /*!
+ * \brief Get the control loop's frequency estimate.
+ */
+ float get_frequency() const;
- /*!
- * \brief Get the control loop's minimum frequency.
- */
- float get_min_freq() const;
- };
+ /*!
+ * \brief Get the control loop's phase estimate.
+ */
+ float get_phase() const;
- // This is a table of tanh(x) for x in [-2, 2] used in tanh_lut.
- static float
- tanh_lut_table[256] = { -0.96402758, -0.96290241, -0.96174273, -0.96054753, -0.95931576,
- -0.95804636, -0.95673822, -0.95539023, -0.95400122, -0.95257001,
- -0.95109539, -0.9495761 , -0.94801087, -0.94639839, -0.94473732,
- -0.94302627, -0.94126385, -0.93944862, -0.93757908, -0.93565374,
- -0.93367104, -0.93162941, -0.92952723, -0.92736284, -0.92513456,
- -0.92284066, -0.92047938, -0.91804891, -0.91554743, -0.91297305,
- -0.91032388, -0.90759795, -0.9047933 , -0.90190789, -0.89893968,
- -0.89588656, -0.89274642, -0.88951709, -0.88619637, -0.88278203,
- -0.87927182, -0.87566342, -0.87195453, -0.86814278, -0.86422579,
- -0.86020115, -0.85606642, -0.85181914, -0.84745683, -0.84297699,
- -0.83837709, -0.83365461, -0.82880699, -0.82383167, -0.81872609,
- -0.81348767, -0.80811385, -0.80260204, -0.7969497 , -0.79115425,
- -0.78521317, -0.77912392, -0.772884 , -0.76649093, -0.75994227,
- -0.75323562, -0.74636859, -0.73933889, -0.73214422, -0.7247824 ,
- -0.71725127, -0.70954876, -0.70167287, -0.6936217 , -0.68539341,
- -0.67698629, -0.66839871, -0.65962916, -0.65067625, -0.64153871,
- -0.6322154 , -0.62270534, -0.61300768, -0.60312171, -0.59304692,
- -0.58278295, -0.57232959, -0.56168685, -0.55085493, -0.53983419,
- -0.52862523, -0.51722883, -0.50564601, -0.49387799, -0.48192623,
- -0.46979241, -0.45747844, -0.44498647, -0.4323189 , -0.41947836,
- -0.40646773, -0.39329014, -0.37994896, -0.36644782, -0.35279057,
- -0.33898135, -0.32502449, -0.31092459, -0.2966865 , -0.28231527,
- -0.26781621, -0.25319481, -0.23845682, -0.22360817, -0.208655 ,
- -0.19360362, -0.17846056, -0.16323249, -0.14792623, -0.13254879,
- -0.11710727, -0.10160892, -0.08606109, -0.07047123, -0.05484686,
- -0.0391956 , -0.02352507, -0.00784298, 0.00784298, 0.02352507,
- 0.0391956 , 0.05484686, 0.07047123, 0.08606109, 0.10160892,
- 0.11710727, 0.13254879, 0.14792623, 0.16323249, 0.17846056,
- 0.19360362, 0.208655 , 0.22360817, 0.23845682, 0.25319481,
- 0.26781621, 0.28231527, 0.2966865 , 0.31092459, 0.32502449,
- 0.33898135, 0.35279057, 0.36644782, 0.37994896, 0.39329014,
- 0.40646773, 0.41947836, 0.4323189 , 0.44498647, 0.45747844,
- 0.46979241, 0.48192623, 0.49387799, 0.50564601, 0.51722883,
- 0.52862523, 0.53983419, 0.55085493, 0.56168685, 0.57232959,
- 0.58278295, 0.59304692, 0.60312171, 0.61300768, 0.62270534,
- 0.6322154 , 0.64153871, 0.65067625, 0.65962916, 0.66839871,
- 0.67698629, 0.68539341, 0.6936217 , 0.70167287, 0.70954876,
- 0.71725127, 0.7247824 , 0.73214422, 0.73933889, 0.74636859,
- 0.75323562, 0.75994227, 0.76649093, 0.772884 , 0.77912392,
- 0.78521317, 0.79115425, 0.7969497 , 0.80260204, 0.80811385,
- 0.81348767, 0.81872609, 0.82383167, 0.82880699, 0.83365461,
- 0.83837709, 0.84297699, 0.84745683, 0.85181914, 0.85606642,
- 0.86020115, 0.86422579, 0.86814278, 0.87195453, 0.87566342,
- 0.87927182, 0.88278203, 0.88619637, 0.88951709, 0.89274642,
- 0.89588656, 0.89893968, 0.90190789, 0.9047933 , 0.90759795,
- 0.91032388, 0.91297305, 0.91554743, 0.91804891, 0.92047938,
- 0.92284066, 0.92513456, 0.92736284, 0.92952723, 0.93162941,
- 0.93367104, 0.93565374, 0.93757908, 0.93944862, 0.94126385,
- 0.94302627, 0.94473732, 0.94639839, 0.94801087, 0.9495761 ,
- 0.95109539, 0.95257001, 0.95400122, 0.95539023, 0.95673822,
- 0.95804636, 0.95931576, 0.96054753, 0.96174273, 0.96290241,
- 0.96402758 };
+ /*!
+ * \brief Get the control loop's maximum frequency.
+ */
+ float get_max_freq() const;
/*!
- * A look-up table (LUT) tanh calcuation. This function returns an
- * estimate to tanh(x) based on a 256-point LUT between -2 and
- * 2. If x < -2, it returns -1; if > 2, it returns 1.
- *
- * This LUT form of the tanh is "hidden" in this code because it
- * is likely too coarse an estimate for any real uses of a
- * tanh. It is useful, however, in certain control loop
- * applications where the input is expected to be within these
- * bounds and the noise will be greater than the quanitzation of
- * this small LUT. For more accurate forms of tanh, see
- * volk_32f_tanh_32f.
+ * \brief Get the control loop's minimum frequency.
*/
- static inline float
- tanhf_lut(float x)
- {
- if(x > 2)
+ float get_min_freq() const;
+};
+
+// This is a table of tanh(x) for x in [-2, 2] used in tanh_lut.
+static float tanh_lut_table[256] = {
+ -0.96402758, -0.96290241, -0.96174273, -0.96054753, -0.95931576, -0.95804636,
+ -0.95673822, -0.95539023, -0.95400122, -0.95257001, -0.95109539, -0.9495761,
+ -0.94801087, -0.94639839, -0.94473732, -0.94302627, -0.94126385, -0.93944862,
+ -0.93757908, -0.93565374, -0.93367104, -0.93162941, -0.92952723, -0.92736284,
+ -0.92513456, -0.92284066, -0.92047938, -0.91804891, -0.91554743, -0.91297305,
+ -0.91032388, -0.90759795, -0.9047933, -0.90190789, -0.89893968, -0.89588656,
+ -0.89274642, -0.88951709, -0.88619637, -0.88278203, -0.87927182, -0.87566342,
+ -0.87195453, -0.86814278, -0.86422579, -0.86020115, -0.85606642, -0.85181914,
+ -0.84745683, -0.84297699, -0.83837709, -0.83365461, -0.82880699, -0.82383167,
+ -0.81872609, -0.81348767, -0.80811385, -0.80260204, -0.7969497, -0.79115425,
+ -0.78521317, -0.77912392, -0.772884, -0.76649093, -0.75994227, -0.75323562,
+ -0.74636859, -0.73933889, -0.73214422, -0.7247824, -0.71725127, -0.70954876,
+ -0.70167287, -0.6936217, -0.68539341, -0.67698629, -0.66839871, -0.65962916,
+ -0.65067625, -0.64153871, -0.6322154, -0.62270534, -0.61300768, -0.60312171,
+ -0.59304692, -0.58278295, -0.57232959, -0.56168685, -0.55085493, -0.53983419,
+ -0.52862523, -0.51722883, -0.50564601, -0.49387799, -0.48192623, -0.46979241,
+ -0.45747844, -0.44498647, -0.4323189, -0.41947836, -0.40646773, -0.39329014,
+ -0.37994896, -0.36644782, -0.35279057, -0.33898135, -0.32502449, -0.31092459,
+ -0.2966865, -0.28231527, -0.26781621, -0.25319481, -0.23845682, -0.22360817,
+ -0.208655, -0.19360362, -0.17846056, -0.16323249, -0.14792623, -0.13254879,
+ -0.11710727, -0.10160892, -0.08606109, -0.07047123, -0.05484686, -0.0391956,
+ -0.02352507, -0.00784298, 0.00784298, 0.02352507, 0.0391956, 0.05484686,
+ 0.07047123, 0.08606109, 0.10160892, 0.11710727, 0.13254879, 0.14792623,
+ 0.16323249, 0.17846056, 0.19360362, 0.208655, 0.22360817, 0.23845682,
+ 0.25319481, 0.26781621, 0.28231527, 0.2966865, 0.31092459, 0.32502449,
+ 0.33898135, 0.35279057, 0.36644782, 0.37994896, 0.39329014, 0.40646773,
+ 0.41947836, 0.4323189, 0.44498647, 0.45747844, 0.46979241, 0.48192623,
+ 0.49387799, 0.50564601, 0.51722883, 0.52862523, 0.53983419, 0.55085493,
+ 0.56168685, 0.57232959, 0.58278295, 0.59304692, 0.60312171, 0.61300768,
+ 0.62270534, 0.6322154, 0.64153871, 0.65067625, 0.65962916, 0.66839871,
+ 0.67698629, 0.68539341, 0.6936217, 0.70167287, 0.70954876, 0.71725127,
+ 0.7247824, 0.73214422, 0.73933889, 0.74636859, 0.75323562, 0.75994227,
+ 0.76649093, 0.772884, 0.77912392, 0.78521317, 0.79115425, 0.7969497,
+ 0.80260204, 0.80811385, 0.81348767, 0.81872609, 0.82383167, 0.82880699,
+ 0.83365461, 0.83837709, 0.84297699, 0.84745683, 0.85181914, 0.85606642,
+ 0.86020115, 0.86422579, 0.86814278, 0.87195453, 0.87566342, 0.87927182,
+ 0.88278203, 0.88619637, 0.88951709, 0.89274642, 0.89588656, 0.89893968,
+ 0.90190789, 0.9047933, 0.90759795, 0.91032388, 0.91297305, 0.91554743,
+ 0.91804891, 0.92047938, 0.92284066, 0.92513456, 0.92736284, 0.92952723,
+ 0.93162941, 0.93367104, 0.93565374, 0.93757908, 0.93944862, 0.94126385,
+ 0.94302627, 0.94473732, 0.94639839, 0.94801087, 0.9495761, 0.95109539,
+ 0.95257001, 0.95400122, 0.95539023, 0.95673822, 0.95804636, 0.95931576,
+ 0.96054753, 0.96174273, 0.96290241, 0.96402758
+};
+
+/*!
+ * A look-up table (LUT) tanh calcuation. This function returns an
+ * estimate to tanh(x) based on a 256-point LUT between -2 and
+ * 2. If x < -2, it returns -1; if > 2, it returns 1.
+ *
+ * This LUT form of the tanh is "hidden" in this code because it
+ * is likely too coarse an estimate for any real uses of a
+ * tanh. It is useful, however, in certain control loop
+ * applications where the input is expected to be within these
+ * bounds and the noise will be greater than the quanitzation of
+ * this small LUT. For more accurate forms of tanh, see
+ * volk_32f_tanh_32f.
+ */
+static inline float tanhf_lut(float x)
+{
+ if (x > 2)
return 1;
- else if(x <= -2)
+ else if (x <= -2)
return -1;
- else {
- int index = 128 + 64*x;
+ else {
+ int index = 128 + 64 * x;
return tanh_lut_table[index];
- }
}
+}
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* GR_BLOCKS_CONTROL_LOOP */
diff --git a/gr-blocks/include/gnuradio/blocks/copy.h b/gr-blocks/include/gnuradio/blocks/copy.h
index a953b413af..8305485a13 100644
--- a/gr-blocks/include/gnuradio/blocks/copy.h
+++ b/gr-blocks/include/gnuradio/blocks/copy.h
@@ -27,35 +27,35 @@
#include <gnuradio/block.h>
namespace gr {
- namespace blocks {
-
- /*!
- * \brief output[i] = input[i]
- * \ingroup misc_blk
- *
- * \details
- * When enabled (default), this block copies its input to its
- * output. When disabled, this block drops its input on the floor.
- *
- * Message Ports:
- *
- * - en (input):
- * Receives a PMT bool message to either enable to disable
- * copy.
- */
- class BLOCKS_API copy : virtual public 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 blocks {
+
+/*!
+ * \brief output[i] = input[i]
+ * \ingroup misc_blk
+ *
+ * \details
+ * When enabled (default), this block copies its input to its
+ * output. When disabled, this block drops its input on the floor.
+ *
+ * Message Ports:
+ *
+ * - en (input):
+ * Receives a PMT bool message to either enable to disable
+ * copy.
+ */
+class BLOCKS_API copy : virtual public 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/gnuradio/blocks/count_bits.h b/gr-blocks/include/gnuradio/blocks/count_bits.h
index 80b58041bd..264b6ed363 100644
--- a/gr-blocks/include/gnuradio/blocks/count_bits.h
+++ b/gr-blocks/include/gnuradio/blocks/count_bits.h
@@ -26,21 +26,21 @@
#include <gnuradio/blocks/api.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- //! return number of set bits in the low 8 bits of x
- BLOCKS_API unsigned int count_bits8(unsigned int x);
+//! return number of set bits in the low 8 bits of x
+BLOCKS_API unsigned int count_bits8(unsigned int x);
- //! return number of set bits in the low 16 bits of x
- BLOCKS_API unsigned int count_bits16(unsigned int x);
+//! return number of set bits in the low 16 bits of x
+BLOCKS_API unsigned int count_bits16(unsigned int x);
- //! return number of set bits in the low 32 bits of x
- BLOCKS_API unsigned int count_bits32(unsigned int x);
+//! return number of set bits in the low 32 bits of x
+BLOCKS_API unsigned int count_bits32(unsigned int x);
- //! return number of set bits in a 64-bit word
- BLOCKS_API unsigned int count_bits64(unsigned long long int x);
+//! return number of set bits in a 64-bit word
+BLOCKS_API unsigned int count_bits64(unsigned long long int x);
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* _GR_COUNT_BITS_H_ */
diff --git a/gr-blocks/include/gnuradio/blocks/ctrlport_probe2_b.h b/gr-blocks/include/gnuradio/blocks/ctrlport_probe2_b.h
index 5ad31655cf..a5db817f29 100644
--- a/gr-blocks/include/gnuradio/blocks/ctrlport_probe2_b.h
+++ b/gr-blocks/include/gnuradio/blocks/ctrlport_probe2_b.h
@@ -27,43 +27,42 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief A ControlPort probe to export vectors of signals.
+ * \ingroup measurement_tools_blk
+ * \ingroup controlport_blk
+ *
+ * \details
+ * This block acts as a sink in the flowgraph but also exports
+ * vectors of complex samples over ControlPort. This block holds
+ * the latest \p len number of complex samples so that every query
+ * by a ControlPort client will get the same length vector.
+ */
+class BLOCKS_API ctrlport_probe2_b : virtual public sync_block
+{
+public:
+ // gr::blocks::ctrlport_probe2_b::sptr
+ typedef boost::shared_ptr<ctrlport_probe2_b> sptr;
/*!
- * \brief A ControlPort probe to export vectors of signals.
- * \ingroup measurement_tools_blk
- * \ingroup controlport_blk
- *
- * \details
- * This block acts as a sink in the flowgraph but also exports
- * vectors of complex samples over ControlPort. This block holds
- * the latest \p len number of complex samples so that every query
- * by a ControlPort client will get the same length vector.
+ * \brief Make a ControlPort probe block.
+ * \param id A string ID to name the probe over ControlPort.
+ * \param desc A string describing the probe.
+ * \param len Number of samples to transmit.
+ * \param disp_mask Mask to set default display params.
*/
- class BLOCKS_API ctrlport_probe2_b : virtual public sync_block
- {
- public:
- // gr::blocks::ctrlport_probe2_b::sptr
- typedef boost::shared_ptr<ctrlport_probe2_b> sptr;
+ static sptr
+ make(const std::string& id, const std::string& desc, int len, unsigned int disp_mask);
- /*!
- * \brief Make a ControlPort probe block.
- * \param id A string ID to name the probe over ControlPort.
- * \param desc A string describing the probe.
- * \param len Number of samples to transmit.
- * \param disp_mask Mask to set default display params.
- */
- static sptr make(const std::string &id, const std::string &desc,
- int len, unsigned int disp_mask);
+ virtual std::vector<signed char> get() = 0;
- virtual std::vector<signed char> get() = 0;
+ virtual void set_length(int len) = 0;
+ virtual int length() const = 0;
+};
- virtual void set_length(int len) = 0;
- virtual int length() const = 0;
- };
-
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_CTRLPORT_PROBE2_B_H */
-
diff --git a/gr-blocks/include/gnuradio/blocks/ctrlport_probe2_c.h b/gr-blocks/include/gnuradio/blocks/ctrlport_probe2_c.h
index 51d908b47a..89c5a60437 100644
--- a/gr-blocks/include/gnuradio/blocks/ctrlport_probe2_c.h
+++ b/gr-blocks/include/gnuradio/blocks/ctrlport_probe2_c.h
@@ -27,43 +27,42 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief A ControlPort probe to export vectors of signals.
+ * \ingroup measurement_tools_blk
+ * \ingroup controlport_blk
+ *
+ * \details
+ * This block acts as a sink in the flowgraph but also exports
+ * vectors of complex samples over ControlPort. This block holds
+ * the latest \p len number of complex samples so that every query
+ * by a ControlPort client will get the same length vector.
+ */
+class BLOCKS_API ctrlport_probe2_c : virtual public sync_block
+{
+public:
+ // gr::blocks::ctrlport_probe2_c::sptr
+ typedef boost::shared_ptr<ctrlport_probe2_c> sptr;
/*!
- * \brief A ControlPort probe to export vectors of signals.
- * \ingroup measurement_tools_blk
- * \ingroup controlport_blk
- *
- * \details
- * This block acts as a sink in the flowgraph but also exports
- * vectors of complex samples over ControlPort. This block holds
- * the latest \p len number of complex samples so that every query
- * by a ControlPort client will get the same length vector.
+ * \brief Make a ControlPort probe block.
+ * \param id A string ID to name the probe over ControlPort.
+ * \param desc A string describing the probe.
+ * \param len Number of samples to transmit.
+ * \param disp_mask Mask to set default display params.
*/
- class BLOCKS_API ctrlport_probe2_c : virtual public sync_block
- {
- public:
- // gr::blocks::ctrlport_probe2_c::sptr
- typedef boost::shared_ptr<ctrlport_probe2_c> sptr;
+ static sptr
+ make(const std::string& id, const std::string& desc, int len, unsigned int disp_mask);
- /*!
- * \brief Make a ControlPort probe block.
- * \param id A string ID to name the probe over ControlPort.
- * \param desc A string describing the probe.
- * \param len Number of samples to transmit.
- * \param disp_mask Mask to set default display params.
- */
- static sptr make(const std::string &id, const std::string &desc,
- int len, unsigned int disp_mask);
+ virtual std::vector<gr_complex> get() = 0;
- virtual std::vector<gr_complex> get() = 0;
+ virtual void set_length(int len) = 0;
+ virtual int length() const = 0;
+};
- virtual void set_length(int len) = 0;
- virtual int length() const = 0;
- };
-
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_CTRLPORT_PROBE2_C_H */
-
diff --git a/gr-blocks/include/gnuradio/blocks/ctrlport_probe2_f.h b/gr-blocks/include/gnuradio/blocks/ctrlport_probe2_f.h
index 38d1906ed0..930853af50 100644
--- a/gr-blocks/include/gnuradio/blocks/ctrlport_probe2_f.h
+++ b/gr-blocks/include/gnuradio/blocks/ctrlport_probe2_f.h
@@ -27,43 +27,42 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief A ControlPort probe to export vectors of signals.
+ * \ingroup measurement_tools_blk
+ * \ingroup controlport_blk
+ *
+ * \details
+ * This block acts as a sink in the flowgraph but also exports
+ * vectors of complex samples over ControlPort. This block holds
+ * the latest \p len number of complex samples so that every query
+ * by a ControlPort client will get the same length vector.
+ */
+class BLOCKS_API ctrlport_probe2_f : virtual public sync_block
+{
+public:
+ // gr::blocks::ctrlport_probe2_f::sptr
+ typedef boost::shared_ptr<ctrlport_probe2_f> sptr;
/*!
- * \brief A ControlPort probe to export vectors of signals.
- * \ingroup measurement_tools_blk
- * \ingroup controlport_blk
- *
- * \details
- * This block acts as a sink in the flowgraph but also exports
- * vectors of complex samples over ControlPort. This block holds
- * the latest \p len number of complex samples so that every query
- * by a ControlPort client will get the same length vector.
+ * \brief Make a ControlPort probe block.
+ * \param id A string ID to name the probe over ControlPort.
+ * \param desc A string describing the probe.
+ * \param len Number of samples to transmit.
+ * \param disp_mask Mask to set default display params.
*/
- class BLOCKS_API ctrlport_probe2_f : virtual public sync_block
- {
- public:
- // gr::blocks::ctrlport_probe2_f::sptr
- typedef boost::shared_ptr<ctrlport_probe2_f> sptr;
+ static sptr
+ make(const std::string& id, const std::string& desc, int len, unsigned int disp_mask);
- /*!
- * \brief Make a ControlPort probe block.
- * \param id A string ID to name the probe over ControlPort.
- * \param desc A string describing the probe.
- * \param len Number of samples to transmit.
- * \param disp_mask Mask to set default display params.
- */
- static sptr make(const std::string &id, const std::string &desc,
- int len, unsigned int disp_mask);
+ virtual std::vector<float> get() = 0;
- virtual std::vector<float> get() = 0;
+ virtual void set_length(int len) = 0;
+ virtual int length() const = 0;
+};
- virtual void set_length(int len) = 0;
- virtual int length() const = 0;
- };
-
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_CTRLPORT_PROBE2_F_H */
-
diff --git a/gr-blocks/include/gnuradio/blocks/ctrlport_probe2_i.h b/gr-blocks/include/gnuradio/blocks/ctrlport_probe2_i.h
index cdfb1b86a4..7f07e03452 100644
--- a/gr-blocks/include/gnuradio/blocks/ctrlport_probe2_i.h
+++ b/gr-blocks/include/gnuradio/blocks/ctrlport_probe2_i.h
@@ -27,43 +27,42 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief A ControlPort probe to export vectors of signals.
+ * \ingroup measurement_tools_blk
+ * \ingroup controlport_blk
+ *
+ * \details
+ * This block acts as a sink in the flowgraph but also exports
+ * vectors of complex samples over ControlPort. This block holds
+ * the latest \p len number of complex samples so that every query
+ * by a ControlPort client will get the same length vector.
+ */
+class BLOCKS_API ctrlport_probe2_i : virtual public sync_block
+{
+public:
+ // gr::blocks::ctrlport_probe2_i::sptr
+ typedef boost::shared_ptr<ctrlport_probe2_i> sptr;
/*!
- * \brief A ControlPort probe to export vectors of signals.
- * \ingroup measurement_tools_blk
- * \ingroup controlport_blk
- *
- * \details
- * This block acts as a sink in the flowgraph but also exports
- * vectors of complex samples over ControlPort. This block holds
- * the latest \p len number of complex samples so that every query
- * by a ControlPort client will get the same length vector.
+ * \brief Make a ControlPort probe block.
+ * \param id A string ID to name the probe over ControlPort.
+ * \param desc A string describing the probe.
+ * \param len Number of samples to transmit.
+ * \param disp_mask Mask to set default display params.
*/
- class BLOCKS_API ctrlport_probe2_i : virtual public sync_block
- {
- public:
- // gr::blocks::ctrlport_probe2_i::sptr
- typedef boost::shared_ptr<ctrlport_probe2_i> sptr;
+ static sptr
+ make(const std::string& id, const std::string& desc, int len, unsigned int disp_mask);
- /*!
- * \brief Make a ControlPort probe block.
- * \param id A string ID to name the probe over ControlPort.
- * \param desc A string describing the probe.
- * \param len Number of samples to transmit.
- * \param disp_mask Mask to set default display params.
- */
- static sptr make(const std::string &id, const std::string &desc,
- int len, unsigned int disp_mask);
+ virtual std::vector<int> get() = 0;
- virtual std::vector<int> get() = 0;
+ virtual void set_length(int len) = 0;
+ virtual int length() const = 0;
+};
- virtual void set_length(int len) = 0;
- virtual int length() const = 0;
- };
-
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_CTRLPORT_PROBE2_I_H */
-
diff --git a/gr-blocks/include/gnuradio/blocks/ctrlport_probe2_s.h b/gr-blocks/include/gnuradio/blocks/ctrlport_probe2_s.h
index 676a24822a..b382e46af8 100644
--- a/gr-blocks/include/gnuradio/blocks/ctrlport_probe2_s.h
+++ b/gr-blocks/include/gnuradio/blocks/ctrlport_probe2_s.h
@@ -27,43 +27,42 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief A ControlPort probe to export vectors of signals.
+ * \ingroup measurement_tools_blk
+ * \ingroup controlport_blk
+ *
+ * \details
+ * This block acts as a sink in the flowgraph but also exports
+ * vectors of complex samples over ControlPort. This block holds
+ * the latest \p len number of complex samples so that every query
+ * by a ControlPort client will get the same length vector.
+ */
+class BLOCKS_API ctrlport_probe2_s : virtual public sync_block
+{
+public:
+ // gr::blocks::ctrlport_probe2_s::sptr
+ typedef boost::shared_ptr<ctrlport_probe2_s> sptr;
/*!
- * \brief A ControlPort probe to export vectors of signals.
- * \ingroup measurement_tools_blk
- * \ingroup controlport_blk
- *
- * \details
- * This block acts as a sink in the flowgraph but also exports
- * vectors of complex samples over ControlPort. This block holds
- * the latest \p len number of complex samples so that every query
- * by a ControlPort client will get the same length vector.
+ * \brief Make a ControlPort probe block.
+ * \param id A string ID to name the probe over ControlPort.
+ * \param desc A string describing the probe.
+ * \param len Number of samples to transmit.
+ * \param disp_mask Mask to set default display params.
*/
- class BLOCKS_API ctrlport_probe2_s : virtual public sync_block
- {
- public:
- // gr::blocks::ctrlport_probe2_s::sptr
- typedef boost::shared_ptr<ctrlport_probe2_s> sptr;
+ static sptr
+ make(const std::string& id, const std::string& desc, int len, unsigned int disp_mask);
- /*!
- * \brief Make a ControlPort probe block.
- * \param id A string ID to name the probe over ControlPort.
- * \param desc A string describing the probe.
- * \param len Number of samples to transmit.
- * \param disp_mask Mask to set default display params.
- */
- static sptr make(const std::string &id, const std::string &desc,
- int len, unsigned int disp_mask);
+ virtual std::vector<short> get() = 0;
- virtual std::vector<short> get() = 0;
+ virtual void set_length(int len) = 0;
+ virtual int length() const = 0;
+};
- virtual void set_length(int len) = 0;
- virtual int length() const = 0;
- };
-
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_CTRLPORT_PROBE2_S_H */
-
diff --git a/gr-blocks/include/gnuradio/blocks/ctrlport_probe_c.h b/gr-blocks/include/gnuradio/blocks/ctrlport_probe_c.h
index 2b9bd12788..40ef05ed82 100644
--- a/gr-blocks/include/gnuradio/blocks/ctrlport_probe_c.h
+++ b/gr-blocks/include/gnuradio/blocks/ctrlport_probe_c.h
@@ -29,37 +29,36 @@
#include <boost/thread/shared_mutex.hpp>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief A ControlPort probe to export vectors of signals.
+ * \ingroup measurement_tools_blk
+ * \ingroup controlport_blk
+ *
+ * \details
+ * This block acts as a sink in the flowgraph but also exports
+ * vectors of complex samples over ControlPort. This block simply
+ * sends the current vector held in the work function when the
+ * queried by a ControlPort client.
+ */
+class BLOCKS_API ctrlport_probe_c : virtual public sync_block
+{
+public:
+ // gr::blocks::ctrlport_probe_c::sptr
+ typedef boost::shared_ptr<ctrlport_probe_c> sptr;
/*!
- * \brief A ControlPort probe to export vectors of signals.
- * \ingroup measurement_tools_blk
- * \ingroup controlport_blk
- *
- * \details
- * This block acts as a sink in the flowgraph but also exports
- * vectors of complex samples over ControlPort. This block simply
- * sends the current vector held in the work function when the
- * queried by a ControlPort client.
+ * \brief Make a ControlPort probe block.
+ * \param id A string ID to name the probe over ControlPort.
+ * \param desc A string describing the probe.
*/
- class BLOCKS_API ctrlport_probe_c : virtual public sync_block
- {
- public:
- // gr::blocks::ctrlport_probe_c::sptr
- typedef boost::shared_ptr<ctrlport_probe_c> sptr;
+ static sptr make(const std::string& id, const std::string& desc);
- /*!
- * \brief Make a ControlPort probe block.
- * \param id A string ID to name the probe over ControlPort.
- * \param desc A string describing the probe.
- */
- static sptr make(const std::string &id, const std::string &desc);
+ virtual std::vector<gr_complex> get() = 0;
+};
- virtual std::vector<gr_complex> get() = 0;
- };
-
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_CTRLPORT_GR_CTRLPORT_PROBE_C_H */
-
diff --git a/gr-blocks/include/gnuradio/blocks/deinterleave.h b/gr-blocks/include/gnuradio/blocks/deinterleave.h
index a3b5480089..1589ebae16 100644
--- a/gr-blocks/include/gnuradio/blocks/deinterleave.h
+++ b/gr-blocks/include/gnuradio/blocks/deinterleave.h
@@ -27,51 +27,51 @@
#include <gnuradio/block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief deinterleave an input block of samples into N outputs.
+ * \ingroup stream_operators_blk
+ *
+ * \details
+ * This block deinterleaves blocks of samples. For each output
+ * connection, the input stream will be deinterleaved successively
+ * to the output connections. By default, the block deinterleaves
+ * a single input to each output unless blocksize is given in the
+ * constructor.
+ *
+ * \code
+ * blocksize = 1
+ * connections = 2
+ * input = [a, b, c, d, e, f, g, h]
+ * output[0] = [a, c, e, g]
+ * output[1] = [b, d, f, h]
+ * \endcode
+ *
+ * \code
+ * blocksize = 2
+ * connections = 2
+ * input = [a, b, c, d, e, f, g, h]
+ * output[0] = [a, b, e, f]
+ * output[1] = [c, d, g, h]
+ * \endcode
+ */
+class BLOCKS_API deinterleave : virtual public block
+{
+public:
+ // gr::blocks::deinterleave::sptr
+ typedef boost::shared_ptr<deinterleave> sptr;
/*!
- * \brief deinterleave an input block of samples into N outputs.
- * \ingroup stream_operators_blk
- *
- * \details
- * This block deinterleaves blocks of samples. For each output
- * connection, the input stream will be deinterleaved successively
- * to the output connections. By default, the block deinterleaves
- * a single input to each output unless blocksize is given in the
- * constructor.
+ * Make a deinterleave block.
*
- * \code
- * blocksize = 1
- * connections = 2
- * input = [a, b, c, d, e, f, g, h]
- * output[0] = [a, c, e, g]
- * output[1] = [b, d, f, h]
- * \endcode
- *
- * \code
- * blocksize = 2
- * connections = 2
- * input = [a, b, c, d, e, f, g, h]
- * output[0] = [a, b, e, f]
- * output[1] = [c, d, g, h]
- * \endcode
+ * \param itemsize stream itemsize
+ * \param blocksize size of block to deinterleave
*/
- class BLOCKS_API deinterleave : virtual public block
- {
- public:
- // gr::blocks::deinterleave::sptr
- typedef boost::shared_ptr<deinterleave> sptr;
-
- /*!
- * Make a deinterleave block.
- *
- * \param itemsize stream itemsize
- * \param blocksize size of block to deinterleave
- */
- static sptr make(size_t itemsize, unsigned int blocksize = 1);
- };
+ static sptr make(size_t itemsize, unsigned int blocksize = 1);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_BLOCKS_DEINTERLEAVE_H */
diff --git a/gr-blocks/include/gnuradio/blocks/delay.h b/gr-blocks/include/gnuradio/blocks/delay.h
index 381669b7ed..771212501b 100644
--- a/gr-blocks/include/gnuradio/blocks/delay.h
+++ b/gr-blocks/include/gnuradio/blocks/delay.h
@@ -27,44 +27,44 @@
#include <gnuradio/block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief delay the input by a certain number of samples
+ * \ingroup misc_blk
+ *
+ * Positive delays insert zero items at the beginning of the stream.
+ * Negative delays discard items from the stream.
+ *
+ * You cannot initialize this block with a negative delay,
+ * however. That leads to a causality issue with the buffers when
+ * they are initialized. If you need to negetively delay one path,
+ * then put the positive delay on the other path instead.
+ */
+class BLOCKS_API delay : virtual public block
+{
+public:
+ // gr::blocks::delay::sptr
+ typedef boost::shared_ptr<delay> sptr;
/*!
- * \brief delay the input by a certain number of samples
- * \ingroup misc_blk
- *
- * Positive delays insert zero items at the beginning of the stream.
- * Negative delays discard items from the stream.
- *
- * You cannot initialize this block with a negative delay,
- * however. That leads to a causality issue with the buffers when
- * they are initialized. If you need to negetively delay one path,
- * then put the positive delay on the other path instead.
+ * \brief Make a delay block.
+ * \param itemsize size of the data items.
+ * \param delay number of samples to delay stream (>= 0).
*/
- class BLOCKS_API delay : virtual public block
- {
- public:
- // gr::blocks::delay::sptr
- typedef boost::shared_ptr<delay> sptr;
+ static sptr make(size_t itemsize, int delay);
- /*!
- * \brief Make a delay block.
- * \param itemsize size of the data items.
- * \param delay number of samples to delay stream (>= 0).
- */
- static sptr make(size_t itemsize, int delay);
+ virtual int dly() const = 0;
- virtual int dly() const = 0;
-
- /*!
- * \brief Reset the delay.
- * \param d change the delay value. This can be a positive or
- * negative value.
- */
- virtual void set_dly(int d) = 0;
- };
+ /*!
+ * \brief Reset the delay.
+ * \param d change the delay value. This can be a positive or
+ * negative value.
+ */
+ virtual void set_dly(int d) = 0;
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_BLOCKS_DELAY_H */
diff --git a/gr-blocks/include/gnuradio/blocks/divide.h b/gr-blocks/include/gnuradio/blocks/divide.h
index 0ad62e50b4..d30e1c2cb6 100644
--- a/gr-blocks/include/gnuradio/blocks/divide.h
+++ b/gr-blocks/include/gnuradio/blocks/divide.h
@@ -29,31 +29,30 @@
#include <cstdint>
namespace gr {
- namespace blocks {
-
- /*!
- * \brief output = input[0] / input[1] / ... / input[M-1]
- * \ingroup math_operators_blk
- *
- * \details
- * Divide across all input streams.
- */
-template<class T>
- class BLOCKS_API divide : virtual public sync_block
- {
- public:
-
- // gr::blocks::divide::sptr
- typedef boost::shared_ptr< divide<T> > sptr;
-
- static sptr make(size_t vlen=1);
- };
+namespace blocks {
+
+/*!
+ * \brief output = input[0] / input[1] / ... / input[M-1]
+ * \ingroup math_operators_blk
+ *
+ * \details
+ * Divide across all input streams.
+ */
+template <class T>
+class BLOCKS_API divide : virtual public sync_block
+{
+public:
+ // gr::blocks::divide::sptr
+ typedef boost::shared_ptr<divide<T>> sptr;
+
+ static sptr make(size_t vlen = 1);
+};
typedef divide<std::int16_t> divide_ss;
typedef divide<std::int32_t> divide_ii;
typedef divide<float> divide_ff;
typedef divide<gr_complex> divide_cc;
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* DIVIDE_H */
diff --git a/gr-blocks/include/gnuradio/blocks/endian_swap.h b/gr-blocks/include/gnuradio/blocks/endian_swap.h
index 379ee734c7..91338e718c 100644
--- a/gr-blocks/include/gnuradio/blocks/endian_swap.h
+++ b/gr-blocks/include/gnuradio/blocks/endian_swap.h
@@ -27,28 +27,28 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief Convert stream of items into their byte swapped version
+ * \ingroup stream_operators_blk
+ */
+class BLOCKS_API endian_swap : virtual public sync_block
+{
+public:
+ // gr::blocks::endian_swap::sptr
+ typedef boost::shared_ptr<endian_swap> sptr;
/*!
- * \brief Convert stream of items into their byte swapped version
- * \ingroup stream_operators_blk
+ * Make an endian swap block.
+ *
+ * \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 sync_block
- {
- public:
- // gr::blocks::endian_swap::sptr
- typedef boost::shared_ptr<endian_swap> sptr;
-
- /*!
- * Make an endian swap block.
- *
- * \param item_size_bytes number of bytes per item, 1=no-op,
- * 2=uint16_t, 4=uint32_t, 8=uint64_t
- */
- static sptr make(size_t item_size_bytes=1);
- };
+ static sptr make(size_t item_size_bytes = 1);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_GR_ENDIAN_SWAP_H */
diff --git a/gr-blocks/include/gnuradio/blocks/exponentiate_const_cci.h b/gr-blocks/include/gnuradio/blocks/exponentiate_const_cci.h
index 0d96c645cf..c0a897f394 100644
--- a/gr-blocks/include/gnuradio/blocks/exponentiate_const_cci.h
+++ b/gr-blocks/include/gnuradio/blocks/exponentiate_const_cci.h
@@ -28,39 +28,38 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- /*!
- * \brief Exponentiates a complex stream with an integer exponent
- * \ingroup blocks
- *
- * \details
- * This block raises a complex stream to an integer exponent. The exponent
- * must be at least 1. There is a callback function so the exponent can be
- * changed at runtime.
- *
- * NOTE: The algorithm uses iterative multiplication to achieve exponentiation,
- * hence it is O(exponent). Therefore, this block could be inefficient for large
- * exponents.
- */
- class BLOCKS_API exponentiate_const_cci : virtual public gr::sync_block
- {
- public:
- typedef boost::shared_ptr<exponentiate_const_cci> sptr;
+/*!
+ * \brief Exponentiates a complex stream with an integer exponent
+ * \ingroup blocks
+ *
+ * \details
+ * This block raises a complex stream to an integer exponent. The exponent
+ * must be at least 1. There is a callback function so the exponent can be
+ * changed at runtime.
+ *
+ * NOTE: The algorithm uses iterative multiplication to achieve exponentiation,
+ * hence it is O(exponent). Therefore, this block could be inefficient for large
+ * exponents.
+ */
+class BLOCKS_API exponentiate_const_cci : virtual public gr::sync_block
+{
+public:
+ typedef boost::shared_ptr<exponentiate_const_cci> sptr;
- /*
- * \param exponent Exponent the input stream is raised to, which must be an integer.
- * The algorithm uses iterative multiplication to achieve exponentiation, hence it is
- * O(exponent). Therefore, this block could be inefficient for large exponents.
- * \param vlen Vector length of input/output stream
- */
- static sptr make(int exponent, size_t vlen = 1);
+ /*
+ * \param exponent Exponent the input stream is raised to, which must be an integer.
+ * The algorithm uses iterative multiplication to achieve exponentiation, hence it is
+ * O(exponent). Therefore, this block could be inefficient for large exponents.
+ * \param vlen Vector length of input/output stream
+ */
+ static sptr make(int exponent, size_t vlen = 1);
- virtual void set_exponent(int exponent) = 0;
- };
+ virtual void set_exponent(int exponent) = 0;
+};
- } // namespace blocks
+} // namespace blocks
} // namespace gr
#endif /* INCLUDED_BLOCKS_EXPONENTIATE_CONST_CCI_H */
-
diff --git a/gr-blocks/include/gnuradio/blocks/file_descriptor_sink.h b/gr-blocks/include/gnuradio/blocks/file_descriptor_sink.h
index 6399aec854..2613ef8bf8 100644
--- a/gr-blocks/include/gnuradio/blocks/file_descriptor_sink.h
+++ b/gr-blocks/include/gnuradio/blocks/file_descriptor_sink.h
@@ -27,29 +27,29 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief Write stream to file descriptor.
+ * \ingroup file_operators_blk
+ */
+class BLOCKS_API file_descriptor_sink : virtual public sync_block
+{
+public:
+ // gr::blocks::file_descriptor_sink::sptr
+ typedef boost::shared_ptr<file_descriptor_sink> sptr;
/*!
- * \brief Write stream to file descriptor.
- * \ingroup file_operators_blk
+ * Build a file descriptor sink block. The provided file descriptor will
+ * be closed when the sink is destroyed.
+ *
+ * \param itemsize item size of the incoming data stream.
+ * \param fd file descriptor (as an integer).
*/
- class BLOCKS_API file_descriptor_sink : virtual public sync_block
- {
- public:
- // gr::blocks::file_descriptor_sink::sptr
- typedef boost::shared_ptr<file_descriptor_sink> sptr;
-
- /*!
- * Build a file descriptor sink block. The provided file descriptor will
- * be closed when the sink is destroyed.
- *
- * \param itemsize item size of the incoming data stream.
- * \param fd file descriptor (as an integer).
- */
- static sptr make(size_t itemsize, int fd);
- };
+ static sptr make(size_t itemsize, int fd);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_GR_FILE_DESCRIPTOR_SINK_H */
diff --git a/gr-blocks/include/gnuradio/blocks/file_descriptor_source.h b/gr-blocks/include/gnuradio/blocks/file_descriptor_source.h
index d78b10a84f..12f03bb84d 100644
--- a/gr-blocks/include/gnuradio/blocks/file_descriptor_source.h
+++ b/gr-blocks/include/gnuradio/blocks/file_descriptor_source.h
@@ -28,35 +28,35 @@
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief Read stream from file descriptor.
+ * \ingroup file_operators_blk
+ */
+class BLOCKS_API file_descriptor_source : virtual public 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;
/*!
- * \brief Read stream from file descriptor.
- * \ingroup file_operators_blk
+ * Build a file descriptor source block. The provided file descriptor will
+ * be closed when the sink is destroyed.
+ *
+ * \param itemsize item size of the incoming data stream.
+ * \param fd file descriptor (as an integer).
+ * \param repeat repeat the data stream continuously.
*/
- class BLOCKS_API file_descriptor_source : virtual public 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. The provided file descriptor will
- * be closed when the sink is destroyed.
- *
- * \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=false);
- };
-
- } /* namespace blocks */
+ static sptr make(size_t itemsize, int fd, bool repeat = false);
+};
+
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_GR_FILE_DESCRIPTOR_SOURCE_H */
diff --git a/gr-blocks/include/gnuradio/blocks/file_meta_sink.h b/gr-blocks/include/gnuradio/blocks/file_meta_sink.h
index 36d44b545a..f967ea042c 100644
--- a/gr-blocks/include/gnuradio/blocks/file_meta_sink.h
+++ b/gr-blocks/include/gnuradio/blocks/file_meta_sink.h
@@ -27,89 +27,89 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- const char METADATA_VERSION = 0;
- const size_t METADATA_HEADER_SIZE = 149;
+const char METADATA_VERSION = 0;
+const size_t METADATA_HEADER_SIZE = 149;
- enum gr_file_types {
- GR_FILE_BYTE=0,
- GR_FILE_CHAR=0,
- GR_FILE_SHORT=1,
- GR_FILE_INT,
- GR_FILE_LONG,
- GR_FILE_LONG_LONG,
- GR_FILE_FLOAT,
- GR_FILE_DOUBLE,
- };
+enum gr_file_types {
+ GR_FILE_BYTE = 0,
+ GR_FILE_CHAR = 0,
+ GR_FILE_SHORT = 1,
+ GR_FILE_INT,
+ GR_FILE_LONG,
+ GR_FILE_LONG_LONG,
+ GR_FILE_FLOAT,
+ GR_FILE_DOUBLE,
+};
+
+/*!
+ * \brief Write stream to file with meta-data headers.
+ * \ingroup file_operators_blk
+ *
+ * \details
+ * These files represent data as binary information in between
+ * meta-data headers. The headers contain information about the
+ * type of data and properties of the data in the next segment of
+ * samples. The information includes:
+ *
+ * \li rx_rate (double): sample rate of data.
+ * \li rx_time (uint64_t, double): time stamp of first sample in segment.
+ * \li size (uint32_t): item size in bytes.
+ * \li type (::gr_file_types as int32_t): data type.
+ * \li cplx (bool): Is data complex?
+ * \li strt (uint64_t): Starting byte of data in this segment.
+ * \li bytes (uint64_t): Size in bytes of data in this segment.
+ *
+ * Tags can be sent to the file to update the information, which
+ * will create a new header. Headers are found by searching from
+ * the first header (at position 0 in the file) and reading where
+ * the data segment starts plus the data segment size. Following
+ * will either be a new header or EOF.
+ */
+class BLOCKS_API file_meta_sink : virtual public sync_block
+{
+public:
+ // gr::blocks::file_meta_sink::sptr
+ typedef boost::shared_ptr<file_meta_sink> sptr;
/*!
- * \brief Write stream to file with meta-data headers.
- * \ingroup file_operators_blk
- *
- * \details
- * These files represent data as binary information in between
- * meta-data headers. The headers contain information about the
- * type of data and properties of the data in the next segment of
- * samples. The information includes:
+ * \brief Create a meta-data file sink.
*
- * \li rx_rate (double): sample rate of data.
- * \li rx_time (uint64_t, double): time stamp of first sample in segment.
- * \li size (uint32_t): item size in bytes.
- * \li type (::gr_file_types as int32_t): data type.
- * \li cplx (bool): Is data complex?
- * \li strt (uint64_t): Starting byte of data in this segment.
- * \li bytes (uint64_t): Size in bytes of data in this segment.
- *
- * Tags can be sent to the file to update the information, which
- * will create a new header. Headers are found by searching from
- * the first header (at position 0 in the file) and reading where
- * the data segment starts plus the data segment size. Following
- * will either be a new header or EOF.
+ * \param itemsize (size_t): Size of data type.
+ * \param filename (string): Name of file to write data to.
+ * \param samp_rate (double): Sample rate of data. If sample rate will be
+ * set by a tag, such as rx_tag from a UHD source, this is
+ * basically ignored.
+ * \param relative_rate (double): Rate chance from source of sample
+ * rate tag to sink.
+ * \param type (gr_file_types): Data type (int, float, etc.)
+ * \param complex (bool): If data stream is complex
+ * \param max_segment_size (size_t): Length of a single segment
+ * before the header is repeated (in items).
+ * \param extra_dict: a PMT dictionary of extra
+ * information.
+ * \param detached_header (bool): Set to true to store the header
+ * info in a separate file (named filename.hdr)
*/
- class BLOCKS_API file_meta_sink : virtual public sync_block
- {
- public:
- // gr::blocks::file_meta_sink::sptr
- typedef boost::shared_ptr<file_meta_sink> sptr;
-
- /*!
- * \brief Create a meta-data file sink.
- *
- * \param itemsize (size_t): Size of data type.
- * \param filename (string): Name of file to write data to.
- * \param samp_rate (double): Sample rate of data. If sample rate will be
- * set by a tag, such as rx_tag from a UHD source, this is
- * basically ignored.
- * \param relative_rate (double): Rate chance from source of sample
- * rate tag to sink.
- * \param type (gr_file_types): Data type (int, float, etc.)
- * \param complex (bool): If data stream is complex
- * \param max_segment_size (size_t): Length of a single segment
- * before the header is repeated (in items).
- * \param extra_dict: a PMT dictionary of extra
- * information.
- * \param detached_header (bool): Set to true to store the header
- * info in a separate file (named filename.hdr)
- */
- static sptr make(size_t itemsize,
- const std::string &filename,
- double samp_rate=1,
- double relative_rate=1,
- gr_file_types type=GR_FILE_FLOAT,
- bool complex=true,
- size_t max_segment_size=1000000,
- pmt::pmt_t extra_dict=pmt::make_dict(),
- bool detached_header=false);
+ static sptr make(size_t itemsize,
+ const std::string& filename,
+ double samp_rate = 1,
+ double relative_rate = 1,
+ gr_file_types type = GR_FILE_FLOAT,
+ bool complex = true,
+ size_t max_segment_size = 1000000,
+ pmt::pmt_t extra_dict = pmt::make_dict(),
+ bool detached_header = false);
- virtual bool open(const std::string &filename) = 0;
- virtual void close() = 0;
- virtual void do_update() = 0;
+ virtual bool open(const std::string& filename) = 0;
+ virtual void close() = 0;
+ virtual void do_update() = 0;
- virtual void set_unbuffered(bool unbuffered) = 0;
- };
+ virtual void set_unbuffered(bool unbuffered) = 0;
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_BLOCKS_FILE_META_SINK_H */
diff --git a/gr-blocks/include/gnuradio/blocks/file_meta_source.h b/gr-blocks/include/gnuradio/blocks/file_meta_source.h
index 57bac1eca1..fef90e473d 100644
--- a/gr-blocks/include/gnuradio/blocks/file_meta_source.h
+++ b/gr-blocks/include/gnuradio/blocks/file_meta_source.h
@@ -27,56 +27,56 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief Reads stream from file with meta-data headers. Headers
+ * are parsed into tags.
+ * \ingroup file_operators_blk
+ *
+ * \details
+ * The information in the metadata headers includes:
+ *
+ * \li rx_rate (double): sample rate of data.
+ * \li rx_time (uint64_t, double): time stamp of first sample in segment.
+ * \li size (uint32_t): item size in bytes.
+ * \li type (::gr_file_types as int32_t): data type.
+ * \li cplx (bool): Is data complex?
+ * \li strt (uint64_t): Starting byte of data in this segment.
+ * \li bytes (uint64_t): Size in bytes of data in this segment.
+ *
+ * Any item inside of the extra header dictionary is ready out and
+ * made into a stream tag.
+ */
+class BLOCKS_API file_meta_source : virtual public sync_block
+{
+public:
+ // gr::blocks::file_meta_source::sptr
+ typedef boost::shared_ptr<file_meta_source> sptr;
/*!
- * \brief Reads stream from file with meta-data headers. Headers
- * are parsed into tags.
- * \ingroup file_operators_blk
- *
- * \details
- * The information in the metadata headers includes:
+ * \brief Create a meta-data file source.
*
- * \li rx_rate (double): sample rate of data.
- * \li rx_time (uint64_t, double): time stamp of first sample in segment.
- * \li size (uint32_t): item size in bytes.
- * \li type (::gr_file_types as int32_t): data type.
- * \li cplx (bool): Is data complex?
- * \li strt (uint64_t): Starting byte of data in this segment.
- * \li bytes (uint64_t): Size in bytes of data in this segment.
- *
- * Any item inside of the extra header dictionary is ready out and
- * made into a stream tag.
+ * \param filename (string): Name of file to write data to.
+ * \param repeat (bool): Repeats file when EOF is found.
+ * \param detached_header (bool): Set to true if header
+ * info is stored in a separate file (usually named filename.hdr)
+ * \param hdr_filename (string): Name of detached header file if used.
+ * Defaults to 'filename.hdr' if detached_header is true but this
+ * field is an empty string.
*/
- class BLOCKS_API file_meta_source : virtual public sync_block
- {
- public:
- // gr::blocks::file_meta_source::sptr
- typedef boost::shared_ptr<file_meta_source> sptr;
-
- /*!
- * \brief Create a meta-data file source.
- *
- * \param filename (string): Name of file to write data to.
- * \param repeat (bool): Repeats file when EOF is found.
- * \param detached_header (bool): Set to true if header
- * info is stored in a separate file (usually named filename.hdr)
- * \param hdr_filename (string): Name of detached header file if used.
- * Defaults to 'filename.hdr' if detached_header is true but this
- * field is an empty string.
- */
- static sptr make(const std::string &filename,
- bool repeat=false,
- bool detached_header=false,
- const std::string &hdr_filename="");
+ static sptr make(const std::string& filename,
+ bool repeat = false,
+ bool detached_header = false,
+ const std::string& hdr_filename = "");
- virtual bool open(const std::string &filename,
- const std::string &hdr_filename="") = 0;
- virtual void close() = 0;
- virtual void do_update() = 0;
- };
+ virtual bool open(const std::string& filename,
+ const std::string& hdr_filename = "") = 0;
+ virtual void close() = 0;
+ virtual void do_update() = 0;
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_BLOCKS_FILE_META_SOURCE_H */
diff --git a/gr-blocks/include/gnuradio/blocks/file_sink.h b/gr-blocks/include/gnuradio/blocks/file_sink.h
index 177964682d..43d77213ed 100644
--- a/gr-blocks/include/gnuradio/blocks/file_sink.h
+++ b/gr-blocks/include/gnuradio/blocks/file_sink.h
@@ -28,30 +28,29 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief Write stream to file.
+ * \ingroup file_operators_blk
+ */
+class BLOCKS_API file_sink : virtual public sync_block, virtual public file_sink_base
+{
+public:
+ // gr::blocks::file_sink::sptr
+ typedef boost::shared_ptr<file_sink> sptr;
/*!
- * \brief Write stream to file.
- * \ingroup file_operators_blk
+ * \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.
+ * \param append if true, data is appended to the file instead of
+ * overwriting the initial content.
*/
- class BLOCKS_API file_sink : virtual public 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.
- * \param append if true, data is appended to the file instead of
- * overwriting the initial content.
- */
- static sptr make(size_t itemsize, const char *filename, bool append=false);
- };
+ static sptr make(size_t itemsize, const char* filename, bool append = false);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_GR_FILE_SINK_H */
diff --git a/gr-blocks/include/gnuradio/blocks/file_sink_base.h b/gr-blocks/include/gnuradio/blocks/file_sink_base.h
index 253b5ea122..fa62cb4972 100644
--- a/gr-blocks/include/gnuradio/blocks/file_sink_base.h
+++ b/gr-blocks/include/gnuradio/blocks/file_sink_base.h
@@ -28,54 +28,54 @@
#include <cstdio>
namespace gr {
- namespace blocks {
+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;
- bool d_append;
+/*!
+ * \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;
+ bool d_append;
- protected:
- file_sink_base(const char *filename, bool is_binary, bool append);
+protected:
+ file_sink_base(const char* filename, bool is_binary, bool append);
- public:
- file_sink_base() {}
- ~file_sink_base();
+public:
+ file_sink_base() {}
+ ~file_sink_base();
- /*!
- * \brief Open filename and begin output to it.
- */
- bool open(const char *filename);
+ /*!
+ * \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 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 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);
- };
+ /*!
+ * \brief turn on unbuffered writes for slower outputs
+ */
+ void set_unbuffered(bool unbuffered);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_GR_FILE_SINK_BASE_H */
diff --git a/gr-blocks/include/gnuradio/blocks/file_source.h b/gr-blocks/include/gnuradio/blocks/file_source.h
index bb1ea84a8a..f8ed700e5c 100644
--- a/gr-blocks/include/gnuradio/blocks/file_source.h
+++ b/gr-blocks/include/gnuradio/blocks/file_source.h
@@ -27,73 +27,76 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief Read stream from file
+ * \ingroup file_operators_blk
+ */
+class BLOCKS_API file_source : virtual public sync_block
+{
+public:
+ // gr::blocks::file_source::sptr
+ typedef boost::shared_ptr<file_source> sptr;
/*!
- * \brief Read stream from file
- * \ingroup file_operators_blk
+ * \brief Create a file source.
+ *
+ * Opens \p filename as a source of items into a flowgraph. The
+ * data is expected to be in binary format, item after item. The
+ * \p itemsize of the block determines the conversion from bits
+ * to items. The first \p offset items (default 0) will be
+ * skipped.
+ *
+ * If \p repeat is turned on, the file will repeat the file after
+ * it's reached the end.
+ *
+ * If \p len is non-zero, only items (offset, offset+len) will
+ * be produced.
+ *
+ * \param itemsize the size of each item in the file, in bytes
+ * \param filename name of the file to source from
+ * \param repeat repeat file from start
+ * \param offset begin this many items into file
+ * \param len produce only items (offset, offset+len)
*/
- class BLOCKS_API file_source : virtual public sync_block
- {
- public:
-
- // gr::blocks::file_source::sptr
- typedef boost::shared_ptr<file_source> sptr;
+ static sptr make(size_t itemsize,
+ const char* filename,
+ bool repeat = false,
+ uint64_t offset = 0,
+ uint64_t len = 0);
- /*!
- * \brief Create a file source.
- *
- * Opens \p filename as a source of items into a flowgraph. The
- * data is expected to be in binary format, item after item. The
- * \p itemsize of the block determines the conversion from bits
- * to items. The first \p offset items (default 0) will be
- * skipped.
- *
- * If \p repeat is turned on, the file will repeat the file after
- * it's reached the end.
- *
- * If \p len is non-zero, only items (offset, offset+len) will
- * be produced.
- *
- * \param itemsize the size of each item in the file, in bytes
- * \param filename name of the file to source from
- * \param repeat repeat file from start
- * \param offset begin this many items into file
- * \param len produce only items (offset, offset+len)
- */
- static sptr make(size_t itemsize, const char *filename, bool repeat = false,
- uint64_t offset = 0, uint64_t len = 0);
-
- /*!
- * \brief seek file to \p seek_point relative to \p whence
- *
- * \param seek_point sample offset in file
- * \param whence one of SEEK_SET, SEEK_CUR, SEEK_END (man fseek)
- */
- virtual bool seek(int64_t seek_point, int whence) = 0;
+ /*!
+ * \brief seek file to \p seek_point relative to \p whence
+ *
+ * \param seek_point sample offset in file
+ * \param whence one of SEEK_SET, SEEK_CUR, SEEK_END (man fseek)
+ */
+ virtual bool seek(int64_t seek_point, int whence) = 0;
- /*!
- * \brief Opens a new file.
- *
- * \param filename name of the file to source from
- * \param repeat repeat file from start
- * \param offset begin this many items into file
- * \param len produce only items [offset, offset+len)
- */
- virtual void open(const char *filename, bool repeat, uint64_t offset = 0, uint64_t len = 0) = 0;
+ /*!
+ * \brief Opens a new file.
+ *
+ * \param filename name of the file to source from
+ * \param repeat repeat file from start
+ * \param offset begin this many items into file
+ * \param len produce only items [offset, offset+len)
+ */
+ virtual void
+ open(const char* filename, bool repeat, uint64_t offset = 0, uint64_t len = 0) = 0;
- /*!
- * \brief Close the file handle.
- */
- virtual void close() = 0;
+ /*!
+ * \brief Close the file handle.
+ */
+ virtual void close() = 0;
- /*!
- * \brief Add a stream tag to the first sample of the file if true
- */
- virtual void set_begin_tag(pmt::pmt_t val) = 0;
- };
+ /*!
+ * \brief Add a stream tag to the first sample of the file if true
+ */
+ virtual void set_begin_tag(pmt::pmt_t val) = 0;
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_BLOCKS_FILE_SOURCE_H */
diff --git a/gr-blocks/include/gnuradio/blocks/float_to_char.h b/gr-blocks/include/gnuradio/blocks/float_to_char.h
index f5dcd4363e..12eb2bb3b6 100644
--- a/gr-blocks/include/gnuradio/blocks/float_to_char.h
+++ b/gr-blocks/include/gnuradio/blocks/float_to_char.h
@@ -27,38 +27,38 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief Convert stream of floats to a stream of char
+ * \ingroup type_converters_blk
+ */
+class BLOCKS_API float_to_char : virtual public sync_block
+{
+public:
+ // gr::blocks::float_to_char_ff::sptr
+ typedef boost::shared_ptr<float_to_char> sptr;
/*!
- * \brief Convert stream of floats to a stream of char
- * \ingroup type_converters_blk
+ * Build a float to char block.
+ *
+ * \param vlen vector length of data streams.
+ * \param scale a scalar multiplier to change the output signal scale.
*/
- class BLOCKS_API float_to_char : virtual public sync_block
- {
- public:
- // gr::blocks::float_to_char_ff::sptr
- typedef boost::shared_ptr<float_to_char> sptr;
+ static sptr make(size_t vlen = 1, float scale = 1.0);
- /*!
- * Build a float to char block.
- *
- * \param vlen vector length of data streams.
- * \param scale a scalar multiplier to change the output signal scale.
- */
- static sptr make(size_t vlen=1, float scale=1.0);
-
- /*!
- * Get the scalar multiplier value.
- */
- virtual float scale() const = 0;
+ /*!
+ * Get the scalar multiplier value.
+ */
+ virtual float scale() const = 0;
- /*!
- * Set the scalar multiplier value.
- */
- virtual void set_scale(float scale) = 0;
- };
+ /*!
+ * Set the scalar multiplier value.
+ */
+ virtual void set_scale(float scale) = 0;
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_BLOCKS_FLOAT_TO_CHAR_H */
diff --git a/gr-blocks/include/gnuradio/blocks/float_to_complex.h b/gr-blocks/include/gnuradio/blocks/float_to_complex.h
index 03de245f70..5b6438472c 100644
--- a/gr-blocks/include/gnuradio/blocks/float_to_complex.h
+++ b/gr-blocks/include/gnuradio/blocks/float_to_complex.h
@@ -27,27 +27,27 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief one or two floats in, complex out
+ * \ingroup type_converters_blk
+ */
+class BLOCKS_API float_to_complex : virtual public sync_block
+{
+public:
+ // gr::blocks::float_to_complex_ff::sptr
+ typedef boost::shared_ptr<float_to_complex> sptr;
/*!
- * \brief one or two floats in, complex out
- * \ingroup type_converters_blk
+ * Build a float to complex block.
+ *
+ * \param vlen vector len (default 1)
*/
- class BLOCKS_API float_to_complex : virtual public sync_block
- {
- public:
- // gr::blocks::float_to_complex_ff::sptr
- typedef boost::shared_ptr<float_to_complex> sptr;
-
- /*!
- * Build a float to complex block.
- *
- * \param vlen vector len (default 1)
- */
- static sptr make(size_t vlen=1);
- };
+ static sptr make(size_t vlen = 1);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_BLOCKS_FLOAT_TO_COMPLEX_H */
diff --git a/gr-blocks/include/gnuradio/blocks/float_to_int.h b/gr-blocks/include/gnuradio/blocks/float_to_int.h
index 71e26d6f90..f49d4b54f4 100644
--- a/gr-blocks/include/gnuradio/blocks/float_to_int.h
+++ b/gr-blocks/include/gnuradio/blocks/float_to_int.h
@@ -27,38 +27,38 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief Convert stream of floats to a stream of ints.
+ * \ingroup type_converters_blk
+ */
+class BLOCKS_API float_to_int : virtual public sync_block
+{
+public:
+ // gr::blocks::float_to_int_ff::sptr
+ typedef boost::shared_ptr<float_to_int> sptr;
/*!
- * \brief Convert stream of floats to a stream of ints.
- * \ingroup type_converters_blk
+ * Build a float to int block.
+ *
+ * \param vlen vector length of data streams.
+ * \param scale a scalar multiplier to change the output signal scale.
*/
- class BLOCKS_API float_to_int : virtual public sync_block
- {
- public:
- // gr::blocks::float_to_int_ff::sptr
- typedef boost::shared_ptr<float_to_int> sptr;
+ static sptr make(size_t vlen = 1, float scale = 1.0);
- /*!
- * Build a float to int block.
- *
- * \param vlen vector length of data streams.
- * \param scale a scalar multiplier to change the output signal scale.
- */
- static sptr make(size_t vlen=1, float scale=1.0);
-
- /*!
- * Get the scalar multiplier value.
- */
- virtual float scale() const = 0;
+ /*!
+ * Get the scalar multiplier value.
+ */
+ virtual float scale() const = 0;
- /*!
- * Set the scalar multiplier value.
- */
- virtual void set_scale(float scale) = 0;
- };
+ /*!
+ * Set the scalar multiplier value.
+ */
+ virtual void set_scale(float scale) = 0;
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_BLOCKS_FLOAT_TO_INT_H */
diff --git a/gr-blocks/include/gnuradio/blocks/float_to_short.h b/gr-blocks/include/gnuradio/blocks/float_to_short.h
index 48426dde14..62339f5b05 100644
--- a/gr-blocks/include/gnuradio/blocks/float_to_short.h
+++ b/gr-blocks/include/gnuradio/blocks/float_to_short.h
@@ -27,38 +27,38 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief Convert stream of floats to a stream of shorts
+ * \ingroup type_converters_blk
+ */
+class BLOCKS_API float_to_short : virtual public sync_block
+{
+public:
+ // gr::blocks::float_to_short_ff::sptr
+ typedef boost::shared_ptr<float_to_short> sptr;
/*!
- * \brief Convert stream of floats to a stream of shorts
- * \ingroup type_converters_blk
+ * Build a float to short block.
+ *
+ * \param vlen vector length of data streams.
+ * \param scale a scalar multiplier to change the output signal scale.
*/
- class BLOCKS_API float_to_short : virtual public sync_block
- {
- public:
- // gr::blocks::float_to_short_ff::sptr
- typedef boost::shared_ptr<float_to_short> sptr;
+ static sptr make(size_t vlen = 1, float scale = 1.0);
- /*!
- * Build a float to short block.
- *
- * \param vlen vector length of data streams.
- * \param scale a scalar multiplier to change the output signal scale.
- */
- static sptr make(size_t vlen=1, float scale=1.0);
-
- /*!
- * Get the scalar multiplier value.
- */
- virtual float scale() const = 0;
+ /*!
+ * Get the scalar multiplier value.
+ */
+ virtual float scale() const = 0;
- /*!
- * Set the scalar multiplier value.
- */
- virtual void set_scale(float scale) = 0;
- };
+ /*!
+ * Set the scalar multiplier value.
+ */
+ virtual void set_scale(float scale) = 0;
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_BLOCKS_FLOAT_TO_SHORT_H */
diff --git a/gr-blocks/include/gnuradio/blocks/float_to_uchar.h b/gr-blocks/include/gnuradio/blocks/float_to_uchar.h
index 26189ac981..2d9f3afc02 100644
--- a/gr-blocks/include/gnuradio/blocks/float_to_uchar.h
+++ b/gr-blocks/include/gnuradio/blocks/float_to_uchar.h
@@ -27,26 +27,25 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief Convert stream of floats to a stream of unsigned chars
+ * \ingroup type_converters_blk
+ */
+class BLOCKS_API float_to_uchar : virtual public sync_block
+{
+public:
+ // gr::blocks::float_to_uchar_ff::sptr
+ typedef boost::shared_ptr<float_to_uchar> sptr;
/*!
- * \brief Convert stream of floats to a stream of unsigned chars
- * \ingroup type_converters_blk
+ * Build a float to uchar block.
*/
- class BLOCKS_API float_to_uchar : virtual public sync_block
- {
- public:
-
- // gr::blocks::float_to_uchar_ff::sptr
- typedef boost::shared_ptr<float_to_uchar> sptr;
-
- /*!
- * Build a float to uchar block.
- */
- static sptr make();
- };
+ static sptr make();
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_BLOCKS_FLOAT_TO_UCHAR_H */
diff --git a/gr-blocks/include/gnuradio/blocks/head.h b/gr-blocks/include/gnuradio/blocks/head.h
index a41137c023..6096c5dfe2 100644
--- a/gr-blocks/include/gnuradio/blocks/head.h
+++ b/gr-blocks/include/gnuradio/blocks/head.h
@@ -25,32 +25,31 @@
#include <gnuradio/blocks/api.h>
#include <gnuradio/sync_block.h>
-#include <stddef.h> // size_t
+#include <stddef.h> // size_t
namespace gr {
- namespace blocks {
-
- /*!
- * \brief copies the first N items to the output then signals done
- * \ingroup misc_blk
- *
- * \details
- * Useful for building test cases
- */
- class BLOCKS_API head : virtual public 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(uint64_t nitems) = 0;
- };
-
- } /* namespace blocks */
+namespace blocks {
+
+/*!
+ * \brief copies the first N items to the output then signals done
+ * \ingroup misc_blk
+ *
+ * \details
+ * Useful for building test cases
+ */
+class BLOCKS_API head : virtual public 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(uint64_t nitems) = 0;
+};
+
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_GR_HEAD_H */
diff --git a/gr-blocks/include/gnuradio/blocks/int_to_float.h b/gr-blocks/include/gnuradio/blocks/int_to_float.h
index b8075f2df8..89aeb02fa0 100644
--- a/gr-blocks/include/gnuradio/blocks/int_to_float.h
+++ b/gr-blocks/include/gnuradio/blocks/int_to_float.h
@@ -27,38 +27,38 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief Convert stream of ints to a stream of floats.
+ * \ingroup type_converters_blk
+ */
+class BLOCKS_API int_to_float : virtual public sync_block
+{
+public:
+ // gr::blocks::int_to_float_ff::sptr
+ typedef boost::shared_ptr<int_to_float> sptr;
/*!
- * \brief Convert stream of ints to a stream of floats.
- * \ingroup type_converters_blk
+ * Build an int to float block.
+ *
+ * \param vlen vector length of data streams.
+ * \param scale a scalar divider to change the output signal scale.
*/
- class BLOCKS_API int_to_float : virtual public sync_block
- {
- public:
- // gr::blocks::int_to_float_ff::sptr
- typedef boost::shared_ptr<int_to_float> sptr;
+ static sptr make(size_t vlen = 1, float scale = 1.0);
- /*!
- * Build an int to float block.
- *
- * \param vlen vector length of data streams.
- * \param scale a scalar divider to change the output signal scale.
- */
- static sptr make(size_t vlen=1, float scale=1.0);
-
- /*!
- * Get the scalar divider value.
- */
- virtual float scale() const = 0;
+ /*!
+ * Get the scalar divider value.
+ */
+ virtual float scale() const = 0;
- /*!
- * Set the scalar divider value.
- */
- virtual void set_scale(float scale) = 0;
- };
+ /*!
+ * Set the scalar divider value.
+ */
+ virtual void set_scale(float scale) = 0;
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_BLOCKS_INT_TO_FLOAT_H */
diff --git a/gr-blocks/include/gnuradio/blocks/integrate.h b/gr-blocks/include/gnuradio/blocks/integrate.h
index 0eef4bfd34..bf9b6959a5 100644
--- a/gr-blocks/include/gnuradio/blocks/integrate.h
+++ b/gr-blocks/include/gnuradio/blocks/integrate.h
@@ -29,28 +29,27 @@
#include <cstdint>
namespace gr {
- namespace blocks {
+namespace blocks {
- /*!
- * \brief Integrate successive samples and decimate
- * \ingroup math_operators_blk
- */
-template<class T>
- class BLOCKS_API integrate : virtual public sync_decimator
- {
- public:
-
- // gr::blocks::integrate::sptr
- typedef boost::shared_ptr< integrate<T> > sptr;
+/*!
+ * \brief Integrate successive samples and decimate
+ * \ingroup math_operators_blk
+ */
+template <class T>
+class BLOCKS_API integrate : virtual public sync_decimator
+{
+public:
+ // gr::blocks::integrate::sptr
+ typedef boost::shared_ptr<integrate<T>> sptr;
- static sptr make(int decim, unsigned int vlen = 1);
- };
+ static sptr make(int decim, unsigned int vlen = 1);
+};
typedef integrate<std::int16_t> integrate_ss;
typedef integrate<std::int32_t> integrate_ii;
typedef integrate<float> integrate_ff;
typedef integrate<gr_complex> integrate_cc;
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INTEGRATE_H */
diff --git a/gr-blocks/include/gnuradio/blocks/interleave.h b/gr-blocks/include/gnuradio/blocks/interleave.h
index 5de75fcce4..8b4be52b26 100644
--- a/gr-blocks/include/gnuradio/blocks/interleave.h
+++ b/gr-blocks/include/gnuradio/blocks/interleave.h
@@ -27,52 +27,52 @@
#include <gnuradio/block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief interleave N inputs into a single output
+ * \ingroup stream_operators_blk
+ *
+ * \details
+ *
+ * This block interleaves blocks of samples. For each input
+ * connection, the samples are interleaved successively to the
+ * output connection. By default, the block interleaves a single
+ * sample from each input to the output unless blocksize is given
+ * in the constructor.
+ *
+ * \code
+ * blocksize = 1
+ * connections = 2
+ * input[0] = [a, c, e, g]
+ * input[1] = [b, d, f, h]
+ * output = [a, b, c, d, e, f, g, h]
+ * \endcode
+ *
+ * \code
+ * blocksize = 2
+ * connections = 2
+ * input[0] = [a, b, e, f]
+ * input[1] = [c, d, g, h]
+ * output = [a, b, c, d, e, f, g, h]
+ * \endcode
+ */
+class BLOCKS_API interleave : virtual public block
+{
+public:
+ // gr::blocks::interleave::sptr
+ typedef boost::shared_ptr<interleave> sptr;
/*!
- * \brief interleave N inputs into a single output
- * \ingroup stream_operators_blk
- *
- * \details
- *
- * This block interleaves blocks of samples. For each input
- * connection, the samples are interleaved successively to the
- * output connection. By default, the block interleaves a single
- * sample from each input to the output unless blocksize is given
- * in the constructor.
+ * Make a stream interleave block.
*
- * \code
- * blocksize = 1
- * connections = 2
- * input[0] = [a, c, e, g]
- * input[1] = [b, d, f, h]
- * output = [a, b, c, d, e, f, g, h]
- * \endcode
- *
- * \code
- * blocksize = 2
- * connections = 2
- * input[0] = [a, b, e, f]
- * input[1] = [c, d, g, h]
- * output = [a, b, c, d, e, f, g, h]
- * \endcode
+ * \param itemsize stream itemsize
+ * \param blocksize size of block of samples to interleave
*/
- class BLOCKS_API interleave : virtual public block
- {
- public:
- // gr::blocks::interleave::sptr
- typedef boost::shared_ptr<interleave> sptr;
-
- /*!
- * Make a stream interleave block.
- *
- * \param itemsize stream itemsize
- * \param blocksize size of block of samples to interleave
- */
- static sptr make(size_t itemsize, unsigned int blocksize = 1);
- };
+ static sptr make(size_t itemsize, unsigned int blocksize = 1);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_BLOCKS_INTERLEAVE_H */
diff --git a/gr-blocks/include/gnuradio/blocks/interleaved_char_to_complex.h b/gr-blocks/include/gnuradio/blocks/interleaved_char_to_complex.h
index 53a77e7cd0..29b2d14699 100644
--- a/gr-blocks/include/gnuradio/blocks/interleaved_char_to_complex.h
+++ b/gr-blocks/include/gnuradio/blocks/interleaved_char_to_complex.h
@@ -27,25 +27,25 @@
#include <gnuradio/sync_decimator.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief Convert stream of interleaved chars to a stream of complex
+ * \ingroup type_converters_blk
+ */
+class BLOCKS_API interleaved_char_to_complex : virtual public sync_decimator
+{
+public:
+ // gr::blocks::interleaved_char_to_complex::sptr
+ typedef boost::shared_ptr<interleaved_char_to_complex> sptr;
/*!
- * \brief Convert stream of interleaved chars to a stream of complex
- * \ingroup type_converters_blk
+ * Build an interleaved char to complex block.
*/
- class BLOCKS_API interleaved_char_to_complex : virtual public sync_decimator
- {
- public:
- // gr::blocks::interleaved_char_to_complex::sptr
- typedef boost::shared_ptr<interleaved_char_to_complex> sptr;
-
- /*!
- * Build an interleaved char to complex block.
- */
- static sptr make(bool vector_input=false);
- };
+ static sptr make(bool vector_input = false);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_BLOCKS_INTERLEAVED_CHAR_TO_COMPLEX_H */
diff --git a/gr-blocks/include/gnuradio/blocks/interleaved_short_to_complex.h b/gr-blocks/include/gnuradio/blocks/interleaved_short_to_complex.h
index fee4352b71..7e15d99ed2 100644
--- a/gr-blocks/include/gnuradio/blocks/interleaved_short_to_complex.h
+++ b/gr-blocks/include/gnuradio/blocks/interleaved_short_to_complex.h
@@ -27,27 +27,27 @@
#include <gnuradio/sync_decimator.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief Convert stream of interleaved shorts to a stream of complex
+ * \ingroup type_converters_blk
+ */
+class BLOCKS_API interleaved_short_to_complex : virtual public sync_decimator
+{
+public:
+ // gr::blocks::interleaved_short_to_complex::sptr
+ typedef boost::shared_ptr<interleaved_short_to_complex> sptr;
/*!
- * \brief Convert stream of interleaved shorts to a stream of complex
- * \ingroup type_converters_blk
+ * Build an interleaved short to complex block.
*/
- class BLOCKS_API interleaved_short_to_complex : virtual public sync_decimator
- {
- public:
- // gr::blocks::interleaved_short_to_complex::sptr
- typedef boost::shared_ptr<interleaved_short_to_complex> sptr;
-
- /*!
- * Build an interleaved short to complex block.
- */
- static sptr make(bool vector_input=false, bool swap=false);
+ static sptr make(bool vector_input = false, bool swap = false);
- virtual void set_swap(bool swap)=0;
- };
+ virtual void set_swap(bool swap) = 0;
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_BLOCKS_INTERLEAVED_SHORT_TO_COMPLEX_H */
diff --git a/gr-blocks/include/gnuradio/blocks/keep_m_in_n.h b/gr-blocks/include/gnuradio/blocks/keep_m_in_n.h
index 909b62316e..38d6a3cb3f 100644
--- a/gr-blocks/include/gnuradio/blocks/keep_m_in_n.h
+++ b/gr-blocks/include/gnuradio/blocks/keep_m_in_n.h
@@ -27,35 +27,34 @@
#include <gnuradio/block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief decimate a stream, keeping the first \p m items out of every \p n starting after
+ * \p offset items. \ingroup stream_operators_blk
+ */
+class BLOCKS_API keep_m_in_n : virtual public block
+{
+public:
+ // gr::blocks::keep_m_in_n::sptr
+ typedef boost::shared_ptr<keep_m_in_n> sptr;
/*!
- * \brief decimate a stream, keeping the first \p m items out of every \p n starting after \p offset items.
- * \ingroup stream_operators_blk
+ * Make a keep m in n block.
+ *
+ * \param itemsize stream itemsize
+ * \param m number of items to take in block of \p n items
+ * \param n block size in items
+ * \param offset initial item offset into the stream
*/
- class BLOCKS_API keep_m_in_n : virtual public block
- {
- public:
-
- // gr::blocks::keep_m_in_n::sptr
- typedef boost::shared_ptr<keep_m_in_n> sptr;
-
- /*!
- * Make a keep m in n block.
- *
- * \param itemsize stream itemsize
- * \param m number of items to take in block of \p n items
- * \param n block size in items
- * \param offset initial item offset into the stream
- */
- static sptr make(size_t itemsize, int m, int n, int offset);
-
- virtual void set_m(int m) = 0;
- virtual void set_n(int n) = 0;
- virtual void set_offset(int offset) = 0;
- };
-
- } /* namespace blocks */
+ static sptr make(size_t itemsize, int m, int n, int offset);
+
+ virtual void set_m(int m) = 0;
+ virtual void set_n(int n) = 0;
+ virtual void set_offset(int offset) = 0;
+};
+
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_BLOCKS_KEEP_M_IN_N_H */
diff --git a/gr-blocks/include/gnuradio/blocks/keep_one_in_n.h b/gr-blocks/include/gnuradio/blocks/keep_one_in_n.h
index af5c7de7d2..f95146ca36 100644
--- a/gr-blocks/include/gnuradio/blocks/keep_one_in_n.h
+++ b/gr-blocks/include/gnuradio/blocks/keep_one_in_n.h
@@ -27,31 +27,30 @@
#include <gnuradio/block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief decimate a stream, keeping the last item out of every \p n.
+ * \ingroup stream_operators_blk
+ */
+class BLOCKS_API keep_one_in_n : virtual public block
+{
+public:
+ // gr::blocks::keep_one_in_n::sptr
+ typedef boost::shared_ptr<keep_one_in_n> sptr;
/*!
- * \brief decimate a stream, keeping the last item out of every \p n.
- * \ingroup stream_operators_blk
+ * Make a keep one in n block.
+ *
+ * \param itemsize stream itemsize
+ * \param n block size in items
*/
- class BLOCKS_API keep_one_in_n : virtual public block
- {
- public:
-
- // gr::blocks::keep_one_in_n::sptr
- typedef boost::shared_ptr<keep_one_in_n> sptr;
-
- /*!
- * Make a keep one in n block.
- *
- * \param itemsize stream itemsize
- * \param n block size in items
- */
- static sptr make(size_t itemsize, int n);
+ static sptr make(size_t itemsize, int n);
- virtual void set_n(int n) = 0;
- };
+ virtual void set_n(int n) = 0;
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_BLOCKS_KEEP_ONE_IN_N_H */
diff --git a/gr-blocks/include/gnuradio/blocks/lfsr_15_1_0.h b/gr-blocks/include/gnuradio/blocks/lfsr_15_1_0.h
index 2ebfe08319..22c9521e3d 100644
--- a/gr-blocks/include/gnuradio/blocks/lfsr_15_1_0.h
+++ b/gr-blocks/include/gnuradio/blocks/lfsr_15_1_0.h
@@ -26,45 +26,45 @@
#include <gnuradio/blocks/api.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- /*!
- * \brief Linear Feedback Shift Register using primitive polynomial x^15 + x + 1
- * \ingroup misc
- *
- * \details
- * 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
+/*!
+ * \brief Linear Feedback Shift Register using primitive polynomial x^15 + x + 1
+ * \ingroup misc
+ *
+ * \details
+ * 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(); }
+public:
+ lfsr_15_1_0() { reset(); }
- void reset() { d_sr = 0x7fff; }
+ void reset() { d_sr = 0x7fff; }
- int next_bit()
- {
+ 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;
+ 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 blocks */
} /* namespace gr */
#endif /* INCLUDED_GRI_LFSR_15_1_0_H */
diff --git a/gr-blocks/include/gnuradio/blocks/lfsr_32k.h b/gr-blocks/include/gnuradio/blocks/lfsr_32k.h
index 502efebc5d..2b34460a66 100644
--- a/gr-blocks/include/gnuradio/blocks/lfsr_32k.h
+++ b/gr-blocks/include/gnuradio/blocks/lfsr_32k.h
@@ -27,65 +27,65 @@
#include <gnuradio/blocks/lfsr_15_1_0.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- /*!
- * \brief generate pseudo-random sequence of length 32768 bits.
- * \ingroup misc
- *
- * \details
- * 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;
+/*!
+ * \brief generate pseudo-random sequence of length 32768 bits.
+ * \ingroup misc
+ *
+ * \details
+ * 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 (); }
+public:
+ lfsr_32k() { reset(); }
- void reset()
- {
+ void reset()
+ {
d_lfsr.reset();
d_count = 0;
- }
+ }
- int next_bit()
- {
- if(d_count == 32767) {
- d_count = 0;
- return 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;
+ 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 next_short()
+ {
int v = 0;
- for(int i = 0; i < 16; i++) {
- v >>= 1;
- if(next_bit ())
- v |= 0x8000;
+ for (int i = 0; i < 16; i++) {
+ v >>= 1;
+ if (next_bit())
+ v |= 0x8000;
}
return v;
- }
- };
+ }
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_GRI_LFSR_32k_H */
diff --git a/gr-blocks/include/gnuradio/blocks/lfsr_32k_source_s.h b/gr-blocks/include/gnuradio/blocks/lfsr_32k_source_s.h
index 0d13eafed7..390d1ed9f3 100644
--- a/gr-blocks/include/gnuradio/blocks/lfsr_32k_source_s.h
+++ b/gr-blocks/include/gnuradio/blocks/lfsr_32k_source_s.h
@@ -28,29 +28,29 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief LFSR pseudo-random source with period of 2^15 bits (2^11 shorts)
+ * \ingroup misc_blk
+ *
+ * \details
+ * 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 sync_block
+{
+public:
+ // gr::blocks::lfsr_32k_source_s::sptr
+ typedef boost::shared_ptr<lfsr_32k_source_s> sptr;
/*!
- * \brief LFSR pseudo-random source with period of 2^15 bits (2^11 shorts)
- * \ingroup misc_blk
- *
- * \details
- * This source is typically used along with gr::blocks::check_lfsr_32k_s to
- * test the USRP using its digital loopback mode.
+ * \brief Make a LFSR 32k source block.
*/
- class BLOCKS_API lfsr_32k_source_s : virtual public 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();
- };
+ static sptr make();
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_GR_LFSR_32K_SOURCE_S_H */
diff --git a/gr-blocks/include/gnuradio/blocks/log2_const.h b/gr-blocks/include/gnuradio/blocks/log2_const.h
index c2526e76ed..7fc04a94f3 100644
--- a/gr-blocks/include/gnuradio/blocks/log2_const.h
+++ b/gr-blocks/include/gnuradio/blocks/log2_const.h
@@ -31,23 +31,72 @@
#include <assert.h>
namespace gr {
- namespace blocks {
-
- template<unsigned int k> static inline int log2_const() { assert(0); return 0; }
-
- template<> inline int log2_const<1>() { return 0; }
- template<> inline int log2_const<2>() { return 1; }
- template<> inline int log2_const<4>() { return 2; }
- template<> inline int log2_const<8>() { return 3; }
- template<> inline int log2_const<16>() { return 4; }
- template<> inline int log2_const<32>() { return 5; }
- template<> inline int log2_const<64>() { return 6; }
- template<> inline int log2_const<128>() { return 7; }
- template<> inline int log2_const<256>() { return 8; }
- template<> inline int log2_const<512>() { return 9; }
- template<> inline int log2_const<1024>(){ return 10; }
-
- } /* namespace blocks */
+namespace blocks {
+
+template <unsigned int k>
+static inline int log2_const()
+{
+ assert(0);
+ return 0;
+}
+
+template <>
+inline int log2_const<1>()
+{
+ return 0;
+}
+template <>
+inline int log2_const<2>()
+{
+ return 1;
+}
+template <>
+inline int log2_const<4>()
+{
+ return 2;
+}
+template <>
+inline int log2_const<8>()
+{
+ return 3;
+}
+template <>
+inline int log2_const<16>()
+{
+ return 4;
+}
+template <>
+inline int log2_const<32>()
+{
+ return 5;
+}
+template <>
+inline int log2_const<64>()
+{
+ return 6;
+}
+template <>
+inline int log2_const<128>()
+{
+ return 7;
+}
+template <>
+inline int log2_const<256>()
+{
+ return 8;
+}
+template <>
+inline int log2_const<512>()
+{
+ return 9;
+}
+template <>
+inline int log2_const<1024>()
+{
+ return 10;
+}
+
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_BLOCKS_LOG2_CONST_H */
diff --git a/gr-blocks/include/gnuradio/blocks/magphase_to_complex.h b/gr-blocks/include/gnuradio/blocks/magphase_to_complex.h
index be2eb3af88..a3704cbeee 100644
--- a/gr-blocks/include/gnuradio/blocks/magphase_to_complex.h
+++ b/gr-blocks/include/gnuradio/blocks/magphase_to_complex.h
@@ -27,27 +27,27 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief two floats in (mag and phase), complex out
+ * \ingroup type_converters_blk
+ */
+class BLOCKS_API magphase_to_complex : virtual public sync_block
+{
+public:
+ // gr::blocks::magphase_to_complex_ff::sptr
+ typedef boost::shared_ptr<magphase_to_complex> sptr;
/*!
- * \brief two floats in (mag and phase), complex out
- * \ingroup type_converters_blk
+ * Build a mag and phase to complex block.
+ *
+ * \param vlen vector len (default 1)
*/
- class BLOCKS_API magphase_to_complex : virtual public sync_block
- {
- public:
- // gr::blocks::magphase_to_complex_ff::sptr
- typedef boost::shared_ptr<magphase_to_complex> sptr;
-
- /*!
- * Build a mag and phase to complex block.
- *
- * \param vlen vector len (default 1)
- */
- static sptr make(size_t vlen=1);
- };
+ static sptr make(size_t vlen = 1);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_BLOCKS_MAGPHASE_TO_COMPLEX_H */
diff --git a/gr-blocks/include/gnuradio/blocks/max_blk.h b/gr-blocks/include/gnuradio/blocks/max_blk.h
index dcdc3204d1..7e0acdec39 100644
--- a/gr-blocks/include/gnuradio/blocks/max_blk.h
+++ b/gr-blocks/include/gnuradio/blocks/max_blk.h
@@ -29,37 +29,37 @@
#include <cstdint>
namespace gr {
- namespace blocks {
+namespace blocks {
- /*!
- * \brief Compares vectors from multiple streams and determines
- * the maximum value from each vector over all streams.
- * \ingroup math_operators_blk
- *
- * \details
- * Data is passed in as a vector of length \p vlen from multiple
- * input sources. If vlen_out == 1 then
- * It will look through these streams of \p vlen
- * data items and the output stream will contain the maximum value
- * in the vector.
- * If vlen_out == vlen and not equal to 1 then
- * output will be a vector with individual items selected from
- * the maximum corresponding input vector items.
- */
-template<class T>
- class BLOCKS_API max_blk : virtual public sync_block
- {
- public:
- // gr::blocks::max_blk::sptr
- typedef boost::shared_ptr< max_blk<T> > sptr;
+/*!
+ * \brief Compares vectors from multiple streams and determines
+ * the maximum value from each vector over all streams.
+ * \ingroup math_operators_blk
+ *
+ * \details
+ * Data is passed in as a vector of length \p vlen from multiple
+ * input sources. If vlen_out == 1 then
+ * It will look through these streams of \p vlen
+ * data items and the output stream will contain the maximum value
+ * in the vector.
+ * If vlen_out == vlen and not equal to 1 then
+ * output will be a vector with individual items selected from
+ * the maximum corresponding input vector items.
+ */
+template <class T>
+class BLOCKS_API max_blk : virtual public sync_block
+{
+public:
+ // gr::blocks::max_blk::sptr
+ typedef boost::shared_ptr<max_blk<T>> sptr;
- static sptr make(size_t vlen, size_t vlen_out = 1);
- };
+ static sptr make(size_t vlen, size_t vlen_out = 1);
+};
typedef max_blk<std::int16_t> max_ss;
typedef max_blk<std::int32_t> max_ii;
typedef max_blk<float> max_ff;
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* MAX_BLK_H */
diff --git a/gr-blocks/include/gnuradio/blocks/message_debug.h b/gr-blocks/include/gnuradio/blocks/message_debug.h
index c6c43f5644..6b83da76bb 100644
--- a/gr-blocks/include/gnuradio/blocks/message_debug.h
+++ b/gr-blocks/include/gnuradio/blocks/message_debug.h
@@ -27,62 +27,62 @@
#include <gnuradio/block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief Debug block for the message passing system.
+ * \ingroup message_tools_blk
+ * \ingroup measurement_tools_blk
+ * \ingroup debug_tools_blk
+ *
+ * \details
+ * 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 block
+{
+public:
+ // gr::blocks::message_debug::sptr
+ typedef boost::shared_ptr<message_debug> sptr;
/*!
- * \brief Debug block for the message passing system.
- * \ingroup message_tools_blk
- * \ingroup measurement_tools_blk
- * \ingroup debug_tools_blk
- *
- * \details
- * 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).
+ * \brief Build the message debug block. It takes no parameters
+ * and has three message ports: print, store, and
+ * print_pdu.
*/
- class BLOCKS_API message_debug : virtual public 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();
+ static sptr make();
- /*!
- * \brief Reports the number of messages received by this block.
- */
- virtual int num_messages() = 0;
+ /*!
+ * \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;
- };
+ /*!
+ * \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 blocks */
} /* namespace gr */
#endif /* INCLUDED_GR_MESSAGE_DEBUG_H */
diff --git a/gr-blocks/include/gnuradio/blocks/message_strobe.h b/gr-blocks/include/gnuradio/blocks/message_strobe.h
index 553a1c0f9e..2a2fbdae5b 100644
--- a/gr-blocks/include/gnuradio/blocks/message_strobe.h
+++ b/gr-blocks/include/gnuradio/blocks/message_strobe.h
@@ -27,56 +27,56 @@
#include <gnuradio/block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief Send message at defined interval
+ * \ingroup message_tools_blk
+ *
+ * \details
+ * 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 block
+{
+public:
+ // gr::blocks::message_strobe::sptr
+ typedef boost::shared_ptr<message_strobe> sptr;
/*!
- * \brief Send message at defined interval
- * \ingroup message_tools_blk
+ * Make a message stobe block to send message \p msg every \p
+ * period_ms milliseconds.
*
- * \details
- * Takes a PMT message and sends it out every \p period_ms
- * milliseconds. Useful for testing/debugging the message system.
+ * \param msg The message to send as a PMT.
+ * \param period_ms the time period in milliseconds in which to
+ * send \p msg.
*/
- class BLOCKS_API message_strobe : virtual public block
- {
- public:
- // gr::blocks::message_strobe::sptr
- typedef boost::shared_ptr<message_strobe> sptr;
+ static sptr make(pmt::pmt_t msg, long period_ms);
- /*!
- * 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, long 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;
+ /*!
+ * 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;
+ /*!
+ * 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(long period_ms) = 0;
+ /*!
+ * Reset the sending interval.
+ * \param period_ms the time period in milliseconds.
+ */
+ virtual void set_period(long period_ms) = 0;
- /*!
- * Get the time interval of the strobe.
- */
- virtual long period() const = 0;
- };
+ /*!
+ * Get the time interval of the strobe.
+ */
+ virtual long period() const = 0;
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_GR_MESSAGE_STROBE_H */
diff --git a/gr-blocks/include/gnuradio/blocks/message_strobe_random.h b/gr-blocks/include/gnuradio/blocks/message_strobe_random.h
index 8f5a20e1b3..e481d670e0 100644
--- a/gr-blocks/include/gnuradio/blocks/message_strobe_random.h
+++ b/gr-blocks/include/gnuradio/blocks/message_strobe_random.h
@@ -27,92 +27,94 @@
#include <gnuradio/block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- /*
- * strobing models
- */
- typedef enum {
- STROBE_POISSON=1,
- STROBE_GAUSSIAN=2,
- STROBE_UNIFORM=3
- } message_strobe_random_distribution_t;
+/*
+ * strobing models
+ */
+typedef enum {
+ STROBE_POISSON = 1,
+ STROBE_GAUSSIAN = 2,
+ STROBE_UNIFORM = 3
+} message_strobe_random_distribution_t;
+
+/*!
+ * \brief Send message at defined interval
+ * \ingroup message_tools_blk
+ *
+ * \details
+
+ * Takes a PMT message and sends it out every at random
+ * intervals. The interval is basedon a random distribution, \p
+ * dist, with specified mean (\p mean_ms) and variance (\p
+ * std_ms). Useful for testing/debugging the message system.
+ */
+class BLOCKS_API message_strobe_random : virtual public block
+{
+public:
+ // gr::blocks::message_strobe_random::sptr
+ typedef boost::shared_ptr<message_strobe_random> sptr;
/*!
- * \brief Send message at defined interval
- * \ingroup message_tools_blk
+ * Make a message stobe block to sends message \p msg at random
+ * intervals defined by the distribution \p dist with mean \p
+ * mean_ms and standard deviation \p std_ms.
*
- * \details
+ * \param msg The message to send as a PMT.
+ * \param dist The random distribution from which to draw events.
+ * \param mean_ms The mean of the distribution.
+ * \param std_ms The standard deviation of the distribution.
+ */
+ static sptr make(pmt::pmt_t msg,
+ message_strobe_random_distribution_t dist,
+ float mean_ms,
+ float std_ms);
- * Takes a PMT message and sends it out every at random
- * intervals. The interval is basedon a random distribution, \p
- * dist, with specified mean (\p mean_ms) and variance (\p
- * std_ms). Useful for testing/debugging the message system.
+ /*!
+ * Reset the message being sent.
+ * \param msg The message to send as a PMT.
*/
- class BLOCKS_API message_strobe_random : virtual public block
- {
- public:
- // gr::blocks::message_strobe_random::sptr
- typedef boost::shared_ptr<message_strobe_random> sptr;
-
- /*!
- * Make a message stobe block to sends message \p msg at random
- * intervals defined by the distribution \p dist with mean \p
- * mean_ms and standard deviation \p std_ms.
- *
- * \param msg The message to send as a PMT.
- * \param dist The random distribution from which to draw events.
- * \param mean_ms The mean of the distribution.
- * \param std_ms The standard deviation of the distribution.
- */
- static sptr make(pmt::pmt_t msg, message_strobe_random_distribution_t dist, float mean_ms, float std_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;
-
- /*!
- * \param dist new distribution.
- */
- virtual void set_dist(message_strobe_random_distribution_t dist) = 0;
-
- /*!
- * get the current distribution.
- */
- virtual message_strobe_random_distribution_t dist() const = 0;
-
- /*!
- * Reset the sending interval.
- * \param mean delay in milliseconds.
- */
- virtual void set_mean(float mean) = 0;
-
- /*!
- * Get the time interval of the strobe_random.
- */
- virtual float mean() const = 0;
-
- /*!
- * Reset the sending interval.
- * \param std delay in milliseconds.
- */
- virtual void set_std(float std) = 0;
-
- /*!
- * Get the std of strobe_random.
- */
- virtual float std() const = 0;
-
- };
-
- } /* namespace blocks */
+ virtual void set_msg(pmt::pmt_t msg) = 0;
+
+ /*!
+ * Get the value of the message being sent.
+ */
+ virtual pmt::pmt_t msg() const = 0;
+
+ /*!
+ * \param dist new distribution.
+ */
+ virtual void set_dist(message_strobe_random_distribution_t dist) = 0;
+
+ /*!
+ * get the current distribution.
+ */
+ virtual message_strobe_random_distribution_t dist() const = 0;
+
+ /*!
+ * Reset the sending interval.
+ * \param mean delay in milliseconds.
+ */
+ virtual void set_mean(float mean) = 0;
+
+ /*!
+ * Get the time interval of the strobe_random.
+ */
+ virtual float mean() const = 0;
+
+ /*!
+ * Reset the sending interval.
+ * \param std delay in milliseconds.
+ */
+ virtual void set_std(float std) = 0;
+
+ /*!
+ * Get the std of strobe_random.
+ */
+ virtual float std() const = 0;
+};
+
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_GR_MESSAGE_STROBE_H */
diff --git a/gr-blocks/include/gnuradio/blocks/min_blk.h b/gr-blocks/include/gnuradio/blocks/min_blk.h
index 29dc75ae18..1d4e272931 100644
--- a/gr-blocks/include/gnuradio/blocks/min_blk.h
+++ b/gr-blocks/include/gnuradio/blocks/min_blk.h
@@ -29,36 +29,36 @@
#include <cstdint>
namespace gr {
- namespace blocks {
+namespace blocks {
- /*!
- * \brief Compares vectors from multiple streams and determines
- * the minimum value from each vector over all streams.
- * \ingroup math_operators_blk
- *
- * \details
- * Data is passed in as a vector of length \p vlen from multiple
- * input sources. If vlen_out == 1 then
- * It will look through these streams of \p vlen
- * data items and the output stream will contain the minimum value
- * in the vector.
- * If vlen_out == vlen and not equal to 1 then
- * output will be a vector with individual items selected from
- * the minimum corresponding input vector items.
- */
-template<class T>
- class BLOCKS_API min_blk : virtual public sync_block
- {
- public:
- typedef boost::shared_ptr< min_blk<T> > sptr;
+/*!
+ * \brief Compares vectors from multiple streams and determines
+ * the minimum value from each vector over all streams.
+ * \ingroup math_operators_blk
+ *
+ * \details
+ * Data is passed in as a vector of length \p vlen from multiple
+ * input sources. If vlen_out == 1 then
+ * It will look through these streams of \p vlen
+ * data items and the output stream will contain the minimum value
+ * in the vector.
+ * If vlen_out == vlen and not equal to 1 then
+ * output will be a vector with individual items selected from
+ * the minimum corresponding input vector items.
+ */
+template <class T>
+class BLOCKS_API min_blk : virtual public sync_block
+{
+public:
+ typedef boost::shared_ptr<min_blk<T>> sptr;
- static sptr make(size_t vlen, size_t vlen_out = 1);
- };
+ static sptr make(size_t vlen, size_t vlen_out = 1);
+};
typedef min_blk<std::int16_t> min_ss;
typedef min_blk<std::int32_t> min_ii;
typedef min_blk<float> min_ff;
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* MIN_BLK_H */
diff --git a/gr-blocks/include/gnuradio/blocks/moving_average.h b/gr-blocks/include/gnuradio/blocks/moving_average.h
index 8448c45ded..a66decfc64 100644
--- a/gr-blocks/include/gnuradio/blocks/moving_average.h
+++ b/gr-blocks/include/gnuradio/blocks/moving_average.h
@@ -29,63 +29,61 @@
#include <cstdint>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief output is the moving sum of the last N samples, scaled by the scale factor
+ * \ingroup level_controllers_blk
+ */
+template <class T>
+class BLOCKS_API moving_average : virtual public sync_block
+{
+public:
+ // gr::blocks::moving_average::sptr
+ typedef boost::shared_ptr<moving_average<T>> sptr;
/*!
- * \brief output is the moving sum of the last N samples, scaled by the scale factor
- * \ingroup level_controllers_blk
+ * 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.
+ * \param vlen When > 1, do a per-vector-element moving average
*/
-template<class T>
- class BLOCKS_API moving_average : virtual public sync_block
- {
- public:
- // gr::blocks::moving_average::sptr
- typedef boost::shared_ptr< moving_average<T> > sptr;
+ static sptr make(int length, T scale, int max_iter = 4096, unsigned int vlen = 1);
- /*!
- * 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.
- * \param vlen When > 1, do a per-vector-element moving average
- */
- static sptr make(int length, T scale,
- int max_iter = 4096,
- unsigned int vlen = 1);
-
- /*!
- * Get the length used in the avaraging calculation.
- */
- virtual int length() const = 0;
+ /*!
+ * Get the length used in the avaraging calculation.
+ */
+ virtual int length() const = 0;
- /*!
- * Get the scale factor being used.
- */
- virtual T scale() const = 0;
+ /*!
+ * Get the scale factor being used.
+ */
+ virtual T scale() const = 0;
- /*!
- * Set both the length and the scale factor together.
- */
- virtual void set_length_and_scale(int length, T scale) = 0;
+ /*!
+ * Set both the length and the scale factor together.
+ */
+ virtual void set_length_and_scale(int length, T scale) = 0;
- /*!
- * Set the length.
- */
- virtual void set_length(int length) = 0;
+ /*!
+ * Set the length.
+ */
+ virtual void set_length(int length) = 0;
- /*!
- * Set the scale factor.
- */
- virtual void set_scale(T scale) = 0;
- };
+ /*!
+ * Set the scale factor.
+ */
+ virtual void set_scale(T scale) = 0;
+};
typedef moving_average<std::int16_t> moving_average_ss;
typedef moving_average<std::int32_t> moving_average_ii;
typedef moving_average<float> moving_average_ff;
typedef moving_average<gr_complex> moving_average_cc;
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* MOVING_AVERAGE_H */
diff --git a/gr-blocks/include/gnuradio/blocks/multiply.h b/gr-blocks/include/gnuradio/blocks/multiply.h
index 06bda22cbf..467b341cc9 100644
--- a/gr-blocks/include/gnuradio/blocks/multiply.h
+++ b/gr-blocks/include/gnuradio/blocks/multiply.h
@@ -29,31 +29,30 @@
#include <cstdint>
namespace gr {
- namespace blocks {
-
- /*!
- * \brief output = prod (input_0, input_1, ...)
- * \ingroup math_operators_blk
- *
- * \details
- * Multiply across all input streams.
- */
-template<class T>
- class BLOCKS_API multiply : virtual public sync_block
- {
- public:
-
- // gr::blocks::multiply::sptr
- typedef boost::shared_ptr< multiply<T> > sptr;
-
- static sptr make(size_t vlen=1);
- };
+namespace blocks {
+
+/*!
+ * \brief output = prod (input_0, input_1, ...)
+ * \ingroup math_operators_blk
+ *
+ * \details
+ * Multiply across all input streams.
+ */
+template <class T>
+class BLOCKS_API multiply : virtual public sync_block
+{
+public:
+ // gr::blocks::multiply::sptr
+ typedef boost::shared_ptr<multiply<T>> sptr;
+
+ static sptr make(size_t vlen = 1);
+};
typedef multiply<std::int16_t> multiply_ss;
typedef multiply<std::int32_t> multiply_ii;
typedef multiply<float> multiply_ff;
typedef multiply<gr_complex> multiply_cc;
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* MULTIPLY_H */
diff --git a/gr-blocks/include/gnuradio/blocks/multiply_by_tag_value_cc.h b/gr-blocks/include/gnuradio/blocks/multiply_by_tag_value_cc.h
index f4aba9db65..3867960e81 100644
--- a/gr-blocks/include/gnuradio/blocks/multiply_by_tag_value_cc.h
+++ b/gr-blocks/include/gnuradio/blocks/multiply_by_tag_value_cc.h
@@ -27,43 +27,42 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief output = input * complex constant
+ * \ingroup math_operators_blk
+ *
+ * \details
+ * The complex constant used by this block is found from a tag
+ * with the name specified by \p tag_name. The tag must contain a
+ * float/double or complex PMT value that will be converted into a
+ * gr_complex value. All input data is multiplied by this
+ * value until a new tag with an update value is found. The block
+ * starts with a value of '1.0' for the multiplier constant.
+ */
+class BLOCKS_API multiply_by_tag_value_cc : virtual public sync_block
+{
+public:
+ // gr::blocks::multiply_by_tag_value_cc::sptr
+ typedef boost::shared_ptr<multiply_by_tag_value_cc> sptr;
/*!
- * \brief output = input * complex constant
- * \ingroup math_operators_blk
- *
- * \details
- * The complex constant used by this block is found from a tag
- * with the name specified by \p tag_name. The tag must contain a
- * float/double or complex PMT value that will be converted into a
- * gr_complex value. All input data is multiplied by this
- * value until a new tag with an update value is found. The block
- * starts with a value of '1.0' for the multiplier constant.
+ * \brief Create an instance of multiply_by_tag_value_cc
+ * \param tag_name Tag's key that it will use to get the
+ * multiplicative constant.
+ * \param vlen Vector length of incoming stream
*/
- class BLOCKS_API multiply_by_tag_value_cc : virtual public sync_block
- {
- public:
- // gr::blocks::multiply_by_tag_value_cc::sptr
- typedef boost::shared_ptr<multiply_by_tag_value_cc> sptr;
+ static sptr make(const std::string& tag_name, size_t vlen = 1);
- /*!
- * \brief Create an instance of multiply_by_tag_value_cc
- * \param tag_name Tag's key that it will use to get the
- * multiplicative constant.
- * \param vlen Vector length of incoming stream
- */
- static sptr make(const std::string& tag_name,
- size_t vlen=1);
-
- /*!
- * Get the current multiplicative constant.
- * This block does not allow external setters.
- */
- virtual gr_complex k() const = 0;
- };
+ /*!
+ * Get the current multiplicative constant.
+ * This block does not allow external setters.
+ */
+ virtual gr_complex k() const = 0;
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_MULTIPLY_BY_TAG_VALUE_CC_H */
diff --git a/gr-blocks/include/gnuradio/blocks/multiply_conjugate_cc.h b/gr-blocks/include/gnuradio/blocks/multiply_conjugate_cc.h
index da032da3ed..ff1e799a44 100644
--- a/gr-blocks/include/gnuradio/blocks/multiply_conjugate_cc.h
+++ b/gr-blocks/include/gnuradio/blocks/multiply_conjugate_cc.h
@@ -27,28 +27,27 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief Multiplies stream 0 by the complex conjugate of stream 1.
+ * \ingroup math_operators_blk
+ */
+class BLOCKS_API multiply_conjugate_cc : virtual public sync_block
+{
+public:
+ // gr::blocks::multiply_conjugate_cc::sptr
+ typedef boost::shared_ptr<multiply_conjugate_cc> sptr;
/*!
- * \brief Multiplies stream 0 by the complex conjugate of stream 1.
- * \ingroup math_operators_blk
+ * \brief Multiplies a streams by the conjugate of a second stream
+ * \param vlen Vector length
+ * \ingroup math_blk
*/
- class BLOCKS_API multiply_conjugate_cc : virtual public sync_block
- {
- public:
-
- // gr::blocks::multiply_conjugate_cc::sptr
- typedef boost::shared_ptr<multiply_conjugate_cc> sptr;
-
- /*!
- * \brief Multiplies a streams by the conjugate of a second stream
- * \param vlen Vector length
- * \ingroup math_blk
- */
- static sptr make(size_t vlen=1);
- };
+ static sptr make(size_t vlen = 1);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_BLOCKS_MULTIPLY_CONJUGATE_CC_H */
diff --git a/gr-blocks/include/gnuradio/blocks/multiply_const.h b/gr-blocks/include/gnuradio/blocks/multiply_const.h
index 8781d57659..7ebaffff5d 100644
--- a/gr-blocks/include/gnuradio/blocks/multiply_const.h
+++ b/gr-blocks/include/gnuradio/blocks/multiply_const.h
@@ -29,44 +29,43 @@
#include <cstdint>
namespace gr {
- namespace blocks {
+namespace blocks {
- /*!
- * \brief output = input * constant
- * \ingroup math_operators_blk
- */
-template<class T>
- class BLOCKS_API multiply_const : virtual public sync_block
- {
-
- public:
+/*!
+ * \brief output = input * constant
+ * \ingroup math_operators_blk
+ */
+template <class T>
+class BLOCKS_API multiply_const : virtual public sync_block
+{
- // gr::blocks::multiply_const::sptr
- typedef boost::shared_ptr< multiply_const<T> > sptr;
+public:
+ // gr::blocks::multiply_const::sptr
+ typedef boost::shared_ptr<multiply_const<T>> sptr;
- /*!
- * \brief Create an instance of multiply_const
- * \param k multiplicative constant
- * \param vlen number of items in vector
- */
- static sptr make(T k, size_t vlen=1);
+ /*!
+ * \brief Create an instance of multiply_const
+ * \param k multiplicative constant
+ * \param vlen number of items in vector
+ */
+ static sptr make(T k, size_t vlen = 1);
- /*!
- * \brief Return multiplicative constant
- */
- virtual T k() const = 0;
+ /*!
+ * \brief Return multiplicative constant
+ */
+ virtual T k() const = 0;
- /*!
- * \brief Set multiplicative constant
- */
- virtual void set_k(T k) = 0;
- };
+ /*!
+ * \brief Set multiplicative constant
+ */
+ virtual void set_k(T k) = 0;
+};
typedef multiply_const<std::int16_t> multiply_const_ss;
typedef multiply_const<std::int32_t> multiply_const_ii;
typedef multiply_const<float> multiply_const_ff;
typedef multiply_const<gr_complex> multiply_const_cc;
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* MULTIPLY_CONST_H */
diff --git a/gr-blocks/include/gnuradio/blocks/multiply_const_v.h b/gr-blocks/include/gnuradio/blocks/multiply_const_v.h
index b1cc2dca36..529dca260f 100644
--- a/gr-blocks/include/gnuradio/blocks/multiply_const_v.h
+++ b/gr-blocks/include/gnuradio/blocks/multiply_const_v.h
@@ -28,43 +28,42 @@
#include <cstdint>
namespace gr {
- namespace blocks {
+namespace blocks {
- /*!
- * \brief output = input * constant vector (element-wise)
- * \ingroup math_operators_blk
- */
- template <class T>
- class BLOCKS_API multiply_const_v : virtual public sync_block
- {
-
- public:
+/*!
+ * \brief output = input * constant vector (element-wise)
+ * \ingroup math_operators_blk
+ */
+template <class T>
+class BLOCKS_API multiply_const_v : virtual public sync_block
+{
- // gr::blocks::multiply_const_v::sptr
- typedef boost::shared_ptr< multiply_const_v<T> > sptr;
+public:
+ // gr::blocks::multiply_const_v::sptr
+ typedef boost::shared_ptr<multiply_const_v<T>> sptr;
- /*!
- * \brief Create an instance of multiply_const_v
- * \param k multiplicative constant vector
- */
- static sptr make(std::vector<T> k);
+ /*!
+ * \brief Create an instance of multiply_const_v
+ * \param k multiplicative constant vector
+ */
+ static sptr make(std::vector<T> k);
- /*!
- * \brief Return multiplicative constant vector
- */
- virtual std::vector<T> k() const = 0;
+ /*!
+ * \brief Return multiplicative constant vector
+ */
+ virtual std::vector<T> k() const = 0;
- /*!
- * \brief Set multiplicative constant vector
- */
- virtual void set_k(std::vector<T> k) = 0;
- };
+ /*!
+ * \brief Set multiplicative constant vector
+ */
+ virtual void set_k(std::vector<T> k) = 0;
+};
- typedef multiply_const_v<std::int16_t> multiply_const_vss;
- typedef multiply_const_v<std::int32_t> multiply_const_vii;
- typedef multiply_const_v<float> multiply_const_vff;
- typedef multiply_const_v<gr_complex> multiply_const_vcc;
- } /* namespace blocks */
+typedef multiply_const_v<std::int16_t> multiply_const_vss;
+typedef multiply_const_v<std::int32_t> multiply_const_vii;
+typedef multiply_const_v<float> multiply_const_vff;
+typedef multiply_const_v<gr_complex> multiply_const_vcc;
+} /* namespace blocks */
} /* namespace gr */
#endif /* MULTIPLY_CONST_V_H */
diff --git a/gr-blocks/include/gnuradio/blocks/multiply_matrix.h b/gr-blocks/include/gnuradio/blocks/multiply_matrix.h
index fba4930fcd..c07b8c6b1e 100644
--- a/gr-blocks/include/gnuradio/blocks/multiply_matrix.h
+++ b/gr-blocks/include/gnuradio/blocks/multiply_matrix.h
@@ -29,72 +29,74 @@
#include <cstdint>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief Matrix multiplexer/multiplier: y(k) = A x(k)
+ * \ingroup blocks
+ *
+ * This block is similar to gr::blocks::multiply_const_ff, the difference
+ * being it can handle several inputs and outputs, and the input-to-output
+ * relation can be described by the following mathematical equation:
+ * \f[
+ * \mathbf{y}(k) = \mathbf{A} \mathbf{x}(k) \, , \, y \in \mathbb{R}^N, \mathbf{x} \in
+ * \mathbb{R}^M, A \in \mathbb{R}^{N \times M} \f] \f$\mathbf{y}(k)\f$ and
+ * \f$\mathbf{x}(i)\f$ are column-vectors describing the elements on the input port at
+ * time step \f$k\f$ (this is a sync block with no memory).
+ *
+ * Examples for where to use this block include:
+ * - Switch matrices (i.e. switch which ports go where), assuming all ports run on the
+ * same rate
+ * - Simulation of static MIMO-Channels (in that case, \f$\mathbf{A}\f$ is the channel
+ * matrix)
+ * - Summing up streams with variable coefficients
+ *
+ * This block features a special tag propagation mode: When setting the tag propagation
+ * policy to gr::block::TPP_CUSTOM, a tag is propagated from input \f$k\f$ to output
+ * \f$l\f$, if \f$(A)_{l,k} \neq 0\f$.
+ *
+ * \section blocks_matrixmult_msgports_multiply_matrix Message Ports
+ *
+ * This block as one input message port (\p set_A). A message sent to this port will
+ * be converted to a std::vector<std::vector<T> >, and then passed on to set_A().
+ * If no conversion is possible, a warning is issued via the logging interface, and
+ * A remains unchanged.
+ *
+ * *Note*: It is not possible to change the dimension of the matrix after initialization,
+ * as this affects the I/O signature! If a matrix of invalid size is passed to the block,
+ * an alert is raised via the logging interface, and A remains unchanged.
+ */
+template <class T>
+class BLOCKS_API multiply_matrix : virtual public gr::sync_block
+{
+public:
+ typedef boost::shared_ptr<multiply_matrix<T>> sptr;
/*!
- * \brief Matrix multiplexer/multiplier: y(k) = A x(k)
- * \ingroup blocks
- *
- * This block is similar to gr::blocks::multiply_const_ff, the difference
- * being it can handle several inputs and outputs, and the input-to-output
- * relation can be described by the following mathematical equation:
- * \f[
- * \mathbf{y}(k) = \mathbf{A} \mathbf{x}(k) \, , \, y \in \mathbb{R}^N, \mathbf{x} \in \mathbb{R}^M, A \in \mathbb{R}^{N \times M}
- * \f]
- * \f$\mathbf{y}(k)\f$ and \f$\mathbf{x}(i)\f$ are column-vectors describing the elements on the input port
- * at time step \f$k\f$ (this is a sync block with no memory).
- *
- * Examples for where to use this block include:
- * - Switch matrices (i.e. switch which ports go where), assuming all ports run on the same rate
- * - Simulation of static MIMO-Channels (in that case, \f$\mathbf{A}\f$ is the channel matrix)
- * - Summing up streams with variable coefficients
- *
- * This block features a special tag propagation mode: When setting the tag propagation policy
- * to gr::block::TPP_CUSTOM, a tag is propagated from input \f$k\f$
- * to output \f$l\f$, if \f$(A)_{l,k} \neq 0\f$.
- *
- * \section blocks_matrixmult_msgports_multiply_matrix Message Ports
- *
- * This block as one input message port (\p set_A). A message sent to this port will
- * be converted to a std::vector<std::vector<T> >, and then passed on to set_A().
- * If no conversion is possible, a warning is issued via the logging interface, and
- * A remains unchanged.
- *
- * *Note*: It is not possible to change the dimension of the matrix after initialization,
- * as this affects the I/O signature! If a matrix of invalid size is passed to the block,
- * an alert is raised via the logging interface, and A remains unchanged.
+ * \param A The matrix
+ * \param tag_propagation_policy The tag propagation policy.
+ * Note this can be any
+ * gr::block::tag_propagation_policy_t
+ * value. In case of TPP_CUSTOM, tags are
+ * only transferred from input \f$k\f$ to
+ * output \f$l \iff (A)_{l,k} \neq 0\f$.
*/
-template<class T>
- class BLOCKS_API multiply_matrix : virtual public gr::sync_block
- {
- public:
- typedef boost::shared_ptr< multiply_matrix<T> > sptr;
-
- /*!
- * \param A The matrix
- * \param tag_propagation_policy The tag propagation policy.
- * Note this can be any
- * gr::block::tag_propagation_policy_t
- * value. In case of TPP_CUSTOM, tags are
- * only transferred from input \f$k\f$ to
- * output \f$l \iff (A)_{l,k} \neq 0\f$.
- */
- static sptr make(
- std::vector<std::vector<T> > A,
- gr::block::tag_propagation_policy_t tag_propagation_policy=gr::block::TPP_ALL_TO_ALL
- );
+ static sptr make(std::vector<std::vector<T>> A,
+ gr::block::tag_propagation_policy_t tag_propagation_policy =
+ gr::block::TPP_ALL_TO_ALL);
- //! Returns the current matrix
- virtual const std::vector<std::vector<T> >& get_A() const = 0;
- //! Sets the matrix to a new value \p new_A. Returns true if the new matrix was valid and could be changed.
- virtual bool set_A(const std::vector<std::vector<T> > &new_A) = 0;
+ //! Returns the current matrix
+ virtual const std::vector<std::vector<T>>& get_A() const = 0;
+ //! Sets the matrix to a new value \p new_A. Returns true if the new matrix was valid
+ //! and could be changed.
+ virtual bool set_A(const std::vector<std::vector<T>>& new_A) = 0;
- std::string MSG_PORT_NAME_SET_A;
- };
+ std::string MSG_PORT_NAME_SET_A;
+};
- typedef multiply_matrix<float> multiply_matrix_ff;
- typedef multiply_matrix<gr_complex> multiply_matrix_cc;
- } // namespace blocks
+typedef multiply_matrix<float> multiply_matrix_ff;
+typedef multiply_matrix<gr_complex> multiply_matrix_cc;
+} // namespace blocks
} // namespace gr
#endif /* MULTIPLY_MATRIX_H */
diff --git a/gr-blocks/include/gnuradio/blocks/mute.h b/gr-blocks/include/gnuradio/blocks/mute.h
index 1d5f3a3e22..a6ede3cca5 100644
--- a/gr-blocks/include/gnuradio/blocks/mute.h
+++ b/gr-blocks/include/gnuradio/blocks/mute.h
@@ -29,30 +29,29 @@
#include <cstdint>
namespace gr {
- namespace blocks {
+namespace blocks {
- /*!
- * \brief output = input or zero if muted.
- * \ingroup level_controllers_blk
- */
-template<class T>
- class BLOCKS_API mute_blk : virtual public sync_block
- {
- public:
- typedef boost::shared_ptr< mute_blk<T> > sptr;
+/*!
+ * \brief output = input or zero if muted.
+ * \ingroup level_controllers_blk
+ */
+template <class T>
+class BLOCKS_API mute_blk : virtual public sync_block
+{
+public:
+ typedef boost::shared_ptr<mute_blk<T>> sptr;
- static sptr make(bool mute=false);
+ static sptr make(bool mute = false);
- virtual bool mute() const = 0;
- virtual void set_mute(bool mute=false) = 0;
- };
+ virtual bool mute() const = 0;
+ virtual void set_mute(bool mute = false) = 0;
+};
typedef mute_blk<std::int16_t> mute_ss;
typedef mute_blk<std::int32_t> mute_ii;
typedef mute_blk<float> mute_ff;
typedef mute_blk<gr_complex> mute_cc;
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* MUTE_H */
-
diff --git a/gr-blocks/include/gnuradio/blocks/nlog10_ff.h b/gr-blocks/include/gnuradio/blocks/nlog10_ff.h
index e5f7d7bc2a..55bd275a3c 100644
--- a/gr-blocks/include/gnuradio/blocks/nlog10_ff.h
+++ b/gr-blocks/include/gnuradio/blocks/nlog10_ff.h
@@ -27,29 +27,28 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief output = n*log10(input) + k
+ * \ingroup math_operators_blk
+ */
+class BLOCKS_API nlog10_ff : virtual public sync_block
+{
+public:
+ // gr::blocks::nlog10_ff::sptr
+ typedef boost::shared_ptr<nlog10_ff> sptr;
/*!
- * \brief output = n*log10(input) + k
- * \ingroup math_operators_blk
+ * \brief Make an instance of an nlog10_ff block.
+ * \param n Scalar multiplicative constant
+ * \param vlen Input vector length
+ * \param k Scalar additive constant
*/
- class BLOCKS_API nlog10_ff : virtual public sync_block
- {
- public:
-
- // gr::blocks::nlog10_ff::sptr
- typedef boost::shared_ptr<nlog10_ff> sptr;
-
- /*!
- * \brief Make an instance of an nlog10_ff block.
- * \param n Scalar multiplicative constant
- * \param vlen Input vector length
- * \param k Scalar additive constant
- */
- static sptr make(float n=1.0, size_t vlen=1, float k=0.0);
- };
+ static sptr make(float n = 1.0, size_t vlen = 1, float k = 0.0);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_BLOCKS_NLOG10_FF_H */
diff --git a/gr-blocks/include/gnuradio/blocks/nop.h b/gr-blocks/include/gnuradio/blocks/nop.h
index d5b92cdd13..f5977e0c20 100644
--- a/gr-blocks/include/gnuradio/blocks/nop.h
+++ b/gr-blocks/include/gnuradio/blocks/nop.h
@@ -25,35 +25,35 @@
#include <gnuradio/blocks/api.h>
#include <gnuradio/block.h>
-#include <stddef.h> // size_t
+#include <stddef.h> // size_t
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief Does nothing. Used for testing only.
+ * \ingroup misc_blk
+ */
+class BLOCKS_API nop : virtual public block
+{
+public:
+ // gr::blocks::nop::sptr
+ typedef boost::shared_ptr<nop> sptr;
/*!
- * \brief Does nothing. Used for testing only.
- * \ingroup misc_blk
+ * Build a nop block.
+ *
+ * \param sizeof_stream_item size of the stream items in bytes.
*/
- class BLOCKS_API nop : virtual public 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;
-
- virtual int ctrlport_test() const = 0;
- virtual void set_ctrlport_test(int x) = 0;
- };
-
- } /* namespace blocks */
+ static sptr make(size_t sizeof_stream_item);
+
+ virtual int nmsgs_received() const = 0;
+
+ virtual int ctrlport_test() const = 0;
+ virtual void set_ctrlport_test(int x) = 0;
+};
+
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_GR_NOP_H */
diff --git a/gr-blocks/include/gnuradio/blocks/not_blk.h b/gr-blocks/include/gnuradio/blocks/not_blk.h
index 7484e127e5..5f4c7a1926 100644
--- a/gr-blocks/include/gnuradio/blocks/not_blk.h
+++ b/gr-blocks/include/gnuradio/blocks/not_blk.h
@@ -29,28 +29,27 @@
#include <cstdint>
namespace gr {
- namespace blocks {
+namespace blocks {
- /*!
- * \brief output = ~input
- * \ingroup boolean_operators_blk
- *
- * bitwise boolean not of input streams.
- */
-template<class T>
- class BLOCKS_API not_blk : virtual public sync_block
- {
- public:
-
- typedef boost::shared_ptr< not_blk<T> > sptr;
+/*!
+ * \brief output = ~input
+ * \ingroup boolean_operators_blk
+ *
+ * bitwise boolean not of input streams.
+ */
+template <class T>
+class BLOCKS_API not_blk : virtual public sync_block
+{
+public:
+ typedef boost::shared_ptr<not_blk<T>> sptr;
- static sptr make(size_t vlen=1);
- };
+ static sptr make(size_t vlen = 1);
+};
typedef not_blk<std::uint8_t> not_bb;
typedef not_blk<std::int16_t> not_ss;
typedef not_blk<std::int32_t> not_ii;
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* NOT_BLK_H */
diff --git a/gr-blocks/include/gnuradio/blocks/null_sink.h b/gr-blocks/include/gnuradio/blocks/null_sink.h
index cbce9b8c02..62b8ab8817 100644
--- a/gr-blocks/include/gnuradio/blocks/null_sink.h
+++ b/gr-blocks/include/gnuradio/blocks/null_sink.h
@@ -25,31 +25,31 @@
#include <gnuradio/blocks/api.h>
#include <gnuradio/sync_block.h>
-#include <stddef.h> // size_t
+#include <stddef.h> // size_t
namespace gr {
- namespace blocks {
+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 misc_blk
+ */
+class BLOCKS_API null_sink : virtual public sync_block
+{
+public:
+ // gr::blocks::null_sink::sptr
+ typedef boost::shared_ptr<null_sink> sptr;
/*!
- * \brief Bit bucket. Use as a termination point when a sink is
- * required and we don't want to do anything real.
- * \ingroup misc_blk
+ * Build a null sink block.
+ *
+ * \param sizeof_stream_item size of the stream items in bytes.
*/
- class BLOCKS_API null_sink : virtual public 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);
- };
+ static sptr make(size_t sizeof_stream_item);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_GR_NULL_SINK_H */
diff --git a/gr-blocks/include/gnuradio/blocks/null_source.h b/gr-blocks/include/gnuradio/blocks/null_source.h
index eccebe831f..40f42db4d8 100644
--- a/gr-blocks/include/gnuradio/blocks/null_source.h
+++ b/gr-blocks/include/gnuradio/blocks/null_source.h
@@ -27,27 +27,27 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief A source of zeros used mainly for testing.
+ * \ingroup misc_blk
+ */
+class BLOCKS_API null_source : virtual public sync_block
+{
+public:
+ // gr::blocks::null_source::sptr
+ typedef boost::shared_ptr<null_source> sptr;
/*!
- * \brief A source of zeros used mainly for testing.
- * \ingroup misc_blk
+ * Build a null source block.
+ *
+ * \param sizeof_stream_item size of the stream items in bytes.
*/
- class BLOCKS_API null_source : virtual public 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);
- };
+ static sptr make(size_t sizeof_stream_item);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_GR_NULL_SOURCE_H */
diff --git a/gr-blocks/include/gnuradio/blocks/or_blk.h b/gr-blocks/include/gnuradio/blocks/or_blk.h
index d84925bd13..91771d9ca2 100644
--- a/gr-blocks/include/gnuradio/blocks/or_blk.h
+++ b/gr-blocks/include/gnuradio/blocks/or_blk.h
@@ -27,29 +27,28 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- /*!
- * \brief output = input_0 | input_1 | , ... | input_N)
- * \ingroup boolean_operators_blk
- *
- * Bitwise boolean or across all input streams.
- */
- template<class T>
- class BLOCKS_API or_blk : virtual public sync_block
- {
- public:
-
- // gr::blocks::or_blk::sptr
- typedef boost::shared_ptr<or_blk<T> > sptr;
-
- static sptr make(size_t vlen=1);
- };
-
- typedef or_blk<short> or_ss;
- typedef or_blk<int> or_ii;
- typedef or_blk<char> or_bb;
- } /* namespace blocks */
+/*!
+ * \brief output = input_0 | input_1 | , ... | input_N)
+ * \ingroup boolean_operators_blk
+ *
+ * Bitwise boolean or across all input streams.
+ */
+template <class T>
+class BLOCKS_API or_blk : virtual public sync_block
+{
+public:
+ // gr::blocks::or_blk::sptr
+ typedef boost::shared_ptr<or_blk<T>> sptr;
+
+ static sptr make(size_t vlen = 1);
+};
+
+typedef or_blk<short> or_ss;
+typedef or_blk<int> or_ii;
+typedef or_blk<char> or_bb;
+} /* namespace blocks */
} /* namespace gr */
#endif /* OR_BLK_H */
diff --git a/gr-blocks/include/gnuradio/blocks/pack_k_bits.h b/gr-blocks/include/gnuradio/blocks/pack_k_bits.h
index 4197225ad4..a887c009d9 100644
--- a/gr-blocks/include/gnuradio/blocks/pack_k_bits.h
+++ b/gr-blocks/include/gnuradio/blocks/pack_k_bits.h
@@ -21,65 +21,65 @@
*/
#ifndef INCLUDED_GR_BLOCKS_PACK_K_BITS_H
-#define INCLUDED_GR_BLOCKS_PACK_K_BITS_H
+#define INCLUDED_GR_BLOCKS_PACK_K_BITS_H
#include <gnuradio/blocks/api.h>
#include <vector>
namespace gr {
- namespace blocks {
- namespace kernel {
+namespace blocks {
+namespace kernel {
- /*!
- * \brief Converts a vector of bytes with 1 bit in the LSB to a
- * byte with k relevant bits.
- *
- * Example:
- * k = 4
- * in = [0,1,0,1, 0x81,0x00,0x00,0x00]
- * out = [0x05, 0x08]
- *
- * k = 8
- * in = [1,1,1,1, 0,1,0,1, 0,0,0,0, 1,0,0,0]
- * out = [0xf5, 0x08]
- * \ingroup byte_operators_blk
- */
- class BLOCKS_API pack_k_bits
- {
- public:
- /*!
- * \brief Make a pack_k_bits object.
- * \param k number of bits to be packed.
- */
- pack_k_bits(unsigned k);
- ~pack_k_bits();
+/*!
+ * \brief Converts a vector of bytes with 1 bit in the LSB to a
+ * byte with k relevant bits.
+ *
+ * Example:
+ * k = 4
+ * in = [0,1,0,1, 0x81,0x00,0x00,0x00]
+ * out = [0x05, 0x08]
+ *
+ * k = 8
+ * in = [1,1,1,1, 0,1,0,1, 0,0,0,0, 1,0,0,0]
+ * out = [0xf5, 0x08]
+ * \ingroup byte_operators_blk
+ */
+class BLOCKS_API pack_k_bits
+{
+public:
+ /*!
+ * \brief Make a pack_k_bits object.
+ * \param k number of bits to be packed.
+ */
+ pack_k_bits(unsigned k);
+ ~pack_k_bits();
- /*!
- * \brief Perform the packing.
- *
- * This block performs no bounds checking. It assumes that the
- * input, \p in, has of length k*nbytes and that the output
- * vector, \p out, has \p nbytes available for writing.
- *
- * \param bytes output vector (k-bits per byte) of the unpacked data
- * \param bits The input vector of bits to pack
- * \param nbytes The number of output bytes
- */
- void pack(unsigned char *bytes, const unsigned char *bits, int nbytes) const;
+ /*!
+ * \brief Perform the packing.
+ *
+ * This block performs no bounds checking. It assumes that the
+ * input, \p in, has of length k*nbytes and that the output
+ * vector, \p out, has \p nbytes available for writing.
+ *
+ * \param bytes output vector (k-bits per byte) of the unpacked data
+ * \param bits The input vector of bits to pack
+ * \param nbytes The number of output bytes
+ */
+ void pack(unsigned char* bytes, const unsigned char* bits, int nbytes) const;
- /*!
- * Same as pack() but reverses the bits.
- */
- void pack_rev(unsigned char *bytes, const unsigned char *bits, int nbytes) const;
+ /*!
+ * Same as pack() but reverses the bits.
+ */
+ void pack_rev(unsigned char* bytes, const unsigned char* bits, int nbytes) const;
- int k() const;
+ int k() const;
- private:
- unsigned d_k;
- };
+private:
+ unsigned d_k;
+};
- } /* namespace kernel */
- } /* namespace blocks */
+} /* namespace kernel */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_GR_BLOCKS_PACK_K_BITS_H */
diff --git a/gr-blocks/include/gnuradio/blocks/pack_k_bits_bb.h b/gr-blocks/include/gnuradio/blocks/pack_k_bits_bb.h
index d71e73c580..bef2dfc0ef 100644
--- a/gr-blocks/include/gnuradio/blocks/pack_k_bits_bb.h
+++ b/gr-blocks/include/gnuradio/blocks/pack_k_bits_bb.h
@@ -21,42 +21,42 @@
*/
#ifndef INCLUDED_GR_PACK_K_BITS_BB_H
-#define INCLUDED_GR_PACK_K_BITS_BB_H
+#define INCLUDED_GR_PACK_K_BITS_BB_H
#include <gnuradio/blocks/api.h>
#include <gnuradio/sync_decimator.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief Converts a stream of bytes with 1 bit in the LSB to a
+ * byte with k relevant bits.
+ *
+ * This block takes in K bytes at a time, and uses the least significant
+ * bit to form a new byte.
+ *
+ * Example:
+ * k = 4
+ * in = [0,1,0,1, 0x81,0x00,0x00,0x00]
+ * out = [0x05, 0x08]
+ *
+ * \ingroup byte_operators_blk
+ */
+class BLOCKS_API pack_k_bits_bb : virtual public sync_decimator
+{
+public:
+ // gr::blocks::pack_k_bits_bb::sptr
+ typedef boost::shared_ptr<pack_k_bits_bb> sptr;
/*!
- * \brief Converts a stream of bytes with 1 bit in the LSB to a
- * byte with k relevant bits.
- *
- * This block takes in K bytes at a time, and uses the least significant
- * bit to form a new byte.
- *
- * Example:
- * k = 4
- * in = [0,1,0,1, 0x81,0x00,0x00,0x00]
- * out = [0x05, 0x08]
- *
- * \ingroup byte_operators_blk
+ * \brief Make a pack_k_bits block.
+ * \param k number of bits to be packed.
*/
- class BLOCKS_API pack_k_bits_bb : virtual public 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);
- };
+ static sptr make(unsigned k);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_GR_PACK_K_BITS_BB_H */
diff --git a/gr-blocks/include/gnuradio/blocks/packed_to_unpacked.h b/gr-blocks/include/gnuradio/blocks/packed_to_unpacked.h
index 0a9c0d7c3c..0c384af56a 100644
--- a/gr-blocks/include/gnuradio/blocks/packed_to_unpacked.h
+++ b/gr-blocks/include/gnuradio/blocks/packed_to_unpacked.h
@@ -30,49 +30,48 @@
#include <cstdint>
namespace gr {
- namespace blocks {
+namespace blocks {
- /*!
- * \brief Convert a stream of packed bytes or shorts to stream of unpacked bytes or shorts.
- * \ingroup byte_operators_blk
- *
- * \details
- * input: stream of T; output: stream of T
- *
- * This is the inverse of gr::blocks::unpacked_to_packed_XX.
- *
- * The bits in the bytes or shorts input stream are grouped into
- * chunks of \p bits_per_chunk bits and each resulting chunk is
- * written right- justified to the output stream of bytes or
- * shorts. All b or 16 bits of the each input bytes or short are
- * processed. The right thing is done if bits_per_chunk is not a
- * power of two.
- *
- * The combination of gr::blocks::packed_to_unpacked_XX_ followed by
- * gr_chunks_to_symbols_Xf or gr_chunks_to_symbols_Xc handles the
- * general case of mapping from a stream of bytes or shorts into
- * arbitrary float or complex symbols.
- *
- * \sa gr::blocks::packed_to_unpacked_bb, gr::blocks::unpacked_to_packed_bb,
- * \sa gr::blocks::packed_to_unpacked_ss, gr::blocks::unpacked_to_packed_ss,
- * \sa gr::blocks::chunks_to_symbols_bf, gr::blocks::chunks_to_symbols_bc.
- * \sa gr::blocks::chunks_to_symbols_sf, gr::blocks::chunks_to_symbols_sc.
- */
-template<class T>
- class BLOCKS_API packed_to_unpacked : virtual public block
- {
- public:
- // gr::blocks::packed_to_unpacked::sptr
- typedef boost::shared_ptr< packed_to_unpacked<T> > sptr;
+/*!
+ * \brief Convert a stream of packed bytes or shorts to stream of unpacked bytes or
+ * shorts. \ingroup byte_operators_blk
+ *
+ * \details
+ * input: stream of T; output: stream of T
+ *
+ * This is the inverse of gr::blocks::unpacked_to_packed_XX.
+ *
+ * The bits in the bytes or shorts input stream are grouped into
+ * chunks of \p bits_per_chunk bits and each resulting chunk is
+ * written right- justified to the output stream of bytes or
+ * shorts. All b or 16 bits of the each input bytes or short are
+ * processed. The right thing is done if bits_per_chunk is not a
+ * power of two.
+ *
+ * The combination of gr::blocks::packed_to_unpacked_XX_ followed by
+ * gr_chunks_to_symbols_Xf or gr_chunks_to_symbols_Xc handles the
+ * general case of mapping from a stream of bytes or shorts into
+ * arbitrary float or complex symbols.
+ *
+ * \sa gr::blocks::packed_to_unpacked_bb, gr::blocks::unpacked_to_packed_bb,
+ * \sa gr::blocks::packed_to_unpacked_ss, gr::blocks::unpacked_to_packed_ss,
+ * \sa gr::blocks::chunks_to_symbols_bf, gr::blocks::chunks_to_symbols_bc.
+ * \sa gr::blocks::chunks_to_symbols_sf, gr::blocks::chunks_to_symbols_sc.
+ */
+template <class T>
+class BLOCKS_API packed_to_unpacked : virtual public block
+{
+public:
+ // gr::blocks::packed_to_unpacked::sptr
+ typedef boost::shared_ptr<packed_to_unpacked<T>> sptr;
- static sptr make(unsigned int bits_per_chunk,
- endianness_t endianness);
- };
+ static sptr make(unsigned int bits_per_chunk, endianness_t endianness);
+};
typedef packed_to_unpacked<std::uint8_t> packed_to_unpacked_bb;
typedef packed_to_unpacked<std::int16_t> packed_to_unpacked_ss;
typedef packed_to_unpacked<std::int32_t> packed_to_unpacked_ii;
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* PACKED_TO_UNPACKED_H */
diff --git a/gr-blocks/include/gnuradio/blocks/patterned_interleaver.h b/gr-blocks/include/gnuradio/blocks/patterned_interleaver.h
index ad3d1e9c8e..05c3e07414 100644
--- a/gr-blocks/include/gnuradio/blocks/patterned_interleaver.h
+++ b/gr-blocks/include/gnuradio/blocks/patterned_interleaver.h
@@ -27,28 +27,27 @@
#include <gnuradio/block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief Interleave items based on the provided vector \p pattern.
+ * \ingroup stream_operators_blk
+ */
+class BLOCKS_API patterned_interleaver : virtual public block
+{
+public:
+ typedef boost::shared_ptr<patterned_interleaver> sptr;
/*!
- * \brief Interleave items based on the provided vector \p pattern.
- * \ingroup stream_operators_blk
+ * Make a patterned interleaver block.
+ *
+ * \param itemsize stream itemsize
+ * \param pattern vector that represents the interleaving pattern
*/
- class BLOCKS_API patterned_interleaver : virtual public block
- {
- public:
- typedef boost::shared_ptr<patterned_interleaver> sptr;
+ static sptr make(size_t itemsize, std::vector<int> pattern);
+};
- /*!
- * Make a patterned interleaver block.
- *
- * \param itemsize stream itemsize
- * \param pattern vector that represents the interleaving pattern
- */
- static sptr make(size_t itemsize, std::vector<int> pattern);
- };
-
- }
-}
+} // namespace blocks
+} // namespace gr
#endif /* INCLUDED_BLOCKS_PATTERNED_INTERLEAVER_H */
-
diff --git a/gr-blocks/include/gnuradio/blocks/pdu.h b/gr-blocks/include/gnuradio/blocks/pdu.h
index f33575fcf9..86515d5d3f 100644
--- a/gr-blocks/include/gnuradio/blocks/pdu.h
+++ b/gr-blocks/include/gnuradio/blocks/pdu.h
@@ -29,18 +29,18 @@
namespace gr {
- namespace blocks {
- namespace pdu {
- enum vector_type { byte_t, float_t, complex_t };
+namespace blocks {
+namespace pdu {
+enum vector_type { byte_t, float_t, complex_t };
- BLOCKS_API const pmt::pmt_t pdu_port_id();
- 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_pdu_vector(vector_type type, const uint8_t* buf, size_t items);
- BLOCKS_API vector_type type_from_pmt(pmt::pmt_t vector);
+BLOCKS_API const pmt::pmt_t pdu_port_id();
+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_pdu_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 pdu */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_BLOCKS_PDU_H */
diff --git a/gr-blocks/include/gnuradio/blocks/pdu_filter.h b/gr-blocks/include/gnuradio/blocks/pdu_filter.h
index 25dd185934..f98eb2d7fb 100644
--- a/gr-blocks/include/gnuradio/blocks/pdu_filter.h
+++ b/gr-blocks/include/gnuradio/blocks/pdu_filter.h
@@ -27,29 +27,29 @@
#include <gnuradio/block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief Propagates only pdus containing k=>v in meta
+ * \ingroup message_tools_blk
+ * \ingroup debug_tools_blk
+ */
+class BLOCKS_API pdu_filter : virtual public block
+{
+public:
+ // gr::blocks::pdu_filter::sptr
+ typedef boost::shared_ptr<pdu_filter> sptr;
/*!
- * \brief Propagates only pdus containing k=>v in meta
- * \ingroup message_tools_blk
- * \ingroup debug_tools_blk
+ * \brief Construct a PDU filter
*/
- class BLOCKS_API pdu_filter : virtual public block
- {
- public:
- // gr::blocks::pdu_filter::sptr
- typedef boost::shared_ptr<pdu_filter> sptr;
-
- /*!
- * \brief Construct a PDU filter
- */
- static sptr make(pmt::pmt_t k, pmt::pmt_t v, bool invert = false);
- virtual void set_key(pmt::pmt_t key) = 0;
- virtual void set_val(pmt::pmt_t val) = 0;
- virtual void set_inversion(bool invert) = 0;
- };
+ static sptr make(pmt::pmt_t k, pmt::pmt_t v, bool invert = false);
+ virtual void set_key(pmt::pmt_t key) = 0;
+ virtual void set_val(pmt::pmt_t val) = 0;
+ virtual void set_inversion(bool invert) = 0;
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_BLOCKS_PDU_FILTER_H */
diff --git a/gr-blocks/include/gnuradio/blocks/pdu_remove.h b/gr-blocks/include/gnuradio/blocks/pdu_remove.h
index f2ab35f7cf..472729e549 100644
--- a/gr-blocks/include/gnuradio/blocks/pdu_remove.h
+++ b/gr-blocks/include/gnuradio/blocks/pdu_remove.h
@@ -27,27 +27,27 @@
#include <gnuradio/block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief remove key k in pdu's meta field and pass on
+ * \ingroup message_tools_blk
+ * \ingroup debug_tools_blk
+ */
+class BLOCKS_API pdu_remove : virtual public block
+{
+public:
+ // gr::blocks::pdu_remove::sptr
+ typedef boost::shared_ptr<pdu_remove> sptr;
/*!
- * \brief remove key k in pdu's meta field and pass on
- * \ingroup message_tools_blk
- * \ingroup debug_tools_blk
+ * \brief Construct a PDU meta remove block
*/
- class BLOCKS_API pdu_remove : virtual public block
- {
- public:
- // gr::blocks::pdu_remove::sptr
- typedef boost::shared_ptr<pdu_remove> sptr;
-
- /*!
- * \brief Construct a PDU meta remove block
- */
- static sptr make(pmt::pmt_t k);
- virtual void set_key(pmt::pmt_t key) = 0;
- };
+ static sptr make(pmt::pmt_t k);
+ virtual void set_key(pmt::pmt_t key) = 0;
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_BLOCKS_PDU_REMOVE_H */
diff --git a/gr-blocks/include/gnuradio/blocks/pdu_set.h b/gr-blocks/include/gnuradio/blocks/pdu_set.h
index ba96492b61..c0874bbad5 100644
--- a/gr-blocks/include/gnuradio/blocks/pdu_set.h
+++ b/gr-blocks/include/gnuradio/blocks/pdu_set.h
@@ -27,28 +27,28 @@
#include <gnuradio/block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief Set k=>v in pdu's meta field and pass on
+ * \ingroup message_tools_blk
+ * \ingroup debug_tools_blk
+ */
+class BLOCKS_API pdu_set : virtual public block
+{
+public:
+ // gr::blocks::pdu_set::sptr
+ typedef boost::shared_ptr<pdu_set> sptr;
/*!
- * \brief Set k=>v in pdu's meta field and pass on
- * \ingroup message_tools_blk
- * \ingroup debug_tools_blk
+ * \brief Construct a PDU meta set block
*/
- class BLOCKS_API pdu_set : virtual public block
- {
- public:
- // gr::blocks::pdu_set::sptr
- typedef boost::shared_ptr<pdu_set> sptr;
-
- /*!
- * \brief Construct a PDU meta set block
- */
- static sptr make(pmt::pmt_t k, pmt::pmt_t v);
- virtual void set_key(pmt::pmt_t key) = 0;
- virtual void set_val(pmt::pmt_t val) = 0;
- };
+ static sptr make(pmt::pmt_t k, pmt::pmt_t v);
+ virtual void set_key(pmt::pmt_t key) = 0;
+ virtual void set_val(pmt::pmt_t val) = 0;
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_BLOCKS_PDU_SET_H */
diff --git a/gr-blocks/include/gnuradio/blocks/pdu_to_tagged_stream.h b/gr-blocks/include/gnuradio/blocks/pdu_to_tagged_stream.h
index 479e367e72..fe21df7b15 100644
--- a/gr-blocks/include/gnuradio/blocks/pdu_to_tagged_stream.h
+++ b/gr-blocks/include/gnuradio/blocks/pdu_to_tagged_stream.h
@@ -28,29 +28,29 @@
#include <gnuradio/tagged_stream_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief Turns received PDUs into a tagged stream of items
+ * \ingroup message_tools_blk
+ */
+class BLOCKS_API pdu_to_tagged_stream : virtual public tagged_stream_block
+{
+public:
+ // gr::blocks::pdu_to_tagged_stream::sptr
+ typedef boost::shared_ptr<pdu_to_tagged_stream> sptr;
/*!
- * \brief Turns received PDUs into a tagged stream of items
- * \ingroup message_tools_blk
+ * \brief Construct a pdu_to_tagged_stream block
+ * \param type PDU type of pdu::vector_type
+ * \param lengthtagname The name of the tag that specifies how long the packet is.
+ * Defaults to 'packet_len'.
*/
- class BLOCKS_API pdu_to_tagged_stream : virtual public tagged_stream_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
- * \param lengthtagname The name of the tag that specifies how long the packet is.
- * Defaults to 'packet_len'.
- */
- static sptr make(pdu::vector_type type,
- const std::string& lengthtagname="packet_len");
- };
+ static sptr make(pdu::vector_type type,
+ const std::string& lengthtagname = "packet_len");
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_BLOCKS_PDU_TO_TAGGED_STREAM_H */
diff --git a/gr-blocks/include/gnuradio/blocks/peak_detector.h b/gr-blocks/include/gnuradio/blocks/peak_detector.h
index 4cc7dbd627..8dfe609b51 100644
--- a/gr-blocks/include/gnuradio/blocks/peak_detector.h
+++ b/gr-blocks/include/gnuradio/blocks/peak_detector.h
@@ -28,94 +28,94 @@
#include <cstdint>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief Detect the peak of a signal
+ * \ingroup peak_detectors_blk
+ *
+ * \details
+ * If a peak is detected, this block outputs a 1,
+ * or it outputs 0's.
+ */
+template <class T>
+class BLOCKS_API peak_detector : virtual public sync_block
+{
+public:
+ typedef boost::shared_ptr<peak_detector<T>> sptr;
/*!
- * \brief Detect the peak of a signal
- * \ingroup peak_detectors_blk
+ * Make a peak detector block.
*
- * \details
- * If a peak is detected, this block outputs a 1,
- * or it outputs 0's.
+ * \param threshold_factor_rise The threshold factor determines
+ * 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 determines
+ * when a peak has ended. An average of the signal is
+ * calculated and when the value of the signal goes
+ * below 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
*/
- template <class T>
- class BLOCKS_API peak_detector : virtual public sync_block
- {
- public:
- typedef boost::shared_ptr< peak_detector<T> > sptr;
-
- /*!
- * Make a peak detector block.
- *
- * \param threshold_factor_rise The threshold factor determines
- * 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 determines
- * when a peak has ended. An average of the signal is
- * calculated and when the value of the signal goes
- * below 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(float 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;
- };
-
- typedef peak_detector<float> peak_detector_fb;
- typedef peak_detector<std::int32_t> peak_detector_ib;
- typedef peak_detector<std::int16_t> peak_detector_sb;
-
- } /* namespace blocks */
+ virtual void set_alpha(float 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;
+};
+
+typedef peak_detector<float> peak_detector_fb;
+typedef peak_detector<std::int32_t> peak_detector_ib;
+typedef peak_detector<std::int16_t> peak_detector_sb;
+
+} /* namespace blocks */
} /* namespace gr */
#endif /* PEAK_DETECTOR_H */
diff --git a/gr-blocks/include/gnuradio/blocks/peak_detector2_fb.h b/gr-blocks/include/gnuradio/blocks/peak_detector2_fb.h
index 541dd8aa09..f2adee671f 100644
--- a/gr-blocks/include/gnuradio/blocks/peak_detector2_fb.h
+++ b/gr-blocks/include/gnuradio/blocks/peak_detector2_fb.h
@@ -27,77 +27,77 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief Detect the peak of a signal
+ * \ingroup peak_detectors_blk
+ *
+ * \details
+ * If a peak is detected, this block outputs a 1, or it outputs
+ * 0's. A separate debug output may be connected, to view the
+ * internal estimated mean described below.
+ */
+class BLOCKS_API peak_detector2_fb : virtual public sync_block
+{
+public:
+ // gr::blocks::peak_detector2_fb::sptr
+ typedef boost::shared_ptr<peak_detector2_fb> sptr;
/*!
- * \brief Detect the peak of a signal
- * \ingroup peak_detectors_blk
+ * Build a peak detector block with float in, byte out.
*
- * \details
- * If a peak is detected, this block outputs a 1, or it outputs
- * 0's. A separate debug output may be connected, to view the
- * internal estimated mean described below.
+ * \param threshold_factor_rise The threshold factor determines
+ * when a peak is present. An average of the input signal
+ * is calculated (through a single-pole autoregressive
+ * filter) and when the value of the input signal goes
+ * over threshold_factor_rise*average, we assume we are
+ * in the neighborhood of a peak. The block will then
+ * find the position of the maximum within a window of
+ * look_ahead samples starting at the point where the
+ * threshold was crossed upwards.
+ * \param look_ahead The look-ahead value is used when the
+ * threshold is crossed upwards to locate the peak within
+ * this range.
+ * \param alpha One minus the pole of a single-pole
+ * autoregressive filter that evaluates the average of
+ * the input signal.
*/
- class BLOCKS_API peak_detector2_fb : virtual public sync_block
- {
- public:
- // gr::blocks::peak_detector2_fb::sptr
- typedef boost::shared_ptr<peak_detector2_fb> sptr;
+ static sptr
+ make(float threshold_factor_rise = 7, int look_ahead = 1000, float alpha = 0.001);
- /*!
- * Build a peak detector block with float in, byte out.
- *
- * \param threshold_factor_rise The threshold factor determines
- * when a peak is present. An average of the input signal
- * is calculated (through a single-pole autoregressive
- * filter) and when the value of the input signal goes
- * over threshold_factor_rise*average, we assume we are
- * in the neighborhood of a peak. The block will then
- * find the position of the maximum within a window of
- * look_ahead samples starting at the point where the
- * threshold was crossed upwards.
- * \param look_ahead The look-ahead value is used when the
- * threshold is crossed upwards to locate the peak within
- * this range.
- * \param alpha One minus the pole of a single-pole
- * autoregressive filter that evaluates the average of
- * the input signal.
- */
- static sptr make(float threshold_factor_rise=7,
- int look_ahead=1000, 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 rise time
+ * \param thr new threshold factor
+ */
+ virtual void set_threshold_factor_rise(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 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(float alpha) = 0;
+ /*! \brief Set the running average alpha
+ * \param alpha new alpha for running average
+ */
+ virtual void set_alpha(float 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 rise time
+ * \return threshold factor
+ */
+ virtual float threshold_factor_rise() = 0;
- /*! \brief Get the look-ahead factor value
- * \return look-ahead factor
- */
- virtual int look_ahead() = 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;
- };
+ /*! \brief Get the alpha value of the running average
+ * \return alpha
+ */
+ virtual float alpha() = 0;
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_GR_PEAK_DETECTOR2_FB_H */
diff --git a/gr-blocks/include/gnuradio/blocks/plateau_detector_fb.h b/gr-blocks/include/gnuradio/blocks/plateau_detector_fb.h
index 9a9d7c8a16..efad9231e6 100644
--- a/gr-blocks/include/gnuradio/blocks/plateau_detector_fb.h
+++ b/gr-blocks/include/gnuradio/blocks/plateau_detector_fb.h
@@ -28,46 +28,45 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief Detects a plateau and marks the middle.
+ * \ingroup peak_detectors_blk
+ *
+ * \details
+ * 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.
+ */
+class BLOCKS_API plateau_detector_fb : virtual public block
+{
+public:
+ typedef boost::shared_ptr<plateau_detector_fb> sptr;
/*!
- * \brief Detects a plateau and marks the middle.
- * \ingroup peak_detectors_blk
- *
- * \details
- * 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.
+ * \param max_len Maximum length of the plateau
+ * \param threshold Anything above this value is considered a plateau
*/
- class BLOCKS_API plateau_detector_fb : virtual public block
- {
- public:
- typedef boost::shared_ptr<plateau_detector_fb> sptr;
+ static sptr make(int max_len, float threshold = 0.9);
- /*!
- * \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);
+ virtual void set_threshold(float threshold) = 0;
+ virtual float threshold() const = 0;
+};
- virtual void set_threshold(float threshold) = 0;
- virtual float threshold() const = 0;
- };
-
- } // namespace blocks
+} // namespace blocks
} // namespace gr
#endif /* INCLUDED_BLOCKS_PLATEAU_DETECTOR_FB_H */
-
diff --git a/gr-blocks/include/gnuradio/blocks/probe_rate.h b/gr-blocks/include/gnuradio/blocks/probe_rate.h
index a941d10279..db235d1224 100644
--- a/gr-blocks/include/gnuradio/blocks/probe_rate.h
+++ b/gr-blocks/include/gnuradio/blocks/probe_rate.h
@@ -27,35 +27,36 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief throughput measurement
+ * \ingroup measurement_tools_blk
+ */
+class BLOCKS_API probe_rate : virtual public sync_block
+{
+public:
+ // gr::blocks::probe_rate::sptr
+ typedef boost::shared_ptr<probe_rate> sptr;
/*!
- * \brief throughput measurement
- * \ingroup measurement_tools_blk
+ * \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
*/
- class BLOCKS_API probe_rate : virtual public 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);
+ static sptr
+ make(size_t itemsize, double update_rate_ms = 500.0, double alpha = 0.0001);
- virtual void set_alpha(double alpha) = 0;
+ virtual void set_alpha(double alpha) = 0;
- virtual double rate() = 0;
+ virtual double rate() = 0;
- virtual bool start() = 0;
- virtual bool stop() = 0;
- };
+ virtual bool start() = 0;
+ virtual bool stop() = 0;
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_BLOCKS_PROBE_RATE_H */
diff --git a/gr-blocks/include/gnuradio/blocks/probe_signal.h b/gr-blocks/include/gnuradio/blocks/probe_signal.h
index 39754ed7a0..9a7078cc6a 100644
--- a/gr-blocks/include/gnuradio/blocks/probe_signal.h
+++ b/gr-blocks/include/gnuradio/blocks/probe_signal.h
@@ -29,30 +29,30 @@
#include <cstdint>
namespace gr {
- namespace blocks {
+namespace blocks {
- /*!
- * \brief Sink that allows a sample to be grabbed from Python.
- * \ingroup measurement_tools_blk
- */
-template<class T>
- class BLOCKS_API probe_signal : virtual public sync_block
- {
- public:
- // gr::blocks::probe_signal::sptr
- typedef boost::shared_ptr< probe_signal<T> > sptr;
+/*!
+ * \brief Sink that allows a sample to be grabbed from Python.
+ * \ingroup measurement_tools_blk
+ */
+template <class T>
+class BLOCKS_API probe_signal : virtual public sync_block
+{
+public:
+ // gr::blocks::probe_signal::sptr
+ typedef boost::shared_ptr<probe_signal<T>> sptr;
- static sptr make();
+ static sptr make();
- virtual T level() const = 0;
- };
+ virtual T level() const = 0;
+};
typedef probe_signal<std::uint8_t> probe_signal_b;
typedef probe_signal<std::int16_t> probe_signal_s;
typedef probe_signal<std::int32_t> probe_signal_i;
typedef probe_signal<float> probe_signal_f;
typedef probe_signal<gr_complex> probe_signal_c;
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* PROBE_SIGNAL_H */
diff --git a/gr-blocks/include/gnuradio/blocks/probe_signal_v.h b/gr-blocks/include/gnuradio/blocks/probe_signal_v.h
index 2d088cbd5f..f3e43fe2fb 100644
--- a/gr-blocks/include/gnuradio/blocks/probe_signal_v.h
+++ b/gr-blocks/include/gnuradio/blocks/probe_signal_v.h
@@ -29,31 +29,31 @@
#include <cstdint>
namespace gr {
- namespace blocks {
-
- /*!
- * \brief Sink that allows a vector of samples to be grabbed from Python.
- * \ingroup sink_blk
- * \ingroup measurement_tools_blk
- */
- template <class T>
- class BLOCKS_API probe_signal_v : virtual public sync_block
- {
- public:
- typedef boost::shared_ptr< probe_signal_v<T> > sptr;
-
- static sptr make(size_t size);
-
- virtual std::vector<T> level() const = 0;
- };
-
- typedef probe_signal_v<std::uint8_t> probe_signal_vb;
- typedef probe_signal_v<std::int16_t> probe_signal_vs;
- typedef probe_signal_v<std::int32_t> probe_signal_vi;
- typedef probe_signal_v<float> probe_signal_vf;
- typedef probe_signal_v<gr_complex> probe_signal_vc;
-
- } /* namespace blocks */
+namespace blocks {
+
+/*!
+ * \brief Sink that allows a vector of samples to be grabbed from Python.
+ * \ingroup sink_blk
+ * \ingroup measurement_tools_blk
+ */
+template <class T>
+class BLOCKS_API probe_signal_v : virtual public sync_block
+{
+public:
+ typedef boost::shared_ptr<probe_signal_v<T>> sptr;
+
+ static sptr make(size_t size);
+
+ virtual std::vector<T> level() const = 0;
+};
+
+typedef probe_signal_v<std::uint8_t> probe_signal_vb;
+typedef probe_signal_v<std::int16_t> probe_signal_vs;
+typedef probe_signal_v<std::int32_t> probe_signal_vi;
+typedef probe_signal_v<float> probe_signal_vf;
+typedef probe_signal_v<gr_complex> probe_signal_vc;
+
+} /* namespace blocks */
} /* namespace gr */
#endif /* PROBE_SIGNAL_V_H */
diff --git a/gr-blocks/include/gnuradio/blocks/random_pdu.h b/gr-blocks/include/gnuradio/blocks/random_pdu.h
index 2f9e1bfd5e..6bbc506fe0 100644
--- a/gr-blocks/include/gnuradio/blocks/random_pdu.h
+++ b/gr-blocks/include/gnuradio/blocks/random_pdu.h
@@ -27,26 +27,27 @@
#include <gnuradio/block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief Sends a random PDU at intervals
+ * \ingroup message_tools_blk
+ * \ingroup debug_tools_blk
+ */
+class BLOCKS_API random_pdu : virtual public block
+{
+public:
+ // gr::blocks::random_pdu::sptr
+ typedef boost::shared_ptr<random_pdu> sptr;
/*!
- * \brief Sends a random PDU at intervals
- * \ingroup message_tools_blk
- * \ingroup debug_tools_blk
+ * \brief Construct a random PDU generator
*/
- class BLOCKS_API random_pdu : virtual public block
- {
- public:
- // gr::blocks::random_pdu::sptr
- typedef boost::shared_ptr<random_pdu> sptr;
-
- /*!
- * \brief Construct a random PDU generator
- */
- static sptr make(int mintime, int maxtime, unsigned char byte_mask = 0xFF, int length_modulo = 1);
- };
+ static sptr
+ make(int mintime, int maxtime, unsigned char byte_mask = 0xFF, int length_modulo = 1);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_BLOCKS_RANDOM_PDU_H */
diff --git a/gr-blocks/include/gnuradio/blocks/regenerate_bb.h b/gr-blocks/include/gnuradio/blocks/regenerate_bb.h
index 81949a164e..e4181a9c43 100644
--- a/gr-blocks/include/gnuradio/blocks/regenerate_bb.h
+++ b/gr-blocks/include/gnuradio/blocks/regenerate_bb.h
@@ -27,55 +27,55 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief Detect the peak of a signal and repeat every period samples
+ * \ingroup stream_operators_blk
+ *
+ * \details
+ * If a peak is detected, this block outputs a 1 repeated every
+ * period samples until reset by detection of another 1 on the
+ * input or stopped after max_regen regenerations have occurred.
+ *
+ * Note that if max_regen=(-1)/ULONG_MAX then the regeneration
+ * will run forever.
+ */
+class BLOCKS_API regenerate_bb : virtual public sync_block
+{
+public:
+ // gr::blocks::regenerate_bb::sptr
+ typedef boost::shared_ptr<regenerate_bb> sptr;
/*!
- * \brief Detect the peak of a signal and repeat every period samples
- * \ingroup stream_operators_blk
- *
- * \details
- * If a peak is detected, this block outputs a 1 repeated every
- * period samples until reset by detection of another 1 on the
- * input or stopped after max_regen regenerations have occurred.
- *
- * Note that if max_regen=(-1)/ULONG_MAX then the regeneration
- * will run forever.
+ * \brief Make a regenerate block
+ * \param period The number of samples between regenerations
+ * \param max_regen The maximum number of regenerations to
+ * perform; if set to ULONG_MAX, it will regenerate
+ * continuously.
*/
- class BLOCKS_API regenerate_bb : virtual public sync_block
- {
- public:
- // gr::blocks::regenerate_bb::sptr
- typedef boost::shared_ptr<regenerate_bb> sptr;
+ static sptr make(int period, unsigned int max_regen = 500);
- /*!
- * \brief Make a regenerate block
- * \param period The number of samples between regenerations
- * \param max_regen The maximum number of regenerations to
- * perform; if set to ULONG_MAX, it will regenerate
- * continuously.
- */
- static sptr make(int period, unsigned int max_regen=500);
-
- /*! \brief Reset the maximum regeneration count; this will reset
- the current regen.
- */
- virtual void set_max_regen(unsigned int regen) = 0;
+ /*! \brief Reset the maximum regeneration count; this will reset
+ the current regen.
+ */
+ virtual void set_max_regen(unsigned int regen) = 0;
- /*! \brief Reset the period of regenerations; this will reset
- the current regen.
- */
- virtual void set_period(int period) = 0;
+ /*! \brief Reset the period of regenerations; this will reset
+ the current regen.
+ */
+ virtual void set_period(int period) = 0;
- /*! \brief return the maximum regeneration count.
- */
- virtual unsigned int max_regen() const = 0;
+ /*! \brief return the maximum regeneration count.
+ */
+ virtual unsigned int max_regen() const = 0;
- /*! \brief return the regeneration period.
- */
- virtual int period() const = 0;
- };
+ /*! \brief return the regeneration period.
+ */
+ virtual int period() const = 0;
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_GR_REGENERATE_BB_H */
diff --git a/gr-blocks/include/gnuradio/blocks/repack_bits_bb.h b/gr-blocks/include/gnuradio/blocks/repack_bits_bb.h
index 7bf53ab09c..8eb694f8e6 100644
--- a/gr-blocks/include/gnuradio/blocks/repack_bits_bb.h
+++ b/gr-blocks/include/gnuradio/blocks/repack_bits_bb.h
@@ -28,62 +28,66 @@
#include <gnuradio/endianness.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief Repack \p k bits from the input stream onto \p l bits of the output stream.
+ * \ingroup byte_operators_blk
+ *
+ * \details
+ * 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.
+ *
+ * When supplying a tag name, this block operates on tagged streams.
+ * In this case, it can happen that the input data or the output data
+ * becomes unaligned when k * input length is not equal to l * output length.
+ * In this case, the \p align_output parameter is used to decide which
+ * data packet to align.
+ *
+ * Usually, \p align_output is false for unpacking (k=8, l < 8) and false for
+ * reversing that.
+ *
+ * \section gr_blocks_repack_example Example
+ *
+ * Say you're tx'ing 8-PSK and therefore set k=8, l=3 on the transmit side
+ * before the modulator. Now assume you're transmitting a single byte of data.
+ * Your incoming tagged stream has length 1, the outgoing has length 3. However,
+ * the third item is actually only carrying 2 bits of relevant data, the bits
+ * do not align with the boundaries. So you set \p align_output = false,
+ * because the output can be unaligned.
+ *
+ * Now say you're doing the inverse: packing those three items into full
+ * bytes. How do you interpret those three bytes? Without this flag,
+ * you'd have to assume there's 9 relevant bits in there, so you'd end up
+ * with 2 bytes of output data. But in the packing case, you want the
+ * \b output to be aligned; all output bits must be useful. By asserting this flag,
+ * the packing algorithm tries to do this and in this case assumes that
+ * since we have alignment after 8 bits, the 9th can be discarded.
+ */
+class BLOCKS_API repack_bits_bb : virtual public tagged_stream_block
+{
+public:
+ typedef boost::shared_ptr<repack_bits_bb> sptr;
/*!
- * \brief Repack \p k bits from the input stream onto \p l bits of the output stream.
- * \ingroup byte_operators_blk
- *
- * \details
- * 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.
- *
- * When supplying a tag name, this block operates on tagged streams.
- * In this case, it can happen that the input data or the output data
- * becomes unaligned when k * input length is not equal to l * output length.
- * In this case, the \p align_output parameter is used to decide which
- * data packet to align.
- *
- * Usually, \p align_output is false for unpacking (k=8, l < 8) and false for
- * reversing that.
- *
- * \section gr_blocks_repack_example Example
- *
- * Say you're tx'ing 8-PSK and therefore set k=8, l=3 on the transmit side
- * before the modulator. Now assume you're transmitting a single byte of data.
- * Your incoming tagged stream has length 1, the outgoing has length 3. However,
- * the third item is actually only carrying 2 bits of relevant data, the bits
- * do not align with the boundaries. So you set \p align_output = false,
- * because the output can be unaligned.
- *
- * Now say you're doing the inverse: packing those three items into full
- * bytes. How do you interpret those three bytes? Without this flag,
- * you'd have to assume there's 9 relevant bits in there, so you'd end up
- * with 2 bytes of output data. But in the packing case, you want the
- * \b output to be aligned; all output bits must be useful. By asserting this flag,
- * the packing algorithm tries to do this and in this case assumes that
- * since we have alignment after 8 bits, the 9th can be discarded.
+ * \param k Number of relevant bits on the input stream
+ * \param l Number of relevant bits on the output stream
+ * \param tsb_tag_key If not empty, this is the key for the length tag.
+ * \param align_output If tsb_tag_key is given, this controls if the input
+ * or the output is aligned.
+ * \param endianness The endianness of the output data stream (LSB or MSB).
*/
- class BLOCKS_API repack_bits_bb : virtual public 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 tsb_tag_key If not empty, this is the key for the length tag.
- * \param align_output If tsb_tag_key is given, this controls if the input
- * or the output is aligned.
- * \param endianness The endianness of the output data stream (LSB or MSB).
- */
- static sptr make(int k, int l=8, const std::string &tsb_tag_key="",
- bool align_output=false, endianness_t endianness=GR_LSB_FIRST);
- virtual void set_k_and_l(int k, int l) =0;//callback function for bits per input byte k and bits per output byte l.
- };
+ static sptr make(int k,
+ int l = 8,
+ const std::string& tsb_tag_key = "",
+ bool align_output = false,
+ endianness_t endianness = GR_LSB_FIRST);
+ virtual void set_k_and_l(int k, int l) = 0; // callback function for bits per input
+ // byte k and bits per output byte l.
+};
- } // namespace blocks
+} // namespace blocks
} // namespace gr
#endif /* INCLUDED_BLOCKS_REPACK_BITS_BB_H */
diff --git a/gr-blocks/include/gnuradio/blocks/repeat.h b/gr-blocks/include/gnuradio/blocks/repeat.h
index b34bda1ec5..473297bd40 100644
--- a/gr-blocks/include/gnuradio/blocks/repeat.h
+++ b/gr-blocks/include/gnuradio/blocks/repeat.h
@@ -27,46 +27,47 @@
#include <gnuradio/sync_interpolator.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief repeat each input \p repeat times
+ * \ingroup stream_operators_blk
+ *
+ * Message Ports:
+ * * interpolation (in):
+ * Takes a pmt_pair(pmt::mp("interpolation"), pmt_long interp), setting the
+ * interpolation to interp.
+ */
+class BLOCKS_API repeat : virtual public sync_interpolator
+{
+public:
+ // gr::blocks::repeat::sptr
+ typedef boost::shared_ptr<repeat> sptr;
/*!
- * \brief repeat each input \p repeat times
- * \ingroup stream_operators_blk
+ * Make a repeat block.
*
- * Message Ports:
- * * interpolation (in):
- * Takes a pmt_pair(pmt::mp("interpolation"), pmt_long interp), setting the interpolation to interp.
+ * \param itemsize stream itemsize
+ * \param repeat number of times to repeat the input
*/
- class BLOCKS_API repeat : virtual public sync_interpolator
- {
- public:
- // gr::blocks::repeat::sptr
- typedef boost::shared_ptr<repeat> sptr;
+ static sptr make(size_t itemsize, int repeat);
- /*!
- * Make a repeat block.
- *
- * \param itemsize stream itemsize
- * \param repeat number of times to repeat the input
- */
- static sptr make(size_t itemsize, int repeat);
-
- /*!
- * \brief Return current interpolation
- */
- virtual int interpolation() const = 0;
+ /*!
+ * \brief Return current interpolation
+ */
+ virtual int interpolation() const = 0;
- /*!
- * \brief sets the interpolation
- *
- * Call this method in a callback to adjust the interpolation at run time.
- *
- * \param interp interpolation to be set
- */
- virtual void set_interpolation(int interp) = 0;
- };
+ /*!
+ * \brief sets the interpolation
+ *
+ * Call this method in a callback to adjust the interpolation at run time.
+ *
+ * \param interp interpolation to be set
+ */
+ virtual void set_interpolation(int interp) = 0;
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_BLOCKS_REPEAT_H */
diff --git a/gr-blocks/include/gnuradio/blocks/rms_cf.h b/gr-blocks/include/gnuradio/blocks/rms_cf.h
index ecb50f33d0..3894f1d116 100644
--- a/gr-blocks/include/gnuradio/blocks/rms_cf.h
+++ b/gr-blocks/include/gnuradio/blocks/rms_cf.h
@@ -27,28 +27,28 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief RMS average power
+ * \ingroup math_operators_blk
+ */
+class BLOCKS_API rms_cf : virtual public sync_block
+{
+public:
+ // gr::blocks::rms_cf::sptr
+ typedef boost::shared_ptr<rms_cf> sptr;
/*!
- * \brief RMS average power
- * \ingroup math_operators_blk
+ * \brief Make an RMS calc. block.
+ * \param alpha gain for running average filter.
*/
- class BLOCKS_API rms_cf : virtual public sync_block
- {
- public:
- // gr::blocks::rms_cf::sptr
- typedef boost::shared_ptr<rms_cf> sptr;
-
- /*!
- * \brief Make an RMS calc. block.
- * \param alpha gain for running average filter.
- */
- static sptr make(double alpha = 0.0001);
-
- virtual void set_alpha(double alpha) = 0;
- };
-
- } /* namespace blocks */
+ static sptr make(double alpha = 0.0001);
+
+ virtual void set_alpha(double alpha) = 0;
+};
+
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_BLOCKS_RMS_CF_H */
diff --git a/gr-blocks/include/gnuradio/blocks/rms_ff.h b/gr-blocks/include/gnuradio/blocks/rms_ff.h
index 2d4acd0e3d..09014ead6c 100644
--- a/gr-blocks/include/gnuradio/blocks/rms_ff.h
+++ b/gr-blocks/include/gnuradio/blocks/rms_ff.h
@@ -27,28 +27,28 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief RMS average power
+ * \ingroup math_operators_blk
+ */
+class BLOCKS_API rms_ff : virtual public sync_block
+{
+public:
+ // gr::blocks::rms_ff::sptr
+ typedef boost::shared_ptr<rms_ff> sptr;
/*!
- * \brief RMS average power
- * \ingroup math_operators_blk
+ * \brief Make an RMS calc. block.
+ * \param alpha gain for running average filter.
*/
- class BLOCKS_API rms_ff : virtual public sync_block
- {
- public:
- // gr::blocks::rms_ff::sptr
- typedef boost::shared_ptr<rms_ff> sptr;
-
- /*!
- * \brief Make an RMS calc. block.
- * \param alpha gain for running average filter.
- */
- static sptr make(double alpha = 0.0001);
-
- virtual void set_alpha(double alpha) = 0;
- };
-
- } /* namespace blocks */
+ static sptr make(double alpha = 0.0001);
+
+ virtual void set_alpha(double alpha) = 0;
+};
+
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_BLOCKS_RMS_FF_H */
diff --git a/gr-blocks/include/gnuradio/blocks/rotator.h b/gr-blocks/include/gnuradio/blocks/rotator.h
index 978297716d..161925cf4f 100644
--- a/gr-blocks/include/gnuradio/blocks/rotator.h
+++ b/gr-blocks/include/gnuradio/blocks/rotator.h
@@ -29,42 +29,42 @@
#include <cmath>
namespace gr {
- namespace blocks {
+namespace blocks {
- class rotator
- {
- private:
- gr_complex d_phase;
- gr_complex d_phase_incr;
- unsigned int d_counter;
+class 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)
- { }
+public:
+ rotator() : d_phase(1), d_phase_incr(1), d_counter(0) {}
- void set_phase(gr_complex phase) { d_phase = phase / std::abs(phase); }
- void set_phase_incr(gr_complex incr) { d_phase_incr = incr / std::abs(incr); }
+ void set_phase(gr_complex phase) { d_phase = phase / std::abs(phase); }
+ void set_phase_incr(gr_complex incr) { d_phase_incr = incr / std::abs(incr); }
- gr_complex rotate(gr_complex in)
- {
+ 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)
+ 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 /= std::abs(d_phase); // Normalize to ensure multiplication is rotation
+ if ((d_counter % 512) == 0)
+ d_phase /=
+ std::abs(d_phase); // Normalize to ensure multiplication is rotation
return z;
- }
+ }
- void rotateN(gr_complex *out, const gr_complex *in, int n)
- {
+ void rotateN(gr_complex* out, const gr_complex* in, int n)
+ {
volk_32fc_s32fc_x2_rotator_32fc(out, in, d_phase_incr, &d_phase, n);
- }
- };
+ }
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* _GR_ROTATOR_H_ */
diff --git a/gr-blocks/include/gnuradio/blocks/rotator_cc.h b/gr-blocks/include/gnuradio/blocks/rotator_cc.h
index 0697eeb19b..650ab73991 100644
--- a/gr-blocks/include/gnuradio/blocks/rotator_cc.h
+++ b/gr-blocks/include/gnuradio/blocks/rotator_cc.h
@@ -27,28 +27,28 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief Complex rotator
+ * \ingroup math_operators_blk
+ */
+class BLOCKS_API rotator_cc : virtual public sync_block
+{
+public:
+ // gr::blocks::rotator_cc::sptr
+ typedef boost::shared_ptr<rotator_cc> sptr;
/*!
- * \brief Complex rotator
- * \ingroup math_operators_blk
+ * \brief Make an complex rotator block
+ * \param phase_inc rotational velocity
*/
- class BLOCKS_API rotator_cc : virtual public sync_block
- {
- public:
- // gr::blocks::rotator_cc::sptr
- typedef boost::shared_ptr<rotator_cc> sptr;
-
- /*!
- * \brief Make an complex rotator block
- * \param phase_inc rotational velocity
- */
- static sptr make(double phase_inc = 0.0);
-
- virtual void set_phase_inc(double phase_inc) = 0;
- };
-
- } /* namespace blocks */
+ static sptr make(double phase_inc = 0.0);
+
+ virtual void set_phase_inc(double phase_inc) = 0;
+};
+
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_BLOCKS_ROTATOR_CC_H */
diff --git a/gr-blocks/include/gnuradio/blocks/sample_and_hold.h b/gr-blocks/include/gnuradio/blocks/sample_and_hold.h
index a6172a75c5..71230e7199 100644
--- a/gr-blocks/include/gnuradio/blocks/sample_and_hold.h
+++ b/gr-blocks/include/gnuradio/blocks/sample_and_hold.h
@@ -29,31 +29,31 @@
#include <cstdint>
namespace gr {
- namespace blocks {
-
- /*!
- * \brief sample and hold circuit
- * \ingroup level_controllers_blk
- *
- * \details
- * Samples the data stream (input stream 0) and holds the value if
- * the control signal is 1 (intput stream 1).
- */
-template<class T>
- class BLOCKS_API sample_and_hold : virtual public sync_block
- {
- public:
- // gr::blocks::sample_and_hold::sptr
- typedef boost::shared_ptr< sample_and_hold<T> > sptr;
-
- static sptr make();
- };
+namespace blocks {
+
+/*!
+ * \brief sample and hold circuit
+ * \ingroup level_controllers_blk
+ *
+ * \details
+ * Samples the data stream (input stream 0) and holds the value if
+ * the control signal is 1 (intput stream 1).
+ */
+template <class T>
+class BLOCKS_API sample_and_hold : virtual public sync_block
+{
+public:
+ // gr::blocks::sample_and_hold::sptr
+ typedef boost::shared_ptr<sample_and_hold<T>> sptr;
+
+ static sptr make();
+};
typedef sample_and_hold<std::uint8_t> sample_and_hold_bb;
typedef sample_and_hold<std::int16_t> sample_and_hold_ss;
typedef sample_and_hold<std::int32_t> sample_and_hold_ii;
typedef sample_and_hold<float> sample_and_hold_ff;
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* SAMPLE_AND_HOLD_H */
diff --git a/gr-blocks/include/gnuradio/blocks/short_to_char.h b/gr-blocks/include/gnuradio/blocks/short_to_char.h
index 7e72ee34a3..7cc58d2826 100644
--- a/gr-blocks/include/gnuradio/blocks/short_to_char.h
+++ b/gr-blocks/include/gnuradio/blocks/short_to_char.h
@@ -27,37 +27,37 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief Convert stream of shorts to a stream of chars.
+ *
+ * This block strips off the least significant byte from the
+ * short value.
+ *
+ * [0x00ff, 0x0ff0, 0xff00] => [0x00, 0x0f, 0xff]
+ *
+ * \ingroup type_converters_blk
+ *
+ * \details
+ * Converts \p vlen length vectors of input short samples to chars,
+ * dividing each element by 256.
+ */
+class BLOCKS_API short_to_char : virtual public sync_block
+{
+public:
+ // gr::blocks::short_to_char_ff::sptr
+ typedef boost::shared_ptr<short_to_char> sptr;
/*!
- * \brief Convert stream of shorts to a stream of chars.
- *
- * This block strips off the least significant byte from the
- * short value.
- *
- * [0x00ff, 0x0ff0, 0xff00] => [0x00, 0x0f, 0xff]
+ * Build a short to char block.
*
- * \ingroup type_converters_blk
- *
- * \details
- * Converts \p vlen length vectors of input short samples to chars,
- * dividing each element by 256.
+ * \param vlen vector length of data streams.
*/
- class BLOCKS_API short_to_char : virtual public sync_block
- {
- public:
- // gr::blocks::short_to_char_ff::sptr
- typedef boost::shared_ptr<short_to_char> sptr;
-
- /*!
- * Build a short to char block.
- *
- * \param vlen vector length of data streams.
- */
- static sptr make(size_t vlen=1);
- };
+ static sptr make(size_t vlen = 1);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_BLOCKS_SHORT_TO_CHAR_H */
diff --git a/gr-blocks/include/gnuradio/blocks/short_to_float.h b/gr-blocks/include/gnuradio/blocks/short_to_float.h
index 4a7faa1422..248554daac 100644
--- a/gr-blocks/include/gnuradio/blocks/short_to_float.h
+++ b/gr-blocks/include/gnuradio/blocks/short_to_float.h
@@ -27,38 +27,38 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief Convert stream of shorts to a stream of floats
+ * \ingroup type_converters_blk
+ */
+class BLOCKS_API short_to_float : virtual public sync_block
+{
+public:
+ // gr::blocks::short_to_float_ff::sptr
+ typedef boost::shared_ptr<short_to_float> sptr;
/*!
- * \brief Convert stream of shorts to a stream of floats
- * \ingroup type_converters_blk
+ * Build a short to float block.
+ *
+ * \param vlen vector length of data streams.
+ * \param scale a scalar divider to change the output signal scale.
*/
- class BLOCKS_API short_to_float : virtual public sync_block
- {
- public:
- // gr::blocks::short_to_float_ff::sptr
- typedef boost::shared_ptr<short_to_float> sptr;
+ static sptr make(size_t vlen = 1, float scale = 1.0);
- /*!
- * Build a short to float block.
- *
- * \param vlen vector length of data streams.
- * \param scale a scalar divider to change the output signal scale.
- */
- static sptr make(size_t vlen=1, float scale=1.0);
-
- /*!
- * Get the scalar divider value.
- */
- virtual float scale() const = 0;
+ /*!
+ * Get the scalar divider value.
+ */
+ virtual float scale() const = 0;
- /*!
- * Set the scalar divider value.
- */
- virtual void set_scale(float scale) = 0;
- };
+ /*!
+ * Set the scalar divider value.
+ */
+ virtual void set_scale(float scale) = 0;
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_BLOCKS_SHORT_TO_FLOAT_H */
diff --git a/gr-blocks/include/gnuradio/blocks/skiphead.h b/gr-blocks/include/gnuradio/blocks/skiphead.h
index c3b6d632c1..6b1c29a079 100644
--- a/gr-blocks/include/gnuradio/blocks/skiphead.h
+++ b/gr-blocks/include/gnuradio/blocks/skiphead.h
@@ -25,30 +25,29 @@
#include <gnuradio/blocks/api.h>
#include <gnuradio/sync_block.h>
-#include <stddef.h> // size_t
+#include <stddef.h> // size_t
namespace gr {
- namespace blocks {
+namespace blocks {
- /*!
- * \brief skips the first N items, from then on copies items to the output
- * \ingroup misc_blk
- *
- * \details
- * Useful for building test cases and sources which have metadata
- * or junk at the start
- */
- class BLOCKS_API skiphead : virtual public block
- {
- public:
- // gr::blocks::skiphead::sptr
- typedef boost::shared_ptr<skiphead> sptr;
+/*!
+ * \brief skips the first N items, from then on copies items to the output
+ * \ingroup misc_blk
+ *
+ * \details
+ * Useful for building test cases and sources which have metadata
+ * or junk at the start
+ */
+class BLOCKS_API skiphead : virtual public block
+{
+public:
+ // gr::blocks::skiphead::sptr
+ typedef boost::shared_ptr<skiphead> sptr;
- static sptr make(size_t itemsize,
- uint64_t nitems_to_skip);
- };
+ static sptr make(size_t itemsize, uint64_t nitems_to_skip);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_GR_SKIPHEAD_H */
diff --git a/gr-blocks/include/gnuradio/blocks/socket_pdu.h b/gr-blocks/include/gnuradio/blocks/socket_pdu.h
index 31468a3f43..f91881621e 100644
--- a/gr-blocks/include/gnuradio/blocks/socket_pdu.h
+++ b/gr-blocks/include/gnuradio/blocks/socket_pdu.h
@@ -27,30 +27,34 @@
#include <gnuradio/block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief Creates socket interface and translates traffic to PDUs
+ * \ingroup networking_tools_blk
+ */
+class BLOCKS_API socket_pdu : virtual public block
+{
+public:
+ // gr::blocks::socket_pdu::sptr
+ typedef boost::shared_ptr<socket_pdu> sptr;
/*!
- * \brief Creates socket interface and translates traffic to PDUs
- * \ingroup networking_tools_blk
+ * \brief Construct a SOCKET PDU interface
+ * \param type "TCP_SERVER", "TCP_CLIENT", "UDP_SERVER", or "UDP_CLIENT"
+ * \param addr network address to use
+ * \param port network port to use
+ * \param MTU maximum transmission unit
+ * \param tcp_no_delay TCP No Delay option (set to True to disable Nagle algorithm)
*/
- class BLOCKS_API socket_pdu : virtual public block
- {
- public:
- // gr::blocks::socket_pdu::sptr
- typedef boost::shared_ptr<socket_pdu> sptr;
-
- /*!
- * \brief Construct a SOCKET PDU interface
- * \param type "TCP_SERVER", "TCP_CLIENT", "UDP_SERVER", or "UDP_CLIENT"
- * \param addr network address to use
- * \param port network port to use
- * \param MTU maximum transmission unit
- * \param tcp_no_delay TCP No Delay option (set to True to disable Nagle algorithm)
- */
- static sptr make(std::string type, std::string addr, std::string port, int MTU=10000, bool tcp_no_delay=false);
- };
+ static sptr make(std::string type,
+ std::string addr,
+ std::string port,
+ int MTU = 10000,
+ bool tcp_no_delay = false);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_BLOCKS_SOCKET_PDU_H */
diff --git a/gr-blocks/include/gnuradio/blocks/stream_mux.h b/gr-blocks/include/gnuradio/blocks/stream_mux.h
index 941c186b3f..9dc0386795 100644
--- a/gr-blocks/include/gnuradio/blocks/stream_mux.h
+++ b/gr-blocks/include/gnuradio/blocks/stream_mux.h
@@ -28,43 +28,42 @@
#include <vector>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief Stream muxing block to multiplex many streams into
+ * one with a specified format.
+ * \ingroup stream_operators_blk
+ *
+ * \details
+ * Muxes N streams together producing an output stream that
+ * contains N0 items from the first stream, N1 items from the second,
+ * etc. and repeats:
+ *
+ * [N0, N1, N2, ..., Nm, N0, N1, ...]
+ */
+class BLOCKS_API stream_mux : virtual public block
+{
+public:
+ // gr::blocks::stream_mux::sptr
+ typedef boost::shared_ptr<stream_mux> sptr;
/*!
- * \brief Stream muxing block to multiplex many streams into
+ * \brief Creates a stream muxing block to multiplex many streams into
* one with a specified format.
- * \ingroup stream_operators_blk
*
- * \details
- * Muxes N streams together producing an output stream that
- * contains N0 items from the first stream, N1 items from the second,
- * etc. and repeats:
+ * \param itemsize the item size of the stream
+ * \param lengths a vector (list/tuple) specifying the number of
+ * items from each stream the mux together.
+ * Warning: this requires that at least as many items
+ * per stream are available or the system will wait
+ * indefinitely for the items.
*
- * [N0, N1, N2, ..., Nm, N0, N1, ...]
*/
- class BLOCKS_API stream_mux : virtual public block
- {
- public:
-
- // gr::blocks::stream_mux::sptr
- typedef boost::shared_ptr<stream_mux> sptr;
-
- /*!
- * \brief Creates a stream muxing block to multiplex many streams into
- * one with a specified format.
- *
- * \param itemsize the item size of the stream
- * \param lengths a vector (list/tuple) specifying the number of
- * items from each stream the mux together.
- * Warning: this requires that at least as many items
- * per stream are available or the system will wait
- * indefinitely for the items.
- *
- */
- static sptr make(size_t itemsize, const std::vector<int> &lengths);
- };
+ static sptr make(size_t itemsize, const std::vector<int>& lengths);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_BLOCKS_STREAM_MUX_H */
diff --git a/gr-blocks/include/gnuradio/blocks/stream_to_streams.h b/gr-blocks/include/gnuradio/blocks/stream_to_streams.h
index cb87a4b013..d849df5d75 100644
--- a/gr-blocks/include/gnuradio/blocks/stream_to_streams.h
+++ b/gr-blocks/include/gnuradio/blocks/stream_to_streams.h
@@ -27,32 +27,32 @@
#include <gnuradio/sync_decimator.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief convert a stream of items into a N streams of items
+ * \ingroup stream_operators_blk
+ *
+ * \details
+ * Converts a stream of N items into N streams of 1 item.
+ * Repeat ad infinitum.
+ */
+class BLOCKS_API stream_to_streams : virtual public sync_decimator
+{
+public:
+ // gr::blocks::stream_to_streams::sptr
+ typedef boost::shared_ptr<stream_to_streams> sptr;
/*!
- * \brief convert a stream of items into a N streams of items
- * \ingroup stream_operators_blk
+ * Make a stream-to-streams block.
*
- * \details
- * Converts a stream of N items into N streams of 1 item.
- * Repeat ad infinitum.
+ * \param itemsize the item size of the stream
+ * \param nstreams number of streams to split input into
*/
- class BLOCKS_API stream_to_streams : virtual public sync_decimator
- {
- public:
- // gr::blocks::stream_to_streams::sptr
- typedef boost::shared_ptr<stream_to_streams> sptr;
-
- /*!
- * Make a stream-to-streams block.
- *
- * \param itemsize the item size of the stream
- * \param nstreams number of streams to split input into
- */
- static sptr make(size_t itemsize, size_t nstreams);
- };
+ static sptr make(size_t itemsize, size_t nstreams);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_BLOCKS_STREAM_TO_STREAMS_H */
diff --git a/gr-blocks/include/gnuradio/blocks/stream_to_tagged_stream.h b/gr-blocks/include/gnuradio/blocks/stream_to_tagged_stream.h
index 502412a6bc..b5f689f635 100644
--- a/gr-blocks/include/gnuradio/blocks/stream_to_tagged_stream.h
+++ b/gr-blocks/include/gnuradio/blocks/stream_to_tagged_stream.h
@@ -27,44 +27,41 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief Converts a regular stream into a tagged stream.
+ * \ingroup blocks
+ *
+ * All this block does is add length tags in regular intervals.
+ * It can be used to connect a regular stream to a gr::tagged_stream_block.
+ *
+ * \b Careful: This block is meant to be connected directly to a tagged
+ * stream block. If there are blocks between this block and a tagged
+ * stream block, make sure they either don't change the rate, or modify
+ * the tag value to make sure the length tags actually represent the
+ * packet length.
+ */
+class BLOCKS_API stream_to_tagged_stream : virtual public gr::sync_block
+{
+public:
+ typedef boost::shared_ptr<stream_to_tagged_stream> sptr;
/*!
- * \brief Converts a regular stream into a tagged stream.
- * \ingroup blocks
- *
- * All this block does is add length tags in regular intervals.
- * It can be used to connect a regular stream to a gr::tagged_stream_block.
- *
- * \b Careful: This block is meant to be connected directly to a tagged
- * stream block. If there are blocks between this block and a tagged
- * stream block, make sure they either don't change the rate, or modify
- * the tag value to make sure the length tags actually represent the
- * packet length.
+ * \param itemsize Item size
+ * \param vlen Vector length of the input items. Note that one vector is one item.
+ * \param packet_len Number of items per tagged stream packet. One tag is written
+ * every \p packet_len items. \param len_tag_key Key of the length tag.
*/
- class BLOCKS_API stream_to_tagged_stream : virtual public gr::sync_block
- {
- public:
- typedef boost::shared_ptr<stream_to_tagged_stream> sptr;
-
- /*!
- * \param itemsize Item size
- * \param vlen Vector length of the input items. Note that one vector is one item.
- * \param packet_len Number of items per tagged stream packet. One tag is written every \p packet_len items.
- * \param len_tag_key Key of the length tag.
- */
- static sptr make(
- size_t itemsize,
- unsigned int vlen,
- unsigned packet_len,
- const std::string &len_tag_key
- );
- virtual void set_packet_len(unsigned packet_len) =0;
- virtual void set_packet_len_pmt(unsigned packet_len) =0;
- };
+ static sptr make(size_t itemsize,
+ unsigned int vlen,
+ unsigned packet_len,
+ const std::string& len_tag_key);
+ virtual void set_packet_len(unsigned packet_len) = 0;
+ virtual void set_packet_len_pmt(unsigned packet_len) = 0;
+};
- } // namespace blocks
+} // namespace blocks
} // namespace gr
#endif /* INCLUDED_BLOCKS_STREAM_TO_TAGGED_STREAM_H */
-
diff --git a/gr-blocks/include/gnuradio/blocks/stream_to_vector.h b/gr-blocks/include/gnuradio/blocks/stream_to_vector.h
index ca96bdd7fe..616b2d571e 100644
--- a/gr-blocks/include/gnuradio/blocks/stream_to_vector.h
+++ b/gr-blocks/include/gnuradio/blocks/stream_to_vector.h
@@ -27,28 +27,28 @@
#include <gnuradio/sync_decimator.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief convert a stream of items into a stream of gnuradio/blocks containing
+ * nitems_per_block \ingroup stream_operators_blk
+ */
+class BLOCKS_API stream_to_vector : virtual public sync_decimator
+{
+public:
+ // gr::blocks::stream_to_vector::sptr
+ typedef boost::shared_ptr<stream_to_vector> sptr;
/*!
- * \brief convert a stream of items into a stream of gnuradio/blocks containing nitems_per_block
- * \ingroup stream_operators_blk
+ * Make a stream-to-vector block.
+ *
+ * \param itemsize the item size of the stream
+ * \param nitems_per_block number of items to put into each vector (vector size)
*/
- class BLOCKS_API stream_to_vector : virtual public sync_decimator
- {
- public:
- // gr::blocks::stream_to_vector::sptr
- typedef boost::shared_ptr<stream_to_vector> sptr;
-
- /*!
- * Make a stream-to-vector block.
- *
- * \param itemsize the item size of the stream
- * \param nitems_per_block number of items to put into each vector (vector size)
- */
- static sptr make(size_t itemsize, size_t nitems_per_block);
- };
+ static sptr make(size_t itemsize, size_t nitems_per_block);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_BLOCKS_STREAM_TO_VECTOR_H */
diff --git a/gr-blocks/include/gnuradio/blocks/streams_to_stream.h b/gr-blocks/include/gnuradio/blocks/streams_to_stream.h
index 79c28e6c62..dfda710006 100644
--- a/gr-blocks/include/gnuradio/blocks/streams_to_stream.h
+++ b/gr-blocks/include/gnuradio/blocks/streams_to_stream.h
@@ -27,32 +27,32 @@
#include <gnuradio/sync_interpolator.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief Convert N streams of 1 item into a 1 stream of N items
+ * \ingroup stream_operators_blk
+ *
+ * \details
+ * Convert N streams of 1 item into 1 stream of N items.
+ * Repeat ad infinitum.
+ */
+class BLOCKS_API streams_to_stream : virtual public sync_interpolator
+{
+public:
+ // gr::blocks::streams_to_stream::sptr
+ typedef boost::shared_ptr<streams_to_stream> sptr;
/*!
- * \brief Convert N streams of 1 item into a 1 stream of N items
- * \ingroup stream_operators_blk
+ * Make a streams-to-stream block.
*
- * \details
- * Convert N streams of 1 item into 1 stream of N items.
- * Repeat ad infinitum.
+ * \param itemsize the item size of the stream
+ * \param nstreams number of streams to combine
*/
- class BLOCKS_API streams_to_stream : virtual public sync_interpolator
- {
- public:
- // gr::blocks::streams_to_stream::sptr
- typedef boost::shared_ptr<streams_to_stream> sptr;
-
- /*!
- * Make a streams-to-stream block.
- *
- * \param itemsize the item size of the stream
- * \param nstreams number of streams to combine
- */
- static sptr make(size_t itemsize, size_t nstreams);
- };
+ static sptr make(size_t itemsize, size_t nstreams);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_BLOCKS_STREAMS_TO_STREAM_H */
diff --git a/gr-blocks/include/gnuradio/blocks/streams_to_vector.h b/gr-blocks/include/gnuradio/blocks/streams_to_vector.h
index a99eeedb00..4e5cc2f4c7 100644
--- a/gr-blocks/include/gnuradio/blocks/streams_to_vector.h
+++ b/gr-blocks/include/gnuradio/blocks/streams_to_vector.h
@@ -27,28 +27,28 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief convert N streams of items to 1 stream of vector length N
+ * \ingroup stream_operators_blk
+ */
+class BLOCKS_API streams_to_vector : virtual public sync_block
+{
+public:
+ // gr::blocks::streams_to_vector::sptr
+ typedef boost::shared_ptr<streams_to_vector> sptr;
/*!
- * \brief convert N streams of items to 1 stream of vector length N
- * \ingroup stream_operators_blk
+ * Make a stream-to-vector block.
+ *
+ * \param itemsize the item size of the stream
+ * \param nstreams number of streams to combine into a vector (vector size)
*/
- class BLOCKS_API streams_to_vector : virtual public sync_block
- {
- public:
- // gr::blocks::streams_to_vector::sptr
- typedef boost::shared_ptr<streams_to_vector> sptr;
-
- /*!
- * Make a stream-to-vector block.
- *
- * \param itemsize the item size of the stream
- * \param nstreams number of streams to combine into a vector (vector size)
- */
- static sptr make(size_t itemsize, size_t nstreams);
- };
+ static sptr make(size_t itemsize, size_t nstreams);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_BLOCKS_STREAMS_TO_VECTOR_H */
diff --git a/gr-blocks/include/gnuradio/blocks/stretch_ff.h b/gr-blocks/include/gnuradio/blocks/stretch_ff.h
index d464ab34a1..24537317ff 100644
--- a/gr-blocks/include/gnuradio/blocks/stretch_ff.h
+++ b/gr-blocks/include/gnuradio/blocks/stretch_ff.h
@@ -27,34 +27,34 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief adjust y-range of an input vector by mapping to range
+ * (max-of-input, stipulated-min). Primarily for spectral
+ * signature matching by normalizing spectrum dynamic ranges.
+ * \ingroup stream_operators_blk
+ */
+class BLOCKS_API stretch_ff : virtual public sync_block
+{
+public:
+ // gr::blocks::stretch_ff::sptr
+ typedef boost::shared_ptr<stretch_ff> sptr;
/*!
- * \brief adjust y-range of an input vector by mapping to range
- * (max-of-input, stipulated-min). Primarily for spectral
- * signature matching by normalizing spectrum dynamic ranges.
- * \ingroup stream_operators_blk
+ * \brief Make a stretch block.
+ *
+ * \param lo Set low value for range.
+ * \param vlen vector length of input stream.
*/
- class BLOCKS_API stretch_ff : virtual public sync_block
- {
- public:
- // gr::blocks::stretch_ff::sptr
- typedef boost::shared_ptr<stretch_ff> sptr;
-
- /*!
- * \brief Make a stretch block.
- *
- * \param lo Set low value for range.
- * \param vlen vector length of input stream.
- */
- static sptr make(float lo, size_t vlen=1);
-
- virtual float lo() const = 0;
- virtual void set_lo(float lo) = 0;
- virtual size_t vlen() const = 0;
- };
-
- } /* namespace blocks */
+ static sptr make(float lo, size_t vlen = 1);
+
+ virtual float lo() const = 0;
+ virtual void set_lo(float lo) = 0;
+ virtual size_t vlen() const = 0;
+};
+
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_GR_STRETCH_FF_H */
diff --git a/gr-blocks/include/gnuradio/blocks/sub.h b/gr-blocks/include/gnuradio/blocks/sub.h
index 942cd727d2..39dc747181 100644
--- a/gr-blocks/include/gnuradio/blocks/sub.h
+++ b/gr-blocks/include/gnuradio/blocks/sub.h
@@ -29,31 +29,30 @@
#include <cstdint>
namespace gr {
- namespace blocks {
-
- /*!
- * \brief output = input_0 - input_1 - ...)
- * \ingroup math_operators_blk
- *
- * \details
- * Subtract across all input streams.
- */
-template<class T>
- class BLOCKS_API sub : virtual public sync_block
- {
- public:
-
- // gr::blocks::sub::sptr
- typedef boost::shared_ptr< sub<T> > sptr;
-
- static sptr make(size_t vlen=1);
- };
+namespace blocks {
+
+/*!
+ * \brief output = input_0 - input_1 - ...)
+ * \ingroup math_operators_blk
+ *
+ * \details
+ * Subtract across all input streams.
+ */
+template <class T>
+class BLOCKS_API sub : virtual public sync_block
+{
+public:
+ // gr::blocks::sub::sptr
+ typedef boost::shared_ptr<sub<T>> sptr;
+
+ static sptr make(size_t vlen = 1);
+};
typedef sub<std::int16_t> sub_ss;
typedef sub<std::int32_t> sub_ii;
typedef sub<gr_complex> sub_cc;
typedef sub<float> sub_ff;
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* SUB_H */
diff --git a/gr-blocks/include/gnuradio/blocks/tag_debug.h b/gr-blocks/include/gnuradio/blocks/tag_debug.h
index 3d7725c7d5..08f4ed983d 100644
--- a/gr-blocks/include/gnuradio/blocks/tag_debug.h
+++ b/gr-blocks/include/gnuradio/blocks/tag_debug.h
@@ -27,79 +27,79 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief Bit bucket that prints out any tag received.
+ * \ingroup measurement_tools_blk
+ * \ingroup stream_tag_tools_blk
+ * \ingroup debug_tools_blk
+ *
+ * \details
+ * 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.
+ *
+ * Specifying a key will allow this block to filter out all other
+ * tags and only display tags that match the given key. This can
+ * help clean up the output and allow you to focus in on a
+ * particular tag of interest.
+ *
+ * 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 sync_block
+{
+public:
+ // gr::blocks::tag_debug::sptr
+ typedef boost::shared_ptr<tag_debug> sptr;
/*!
- * \brief Bit bucket that prints out any tag received.
- * \ingroup measurement_tools_blk
- * \ingroup stream_tag_tools_blk
- * \ingroup debug_tools_blk
- *
- * \details
- * 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.
+ * Build a tag debug block
*
- * Specifying a key will allow this block to filter out all other
- * tags and only display tags that match the given key. This can
- * help clean up the output and allow you to focus in on a
- * particular tag of interest.
- *
- * The tags from the last call to this work function are stored
- * and can be retrieved using the function 'current_tags'.
+ * \param sizeof_stream_item size of the items in the incoming stream.
+ * \param name name to identify which debug sink generated the info.
+ * \param key_filter Specify a tag's key value to use as a filter.
*/
- class BLOCKS_API tag_debug : virtual public 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.
- * \param key_filter Specify a tag's key value to use as a filter.
- */
- static sptr make(size_t sizeof_stream_item,
- const std::string &name,
- const std::string &key_filter="");
+ static sptr make(size_t sizeof_stream_item,
+ const std::string& name,
+ const std::string& key_filter = "");
- /*!
- * \brief Returns a vector of tag_t items as of the last call to
- * work.
- */
- virtual std::vector<tag_t> current_tags() = 0;
+ /*!
+ * \brief Returns a vector of tag_t items as of the last call to
+ * work.
+ */
+ virtual std::vector<tag_t> current_tags() = 0;
- /*!
- * \brief Return the total number of tags in the tag queue.
- */
- virtual int num_tags() = 0;
+ /*!
+ * \brief Return the total number of tags in the tag queue.
+ */
+ virtual int num_tags() = 0;
- /*!
- * \brief Set the display of tags to stdout on/off.
- */
- virtual void set_display(bool d) = 0;
+ /*!
+ * \brief Set the display of tags to stdout on/off.
+ */
+ virtual void set_display(bool d) = 0;
- /*!
- * \brief Set a new key to filter with.
- */
- virtual void set_key_filter(const std::string &key_filter) = 0;
+ /*!
+ * \brief Set a new key to filter with.
+ */
+ virtual void set_key_filter(const std::string& key_filter) = 0;
- /*!
- * \brief Get the current filter key.
- */
- virtual std::string key_filter() const = 0;
- };
+ /*!
+ * \brief Get the current filter key.
+ */
+ virtual std::string key_filter() const = 0;
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_GR_TAG_DEBUG_H */
diff --git a/gr-blocks/include/gnuradio/blocks/tag_gate.h b/gr-blocks/include/gnuradio/blocks/tag_gate.h
index 644b5cf75a..e8d61e8d78 100644
--- a/gr-blocks/include/gnuradio/blocks/tag_gate.h
+++ b/gr-blocks/include/gnuradio/blocks/tag_gate.h
@@ -27,45 +27,44 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- /*!
- * \brief Control tag propagation.
- * \ingroup blocks
- *
- * Use this block to stop tags from propagating.
- */
- class BLOCKS_API tag_gate : virtual public gr::sync_block
- {
- public:
- typedef boost::shared_ptr<tag_gate> sptr;
+/*!
+ * \brief Control tag propagation.
+ * \ingroup blocks
+ *
+ * Use this block to stop tags from propagating.
+ */
+class BLOCKS_API tag_gate : virtual public gr::sync_block
+{
+public:
+ typedef boost::shared_ptr<tag_gate> sptr;
- virtual void set_propagation(bool propagate_tags) = 0;
+ virtual void set_propagation(bool propagate_tags) = 0;
- /*!
- * \param item_size Item size
- * \param propagate_tags Set this to true to allow tags to pass through this block.
- */
- static sptr make(size_t item_size, bool propagate_tags=false);
+ /*!
+ * \param item_size Item size
+ * \param propagate_tags Set this to true to allow tags to pass through this block.
+ */
+ static sptr make(size_t item_size, bool propagate_tags = false);
- /*!
- * \brief Only gate stream tags with one specific key instead of all keys
- *
- * \details
- * If set to "", all tags will be affected by the gate.
- * If set to "foo", all tags with key different from "foo" will pass
- * through.
- */
- virtual void set_single_key(const std::string &single_key)=0;
+ /*!
+ * \brief Only gate stream tags with one specific key instead of all keys
+ *
+ * \details
+ * If set to "", all tags will be affected by the gate.
+ * If set to "foo", all tags with key different from "foo" will pass
+ * through.
+ */
+ virtual void set_single_key(const std::string& single_key) = 0;
- /*!
- * \brief Get the current single key.
- */
- virtual std::string single_key() const = 0;
- };
+ /*!
+ * \brief Get the current single key.
+ */
+ virtual std::string single_key() const = 0;
+};
- } // namespace blocks
+} // namespace blocks
} // namespace gr
#endif /* INCLUDED_BLOCKS_TAG_GATE_H */
-
diff --git a/gr-blocks/include/gnuradio/blocks/tag_share.h b/gr-blocks/include/gnuradio/blocks/tag_share.h
index 476076c6f5..7ff867b7fa 100644
--- a/gr-blocks/include/gnuradio/blocks/tag_share.h
+++ b/gr-blocks/include/gnuradio/blocks/tag_share.h
@@ -27,41 +27,41 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief Adds tags from Input 1 onto Input 0's stream.
+ * \ingroup blocks
+ *
+ * \details
+ * This block utilizes the GNU Radio runtime's tag propagation policy
+ * to transfer or share Input 1's tags to Input 0's stream. This is
+ * useful when a signal is detected via a correlate_access_code_bb or
+ * a threshold crossing from a complex_to_mag_squared block. The tag from
+ * that detection is on the alternate stream, either bytes or floats.
+ * Often there is further signal processing that should be done on the
+ * complex stream. This block allows the detection tags to be added to
+ * the complex stream to trigger downstream processing without the need of
+ * redundant trigger inputs on all subsequent blocks.
+ */
+class BLOCKS_API tag_share : virtual public gr::sync_block
+{
+public:
+ typedef boost::shared_ptr<tag_share> sptr;
/*!
- * \brief Adds tags from Input 1 onto Input 0's stream.
- * \ingroup blocks
- *
- * \details
- * This block utilizes the GNU Radio runtime's tag propagation policy
- * to transfer or share Input 1's tags to Input 0's stream. This is
- * useful when a signal is detected via a correlate_access_code_bb or
- * a threshold crossing from a complex_to_mag_squared block. The tag from
- * that detection is on the alternate stream, either bytes or floats.
- * Often there is further signal processing that should be done on the
- * complex stream. This block allows the detection tags to be added to
- * the complex stream to trigger downstream processing without the need of
- * redundant trigger inputs on all subsequent blocks.
+ * \param sizeof_io_item The size of the Input 0/Output 0 stream type. Input 0
+ * stream items will be directly copied to Output 0.
+ * \param sizeof_share_item The size of the Input 1 (tag share) stream type. This
+ * stream type does not have to match the input/output stream type. Tags from
+ * Input 1's items will be combined with Input 0's item tags and outputted on
+ * Output 0.
+ * \param vlen The vector size of the input and output stream items
*/
- class BLOCKS_API tag_share : virtual public gr::sync_block
- {
- public:
- typedef boost::shared_ptr<tag_share> sptr;
-
- /*!
- * \param sizeof_io_item The size of the Input 0/Output 0 stream type. Input 0
- * stream items will be directly copied to Output 0.
- * \param sizeof_share_item The size of the Input 1 (tag share) stream type. This
- * stream type does not have to match the input/output stream type. Tags from
- * Input 1's items will be combined with Input 0's item tags and outputted on
- * Output 0.
- * \param vlen The vector size of the input and output stream items
- */
- static sptr make(size_t sizeof_io_item, size_t sizeof_share_item, size_t vlen = 1);
- };
+ static sptr make(size_t sizeof_io_item, size_t sizeof_share_item, size_t vlen = 1);
+};
- } // namespace blocks
+} // namespace blocks
} // namespace gr
#endif /* INCLUDED_BLOCKS_TAG_SHARE_H */
diff --git a/gr-blocks/include/gnuradio/blocks/tagged_file_sink.h b/gr-blocks/include/gnuradio/blocks/tagged_file_sink.h
index 61c2ad8e60..ea1cfe3ff9 100644
--- a/gr-blocks/include/gnuradio/blocks/tagged_file_sink.h
+++ b/gr-blocks/include/gnuradio/blocks/tagged_file_sink.h
@@ -27,41 +27,41 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief A file sink that uses tags to save files.
+ * \ingroup file_operators_blk
+ * \ingroup stream_tag_tools_blk
+ *
+ * \details
+ * 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 sync_block
+{
+public:
+ // gr::blocks::tagged_file_sink::sptr
+ typedef boost::shared_ptr<tagged_file_sink> sptr;
/*!
- * \brief A file sink that uses tags to save files.
- * \ingroup file_operators_blk
- * \ingroup stream_tag_tools_blk
+ * \brief Build a tagged_file_sink block.
*
- * \details
- * 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.
+ * \param itemsize The item size of the input data stream.
+ * \param samp_rate The sample rate used to determine the time
+ * difference between bursts
*/
- class BLOCKS_API tagged_file_sink : virtual public 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);
- };
+ static sptr make(size_t itemsize, double samp_rate);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_GR_TAGGED_FILE_SINK_H */
diff --git a/gr-blocks/include/gnuradio/blocks/tagged_stream_align.h b/gr-blocks/include/gnuradio/blocks/tagged_stream_align.h
index ae01198113..72548429fa 100644
--- a/gr-blocks/include/gnuradio/blocks/tagged_stream_align.h
+++ b/gr-blocks/include/gnuradio/blocks/tagged_stream_align.h
@@ -26,30 +26,30 @@
#include <gnuradio/block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief Align a stream to a tagged stream item
+ * \ingroup stream_operators_blk
+ *
+ * \details
+ * Takes an unaligned stream of tagged stream items and aligns to the first item
+ */
+class BLOCKS_API tagged_stream_align : virtual public block
+{
+public:
+ typedef boost::shared_ptr<tagged_stream_align> sptr;
/*!
- * \brief Align a stream to a tagged stream item
- * \ingroup stream_operators_blk
+ * Make a tagged stream align
*
- * \details
- * Takes an unaligned stream of tagged stream items and aligns to the first item
+ * \param itemsize The size (in bytes) of the item datatype.
+ * \param lengthtagname Name of the TSB's length tag key.
*/
- class BLOCKS_API tagged_stream_align : virtual public block
- {
- public:
- typedef boost::shared_ptr<tagged_stream_align> sptr;
-
- /*!
- * Make a tagged stream align
- *
- * \param itemsize The size (in bytes) of the item datatype.
- * \param lengthtagname Name of the TSB's length tag key.
- */
- static sptr make(size_t itemsize, const std::string &lengthtagname);
- };
+ static sptr make(size_t itemsize, const std::string& lengthtagname);
+};
- } // namespace blocks
+} // namespace blocks
} // namespace gr
#endif /* INCLUDED_TAGGED_STREAM_ALIGN_H */
diff --git a/gr-blocks/include/gnuradio/blocks/tagged_stream_multiply_length.h b/gr-blocks/include/gnuradio/blocks/tagged_stream_multiply_length.h
index 234b42c041..bdbe73a6f3 100644
--- a/gr-blocks/include/gnuradio/blocks/tagged_stream_multiply_length.h
+++ b/gr-blocks/include/gnuradio/blocks/tagged_stream_multiply_length.h
@@ -26,35 +26,34 @@
#include <gnuradio/tagged_stream_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief Allows scaling of a tagged stream length tag
+ * \ingroup stream_operators_blk
+ *
+ * \details
+ * Searches for a specific tagged stream length tag and multiplies
+ * that length by a constant - for constant rate change blocks
+ * in a tagged stream
+ */
+class BLOCKS_API tagged_stream_multiply_length : virtual public block
+{
+public:
+ typedef boost::shared_ptr<tagged_stream_multiply_length> sptr;
+ virtual void set_scalar(double scalar) = 0;
/*!
- * \brief Allows scaling of a tagged stream length tag
- * \ingroup stream_operators_blk
+ * Make a tagged stream multiply_length block.
*
- * \details
- * Searches for a specific tagged stream length tag and multiplies
- * that length by a constant - for constant rate change blocks
- * in a tagged stream
+ * \param itemsize Items size (number of bytes per item)
+ * \param lengthtagname Length tag key
+ * \param scalar value to scale length tag values by
*/
- class BLOCKS_API tagged_stream_multiply_length : virtual public block
- {
- public:
- typedef boost::shared_ptr<tagged_stream_multiply_length> sptr;
- virtual void set_scalar(double scalar) = 0;
+ static sptr make(size_t itemsize, const std::string& lengthtagname, double scalar);
+};
- /*!
- * Make a tagged stream multiply_length block.
- *
- * \param itemsize Items size (number of bytes per item)
- * \param lengthtagname Length tag key
- * \param scalar value to scale length tag values by
- */
- static sptr make(size_t itemsize, const std::string &lengthtagname, double scalar);
- };
-
- } // namespace blocks
+} // namespace blocks
} // namespace gr
#endif /* INCLUDED_TAGGED_STREAM_MULTIPLY_LENGTH_H */
-
diff --git a/gr-blocks/include/gnuradio/blocks/tagged_stream_mux.h b/gr-blocks/include/gnuradio/blocks/tagged_stream_mux.h
index b7f5685ae1..711964fe7b 100644
--- a/gr-blocks/include/gnuradio/blocks/tagged_stream_mux.h
+++ b/gr-blocks/include/gnuradio/blocks/tagged_stream_mux.h
@@ -26,44 +26,45 @@
#include <gnuradio/tagged_stream_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief Combines tagged streams.
+ * \ingroup stream_operators_blk
+ *
+ * \details
+ * 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. The old length tags are discarded.
+ *
+ * All other tags are propagated as expected, i.e. they stay associated
+ * with the same input item.
+ * There are cases when this behaviour is undesirable. One special case
+ * is when a tag at the first element (the head item) of one input port
+ * must stay on the head item of the output port. To achieve this,
+ * set \p tag_preserve_head_pos to the port that will receive these special
+ * tags.
+ */
+class BLOCKS_API tagged_stream_mux : virtual public tagged_stream_block
+{
+public:
+ typedef boost::shared_ptr<tagged_stream_mux> sptr;
/*!
- * \brief Combines tagged streams.
- * \ingroup stream_operators_blk
+ * Make a tagged stream mux block.
*
- * \details
- * 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. The old length tags are discarded.
- *
- * All other tags are propagated as expected, i.e. they stay associated
- * with the same input item.
- * There are cases when this behaviour is undesirable. One special case
- * is when a tag at the first element (the head item) of one input port
- * must stay on the head item of the output port. To achieve this,
- * set \p tag_preserve_head_pos to the port that will receive these special
- * tags.
+ * \param itemsize Items size (number of bytes per item)
+ * \param lengthtagname Length tag key
+ * \param tag_preserve_head_pos Preserves the head position of tags on this input port
*/
- class BLOCKS_API tagged_stream_mux : virtual public tagged_stream_block
- {
- public:
- typedef boost::shared_ptr<tagged_stream_mux> sptr;
+ static sptr make(size_t itemsize,
+ const std::string& lengthtagname,
+ unsigned int tag_preserve_head_pos = 0);
+};
- /*!
- * Make a tagged stream mux block.
- *
- * \param itemsize Items size (number of bytes per item)
- * \param lengthtagname Length tag key
- * \param tag_preserve_head_pos Preserves the head position of tags on this input port
- */
- static sptr make(size_t itemsize, const std::string &lengthtagname, unsigned int tag_preserve_head_pos=0);
- };
-
- } // namespace blocks
+} // namespace blocks
} // namespace gr
#endif /* INCLUDED_TAGGED_STREAM_MUX_H */
-
diff --git a/gr-blocks/include/gnuradio/blocks/tagged_stream_to_pdu.h b/gr-blocks/include/gnuradio/blocks/tagged_stream_to_pdu.h
index af3279217e..4116d5b364 100644
--- a/gr-blocks/include/gnuradio/blocks/tagged_stream_to_pdu.h
+++ b/gr-blocks/include/gnuradio/blocks/tagged_stream_to_pdu.h
@@ -28,34 +28,34 @@
#include <gnuradio/tagged_stream_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief Turns received stream data and tags into PDUs and sends
+ * them through a message port.
+ * \ingroup message_tools_blk
+ *
+ * The sent message is a PMT-pair (created by pmt::cons()). The
+ * first element is a dictionary containing all the tags. The
+ * second is a vector containing the actual data.
+ */
+class BLOCKS_API tagged_stream_to_pdu : virtual public tagged_stream_block
+{
+public:
+ // gr::blocks::tagged_stream_to_pdu::sptr
+ typedef boost::shared_ptr<tagged_stream_to_pdu> sptr;
/*!
- * \brief Turns received stream data and tags into PDUs and sends
- * them through a message port.
- * \ingroup message_tools_blk
- *
- * The sent message is a PMT-pair (created by pmt::cons()). The
- * first element is a dictionary containing all the tags. The
- * second is a vector containing the actual data.
+ * \brief Construct a tagged_stream_to_pdu block
+ * \param type PDU type of pdu::vector_type
+ * \param lengthtagname The name of the tag that specifies
+ * how long the packet is.
*/
- class BLOCKS_API tagged_stream_to_pdu : virtual public tagged_stream_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
- * \param lengthtagname The name of the tag that specifies
- * how long the packet is.
- */
- static sptr make(pdu::vector_type type,
- const std::string& lengthtagname="packet_len");
- };
+ static sptr make(pdu::vector_type type,
+ const std::string& lengthtagname = "packet_len");
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_BLOCKS_TAGGED_STREAM_TO_PDU_H */
diff --git a/gr-blocks/include/gnuradio/blocks/tags_strobe.h b/gr-blocks/include/gnuradio/blocks/tags_strobe.h
index eb04f01415..4429f2ec35 100644
--- a/gr-blocks/include/gnuradio/blocks/tags_strobe.h
+++ b/gr-blocks/include/gnuradio/blocks/tags_strobe.h
@@ -27,73 +27,74 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief Send tags at defined interval
+ * \ingroup debug_blk
+ *
+ * \details
+ * Sends a tag with key 'strobe' and a user-defined value (as a
+ * PMT) every \p nsamps number of samples. Useful for
+ * testing/debugging the tags system.
+ *
+ * Because tags are sent with a data stream, this is a source
+ * block that acts identical to a null_source block.
+ */
+class BLOCKS_API tags_strobe : virtual public sync_block
+{
+public:
+ // gr::blocks::tags_strobe::sptr
+ typedef boost::shared_ptr<tags_strobe> sptr;
/*!
- * \brief Send tags at defined interval
- * \ingroup debug_blk
- *
- * \details
- * Sends a tag with key 'strobe' and a user-defined value (as a
- * PMT) every \p nsamps number of samples. Useful for
- * testing/debugging the tags system.
+ * Make a tags stobe block to send tags with value \p value
+ * every \p nsamps number of samples.
*
- * Because tags are sent with a data stream, this is a source
- * block that acts identical to a null_source block.
+ * \param sizeof_stream_item size of the stream items in bytes.
+ * \param value The value of the tags to send, as a PMT.
+ * \param nsamps the number of samples between each tag.
+ * \param key The tag key to sent
*/
- class BLOCKS_API tags_strobe : virtual public sync_block
- {
- public:
- // gr::blocks::tags_strobe::sptr
- typedef boost::shared_ptr<tags_strobe> sptr;
+ static sptr make(size_t sizeof_stream_item,
+ pmt::pmt_t value,
+ uint64_t nsamps,
+ pmt::pmt_t key = pmt::intern("strobe"));
- /*!
- * Make a tags stobe block to send tags with value \p value
- * every \p nsamps number of samples.
- *
- * \param sizeof_stream_item size of the stream items in bytes.
- * \param value The value of the tags to send, as a PMT.
- * \param nsamps the number of samples between each tag.
- * \param key The tag key to sent
- */
- static sptr make(size_t sizeof_stream_item,
- pmt::pmt_t value, uint64_t nsamps, pmt::pmt_t key = pmt::intern("strobe"));
-
- /*!
- * Reset the value of the tags being sent.
- * \param value The value of the tags to send as a PMT.
- */
- virtual void set_value(pmt::pmt_t value) = 0;
-
- /*!
- * Change the tag key we are sending
- */
- virtual void set_key(pmt::pmt_t key) = 0;
+ /*!
+ * Reset the value of the tags being sent.
+ * \param value The value of the tags to send as a PMT.
+ */
+ virtual void set_value(pmt::pmt_t value) = 0;
- /*!
- * Get the value of the tags being sent.
- */
- virtual pmt::pmt_t value() const = 0;
+ /*!
+ * Change the tag key we are sending
+ */
+ virtual void set_key(pmt::pmt_t key) = 0;
- /*!
- * Get the key of the tags being sent.
- */
- virtual pmt::pmt_t key() const = 0;
+ /*!
+ * Get the value of the tags being sent.
+ */
+ virtual pmt::pmt_t value() const = 0;
- /*!
- * Reset the sending interval.
- * \param nsamps the number of samples between each tag
- */
- virtual void set_nsamps(uint64_t nsamps) = 0;
+ /*!
+ * Get the key of the tags being sent.
+ */
+ virtual pmt::pmt_t key() const = 0;
- /*!
- * Get the number of samples between the tag strobe.
- */
- virtual uint64_t nsamps() const = 0;
+ /*!
+ * Reset the sending interval.
+ * \param nsamps the number of samples between each tag
+ */
+ virtual void set_nsamps(uint64_t nsamps) = 0;
- };
+ /*!
+ * Get the number of samples between the tag strobe.
+ */
+ virtual uint64_t nsamps() const = 0;
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_GR_TAGS_STROBE_H */
diff --git a/gr-blocks/include/gnuradio/blocks/tcp_server_sink.h b/gr-blocks/include/gnuradio/blocks/tcp_server_sink.h
index 8720577824..534e9970ca 100644
--- a/gr-blocks/include/gnuradio/blocks/tcp_server_sink.h
+++ b/gr-blocks/include/gnuradio/blocks/tcp_server_sink.h
@@ -27,40 +27,39 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief Send stream through a TCP socket.
+ * \ingroup networking_tools_blk
+ *
+ * \details
+ * Listen for incoming TCP connection(s). Duplicate data for each
+ * opened connection. Optionally can wait until first client connects
+ * before streaming starts.
+ */
+class BLOCKS_API tcp_server_sink : virtual public gr::sync_block
+{
+public:
+ // gr::blocks::tcp_server_sink::sptr
+ typedef boost::shared_ptr<tcp_server_sink> sptr;
/*!
- * \brief Send stream through a TCP socket.
- * \ingroup networking_tools_blk
+ * \brief TCP Server Sink Constructor
*
- * \details
- * Listen for incoming TCP connection(s). Duplicate data for each
- * opened connection. Optionally can wait until first client connects
- * before streaming starts.
+ * \param itemsize The size (in bytes) of the item datatype
+ * \param host The name or IP address of interface to bind to.
+ * \param port Port where to listen.
+ * \param noblock If false, wait until first client connects before
+ * streaming starts. In non blocking mode
+ * (noblock=true), drop data onto floor if no client
+ * is connected.
*/
- class BLOCKS_API tcp_server_sink : virtual public gr::sync_block
- {
- public:
- // gr::blocks::tcp_server_sink::sptr
- typedef boost::shared_ptr<tcp_server_sink> sptr;
-
- /*!
- * \brief TCP Server Sink Constructor
- *
- * \param itemsize The size (in bytes) of the item datatype
- * \param host The name or IP address of interface to bind to.
- * \param port Port where to listen.
- * \param noblock If false, wait until first client connects before
- * streaming starts. In non blocking mode
- * (noblock=true), drop data onto floor if no client
- * is connected.
- */
- static sptr make(size_t itemsize,
- const std::string &host, int port,
- bool noblock = false);
- };
+ static sptr
+ make(size_t itemsize, const std::string& host, int port, bool noblock = false);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_BLOCKS_TCP_SERVER_SINK_H */
diff --git a/gr-blocks/include/gnuradio/blocks/test_tag_variable_rate_ff.h b/gr-blocks/include/gnuradio/blocks/test_tag_variable_rate_ff.h
index 7894ad525c..593c47c18c 100644
--- a/gr-blocks/include/gnuradio/blocks/test_tag_variable_rate_ff.h
+++ b/gr-blocks/include/gnuradio/blocks/test_tag_variable_rate_ff.h
@@ -27,53 +27,52 @@
#include <gnuradio/block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief Used for testing tag propagation.
+ * \ingroup measurement_tools_blk
+ * \ingroup stream_tag_tools_blk
+ * \ingroup debug_tools_blk
+ *
+ * This block resamples the stream by a factor that starts at 0.5
+ * but varies around by some random walk. The relative rate of the
+ * block is initialized to 0.5 and the random number generator is
+ * seeded based on the time. For each input, if the random number
+ * is >= 0.5, the relative rate is increased by \p update_step;
+ * otherwise, it is decreased by \p update_step.
+ *
+ * The rate of the change of the resampling factor is set by the
+ * flag \p update_once. If this is set to true, then the rate is
+ * only updated once per work function. If it is set to false
+ * (default), then the rate is changed with every input sample.
+ *
+ * The block's ctor sets the propagation policy to TPP_DONT to
+ * stop tags from automatically propagating. Instead, we handle
+ * the tag propagation ourselves from within the work
+ * function. Because the relative_rate changes so fast, the tag
+ * placement cannot be based on a single factor after the call to
+ * work and must be handled when the samples are and based on the
+ * current resampling rate.
+ */
+class BLOCKS_API test_tag_variable_rate_ff : virtual public block
+{
+public:
+ // gr::blocks::test_tag_variable_rate_ff::sptr
+ typedef boost::shared_ptr<test_tag_variable_rate_ff> sptr;
/*!
- * \brief Used for testing tag propagation.
- * \ingroup measurement_tools_blk
- * \ingroup stream_tag_tools_blk
- * \ingroup debug_tools_blk
- *
- * This block resamples the stream by a factor that starts at 0.5
- * but varies around by some random walk. The relative rate of the
- * block is initialized to 0.5 and the random number generator is
- * seeded based on the time. For each input, if the random number
- * is >= 0.5, the relative rate is increased by \p update_step;
- * otherwise, it is decreased by \p update_step.
+ * Build a test_tag_variable_rate_ff block.
*
- * The rate of the change of the resampling factor is set by the
- * flag \p update_once. If this is set to true, then the rate is
- * only updated once per work function. If it is set to false
- * (default), then the rate is changed with every input sample.
- *
- * The block's ctor sets the propagation policy to TPP_DONT to
- * stop tags from automatically propagating. Instead, we handle
- * the tag propagation ourselves from within the work
- * function. Because the relative_rate changes so fast, the tag
- * placement cannot be based on a single factor after the call to
- * work and must be handled when the samples are and based on the
- * current resampling rate.
+ * \param update_once Update the resampling rate once per call
+ * to work (default=false).
+ * \param update_step How much to adjust the resampling rate by
+ * when the update occurs (default=0.001).
*/
- class BLOCKS_API test_tag_variable_rate_ff : virtual public block
- {
- public:
- // gr::blocks::test_tag_variable_rate_ff::sptr
- typedef boost::shared_ptr<test_tag_variable_rate_ff> sptr;
-
- /*!
- * Build a test_tag_variable_rate_ff block.
- *
- * \param update_once Update the resampling rate once per call
- * to work (default=false).
- * \param update_step How much to adjust the resampling rate by
- * when the update occurs (default=0.001).
- */
- static sptr make(bool update_once=false,
- double update_step=0.001);
- };
+ static sptr make(bool update_once = false, double update_step = 0.001);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_GR_TEST_TAG_VARIABLE_RATE_FF_H */
diff --git a/gr-blocks/include/gnuradio/blocks/threshold_ff.h b/gr-blocks/include/gnuradio/blocks/threshold_ff.h
index b872af0986..1fb9b2516f 100644
--- a/gr-blocks/include/gnuradio/blocks/threshold_ff.h
+++ b/gr-blocks/include/gnuradio/blocks/threshold_ff.h
@@ -27,41 +27,41 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- /*!
- * \brief Output a 1 or zero based on a threshold value.
- * \ingroup level_controllers_blk
- *
- * \details
- * Test the incoming signal against a threshold. If the signal
- * excedes the \p hi value, it will output a 1 until the signal
- * falls below the \p lo value.
- */
- class BLOCKS_API threshold_ff : virtual public sync_block
- {
- public:
- // gr::blocks::threshold_ff::sptr
- typedef boost::shared_ptr<threshold_ff> sptr;
+/*!
+ * \brief Output a 1 or zero based on a threshold value.
+ * \ingroup level_controllers_blk
+ *
+ * \details
+ * Test the incoming signal against a threshold. If the signal
+ * excedes the \p hi value, it will output a 1 until the signal
+ * falls below the \p lo value.
+ */
+class BLOCKS_API threshold_ff : virtual public sync_block
+{
+public:
+ // gr::blocks::threshold_ff::sptr
+ typedef boost::shared_ptr<threshold_ff> sptr;
- /* \brief Create a threadshold block.
- * \param lo Threshold input signal needs to drop below to
- * change state to 0.
- * \param hi Threshold input signal needs to rise above to
- * change state to 1.
- * \param initial_state Initial state of the block (0 or 1).
- */
- static sptr make(float lo, float hi, float initial_state=0);
+ /* \brief Create a threadshold block.
+ * \param lo Threshold input signal needs to drop below to
+ * change state to 0.
+ * \param hi Threshold input signal needs to rise above to
+ * change state to 1.
+ * \param initial_state Initial state of the block (0 or 1).
+ */
+ static sptr make(float lo, float hi, float initial_state = 0);
- virtual float lo () const = 0;
- virtual void set_lo (float lo) = 0;
- virtual float hi () const = 0;
- virtual void set_hi (float hi) = 0;
- virtual float last_state () const = 0;
- virtual void set_last_state (float last_state) = 0;
- };
+ virtual float lo() const = 0;
+ virtual void set_lo(float lo) = 0;
+ virtual float hi() const = 0;
+ virtual void set_hi(float hi) = 0;
+ virtual float last_state() const = 0;
+ virtual void set_last_state(float last_state) = 0;
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_GR_THRESHOLD_FF_H */
diff --git a/gr-blocks/include/gnuradio/blocks/throttle.h b/gr-blocks/include/gnuradio/blocks/throttle.h
index fa38eae09c..a93b14c192 100644
--- a/gr-blocks/include/gnuradio/blocks/throttle.h
+++ b/gr-blocks/include/gnuradio/blocks/throttle.h
@@ -27,37 +27,37 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
-
- /*!
- * \brief throttle flow of samples such that the average rate does
- * not exceed samples_per_sec.
- * \ingroup misc_blk
- *
- * \details
- * input: one stream of itemsize; output: one stream of itemsize
- *
- * N.B. this should only be used in GUI apps where there is no
- * other rate limiting block. It is not intended nor effective at
- * precisely controlling the rate of samples. That should be
- * controlled by a source or sink tied to sample clock. E.g., a
- * USRP or audio card.
- */
- class BLOCKS_API throttle : virtual public sync_block
- {
- public:
- typedef boost::shared_ptr<throttle> sptr;
-
- static sptr make(size_t itemsize, double samples_per_sec, bool ignore_tags=true);
-
- //! Sets the sample rate in samples per second.
- virtual void set_sample_rate(double rate) = 0;
-
- //! Get the sample rate in samples per second.
- virtual double sample_rate() const = 0;
- };
-
- } /* namespace blocks */
+namespace blocks {
+
+/*!
+ * \brief throttle flow of samples such that the average rate does
+ * not exceed samples_per_sec.
+ * \ingroup misc_blk
+ *
+ * \details
+ * input: one stream of itemsize; output: one stream of itemsize
+ *
+ * N.B. this should only be used in GUI apps where there is no
+ * other rate limiting block. It is not intended nor effective at
+ * precisely controlling the rate of samples. That should be
+ * controlled by a source or sink tied to sample clock. E.g., a
+ * USRP or audio card.
+ */
+class BLOCKS_API throttle : virtual public sync_block
+{
+public:
+ typedef boost::shared_ptr<throttle> sptr;
+
+ static sptr make(size_t itemsize, double samples_per_sec, bool ignore_tags = true);
+
+ //! Sets the sample rate in samples per second.
+ virtual void set_sample_rate(double rate) = 0;
+
+ //! Get the sample rate in samples per second.
+ virtual double sample_rate() const = 0;
+};
+
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_GR_THROTTLE_H */
diff --git a/gr-blocks/include/gnuradio/blocks/transcendental.h b/gr-blocks/include/gnuradio/blocks/transcendental.h
index cc7f6897d9..c93ad0d88a 100644
--- a/gr-blocks/include/gnuradio/blocks/transcendental.h
+++ b/gr-blocks/include/gnuradio/blocks/transcendental.h
@@ -28,31 +28,30 @@
#include <string>
namespace gr {
- namespace blocks {
+namespace blocks {
- /*!
- * \brief A block that performs various transcendental math operations.
- * \ingroup math_operators_blk
- *
- * \details
- * Possible function names can be found in the cmath library. IO
- * may be either complex or real, double or single precision.
- *
- * Possible type strings: float, double, complex_float, complex_double
- *
- * output[i] = trans_fcn(input[i])
- */
- class BLOCKS_API transcendental : virtual public sync_block
- {
- public:
- // gr::blocks::transcendental::sptr
- typedef boost::shared_ptr<transcendental> sptr;
+/*!
+ * \brief A block that performs various transcendental math operations.
+ * \ingroup math_operators_blk
+ *
+ * \details
+ * Possible function names can be found in the cmath library. IO
+ * may be either complex or real, double or single precision.
+ *
+ * Possible type strings: float, double, complex_float, complex_double
+ *
+ * output[i] = trans_fcn(input[i])
+ */
+class BLOCKS_API transcendental : virtual public sync_block
+{
+public:
+ // gr::blocks::transcendental::sptr
+ typedef boost::shared_ptr<transcendental> sptr;
- static sptr make(const std::string &name,
- const std::string &type="float");
- };
+ static sptr make(const std::string& name, const std::string& type = "float");
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_GR_TRANSCENDENTAL_H */
diff --git a/gr-blocks/include/gnuradio/blocks/tsb_vector_sink.h b/gr-blocks/include/gnuradio/blocks/tsb_vector_sink.h
index 4e11e7761f..94b32b8f61 100644
--- a/gr-blocks/include/gnuradio/blocks/tsb_vector_sink.h
+++ b/gr-blocks/include/gnuradio/blocks/tsb_vector_sink.h
@@ -29,42 +29,40 @@
#include <cstdint>
namespace gr {
- namespace blocks {
+namespace blocks {
- /*!
- * \brief A vector sink for tagged streams.
- *
- * Unlike a gr::blocks::vector_sink_f, this only works with tagged streams.
- *
- * \ingroup blocks
- */
-template<class T>
- class BLOCKS_API tsb_vector_sink : virtual public gr::tagged_stream_block
- {
- public:
- typedef boost::shared_ptr< tsb_vector_sink<T> > sptr;
+/*!
+ * \brief A vector sink for tagged streams.
+ *
+ * Unlike a gr::blocks::vector_sink_f, this only works with tagged streams.
+ *
+ * \ingroup blocks
+ */
+template <class T>
+class BLOCKS_API tsb_vector_sink : virtual public gr::tagged_stream_block
+{
+public:
+ typedef boost::shared_ptr<tsb_vector_sink<T>> sptr;
- virtual void reset() = 0;
- virtual std::vector<std::vector<T> > data() const = 0;
- /*! Doesn't include the TSB tags.
- */
- virtual std::vector<tag_t> tags() const = 0;
+ virtual void reset() = 0;
+ virtual std::vector<std::vector<T>> data() const = 0;
+ /*! Doesn't include the TSB tags.
+ */
+ virtual std::vector<tag_t> tags() const = 0;
- /*!
- * \param vlen Vector length
- * \param tsb_key Tagged Stream Key
- */
- static sptr make(unsigned int vlen=1,
- const std::string &tsb_key="ts_last");
- };
- typedef tsb_vector_sink<std::uint8_t> tsb_vector_sink_b;
- typedef tsb_vector_sink<std::uint32_t> tsb_vector_sink_i;
- typedef tsb_vector_sink<std::uint16_t> tsb_vector_sink_s;
- typedef tsb_vector_sink<float> tsb_vector_sink_f;
- typedef tsb_vector_sink<gr_complex> tsb_vector_sink_c;
+ /*!
+ * \param vlen Vector length
+ * \param tsb_key Tagged Stream Key
+ */
+ static sptr make(unsigned int vlen = 1, const std::string& tsb_key = "ts_last");
+};
+typedef tsb_vector_sink<std::uint8_t> tsb_vector_sink_b;
+typedef tsb_vector_sink<std::uint32_t> tsb_vector_sink_i;
+typedef tsb_vector_sink<std::uint16_t> tsb_vector_sink_s;
+typedef tsb_vector_sink<float> tsb_vector_sink_f;
+typedef tsb_vector_sink<gr_complex> tsb_vector_sink_c;
- } // namespace blocks
+} // namespace blocks
} // namespace gr
#endif /* TSB_VECTOR_SINK_H */
-
diff --git a/gr-blocks/include/gnuradio/blocks/tuntap_pdu.h b/gr-blocks/include/gnuradio/blocks/tuntap_pdu.h
index a34bab0d83..cda9b586c0 100644
--- a/gr-blocks/include/gnuradio/blocks/tuntap_pdu.h
+++ b/gr-blocks/include/gnuradio/blocks/tuntap_pdu.h
@@ -27,28 +27,28 @@
#include <gnuradio/block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief Creates TUNTAP interface and translates traffic to PDUs
+ * \ingroup networking_tools_blk
+ */
+class BLOCKS_API tuntap_pdu : virtual public block
+{
+public:
+ // gr::blocks::tuntap_pdu::sptr
+ typedef boost::shared_ptr<tuntap_pdu> sptr;
/*!
- * \brief Creates TUNTAP interface and translates traffic to PDUs
- * \ingroup networking_tools_blk
+ * \brief Construct a TUNTAP PDU interface
+ * \param dev Device name to create
+ * \param MTU Maximum Transmission Unit size
+ * \param istunflag Flag to indicate TUN or Tap
*/
- class BLOCKS_API tuntap_pdu : virtual public 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
- * \param istunflag Flag to indicate TUN or Tap
- */
- static sptr make(std::string dev, int MTU=10000, bool istunflag=false);
- };
+ static sptr make(std::string dev, int MTU = 10000, bool istunflag = false);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_BLOCKS_TUNTAP_PDU_H */
diff --git a/gr-blocks/include/gnuradio/blocks/uchar_to_float.h b/gr-blocks/include/gnuradio/blocks/uchar_to_float.h
index 2e22afe4da..99227b2291 100644
--- a/gr-blocks/include/gnuradio/blocks/uchar_to_float.h
+++ b/gr-blocks/include/gnuradio/blocks/uchar_to_float.h
@@ -27,25 +27,25 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief Convert stream of unsigned chars to a stream of floats
+ * \ingroup type_converters_blk
+ */
+class BLOCKS_API uchar_to_float : virtual public sync_block
+{
+public:
+ // gr::blocks::uchar_to_float_ff::sptr
+ typedef boost::shared_ptr<uchar_to_float> sptr;
/*!
- * \brief Convert stream of unsigned chars to a stream of floats
- * \ingroup type_converters_blk
+ * Build a uchar to float block.
*/
- class BLOCKS_API uchar_to_float : virtual public sync_block
- {
- public:
- // gr::blocks::uchar_to_float_ff::sptr
- typedef boost::shared_ptr<uchar_to_float> sptr;
-
- /*!
- * Build a uchar to float block.
- */
- static sptr make();
- };
+ static sptr make();
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_BLOCKS_UCHAR_TO_FLOAT_H */
diff --git a/gr-blocks/include/gnuradio/blocks/udp_sink.h b/gr-blocks/include/gnuradio/blocks/udp_sink.h
index 76e2a2184b..c6278079f3 100644
--- a/gr-blocks/include/gnuradio/blocks/udp_sink.h
+++ b/gr-blocks/include/gnuradio/blocks/udp_sink.h
@@ -27,55 +27,57 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief Write stream to an UDP socket.
+ * \ingroup networking_tools_blk
+ */
+class BLOCKS_API udp_sink : virtual public sync_block
+{
+public:
+ // gr::blocks::udp_sink::sptr
+ typedef boost::shared_ptr<udp_sink> sptr;
/*!
- * \brief Write stream to an UDP socket.
- * \ingroup networking_tools_blk
+ * \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
*/
- class BLOCKS_API udp_sink : virtual public sync_block
- {
- public:
- // gr::blocks::udp_sink::sptr
- typedef boost::shared_ptr<udp_sink> sptr;
+ static sptr make(size_t itemsize,
+ const std::string& host,
+ int port,
+ int payload_size = 1472,
+ bool eof = true);
- /*!
- * \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 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 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;
- };
+ /*! \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 blocks */
} /* namespace gr */
#endif /* INCLUDED_GR_UDP_SINK_H */
diff --git a/gr-blocks/include/gnuradio/blocks/udp_source.h b/gr-blocks/include/gnuradio/blocks/udp_source.h
index d1b4062b79..3581dfddff 100644
--- a/gr-blocks/include/gnuradio/blocks/udp_source.h
+++ b/gr-blocks/include/gnuradio/blocks/udp_source.h
@@ -27,58 +27,59 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief Read stream from an UDP socket.
+ * \ingroup networking_tools_blk
+ */
+class BLOCKS_API udp_source : virtual public sync_block
+{
+public:
+ // gr::blocks::udp_source::sptr
+ typedef boost::shared_ptr<udp_source> sptr;
/*!
- * \brief Read stream from an UDP socket.
- * \ingroup networking_tools_blk
+ * \brief UDP Source Constructor
+ *
+ * \param itemsize The size (in bytes) of the item datatype
+ * \param host The name or IP address of the transmitting 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)
*/
- class BLOCKS_API udp_source : virtual public 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 transmitting 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);
+ 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 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 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 PAYLOAD_SIZE of the socket */
+ virtual int payload_size() = 0;
- /*! \brief return the port number of the socket */
- virtual int get_port() = 0;
- };
+ /*! \brief return the port number of the socket */
+ virtual int get_port() = 0;
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_GR_UDP_SOURCE_H */
diff --git a/gr-blocks/include/gnuradio/blocks/unpack_k_bits.h b/gr-blocks/include/gnuradio/blocks/unpack_k_bits.h
index 8d46e57edd..4c5342de7f 100644
--- a/gr-blocks/include/gnuradio/blocks/unpack_k_bits.h
+++ b/gr-blocks/include/gnuradio/blocks/unpack_k_bits.h
@@ -21,66 +21,66 @@
*/
#ifndef INCLUDED_GR_BLOCKS_UNPACK_K_BITS_H
-#define INCLUDED_GR_BLOCKS_UNPACK_K_BITS_H
+#define INCLUDED_GR_BLOCKS_UNPACK_K_BITS_H
#include <gnuradio/blocks/api.h>
#include <vector>
namespace gr {
- namespace blocks {
- namespace kernel {
+namespace blocks {
+namespace kernel {
- /*!
- * \brief Converts a byte with k relevant bits to k output bytes with 1 bit in the LSB.
- *
- * This is the algorithm kernel for the gr::blocks::unpack_k_bits_bb block.
- *
- * Example:
- * k = 4
- * in = [0xf5, 0x08]
- * out = [0,1,0,1, 1,0,0,0]
- *
- * k = 8
- * in = [0xf5, 0x08]
- * out = [1,1,1,1, 0,1,0,1, 0,0,0,0, 1,0,0,0]
- * \ingroup byte_operators_blk
- */
- class BLOCKS_API unpack_k_bits
- {
- public:
- /*!
- * \brief Make an unpack_k_bits object.
- * \param k number of bits to unpack.
- */
- unpack_k_bits(unsigned k);
- ~unpack_k_bits();
+/*!
+ * \brief Converts a byte with k relevant bits to k output bytes with 1 bit in the LSB.
+ *
+ * This is the algorithm kernel for the gr::blocks::unpack_k_bits_bb block.
+ *
+ * Example:
+ * k = 4
+ * in = [0xf5, 0x08]
+ * out = [0,1,0,1, 1,0,0,0]
+ *
+ * k = 8
+ * in = [0xf5, 0x08]
+ * out = [1,1,1,1, 0,1,0,1, 0,0,0,0, 1,0,0,0]
+ * \ingroup byte_operators_blk
+ */
+class BLOCKS_API unpack_k_bits
+{
+public:
+ /*!
+ * \brief Make an unpack_k_bits object.
+ * \param k number of bits to unpack.
+ */
+ unpack_k_bits(unsigned k);
+ ~unpack_k_bits();
- /*!
- * \brief Perform the unpacking.
- *
- * This function performs no bounds checking. It assumes that the
- * input, \p in, has of length \p nbytes and that the output
- * vector, \p out, has k*nbytes available for writing.
- *
- * \param bits output vector (1-bit per byte) of the unpacked data
- * \param bytes The input vector of bytes to unpack
- * \param nbytes The number of input bytes
- */
- void unpack(unsigned char *bits, const unsigned char *bytes, int nbytes) const;
+ /*!
+ * \brief Perform the unpacking.
+ *
+ * This function performs no bounds checking. It assumes that the
+ * input, \p in, has of length \p nbytes and that the output
+ * vector, \p out, has k*nbytes available for writing.
+ *
+ * \param bits output vector (1-bit per byte) of the unpacked data
+ * \param bytes The input vector of bytes to unpack
+ * \param nbytes The number of input bytes
+ */
+ void unpack(unsigned char* bits, const unsigned char* bytes, int nbytes) const;
- /*!
- * Unpacks in reverse order from unpack().
- */
- void unpack_rev(unsigned char *bits, const unsigned char *bytes, int nbytes) const;
+ /*!
+ * Unpacks in reverse order from unpack().
+ */
+ void unpack_rev(unsigned char* bits, const unsigned char* bytes, int nbytes) const;
- int k() const;
+ int k() const;
- private:
- unsigned d_k;
- };
+private:
+ unsigned d_k;
+};
- } /* namespace kernel */
- } /* namespace blocks */
+} /* namespace kernel */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_GR_BLOCKS_UNPACK_K_BITS_BB_H */
diff --git a/gr-blocks/include/gnuradio/blocks/unpack_k_bits_bb.h b/gr-blocks/include/gnuradio/blocks/unpack_k_bits_bb.h
index 2ed57e08bd..7aaa7eec2a 100644
--- a/gr-blocks/include/gnuradio/blocks/unpack_k_bits_bb.h
+++ b/gr-blocks/include/gnuradio/blocks/unpack_k_bits_bb.h
@@ -21,40 +21,40 @@
*/
#ifndef INCLUDED_GR_UNPACK_K_BITS_BB_H
-#define INCLUDED_GR_UNPACK_K_BITS_BB_H
+#define INCLUDED_GR_UNPACK_K_BITS_BB_H
#include <gnuradio/blocks/api.h>
#include <gnuradio/sync_interpolator.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief Converts a byte with k relevant bits to k output bytes with 1 bit in the LSB.
+ *
+ * This block picks the K least significant bits from a byte, and expands
+ * them into K bytes of 0 or 1.
+ *
+ * Example:
+ * k = 4
+ * in = [0xf5, 0x08]
+ * out = [0,1,0,1, 1,0,0,0]
+ * \ingroup byte_operators_blk
+ */
+class BLOCKS_API unpack_k_bits_bb : virtual public sync_interpolator
+{
+public:
+ // gr::blocks::unpack_k_bits_bb::sptr
+ typedef boost::shared_ptr<unpack_k_bits_bb> sptr;
/*!
- * \brief Converts a byte with k relevant bits to k output bytes with 1 bit in the LSB.
- *
- * This block picks the K least significant bits from a byte, and expands
- * them into K bytes of 0 or 1.
- *
- * Example:
- * k = 4
- * in = [0xf5, 0x08]
- * out = [0,1,0,1, 1,0,0,0]
- * \ingroup byte_operators_blk
+ * \brief Make an unpack_k_bits block.
+ * \param k number of bits to unpack.
*/
- class BLOCKS_API unpack_k_bits_bb : virtual public 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);
- };
+ static sptr make(unsigned k);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_GR_UNPACK_K_BITS_BB_H */
diff --git a/gr-blocks/include/gnuradio/blocks/unpacked_to_packed.h b/gr-blocks/include/gnuradio/blocks/unpacked_to_packed.h
index d23ff6cc12..9317e1add5 100644
--- a/gr-blocks/include/gnuradio/blocks/unpacked_to_packed.h
+++ b/gr-blocks/include/gnuradio/blocks/unpacked_to_packed.h
@@ -30,48 +30,47 @@
#include <cstdint>
namespace gr {
- namespace blocks {
+namespace blocks {
- /*!
- * \brief Convert a stream of unpacked bytes or shorts into a stream of packed bytes or shorts.
- * \ingroup byte_operators_blk
- *
- * \details
- * input: stream of T; output: stream of T
- *
- * This is the inverse of gr::blocks::packed_to_unpacked_XX.
- *
- * The low \p bits_per_chunk bits are extracted from each input
- * byte or short. These bits are then packed densely into the
- * output bytes or shorts, such that all 8 or 16 bits of the
- * output bytes or shorts are filled with valid input bits. The
- * right thing is done if bits_per_chunk is not a power of two.
- *
- * The combination of gr::blocks::packed_to_unpacked_XX followed by
- * gr_chunks_to_symbols_Xf or gr_chunks_to_symbols_Xc handles the
- * general case of mapping from a stream of bytes or shorts into
- * arbitrary float or complex symbols.
- *
- * \sa gr::blocks::packed_to_unpacked_bb, gr::blocks::unpacked_to_packed_bb,
- * \sa gr::blocks::packed_to_unpacked_ss, gr::blocks::unpacked_to_packed_ss,
- * \sa gr::blocks::chunks_to_symbols_bf, gr::blocks::chunks_to_symbols_bc.
- * \sa gr::blocks::chunks_to_symbols_sf, gr::blocks::chunks_to_symbols_sc.
- */
-template<class T>
- class BLOCKS_API unpacked_to_packed : virtual public block
- {
- public:
- // gr::blocks::unpacked_to_packed::sptr
- typedef boost::shared_ptr< unpacked_to_packed<T> > sptr;
+/*!
+ * \brief Convert a stream of unpacked bytes or shorts into a stream of packed bytes or
+ * shorts. \ingroup byte_operators_blk
+ *
+ * \details
+ * input: stream of T; output: stream of T
+ *
+ * This is the inverse of gr::blocks::packed_to_unpacked_XX.
+ *
+ * The low \p bits_per_chunk bits are extracted from each input
+ * byte or short. These bits are then packed densely into the
+ * output bytes or shorts, such that all 8 or 16 bits of the
+ * output bytes or shorts are filled with valid input bits. The
+ * right thing is done if bits_per_chunk is not a power of two.
+ *
+ * The combination of gr::blocks::packed_to_unpacked_XX followed by
+ * gr_chunks_to_symbols_Xf or gr_chunks_to_symbols_Xc handles the
+ * general case of mapping from a stream of bytes or shorts into
+ * arbitrary float or complex symbols.
+ *
+ * \sa gr::blocks::packed_to_unpacked_bb, gr::blocks::unpacked_to_packed_bb,
+ * \sa gr::blocks::packed_to_unpacked_ss, gr::blocks::unpacked_to_packed_ss,
+ * \sa gr::blocks::chunks_to_symbols_bf, gr::blocks::chunks_to_symbols_bc.
+ * \sa gr::blocks::chunks_to_symbols_sf, gr::blocks::chunks_to_symbols_sc.
+ */
+template <class T>
+class BLOCKS_API unpacked_to_packed : virtual public block
+{
+public:
+ // gr::blocks::unpacked_to_packed::sptr
+ typedef boost::shared_ptr<unpacked_to_packed<T>> sptr;
- static sptr make(unsigned int bits_per_chunk,
- endianness_t endianness);
- };
+ static sptr make(unsigned int bits_per_chunk, endianness_t endianness);
+};
typedef unpacked_to_packed<std::uint8_t> unpacked_to_packed_bb;
typedef unpacked_to_packed<std::int16_t> unpacked_to_packed_ss;
typedef unpacked_to_packed<std::int32_t> unpacked_to_packed_ii;
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* UNPACKED_TO_PACKED_H */
diff --git a/gr-blocks/include/gnuradio/blocks/vco_c.h b/gr-blocks/include/gnuradio/blocks/vco_c.h
index ab9723af5b..b897196238 100644
--- a/gr-blocks/include/gnuradio/blocks/vco_c.h
+++ b/gr-blocks/include/gnuradio/blocks/vco_c.h
@@ -27,33 +27,33 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief VCO - Voltage controlled oscillator
+ * \ingroup modulators_blk
+ * \ingroup waveform_generators_blk
+ *
+ * \details
+ * input: float stream of control voltages; output: complex oscillator output
+ */
+class BLOCKS_API vco_c : virtual public sync_block
+{
+public:
+ // gr::blocks::vco_c::sptr
+ typedef boost::shared_ptr<vco_c> sptr;
/*!
* \brief VCO - Voltage controlled oscillator
- * \ingroup modulators_blk
- * \ingroup waveform_generators_blk
*
- * \details
- * input: float stream of control voltages; output: complex oscillator output
+ * \param sampling_rate sampling rate (Hz)
+ * \param sensitivity units are radians/sec/volt
+ * \param amplitude output amplitude
*/
- class BLOCKS_API vco_c : virtual public sync_block
- {
- public:
- // gr::blocks::vco_c::sptr
- typedef boost::shared_ptr<vco_c> 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);
- };
+ static sptr make(double sampling_rate, double sensitivity, double amplitude);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_GR_VCO_C_H */
diff --git a/gr-blocks/include/gnuradio/blocks/vco_f.h b/gr-blocks/include/gnuradio/blocks/vco_f.h
index 51d40af81b..48e7dd5e8b 100644
--- a/gr-blocks/include/gnuradio/blocks/vco_f.h
+++ b/gr-blocks/include/gnuradio/blocks/vco_f.h
@@ -27,33 +27,33 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief VCO - Voltage controlled oscillator
+ * \ingroup modulators_blk
+ * \ingroup waveform_generators_blk
+ *
+ * \details
+ * input: float stream of control voltages; output: float oscillator output
+ */
+class BLOCKS_API vco_f : virtual public sync_block
+{
+public:
+ // gr::blocks::vco_f::sptr
+ typedef boost::shared_ptr<vco_f> sptr;
/*!
* \brief VCO - Voltage controlled oscillator
- * \ingroup modulators_blk
- * \ingroup waveform_generators_blk
*
- * \details
- * input: float stream of control voltages; output: float oscillator output
+ * \param sampling_rate sampling rate (Hz)
+ * \param sensitivity units are radians/sec/volt
+ * \param amplitude output amplitude
*/
- class BLOCKS_API vco_f : virtual public 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);
- };
+ static sptr make(double sampling_rate, double sensitivity, double amplitude);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_GR_VCO_F_H */
diff --git a/gr-blocks/include/gnuradio/blocks/vector_insert.h b/gr-blocks/include/gnuradio/blocks/vector_insert.h
index cce50ed445..ee24adca36 100644
--- a/gr-blocks/include/gnuradio/blocks/vector_insert.h
+++ b/gr-blocks/include/gnuradio/blocks/vector_insert.h
@@ -29,39 +29,38 @@
#include <cstdint>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief source of T's that gets its data from a vector
+ * \ingroup stream_operators_blk
+ */
+template <class T>
+class BLOCKS_API vector_insert : virtual public block
+{
+public:
+ // gr::blocks::vector_insert::sptr
+ typedef boost::shared_ptr<vector_insert<T>> sptr;
/*!
- * \brief source of T's that gets its data from a vector
- * \ingroup stream_operators_blk
+ * Make vector insert block.
+ *
+ * \param data vector of data to insert
+ * \param periodicity number of samples between when to send \p data
+ * \param offset initial item offset of first insert
*/
-template<class T>
- class BLOCKS_API vector_insert : virtual public block
- {
- public:
- // gr::blocks::vector_insert::sptr
- typedef boost::shared_ptr< vector_insert<T> > sptr;
-
- /*!
- * Make vector insert block.
- *
- * \param data vector of data to insert
- * \param periodicity number of samples between when to send \p data
- * \param offset initial item offset of first insert
- */
- static sptr make(const std::vector<T> &data,
- int periodicity, int offset=0);
+ static sptr make(const std::vector<T>& data, int periodicity, int offset = 0);
- virtual void rewind() = 0;
- virtual void set_data(const std::vector<T> &data) = 0;
- };
+ virtual void rewind() = 0;
+ virtual void set_data(const std::vector<T>& data) = 0;
+};
typedef vector_insert<std::uint8_t> vector_insert_b;
typedef vector_insert<std::int16_t> vector_insert_s;
typedef vector_insert<std::int32_t> vector_insert_i;
typedef vector_insert<float> vector_insert_f;
typedef vector_insert<gr_complex> vector_insert_c;
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* VECTOR_INSERT_H */
diff --git a/gr-blocks/include/gnuradio/blocks/vector_map.h b/gr-blocks/include/gnuradio/blocks/vector_map.h
index bd0e74c9f3..bdf39f1355 100644
--- a/gr-blocks/include/gnuradio/blocks/vector_map.h
+++ b/gr-blocks/include/gnuradio/blocks/vector_map.h
@@ -28,45 +28,46 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief Maps elements from a set of input vectors to a set of output vectors.
+ * \ingroup stream_operators_blk
+ *
+ * \details
+ * 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 sync_block
+{
+public:
+ // gr::blocks::vector_map::sptr
+ typedef boost::shared_ptr<vector_map> sptr;
/*!
- * \brief Maps elements from a set of input vectors to a set of output vectors.
- * \ingroup stream_operators_blk
- *
- * \details
- * If in[i] is the input vector in the i'th stream then the output
- * vector in the j'th stream is:
+ * Build a vector map block.
*
- * 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).
+ * \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
*/
- class BLOCKS_API vector_map : virtual public 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);
+ 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;
- };
+ virtual void set_mapping(std::vector<std::vector<std::vector<size_t>>> mapping) = 0;
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_GR_VECTOR_MAP_H */
diff --git a/gr-blocks/include/gnuradio/blocks/vector_sink.h b/gr-blocks/include/gnuradio/blocks/vector_sink.h
index 581e0be970..c180bd5e53 100644
--- a/gr-blocks/include/gnuradio/blocks/vector_sink.h
+++ b/gr-blocks/include/gnuradio/blocks/vector_sink.h
@@ -29,42 +29,42 @@
#include <cstdint>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief T sink that writes to a vector
+ * \ingroup debug_tools_blk
+ */
+template <class T>
+class BLOCKS_API vector_sink : virtual public sync_block
+{
+public:
+ // gr::blocks::vector_sink::sptr
+ typedef boost::shared_ptr<vector_sink<T>> sptr;
/*!
- * \brief T sink that writes to a vector
- * \ingroup debug_tools_blk
+ * \brief Make a new instance of the vector source, and return a shared pointer to it.
+ * \param vlen length of vector items
+ * \param reserve_items reserve space in the internal storage for this many items;
+ * the internal storage will still grow to accommodate more item
+ * if necessary, but setting this to a realistic value can avoid
+ * memory allocations during runtime, especially if you know a
+ * priori how many items you're going to store.
*/
-template<class T>
- class BLOCKS_API vector_sink : virtual public sync_block
- {
- public:
- // gr::blocks::vector_sink::sptr
- typedef boost::shared_ptr< vector_sink<T> > sptr;
-
- /*!
- * \brief Make a new instance of the vector source, and return a shared pointer to it.
- * \param vlen length of vector items
- * \param reserve_items reserve space in the internal storage for this many items;
- * the internal storage will still grow to accommodate more item
- * if necessary, but setting this to a realistic value can avoid
- * memory allocations during runtime, especially if you know a
- * priori how many items you're going to store.
- */
- static sptr make(const unsigned int vlen = 1, const int reserve_items = 1024);
+ static sptr make(const unsigned int vlen = 1, const int reserve_items = 1024);
- //! Clear the data and tags containers.
- virtual void reset() = 0;
- virtual std::vector<T> data() const = 0;
- virtual std::vector<tag_t> tags() const = 0;
- };
+ //! Clear the data and tags containers.
+ virtual void reset() = 0;
+ virtual std::vector<T> data() const = 0;
+ virtual std::vector<tag_t> tags() const = 0;
+};
typedef vector_sink<std::uint8_t> vector_sink_b;
typedef vector_sink<std::int16_t> vector_sink_s;
typedef vector_sink<std::int32_t> vector_sink_i;
typedef vector_sink<float> vector_sink_f;
typedef vector_sink<gr_complex> vector_sink_c;
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* VECTOR_SINK_H */
diff --git a/gr-blocks/include/gnuradio/blocks/vector_source.h b/gr-blocks/include/gnuradio/blocks/vector_source.h
index ae25d85b62..b7aff6e49a 100644
--- a/gr-blocks/include/gnuradio/blocks/vector_source.h
+++ b/gr-blocks/include/gnuradio/blocks/vector_source.h
@@ -29,63 +29,64 @@
#include <cstdint>
namespace gr {
- namespace blocks {
+namespace blocks {
- /*!
- * \brief Source that streams T items based on the input \p data vector.
- * \ingroup misc_blk
- *
- * \details
- * This block produces a stream of samples based on an input
- * vector. In C++, this is a std::vector<T>, and in Python,
- * this is either a list or tuple. The data can repeat infinitely
- * until the flowgraph is terminated by some other event or, the
- * default, run the data once and stop.
- *
- * The vector source can also produce stream tags with the
- * data. Pass in a vector of gr::tag_t objects and they will be
- * emitted based on the specified offset of the tag.
- *
- * GNU Radio provides a utility Python module in gr.tag_utils to
- * convert between tags and Python objects:
- * gr.tag_utils.python_to_tag.
- *
- * We can create tags as Python lists (or tuples) using the list
- * structure [int offset, pmt key, pmt value, pmt srcid]. It is
- * important to define the list/tuple with the values in the
- * correct order and with the correct data type. A python
- * dictionary can also be used using the keys: "offset", "key",
- * "value", and "srcid" with the same data types as for the lists.
- *
- * When given a list of tags, the vector source will emit the tags
- * repeatedly by updating the offset relative to the vector stream
- * length. That is, if the vector has 500 items and a tag has an
- * offset of 0, that tag will be placed on item 0, 500, 1000,
- * 1500, etc.
- */
-template<class T>
- class BLOCKS_API vector_source : virtual public sync_block
- {
- public:
- // gr::blocks::vector_source::sptr
- typedef boost::shared_ptr< vector_source<T> > sptr;
+/*!
+ * \brief Source that streams T items based on the input \p data vector.
+ * \ingroup misc_blk
+ *
+ * \details
+ * This block produces a stream of samples based on an input
+ * vector. In C++, this is a std::vector<T>, and in Python,
+ * this is either a list or tuple. The data can repeat infinitely
+ * until the flowgraph is terminated by some other event or, the
+ * default, run the data once and stop.
+ *
+ * The vector source can also produce stream tags with the
+ * data. Pass in a vector of gr::tag_t objects and they will be
+ * emitted based on the specified offset of the tag.
+ *
+ * GNU Radio provides a utility Python module in gr.tag_utils to
+ * convert between tags and Python objects:
+ * gr.tag_utils.python_to_tag.
+ *
+ * We can create tags as Python lists (or tuples) using the list
+ * structure [int offset, pmt key, pmt value, pmt srcid]. It is
+ * important to define the list/tuple with the values in the
+ * correct order and with the correct data type. A python
+ * dictionary can also be used using the keys: "offset", "key",
+ * "value", and "srcid" with the same data types as for the lists.
+ *
+ * When given a list of tags, the vector source will emit the tags
+ * repeatedly by updating the offset relative to the vector stream
+ * length. That is, if the vector has 500 items and a tag has an
+ * offset of 0, that tag will be placed on item 0, 500, 1000,
+ * 1500, etc.
+ */
+template <class T>
+class BLOCKS_API vector_source : virtual public sync_block
+{
+public:
+ // gr::blocks::vector_source::sptr
+ typedef boost::shared_ptr<vector_source<T>> sptr;
- static sptr make(const std::vector<T> &data,
- bool repeat=false, unsigned int vlen=1,
- const std::vector<tag_t> &tags=std::vector<tag_t>());
+ static sptr make(const std::vector<T>& data,
+ bool repeat = false,
+ unsigned int vlen = 1,
+ const std::vector<tag_t>& tags = std::vector<tag_t>());
- virtual void rewind() = 0;
- virtual void set_data(const std::vector<T> &data,
- const std::vector<tag_t> &tags=std::vector<tag_t>()) = 0;
- virtual void set_repeat(bool repeat) = 0;
- };
+ virtual void rewind() = 0;
+ virtual void set_data(const std::vector<T>& data,
+ const std::vector<tag_t>& tags = std::vector<tag_t>()) = 0;
+ virtual void set_repeat(bool repeat) = 0;
+};
typedef vector_source<std::uint8_t> vector_source_b;
typedef vector_source<std::int16_t> vector_source_s;
typedef vector_source<std::int32_t> vector_source_i;
typedef vector_source<float> vector_source_f;
typedef vector_source<gr_complex> vector_source_c;
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* VECTOR_SOURCE_H */
diff --git a/gr-blocks/include/gnuradio/blocks/vector_to_stream.h b/gr-blocks/include/gnuradio/blocks/vector_to_stream.h
index f1b919d218..67b40f4f4f 100644
--- a/gr-blocks/include/gnuradio/blocks/vector_to_stream.h
+++ b/gr-blocks/include/gnuradio/blocks/vector_to_stream.h
@@ -27,28 +27,28 @@
#include <gnuradio/sync_interpolator.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief convert a stream of gnuradio/blocks of nitems_per_block items into a stream of
+ * items \ingroup stream_operators_blk
+ */
+class BLOCKS_API vector_to_stream : virtual public sync_interpolator
+{
+public:
+ // gr::blocks::vector_to_stream::sptr
+ typedef boost::shared_ptr<vector_to_stream> sptr;
/*!
- * \brief convert a stream of gnuradio/blocks of nitems_per_block items into a stream of items
- * \ingroup stream_operators_blk
+ * Make vector-to-stream block
+ *
+ * \param itemsize the item size of the stream
+ * \param nitems_per_block number of items per vector (vector size)
*/
- class BLOCKS_API vector_to_stream : virtual public sync_interpolator
- {
- public:
- // gr::blocks::vector_to_stream::sptr
- typedef boost::shared_ptr<vector_to_stream> sptr;
-
- /*!
- * Make vector-to-stream block
- *
- * \param itemsize the item size of the stream
- * \param nitems_per_block number of items per vector (vector size)
- */
- static sptr make(size_t itemsize, size_t nitems_per_block);
- };
+ static sptr make(size_t itemsize, size_t nitems_per_block);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_BLOCKS_VECTOR_TO_STREAM_H */
diff --git a/gr-blocks/include/gnuradio/blocks/vector_to_streams.h b/gr-blocks/include/gnuradio/blocks/vector_to_streams.h
index 42ec114498..406f735c4f 100644
--- a/gr-blocks/include/gnuradio/blocks/vector_to_streams.h
+++ b/gr-blocks/include/gnuradio/blocks/vector_to_streams.h
@@ -27,29 +27,29 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
+
+/*!
+ * \brief Convert 1 stream of vectors of length N to N streams of items
+ * \ingroup stream_operators_blk
+ */
+class BLOCKS_API vector_to_streams : virtual public sync_block
+{
+public:
+ // gr::blocks::vector_to_streams::sptr
+ typedef boost::shared_ptr<vector_to_streams> sptr;
/*!
- * \brief Convert 1 stream of vectors of length N to N streams of items
- * \ingroup stream_operators_blk
+ * Make vector-to-streams block
+ *
+ * \param itemsize the item size of the stream
+ * \param nstreams number of items per vector (vector size and
+ * number of streams produced)
*/
- class BLOCKS_API vector_to_streams : virtual public sync_block
- {
- public:
- // gr::blocks::vector_to_streams::sptr
- typedef boost::shared_ptr<vector_to_streams> sptr;
-
- /*!
- * Make vector-to-streams block
- *
- * \param itemsize the item size of the stream
- * \param nstreams number of items per vector (vector size and
- * number of streams produced)
- */
- static sptr make(size_t itemsize, size_t nstreams);
- };
+ static sptr make(size_t itemsize, size_t nstreams);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_BLOCKS_VECTOR_TO_STREAMS_H */
diff --git a/gr-blocks/include/gnuradio/blocks/wavfile.h b/gr-blocks/include/gnuradio/blocks/wavfile.h
index 2c03319c4a..caf06532c3 100644
--- a/gr-blocks/include/gnuradio/blocks/wavfile.h
+++ b/gr-blocks/include/gnuradio/blocks/wavfile.h
@@ -30,76 +30,73 @@
#include <cstdio>
namespace gr {
- namespace blocks {
+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.
- */
- BLOCKS_API 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 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.
+ */
+BLOCKS_API 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.
- *
- * \details
- * Takes care of endianness.
- */
- BLOCKS_API short int wav_read_sample(FILE *fp, int bytes_per_sample);
+/*!
+ * \brief Read one sample from an open WAV file at the current position.
+ *
+ * \details
+ * Takes care of endianness.
+ */
+BLOCKS_API 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.
- */
- BLOCKS_API bool wavheader_write(FILE *fp,
- unsigned int sample_rate,
- int nchans,
- 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.
+ */
+BLOCKS_API 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.
- *
- * \details
- * Takes care of endianness.
- */
- BLOCKS_API void wav_write_sample(FILE *fp, short int sample, int bytes_per_sample);
+/*!
+ * \brief Write one sample to an open WAV file at the current position.
+ *
+ * \details
+ * Takes care of endianness.
+ */
+BLOCKS_API void wav_write_sample(FILE* fp, short int sample, int bytes_per_sample);
- /*!
- * \brief Complete a WAV header
- *
- * \details
- * 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 wherever).
- *
- * \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.
- */
- BLOCKS_API bool wavheader_complete(FILE *fp, unsigned int byte_count);
+/*!
+ * \brief Complete a WAV header
+ *
+ * \details
+ * 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 wherever).
+ *
+ * \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.
+ */
+BLOCKS_API bool wavheader_complete(FILE* fp, unsigned int byte_count);
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* _GR_WAVFILE_H_ */
-
diff --git a/gr-blocks/include/gnuradio/blocks/wavfile_sink.h b/gr-blocks/include/gnuradio/blocks/wavfile_sink.h
index d841a8b303..c9d9501ebf 100644
--- a/gr-blocks/include/gnuradio/blocks/wavfile_sink.h
+++ b/gr-blocks/include/gnuradio/blocks/wavfile_sink.h
@@ -27,61 +27,61 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- /*!
- * \brief Write stream to a Microsoft PCM (.wav) file.
- * \ingroup audio_blk
- *
- * \details
- * Values must be floats within [-1;1].
- * Check gr_make_wavfile_sink() for extra info.
- */
- class BLOCKS_API wavfile_sink : virtual public sync_block
- {
- public:
- // gr::blocks::wavfile_sink::sptr
- typedef boost::shared_ptr<wavfile_sink> sptr;
+/*!
+ * \brief Write stream to a Microsoft PCM (.wav) file.
+ * \ingroup audio_blk
+ *
+ * \details
+ * Values must be floats within [-1;1].
+ * Check gr_make_wavfile_sink() for extra info.
+ */
+class BLOCKS_API wavfile_sink : virtual public sync_block
+{
+public:
+ // gr::blocks::wavfile_sink::sptr
+ typedef boost::shared_ptr<wavfile_sink> sptr;
- /*
- * \param filename The .wav file to be opened
- * \param n_channels Number of channels (2 = stereo or I/Q output)
- * \param sample_rate Sample rate [S/s]
- * \param 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);
+ /*
+ * \param filename The .wav file to be opened
+ * \param n_channels Number of channels (2 = stereo or I/Q output)
+ * \param sample_rate Sample rate [S/s]
+ * \param 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 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 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 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;
- };
+ /*!
+ * \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 blocks */
} /* namespace gr */
#endif /* INCLUDED_GR_WAVFILE_SINK_H */
diff --git a/gr-blocks/include/gnuradio/blocks/wavfile_source.h b/gr-blocks/include/gnuradio/blocks/wavfile_source.h
index bb46d4ba0c..62d2c20854 100644
--- a/gr-blocks/include/gnuradio/blocks/wavfile_source.h
+++ b/gr-blocks/include/gnuradio/blocks/wavfile_source.h
@@ -27,44 +27,44 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- /*!
- * \brief Read stream from a Microsoft PCM (.wav) file, output floats
- * \ingroup audio_blk
- *
- * \details
- * Unless otherwise called, values are within [-1;1].
- * Check gr_make_wavfile_source() for extra info.
- */
- class BLOCKS_API wavfile_source : virtual public sync_block
- {
- public:
- // gr::blocks::wavfile_source::sptr
- typedef boost::shared_ptr<wavfile_source> sptr;
+/*!
+ * \brief Read stream from a Microsoft PCM (.wav) file, output floats
+ * \ingroup audio_blk
+ *
+ * \details
+ * Unless otherwise called, values are within [-1;1].
+ * Check gr_make_wavfile_source() for extra info.
+ */
+class BLOCKS_API wavfile_source : virtual public sync_block
+{
+public:
+ // gr::blocks::wavfile_source::sptr
+ typedef boost::shared_ptr<wavfile_source> sptr;
- static sptr make(const char *filename, bool repeat = false);
+ 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 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 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;
- };
+ /*!
+ * \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 blocks */
} /* namespace gr */
#endif /* INCLUDED_GR_WAVFILE_SOURCE_H */
diff --git a/gr-blocks/include/gnuradio/blocks/xor_blk.h b/gr-blocks/include/gnuradio/blocks/xor_blk.h
index 3113a0703c..da937614ed 100644
--- a/gr-blocks/include/gnuradio/blocks/xor_blk.h
+++ b/gr-blocks/include/gnuradio/blocks/xor_blk.h
@@ -29,29 +29,28 @@
#include <cstdint>
namespace gr {
- namespace blocks {
+namespace blocks {
- /*!
- * \brief output = input_0 ^ input_1 ^ , ... ^ input_N)
- * \ingroup boolean_operators_blk
- *
- * Bitwise boolean xor across all input streams.
- */
-template<class T>
- class BLOCKS_API xor_blk : virtual public sync_block
- {
- public:
-
- // gr::blocks::xor::sptr
- typedef boost::shared_ptr< xor_blk<T> > sptr;
+/*!
+ * \brief output = input_0 ^ input_1 ^ , ... ^ input_N)
+ * \ingroup boolean_operators_blk
+ *
+ * Bitwise boolean xor across all input streams.
+ */
+template <class T>
+class BLOCKS_API xor_blk : virtual public sync_block
+{
+public:
+ // gr::blocks::xor::sptr
+ typedef boost::shared_ptr<xor_blk<T>> sptr;
- static sptr make(size_t vlen=1);
- };
+ static sptr make(size_t vlen = 1);
+};
typedef xor_blk<std::uint8_t> xor_bb;
typedef xor_blk<std::int16_t> xor_ss;
typedef xor_blk<std::int32_t> xor_ii;
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* XOR_BLK_H */
diff --git a/gr-blocks/lib/abs_blk_impl.cc b/gr-blocks/lib/abs_blk_impl.cc
index aab0c8552a..cc772aec81 100644
--- a/gr-blocks/lib/abs_blk_impl.cc
+++ b/gr-blocks/lib/abs_blk_impl.cc
@@ -29,42 +29,41 @@
#include <gnuradio/io_signature.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- template <class T>
- typename abs_blk<T>::sptr abs_blk<T>::make(size_t vlen)
- {
- return gnuradio::get_initial_sptr(new abs_blk_impl<T> (vlen));
- }
+template <class T>
+typename abs_blk<T>::sptr abs_blk<T>::make(size_t vlen)
+{
+ return gnuradio::get_initial_sptr(new abs_blk_impl<T>(vlen));
+}
- template <class T>
- abs_blk_impl<T> ::abs_blk_impl (size_t vlen)
- : sync_block("abs_blk",
- io_signature::make (1, 1, sizeof (T)*vlen),
- io_signature::make (1, 1, sizeof (T)*vlen)),
- d_vlen(vlen)
- {
- }
+template <class T>
+abs_blk_impl<T>::abs_blk_impl(size_t vlen)
+ : sync_block("abs_blk",
+ io_signature::make(1, 1, sizeof(T) * vlen),
+ io_signature::make(1, 1, sizeof(T) * vlen)),
+ d_vlen(vlen)
+{
+}
- template <class T>
- int
- abs_blk_impl<T> ::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- T *iptr = (T *) input_items[0];
- T *optr = (T *) output_items[0];
+template <class T>
+int abs_blk_impl<T>::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ T* iptr = (T*)input_items[0];
+ T* optr = (T*)output_items[0];
- for(size_t i=0; i<noutput_items*d_vlen; i++) {
+ for (size_t i = 0; i < noutput_items * d_vlen; i++) {
T val = iptr[i];
optr[i] = ((val < ((T)0)) ? -val : val);
- }
-
- return noutput_items;
}
+ return noutput_items;
+}
+
template class abs_blk<std::int16_t>;
template class abs_blk<std::int32_t>;
template class abs_blk<float>;
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/abs_blk_impl.h b/gr-blocks/lib/abs_blk_impl.h
index 787a056767..d9e54785f2 100644
--- a/gr-blocks/lib/abs_blk_impl.h
+++ b/gr-blocks/lib/abs_blk_impl.h
@@ -27,23 +27,23 @@
#include <gnuradio/blocks/abs_blk.h>
namespace gr {
- namespace blocks {
+namespace blocks {
-template<class T>
- class BLOCKS_API abs_blk_impl : public abs_blk<T>
- {
- private:
- size_t d_vlen;
+template <class T>
+class BLOCKS_API abs_blk_impl : public abs_blk<T>
+{
+private:
+ size_t d_vlen;
- public:
- abs_blk_impl(size_t vlen);
+public:
+ abs_blk_impl(size_t vlen);
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* ABS_BLK_IMPL_H */
diff --git a/gr-blocks/lib/add_blk_impl.cc b/gr-blocks/lib/add_blk_impl.cc
index 9cda4d080e..2b6cdc0b0d 100644
--- a/gr-blocks/lib/add_blk_impl.cc
+++ b/gr-blocks/lib/add_blk_impl.cc
@@ -30,77 +30,73 @@
#include <volk/volk.h>
namespace gr {
- namespace blocks {
-
- template <class T>
- typename add_blk<T>::sptr add_blk<T>::make(size_t vlen)
- {
- return gnuradio::get_initial_sptr(new add_blk_impl<T> (vlen));
- }
+namespace blocks {
+template <class T>
+typename add_blk<T>::sptr add_blk<T>::make(size_t vlen)
+{
+ return gnuradio::get_initial_sptr(new add_blk_impl<T>(vlen));
+}
- template <>
- add_blk_impl<float>::add_blk_impl(size_t vlen)
- : sync_block("add_ff",
- io_signature::make (1, -1, sizeof(float)*vlen),
- io_signature::make (1, 1, sizeof(float)*vlen)),
- d_vlen(vlen)
- {
- const int alignment_multiple =
- volk_get_alignment() / sizeof(float);
- set_alignment(std::max(1, alignment_multiple));
- }
- template <>
- int
- add_blk_impl<float>::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- float *out = (float *) output_items[0];
- int noi = d_vlen*noutput_items;
-
- memcpy(out, input_items[0], noi*sizeof(float));
- for(size_t i = 1; i < input_items.size(); i++)
+template <>
+add_blk_impl<float>::add_blk_impl(size_t vlen)
+ : sync_block("add_ff",
+ io_signature::make(1, -1, sizeof(float) * vlen),
+ io_signature::make(1, 1, sizeof(float) * vlen)),
+ d_vlen(vlen)
+{
+ const int alignment_multiple = volk_get_alignment() / sizeof(float);
+ set_alignment(std::max(1, alignment_multiple));
+}
+
+template <>
+int add_blk_impl<float>::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ float* out = (float*)output_items[0];
+ int noi = d_vlen * noutput_items;
+
+ memcpy(out, input_items[0], noi * sizeof(float));
+ for (size_t i = 1; i < input_items.size(); i++)
volk_32f_x2_add_32f(out, out, (const float*)input_items[i], noi);
- return noutput_items;
- }
+ return noutput_items;
+}
-
- template <class T>
- add_blk_impl<T> ::add_blk_impl (size_t vlen)
- : sync_block ("add_blk",
- io_signature::make (1, -1, sizeof (T)*vlen),
- io_signature::make (1, 1, sizeof (T)*vlen)),
+template <class T>
+add_blk_impl<T>::add_blk_impl(size_t vlen)
+ : sync_block("add_blk",
+ io_signature::make(1, -1, sizeof(T) * vlen),
+ io_signature::make(1, 1, sizeof(T) * vlen)),
d_vlen(vlen)
- {
- }
+{
+}
- template <class T>
- int
- add_blk_impl<T> ::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- T *optr = (T *) output_items[0];
+template <class T>
+int add_blk_impl<T>::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ T* optr = (T*)output_items[0];
- int ninputs = input_items.size ();
+ int ninputs = input_items.size();
- for (size_t i = 0; i < noutput_items*d_vlen; i++){
- T acc = ((T *) input_items[0])[i];
- for (int j = 1; j < ninputs; j++)
- acc += ((T *) input_items[j])[i];
+ for (size_t i = 0; i < noutput_items * d_vlen; i++) {
+ T acc = ((T*)input_items[0])[i];
+ for (int j = 1; j < ninputs; j++)
+ acc += ((T*)input_items[j])[i];
- *optr++ = (T) acc;
- }
-
- return noutput_items;
+ *optr++ = (T)acc;
}
+ return noutput_items;
+}
+
template class add_blk<std::int16_t>;
template class add_blk<std::int32_t>;
template class add_blk<gr_complex>;
template class add_blk<float>;
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/add_blk_impl.h b/gr-blocks/lib/add_blk_impl.h
index 74f3e1bac1..adc0bc5df7 100644
--- a/gr-blocks/lib/add_blk_impl.h
+++ b/gr-blocks/lib/add_blk_impl.h
@@ -27,23 +27,23 @@
#include <gnuradio/blocks/add_blk.h>
namespace gr {
- namespace blocks {
+namespace blocks {
-template<class T>
-class BLOCKS_API add_blk_impl : public add_blk<T>
- {
- private:
- size_t d_vlen;
+template <class T>
+class BLOCKS_API add_blk_impl : public add_blk<T>
+{
+private:
+ size_t d_vlen;
- public:
- add_blk_impl (size_t vlen);
+public:
+ add_blk_impl(size_t vlen);
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* ADD_BLK_IMPL_H */
diff --git a/gr-blocks/lib/add_const_bb_impl.cc b/gr-blocks/lib/add_const_bb_impl.cc
index 8f225d6e68..1ac9aff4ba 100644
--- a/gr-blocks/lib/add_const_bb_impl.cc
+++ b/gr-blocks/lib/add_const_bb_impl.cc
@@ -28,80 +28,79 @@
#include <gnuradio/io_signature.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- add_const_bb::sptr add_const_bb::make(unsigned char k)
- {
- return gnuradio::get_initial_sptr
- (new add_const_bb_impl(k));
- }
-
- add_const_bb_impl::add_const_bb_impl(unsigned char k)
- : sync_block("add_const_bb",
- io_signature::make (1, 1, sizeof(unsigned char)),
- io_signature::make (1, 1, sizeof(unsigned char))),
- d_k(k)
- {
- }
+add_const_bb::sptr add_const_bb::make(unsigned char k)
+{
+ return gnuradio::get_initial_sptr(new add_const_bb_impl(k));
+}
- add_const_bb_impl::~add_const_bb_impl()
- {
- }
+add_const_bb_impl::add_const_bb_impl(unsigned char k)
+ : sync_block("add_const_bb",
+ io_signature::make(1, 1, sizeof(unsigned char)),
+ io_signature::make(1, 1, sizeof(unsigned char))),
+ d_k(k)
+{
+}
- int
- add_const_bb_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- const unsigned char *iptr = (const unsigned char *) input_items[0];
- unsigned char *optr = (unsigned char *) output_items[0];
+add_const_bb_impl::~add_const_bb_impl() {}
- int size = noutput_items;
+int add_const_bb_impl::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ const unsigned char* iptr = (const unsigned char*)input_items[0];
+ unsigned char* optr = (unsigned char*)output_items[0];
- while(size >= 8) {
- *optr++ = *iptr++ + d_k;
- *optr++ = *iptr++ + d_k;
- *optr++ = *iptr++ + d_k;
- *optr++ = *iptr++ + d_k;
- *optr++ = *iptr++ + d_k;
- *optr++ = *iptr++ + d_k;
- *optr++ = *iptr++ + d_k;
- *optr++ = *iptr++ + d_k;
- size -= 8;
- }
+ int size = noutput_items;
- while(size-- > 0) {
- *optr++ = *iptr++ + d_k;
- }
+ while (size >= 8) {
+ *optr++ = *iptr++ + d_k;
+ *optr++ = *iptr++ + d_k;
+ *optr++ = *iptr++ + d_k;
+ *optr++ = *iptr++ + d_k;
+ *optr++ = *iptr++ + d_k;
+ *optr++ = *iptr++ + d_k;
+ *optr++ = *iptr++ + d_k;
+ *optr++ = *iptr++ + d_k;
+ size -= 8;
+ }
- return noutput_items;
+ while (size-- > 0) {
+ *optr++ = *iptr++ + d_k;
}
- void
- add_const_bb_impl::setup_rpc()
- {
+ return noutput_items;
+}
+
+void add_const_bb_impl::setup_rpc()
+{
#ifdef GR_CTRLPORT
- add_rpc_variable(
- rpcbasic_sptr(new rpcbasic_register_get<add_const_bb, unsigned char>(
- alias(), "Constant",
- &add_const_bb::k,
- pmt::from_long(-128),
- pmt::from_long(127),
- pmt::from_long(0),
- "", "Constant to add", RPC_PRIVLVL_MIN,
- DISPTIME | DISPOPTCPLX | DISPOPTSTRIP)));
+ add_rpc_variable(rpcbasic_sptr(new rpcbasic_register_get<add_const_bb, unsigned char>(
+ alias(),
+ "Constant",
+ &add_const_bb::k,
+ pmt::from_long(-128),
+ pmt::from_long(127),
+ pmt::from_long(0),
+ "",
+ "Constant to add",
+ RPC_PRIVLVL_MIN,
+ DISPTIME | DISPOPTCPLX | DISPOPTSTRIP)));
- add_rpc_variable(
- rpcbasic_sptr(new rpcbasic_register_set<add_const_bb, unsigned char>(
- alias(), "Constant",
- &add_const_bb::set_k,
- pmt::from_long(-128),
- pmt::from_long(127),
- pmt::from_long(0),
- "", "Constant to add",
- RPC_PRIVLVL_MIN, DISPNULL)));
+ add_rpc_variable(rpcbasic_sptr(
+ new rpcbasic_register_set<add_const_bb, unsigned char>(alias(),
+ "Constant",
+ &add_const_bb::set_k,
+ pmt::from_long(-128),
+ pmt::from_long(127),
+ pmt::from_long(0),
+ "",
+ "Constant to add",
+ RPC_PRIVLVL_MIN,
+ DISPNULL)));
#endif /* GR_CTRLPORT */
- }
+}
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/add_const_bb_impl.h b/gr-blocks/lib/add_const_bb_impl.h
index 677569c45c..99a44c4f6d 100644
--- a/gr-blocks/lib/add_const_bb_impl.h
+++ b/gr-blocks/lib/add_const_bb_impl.h
@@ -26,28 +26,28 @@
#include <gnuradio/blocks/add_const_bb.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class BLOCKS_API add_const_bb_impl : public add_const_bb
- {
- private:
- unsigned char d_k;
+class BLOCKS_API add_const_bb_impl : public add_const_bb
+{
+private:
+ unsigned char d_k;
- public:
- add_const_bb_impl(unsigned char k);
- ~add_const_bb_impl();
+public:
+ add_const_bb_impl(unsigned char k);
+ ~add_const_bb_impl();
- void setup_rpc();
+ void setup_rpc();
- unsigned char k() const { return d_k; }
- void set_k(unsigned char k) { d_k = k; }
+ unsigned char k() const { return d_k; }
+ void set_k(unsigned char k) { d_k = k; }
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* ADD_CONST_BB_IMPL */
diff --git a/gr-blocks/lib/add_const_cc_impl.cc b/gr-blocks/lib/add_const_cc_impl.cc
index 133d45dfc0..6c326f1e1f 100644
--- a/gr-blocks/lib/add_const_cc_impl.cc
+++ b/gr-blocks/lib/add_const_cc_impl.cc
@@ -28,76 +28,77 @@
#include <gnuradio/io_signature.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- add_const_cc::sptr add_const_cc::make(gr_complex k)
- {
- return gnuradio::get_initial_sptr
- (new add_const_cc_impl(k));
- }
-
- add_const_cc_impl::add_const_cc_impl(gr_complex k)
- : sync_block("add_const_cc",
- io_signature::make (1, 1, sizeof(gr_complex)),
- io_signature::make (1, 1, sizeof(gr_complex))),
- d_k(k)
- {
- }
+add_const_cc::sptr add_const_cc::make(gr_complex k)
+{
+ return gnuradio::get_initial_sptr(new add_const_cc_impl(k));
+}
- int
- add_const_cc_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- const gr_complex *iptr = (const gr_complex *) input_items[0];
- gr_complex *optr = (gr_complex *) output_items[0];
+add_const_cc_impl::add_const_cc_impl(gr_complex k)
+ : sync_block("add_const_cc",
+ io_signature::make(1, 1, sizeof(gr_complex)),
+ io_signature::make(1, 1, sizeof(gr_complex))),
+ d_k(k)
+{
+}
- int size = noutput_items;
+int add_const_cc_impl::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ const gr_complex* iptr = (const gr_complex*)input_items[0];
+ gr_complex* optr = (gr_complex*)output_items[0];
- while(size >= 8) {
- *optr++ = *iptr++ + d_k;
- *optr++ = *iptr++ + d_k;
- *optr++ = *iptr++ + d_k;
- *optr++ = *iptr++ + d_k;
- *optr++ = *iptr++ + d_k;
- *optr++ = *iptr++ + d_k;
- *optr++ = *iptr++ + d_k;
- *optr++ = *iptr++ + d_k;
- size -= 8;
- }
+ int size = noutput_items;
- while(size-- > 0) {
- *optr++ = *iptr++ + d_k;
- }
+ while (size >= 8) {
+ *optr++ = *iptr++ + d_k;
+ *optr++ = *iptr++ + d_k;
+ *optr++ = *iptr++ + d_k;
+ *optr++ = *iptr++ + d_k;
+ *optr++ = *iptr++ + d_k;
+ *optr++ = *iptr++ + d_k;
+ *optr++ = *iptr++ + d_k;
+ *optr++ = *iptr++ + d_k;
+ size -= 8;
+ }
- return noutput_items;
+ while (size-- > 0) {
+ *optr++ = *iptr++ + d_k;
}
- void
- add_const_cc_impl::setup_rpc()
- {
+ return noutput_items;
+}
+
+void add_const_cc_impl::setup_rpc()
+{
#ifdef GR_CTRLPORT
- add_rpc_variable(
- rpcbasic_sptr(new rpcbasic_register_get<add_const_cc, gr_complex>(
- alias(), "Constant",
- &add_const_cc::k,
- pmt::from_complex(-4.29e9, 0),
- pmt::from_complex(4.29e9, 0),
- pmt::from_complex(0, 0),
- "", "Constant to add", RPC_PRIVLVL_MIN,
- DISPTIME | DISPOPTCPLX | DISPOPTSTRIP)));
+ add_rpc_variable(rpcbasic_sptr(new rpcbasic_register_get<add_const_cc, gr_complex>(
+ alias(),
+ "Constant",
+ &add_const_cc::k,
+ pmt::from_complex(-4.29e9, 0),
+ pmt::from_complex(4.29e9, 0),
+ pmt::from_complex(0, 0),
+ "",
+ "Constant to add",
+ RPC_PRIVLVL_MIN,
+ DISPTIME | DISPOPTCPLX | DISPOPTSTRIP)));
- add_rpc_variable(
- rpcbasic_sptr(new rpcbasic_register_set<add_const_cc, gr_complex>(
- alias(), "Constant",
- &add_const_cc::set_k,
- pmt::from_complex(-4.29e9, 0),
- pmt::from_complex(4.29e9, 0),
- pmt::from_complex(0, 0),
- "", "Constant to add",
- RPC_PRIVLVL_MIN, DISPNULL)));
+ add_rpc_variable(rpcbasic_sptr(
+ new rpcbasic_register_set<add_const_cc, gr_complex>(alias(),
+ "Constant",
+ &add_const_cc::set_k,
+ pmt::from_complex(-4.29e9, 0),
+ pmt::from_complex(4.29e9, 0),
+ pmt::from_complex(0, 0),
+ "",
+ "Constant to add",
+ RPC_PRIVLVL_MIN,
+ DISPNULL)));
#endif /* GR_CTRLPORT */
- }
+}
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/add_const_cc_impl.h b/gr-blocks/lib/add_const_cc_impl.h
index f1861da7b2..075328fc2a 100644
--- a/gr-blocks/lib/add_const_cc_impl.h
+++ b/gr-blocks/lib/add_const_cc_impl.h
@@ -26,27 +26,27 @@
#include <gnuradio/blocks/add_const_cc.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class BLOCKS_API add_const_cc_impl : public add_const_cc
- {
- private:
- gr_complex d_k;
+class BLOCKS_API add_const_cc_impl : public add_const_cc
+{
+private:
+ gr_complex d_k;
- public:
- add_const_cc_impl(gr_complex k);
+public:
+ add_const_cc_impl(gr_complex k);
- void setup_rpc();
+ void setup_rpc();
- gr_complex k() const { return d_k; }
- void set_k(gr_complex k) { d_k = k; }
+ gr_complex k() const { return d_k; }
+ void set_k(gr_complex k) { d_k = k; }
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* ADD_CONST_CC_IMPL */
diff --git a/gr-blocks/lib/add_const_ff_impl.cc b/gr-blocks/lib/add_const_ff_impl.cc
index 6da622f08b..110c5450eb 100644
--- a/gr-blocks/lib/add_const_ff_impl.cc
+++ b/gr-blocks/lib/add_const_ff_impl.cc
@@ -28,76 +28,77 @@
#include <gnuradio/io_signature.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- add_const_ff::sptr add_const_ff::make(float k)
- {
- return gnuradio::get_initial_sptr
- (new add_const_ff_impl(k));
- }
-
- add_const_ff_impl::add_const_ff_impl(float k)
- : sync_block("add_const_ff",
- io_signature::make (1, 1, sizeof(float)),
- io_signature::make (1, 1, sizeof(float))),
- d_k(k)
- {
- }
+add_const_ff::sptr add_const_ff::make(float k)
+{
+ return gnuradio::get_initial_sptr(new add_const_ff_impl(k));
+}
- int
- add_const_ff_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- const float *iptr = (const float *) input_items[0];
- float *optr = (float *) output_items[0];
+add_const_ff_impl::add_const_ff_impl(float k)
+ : sync_block("add_const_ff",
+ io_signature::make(1, 1, sizeof(float)),
+ io_signature::make(1, 1, sizeof(float))),
+ d_k(k)
+{
+}
- int size = noutput_items;
+int add_const_ff_impl::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ const float* iptr = (const float*)input_items[0];
+ float* optr = (float*)output_items[0];
- while(size >= 8) {
- *optr++ = *iptr++ + d_k;
- *optr++ = *iptr++ + d_k;
- *optr++ = *iptr++ + d_k;
- *optr++ = *iptr++ + d_k;
- *optr++ = *iptr++ + d_k;
- *optr++ = *iptr++ + d_k;
- *optr++ = *iptr++ + d_k;
- *optr++ = *iptr++ + d_k;
- size -= 8;
- }
+ int size = noutput_items;
- while(size-- > 0) {
- *optr++ = *iptr++ + d_k;
- }
+ while (size >= 8) {
+ *optr++ = *iptr++ + d_k;
+ *optr++ = *iptr++ + d_k;
+ *optr++ = *iptr++ + d_k;
+ *optr++ = *iptr++ + d_k;
+ *optr++ = *iptr++ + d_k;
+ *optr++ = *iptr++ + d_k;
+ *optr++ = *iptr++ + d_k;
+ *optr++ = *iptr++ + d_k;
+ size -= 8;
+ }
- return noutput_items;
+ while (size-- > 0) {
+ *optr++ = *iptr++ + d_k;
}
- void
- add_const_ff_impl::setup_rpc()
- {
+ return noutput_items;
+}
+
+void add_const_ff_impl::setup_rpc()
+{
#ifdef GR_CTRLPORT
- add_rpc_variable(
- rpcbasic_sptr(new rpcbasic_register_get<add_const_ff, float>(
- alias(), "Constant",
- &add_const_ff::k,
- pmt::from_double(-4.29e9),
- pmt::from_double(4.29e9),
- pmt::from_double(0),
- "", "Constant to add", RPC_PRIVLVL_MIN,
- DISPTIME | DISPOPTCPLX | DISPOPTSTRIP)));
+ add_rpc_variable(rpcbasic_sptr(new rpcbasic_register_get<add_const_ff, float>(
+ alias(),
+ "Constant",
+ &add_const_ff::k,
+ pmt::from_double(-4.29e9),
+ pmt::from_double(4.29e9),
+ pmt::from_double(0),
+ "",
+ "Constant to add",
+ RPC_PRIVLVL_MIN,
+ DISPTIME | DISPOPTCPLX | DISPOPTSTRIP)));
- add_rpc_variable(
- rpcbasic_sptr(new rpcbasic_register_set<add_const_ff, float>(
- alias(), "Constant",
- &add_const_ff::set_k,
- pmt::from_double(-4.29e9),
- pmt::from_double(4.29e9),
- pmt::from_double(0),
- "", "Constant to add",
- RPC_PRIVLVL_MIN, DISPNULL)));
+ add_rpc_variable(rpcbasic_sptr(
+ new rpcbasic_register_set<add_const_ff, float>(alias(),
+ "Constant",
+ &add_const_ff::set_k,
+ pmt::from_double(-4.29e9),
+ pmt::from_double(4.29e9),
+ pmt::from_double(0),
+ "",
+ "Constant to add",
+ RPC_PRIVLVL_MIN,
+ DISPNULL)));
#endif /* GR_CTRLPORT */
- }
+}
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/add_const_ff_impl.h b/gr-blocks/lib/add_const_ff_impl.h
index a3074b4b98..df07aab1c3 100644
--- a/gr-blocks/lib/add_const_ff_impl.h
+++ b/gr-blocks/lib/add_const_ff_impl.h
@@ -26,27 +26,27 @@
#include <gnuradio/blocks/add_const_ff.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class BLOCKS_API add_const_ff_impl : public add_const_ff
- {
- private:
- float d_k;
+class BLOCKS_API add_const_ff_impl : public add_const_ff
+{
+private:
+ float d_k;
- public:
- add_const_ff_impl(float k);
+public:
+ add_const_ff_impl(float k);
- void setup_rpc();
+ void setup_rpc();
- float k() const { return d_k; }
- void set_k(float k) { d_k = k; }
+ float k() const { return d_k; }
+ void set_k(float k) { d_k = k; }
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* ADD_CONST_FF_IMPL */
diff --git a/gr-blocks/lib/add_const_ii_impl.cc b/gr-blocks/lib/add_const_ii_impl.cc
index de81af5b26..3fa36d27bf 100644
--- a/gr-blocks/lib/add_const_ii_impl.cc
+++ b/gr-blocks/lib/add_const_ii_impl.cc
@@ -28,76 +28,77 @@
#include <gnuradio/io_signature.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- add_const_ii::sptr add_const_ii::make(int k)
- {
- return gnuradio::get_initial_sptr
- (new add_const_ii_impl(k));
- }
-
- add_const_ii_impl::add_const_ii_impl(int k)
- : sync_block("add_const_ii",
- io_signature::make (1, 1, sizeof(int)),
- io_signature::make (1, 1, sizeof(int))),
- d_k(k)
- {
- }
+add_const_ii::sptr add_const_ii::make(int k)
+{
+ return gnuradio::get_initial_sptr(new add_const_ii_impl(k));
+}
- int
- add_const_ii_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- const int *iptr = (const int *) input_items[0];
- int *optr = (int *) output_items[0];
+add_const_ii_impl::add_const_ii_impl(int k)
+ : sync_block("add_const_ii",
+ io_signature::make(1, 1, sizeof(int)),
+ io_signature::make(1, 1, sizeof(int))),
+ d_k(k)
+{
+}
- int size = noutput_items;
+int add_const_ii_impl::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ const int* iptr = (const int*)input_items[0];
+ int* optr = (int*)output_items[0];
- while(size >= 8) {
- *optr++ = *iptr++ + d_k;
- *optr++ = *iptr++ + d_k;
- *optr++ = *iptr++ + d_k;
- *optr++ = *iptr++ + d_k;
- *optr++ = *iptr++ + d_k;
- *optr++ = *iptr++ + d_k;
- *optr++ = *iptr++ + d_k;
- *optr++ = *iptr++ + d_k;
- size -= 8;
- }
+ int size = noutput_items;
- while(size-- > 0) {
- *optr++ = *iptr++ + d_k;
- }
+ while (size >= 8) {
+ *optr++ = *iptr++ + d_k;
+ *optr++ = *iptr++ + d_k;
+ *optr++ = *iptr++ + d_k;
+ *optr++ = *iptr++ + d_k;
+ *optr++ = *iptr++ + d_k;
+ *optr++ = *iptr++ + d_k;
+ *optr++ = *iptr++ + d_k;
+ *optr++ = *iptr++ + d_k;
+ size -= 8;
+ }
- return noutput_items;
+ while (size-- > 0) {
+ *optr++ = *iptr++ + d_k;
}
- void
- add_const_ii_impl::setup_rpc()
- {
+ return noutput_items;
+}
+
+void add_const_ii_impl::setup_rpc()
+{
#ifdef GR_CTRLPORT
- add_rpc_variable(
- rpcbasic_sptr(new rpcbasic_register_get<add_const_ii, int>(
- alias(), "Constant",
- &add_const_ii::k,
- pmt::from_long(-2147483648),
- pmt::from_long(2147483647),
- pmt::from_long(0),
- "", "Constant to add", RPC_PRIVLVL_MIN,
- DISPTIME | DISPOPTCPLX | DISPOPTSTRIP)));
+ add_rpc_variable(rpcbasic_sptr(new rpcbasic_register_get<add_const_ii, int>(
+ alias(),
+ "Constant",
+ &add_const_ii::k,
+ pmt::from_long(-2147483648),
+ pmt::from_long(2147483647),
+ pmt::from_long(0),
+ "",
+ "Constant to add",
+ RPC_PRIVLVL_MIN,
+ DISPTIME | DISPOPTCPLX | DISPOPTSTRIP)));
- add_rpc_variable(
- rpcbasic_sptr(new rpcbasic_register_set<add_const_ii, int>(
- alias(), "Constant",
- &add_const_ii::set_k,
- pmt::from_long(-2147483648),
- pmt::from_long(2147483647),
- pmt::from_long(0),
- "", "Constant to add",
- RPC_PRIVLVL_MIN, DISPNULL)));
+ add_rpc_variable(rpcbasic_sptr(
+ new rpcbasic_register_set<add_const_ii, int>(alias(),
+ "Constant",
+ &add_const_ii::set_k,
+ pmt::from_long(-2147483648),
+ pmt::from_long(2147483647),
+ pmt::from_long(0),
+ "",
+ "Constant to add",
+ RPC_PRIVLVL_MIN,
+ DISPNULL)));
#endif /* GR_CTRLPORT */
- }
+}
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/add_const_ii_impl.h b/gr-blocks/lib/add_const_ii_impl.h
index 8ddc3adb51..2eb9053497 100644
--- a/gr-blocks/lib/add_const_ii_impl.h
+++ b/gr-blocks/lib/add_const_ii_impl.h
@@ -26,27 +26,27 @@
#include <gnuradio/blocks/add_const_ii.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class BLOCKS_API add_const_ii_impl : public add_const_ii
- {
- private:
- int d_k;
+class BLOCKS_API add_const_ii_impl : public add_const_ii
+{
+private:
+ int d_k;
- public:
- add_const_ii_impl(int k);
+public:
+ add_const_ii_impl(int k);
- void setup_rpc();
+ void setup_rpc();
- int k() const { return d_k; }
- void set_k(int k) { d_k = k; }
+ int k() const { return d_k; }
+ void set_k(int k) { d_k = k; }
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* ADD_CONST_II_IMPL */
diff --git a/gr-blocks/lib/add_const_ss_impl.cc b/gr-blocks/lib/add_const_ss_impl.cc
index 2796b2fbdd..3ae814f13e 100644
--- a/gr-blocks/lib/add_const_ss_impl.cc
+++ b/gr-blocks/lib/add_const_ss_impl.cc
@@ -28,80 +28,79 @@
#include <gnuradio/io_signature.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- add_const_ss::sptr add_const_ss::make(short k)
- {
- return gnuradio::get_initial_sptr
- (new add_const_ss_impl(k));
- }
-
- add_const_ss_impl::add_const_ss_impl(short k)
- : sync_block("add_const_ss",
- io_signature::make (1, 1, sizeof(short)),
- io_signature::make (1, 1, sizeof(short))),
- d_k(k)
- {
- }
+add_const_ss::sptr add_const_ss::make(short k)
+{
+ return gnuradio::get_initial_sptr(new add_const_ss_impl(k));
+}
- add_const_ss_impl::~add_const_ss_impl()
- {
- }
+add_const_ss_impl::add_const_ss_impl(short k)
+ : sync_block("add_const_ss",
+ io_signature::make(1, 1, sizeof(short)),
+ io_signature::make(1, 1, sizeof(short))),
+ d_k(k)
+{
+}
- int
- add_const_ss_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- const short *iptr = (const short *) input_items[0];
- short *optr = (short *) output_items[0];
+add_const_ss_impl::~add_const_ss_impl() {}
- int size = noutput_items;
+int add_const_ss_impl::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ const short* iptr = (const short*)input_items[0];
+ short* optr = (short*)output_items[0];
- while(size >= 8) {
- *optr++ = *iptr++ + d_k;
- *optr++ = *iptr++ + d_k;
- *optr++ = *iptr++ + d_k;
- *optr++ = *iptr++ + d_k;
- *optr++ = *iptr++ + d_k;
- *optr++ = *iptr++ + d_k;
- *optr++ = *iptr++ + d_k;
- *optr++ = *iptr++ + d_k;
- size -= 8;
- }
+ int size = noutput_items;
- while(size-- > 0) {
- *optr++ = *iptr++ + d_k;
- }
+ while (size >= 8) {
+ *optr++ = *iptr++ + d_k;
+ *optr++ = *iptr++ + d_k;
+ *optr++ = *iptr++ + d_k;
+ *optr++ = *iptr++ + d_k;
+ *optr++ = *iptr++ + d_k;
+ *optr++ = *iptr++ + d_k;
+ *optr++ = *iptr++ + d_k;
+ *optr++ = *iptr++ + d_k;
+ size -= 8;
+ }
- return noutput_items;
+ while (size-- > 0) {
+ *optr++ = *iptr++ + d_k;
}
- void
- add_const_ss_impl::setup_rpc()
- {
+ return noutput_items;
+}
+
+void add_const_ss_impl::setup_rpc()
+{
#ifdef GR_CTRLPORT
- add_rpc_variable(
- rpcbasic_sptr(new rpcbasic_register_get<add_const_ss, short>(
- alias(), "Constant",
- &add_const_ss::k,
- pmt::from_long(-65536),
- pmt::from_long(65535),
- pmt::from_long(0),
- "", "Constant to add", RPC_PRIVLVL_MIN,
- DISPTIME | DISPOPTCPLX | DISPOPTSTRIP)));
+ add_rpc_variable(rpcbasic_sptr(new rpcbasic_register_get<add_const_ss, short>(
+ alias(),
+ "Constant",
+ &add_const_ss::k,
+ pmt::from_long(-65536),
+ pmt::from_long(65535),
+ pmt::from_long(0),
+ "",
+ "Constant to add",
+ RPC_PRIVLVL_MIN,
+ DISPTIME | DISPOPTCPLX | DISPOPTSTRIP)));
- add_rpc_variable(
- rpcbasic_sptr(new rpcbasic_register_set<add_const_ss, short>(
- alias(), "Constant",
- &add_const_ss::set_k,
- pmt::from_long(-65536),
- pmt::from_long(65535),
- pmt::from_long(0),
- "", "Constant to add",
- RPC_PRIVLVL_MIN, DISPNULL)));
+ add_rpc_variable(rpcbasic_sptr(
+ new rpcbasic_register_set<add_const_ss, short>(alias(),
+ "Constant",
+ &add_const_ss::set_k,
+ pmt::from_long(-65536),
+ pmt::from_long(65535),
+ pmt::from_long(0),
+ "",
+ "Constant to add",
+ RPC_PRIVLVL_MIN,
+ DISPNULL)));
#endif /* GR_CTRLPORT */
- }
+}
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/add_const_ss_impl.h b/gr-blocks/lib/add_const_ss_impl.h
index 40bcfb9b45..169422612c 100644
--- a/gr-blocks/lib/add_const_ss_impl.h
+++ b/gr-blocks/lib/add_const_ss_impl.h
@@ -26,28 +26,28 @@
#include <gnuradio/blocks/add_const_ss.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class BLOCKS_API add_const_ss_impl : public add_const_ss
- {
- private:
- short d_k;
+class BLOCKS_API add_const_ss_impl : public add_const_ss
+{
+private:
+ short d_k;
- public:
- add_const_ss_impl(short k);
- ~add_const_ss_impl();
+public:
+ add_const_ss_impl(short k);
+ ~add_const_ss_impl();
- void setup_rpc();
+ void setup_rpc();
- short k() const { return d_k; }
- void set_k(short k) { d_k = k; }
+ short k() const { return d_k; }
+ void set_k(short k) { d_k = k; }
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* ADD_CONST_SS_IMPL */
diff --git a/gr-blocks/lib/add_const_v_impl.cc b/gr-blocks/lib/add_const_v_impl.cc
index 06b420f7f5..7494c16d56 100644
--- a/gr-blocks/lib/add_const_v_impl.cc
+++ b/gr-blocks/lib/add_const_v_impl.cc
@@ -28,45 +28,44 @@
#include <gnuradio/io_signature.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- template <class T>
- typename add_const_v<T>::sptr add_const_v<T>::make(std::vector<T> k)
- {
- return gnuradio::get_initial_sptr(new add_const_v_impl<T>(k));
- }
+template <class T>
+typename add_const_v<T>::sptr add_const_v<T>::make(std::vector<T> k)
+{
+ return gnuradio::get_initial_sptr(new add_const_v_impl<T>(k));
+}
- template <class T>
- add_const_v_impl<T>::add_const_v_impl(std::vector<T> k)
- : sync_block ("add_const_v",
- io_signature::make (1, 1, sizeof (T)*k.size()),
- io_signature::make (1, 1, sizeof (T)*k.size())),
+template <class T>
+add_const_v_impl<T>::add_const_v_impl(std::vector<T> k)
+ : sync_block("add_const_v",
+ io_signature::make(1, 1, sizeof(T) * k.size()),
+ io_signature::make(1, 1, sizeof(T) * k.size())),
d_k(k)
- {
- }
+{
+}
- template <class T>
- int
- add_const_v_impl<T>::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- T *iptr = (T *)input_items[0];
- T *optr = (T *)output_items[0];
+template <class T>
+int add_const_v_impl<T>::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ T* iptr = (T*)input_items[0];
+ T* optr = (T*)output_items[0];
- int nitems_per_block = this->output_signature()->sizeof_stream_item(0)/sizeof(T);
+ int nitems_per_block = this->output_signature()->sizeof_stream_item(0) / sizeof(T);
- for (int i = 0; i < noutput_items; i++)
- for (int j = 0; j < nitems_per_block; j++)
- *optr++ = *iptr++ + d_k[j];
+ for (int i = 0; i < noutput_items; i++)
+ for (int j = 0; j < nitems_per_block; j++)
+ *optr++ = *iptr++ + d_k[j];
- return noutput_items;
- }
+ return noutput_items;
+}
- template class add_const_v<std::uint8_t>;
- template class add_const_v<std::int16_t>;
- template class add_const_v<std::int32_t>;
- template class add_const_v<float>;
- template class add_const_v<gr_complex>;
- } /* namespace blocks */
+template class add_const_v<std::uint8_t>;
+template class add_const_v<std::int16_t>;
+template class add_const_v<std::int32_t>;
+template class add_const_v<float>;
+template class add_const_v<gr_complex>;
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/add_const_v_impl.h b/gr-blocks/lib/add_const_v_impl.h
index 1257ec08a0..1834ff68fb 100644
--- a/gr-blocks/lib/add_const_v_impl.h
+++ b/gr-blocks/lib/add_const_v_impl.h
@@ -26,25 +26,25 @@
#include <gnuradio/blocks/add_const_v.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- template <class T>
- class BLOCKS_API add_const_v_impl: public add_const_v<T>
- {
- std::vector<T> d_k;
+template <class T>
+class BLOCKS_API add_const_v_impl : public add_const_v<T>
+{
+ std::vector<T> d_k;
- public:
- add_const_v_impl(std::vector<T> k);
+public:
+ add_const_v_impl(std::vector<T> k);
- std::vector<T> k() const { return d_k; }
- void set_k(std::vector<T> k) { d_k = k; }
+ std::vector<T> k() const { return d_k; }
+ void set_k(std::vector<T> k) { d_k = k; }
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* ADD_CONST_V_IMPL_H */
diff --git a/gr-blocks/lib/and_blk_impl.cc b/gr-blocks/lib/and_blk_impl.cc
index f0f329dae4..f84906664b 100644
--- a/gr-blocks/lib/and_blk_impl.cc
+++ b/gr-blocks/lib/and_blk_impl.cc
@@ -29,46 +29,45 @@
#include <gnuradio/io_signature.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- template <class T>
- typename and_blk<T>::sptr and_blk<T>::make(size_t vlen)
- {
- return gnuradio::get_initial_sptr(new and_blk_impl<T> (vlen));
- }
+template <class T>
+typename and_blk<T>::sptr and_blk<T>::make(size_t vlen)
+{
+ return gnuradio::get_initial_sptr(new and_blk_impl<T>(vlen));
+}
- template <class T>
- and_blk_impl<T> ::and_blk_impl (size_t vlen)
- : sync_block ("and_blk",
- io_signature::make (1, -1, sizeof (T)*vlen),
- io_signature::make (1, 1, sizeof (T)*vlen)),
+template <class T>
+and_blk_impl<T>::and_blk_impl(size_t vlen)
+ : sync_block("and_blk",
+ io_signature::make(1, -1, sizeof(T) * vlen),
+ io_signature::make(1, 1, sizeof(T) * vlen)),
d_vlen(vlen)
- {
- }
+{
+}
- template <class T>
- int
- and_blk_impl<T> ::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- T *optr = (T *) output_items[0];
+template <class T>
+int and_blk_impl<T>::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ T* optr = (T*)output_items[0];
- int ninputs = input_items.size ();
+ int ninputs = input_items.size();
- for (size_t i = 0; i < noutput_items*d_vlen; i++){
- T acc = ((T *) input_items[0])[i];
- for (int j = 1; j < ninputs; j++)
- acc &= ((T *) input_items[j])[i];
+ for (size_t i = 0; i < noutput_items * d_vlen; i++) {
+ T acc = ((T*)input_items[0])[i];
+ for (int j = 1; j < ninputs; j++)
+ acc &= ((T*)input_items[j])[i];
- *optr++ = (T) acc;
- }
-
- return noutput_items;
+ *optr++ = (T)acc;
}
+ return noutput_items;
+}
+
template class and_blk<std::uint8_t>;
template class and_blk<std::int16_t>;
template class and_blk<std::int32_t>;
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/and_blk_impl.h b/gr-blocks/lib/and_blk_impl.h
index 54d721111e..8ce00f797d 100644
--- a/gr-blocks/lib/and_blk_impl.h
+++ b/gr-blocks/lib/and_blk_impl.h
@@ -27,22 +27,22 @@
#include <gnuradio/blocks/and_blk.h>
namespace gr {
- namespace blocks {
+namespace blocks {
-template<class T>
- class BLOCKS_API and_blk_impl : public and_blk<T>
- {
- size_t d_vlen;
+template <class T>
+class BLOCKS_API and_blk_impl : public and_blk<T>
+{
+ size_t d_vlen;
- public:
- and_blk_impl (size_t vlen);
+public:
+ and_blk_impl(size_t vlen);
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* AND_BLK_IMPL_H */
diff --git a/gr-blocks/lib/and_const_impl.cc b/gr-blocks/lib/and_const_impl.cc
index 76b24956cf..ad464e0a1a 100644
--- a/gr-blocks/lib/and_const_impl.cc
+++ b/gr-blocks/lib/and_const_impl.cc
@@ -29,54 +29,53 @@
#include <gnuradio/io_signature.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- template <class T>
- typename and_const<T>::sptr and_const<T>::make(T k)
- {
- return gnuradio::get_initial_sptr(new and_const_impl<T> (k));
- }
+template <class T>
+typename and_const<T>::sptr and_const<T>::make(T k)
+{
+ return gnuradio::get_initial_sptr(new and_const_impl<T>(k));
+}
- template <class T>
- and_const_impl<T> ::and_const_impl (T k)
- : sync_block ("and_const",
- io_signature::make (1, 1, sizeof (T)),
- io_signature::make (1, 1, sizeof (T))),
+template <class T>
+and_const_impl<T>::and_const_impl(T k)
+ : sync_block("and_const",
+ io_signature::make(1, 1, sizeof(T)),
+ io_signature::make(1, 1, sizeof(T))),
d_k(k)
- {
- }
+{
+}
- template <class T>
- int
- and_const_impl<T> ::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- T *iptr = (T *) input_items[0];
- T *optr = (T *) output_items[0];
+template <class T>
+int and_const_impl<T>::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ T* iptr = (T*)input_items[0];
+ T* optr = (T*)output_items[0];
- int size = noutput_items;
+ int size = noutput_items;
- while (size >= 8){
- *optr++ = *iptr++ & d_k;
- *optr++ = *iptr++ & d_k;
- *optr++ = *iptr++ & d_k;
- *optr++ = *iptr++ & d_k;
- *optr++ = *iptr++ & d_k;
- *optr++ = *iptr++ & d_k;
- *optr++ = *iptr++ & d_k;
- *optr++ = *iptr++ & d_k;
- size -= 8;
- }
+ while (size >= 8) {
+ *optr++ = *iptr++ & d_k;
+ *optr++ = *iptr++ & d_k;
+ *optr++ = *iptr++ & d_k;
+ *optr++ = *iptr++ & d_k;
+ *optr++ = *iptr++ & d_k;
+ *optr++ = *iptr++ & d_k;
+ *optr++ = *iptr++ & d_k;
+ *optr++ = *iptr++ & d_k;
+ size -= 8;
+ }
- while (size-- > 0)
- *optr++ = *iptr++ & d_k;
+ while (size-- > 0)
+ *optr++ = *iptr++ & d_k;
- return noutput_items;
- }
+ return noutput_items;
+}
template class and_const<std::uint8_t>;
template class and_const<std::int16_t>;
template class and_const<std::int32_t>;
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/and_const_impl.h b/gr-blocks/lib/and_const_impl.h
index 3af7651e22..ee8af0c2fa 100644
--- a/gr-blocks/lib/and_const_impl.h
+++ b/gr-blocks/lib/and_const_impl.h
@@ -27,25 +27,25 @@
#include <gnuradio/blocks/and_const.h>
namespace gr {
- namespace blocks {
+namespace blocks {
-template<class T>
- class BLOCKS_API and_const_impl : public and_const<T>
- {
- T d_k;
+template <class T>
+class BLOCKS_API and_const_impl : public and_const<T>
+{
+ T d_k;
- public:
- and_const_impl (T k);
+public:
+ and_const_impl(T k);
- T k() const { return d_k; }
- void set_k(T k) { d_k = k; }
+ T k() const { return d_k; }
+ void set_k(T k) { d_k = k; }
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* AND_CONST_IMPL_H */
diff --git a/gr-blocks/lib/annotator_1to1_impl.cc b/gr-blocks/lib/annotator_1to1_impl.cc
index cf26728193..1b099cde74 100644
--- a/gr-blocks/lib/annotator_1to1_impl.cc
+++ b/gr-blocks/lib/annotator_1to1_impl.cc
@@ -31,83 +31,78 @@
#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)
- : sync_block("annotator_1to1",
- io_signature::make(1, -1, sizeof_stream_item),
- io_signature::make(1, -1, sizeof_stream_item)),
- d_when((uint64_t)when)
- {
- set_tag_propagation_policy(TPP_ONE_TO_ONE);
-
- d_tag_counter = 0;
- set_relative_rate(1, 1);
- }
-
- 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++) {
+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)
+ : sync_block("annotator_1to1",
+ io_signature::make(1, -1, sizeof_stream_item),
+ io_signature::make(1, -1, sizeof_stream_item)),
+ d_when((uint64_t)when)
+{
+ set_tag_propagation_policy(TPP_ONE_TO_ONE);
+
+ d_tag_counter = 0;
+ set_relative_rate(1, 1);
+}
+
+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<tag_t> all_tags;
get_tags_in_range(all_tags, i, abs_N, abs_N + noutput_items);
std::vector<tag_t>::iterator itr;
- for(itr = all_tags.begin(); itr != all_tags.end(); itr++) {
- d_stored_tags.push_back(*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::string_to_symbol(str.str());
- pmt::pmt_t key = pmt::string_to_symbol("seq");
+ // Storing the current noutput_items as the value to the "noutput_items" key
+ pmt::pmt_t srcid = pmt::string_to_symbol(str.str());
+ pmt::pmt_t key = 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++) {
+ // 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::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];
+ for (int i = 0; i < std::min(noutputs, ninputs); i++) {
+ if (abs_N % d_when == 0) {
+ pmt::pmt_t value = 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 */
+ 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
index 206366ca17..eca1c7c11e 100644
--- a/gr-blocks/lib/annotator_1to1_impl.h
+++ b/gr-blocks/lib/annotator_1to1_impl.h
@@ -21,35 +21,32 @@
*/
#ifndef INCLUDED_GR_ANNOTATOR_1TO1_IMPL_H
-#define INCLUDED_GR_ANNOTATOR_1TO1_IMPL_H
+#define INCLUDED_GR_ANNOTATOR_1TO1_IMPL_H
#include <gnuradio/blocks/annotator_1to1.h>
namespace gr {
- namespace blocks {
-
- class annotator_1to1_impl : public annotator_1to1
- {
- private:
- uint64_t d_when;
- uint64_t d_tag_counter;
- std::vector<tag_t> d_stored_tags;
-
- public:
- annotator_1to1_impl(int when, size_t sizeof_stream_item);
- ~annotator_1to1_impl();
-
- std::vector<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 blocks {
+
+class annotator_1to1_impl : public annotator_1to1
+{
+private:
+ uint64_t d_when;
+ uint64_t d_tag_counter;
+ std::vector<tag_t> d_stored_tags;
+
+public:
+ annotator_1to1_impl(int when, size_t sizeof_stream_item);
+ ~annotator_1to1_impl();
+
+ std::vector<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
index afc60d0acb..8eeb7625e0 100644
--- a/gr-blocks/lib/annotator_alltoall_impl.cc
+++ b/gr-blocks/lib/annotator_alltoall_impl.cc
@@ -31,45 +31,40 @@
#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)
- : sync_block("annotator_alltoall",
- io_signature::make(1, -1, sizeof_stream_item),
- io_signature::make(1, -1, 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++) {
+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)
+ : sync_block("annotator_alltoall",
+ io_signature::make(1, -1, sizeof_stream_item),
+ io_signature::make(1, -1, 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);
@@ -77,41 +72,41 @@ namespace gr {
get_tags_in_range(all_tags, i, abs_N, end_N);
std::vector<tag_t>::iterator itr;
- for(itr = all_tags.begin(); itr != all_tags.end(); itr++) {
- d_stored_tags.push_back(*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::string_to_symbol(str.str());
- pmt::pmt_t key = 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::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];
- }
+ }
+
+ // Source ID and key for any tag that might get applied from this block
+ pmt::pmt_t srcid = pmt::string_to_symbol(str.str());
+ pmt::pmt_t key = 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::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 */
+ 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
index cdd5c88e62..8aa12ba8e0 100644
--- a/gr-blocks/lib/annotator_alltoall_impl.h
+++ b/gr-blocks/lib/annotator_alltoall_impl.h
@@ -21,35 +21,32 @@
*/
#ifndef INCLUDED_GR_ANNOTATOR_ALLTOALL_IMPL_H
-#define INCLUDED_GR_ANNOTATOR_ALLTOALL_IMPL_H
+#define INCLUDED_GR_ANNOTATOR_ALLTOALL_IMPL_H
#include <gnuradio/blocks/annotator_alltoall.h>
namespace gr {
- namespace blocks {
-
- class annotator_alltoall_impl : public annotator_alltoall
- {
- private:
- uint64_t d_when;
- uint64_t d_tag_counter;
- std::vector<tag_t> d_stored_tags;
-
- public:
- annotator_alltoall_impl(int when, size_t sizeof_stream_item);
- ~annotator_alltoall_impl();
-
- std::vector<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 blocks {
+
+class annotator_alltoall_impl : public annotator_alltoall
+{
+private:
+ uint64_t d_when;
+ uint64_t d_tag_counter;
+ std::vector<tag_t> d_stored_tags;
+
+public:
+ annotator_alltoall_impl(int when, size_t sizeof_stream_item);
+ ~annotator_alltoall_impl();
+
+ std::vector<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
index ce15103822..4ca6f3fde5 100644
--- a/gr-blocks/lib/annotator_raw_impl.cc
+++ b/gr-blocks/lib/annotator_raw_impl.cc
@@ -34,80 +34,73 @@
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)
- : sync_block("annotator_raw",
- io_signature::make(1, 1, sizeof_stream_item),
- io_signature::make(1, 1, sizeof_stream_item)),
- d_itemsize(sizeof_stream_item)
- {
- set_tag_propagation_policy(TPP_ONE_TO_ONE);
- set_relative_rate(1, 1);
+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)
+ : sync_block("annotator_raw",
+ io_signature::make(1, 1, sizeof_stream_item),
+ io_signature::make(1, 1, sizeof_stream_item)),
+ d_itemsize(sizeof_stream_item)
+{
+ set_tag_propagation_policy(TPP_ONE_TO_ONE);
+ set_relative_rate(1, 1);
+}
+
+annotator_raw_impl::~annotator_raw_impl() {}
+
+void annotator_raw_impl::add_tag(uint64_t offset, pmt_t key, pmt_t val)
+{
+ gr::thread::scoped_lock l(d_mutex);
+
+ tag_t tag;
+ tag.srcid = 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(), 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()
- {
- }
-
- void
- annotator_raw_impl::add_tag(uint64_t offset, pmt_t key, pmt_t val)
- {
- gr::thread::scoped_lock l(d_mutex);
-
- tag_t tag;
- tag.srcid = 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(),
- 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.");
- }
- }
-
- int
- annotator_raw_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- gr::thread::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<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;
+}
+
+int annotator_raw_impl::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ gr::thread::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<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 */
+ // 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
index 54bed2ea25..9bf3f9eeb9 100644
--- a/gr-blocks/lib/annotator_raw_impl.h
+++ b/gr-blocks/lib/annotator_raw_impl.h
@@ -21,34 +21,34 @@
*/
#ifndef INCLUDED_GR_ANNOTATOR_RAW_IMPL_H
-#define INCLUDED_GR_ANNOTATOR_RAW_IMPL_H
+#define INCLUDED_GR_ANNOTATOR_RAW_IMPL_H
#include <gnuradio/blocks/annotator_raw.h>
#include <gnuradio/thread/thread.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class annotator_raw_impl : public annotator_raw
- {
- private:
- size_t d_itemsize;
- std::vector<tag_t> d_queued_tags;
- gr::thread::mutex d_mutex;
+class annotator_raw_impl : public annotator_raw
+{
+private:
+ size_t d_itemsize;
+ std::vector<tag_t> d_queued_tags;
+ gr::thread::mutex d_mutex;
- public:
- annotator_raw_impl(size_t sizeof_stream_item);
- ~annotator_raw_impl();
+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);
+ // 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);
- };
+ int work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_GR_ANNOTATOR_RAW_IMPL_H */
diff --git a/gr-blocks/lib/argmax_impl.cc b/gr-blocks/lib/argmax_impl.cc
index b3fd548aee..c3d7546c34 100644
--- a/gr-blocks/lib/argmax_impl.cc
+++ b/gr-blocks/lib/argmax_impl.cc
@@ -28,64 +28,61 @@
#include <gnuradio/io_signature.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- template <class T>
- typename argmax<T>::sptr
- argmax<T>::make(size_t vlen)
- {
- return gnuradio::get_initial_sptr
- (new argmax_impl<T>(vlen));
- }
+template <class T>
+typename argmax<T>::sptr argmax<T>::make(size_t vlen)
+{
+ return gnuradio::get_initial_sptr(new argmax_impl<T>(vlen));
+}
- template <class T>
- argmax_impl<T>::argmax_impl(size_t vlen)
+template <class T>
+argmax_impl<T>::argmax_impl(size_t vlen)
: sync_block("argmax",
- io_signature::make(1, -1, vlen*sizeof(T)),
- io_signature::make(2, 2, sizeof(std::int16_t))),
+ io_signature::make(1, -1, vlen * sizeof(T)),
+ io_signature::make(2, 2, sizeof(std::int16_t))),
d_vlen(vlen)
- {
- }
+{
+}
- template <class T>
- argmax_impl<T>::~argmax_impl()
- {
- }
+template <class T>
+argmax_impl<T>::~argmax_impl()
+{
+}
- template <class T>
- int
- argmax_impl<T>::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- int ninputs = input_items.size ();
+template <class T>
+int argmax_impl<T>::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ int ninputs = input_items.size();
- std::int16_t *x_optr = (std::int16_t *)output_items[0];
- std::int16_t *y_optr = (std::int16_t *)output_items[1];
+ std::int16_t* x_optr = (std::int16_t*)output_items[0];
+ std::int16_t* y_optr = (std::int16_t*)output_items[1];
- for(int i = 0; i < noutput_items; i++) {
- T max = ((T *)input_items[0])[i*d_vlen];
+ for (int i = 0; i < noutput_items; i++) {
+ T max = ((T*)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(((T *)input_items[k])[i*d_vlen + j] > max) {
- max = ((T *)input_items[k])[i*d_vlen + j];
- x = j;
- y = k;
+ for (int j = 0; j < (int)d_vlen; j++) {
+ for (int k = 0; k < ninputs; k++) {
+ if (((T*)input_items[k])[i * d_vlen + j] > max) {
+ max = ((T*)input_items[k])[i * d_vlen + j];
+ x = j;
+ y = k;
+ }
}
- }
}
*x_optr++ = (std::int16_t)x;
*y_optr++ = (std::int16_t)y;
- }
- return noutput_items;
}
- template class argmax<float>;
- template class argmax<std::int32_t>;
- template class argmax<std::int16_t>;
+ return noutput_items;
+}
+template class argmax<float>;
+template class argmax<std::int32_t>;
+template class argmax<std::int16_t>;
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/argmax_impl.h b/gr-blocks/lib/argmax_impl.h
index e6609930dc..c4de0bd38a 100644
--- a/gr-blocks/lib/argmax_impl.h
+++ b/gr-blocks/lib/argmax_impl.h
@@ -26,24 +26,24 @@
#include <gnuradio/blocks/argmax.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- template <class T>
- class argmax_impl : public argmax<T>
- {
- private:
- size_t d_vlen;
+template <class T>
+class argmax_impl : public argmax<T>
+{
+private:
+ size_t d_vlen;
- public:
- argmax_impl(size_t vlen);
- ~argmax_impl();
+public:
+ argmax_impl(size_t vlen);
+ ~argmax_impl();
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* ARGMAX_IMPL_H */
diff --git a/gr-blocks/lib/bin_statistics_f_impl.cc b/gr-blocks/lib/bin_statistics_f_impl.cc
index f91faea61d..0886a2a75a 100644
--- a/gr-blocks/lib/bin_statistics_f_impl.cc
+++ b/gr-blocks/lib/bin_statistics_f_impl.cc
@@ -29,148 +29,136 @@
#include <string.h>
namespace gr {
- namespace blocks {
-
- bin_statistics_f::sptr
- bin_statistics_f::make(unsigned int vlen,
- msg_queue::sptr msgq,
- 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,
- msg_queue::sptr msgq,
- feval_dd *tune,
- size_t tune_delay,
- size_t dwell_delay)
- : sync_block("bin_statistics_f",
- io_signature::make(1, 1, sizeof(float) * vlen),
- io_signature::make(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:
+namespace blocks {
+
+bin_statistics_f::sptr bin_statistics_f::make(unsigned int vlen,
+ msg_queue::sptr msgq,
+ 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,
+ msg_queue::sptr msgq,
+ feval_dd* tune,
+ size_t tune_delay,
+ size_t dwell_delay)
+ : sync_block("bin_statistics_f",
+ io_signature::make(1, 1, sizeof(float) * vlen),
+ io_signature::make(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:
+ case ST_TUNE_DELAY:
t = std::min(noutput_items - n, int(d_delay));
n += t;
d_delay -= t;
- if(d_delay == 0)
- enter_dwell_delay();
+ if (d_delay == 0)
+ enter_dwell_delay();
break;
- case ST_DWELL_DELAY:
+ 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++;
+ for (int i = 0; i < t; i++) {
+ accrue_stats(&input[n * vlen]);
+ n++;
}
d_delay -= t;
- if(d_delay == 0) {
- leave_dwell_delay();
- enter_tune_delay();
+ if (d_delay == 0) {
+ leave_dwell_delay();
+ enter_tune_delay();
}
break;
- default:
+ default:
assert(0);
- }
- }
-
- return noutput_items;
+ }
}
- //////////////////////////////////////////////////////////////////////////
- // virtual methods for gathering stats
- //////////////////////////////////////////////////////////////////////////
+ return noutput_items;
+}
+
+//////////////////////////////////////////////////////////////////////////
+// virtual methods for gathering stats
+//////////////////////////////////////////////////////////////////////////
- void
- bin_statistics_f_impl::reset_stats()
- {
- for (size_t i = 0; i < vlen(); i++){
+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::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...
+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
- message::sptr msg = message::make(0, center_freq(), vlen(), vlen() * sizeof(float));
- memcpy(msg->msg(), &d_max[0], vlen() * sizeof(float));
- msgq()->insert_tail(msg);
- }
+ // build & send a message
+ message::sptr msg = message::make(0, center_freq(), vlen(), vlen() * sizeof(float));
+ memcpy(msg->msg(), &d_max[0], vlen() * sizeof(float));
+ msgq()->insert_tail(msg);
+}
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
-
diff --git a/gr-blocks/lib/bin_statistics_f_impl.h b/gr-blocks/lib/bin_statistics_f_impl.h
index 1d8da6b348..09686d04f1 100644
--- a/gr-blocks/lib/bin_statistics_f_impl.h
+++ b/gr-blocks/lib/bin_statistics_f_impl.h
@@ -29,54 +29,53 @@
#include <gnuradio/msg_queue.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class bin_statistics_f_impl : public bin_statistics_f
- {
- private:
- enum state_t { ST_INIT, ST_TUNE_DELAY, ST_DWELL_DELAY };
+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;
- msg_queue::sptr d_msgq;
- feval_dd *d_tune;
- size_t d_tune_delay;
- size_t d_dwell_delay;
- double d_center_freq;
+ size_t d_vlen;
+ msg_queue::sptr d_msgq;
+ 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
+ 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();
+ void enter_init();
+ void enter_tune_delay();
+ void enter_dwell_delay();
+ void leave_dwell_delay();
- protected:
- std::vector<float> d_max; // per bin maxima
+protected:
+ std::vector<float> d_max; // per bin maxima
- size_t vlen() const { return d_vlen; }
- double center_freq() const { return d_center_freq; }
- msg_queue::sptr msgq() const { return d_msgq; }
+ size_t vlen() const { return d_vlen; }
+ double center_freq() const { return d_center_freq; }
+ msg_queue::sptr msgq() const { return d_msgq; }
- virtual void reset_stats();
- virtual void accrue_stats(const float *input);
- virtual void send_stats();
+ virtual void reset_stats();
+ virtual void accrue_stats(const float* input);
+ virtual void send_stats();
- public:
- bin_statistics_f_impl(unsigned int vlen,
- msg_queue::sptr msgq,
- feval_dd *tune,
- size_t tune_delay,
- size_t dwell_delay);
- ~bin_statistics_f_impl();
+public:
+ bin_statistics_f_impl(unsigned int vlen,
+ msg_queue::sptr msgq,
+ 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);
+ int work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- };
-
- } /* namespace blocks */
+} /* 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
index da69a0ea48..a2a8c87c0f 100644
--- a/gr-blocks/lib/burst_tagger_impl.cc
+++ b/gr-blocks/lib/burst_tagger_impl.cc
@@ -29,88 +29,79 @@
#include <string.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- burst_tagger::sptr
- burst_tagger::make(size_t itemsize)
- {
- return gnuradio::get_initial_sptr
- (new burst_tagger_impl(itemsize));
- }
+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)
- : sync_block("burst_tagger",
- io_signature::make2(2, 2, itemsize, sizeof(short)),
- io_signature::make(1, 1, itemsize)),
- d_itemsize(itemsize), d_state(false)
- {
- std::stringstream str;
- str << name() << unique_id();
+burst_tagger_impl::burst_tagger_impl(size_t itemsize)
+ : sync_block("burst_tagger",
+ io_signature::make2(2, 2, itemsize, sizeof(short)),
+ io_signature::make(1, 1, itemsize)),
+ d_itemsize(itemsize),
+ d_state(false)
+{
+ std::stringstream str;
+ str << name() << unique_id();
- d_true_key = pmt::string_to_symbol("burst");
- d_true_value = pmt::PMT_T;
+ d_true_key = pmt::string_to_symbol("burst");
+ d_true_value = pmt::PMT_T;
- d_false_key = pmt::string_to_symbol("burst");
- d_false_value = pmt::PMT_F;
+ d_false_key = pmt::string_to_symbol("burst");
+ d_false_value = pmt::PMT_F;
- d_id = pmt::string_to_symbol(str.str());
- }
+ d_id = pmt::string_to_symbol(str.str());
+}
- burst_tagger_impl::~burst_tagger_impl()
- {
- }
+burst_tagger_impl::~burst_tagger_impl() {}
- void
- burst_tagger_impl::set_true_tag(const std::string &key, bool value)
- {
- d_true_key = pmt::string_to_symbol(key);
- if(value == true) {
+void burst_tagger_impl::set_true_tag(const std::string& key, bool value)
+{
+ d_true_key = pmt::string_to_symbol(key);
+ if (value == true) {
d_true_value = pmt::PMT_T;
- }
- else {
+ } else {
d_true_value = pmt::PMT_F;
- }
}
+}
- void
- burst_tagger_impl::set_false_tag (const std::string &key, bool value)
- {
- d_false_key = pmt::string_to_symbol(key);
- if(value == true) {
+void burst_tagger_impl::set_false_tag(const std::string& key, bool value)
+{
+ d_false_key = pmt::string_to_symbol(key);
+ if (value == true) {
d_false_value = pmt::PMT_T;
- }
- else {
+ } 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];
+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);
+ 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);
- }
+ 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;
}
+ return noutput_items;
+}
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/burst_tagger_impl.h b/gr-blocks/lib/burst_tagger_impl.h
index 65ad58f8b3..412e9cc695 100644
--- a/gr-blocks/lib/burst_tagger_impl.h
+++ b/gr-blocks/lib/burst_tagger_impl.h
@@ -26,34 +26,34 @@
#include <gnuradio/blocks/burst_tagger.h>
namespace gr {
- namespace blocks {
+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;
+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_false_key;
+ pmt::pmt_t d_false_value;
- pmt::pmt_t d_id;
+ pmt::pmt_t d_id;
- public:
- burst_tagger_impl(size_t itemsize);
- ~burst_tagger_impl();
+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);
+ 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);
- };
+ int work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_GR_BURST_TAGGER_IMPL_H */
diff --git a/gr-blocks/lib/char_to_float_impl.cc b/gr-blocks/lib/char_to_float_impl.cc
index f6fb990981..3c550412ef 100644
--- a/gr-blocks/lib/char_to_float_impl.cc
+++ b/gr-blocks/lib/char_to_float_impl.cc
@@ -29,37 +29,36 @@
#include <volk/volk.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- char_to_float::sptr char_to_float::make(size_t vlen, float scale)
- {
- return gnuradio::get_initial_sptr(new char_to_float_impl(vlen, scale));
- }
+char_to_float::sptr char_to_float::make(size_t vlen, float scale)
+{
+ return gnuradio::get_initial_sptr(new char_to_float_impl(vlen, scale));
+}
- char_to_float_impl::char_to_float_impl(size_t vlen, float scale)
- : sync_block("char_to_float",
- io_signature::make (1, -1, sizeof(char)*vlen),
- io_signature::make (1, 1, sizeof(float)*vlen)),
- d_vlen(vlen), d_scale(scale)
- {
- const int alignment_multiple =
- volk_get_alignment() / sizeof(float);
- set_alignment(std::max(1, alignment_multiple));
- }
+char_to_float_impl::char_to_float_impl(size_t vlen, float scale)
+ : sync_block("char_to_float",
+ io_signature::make(1, -1, sizeof(char) * vlen),
+ io_signature::make(1, 1, sizeof(float) * vlen)),
+ d_vlen(vlen),
+ d_scale(scale)
+{
+ const int alignment_multiple = volk_get_alignment() / sizeof(float);
+ set_alignment(std::max(1, alignment_multiple));
+}
- int
- char_to_float_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- const int8_t *in = (const int8_t *) input_items[0];
- float *out = (float *) output_items[0];
+int char_to_float_impl::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ const int8_t* in = (const int8_t*)input_items[0];
+ float* out = (float*)output_items[0];
- // Note: the unaligned benchmarked much faster than the aligned
- volk_8i_s32f_convert_32f_u(out, in, d_scale, d_vlen*noutput_items);
+ // Note: the unaligned benchmarked much faster than the aligned
+ volk_8i_s32f_convert_32f_u(out, in, d_scale, d_vlen * noutput_items);
- return noutput_items;
- }
+ return noutput_items;
+}
- } /* namespace blocks */
-}/* namespace gr */
+} /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/char_to_float_impl.h b/gr-blocks/lib/char_to_float_impl.h
index 4d056850b0..1d73335eed 100644
--- a/gr-blocks/lib/char_to_float_impl.h
+++ b/gr-blocks/lib/char_to_float_impl.h
@@ -26,25 +26,25 @@
#include <gnuradio/blocks/char_to_float.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class BLOCKS_API char_to_float_impl : public char_to_float
- {
- size_t d_vlen;
- float d_scale;
+class BLOCKS_API char_to_float_impl : public char_to_float
+{
+ size_t d_vlen;
+ float d_scale;
- public:
- char_to_float_impl(size_t vlen, float scale);
+public:
+ char_to_float_impl(size_t vlen, float scale);
- virtual float scale() const { return d_scale; }
- virtual void set_scale(float scale) { d_scale = scale; }
+ virtual float scale() const { return d_scale; }
+ virtual void set_scale(float scale) { d_scale = scale; }
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/char_to_short_impl.cc b/gr-blocks/lib/char_to_short_impl.cc
index fa8d55fbd0..f75e5b7c84 100644
--- a/gr-blocks/lib/char_to_short_impl.cc
+++ b/gr-blocks/lib/char_to_short_impl.cc
@@ -29,36 +29,34 @@
#include <volk/volk.h>
namespace gr {
- namespace blocks {
-
- char_to_short::sptr char_to_short::make(size_t vlen)
- {
- return gnuradio::get_initial_sptr(new char_to_short_impl(vlen));
- }
-
- char_to_short_impl::char_to_short_impl(size_t vlen)
- : sync_block("char_to_short",
- io_signature::make(1, 1, sizeof(char)*vlen),
- io_signature::make(1, 1, sizeof(short)*vlen)),
- d_vlen(vlen)
- {
- const int alignment_multiple =
- volk_get_alignment() / sizeof(short);
- set_alignment(std::max(1, alignment_multiple));
- }
-
- int
- char_to_short_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- const int8_t *in = (const int8_t *)input_items[0];
- int16_t *out = (int16_t *)output_items[0];
-
- volk_8i_convert_16i(out, in, d_vlen*noutput_items);
-
- return noutput_items;
- }
-
- } /* namespace blocks */
-}/* namespace gr */
+namespace blocks {
+
+char_to_short::sptr char_to_short::make(size_t vlen)
+{
+ return gnuradio::get_initial_sptr(new char_to_short_impl(vlen));
+}
+
+char_to_short_impl::char_to_short_impl(size_t vlen)
+ : sync_block("char_to_short",
+ io_signature::make(1, 1, sizeof(char) * vlen),
+ io_signature::make(1, 1, sizeof(short) * vlen)),
+ d_vlen(vlen)
+{
+ const int alignment_multiple = volk_get_alignment() / sizeof(short);
+ set_alignment(std::max(1, alignment_multiple));
+}
+
+int char_to_short_impl::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ const int8_t* in = (const int8_t*)input_items[0];
+ int16_t* out = (int16_t*)output_items[0];
+
+ volk_8i_convert_16i(out, in, d_vlen * noutput_items);
+
+ return noutput_items;
+}
+
+} /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/char_to_short_impl.h b/gr-blocks/lib/char_to_short_impl.h
index ad13fd1918..e49c204ec5 100644
--- a/gr-blocks/lib/char_to_short_impl.h
+++ b/gr-blocks/lib/char_to_short_impl.h
@@ -26,21 +26,21 @@
#include <gnuradio/blocks/char_to_short.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class BLOCKS_API char_to_short_impl : public char_to_short
- {
- size_t d_vlen;
+class BLOCKS_API char_to_short_impl : public char_to_short
+{
+ size_t d_vlen;
- public:
- char_to_short_impl(size_t vlen);
+public:
+ char_to_short_impl(size_t vlen);
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/check_lfsr_32k_s_impl.cc b/gr-blocks/lib/check_lfsr_32k_s_impl.cc
index fac30223f7..a3826d5a6e 100644
--- a/gr-blocks/lib/check_lfsr_32k_s_impl.cc
+++ b/gr-blocks/lib/check_lfsr_32k_s_impl.cc
@@ -30,150 +30,144 @@
#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()
- : sync_block("check_lfsr_32k",
- io_signature::make(1, 1, sizeof(short)),
- io_signature::make(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++)
+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()
+ : sync_block("check_lfsr_32k",
+ io_signature::make(1, 1, sizeof(short)),
+ io_signature::make(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();
- }
+ enter_SEARCHING();
+}
- check_lfsr_32k_s_impl::~check_lfsr_32k_s_impl()
- {
- }
+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];
+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++) {
+ for (int i = 0; i < noutput_items; i++) {
unsigned short x = in[i];
unsigned short expected;
- switch(d_state) {
+ switch (d_state) {
case MATCH0:
- if(x == d_buffer[0])
- enter_MATCH1();
- break;
+ if (x == d_buffer[0])
+ enter_MATCH1();
+ break;
case MATCH1:
- if(x == d_buffer[1])
- enter_MATCH2();
- else
- enter_MATCH0();
- break;
+ if (x == d_buffer[1])
+ enter_MATCH2();
+ else
+ enter_MATCH0();
+ break;
case MATCH2:
- if(x == d_buffer[2])
- enter_LOCKED();
- else
- enter_MATCH0();
- break;
+ 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;
+ 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();
+ abort();
}
d_ntotal++;
- }
-
- return noutput_items;
}
- void
- check_lfsr_32k_s_impl::enter_SEARCHING()
- {
- d_state = SEARCHING;
- wrong(); // reset history
- wrong();
- wrong();
+ return noutput_items;
+}
- d_runlength = 0;
- d_index = 0; // reset LFSR to beginning
+void check_lfsr_32k_s_impl::enter_SEARCHING()
+{
+ d_state = SEARCHING;
+ wrong(); // reset history
+ wrong();
+ wrong();
- if(0)
- fprintf(stdout, "check_lfsr_32k: enter_SEARCHING at offset %8ld (0x%08lx)\n",
- d_ntotal, d_ntotal);
+ d_runlength = 0;
+ d_index = 0; // reset LFSR to beginning
- enter_MATCH0();
- }
+ if (0)
+ fprintf(stdout,
+ "check_lfsr_32k: enter_SEARCHING at offset %8ld (0x%08lx)\n",
+ d_ntotal,
+ d_ntotal);
- void
- check_lfsr_32k_s_impl::enter_MATCH0()
- {
- d_state = MATCH0;
- }
+ enter_MATCH0();
+}
- void
- check_lfsr_32k_s_impl::enter_MATCH1()
- {
- d_state = MATCH1;
- }
+void check_lfsr_32k_s_impl::enter_MATCH0() { d_state = MATCH0; }
- void
- check_lfsr_32k_s_impl::enter_MATCH2()
- {
- d_state = MATCH2;
- }
+void check_lfsr_32k_s_impl::enter_MATCH1() { d_state = MATCH1; }
- void
- check_lfsr_32k_s_impl::enter_LOCKED()
- {
- d_state = LOCKED;
- right(); // setup history
- right();
- right();
+void check_lfsr_32k_s_impl::enter_MATCH2() { d_state = MATCH2; }
- d_index = 3; // already matched first 3 items
+void check_lfsr_32k_s_impl::enter_LOCKED()
+{
+ d_state = LOCKED;
+ right(); // setup history
+ right();
+ right();
- if(0)
- fprintf(stdout, "check_lfsr_32k: enter_LOCKED at offset %8ld (0x%08lx)\n",
- d_ntotal, d_ntotal);
- }
+ d_index = 3; // already matched first 3 items
- void
- check_lfsr_32k_s_impl::log_error(unsigned short expected, unsigned short actual)
- {
- if(0)
+ if (0)
fprintf(stdout,
- "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 */
+ "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,
+ "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
index 2d0da21fcf..3830c0b814 100644
--- a/gr-blocks/lib/check_lfsr_32k_s_impl.h
+++ b/gr-blocks/lib/check_lfsr_32k_s_impl.h
@@ -27,68 +27,68 @@
#include <gnuradio/blocks/lfsr_32k.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class check_lfsr_32k_s_impl : public check_lfsr_32k_s
- {
- private:
- enum state {
- SEARCHING, // searching for synchronization
+class check_lfsr_32k_s_impl : public check_lfsr_32k_s
+{
+private:
+ enum state {
+ SEARCHING, // searching for synchronization
MATCH0,
MATCH1,
MATCH2,
- LOCKED // is locked
- };
+ LOCKED // is locked
+ };
- state d_state;
- unsigned int d_history; // bitmask of decisions
+ 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
+ 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];
+ 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 enter_SEARCHING();
+ void enter_MATCH0();
+ void enter_MATCH1();
+ void enter_MATCH2();
+ void enter_LOCKED();
- void right()
- {
+ void right()
+ {
d_history = (d_history << 1) | 0x1;
d_nright++;
d_runlength++;
- }
+ }
- void wrong()
- {
+ 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; }
+ 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);
+ void log_error(unsigned short expected, unsigned short actual);
- public:
- check_lfsr_32k_s_impl();
- ~check_lfsr_32k_s_impl();
+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);
+ 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; }
- };
+ long ntotal() const { return d_ntotal; }
+ long nright() const { return d_nright; }
+ long runlength() const { return d_runlength; }
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_GR_CHECK_LFSR_32K_S_IMPL_H */
diff --git a/gr-blocks/lib/complex_to_arg_impl.cc b/gr-blocks/lib/complex_to_arg_impl.cc
index ab92c08b3b..8f5bf61c81 100644
--- a/gr-blocks/lib/complex_to_arg_impl.cc
+++ b/gr-blocks/lib/complex_to_arg_impl.cc
@@ -30,41 +30,39 @@
#include <gnuradio/math.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- complex_to_arg::sptr complex_to_arg::make(size_t vlen)
- {
- return gnuradio::get_initial_sptr(new complex_to_arg_impl(vlen));
- }
-
- complex_to_arg_impl::complex_to_arg_impl(size_t vlen)
- : sync_block("complex_to_arg",
- io_signature::make (1, 1, sizeof(gr_complex)*vlen),
- io_signature::make (1, 1, sizeof(float)*vlen)),
- d_vlen(vlen)
- {
- const int alignment_multiple =
- volk_get_alignment() / sizeof(float);
- set_alignment(std::max(1,alignment_multiple));
- }
+complex_to_arg::sptr complex_to_arg::make(size_t vlen)
+{
+ return gnuradio::get_initial_sptr(new complex_to_arg_impl(vlen));
+}
- int
- complex_to_arg_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- const gr_complex *in = (const gr_complex *) input_items[0];
- float *out = (float *) output_items[0];
- int noi = noutput_items * d_vlen;
+complex_to_arg_impl::complex_to_arg_impl(size_t vlen)
+ : sync_block("complex_to_arg",
+ io_signature::make(1, 1, sizeof(gr_complex) * vlen),
+ io_signature::make(1, 1, sizeof(float) * vlen)),
+ d_vlen(vlen)
+{
+ const int alignment_multiple = volk_get_alignment() / sizeof(float);
+ set_alignment(std::max(1, alignment_multiple));
+}
- // The fast_atan2f is faster than Volk
- for (int i = 0; i < noi; i++){
- // out[i] = std::arg (in[i]);
- out[i] = gr::fast_atan2f(in[i]);
- }
+int complex_to_arg_impl::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ const gr_complex* in = (const gr_complex*)input_items[0];
+ float* out = (float*)output_items[0];
+ int noi = noutput_items * d_vlen;
- return noutput_items;
+ // The fast_atan2f is faster than Volk
+ for (int i = 0; i < noi; i++) {
+ // out[i] = std::arg (in[i]);
+ out[i] = gr::fast_atan2f(in[i]);
}
- } /* namespace blocks */
-}/* namespace gr */
+ return noutput_items;
+}
+
+} /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/complex_to_arg_impl.h b/gr-blocks/lib/complex_to_arg_impl.h
index 923ef4ba8e..60e08bf387 100644
--- a/gr-blocks/lib/complex_to_arg_impl.h
+++ b/gr-blocks/lib/complex_to_arg_impl.h
@@ -26,21 +26,21 @@
#include <gnuradio/blocks/complex_to_arg.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class BLOCKS_API complex_to_arg_impl : public complex_to_arg
- {
- size_t d_vlen;
+class BLOCKS_API complex_to_arg_impl : public complex_to_arg
+{
+ size_t d_vlen;
- public:
- complex_to_arg_impl(size_t vlen);
+public:
+ complex_to_arg_impl(size_t vlen);
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/complex_to_float_impl.cc b/gr-blocks/lib/complex_to_float_impl.cc
index bfa75bd35d..3fc42fafaf 100644
--- a/gr-blocks/lib/complex_to_float_impl.cc
+++ b/gr-blocks/lib/complex_to_float_impl.cc
@@ -29,51 +29,48 @@
#include <volk/volk.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- complex_to_float::sptr complex_to_float::make(size_t vlen)
- {
- return gnuradio::get_initial_sptr(new complex_to_float_impl(vlen));
- }
+complex_to_float::sptr complex_to_float::make(size_t vlen)
+{
+ return gnuradio::get_initial_sptr(new complex_to_float_impl(vlen));
+}
- complex_to_float_impl::complex_to_float_impl(size_t vlen)
- : sync_block("complex_to_float",
- io_signature::make (1, 1, sizeof(gr_complex)*vlen),
- io_signature::make (1, 2, sizeof(float)*vlen)),
- d_vlen(vlen)
- {
- const int alignment_multiple =
- volk_get_alignment() / sizeof(float);
- set_alignment(std::max(1,alignment_multiple));
- }
+complex_to_float_impl::complex_to_float_impl(size_t vlen)
+ : sync_block("complex_to_float",
+ io_signature::make(1, 1, sizeof(gr_complex) * vlen),
+ io_signature::make(1, 2, sizeof(float) * vlen)),
+ d_vlen(vlen)
+{
+ const int alignment_multiple = volk_get_alignment() / sizeof(float);
+ set_alignment(std::max(1, alignment_multiple));
+}
- int
- complex_to_float_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- const gr_complex *in = (const gr_complex *) input_items[0];
- float *out0 = (float *) output_items[0];
- float* out1;
- int noi = noutput_items * d_vlen;
+int complex_to_float_impl::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ const gr_complex* in = (const gr_complex*)input_items[0];
+ float* out0 = (float*)output_items[0];
+ float* out1;
+ int noi = noutput_items * d_vlen;
- switch (output_items.size ()){
- case 1:
+ switch (output_items.size()) {
+ case 1:
volk_32fc_deinterleave_real_32f(out0, in, noi);
- break;
+ break;
- case 2:
- out1 = (float *) output_items[1];
+ case 2:
+ out1 = (float*)output_items[1];
volk_32fc_deinterleave_32f_x2(out0, out1, in, noi);
- break;
-
- default:
- abort ();
+ break;
- }
-
- return noutput_items;
+ default:
+ abort();
}
- } /* namespace blocks */
-}/* namespace gr */
+ return noutput_items;
+}
+
+} /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/complex_to_float_impl.h b/gr-blocks/lib/complex_to_float_impl.h
index 81ac801e71..2bcfb04ff7 100644
--- a/gr-blocks/lib/complex_to_float_impl.h
+++ b/gr-blocks/lib/complex_to_float_impl.h
@@ -26,21 +26,21 @@
#include <gnuradio/blocks/complex_to_float.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class BLOCKS_API complex_to_float_impl : public complex_to_float
- {
- size_t d_vlen;
+class BLOCKS_API complex_to_float_impl : public complex_to_float
+{
+ size_t d_vlen;
- public:
- complex_to_float_impl(size_t vlen);
+public:
+ complex_to_float_impl(size_t vlen);
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/complex_to_imag_impl.cc b/gr-blocks/lib/complex_to_imag_impl.cc
index 8e47201694..4620d1d1ac 100644
--- a/gr-blocks/lib/complex_to_imag_impl.cc
+++ b/gr-blocks/lib/complex_to_imag_impl.cc
@@ -29,37 +29,35 @@
#include <volk/volk.h>
namespace gr {
- namespace blocks {
-
- complex_to_imag::sptr complex_to_imag::make(size_t vlen)
- {
- return gnuradio::get_initial_sptr(new complex_to_imag_impl(vlen));
- }
-
- complex_to_imag_impl::complex_to_imag_impl(size_t vlen)
- : sync_block("complex_to_imag",
- io_signature::make (1, 1, sizeof(gr_complex)*vlen),
- io_signature::make (1, 1, sizeof(float)*vlen)),
- d_vlen(vlen)
- {
- const int alignment_multiple =
- volk_get_alignment() / sizeof(float);
- set_alignment(std::max(1,alignment_multiple));
- }
-
- int
- complex_to_imag_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- const gr_complex *in = (const gr_complex *) input_items[0];
- float *out = (float *) output_items[0];
- int noi = noutput_items * d_vlen;
-
- volk_32fc_deinterleave_imag_32f(out, in, noi);
-
- return noutput_items;
- }
-
- } /* namespace blocks */
-}/* namespace gr */
+namespace blocks {
+
+complex_to_imag::sptr complex_to_imag::make(size_t vlen)
+{
+ return gnuradio::get_initial_sptr(new complex_to_imag_impl(vlen));
+}
+
+complex_to_imag_impl::complex_to_imag_impl(size_t vlen)
+ : sync_block("complex_to_imag",
+ io_signature::make(1, 1, sizeof(gr_complex) * vlen),
+ io_signature::make(1, 1, sizeof(float) * vlen)),
+ d_vlen(vlen)
+{
+ const int alignment_multiple = volk_get_alignment() / sizeof(float);
+ set_alignment(std::max(1, alignment_multiple));
+}
+
+int complex_to_imag_impl::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ const gr_complex* in = (const gr_complex*)input_items[0];
+ float* out = (float*)output_items[0];
+ int noi = noutput_items * d_vlen;
+
+ volk_32fc_deinterleave_imag_32f(out, in, noi);
+
+ return noutput_items;
+}
+
+} /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/complex_to_imag_impl.h b/gr-blocks/lib/complex_to_imag_impl.h
index f624c97d82..0ee01b03ae 100644
--- a/gr-blocks/lib/complex_to_imag_impl.h
+++ b/gr-blocks/lib/complex_to_imag_impl.h
@@ -26,21 +26,21 @@
#include <gnuradio/blocks/complex_to_imag.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class BLOCKS_API complex_to_imag_impl : public complex_to_imag
- {
- size_t d_vlen;
+class BLOCKS_API complex_to_imag_impl : public complex_to_imag
+{
+ size_t d_vlen;
- public:
- complex_to_imag_impl(size_t vlen);
+public:
+ complex_to_imag_impl(size_t vlen);
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/complex_to_interleaved_char_impl.cc b/gr-blocks/lib/complex_to_interleaved_char_impl.cc
index f25378e64e..066b48f0ba 100644
--- a/gr-blocks/lib/complex_to_interleaved_char_impl.cc
+++ b/gr-blocks/lib/complex_to_interleaved_char_impl.cc
@@ -17,7 +17,7 @@
* You should have received a copy of the GNU General Public License
* along with GNU Radio; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
-* Boston, MA 02110-1301, USA.
+ * Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
@@ -28,38 +28,38 @@
#include <gnuradio/io_signature.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- complex_to_interleaved_char::sptr complex_to_interleaved_char::make(bool vector)
- {
- return gnuradio::get_initial_sptr(new complex_to_interleaved_char_impl(vector));
- }
-
- complex_to_interleaved_char_impl::complex_to_interleaved_char_impl(bool vector)
- : sync_interpolator("complex_to_interleaved_char",
- io_signature::make (1, 1, sizeof(gr_complex)),
- io_signature::make (1, 1, vector?2*sizeof(char):sizeof(char)),
- vector?1:2),
- d_vector(vector)
- {
- }
+complex_to_interleaved_char::sptr complex_to_interleaved_char::make(bool vector)
+{
+ return gnuradio::get_initial_sptr(new complex_to_interleaved_char_impl(vector));
+}
- int
- complex_to_interleaved_char_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- const gr_complex *in = (const gr_complex *) input_items[0];
- char *out = (char *) output_items[0];
+complex_to_interleaved_char_impl::complex_to_interleaved_char_impl(bool vector)
+ : sync_interpolator(
+ "complex_to_interleaved_char",
+ io_signature::make(1, 1, sizeof(gr_complex)),
+ io_signature::make(1, 1, vector ? 2 * sizeof(char) : sizeof(char)),
+ vector ? 1 : 2),
+ d_vector(vector)
+{
+}
- int npairs = (d_vector?noutput_items:noutput_items/2);
- for (int i = 0; i < npairs; i++){
- *out++ = (char) lrintf(in[i].real()); // FIXME saturate?
- *out++ = (char) lrintf(in[i].imag());
- }
+int complex_to_interleaved_char_impl::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ const gr_complex* in = (const gr_complex*)input_items[0];
+ char* out = (char*)output_items[0];
- return noutput_items;
+ int npairs = (d_vector ? noutput_items : noutput_items / 2);
+ for (int i = 0; i < npairs; i++) {
+ *out++ = (char)lrintf(in[i].real()); // FIXME saturate?
+ *out++ = (char)lrintf(in[i].imag());
}
- } /* namespace blocks */
-}/* namespace gr */
+ return noutput_items;
+}
+
+} /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/complex_to_interleaved_char_impl.h b/gr-blocks/lib/complex_to_interleaved_char_impl.h
index 95ca7ea6a4..74bdbd1a3e 100644
--- a/gr-blocks/lib/complex_to_interleaved_char_impl.h
+++ b/gr-blocks/lib/complex_to_interleaved_char_impl.h
@@ -26,21 +26,22 @@
#include <gnuradio/blocks/complex_to_interleaved_char.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class BLOCKS_API complex_to_interleaved_char_impl : public complex_to_interleaved_char
- {
- private:
- bool d_vector;
- public:
- complex_to_interleaved_char_impl(bool vector);
+class BLOCKS_API complex_to_interleaved_char_impl : public complex_to_interleaved_char
+{
+private:
+ bool d_vector;
- int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
- };
+public:
+ complex_to_interleaved_char_impl(bool vector);
- } /* namespace blocks */
+ int work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
+
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/complex_to_interleaved_short_impl.cc b/gr-blocks/lib/complex_to_interleaved_short_impl.cc
index 1bc79989a9..411929905e 100644
--- a/gr-blocks/lib/complex_to_interleaved_short_impl.cc
+++ b/gr-blocks/lib/complex_to_interleaved_short_impl.cc
@@ -28,38 +28,38 @@
#include <gnuradio/io_signature.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- complex_to_interleaved_short::sptr complex_to_interleaved_short::make(bool vector)
- {
- return gnuradio::get_initial_sptr(new complex_to_interleaved_short_impl(vector));
- }
-
- complex_to_interleaved_short_impl::complex_to_interleaved_short_impl(bool vector)
- : sync_interpolator("complex_to_interleaved_short",
- io_signature::make (1, 1, sizeof(gr_complex)),
- io_signature::make (1, 1, vector?2*sizeof(short):sizeof(short)),
- vector?1:2),
- d_vector(vector)
- {
- }
+complex_to_interleaved_short::sptr complex_to_interleaved_short::make(bool vector)
+{
+ return gnuradio::get_initial_sptr(new complex_to_interleaved_short_impl(vector));
+}
- int
- complex_to_interleaved_short_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- const gr_complex *in = (const gr_complex *) input_items[0];
- short *out = (short *) output_items[0];
+complex_to_interleaved_short_impl::complex_to_interleaved_short_impl(bool vector)
+ : sync_interpolator(
+ "complex_to_interleaved_short",
+ io_signature::make(1, 1, sizeof(gr_complex)),
+ io_signature::make(1, 1, vector ? 2 * sizeof(short) : sizeof(short)),
+ vector ? 1 : 2),
+ d_vector(vector)
+{
+}
- int npairs = (d_vector?noutput_items:noutput_items/2);
- for (int i = 0; i < npairs; i++){
- *out++ = (short) lrintf(in[i].real()); // FIXME saturate?
- *out++ = (short) lrintf(in[i].imag());
- }
+int complex_to_interleaved_short_impl::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ const gr_complex* in = (const gr_complex*)input_items[0];
+ short* out = (short*)output_items[0];
- return noutput_items;
+ int npairs = (d_vector ? noutput_items : noutput_items / 2);
+ for (int i = 0; i < npairs; i++) {
+ *out++ = (short)lrintf(in[i].real()); // FIXME saturate?
+ *out++ = (short)lrintf(in[i].imag());
}
- } /* namespace blocks */
-}/* namespace gr */
+ return noutput_items;
+}
+
+} /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/complex_to_interleaved_short_impl.h b/gr-blocks/lib/complex_to_interleaved_short_impl.h
index 64835f0eec..f14efe0cbd 100644
--- a/gr-blocks/lib/complex_to_interleaved_short_impl.h
+++ b/gr-blocks/lib/complex_to_interleaved_short_impl.h
@@ -26,21 +26,22 @@
#include <gnuradio/blocks/complex_to_interleaved_short.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class BLOCKS_API complex_to_interleaved_short_impl : public complex_to_interleaved_short
- {
- private:
- bool d_vector;
- public:
- complex_to_interleaved_short_impl(bool vector);
+class BLOCKS_API complex_to_interleaved_short_impl : public complex_to_interleaved_short
+{
+private:
+ bool d_vector;
- int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
- };
+public:
+ complex_to_interleaved_short_impl(bool vector);
- } /* namespace blocks */
+ int work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
+
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/complex_to_mag_impl.cc b/gr-blocks/lib/complex_to_mag_impl.cc
index b9574a92ce..b520f45d57 100644
--- a/gr-blocks/lib/complex_to_mag_impl.cc
+++ b/gr-blocks/lib/complex_to_mag_impl.cc
@@ -29,38 +29,36 @@
#include <volk/volk.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- complex_to_mag::sptr complex_to_mag::make(size_t vlen)
- {
- return gnuradio::get_initial_sptr(new complex_to_mag_impl(vlen));
- }
+complex_to_mag::sptr complex_to_mag::make(size_t vlen)
+{
+ return gnuradio::get_initial_sptr(new complex_to_mag_impl(vlen));
+}
- complex_to_mag_impl::complex_to_mag_impl(size_t vlen)
- : sync_block("complex_to_mag",
- io_signature::make (1, 1, sizeof(gr_complex)*vlen),
- io_signature::make (1, 1, sizeof(float)*vlen)),
- d_vlen(vlen)
- {
- const int alignment_multiple =
- volk_get_alignment() / sizeof(float);
- set_alignment(std::max(1,alignment_multiple));
- }
+complex_to_mag_impl::complex_to_mag_impl(size_t vlen)
+ : sync_block("complex_to_mag",
+ io_signature::make(1, 1, sizeof(gr_complex) * vlen),
+ io_signature::make(1, 1, sizeof(float) * vlen)),
+ d_vlen(vlen)
+{
+ const int alignment_multiple = volk_get_alignment() / sizeof(float);
+ set_alignment(std::max(1, alignment_multiple));
+}
- int
- complex_to_mag_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- const gr_complex *in = (const gr_complex *) input_items[0];
- float *out = (float *) output_items[0];
- int noi = noutput_items * d_vlen;
+int complex_to_mag_impl::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ const gr_complex* in = (const gr_complex*)input_items[0];
+ float* out = (float*)output_items[0];
+ int noi = noutput_items * d_vlen;
- // turned out to be faster than aligned/unaligned switching
- volk_32fc_magnitude_32f_u(out, in, noi);
+ // turned out to be faster than aligned/unaligned switching
+ volk_32fc_magnitude_32f_u(out, in, noi);
- return noutput_items;
- }
+ return noutput_items;
+}
- } /* namespace blocks */
-}/* namespace gr */
+} /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/complex_to_mag_impl.h b/gr-blocks/lib/complex_to_mag_impl.h
index 88f6f2843a..5778bd91ca 100644
--- a/gr-blocks/lib/complex_to_mag_impl.h
+++ b/gr-blocks/lib/complex_to_mag_impl.h
@@ -26,21 +26,21 @@
#include <gnuradio/blocks/complex_to_mag.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class BLOCKS_API complex_to_mag_impl : public complex_to_mag
- {
- size_t d_vlen;
+class BLOCKS_API complex_to_mag_impl : public complex_to_mag
+{
+ size_t d_vlen;
- public:
- complex_to_mag_impl(size_t vlen);
+public:
+ complex_to_mag_impl(size_t vlen);
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/complex_to_mag_squared_impl.cc b/gr-blocks/lib/complex_to_mag_squared_impl.cc
index 0e41ae0d4c..070d04e8cc 100644
--- a/gr-blocks/lib/complex_to_mag_squared_impl.cc
+++ b/gr-blocks/lib/complex_to_mag_squared_impl.cc
@@ -29,37 +29,35 @@
#include <volk/volk.h>
namespace gr {
- namespace blocks {
-
- complex_to_mag_squared::sptr complex_to_mag_squared::make(size_t vlen)
- {
- return gnuradio::get_initial_sptr(new complex_to_mag_squared_impl(vlen));
- }
-
- complex_to_mag_squared_impl::complex_to_mag_squared_impl(size_t vlen)
- : sync_block("complex_to_mag_squared",
- io_signature::make (1, 1, sizeof(gr_complex)*vlen),
- io_signature::make (1, 1, sizeof(float)*vlen)),
- d_vlen(vlen)
- {
- const int alignment_multiple =
- volk_get_alignment() / sizeof(float);
- set_alignment(std::max(1,alignment_multiple));
- }
-
- int
- complex_to_mag_squared_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- const gr_complex *in = (const gr_complex *) input_items[0];
- float *out = (float *) output_items[0];
- int noi = noutput_items * d_vlen;
-
- volk_32fc_magnitude_squared_32f(out, in, noi);
-
- return noutput_items;
- }
-
- } /* namespace blocks */
-}/* namespace gr */
+namespace blocks {
+
+complex_to_mag_squared::sptr complex_to_mag_squared::make(size_t vlen)
+{
+ return gnuradio::get_initial_sptr(new complex_to_mag_squared_impl(vlen));
+}
+
+complex_to_mag_squared_impl::complex_to_mag_squared_impl(size_t vlen)
+ : sync_block("complex_to_mag_squared",
+ io_signature::make(1, 1, sizeof(gr_complex) * vlen),
+ io_signature::make(1, 1, sizeof(float) * vlen)),
+ d_vlen(vlen)
+{
+ const int alignment_multiple = volk_get_alignment() / sizeof(float);
+ set_alignment(std::max(1, alignment_multiple));
+}
+
+int complex_to_mag_squared_impl::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ const gr_complex* in = (const gr_complex*)input_items[0];
+ float* out = (float*)output_items[0];
+ int noi = noutput_items * d_vlen;
+
+ volk_32fc_magnitude_squared_32f(out, in, noi);
+
+ return noutput_items;
+}
+
+} /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/complex_to_mag_squared_impl.h b/gr-blocks/lib/complex_to_mag_squared_impl.h
index 2413b3bbdf..e03e59aabb 100644
--- a/gr-blocks/lib/complex_to_mag_squared_impl.h
+++ b/gr-blocks/lib/complex_to_mag_squared_impl.h
@@ -26,21 +26,21 @@
#include <gnuradio/blocks/complex_to_mag_squared.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class BLOCKS_API complex_to_mag_squared_impl : public complex_to_mag_squared
- {
- size_t d_vlen;
+class BLOCKS_API complex_to_mag_squared_impl : public complex_to_mag_squared
+{
+ size_t d_vlen;
- public:
- complex_to_mag_squared_impl(size_t vlen);
+public:
+ complex_to_mag_squared_impl(size_t vlen);
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/complex_to_magphase_impl.cc b/gr-blocks/lib/complex_to_magphase_impl.cc
index 8c914f756b..dd72c8e9c8 100644
--- a/gr-blocks/lib/complex_to_magphase_impl.cc
+++ b/gr-blocks/lib/complex_to_magphase_impl.cc
@@ -30,44 +30,42 @@
#include <gnuradio/math.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- complex_to_magphase::sptr complex_to_magphase::make(size_t vlen)
- {
- return gnuradio::get_initial_sptr(new complex_to_magphase_impl(vlen));
- }
-
- complex_to_magphase_impl::complex_to_magphase_impl(size_t vlen)
- : sync_block("complex_to_magphase",
- io_signature::make (1, 1, sizeof(gr_complex)*vlen),
- io_signature::make (2, 2, sizeof(float)*vlen)),
- d_vlen(vlen)
- {
- const int alignment_multiple =
- volk_get_alignment() / sizeof(float);
- set_alignment(std::max(1,alignment_multiple));
- }
+complex_to_magphase::sptr complex_to_magphase::make(size_t vlen)
+{
+ return gnuradio::get_initial_sptr(new complex_to_magphase_impl(vlen));
+}
- int
- complex_to_magphase_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- const gr_complex *in = (const gr_complex *) input_items[0];
- float *out0 = (float *) output_items[0];
- float* out1 = (float *) output_items[1];
- int noi = noutput_items * d_vlen;
+complex_to_magphase_impl::complex_to_magphase_impl(size_t vlen)
+ : sync_block("complex_to_magphase",
+ io_signature::make(1, 1, sizeof(gr_complex) * vlen),
+ io_signature::make(2, 2, sizeof(float) * vlen)),
+ d_vlen(vlen)
+{
+ const int alignment_multiple = volk_get_alignment() / sizeof(float);
+ set_alignment(std::max(1, alignment_multiple));
+}
- volk_32fc_magnitude_32f_u(out0, in, noi);
+int complex_to_magphase_impl::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ const gr_complex* in = (const gr_complex*)input_items[0];
+ float* out0 = (float*)output_items[0];
+ float* out1 = (float*)output_items[1];
+ int noi = noutput_items * d_vlen;
- // The fast_atan2f is faster than Volk
- for (int i = 0; i < noi; i++){
- // out[i] = std::arg (in[i]);
- out1[i] = gr::fast_atan2f(in[i]);
- }
+ volk_32fc_magnitude_32f_u(out0, in, noi);
- return noutput_items;
+ // The fast_atan2f is faster than Volk
+ for (int i = 0; i < noi; i++) {
+ // out[i] = std::arg (in[i]);
+ out1[i] = gr::fast_atan2f(in[i]);
}
- } /* namespace blocks */
-}/* namespace gr */
+ return noutput_items;
+}
+
+} /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/complex_to_magphase_impl.h b/gr-blocks/lib/complex_to_magphase_impl.h
index 4673d8ab2a..a6c1be0049 100644
--- a/gr-blocks/lib/complex_to_magphase_impl.h
+++ b/gr-blocks/lib/complex_to_magphase_impl.h
@@ -26,21 +26,21 @@
#include <gnuradio/blocks/complex_to_magphase.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class BLOCKS_API complex_to_magphase_impl : public complex_to_magphase
- {
- size_t d_vlen;
+class BLOCKS_API complex_to_magphase_impl : public complex_to_magphase
+{
+ size_t d_vlen;
- public:
- complex_to_magphase_impl(size_t vlen);
+public:
+ complex_to_magphase_impl(size_t vlen);
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/complex_to_real_impl.cc b/gr-blocks/lib/complex_to_real_impl.cc
index bab139e79c..ab4119969f 100644
--- a/gr-blocks/lib/complex_to_real_impl.cc
+++ b/gr-blocks/lib/complex_to_real_impl.cc
@@ -29,37 +29,35 @@
#include <volk/volk.h>
namespace gr {
- namespace blocks {
-
- complex_to_real::sptr complex_to_real::make(size_t vlen)
- {
- return gnuradio::get_initial_sptr(new complex_to_real_impl(vlen));
- }
-
- complex_to_real_impl::complex_to_real_impl(size_t vlen)
- : sync_block("complex_to_real",
- io_signature::make (1, 1, sizeof(gr_complex)*vlen),
- io_signature::make (1, 1, sizeof(float)*vlen)),
- d_vlen(vlen)
- {
- const int alignment_multiple =
- volk_get_alignment() / sizeof(float);
- set_alignment(std::max(1,alignment_multiple));
- }
-
- int
- complex_to_real_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- const gr_complex *in = (const gr_complex *) input_items[0];
- float *out = (float *) output_items[0];
- int noi = noutput_items * d_vlen;
-
- volk_32fc_deinterleave_real_32f(out, in, noi);
-
- return noutput_items;
- }
-
- } /* namespace blocks */
-}/* namespace gr */
+namespace blocks {
+
+complex_to_real::sptr complex_to_real::make(size_t vlen)
+{
+ return gnuradio::get_initial_sptr(new complex_to_real_impl(vlen));
+}
+
+complex_to_real_impl::complex_to_real_impl(size_t vlen)
+ : sync_block("complex_to_real",
+ io_signature::make(1, 1, sizeof(gr_complex) * vlen),
+ io_signature::make(1, 1, sizeof(float) * vlen)),
+ d_vlen(vlen)
+{
+ const int alignment_multiple = volk_get_alignment() / sizeof(float);
+ set_alignment(std::max(1, alignment_multiple));
+}
+
+int complex_to_real_impl::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ const gr_complex* in = (const gr_complex*)input_items[0];
+ float* out = (float*)output_items[0];
+ int noi = noutput_items * d_vlen;
+
+ volk_32fc_deinterleave_real_32f(out, in, noi);
+
+ return noutput_items;
+}
+
+} /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/complex_to_real_impl.h b/gr-blocks/lib/complex_to_real_impl.h
index e3c4dbaa19..27af7f766b 100644
--- a/gr-blocks/lib/complex_to_real_impl.h
+++ b/gr-blocks/lib/complex_to_real_impl.h
@@ -26,21 +26,21 @@
#include <gnuradio/blocks/complex_to_real.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class BLOCKS_API complex_to_real_impl : public complex_to_real
- {
- size_t d_vlen;
+class BLOCKS_API complex_to_real_impl : public complex_to_real
+{
+ size_t d_vlen;
- public:
- complex_to_real_impl(size_t vlen);
+public:
+ complex_to_real_impl(size_t vlen);
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/conjugate_cc_impl.cc b/gr-blocks/lib/conjugate_cc_impl.cc
index d16f9eb421..a8c9d79b77 100644
--- a/gr-blocks/lib/conjugate_cc_impl.cc
+++ b/gr-blocks/lib/conjugate_cc_impl.cc
@@ -29,35 +29,33 @@
#include <volk/volk.h>
namespace gr {
- namespace blocks {
-
- conjugate_cc::sptr conjugate_cc::make()
- {
- return gnuradio::get_initial_sptr(new conjugate_cc_impl());
- }
-
- conjugate_cc_impl::conjugate_cc_impl()
- : sync_block("conjugate_cc",
- io_signature::make (1, 1, sizeof(gr_complex)),
- io_signature::make (1, 1, sizeof(gr_complex)))
- {
- const int alignment_multiple =
- volk_get_alignment() / sizeof(gr_complex);
- set_alignment(std::max(1, alignment_multiple));
- }
-
- int
- conjugate_cc_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- gr_complex *iptr = (gr_complex *) input_items[0];
- gr_complex *optr = (gr_complex *) output_items[0];
-
- volk_32fc_conjugate_32fc(optr, iptr, noutput_items);
-
- return noutput_items;
- }
-
- } /* namespace blocks */
-}/* namespace gr */
+namespace blocks {
+
+conjugate_cc::sptr conjugate_cc::make()
+{
+ return gnuradio::get_initial_sptr(new conjugate_cc_impl());
+}
+
+conjugate_cc_impl::conjugate_cc_impl()
+ : sync_block("conjugate_cc",
+ io_signature::make(1, 1, sizeof(gr_complex)),
+ io_signature::make(1, 1, sizeof(gr_complex)))
+{
+ const int alignment_multiple = volk_get_alignment() / sizeof(gr_complex);
+ set_alignment(std::max(1, alignment_multiple));
+}
+
+int conjugate_cc_impl::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ gr_complex* iptr = (gr_complex*)input_items[0];
+ gr_complex* optr = (gr_complex*)output_items[0];
+
+ volk_32fc_conjugate_32fc(optr, iptr, noutput_items);
+
+ return noutput_items;
+}
+
+} /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/conjugate_cc_impl.h b/gr-blocks/lib/conjugate_cc_impl.h
index d3d0f9a0b7..4d35a22e69 100644
--- a/gr-blocks/lib/conjugate_cc_impl.h
+++ b/gr-blocks/lib/conjugate_cc_impl.h
@@ -26,19 +26,19 @@
#include <gnuradio/blocks/conjugate_cc.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class BLOCKS_API conjugate_cc_impl : public conjugate_cc
- {
- public:
- conjugate_cc_impl();
+class BLOCKS_API conjugate_cc_impl : public conjugate_cc
+{
+public:
+ conjugate_cc_impl();
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_CONJUGATE_CC_IMPL_H */
diff --git a/gr-blocks/lib/control_loop.cc b/gr-blocks/lib/control_loop.cc
index 30260b5646..c8bca8ef12 100644
--- a/gr-blocks/lib/control_loop.cc
+++ b/gr-blocks/lib/control_loop.cc
@@ -29,186 +29,133 @@
#include <stdexcept>
namespace gr {
- namespace blocks {
-
-#define M_TWOPI (2.0f*GR_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)
+namespace blocks {
+
+#define M_TWOPI (2.0f * GR_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)
+ while (d_phase < -M_TWOPI)
d_phase += M_TWOPI;
- }
+}
- void
- control_loop::frequency_limit()
- {
- if(d_freq > d_max_freq)
+void control_loop::frequency_limit()
+{
+ if (d_freq > d_max_freq)
d_freq = d_max_freq;
- else if(d_freq < d_min_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.");
- }
+/*******************************************************************
+ * SET FUNCTIONS
+ *******************************************************************/
- d_loop_bw = bw;
- update_gains();
+void control_loop::set_loop_bandwidth(float bw)
+{
+ if (bw < 0) {
+ throw std::out_of_range("control_loop: invalid bandwidth. Must be >= 0.");
}
- void
- control_loop::set_damping_factor(float df)
- {
- if(df <= 0) {
- throw std::out_of_range ("control_loop: invalid damping factor. Must be > 0.");
- }
+ d_loop_bw = bw;
+ update_gains();
+}
- d_damping = df;
- update_gains();
+void control_loop::set_damping_factor(float df)
+{
+ if (df <= 0) {
+ throw std::out_of_range("control_loop: invalid damping factor. Must be > 0.");
}
- 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;
+ 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_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)
+void control_loop::set_frequency(float freq)
+{
+ if (freq > d_max_freq)
d_freq = d_min_freq;
- else if(freq < d_min_freq)
+ else if (freq < d_min_freq)
d_freq = d_max_freq;
- else
+ else
d_freq = freq;
- }
+}
- void
- control_loop::set_phase(float phase)
- {
- d_phase = phase;
- while(d_phase>M_TWOPI)
+void control_loop::set_phase(float phase)
+{
+ d_phase = phase;
+ while (d_phase > M_TWOPI)
d_phase -= M_TWOPI;
- while(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_max_freq(float freq) { d_max_freq = freq; }
- void
- control_loop::set_min_freq(float freq)
- {
- d_min_freq = freq;
- }
+void control_loop::set_min_freq(float freq) { d_min_freq = freq; }
- /*******************************************************************
- * GET FUNCTIONS
- *******************************************************************/
+/*******************************************************************
+ * GET FUNCTIONS
+ *******************************************************************/
- float
- control_loop::get_loop_bandwidth() const
- {
- return d_loop_bw;
- }
+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_damping_factor() const { return d_damping; }
- float
- control_loop::get_alpha() const
- {
- return d_alpha;
- }
+float control_loop::get_alpha() const { return d_alpha; }
- float
- control_loop::get_beta() const
- {
- return d_beta;
- }
+float control_loop::get_beta() const { return d_beta; }
- float
- control_loop::get_frequency() const
- {
- return d_freq;
- }
+float control_loop::get_frequency() const { return d_freq; }
- float
- control_loop::get_phase() const
- {
- return d_phase;
- }
+float control_loop::get_phase() const { return d_phase; }
- float
- control_loop::get_max_freq() const
- {
- return d_max_freq;
- }
+float control_loop::get_max_freq() const { return d_max_freq; }
- float
- control_loop::get_min_freq() const
- {
- return d_min_freq;
- }
+float control_loop::get_min_freq() const { return d_min_freq; }
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/copy_impl.cc b/gr-blocks/lib/copy_impl.cc
index acac576075..c377e57b1e 100644
--- a/gr-blocks/lib/copy_impl.cc
+++ b/gr-blocks/lib/copy_impl.cc
@@ -29,88 +29,72 @@
#include <string.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- copy::sptr
- copy::make(size_t itemsize)
- {
- return gnuradio::get_initial_sptr
- (new copy_impl(itemsize));
- }
+copy::sptr copy::make(size_t itemsize)
+{
+ return gnuradio::get_initial_sptr(new copy_impl(itemsize));
+}
- copy_impl::copy_impl(size_t itemsize)
- : block("copy",
- io_signature::make(1, -1, itemsize),
- io_signature::make(1, -1, itemsize)),
- d_itemsize(itemsize),
- d_enabled(true)
- {
- message_port_register_in(pmt::mp("en"));
- set_msg_handler(pmt::mp("en"),
- boost::bind(&copy_impl::handle_enable, this, _1));
- }
+copy_impl::copy_impl(size_t itemsize)
+ : block("copy",
+ io_signature::make(1, -1, itemsize),
+ io_signature::make(1, -1, itemsize)),
+ d_itemsize(itemsize),
+ d_enabled(true)
+{
+ message_port_register_in(pmt::mp("en"));
+ set_msg_handler(pmt::mp("en"), boost::bind(&copy_impl::handle_enable, this, _1));
+}
- copy_impl::~copy_impl()
- {
- }
+copy_impl::~copy_impl() {}
- void
- copy_impl::handle_enable(pmt::pmt_t msg)
- {
- if(pmt::is_bool(msg)) {
+void copy_impl::handle_enable(pmt::pmt_t msg)
+{
+ if (pmt::is_bool(msg)) {
bool en = pmt::to_bool(msg);
d_enabled = en;
- }
}
+}
- 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;
- }
+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;
- }
+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 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 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);
+ 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;
}
+ consume_each(noutput_items);
+ return n;
+}
- void
- copy_impl::setup_rpc()
- {
+
+void copy_impl::setup_rpc()
+{
#ifdef GR_CTRLPORT
- add_rpc_variable(
- rpcbasic_sptr(new rpcbasic_register_handler<copy>(
- alias(), "en",
- "", "Enable",
- RPC_PRIVLVL_MIN, DISPNULL)));
+ add_rpc_variable(rpcbasic_sptr(new rpcbasic_register_handler<copy>(
+ alias(), "en", "", "Enable", RPC_PRIVLVL_MIN, DISPNULL)));
#endif /* GR_CTRLPORT */
- }
+}
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/copy_impl.h b/gr-blocks/lib/copy_impl.h
index ac7126749b..d49dd128f5 100644
--- a/gr-blocks/lib/copy_impl.h
+++ b/gr-blocks/lib/copy_impl.h
@@ -26,35 +26,35 @@
#include <gnuradio/blocks/copy.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class copy_impl : public copy
- {
- private:
- size_t d_itemsize;
- bool d_enabled;
+class copy_impl : public copy
+{
+private:
+ size_t d_itemsize;
+ bool d_enabled;
- public:
- copy_impl(size_t itemsize);
- ~copy_impl();
+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 forecast(int noutput_items, gr_vector_int& ninput_items_required);
+ bool check_topology(int ninputs, int noutputs);
- void handle_enable(pmt::pmt_t msg);
+ void handle_enable(pmt::pmt_t msg);
- void setup_rpc();
+ void setup_rpc();
- void set_enabled(bool enable) { d_enabled = enable; }
- bool enabled() const { return d_enabled;}
+ 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);
- };
+ 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 blocks */
} /* namespace gr */
#endif /* INCLUDED_GR_COPY_IMPL_H */
diff --git a/gr-blocks/lib/count_bits.cc b/gr-blocks/lib/count_bits.cc
index c65dc94894..aaab97b66a 100644
--- a/gr-blocks/lib/count_bits.cc
+++ b/gr-blocks/lib/count_bits.cc
@@ -29,50 +29,45 @@
*/
namespace gr {
- namespace blocks {
+namespace blocks {
- unsigned int
- count_bits8(unsigned int x)
- {
- int count = 0;
+unsigned int count_bits8(unsigned int x)
+{
+ int count = 0;
- for(int i = 0; i < 8; i++) {
- if(x & (1 << i))
- count++;
- }
-
- return count;
+ for (int i = 0; i < 8; i++) {
+ if (x & (1 << i))
+ count++;
}
- unsigned int
- count_bits16(unsigned int x)
- {
- int count = 0;
+ return count;
+}
- for(int i = 0; i < 16; i++) {
- if(x & (1 << i))
- count++;
- }
+unsigned int count_bits16(unsigned int x)
+{
+ int count = 0;
- return count;
+ for (int i = 0; i < 16; i++) {
+ if (x & (1 << i))
+ count++;
}
- unsigned int
- count_bits32(unsigned int x)
- {
- unsigned res = (x & 0x55555555) + ((x >> 1) & 0x55555555);
- res = (res & 0x33333333) + ((res >> 2) & 0x33333333);
- res = (res & 0x0F0F0F0F) + ((res >> 4) & 0x0F0F0F0F);
- res = (res & 0x00FF00FF) + ((res >> 8) & 0x00FF00FF);
- return (res & 0x0000FFFF) + ((res >> 16) & 0x0000FFFF);
- }
+ return count;
+}
- unsigned int
- count_bits64(unsigned long long x)
- {
- return count_bits32((x >> 32) & 0xffffffff) + \
- count_bits32(x & 0xffffffff);
- }
+unsigned int count_bits32(unsigned int x)
+{
+ unsigned res = (x & 0x55555555) + ((x >> 1) & 0x55555555);
+ res = (res & 0x33333333) + ((res >> 2) & 0x33333333);
+ res = (res & 0x0F0F0F0F) + ((res >> 4) & 0x0F0F0F0F);
+ res = (res & 0x00FF00FF) + ((res >> 8) & 0x00FF00FF);
+ return (res & 0x0000FFFF) + ((res >> 16) & 0x0000FFFF);
+}
+
+unsigned int count_bits64(unsigned long long x)
+{
+ return count_bits32((x >> 32) & 0xffffffff) + count_bits32(x & 0xffffffff);
+}
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/ctrlport_probe2_b_impl.cc b/gr-blocks/lib/ctrlport_probe2_b_impl.cc
index 996e997d96..b5c9532658 100644
--- a/gr-blocks/lib/ctrlport_probe2_b_impl.cc
+++ b/gr-blocks/lib/ctrlport_probe2_b_impl.cc
@@ -28,122 +28,132 @@
#include <gnuradio/io_signature.h>
namespace gr {
- namespace blocks {
-
- ctrlport_probe2_b::sptr
- ctrlport_probe2_b::make(const std::string &id, const std::string &desc,
- int len, unsigned int disp_mask)
- {
- return gnuradio::get_initial_sptr
- (new ctrlport_probe2_b_impl(id, desc, len, disp_mask));
- }
-
- ctrlport_probe2_b_impl::ctrlport_probe2_b_impl(const std::string &id,
- const std::string &desc,
- int len, unsigned int disp_mask)
+namespace blocks {
+
+ctrlport_probe2_b::sptr ctrlport_probe2_b::make(const std::string& id,
+ const std::string& desc,
+ int len,
+ unsigned int disp_mask)
+{
+ return gnuradio::get_initial_sptr(
+ new ctrlport_probe2_b_impl(id, desc, len, disp_mask));
+}
+
+ctrlport_probe2_b_impl::ctrlport_probe2_b_impl(const std::string& id,
+ const std::string& desc,
+ int len,
+ unsigned int disp_mask)
: sync_block("probe2_b",
io_signature::make(1, 1, sizeof(char)),
io_signature::make(0, 0, 0)),
- d_id(id), d_desc(desc), d_len(len), d_disp_mask(disp_mask)
- {
- set_length(len);
- }
-
- ctrlport_probe2_b_impl::~ctrlport_probe2_b_impl()
- {
- }
-
- void
- ctrlport_probe2_b_impl::forecast(int noutput_items,
- gr_vector_int &ninput_items_required)
- {
- // make sure all inputs have noutput_items available
- unsigned ninputs = ninput_items_required.size();
- for(unsigned i = 0; i < ninputs; i++)
+ d_id(id),
+ d_desc(desc),
+ d_len(len),
+ d_disp_mask(disp_mask)
+{
+ set_length(len);
+}
+
+ctrlport_probe2_b_impl::~ctrlport_probe2_b_impl() {}
+
+void ctrlport_probe2_b_impl::forecast(int noutput_items,
+ gr_vector_int& ninput_items_required)
+{
+ // make sure all inputs have noutput_items available
+ unsigned ninputs = ninput_items_required.size();
+ for (unsigned i = 0; i < ninputs; i++)
ninput_items_required[i] = d_len;
- }
+}
- std::vector<signed char>
- ctrlport_probe2_b_impl::get()
- {
- return buffered_get.get();
- }
+std::vector<signed char> ctrlport_probe2_b_impl::get() { return buffered_get.get(); }
- void
- ctrlport_probe2_b_impl::set_length(int len)
- {
- gr::thread::scoped_lock guard(d_setlock);
+void ctrlport_probe2_b_impl::set_length(int len)
+{
+ gr::thread::scoped_lock guard(d_setlock);
- if(len > 8191) {
+ if (len > 8191) {
GR_LOG_WARN(d_logger,
boost::format("probe2_b: length %1% exceeds maximum"
- " buffer size of 8191") % len);
+ " buffer size of 8191") %
+ len);
len = 8191;
- }
-
- d_len = len;
- d_buffer.resize(d_len);
- d_index = 0;
}
- int
- ctrlport_probe2_b_impl::length() const
- {
- return (int)d_len;
- }
+ d_len = len;
+ d_buffer.resize(d_len);
+ d_index = 0;
+}
- int
- ctrlport_probe2_b_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];
+int ctrlport_probe2_b_impl::length() const { return (int)d_len; }
- gr::thread::scoped_lock guard(d_setlock);
+int ctrlport_probe2_b_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];
- // copy samples to get buffer if we need samples
- if(d_index < d_len) {
+ gr::thread::scoped_lock guard(d_setlock);
+
+ // copy samples to get buffer if we need samples
+ if (d_index < d_len) {
// copy smaller of remaining buffer space and num inputs to work()
- int num_copy = std::min( (int)(d_len - d_index), noutput_items );
+ int num_copy = std::min((int)(d_len - d_index), noutput_items);
- memcpy(&d_buffer[d_index], in, num_copy*sizeof(char));
+ memcpy(&d_buffer[d_index], in, num_copy * sizeof(char));
d_index += num_copy;
- }
+ }
- // notify the waiting get() if we fill up the buffer
- if(d_index == d_len) {
+ // notify the waiting get() if we fill up the buffer
+ if (d_index == d_len) {
buffered_get.offer_data(d_buffer);
d_index = 0;
- }
-
- return noutput_items;
}
- void
- ctrlport_probe2_b_impl::setup_rpc()
- {
+ return noutput_items;
+}
+
+void ctrlport_probe2_b_impl::setup_rpc()
+{
#ifdef GR_CTRLPORT
- int len = static_cast<int>(d_len);
- d_rpc_vars.push_back(
- rpcbasic_sptr(new rpcbasic_register_get<ctrlport_probe2_b, std::vector<signed char> >(
- alias(), d_id.c_str(), &ctrlport_probe2_b::get,
- pmt::mp(-128), pmt::mp(127), pmt::mp(0),
- "volts", d_desc.c_str(), RPC_PRIVLVL_MIN,
- d_disp_mask)));
-
- d_rpc_vars.push_back(
- rpcbasic_sptr(new rpcbasic_register_get<ctrlport_probe2_b, int>(
- alias(), "length", &ctrlport_probe2_b::length,
- pmt::mp(1), pmt::mp(10*len), pmt::mp(len),
- "samples", "get vector length", RPC_PRIVLVL_MIN, DISPNULL)));
-
- d_rpc_vars.push_back(
- rpcbasic_sptr(new rpcbasic_register_set<ctrlport_probe2_b, int>(
- alias(), "length", &ctrlport_probe2_b::set_length,
- pmt::mp(1), pmt::mp(10*len), pmt::mp(len),
- "samples", "set vector length", RPC_PRIVLVL_MIN, DISPNULL)));
+ int len = static_cast<int>(d_len);
+ d_rpc_vars.push_back(rpcbasic_sptr(
+ new rpcbasic_register_get<ctrlport_probe2_b, std::vector<signed char>>(
+ alias(),
+ d_id.c_str(),
+ &ctrlport_probe2_b::get,
+ pmt::mp(-128),
+ pmt::mp(127),
+ pmt::mp(0),
+ "volts",
+ d_desc.c_str(),
+ RPC_PRIVLVL_MIN,
+ d_disp_mask)));
+
+ d_rpc_vars.push_back(rpcbasic_sptr(
+ new rpcbasic_register_get<ctrlport_probe2_b, int>(alias(),
+ "length",
+ &ctrlport_probe2_b::length,
+ pmt::mp(1),
+ pmt::mp(10 * len),
+ pmt::mp(len),
+ "samples",
+ "get vector length",
+ RPC_PRIVLVL_MIN,
+ DISPNULL)));
+
+ d_rpc_vars.push_back(rpcbasic_sptr(
+ new rpcbasic_register_set<ctrlport_probe2_b, int>(alias(),
+ "length",
+ &ctrlport_probe2_b::set_length,
+ pmt::mp(1),
+ pmt::mp(10 * len),
+ pmt::mp(len),
+ "samples",
+ "set vector length",
+ RPC_PRIVLVL_MIN,
+ DISPNULL)));
#endif /* GR_CTRLPORT */
- }
+}
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/ctrlport_probe2_b_impl.h b/gr-blocks/lib/ctrlport_probe2_b_impl.h
index 165f0d33db..8a5f7952c8 100644
--- a/gr-blocks/lib/ctrlport_probe2_b_impl.h
+++ b/gr-blocks/lib/ctrlport_probe2_b_impl.h
@@ -28,40 +28,42 @@
#include <gnuradio/rpcbufferedget.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class ctrlport_probe2_b_impl : public ctrlport_probe2_b
- {
- private:
- std::string d_id;
- std::string d_desc;
- size_t d_len;
- unsigned int d_disp_mask;
+class ctrlport_probe2_b_impl : public ctrlport_probe2_b
+{
+private:
+ std::string d_id;
+ std::string d_desc;
+ size_t d_len;
+ unsigned int d_disp_mask;
- size_t d_index;
- std::vector<signed char> d_buffer;
- rpcbufferedget< std::vector<signed char> > buffered_get;
+ size_t d_index;
+ std::vector<signed char> d_buffer;
+ rpcbufferedget<std::vector<signed char>> buffered_get;
- public:
- ctrlport_probe2_b_impl(const std::string &id, const std::string &desc,
- int len, unsigned int disp_mask);
- ~ctrlport_probe2_b_impl();
+public:
+ ctrlport_probe2_b_impl(const std::string& id,
+ const std::string& desc,
+ int len,
+ unsigned int disp_mask);
+ ~ctrlport_probe2_b_impl();
- void setup_rpc();
+ void setup_rpc();
- void forecast(int noutput_items, gr_vector_int &ninput_items_required);
+ void forecast(int noutput_items, gr_vector_int& ninput_items_required);
- std::vector<signed char> get();
+ std::vector<signed char> get();
- void set_length(int len);
- int length() const;
+ void set_length(int len);
+ int length() const;
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_CTRLPORT_PROBE2_C_IMPL_H */
diff --git a/gr-blocks/lib/ctrlport_probe2_c_impl.cc b/gr-blocks/lib/ctrlport_probe2_c_impl.cc
index b8ed0af444..b1b8233f2d 100644
--- a/gr-blocks/lib/ctrlport_probe2_c_impl.cc
+++ b/gr-blocks/lib/ctrlport_probe2_c_impl.cc
@@ -28,123 +28,132 @@
#include <gnuradio/io_signature.h>
namespace gr {
- namespace blocks {
-
- ctrlport_probe2_c::sptr
- ctrlport_probe2_c::make(const std::string &id,
- const std::string &desc,
- int len, unsigned int disp_mask)
- {
- return gnuradio::get_initial_sptr
- (new ctrlport_probe2_c_impl(id, desc, len, disp_mask));
- }
-
- ctrlport_probe2_c_impl::ctrlport_probe2_c_impl(const std::string &id,
- const std::string &desc,
- int len, unsigned int disp_mask)
- : sync_block("probe2_c",
- io_signature::make(1, 1, sizeof(gr_complex)),
- io_signature::make(0, 0, 0)),
- d_id(id), d_desc(desc), d_len(len), d_disp_mask(disp_mask)
- {
- set_length(len);
- }
-
- ctrlport_probe2_c_impl::~ctrlport_probe2_c_impl()
- {
- }
-
- void
- ctrlport_probe2_c_impl::forecast(int noutput_items,
- gr_vector_int &ninput_items_required)
- {
- // make sure all inputs have noutput_items available
- unsigned ninputs = ninput_items_required.size();
- for(unsigned i = 0; i < ninputs; i++)
+namespace blocks {
+
+ctrlport_probe2_c::sptr ctrlport_probe2_c::make(const std::string& id,
+ const std::string& desc,
+ int len,
+ unsigned int disp_mask)
+{
+ return gnuradio::get_initial_sptr(
+ new ctrlport_probe2_c_impl(id, desc, len, disp_mask));
+}
+
+ctrlport_probe2_c_impl::ctrlport_probe2_c_impl(const std::string& id,
+ const std::string& desc,
+ int len,
+ unsigned int disp_mask)
+ : sync_block("probe2_c",
+ io_signature::make(1, 1, sizeof(gr_complex)),
+ io_signature::make(0, 0, 0)),
+ d_id(id),
+ d_desc(desc),
+ d_len(len),
+ d_disp_mask(disp_mask)
+{
+ set_length(len);
+}
+
+ctrlport_probe2_c_impl::~ctrlport_probe2_c_impl() {}
+
+void ctrlport_probe2_c_impl::forecast(int noutput_items,
+ gr_vector_int& ninput_items_required)
+{
+ // make sure all inputs have noutput_items available
+ unsigned ninputs = ninput_items_required.size();
+ for (unsigned i = 0; i < ninputs; i++)
ninput_items_required[i] = d_len;
- }
+}
- std::vector<gr_complex>
- ctrlport_probe2_c_impl::get()
- {
- return buffered_get.get();
- }
+std::vector<gr_complex> ctrlport_probe2_c_impl::get() { return buffered_get.get(); }
- void
- ctrlport_probe2_c_impl::set_length(int len)
- {
- gr::thread::scoped_lock guard(d_setlock);
+void ctrlport_probe2_c_impl::set_length(int len)
+{
+ gr::thread::scoped_lock guard(d_setlock);
- if(len > 8191) {
+ if (len > 8191) {
GR_LOG_WARN(d_logger,
boost::format("probe2_c: length %1% exceeds maximum"
- " buffer size of 8191") % len);
+ " buffer size of 8191") %
+ len);
len = 8191;
- }
-
- d_len = len;
- d_buffer.resize(d_len);
- d_index = 0;
}
- int
- ctrlport_probe2_c_impl::length() const
- {
- return (int)d_len;
- }
+ d_len = len;
+ d_buffer.resize(d_len);
+ d_index = 0;
+}
- int
- ctrlport_probe2_c_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- const gr_complex *in = (const gr_complex*)input_items[0];
+int ctrlport_probe2_c_impl::length() const { return (int)d_len; }
- gr::thread::scoped_lock guard(d_setlock);
+int ctrlport_probe2_c_impl::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ const gr_complex* in = (const gr_complex*)input_items[0];
- // copy samples to get buffer if we need samples
- if(d_index < d_len) {
+ gr::thread::scoped_lock guard(d_setlock);
+
+ // copy samples to get buffer if we need samples
+ if (d_index < d_len) {
// copy smaller of remaining buffer space and num inputs to work()
- int num_copy = std::min( (int)(d_len - d_index), noutput_items );
+ int num_copy = std::min((int)(d_len - d_index), noutput_items);
- memcpy(&d_buffer[d_index], in, num_copy*sizeof(gr_complex));
+ memcpy(&d_buffer[d_index], in, num_copy * sizeof(gr_complex));
d_index += num_copy;
- }
+ }
- // notify the waiting get() if we fill up the buffer
- if(d_index == d_len) {
+ // notify the waiting get() if we fill up the buffer
+ if (d_index == d_len) {
buffered_get.offer_data(d_buffer);
d_index = 0;
- }
-
- return noutput_items;
}
- void
- ctrlport_probe2_c_impl::setup_rpc()
- {
+ return noutput_items;
+}
+
+void ctrlport_probe2_c_impl::setup_rpc()
+{
#ifdef GR_CTRLPORT
- int len = static_cast<int>(d_len);
- d_rpc_vars.push_back(
- rpcbasic_sptr(new rpcbasic_register_get<ctrlport_probe2_c, std::vector<std::complex<float> > >(
- alias(), d_id.c_str(), &ctrlport_probe2_c::get,
- pmt::mp(-2), pmt::mp(2), pmt::mp(0),
- "volts", d_desc.c_str(), RPC_PRIVLVL_MIN,
- d_disp_mask | DISPOPTCPLX)));
-
- d_rpc_vars.push_back(
- rpcbasic_sptr(new rpcbasic_register_get<ctrlport_probe2_c, int>(
- alias(), "length", &ctrlport_probe2_c::length,
- pmt::mp(1), pmt::mp(10*len), pmt::mp(len),
- "samples", "get vector length", RPC_PRIVLVL_MIN, DISPNULL)));
-
- d_rpc_vars.push_back(
- rpcbasic_sptr(new rpcbasic_register_set<ctrlport_probe2_c, int>(
- alias(), "length", &ctrlport_probe2_c::set_length,
- pmt::mp(1), pmt::mp(10*len), pmt::mp(len),
- "samples", "set vector length", RPC_PRIVLVL_MIN, DISPNULL)));
+ int len = static_cast<int>(d_len);
+ d_rpc_vars.push_back(rpcbasic_sptr(
+ new rpcbasic_register_get<ctrlport_probe2_c, std::vector<std::complex<float>>>(
+ alias(),
+ d_id.c_str(),
+ &ctrlport_probe2_c::get,
+ pmt::mp(-2),
+ pmt::mp(2),
+ pmt::mp(0),
+ "volts",
+ d_desc.c_str(),
+ RPC_PRIVLVL_MIN,
+ d_disp_mask | DISPOPTCPLX)));
+
+ d_rpc_vars.push_back(rpcbasic_sptr(
+ new rpcbasic_register_get<ctrlport_probe2_c, int>(alias(),
+ "length",
+ &ctrlport_probe2_c::length,
+ pmt::mp(1),
+ pmt::mp(10 * len),
+ pmt::mp(len),
+ "samples",
+ "get vector length",
+ RPC_PRIVLVL_MIN,
+ DISPNULL)));
+
+ d_rpc_vars.push_back(rpcbasic_sptr(
+ new rpcbasic_register_set<ctrlport_probe2_c, int>(alias(),
+ "length",
+ &ctrlport_probe2_c::set_length,
+ pmt::mp(1),
+ pmt::mp(10 * len),
+ pmt::mp(len),
+ "samples",
+ "set vector length",
+ RPC_PRIVLVL_MIN,
+ DISPNULL)));
#endif /* GR_CTRLPORT */
- }
+}
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/ctrlport_probe2_c_impl.h b/gr-blocks/lib/ctrlport_probe2_c_impl.h
index 119738a481..63d7629e26 100644
--- a/gr-blocks/lib/ctrlport_probe2_c_impl.h
+++ b/gr-blocks/lib/ctrlport_probe2_c_impl.h
@@ -28,40 +28,42 @@
#include <gnuradio/rpcbufferedget.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class ctrlport_probe2_c_impl : public ctrlport_probe2_c
- {
- private:
- std::string d_id;
- std::string d_desc;
- size_t d_len;
- unsigned int d_disp_mask;
+class ctrlport_probe2_c_impl : public ctrlport_probe2_c
+{
+private:
+ std::string d_id;
+ std::string d_desc;
+ size_t d_len;
+ unsigned int d_disp_mask;
- size_t d_index;
- std::vector<gr_complex> d_buffer;
- rpcbufferedget< std::vector<gr_complex> > buffered_get;
+ size_t d_index;
+ std::vector<gr_complex> d_buffer;
+ rpcbufferedget<std::vector<gr_complex>> buffered_get;
- public:
- ctrlport_probe2_c_impl(const std::string &id, const std::string &desc,
- int len, unsigned int disp_mask);
- ~ctrlport_probe2_c_impl();
+public:
+ ctrlport_probe2_c_impl(const std::string& id,
+ const std::string& desc,
+ int len,
+ unsigned int disp_mask);
+ ~ctrlport_probe2_c_impl();
- void setup_rpc();
+ void setup_rpc();
- void forecast(int noutput_items, gr_vector_int &ninput_items_required);
+ void forecast(int noutput_items, gr_vector_int& ninput_items_required);
- std::vector<gr_complex> get();
+ std::vector<gr_complex> get();
- void set_length(int len);
- int length() const;
+ void set_length(int len);
+ int length() const;
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_CTRLPORT_PROBE2_C_IMPL_H */
diff --git a/gr-blocks/lib/ctrlport_probe2_f_impl.cc b/gr-blocks/lib/ctrlport_probe2_f_impl.cc
index ff37401e88..d373c23770 100644
--- a/gr-blocks/lib/ctrlport_probe2_f_impl.cc
+++ b/gr-blocks/lib/ctrlport_probe2_f_impl.cc
@@ -28,124 +28,135 @@
#include <gnuradio/io_signature.h>
namespace gr {
- namespace blocks {
-
- ctrlport_probe2_f::sptr
- ctrlport_probe2_f::make(const std::string &id, const std::string &desc,
- int len, unsigned int disp_mask)
- {
- return gnuradio::get_initial_sptr
- (new ctrlport_probe2_f_impl(id, desc, len, disp_mask));
- }
-
- ctrlport_probe2_f_impl::ctrlport_probe2_f_impl(const std::string &id, const std::string &desc,
- int len, unsigned int disp_mask)
+namespace blocks {
+
+ctrlport_probe2_f::sptr ctrlport_probe2_f::make(const std::string& id,
+ const std::string& desc,
+ int len,
+ unsigned int disp_mask)
+{
+ return gnuradio::get_initial_sptr(
+ new ctrlport_probe2_f_impl(id, desc, len, disp_mask));
+}
+
+ctrlport_probe2_f_impl::ctrlport_probe2_f_impl(const std::string& id,
+ const std::string& desc,
+ int len,
+ unsigned int disp_mask)
: sync_block("probe2_f",
io_signature::make(1, 1, sizeof(float)),
io_signature::make(0, 0, 0)),
- d_id(id), d_desc(desc), d_len(len), d_disp_mask(disp_mask)
- {
- set_length(len);
- }
-
- ctrlport_probe2_f_impl::~ctrlport_probe2_f_impl()
- {
- }
-
- void
- ctrlport_probe2_f_impl::forecast(int noutput_items,
- gr_vector_int &ninput_items_required)
- {
- // make sure all inputs have noutput_items available
- unsigned ninputs = ninput_items_required.size();
- for(unsigned i = 0; i < ninputs; i++)
+ d_id(id),
+ d_desc(desc),
+ d_len(len),
+ d_disp_mask(disp_mask)
+{
+ set_length(len);
+}
+
+ctrlport_probe2_f_impl::~ctrlport_probe2_f_impl() {}
+
+void ctrlport_probe2_f_impl::forecast(int noutput_items,
+ gr_vector_int& ninput_items_required)
+{
+ // make sure all inputs have noutput_items available
+ unsigned ninputs = ninput_items_required.size();
+ for (unsigned i = 0; i < ninputs; i++)
ninput_items_required[i] = d_len;
- }
+}
- std::vector<float>
- ctrlport_probe2_f_impl::get()
- {
- return buffered_get.get();
- }
+std::vector<float> ctrlport_probe2_f_impl::get() { return buffered_get.get(); }
- void
- ctrlport_probe2_f_impl::set_length(int len)
- {
- gr::thread::scoped_lock guard(d_setlock);
+void ctrlport_probe2_f_impl::set_length(int len)
+{
+ gr::thread::scoped_lock guard(d_setlock);
- if(len > 8191) {
+ if (len > 8191) {
GR_LOG_WARN(d_logger,
boost::format("probe2_f: length %1% exceeds maximum"
- " buffer size of 8191") % len);
+ " buffer size of 8191") %
+ len);
len = 8191;
- }
-
- d_len = len;
- d_buffer.resize(d_len);
- d_index = 0;
}
- int
- ctrlport_probe2_f_impl::length() const
- {
- return (int)d_len;
- }
+ d_len = len;
+ d_buffer.resize(d_len);
+ d_index = 0;
+}
- int
- ctrlport_probe2_f_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];
+int ctrlport_probe2_f_impl::length() const { return (int)d_len; }
- gr::thread::scoped_lock guard(d_setlock);
+int ctrlport_probe2_f_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];
- // copy samples to get buffer if we need samples
- if(d_index < d_len) {
+ gr::thread::scoped_lock guard(d_setlock);
+
+ // copy samples to get buffer if we need samples
+ if (d_index < d_len) {
// copy smaller of remaining buffer space and num inputs to work()
- int num_copy = std::min( (int)(d_len - d_index), noutput_items );
+ int num_copy = std::min((int)(d_len - d_index), noutput_items);
- memcpy(&d_buffer[d_index], in, num_copy*sizeof(float));
+ memcpy(&d_buffer[d_index], in, num_copy * sizeof(float));
d_index += num_copy;
- }
+ }
- // notify the waiting get() if we fill up the buffer
- if(d_index == d_len) {
+ // notify the waiting get() if we fill up the buffer
+ if (d_index == d_len) {
buffered_get.offer_data(d_buffer);
d_index = 0;
- }
-
- return noutput_items;
}
- void
- ctrlport_probe2_f_impl::setup_rpc()
- {
+ return noutput_items;
+}
+
+void ctrlport_probe2_f_impl::setup_rpc()
+{
#ifdef GR_CTRLPORT
- int len = static_cast<int>(d_len);
- d_rpc_vars.push_back(
- rpcbasic_sptr(new rpcbasic_register_get<ctrlport_probe2_f, std::vector<float> >(
- alias(), d_id.c_str(), &ctrlport_probe2_f::get,
- pmt::mp(-2.0f), pmt::mp(2.0f), pmt::mp(0.0f),
-// pmt::make_f32vector(1,-2),
-// pmt::make_f32vector(1,2),
-// pmt::make_f32vector(1,0),
- "volts", d_desc.c_str(), RPC_PRIVLVL_MIN,
- d_disp_mask)));
-
- d_rpc_vars.push_back(
- rpcbasic_sptr(new rpcbasic_register_get<ctrlport_probe2_f, int>(
- alias(), "length", &ctrlport_probe2_f::length,
- pmt::mp(1), pmt::mp(10*len), pmt::mp(len),
- "samples", "get vector length", RPC_PRIVLVL_MIN, DISPNULL)));
-
- d_rpc_vars.push_back(
- rpcbasic_sptr(new rpcbasic_register_set<ctrlport_probe2_f, int>(
- alias(), "length", &ctrlport_probe2_f::set_length,
- pmt::mp(1), pmt::mp(10*len), pmt::mp(len),
- "samples", "set vector length", RPC_PRIVLVL_MIN, DISPNULL)));
+ int len = static_cast<int>(d_len);
+ d_rpc_vars.push_back(
+ rpcbasic_sptr(new rpcbasic_register_get<ctrlport_probe2_f, std::vector<float>>(
+ alias(),
+ d_id.c_str(),
+ &ctrlport_probe2_f::get,
+ pmt::mp(-2.0f),
+ pmt::mp(2.0f),
+ pmt::mp(0.0f),
+ // pmt::make_f32vector(1,-2),
+ // pmt::make_f32vector(1,2),
+ // pmt::make_f32vector(1,0),
+ "volts",
+ d_desc.c_str(),
+ RPC_PRIVLVL_MIN,
+ d_disp_mask)));
+
+ d_rpc_vars.push_back(rpcbasic_sptr(
+ new rpcbasic_register_get<ctrlport_probe2_f, int>(alias(),
+ "length",
+ &ctrlport_probe2_f::length,
+ pmt::mp(1),
+ pmt::mp(10 * len),
+ pmt::mp(len),
+ "samples",
+ "get vector length",
+ RPC_PRIVLVL_MIN,
+ DISPNULL)));
+
+ d_rpc_vars.push_back(rpcbasic_sptr(
+ new rpcbasic_register_set<ctrlport_probe2_f, int>(alias(),
+ "length",
+ &ctrlport_probe2_f::set_length,
+ pmt::mp(1),
+ pmt::mp(10 * len),
+ pmt::mp(len),
+ "samples",
+ "set vector length",
+ RPC_PRIVLVL_MIN,
+ DISPNULL)));
#endif /* GR_CTRLPORT */
- }
+}
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/ctrlport_probe2_f_impl.h b/gr-blocks/lib/ctrlport_probe2_f_impl.h
index 6aec0789f4..81c79e4d36 100644
--- a/gr-blocks/lib/ctrlport_probe2_f_impl.h
+++ b/gr-blocks/lib/ctrlport_probe2_f_impl.h
@@ -28,40 +28,42 @@
#include <gnuradio/rpcbufferedget.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class ctrlport_probe2_f_impl : public ctrlport_probe2_f
- {
- private:
- std::string d_id;
- std::string d_desc;
- size_t d_len;
- unsigned int d_disp_mask;
+class ctrlport_probe2_f_impl : public ctrlport_probe2_f
+{
+private:
+ std::string d_id;
+ std::string d_desc;
+ size_t d_len;
+ unsigned int d_disp_mask;
- size_t d_index;
- std::vector<float> d_buffer;
- rpcbufferedget< std::vector<float> > buffered_get;
+ size_t d_index;
+ std::vector<float> d_buffer;
+ rpcbufferedget<std::vector<float>> buffered_get;
- public:
- ctrlport_probe2_f_impl(const std::string &id, const std::string &desc,
- int len, unsigned int disp_mask);
- ~ctrlport_probe2_f_impl();
+public:
+ ctrlport_probe2_f_impl(const std::string& id,
+ const std::string& desc,
+ int len,
+ unsigned int disp_mask);
+ ~ctrlport_probe2_f_impl();
- void setup_rpc();
+ void setup_rpc();
- void forecast(int noutput_items, gr_vector_int &ninput_items_required);
+ void forecast(int noutput_items, gr_vector_int& ninput_items_required);
- std::vector<float> get();
+ std::vector<float> get();
- void set_length(int len);
- int length() const;
+ void set_length(int len);
+ int length() const;
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_CTRLPORT_PROBE2_F_IMPL_H */
diff --git a/gr-blocks/lib/ctrlport_probe2_i_impl.cc b/gr-blocks/lib/ctrlport_probe2_i_impl.cc
index 7e17d8e8fe..d52f1762b0 100644
--- a/gr-blocks/lib/ctrlport_probe2_i_impl.cc
+++ b/gr-blocks/lib/ctrlport_probe2_i_impl.cc
@@ -28,123 +28,131 @@
#include <gnuradio/io_signature.h>
namespace gr {
- namespace blocks {
-
- ctrlport_probe2_i::sptr
- ctrlport_probe2_i::make(const std::string &id,
- const std::string &desc,
- int len, unsigned int disp_mask)
- {
- return gnuradio::get_initial_sptr
- (new ctrlport_probe2_i_impl(id, desc, len, disp_mask));
- }
-
- ctrlport_probe2_i_impl::ctrlport_probe2_i_impl(const std::string &id,
- const std::string &desc,
- int len, unsigned int disp_mask)
- : sync_block("probe2_i",
- io_signature::make(1, 1, sizeof(int)),
- io_signature::make(0, 0, 0)),
- d_id(id), d_desc(desc), d_len(len), d_disp_mask(disp_mask)
- {
- set_length(len);
- }
-
- ctrlport_probe2_i_impl::~ctrlport_probe2_i_impl()
- {
- }
-
- void
- ctrlport_probe2_i_impl::forecast(int noutput_items,
- gr_vector_int &ninput_items_required)
- {
- // make sure all inputs have noutput_items available
- unsigned ninputs = ninput_items_required.size();
- for(unsigned i = 0; i < ninputs; i++)
+namespace blocks {
+
+ctrlport_probe2_i::sptr ctrlport_probe2_i::make(const std::string& id,
+ const std::string& desc,
+ int len,
+ unsigned int disp_mask)
+{
+ return gnuradio::get_initial_sptr(
+ new ctrlport_probe2_i_impl(id, desc, len, disp_mask));
+}
+
+ctrlport_probe2_i_impl::ctrlport_probe2_i_impl(const std::string& id,
+ const std::string& desc,
+ int len,
+ unsigned int disp_mask)
+ : sync_block(
+ "probe2_i", io_signature::make(1, 1, sizeof(int)), io_signature::make(0, 0, 0)),
+ d_id(id),
+ d_desc(desc),
+ d_len(len),
+ d_disp_mask(disp_mask)
+{
+ set_length(len);
+}
+
+ctrlport_probe2_i_impl::~ctrlport_probe2_i_impl() {}
+
+void ctrlport_probe2_i_impl::forecast(int noutput_items,
+ gr_vector_int& ninput_items_required)
+{
+ // make sure all inputs have noutput_items available
+ unsigned ninputs = ninput_items_required.size();
+ for (unsigned i = 0; i < ninputs; i++)
ninput_items_required[i] = d_len;
- }
+}
- std::vector<int>
- ctrlport_probe2_i_impl::get()
- {
- return buffered_get.get();
- }
+std::vector<int> ctrlport_probe2_i_impl::get() { return buffered_get.get(); }
- void
- ctrlport_probe2_i_impl::set_length(int len)
- {
- gr::thread::scoped_lock guard(d_setlock);
+void ctrlport_probe2_i_impl::set_length(int len)
+{
+ gr::thread::scoped_lock guard(d_setlock);
- if(len > 8191) {
+ if (len > 8191) {
GR_LOG_WARN(d_logger,
boost::format("probe2_i: length %1% exceeds maximum"
- " buffer size of 8191") % len);
+ " buffer size of 8191") %
+ len);
len = 8191;
- }
-
- d_len = len;
- d_buffer.resize(d_len);
- d_index = 0;
}
- int
- ctrlport_probe2_i_impl::length() const
- {
- return (int)d_len;
- }
+ d_len = len;
+ d_buffer.resize(d_len);
+ d_index = 0;
+}
- int
- ctrlport_probe2_i_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- const int *in = (const int*)input_items[0];
+int ctrlport_probe2_i_impl::length() const { return (int)d_len; }
- gr::thread::scoped_lock guard(d_setlock);
+int ctrlport_probe2_i_impl::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ const int* in = (const int*)input_items[0];
- // copy samples to get buffer if we need samples
- if(d_index < d_len) {
+ gr::thread::scoped_lock guard(d_setlock);
+
+ // copy samples to get buffer if we need samples
+ if (d_index < d_len) {
// copy smaller of remaining buffer space and num inputs to work()
- int num_copy = std::min( (int)(d_len - d_index), noutput_items );
+ int num_copy = std::min((int)(d_len - d_index), noutput_items);
- memcpy(&d_buffer[d_index], in, num_copy*sizeof(int));
+ memcpy(&d_buffer[d_index], in, num_copy * sizeof(int));
d_index += num_copy;
- }
+ }
- // notify the waiting get() if we fill up the buffer
- if(d_index == d_len) {
+ // notify the waiting get() if we fill up the buffer
+ if (d_index == d_len) {
buffered_get.offer_data(d_buffer);
d_index = 0;
- }
-
- return noutput_items;
}
- void
- ctrlport_probe2_i_impl::setup_rpc()
- {
+ return noutput_items;
+}
+
+void ctrlport_probe2_i_impl::setup_rpc()
+{
#ifdef GR_CTRLPORT
- int len = static_cast<int>(d_len);
- d_rpc_vars.push_back(
- rpcbasic_sptr(new rpcbasic_register_get<ctrlport_probe2_i, std::vector<int> >(
- alias(), d_id.c_str(), &ctrlport_probe2_i::get,
- pmt::mp(-32768), pmt::mp(32767), pmt::mp(0),
- "volts", d_desc.c_str(), RPC_PRIVLVL_MIN,
- d_disp_mask)));
-
- d_rpc_vars.push_back(
- rpcbasic_sptr(new rpcbasic_register_get<ctrlport_probe2_i, int>(
- alias(), "length", &ctrlport_probe2_i::length,
- pmt::mp(1), pmt::mp(10*len), pmt::mp(len),
- "samples", "get vector length", RPC_PRIVLVL_MIN, DISPNULL)));
-
- d_rpc_vars.push_back(
- rpcbasic_sptr(new rpcbasic_register_set<ctrlport_probe2_i, int>(
- alias(), "length", &ctrlport_probe2_i::set_length,
- pmt::mp(1), pmt::mp(10*len), pmt::mp(len),
- "samples", "set vector length", RPC_PRIVLVL_MIN, DISPNULL)));
+ int len = static_cast<int>(d_len);
+ d_rpc_vars.push_back(
+ rpcbasic_sptr(new rpcbasic_register_get<ctrlport_probe2_i, std::vector<int>>(
+ alias(),
+ d_id.c_str(),
+ &ctrlport_probe2_i::get,
+ pmt::mp(-32768),
+ pmt::mp(32767),
+ pmt::mp(0),
+ "volts",
+ d_desc.c_str(),
+ RPC_PRIVLVL_MIN,
+ d_disp_mask)));
+
+ d_rpc_vars.push_back(rpcbasic_sptr(
+ new rpcbasic_register_get<ctrlport_probe2_i, int>(alias(),
+ "length",
+ &ctrlport_probe2_i::length,
+ pmt::mp(1),
+ pmt::mp(10 * len),
+ pmt::mp(len),
+ "samples",
+ "get vector length",
+ RPC_PRIVLVL_MIN,
+ DISPNULL)));
+
+ d_rpc_vars.push_back(rpcbasic_sptr(
+ new rpcbasic_register_set<ctrlport_probe2_i, int>(alias(),
+ "length",
+ &ctrlport_probe2_i::set_length,
+ pmt::mp(1),
+ pmt::mp(10 * len),
+ pmt::mp(len),
+ "samples",
+ "set vector length",
+ RPC_PRIVLVL_MIN,
+ DISPNULL)));
#endif /* GR_CTRLPORT */
- }
+}
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/ctrlport_probe2_i_impl.h b/gr-blocks/lib/ctrlport_probe2_i_impl.h
index 2832af07ec..ed59801160 100644
--- a/gr-blocks/lib/ctrlport_probe2_i_impl.h
+++ b/gr-blocks/lib/ctrlport_probe2_i_impl.h
@@ -28,40 +28,42 @@
#include <gnuradio/rpcbufferedget.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class ctrlport_probe2_i_impl : public ctrlport_probe2_i
- {
- private:
- std::string d_id;
- std::string d_desc;
- size_t d_len;
- unsigned int d_disp_mask;
+class ctrlport_probe2_i_impl : public ctrlport_probe2_i
+{
+private:
+ std::string d_id;
+ std::string d_desc;
+ size_t d_len;
+ unsigned int d_disp_mask;
- size_t d_index;
- std::vector<int> d_buffer;
- rpcbufferedget< std::vector<int> > buffered_get;
+ size_t d_index;
+ std::vector<int> d_buffer;
+ rpcbufferedget<std::vector<int>> buffered_get;
- public:
- ctrlport_probe2_i_impl(const std::string &id, const std::string &desc,
- int len, unsigned int disp_mask);
- ~ctrlport_probe2_i_impl();
+public:
+ ctrlport_probe2_i_impl(const std::string& id,
+ const std::string& desc,
+ int len,
+ unsigned int disp_mask);
+ ~ctrlport_probe2_i_impl();
- void setup_rpc();
+ void setup_rpc();
- void forecast(int noutput_items, gr_vector_int &ninput_items_required);
+ void forecast(int noutput_items, gr_vector_int& ninput_items_required);
- std::vector<int> get();
+ std::vector<int> get();
- void set_length(int len);
- int length() const;
+ void set_length(int len);
+ int length() const;
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_CTRLPORT_PROBE2_I_IMPL_H */
diff --git a/gr-blocks/lib/ctrlport_probe2_s_impl.cc b/gr-blocks/lib/ctrlport_probe2_s_impl.cc
index 9924243db0..45ae21a839 100644
--- a/gr-blocks/lib/ctrlport_probe2_s_impl.cc
+++ b/gr-blocks/lib/ctrlport_probe2_s_impl.cc
@@ -28,122 +28,131 @@
#include <gnuradio/io_signature.h>
namespace gr {
- namespace blocks {
-
- ctrlport_probe2_s::sptr
- ctrlport_probe2_s::make(const std::string &id,
- const std::string &desc,
- int len, unsigned disp_mask)
- {
- return gnuradio::get_initial_sptr
- (new ctrlport_probe2_s_impl(id, desc, len, disp_mask));
- }
-
- ctrlport_probe2_s_impl::ctrlport_probe2_s_impl(const std::string &id,
- const std::string &desc,
- int len, unsigned disp_mask)
+namespace blocks {
+
+ctrlport_probe2_s::sptr ctrlport_probe2_s::make(const std::string& id,
+ const std::string& desc,
+ int len,
+ unsigned disp_mask)
+{
+ return gnuradio::get_initial_sptr(
+ new ctrlport_probe2_s_impl(id, desc, len, disp_mask));
+}
+
+ctrlport_probe2_s_impl::ctrlport_probe2_s_impl(const std::string& id,
+ const std::string& desc,
+ int len,
+ unsigned disp_mask)
: sync_block("probe2_s",
io_signature::make(1, 1, sizeof(short)),
io_signature::make(0, 0, 0)),
- d_id(id), d_desc(desc), d_len(len), d_disp_mask(disp_mask)
- {
- set_length(len);
- }
-
- ctrlport_probe2_s_impl::~ctrlport_probe2_s_impl()
- {
- }
-
- void
- ctrlport_probe2_s_impl::forecast(int noutput_items,
- gr_vector_int &ninput_items_required)
- {
- // make sure all inputs have noutput_items available
- unsigned ninputs = ninput_items_required.size();
- for(unsigned i = 0; i < ninputs; i++)
+ d_id(id),
+ d_desc(desc),
+ d_len(len),
+ d_disp_mask(disp_mask)
+{
+ set_length(len);
+}
+
+ctrlport_probe2_s_impl::~ctrlport_probe2_s_impl() {}
+
+void ctrlport_probe2_s_impl::forecast(int noutput_items,
+ gr_vector_int& ninput_items_required)
+{
+ // make sure all inputs have noutput_items available
+ unsigned ninputs = ninput_items_required.size();
+ for (unsigned i = 0; i < ninputs; i++)
ninput_items_required[i] = d_len;
- }
+}
- std::vector<short>
- ctrlport_probe2_s_impl::get()
- {
- return buffered_get.get();
- }
+std::vector<short> ctrlport_probe2_s_impl::get() { return buffered_get.get(); }
- void
- ctrlport_probe2_s_impl::set_length(int len)
- {
- gr::thread::scoped_lock guard(d_setlock);
+void ctrlport_probe2_s_impl::set_length(int len)
+{
+ gr::thread::scoped_lock guard(d_setlock);
- if(len > 8191) {
+ if (len > 8191) {
GR_LOG_WARN(d_logger,
boost::format("probe2_s: length %1% exceeds maximum"
- " buffer size of 8191") % len);
+ " buffer size of 8191") %
+ len);
len = 8191;
- }
-
- d_len = len;
- d_buffer.resize(d_len);
- d_index = 0;
}
- int
- ctrlport_probe2_s_impl::length() const
- {
- return (int)d_len;
- }
+ d_len = len;
+ d_buffer.resize(d_len);
+ d_index = 0;
+}
- int
- ctrlport_probe2_s_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- const short *in = (const short*)input_items[0];
+int ctrlport_probe2_s_impl::length() const { return (int)d_len; }
- gr::thread::scoped_lock guard(d_setlock);
+int ctrlport_probe2_s_impl::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ const short* in = (const short*)input_items[0];
- // copy samples to get buffer if we need samples
- if(d_index < d_len) {
+ gr::thread::scoped_lock guard(d_setlock);
+
+ // copy samples to get buffer if we need samples
+ if (d_index < d_len) {
// copy smaller of remaining buffer space and num inputs to work()
- int num_copy = std::min( (int)(d_len - d_index), noutput_items );
+ int num_copy = std::min((int)(d_len - d_index), noutput_items);
- memcpy(&d_buffer[d_index], in, num_copy*sizeof(short));
+ memcpy(&d_buffer[d_index], in, num_copy * sizeof(short));
d_index += num_copy;
- }
-
- // notify the waiting get() if we fill up the buffer
- if(d_index == d_len) {
- buffered_get.offer_data(d_buffer);
- }
+ }
- return noutput_items;
+ // notify the waiting get() if we fill up the buffer
+ if (d_index == d_len) {
+ buffered_get.offer_data(d_buffer);
}
- void
- ctrlport_probe2_s_impl::setup_rpc()
- {
+ return noutput_items;
+}
+
+void ctrlport_probe2_s_impl::setup_rpc()
+{
#ifdef GR_CTRLPORT
- int len = static_cast<int>(d_len);
- d_rpc_vars.push_back(
- rpcbasic_sptr(new rpcbasic_register_get<ctrlport_probe2_s, std::vector<short> >(
- alias(), d_id.c_str(), &ctrlport_probe2_s::get,
- pmt::mp(-32768), pmt::mp(32767), pmt::mp(0),
- "volts", d_desc.c_str(), RPC_PRIVLVL_MIN,
- d_disp_mask)));
-
- d_rpc_vars.push_back(
- rpcbasic_sptr(new rpcbasic_register_get<ctrlport_probe2_s, int>(
- alias(), "length", &ctrlport_probe2_s::length,
- pmt::mp(1), pmt::mp(10*len), pmt::mp(len),
- "samples", "get vector length", RPC_PRIVLVL_MIN, DISPNULL)));
-
- d_rpc_vars.push_back(
- rpcbasic_sptr(new rpcbasic_register_set<ctrlport_probe2_s, int>(
- alias(), "length", &ctrlport_probe2_s::set_length,
- pmt::mp(1), pmt::mp(10*len), pmt::mp(len),
- "samples", "set vector length", RPC_PRIVLVL_MIN, DISPNULL)));
+ int len = static_cast<int>(d_len);
+ d_rpc_vars.push_back(
+ rpcbasic_sptr(new rpcbasic_register_get<ctrlport_probe2_s, std::vector<short>>(
+ alias(),
+ d_id.c_str(),
+ &ctrlport_probe2_s::get,
+ pmt::mp(-32768),
+ pmt::mp(32767),
+ pmt::mp(0),
+ "volts",
+ d_desc.c_str(),
+ RPC_PRIVLVL_MIN,
+ d_disp_mask)));
+
+ d_rpc_vars.push_back(rpcbasic_sptr(
+ new rpcbasic_register_get<ctrlport_probe2_s, int>(alias(),
+ "length",
+ &ctrlport_probe2_s::length,
+ pmt::mp(1),
+ pmt::mp(10 * len),
+ pmt::mp(len),
+ "samples",
+ "get vector length",
+ RPC_PRIVLVL_MIN,
+ DISPNULL)));
+
+ d_rpc_vars.push_back(rpcbasic_sptr(
+ new rpcbasic_register_set<ctrlport_probe2_s, int>(alias(),
+ "length",
+ &ctrlport_probe2_s::set_length,
+ pmt::mp(1),
+ pmt::mp(10 * len),
+ pmt::mp(len),
+ "samples",
+ "set vector length",
+ RPC_PRIVLVL_MIN,
+ DISPNULL)));
#endif /* GR_CTRLPORT */
- }
+}
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/ctrlport_probe2_s_impl.h b/gr-blocks/lib/ctrlport_probe2_s_impl.h
index a608a7898c..6b3677a4f3 100644
--- a/gr-blocks/lib/ctrlport_probe2_s_impl.h
+++ b/gr-blocks/lib/ctrlport_probe2_s_impl.h
@@ -28,40 +28,42 @@
#include <gnuradio/rpcbufferedget.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class ctrlport_probe2_s_impl : public ctrlport_probe2_s
- {
- private:
- std::string d_id;
- std::string d_desc;
- size_t d_len;
- unsigned int d_disp_mask;
+class ctrlport_probe2_s_impl : public ctrlport_probe2_s
+{
+private:
+ std::string d_id;
+ std::string d_desc;
+ size_t d_len;
+ unsigned int d_disp_mask;
- size_t d_index;
- std::vector<short> d_buffer;
- rpcbufferedget< std::vector<short> > buffered_get;
+ size_t d_index;
+ std::vector<short> d_buffer;
+ rpcbufferedget<std::vector<short>> buffered_get;
- public:
- ctrlport_probe2_s_impl(const std::string &id, const std::string &desc,
- int len, unsigned int disp_mask);
- ~ctrlport_probe2_s_impl();
+public:
+ ctrlport_probe2_s_impl(const std::string& id,
+ const std::string& desc,
+ int len,
+ unsigned int disp_mask);
+ ~ctrlport_probe2_s_impl();
- void setup_rpc();
+ void setup_rpc();
- void forecast(int noutput_items, gr_vector_int &ninput_items_required);
+ void forecast(int noutput_items, gr_vector_int& ninput_items_required);
- std::vector<short> get();
+ std::vector<short> get();
- void set_length(int len);
- int length() const;
+ void set_length(int len);
+ int length() const;
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_CTRLPORT_PROBE2_S_IMPL_H */
diff --git a/gr-blocks/lib/ctrlport_probe_c_impl.cc b/gr-blocks/lib/ctrlport_probe_c_impl.cc
index 8141b2a2d1..a899917c98 100644
--- a/gr-blocks/lib/ctrlport_probe_c_impl.cc
+++ b/gr-blocks/lib/ctrlport_probe_c_impl.cc
@@ -28,74 +28,73 @@
#include <gnuradio/io_signature.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- ctrlport_probe_c::sptr
- ctrlport_probe_c::make(const std::string &id,
- const std::string &desc)
- {
- return gnuradio::get_initial_sptr
- (new ctrlport_probe_c_impl(id, desc));
- }
+ctrlport_probe_c::sptr ctrlport_probe_c::make(const std::string& id,
+ const std::string& desc)
+{
+ return gnuradio::get_initial_sptr(new ctrlport_probe_c_impl(id, desc));
+}
- ctrlport_probe_c_impl::ctrlport_probe_c_impl(const std::string &id,
- const std::string &desc)
- : sync_block("probe_c",
- io_signature::make(1, 1, sizeof(gr_complex)),
- io_signature::make(0, 0, 0)),
- d_id(id), d_desc(desc), d_ptr(NULL), d_ptrLen(0)
- {
- }
+ctrlport_probe_c_impl::ctrlport_probe_c_impl(const std::string& id,
+ const std::string& desc)
+ : sync_block("probe_c",
+ io_signature::make(1, 1, sizeof(gr_complex)),
+ io_signature::make(0, 0, 0)),
+ d_id(id),
+ d_desc(desc),
+ d_ptr(NULL),
+ d_ptrLen(0)
+{
+}
- ctrlport_probe_c_impl::~ctrlport_probe_c_impl()
- {
- }
+ctrlport_probe_c_impl::~ctrlport_probe_c_impl() {}
- std::vector<gr_complex>
- ctrlport_probe_c_impl::get()
- {
- if(d_ptr != NULL && d_ptrLen > 0) {
+std::vector<gr_complex> ctrlport_probe_c_impl::get()
+{
+ if (d_ptr != NULL && d_ptrLen > 0) {
ptrlock.lock();
- std::vector<gr_complex> vec(d_ptr, d_ptr+d_ptrLen);
+ std::vector<gr_complex> vec(d_ptr, d_ptr + d_ptrLen);
ptrlock.unlock();
return vec;
- }
- else {
+ } else {
std::vector<gr_complex> vec;
return vec;
- }
}
+}
- int
- ctrlport_probe_c_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- const gr_complex *in = (const gr_complex*)input_items[0];
+int ctrlport_probe_c_impl::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ const gr_complex* in = (const gr_complex*)input_items[0];
- // keep reference to symbols
- ptrlock.lock();
- d_ptr = in;
- d_ptrLen = noutput_items;
- ptrlock.unlock();
+ // keep reference to symbols
+ ptrlock.lock();
+ d_ptr = in;
+ d_ptrLen = noutput_items;
+ ptrlock.unlock();
- return noutput_items;
- }
+ return noutput_items;
+}
- void
- ctrlport_probe_c_impl::setup_rpc()
- {
+void ctrlport_probe_c_impl::setup_rpc()
+{
#ifdef GR_CTRLPORT
- d_rpc_vars.push_back(
- rpcbasic_sptr(new rpcbasic_register_get<ctrlport_probe_c, std::vector<std::complex<float> > >(
- alias(), d_id.c_str(), &ctrlport_probe_c::get,
- pmt::make_c32vector(0,-2),
- pmt::make_c32vector(0,2),
- pmt::make_c32vector(0,0),
- "volts", d_desc.c_str(), RPC_PRIVLVL_MIN,
- DISPXY | DISPOPTSCATTER)));
+ d_rpc_vars.push_back(rpcbasic_sptr(
+ new rpcbasic_register_get<ctrlport_probe_c, std::vector<std::complex<float>>>(
+ alias(),
+ d_id.c_str(),
+ &ctrlport_probe_c::get,
+ pmt::make_c32vector(0, -2),
+ pmt::make_c32vector(0, 2),
+ pmt::make_c32vector(0, 0),
+ "volts",
+ d_desc.c_str(),
+ RPC_PRIVLVL_MIN,
+ DISPXY | DISPOPTSCATTER)));
#endif /* GR_CTRLPORT */
- }
+}
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/ctrlport_probe_c_impl.h b/gr-blocks/lib/ctrlport_probe_c_impl.h
index 59e9497a82..4170e24929 100644
--- a/gr-blocks/lib/ctrlport_probe_c_impl.h
+++ b/gr-blocks/lib/ctrlport_probe_c_impl.h
@@ -28,33 +28,32 @@
#include <boost/thread/shared_mutex.hpp>
namespace gr {
- namespace blocks {
+namespace blocks {
- class ctrlport_probe_c_impl : public ctrlport_probe_c
- {
- private:
- boost::shared_mutex ptrlock;
+class ctrlport_probe_c_impl : public ctrlport_probe_c
+{
+private:
+ boost::shared_mutex ptrlock;
- std::string d_id;
- std::string d_desc;
- const gr_complex* d_ptr;
- size_t d_ptrLen;
+ std::string d_id;
+ std::string d_desc;
+ const gr_complex* d_ptr;
+ size_t d_ptrLen;
- public:
- ctrlport_probe_c_impl(const std::string &id, const std::string &desc);
- ~ctrlport_probe_c_impl();
+public:
+ ctrlport_probe_c_impl(const std::string& id, const std::string& desc);
+ ~ctrlport_probe_c_impl();
- void setup_rpc();
+ void setup_rpc();
- std::vector<gr_complex> get();
+ std::vector<gr_complex> get();
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_CTRLPORT_GR_CTRLPORT_PROBE_C_IMPL_H */
-
diff --git a/gr-blocks/lib/deinterleave_impl.cc b/gr-blocks/lib/deinterleave_impl.cc
index d7fdbb8f8f..e6f36dae9a 100644
--- a/gr-blocks/lib/deinterleave_impl.cc
+++ b/gr-blocks/lib/deinterleave_impl.cc
@@ -28,51 +28,50 @@
#include <gnuradio/io_signature.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- deinterleave::sptr deinterleave::make(size_t itemsize, unsigned int blocksize)
- {
- return gnuradio::get_initial_sptr(new deinterleave_impl(itemsize, blocksize));
- }
+deinterleave::sptr deinterleave::make(size_t itemsize, unsigned int blocksize)
+{
+ return gnuradio::get_initial_sptr(new deinterleave_impl(itemsize, blocksize));
+}
- deinterleave_impl::deinterleave_impl(size_t itemsize, unsigned int blocksize)
- : block("deinterleave",
- io_signature::make (1, 1, itemsize),
- io_signature::make (1, io_signature::IO_INFINITE, itemsize)),
- d_itemsize(itemsize), d_blocksize(blocksize), d_current_output(0)
- {
- d_size_bytes = d_itemsize * d_blocksize;
- set_output_multiple(blocksize);
- }
+deinterleave_impl::deinterleave_impl(size_t itemsize, unsigned int blocksize)
+ : block("deinterleave",
+ io_signature::make(1, 1, itemsize),
+ io_signature::make(1, io_signature::IO_INFINITE, itemsize)),
+ d_itemsize(itemsize),
+ d_blocksize(blocksize),
+ d_current_output(0)
+{
+ d_size_bytes = d_itemsize * d_blocksize;
+ set_output_multiple(blocksize);
+}
- void
- deinterleave_impl::forecast(int noutput_items, gr_vector_int &ninput_items_required)
- {
- ninput_items_required[0] = noutput_items * d_noutputs;
- }
+void deinterleave_impl::forecast(int noutput_items, gr_vector_int& ninput_items_required)
+{
+ ninput_items_required[0] = noutput_items * d_noutputs;
+}
- bool
- deinterleave_impl::check_topology(int ninputs, int noutputs)
- {
- set_relative_rate(1, (uint64_t)noutputs);
- d_noutputs = noutputs;
- return true;
- }
+bool deinterleave_impl::check_topology(int ninputs, int noutputs)
+{
+ set_relative_rate(1, (uint64_t)noutputs);
+ d_noutputs = noutputs;
+ return true;
+}
- int
- deinterleave_impl::general_work(int noutput_items,
+int deinterleave_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];
+ 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 count = 0, totalcount = noutput_items*d_noutputs;
- unsigned int skip = 0;
- unsigned int acc = 0;
- while(count < totalcount) {
- memcpy(out[d_current_output]+skip*d_size_bytes, in, d_size_bytes);
+ int count = 0, totalcount = noutput_items * d_noutputs;
+ unsigned int skip = 0;
+ unsigned int acc = 0;
+ while (count < totalcount) {
+ memcpy(out[d_current_output] + skip * d_size_bytes, in, d_size_bytes);
in += d_size_bytes;
produce(d_current_output, d_blocksize);
d_current_output = (d_current_output + 1) % d_noutputs;
@@ -82,18 +81,18 @@ namespace gr {
// This is separate than d_current_output since we could be in
// the middle of a loop when we exit.
acc++;
- if(acc >= d_noutputs) {
- skip++;
- acc = 0;
+ if (acc >= d_noutputs) {
+ skip++;
+ acc = 0;
}
// Keep track of our loop counter
- count+=d_blocksize;
- }
- consume_each(totalcount);
- return WORK_CALLED_PRODUCE;
+ count += d_blocksize;
}
+ consume_each(totalcount);
+ return WORK_CALLED_PRODUCE;
+}
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/deinterleave_impl.h b/gr-blocks/lib/deinterleave_impl.h
index 71a551a69c..951e66b526 100644
--- a/gr-blocks/lib/deinterleave_impl.h
+++ b/gr-blocks/lib/deinterleave_impl.h
@@ -26,31 +26,30 @@
#include <gnuradio/blocks/deinterleave.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class BLOCKS_API deinterleave_impl : public deinterleave
- {
+class BLOCKS_API deinterleave_impl : public deinterleave
+{
- size_t d_itemsize;
- unsigned int d_blocksize;
- unsigned int d_current_output;
- unsigned int d_noutputs;
- unsigned int d_size_bytes; // block size in bytes
+ size_t d_itemsize;
+ unsigned int d_blocksize;
+ unsigned int d_current_output;
+ unsigned int d_noutputs;
+ unsigned int d_size_bytes; // block size in bytes
- public:
- deinterleave_impl(size_t itemsize, unsigned int blocksize);
+public:
+ deinterleave_impl(size_t itemsize, unsigned int blocksize);
- void forecast(int noutput_items, gr_vector_int &ninput_items_required);
- bool check_topology(int ninputs, int noutputs);
+ void forecast(int noutput_items, gr_vector_int& ninput_items_required);
+ bool check_topology(int ninputs, int noutputs);
- int general_work(int noutput_items,
- gr_vector_int& ninput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
+ 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 blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/delay_impl.cc b/gr-blocks/lib/delay_impl.cc
index 0ebe124b09..d064ccf86d 100644
--- a/gr-blocks/lib/delay_impl.cc
+++ b/gr-blocks/lib/delay_impl.cc
@@ -29,117 +29,109 @@
#include <string.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- delay::sptr
- delay::make(size_t itemsize, int delay)
- {
- return gnuradio::get_initial_sptr
- (new delay_impl(itemsize, delay));
- }
+delay::sptr delay::make(size_t itemsize, int delay)
+{
+ return gnuradio::get_initial_sptr(new delay_impl(itemsize, delay));
+}
- delay_impl::delay_impl(size_t itemsize, int delay)
- : block("delay",
- io_signature::make(1, -1, itemsize),
- io_signature::make(1, -1, itemsize)),
- d_itemsize(itemsize)
- {
- if(delay < 0) {
+delay_impl::delay_impl(size_t itemsize, int delay)
+ : block("delay",
+ io_signature::make(1, -1, itemsize),
+ io_signature::make(1, -1, itemsize)),
+ d_itemsize(itemsize)
+{
+ if (delay < 0) {
throw std::runtime_error("delay: Cannot initialize block with a delay < 0.");
- }
- set_dly(delay);
- d_delta = 0;
}
+ set_dly(delay);
+ d_delta = 0;
+}
- delay_impl::~delay_impl()
- {
- }
+delay_impl::~delay_impl() {}
- void
- delay_impl::forecast(int noutput_items,
- gr_vector_int &ninput_items_required)
- {
- // make sure all inputs have noutput_items available
- unsigned ninputs = ninput_items_required.size();
- for(unsigned i = 0; i < ninputs; i++)
+void delay_impl::forecast(int noutput_items, gr_vector_int& ninput_items_required)
+{
+ // make sure all inputs have noutput_items available
+ unsigned ninputs = ninput_items_required.size();
+ for (unsigned i = 0; i < ninputs; i++)
ninput_items_required[i] = noutput_items;
- }
+}
- void
- delay_impl::set_dly(int d)
- {
- // only set a new delta if there is a change in the delay; this
- // protects from quickly-repeated calls to this function that
- // would end with d_delta=0.
- if(d != dly()) {
+void delay_impl::set_dly(int d)
+{
+ // only set a new delta if there is a change in the delay; this
+ // protects from quickly-repeated calls to this function that
+ // would end with d_delta=0.
+ if (d != dly()) {
gr::thread::scoped_lock l(d_mutex_delay);
int old = dly();
- set_history(d+1);
- declare_sample_delay(history()-1);
+ set_history(d + 1);
+ declare_sample_delay(history() - 1);
d_delta += dly() - old;
- }
}
+}
- int
- delay_impl::general_work(int noutput_items,
- gr_vector_int &ninput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- gr::thread::scoped_lock l(d_mutex_delay);
- assert(input_items.size() == output_items.size());
+int delay_impl::general_work(int noutput_items,
+ gr_vector_int& ninput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ gr::thread::scoped_lock l(d_mutex_delay);
+ assert(input_items.size() == output_items.size());
- const char *iptr;
- char *optr;
- int cons, ret;
+ const char* iptr;
+ char* optr;
+ int cons, ret;
- // No change in delay; just memcpy ins to outs
- if(d_delta == 0) {
- for(size_t i = 0; i < input_items.size(); i++) {
- iptr = (const char *)input_items[i];
- optr = (char *)output_items[i];
- std::memcpy(optr, iptr, noutput_items*d_itemsize);
+ // No change in delay; just memcpy ins to outs
+ if (d_delta == 0) {
+ for (size_t i = 0; i < input_items.size(); i++) {
+ iptr = (const char*)input_items[i];
+ optr = (char*)output_items[i];
+ std::memcpy(optr, iptr, noutput_items * d_itemsize);
}
cons = noutput_items;
ret = noutput_items;
- }
+ }
- // Skip over d_delta items on the input
- else if(d_delta < 0) {
+ // Skip over d_delta items on the input
+ else if (d_delta < 0) {
int n_to_copy, n_adj;
int delta = -d_delta;
- n_to_copy = std::max(0, noutput_items-delta);
+ n_to_copy = std::max(0, noutput_items - delta);
n_adj = std::min(delta, noutput_items);
- for(size_t i = 0; i < input_items.size(); i++) {
- iptr = (const char *) input_items[i];
- optr = (char *) output_items[i];
- std::memcpy(optr, iptr+delta*d_itemsize, n_to_copy*d_itemsize);
+ for (size_t i = 0; i < input_items.size(); i++) {
+ iptr = (const char*)input_items[i];
+ optr = (char*)output_items[i];
+ std::memcpy(optr, iptr + delta * d_itemsize, n_to_copy * d_itemsize);
}
cons = noutput_items;
ret = n_to_copy;
delta -= n_adj;
d_delta = -delta;
- }
+ }
- //produce but not consume (inserts zeros)
- else { // d_delta > 0
+ // produce but not consume (inserts zeros)
+ else { // d_delta > 0
int n_from_input, n_padding;
- n_from_input = std::max(0, noutput_items-d_delta);
+ n_from_input = std::max(0, noutput_items - d_delta);
n_padding = std::min(d_delta, noutput_items);
- for(size_t i = 0; i < input_items.size(); i++) {
- iptr = (const char *) input_items[i];
- optr = (char *) output_items[i];
- std::memset(optr, 0, n_padding*d_itemsize);
- std::memcpy(optr, iptr, n_from_input*d_itemsize);
+ for (size_t i = 0; i < input_items.size(); i++) {
+ iptr = (const char*)input_items[i];
+ optr = (char*)output_items[i];
+ std::memset(optr, 0, n_padding * d_itemsize);
+ std::memcpy(optr, iptr, n_from_input * d_itemsize);
}
cons = n_from_input;
ret = noutput_items;
d_delta -= n_padding;
- }
-
- consume_each(cons);
- return ret;
}
- } /* namespace blocks */
+ consume_each(cons);
+ return ret;
+}
+
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/delay_impl.h b/gr-blocks/lib/delay_impl.h
index ad07e6aa78..434fb03a15 100644
--- a/gr-blocks/lib/delay_impl.h
+++ b/gr-blocks/lib/delay_impl.h
@@ -27,32 +27,31 @@
#include <gnuradio/thread/thread.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class delay_impl : public delay
- {
- private:
- void forecast(int noutput_items,
- gr_vector_int &ninput_items_required);
+class delay_impl : public delay
+{
+private:
+ void forecast(int noutput_items, gr_vector_int& ninput_items_required);
- size_t d_itemsize;
- int d_delta;
- gr::thread::mutex d_mutex_delay;
+ size_t d_itemsize;
+ int d_delta;
+ gr::thread::mutex d_mutex_delay;
- public:
- delay_impl(size_t itemsize, int delay);
- ~delay_impl();
+public:
+ delay_impl(size_t itemsize, int delay);
+ ~delay_impl();
- int dly() const { return history()-1; }
- void set_dly(int d);
+ int dly() const { return history() - 1; }
+ void set_dly(int d);
- int general_work(int noutput_items,
- gr_vector_int &ninput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
- };
+ 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 blocks */
} /* namespace gr */
#endif /* INCLUDED_GR_DELAY_IMPL_H */
diff --git a/gr-blocks/lib/divide_impl.cc b/gr-blocks/lib/divide_impl.cc
index 5fe08f95d1..2c7258dd32 100644
--- a/gr-blocks/lib/divide_impl.cc
+++ b/gr-blocks/lib/divide_impl.cc
@@ -30,101 +30,98 @@
#include <volk/volk.h>
namespace gr {
- namespace blocks {
-
- template <class T>
- typename divide<T>::sptr divide<T>::make(size_t vlen)
- {
- return gnuradio::get_initial_sptr(new divide_impl<T> (vlen));
- }
-
- template <>
- divide_impl<float>::divide_impl(size_t vlen)
- : sync_block ("divide",
- io_signature::make (2, -1, sizeof (float)*vlen),
- io_signature::make (1, 1, sizeof (float)*vlen)),
- d_vlen(vlen)
- {
+namespace blocks {
+
+template <class T>
+typename divide<T>::sptr divide<T>::make(size_t vlen)
+{
+ return gnuradio::get_initial_sptr(new divide_impl<T>(vlen));
+}
+
+template <>
+divide_impl<float>::divide_impl(size_t vlen)
+ : sync_block("divide",
+ io_signature::make(2, -1, sizeof(float) * vlen),
+ io_signature::make(1, 1, sizeof(float) * vlen)),
+ d_vlen(vlen)
+{
+}
+
+template <>
+int divide_impl<float>::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ float* optr = (float*)output_items[0];
+ size_t ninputs = input_items.size();
+ float* numerator = (float*)input_items[0];
+ for (size_t inp = 1; inp < ninputs; ++inp) {
+ volk_32f_x2_divide_32f(
+ optr, numerator, (float*)input_items[inp], noutput_items * d_vlen);
+ numerator = optr;
}
- template <>
- int
- divide_impl<float>::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- float *optr = (float *) output_items[0];
- size_t ninputs = input_items.size ();
- float *numerator = (float *) input_items[0];
- for(size_t inp = 1; inp < ninputs; ++inp)
- {
- volk_32f_x2_divide_32f(optr, numerator, (float*) input_items[inp], noutput_items * d_vlen);
- numerator = optr;
- }
-
- return noutput_items;
- }
+ return noutput_items;
+}
- template <>
- divide_impl<gr_complex>::divide_impl(size_t vlen)
- : sync_block ("divide_cc",
- io_signature::make (2, -1, sizeof (gr_complex)*vlen),
- io_signature::make (1, 1, sizeof (gr_complex)*vlen)),
- d_vlen(vlen)
- {
+template <>
+divide_impl<gr_complex>::divide_impl(size_t vlen)
+ : sync_block("divide_cc",
+ io_signature::make(2, -1, sizeof(gr_complex) * vlen),
+ io_signature::make(1, 1, sizeof(gr_complex) * vlen)),
+ d_vlen(vlen)
+{
+}
+
+template <>
+int divide_impl<gr_complex>::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ gr_complex* optr = (gr_complex*)output_items[0];
+ size_t ninputs = input_items.size();
+ gr_complex* numerator = (gr_complex*)input_items[0];
+ for (size_t inp = 1; inp < ninputs; ++inp) {
+ volk_32fc_x2_divide_32fc(
+ optr, numerator, (gr_complex*)input_items[inp], noutput_items * d_vlen);
+ numerator = optr;
}
- template <>
- int
- divide_impl<gr_complex>::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- gr_complex *optr = (gr_complex *) output_items[0];
- size_t ninputs = input_items.size ();
- gr_complex *numerator = (gr_complex *) input_items[0];
- for(size_t inp = 1; inp < ninputs; ++inp)
- {
- volk_32fc_x2_divide_32fc(optr, numerator, (gr_complex*) input_items[inp], noutput_items * d_vlen);
- numerator = optr;
- }
-
- return noutput_items;
- }
+ return noutput_items;
+}
- template <class T>
- divide_impl<T> ::divide_impl (size_t vlen)
- : sync_block ("divide",
- io_signature::make (1, -1, sizeof (T)*vlen),
- io_signature::make (1, 1, sizeof (T)*vlen)),
+template <class T>
+divide_impl<T>::divide_impl(size_t vlen)
+ : sync_block("divide",
+ io_signature::make(1, -1, sizeof(T) * vlen),
+ io_signature::make(1, 1, sizeof(T) * vlen)),
d_vlen(vlen)
- {
- }
+{
+}
- template <class T>
- int
- divide_impl<T> ::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- T *optr = (T *) output_items[0];
+template <class T>
+int divide_impl<T>::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ T* optr = (T*)output_items[0];
- int ninputs = input_items.size ();
+ int ninputs = input_items.size();
- for (size_t i = 0; i < noutput_items*d_vlen; i++){
- T acc = ((T *) input_items[0])[i];
- for (int j = 1; j < ninputs; j++)
- acc /= ((T *) input_items[j])[i];
+ for (size_t i = 0; i < noutput_items * d_vlen; i++) {
+ T acc = ((T*)input_items[0])[i];
+ for (int j = 1; j < ninputs; j++)
+ acc /= ((T*)input_items[j])[i];
- *optr++ = (T) acc;
- }
-
- return noutput_items;
+ *optr++ = (T)acc;
}
+ return noutput_items;
+}
+
template class divide<std::int16_t>;
template class divide<std::int32_t>;
- template class divide<float>;
- template class divide<gr_complex>;
- } /* namespace blocks */
+template class divide<float>;
+template class divide<gr_complex>;
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/divide_impl.h b/gr-blocks/lib/divide_impl.h
index cc9045c711..35f1bb0f2e 100644
--- a/gr-blocks/lib/divide_impl.h
+++ b/gr-blocks/lib/divide_impl.h
@@ -27,22 +27,22 @@
#include <gnuradio/blocks/divide.h>
namespace gr {
- namespace blocks {
+namespace blocks {
-template<class T>
- class BLOCKS_API divide_impl : public divide<T>
- {
- size_t d_vlen;
+template <class T>
+class BLOCKS_API divide_impl : public divide<T>
+{
+ size_t d_vlen;
- public:
- divide_impl (size_t vlen);
+public:
+ divide_impl(size_t vlen);
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* DIVIDE_IMPL_H */
diff --git a/gr-blocks/lib/endian_swap_impl.cc b/gr-blocks/lib/endian_swap_impl.cc
index 604e8b9ad8..e4db818b1e 100644
--- a/gr-blocks/lib/endian_swap_impl.cc
+++ b/gr-blocks/lib/endian_swap_impl.cc
@@ -29,59 +29,54 @@
#include <volk/volk.h>
namespace gr {
- namespace blocks {
+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::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)
- : sync_block("endian_swap_impl",
- io_signature::make(1, 1, item_size_bytes),
- io_signature::make(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(size_t item_size_bytes)
+ : sync_block("endian_swap_impl",
+ io_signature::make(1, 1, item_size_bytes),
+ io_signature::make(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()
- {
- }
+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 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));
- switch(nbytes){
- case 1:
- memcpy(out,in,noutput_items);
+ int nbytes(output_signature()->sizeof_stream_item(0));
+ switch (nbytes) {
+ case 1:
+ memcpy(out, in, noutput_items);
break;
- case 2:
- memcpy(out,in,2*noutput_items);
- volk_16u_byteswap((uint16_t*)out,noutput_items);
+ case 2:
+ memcpy(out, in, 2 * noutput_items);
+ volk_16u_byteswap((uint16_t*)out, noutput_items);
break;
- case 4:
- memcpy(out,in,4*noutput_items);
- volk_32u_byteswap((uint32_t*)out,noutput_items);
+ case 4:
+ memcpy(out, in, 4 * noutput_items);
+ volk_32u_byteswap((uint32_t*)out, noutput_items);
break;
- case 8:
- memcpy(out,in,8*noutput_items);
- volk_64u_byteswap((uint64_t*)out,noutput_items);
+ case 8:
+ memcpy(out, in, 8 * noutput_items);
+ volk_64u_byteswap((uint64_t*)out, noutput_items);
break;
- default:
+ default:
throw std::runtime_error("itemsize is not valid for endian_swap!");
- }
-
- return noutput_items;
}
- } /* namespace blocks */
+ 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
index de56c52725..975e178327 100644
--- a/gr-blocks/lib/endian_swap_impl.h
+++ b/gr-blocks/lib/endian_swap_impl.h
@@ -26,22 +26,21 @@
#include <gnuradio/blocks/endian_swap.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class endian_swap_impl : public endian_swap
- {
- private:
+class endian_swap_impl : public endian_swap
+{
+private:
+public:
+ endian_swap_impl(size_t item_size_bytes);
+ ~endian_swap_impl();
- 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);
+};
- int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
- };
-
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_GR_ENDIAN_SWAP_IMPL_H */
diff --git a/gr-blocks/lib/exponentiate_const_cci_impl.cc b/gr-blocks/lib/exponentiate_const_cci_impl.cc
index c46930febb..cd9a287ae5 100644
--- a/gr-blocks/lib/exponentiate_const_cci_impl.cc
+++ b/gr-blocks/lib/exponentiate_const_cci_impl.cc
@@ -29,74 +29,66 @@
#include <volk/volk.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- exponentiate_const_cci::sptr
- exponentiate_const_cci::make(int exponent, size_t vlen)
- {
- return gnuradio::get_initial_sptr
- (new exponentiate_const_cci_impl(exponent, vlen));
- }
+exponentiate_const_cci::sptr exponentiate_const_cci::make(int exponent, size_t vlen)
+{
+ return gnuradio::get_initial_sptr(new exponentiate_const_cci_impl(exponent, vlen));
+}
- /*
- * The private constructor
- */
- exponentiate_const_cci_impl::exponentiate_const_cci_impl(int exponent, size_t vlen)
- : gr::sync_block("exponentiate_const_cci",
- gr::io_signature::make(1, -1, sizeof(gr_complex)*vlen),
- gr::io_signature::make(1, -1, sizeof(gr_complex)*vlen)),
- d_exponent(exponent),
- d_vlen(vlen)
- {
- const int alignment_multiple = volk_get_alignment()/sizeof(gr_complex);
- set_alignment(std::max(1, alignment_multiple));
- }
+/*
+ * The private constructor
+ */
+exponentiate_const_cci_impl::exponentiate_const_cci_impl(int exponent, size_t vlen)
+ : gr::sync_block("exponentiate_const_cci",
+ gr::io_signature::make(1, -1, sizeof(gr_complex) * vlen),
+ gr::io_signature::make(1, -1, sizeof(gr_complex) * vlen)),
+ d_exponent(exponent),
+ d_vlen(vlen)
+{
+ const int alignment_multiple = volk_get_alignment() / sizeof(gr_complex);
+ set_alignment(std::max(1, alignment_multiple));
+}
- /*
- * Our virtual destructor.
- */
- exponentiate_const_cci_impl::~exponentiate_const_cci_impl()
- {
- }
+/*
+ * Our virtual destructor.
+ */
+exponentiate_const_cci_impl::~exponentiate_const_cci_impl() {}
- bool
- exponentiate_const_cci_impl::check_topology(int ninputs, int noutputs)
- {
- return ninputs == noutputs;
- }
+bool exponentiate_const_cci_impl::check_topology(int ninputs, int noutputs)
+{
+ return ninputs == noutputs;
+}
- void
- exponentiate_const_cci_impl::set_exponent(int exponent) {
- gr::thread::scoped_lock guard(d_setlock);
- d_exponent = exponent;
- }
+void exponentiate_const_cci_impl::set_exponent(int exponent)
+{
+ gr::thread::scoped_lock guard(d_setlock);
+ d_exponent = exponent;
+}
- int
- exponentiate_const_cci_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- gr::thread::scoped_lock guard(d_setlock);
+int exponentiate_const_cci_impl::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ gr::thread::scoped_lock guard(d_setlock);
- for(unsigned int i = 0; i < input_items.size(); i++) {
- const gr_complex *in = (const gr_complex *) input_items[i];
- gr_complex *out = (gr_complex *) output_items[i];
-
- if(d_exponent > 1) {
- volk_32fc_x2_multiply_32fc(out, in, in, noutput_items*d_vlen);
- for(int j = 2; j < d_exponent; j++) {
- volk_32fc_x2_multiply_32fc(out, out, in, noutput_items*d_vlen);
- }
- }
- else {
- memcpy(out, in, sizeof(gr_complex)*noutput_items*d_vlen);
- }
- }
+ for (unsigned int i = 0; i < input_items.size(); i++) {
+ const gr_complex* in = (const gr_complex*)input_items[i];
+ gr_complex* out = (gr_complex*)output_items[i];
- // Tell runtime system how many output items we produced.
- return noutput_items;
+ if (d_exponent > 1) {
+ volk_32fc_x2_multiply_32fc(out, in, in, noutput_items * d_vlen);
+ for (int j = 2; j < d_exponent; j++) {
+ volk_32fc_x2_multiply_32fc(out, out, in, noutput_items * d_vlen);
+ }
+ } else {
+ memcpy(out, in, sizeof(gr_complex) * noutput_items * d_vlen);
+ }
}
- } /* namespace blocks */
-} /* namespace gr */
+ // Tell runtime system how many output items we produced.
+ return noutput_items;
+}
+} /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/exponentiate_const_cci_impl.h b/gr-blocks/lib/exponentiate_const_cci_impl.h
index c89fe57646..35aea10e9d 100644
--- a/gr-blocks/lib/exponentiate_const_cci_impl.h
+++ b/gr-blocks/lib/exponentiate_const_cci_impl.h
@@ -26,28 +26,27 @@
#include <gnuradio/blocks/exponentiate_const_cci.h>
namespace gr {
- namespace blocks {
-
- class exponentiate_const_cci_impl : public exponentiate_const_cci
- {
- private:
- int d_exponent;
- int d_vlen;
-
- public:
- exponentiate_const_cci_impl(int exponent, size_t vlen);
- ~exponentiate_const_cci_impl();
- bool check_topology(int ninputs, int noutputs);
- void set_exponent(int exponent);
-
- // Where all the action really happens
- int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
- };
-
- } // namespace blocks
+namespace blocks {
+
+class exponentiate_const_cci_impl : public exponentiate_const_cci
+{
+private:
+ int d_exponent;
+ int d_vlen;
+
+public:
+ exponentiate_const_cci_impl(int exponent, size_t vlen);
+ ~exponentiate_const_cci_impl();
+ bool check_topology(int ninputs, int noutputs);
+ void set_exponent(int exponent);
+
+ // Where all the action really happens
+ 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_EXPONENTIATE_CONST_CCI_IMPL_H */
-
diff --git a/gr-blocks/lib/file_descriptor_sink_impl.cc b/gr-blocks/lib/file_descriptor_sink_impl.cc
index 975c60c63d..cb16129bcc 100644
--- a/gr-blocks/lib/file_descriptor_sink_impl.cc
+++ b/gr-blocks/lib/file_descriptor_sink_impl.cc
@@ -39,56 +39,50 @@
#endif
namespace gr {
- namespace blocks {
+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::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)
- : sync_block("file_descriptor_sink",
- io_signature::make(1, 1, itemsize),
- io_signature::make(0, 0, 0)),
- d_itemsize(itemsize), d_fd(fd)
- {
- }
+file_descriptor_sink_impl::file_descriptor_sink_impl(size_t itemsize, int fd)
+ : sync_block("file_descriptor_sink",
+ io_signature::make(1, 1, itemsize),
+ io_signature::make(0, 0, 0)),
+ d_itemsize(itemsize),
+ d_fd(fd)
+{
+}
- file_descriptor_sink_impl::~file_descriptor_sink_impl()
- {
- close(d_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;
+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) {
+ 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
- }
+ if (r == -1) {
+ if (errno == EINTR)
+ continue;
+ else {
+ perror("file_descriptor_sink");
+ return -1; // indicate we're done
+ }
+ } else {
+ byte_size -= r;
+ inbuf += r;
}
- else {
- byte_size -= r;
- inbuf += r;
- }
- }
-
- return noutput_items;
}
- } /* namespace blocks */
+ 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
index 0b455879a4..16df63333e 100644
--- a/gr-blocks/lib/file_descriptor_sink_impl.h
+++ b/gr-blocks/lib/file_descriptor_sink_impl.h
@@ -26,24 +26,24 @@
#include <gnuradio/blocks/file_descriptor_sink.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class file_descriptor_sink_impl : public file_descriptor_sink
- {
- private:
- size_t d_itemsize;
- int d_fd;
+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();
+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);
- };
+ int work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* 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
index 575681ba9b..de47bb85a3 100644
--- a/gr-blocks/lib/file_descriptor_source_impl.cc
+++ b/gr-blocks/lib/file_descriptor_source_impl.cc
@@ -40,117 +40,114 @@
#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)
- : sync_block("file_descriptor_source",
- io_signature::make(0, 0, 0),
- io_signature::make(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) {
+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)
+ : sync_block("file_descriptor_source",
+ io_signature::make(0, 0, 0),
+ io_signature::make(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) {
+ 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);
+ r = handle_residue(buf, r + nbytes_read);
- if(r == 0) // block until we get something
+ if (r == 0) // block until we get something
return read_items(buf, nitems);
- return r;
- }
+ 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) {
+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;
}
+ 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);
+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;
+ char* o = (char*)output_items[0];
+ int nread = 0;
- while(1) {
+ 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;
+ if (r == -1) {
+ if (errno == EINTR)
+ continue;
+ else {
+ perror("file_descriptor_source[read]");
+ return -1;
}
- }
- }
- else {
- o += r * d_itemsize;
- nread += r;
- break;
+ } 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
+ if (nread == 0) // EOF
return -1;
- return nread;
- }
+ return nread;
+}
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/file_descriptor_source_impl.h b/gr-blocks/lib/file_descriptor_source_impl.h
index 6bdfa03614..e0f49bfd9d 100644
--- a/gr-blocks/lib/file_descriptor_source_impl.h
+++ b/gr-blocks/lib/file_descriptor_source_impl.h
@@ -26,33 +26,33 @@
#include <gnuradio/blocks/file_descriptor_source.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class file_descriptor_source_impl : public file_descriptor_source
- {
- private:
- size_t d_itemsize;
- int d_fd;
- bool d_repeat;
+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;
+ 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; }
+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();
+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);
- };
+ int work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_GR_FILE_DESCRIPTOR_SOURCE_IMPL_H */
diff --git a/gr-blocks/lib/file_meta_sink_impl.cc b/gr-blocks/lib/file_meta_sink_impl.cc
index fed28c7352..342ee4573c 100644
--- a/gr-blocks/lib/file_meta_sink_impl.cc
+++ b/gr-blocks/lib/file_meta_sink_impl.cc
@@ -38,433 +38,420 @@
#include <io.h>
#endif
#ifdef O_BINARY
-#define OUR_O_BINARY O_BINARY
+#define OUR_O_BINARY O_BINARY
#else
-#define OUR_O_BINARY 0
+#define OUR_O_BINARY 0
#endif
// should be handled via configure
#ifdef O_LARGEFILE
-#define OUR_O_LARGEFILE O_LARGEFILE
+#define OUR_O_LARGEFILE O_LARGEFILE
#else
-#define OUR_O_LARGEFILE 0
+#define OUR_O_LARGEFILE 0
#endif
namespace gr {
- namespace blocks {
-
-
- file_meta_sink::sptr
- file_meta_sink::make(size_t itemsize,
- const std::string &filename,
- double samp_rate,
- double relative_rate,
- gr_file_types type,
- bool complex,
- size_t max_segment_size,
- pmt::pmt_t extra_dict,
- bool detached_header)
- {
- return gnuradio::get_initial_sptr
- (new file_meta_sink_impl(itemsize, filename,
- samp_rate, relative_rate,
- type, complex,
- max_segment_size,
- extra_dict,
- detached_header));
+namespace blocks {
+
+
+file_meta_sink::sptr file_meta_sink::make(size_t itemsize,
+ const std::string& filename,
+ double samp_rate,
+ double relative_rate,
+ gr_file_types type,
+ bool complex,
+ size_t max_segment_size,
+ pmt::pmt_t extra_dict,
+ bool detached_header)
+{
+ return gnuradio::get_initial_sptr(new file_meta_sink_impl(itemsize,
+ filename,
+ samp_rate,
+ relative_rate,
+ type,
+ complex,
+ max_segment_size,
+ extra_dict,
+ detached_header));
+}
+
+file_meta_sink_impl::file_meta_sink_impl(size_t itemsize,
+ const std::string& filename,
+ double samp_rate,
+ double relative_rate,
+ gr_file_types type,
+ bool complex,
+ size_t max_segment_size,
+ pmt::pmt_t extra_dict,
+ bool detached_header)
+ : sync_block("file_meta_sink",
+ io_signature::make(1, 1, itemsize),
+ io_signature::make(0, 0, 0)),
+ d_itemsize(itemsize),
+ d_samp_rate(samp_rate),
+ d_relative_rate(relative_rate),
+ d_max_seg_size(max_segment_size),
+ d_total_seg_size(0),
+ d_updated(false),
+ d_unbuffered(false)
+{
+ d_fp = 0;
+ d_new_fp = 0;
+ d_hdr_fp = 0;
+ d_new_hdr_fp = 0;
+
+ if (detached_header == true)
+ d_state = STATE_DETACHED;
+ else
+ d_state = STATE_INLINE;
+
+ if (!open(filename))
+ throw std::runtime_error("file_meta_sink: can't open file\n");
+
+ pmt::pmt_t timestamp = pmt::make_tuple(pmt::from_uint64(0), pmt::from_double(0));
+
+ // handle extra dictionary
+ d_extra = pmt::make_dict();
+ pmt::pmt_t keys = pmt::dict_keys(extra_dict);
+ pmt::pmt_t vals = pmt::dict_values(extra_dict);
+ size_t nitems = pmt::length(keys);
+ for (size_t i = 0; i < nitems; i++) {
+ d_extra = pmt::dict_add(d_extra, pmt::nth(i, keys), pmt::nth(i, vals));
}
- file_meta_sink_impl::file_meta_sink_impl(size_t itemsize,
- const std::string &filename,
- double samp_rate, double relative_rate,
- gr_file_types type, bool complex,
- size_t max_segment_size,
- pmt::pmt_t extra_dict,
- bool detached_header)
- : sync_block("file_meta_sink",
- io_signature::make(1, 1, itemsize),
- io_signature::make(0, 0, 0)),
- d_itemsize(itemsize),
- d_samp_rate(samp_rate), d_relative_rate(relative_rate),
- d_max_seg_size(max_segment_size), d_total_seg_size(0),
- d_updated(false), d_unbuffered(false)
- {
- d_fp = 0;
- d_new_fp = 0;
- d_hdr_fp = 0;
- d_new_hdr_fp = 0;
-
- if(detached_header == true)
- d_state = STATE_DETACHED;
- else
- d_state = STATE_INLINE;
-
- if(!open(filename))
- throw std::runtime_error("file_meta_sink: can't open file\n");
-
- pmt::pmt_t timestamp = pmt::make_tuple(pmt::from_uint64(0),
- pmt::from_double(0));
-
- // handle extra dictionary
- d_extra = pmt::make_dict();
- pmt::pmt_t keys = pmt::dict_keys(extra_dict);
- pmt::pmt_t vals = pmt::dict_values(extra_dict);
- size_t nitems = pmt::length(keys);
- for(size_t i = 0; i < nitems; i++) {
- d_extra = pmt::dict_add(d_extra,
- pmt::nth(i, keys),
- pmt::nth(i, vals));
- }
-
- d_extra_size = pmt::serialize_str(d_extra).size();
-
- d_header = pmt::make_dict();
- d_header = pmt::dict_add(d_header, pmt::mp("version"), pmt::mp(METADATA_VERSION));
- d_header = pmt::dict_add(d_header, pmt::mp("rx_rate"), pmt::mp(samp_rate));
- d_header = pmt::dict_add(d_header, pmt::mp("rx_time"), timestamp);
- d_header = pmt::dict_add(d_header, pmt::mp("size"), pmt::from_long(d_itemsize));
- d_header = pmt::dict_add(d_header, pmt::mp("type"), pmt::from_long(type));
- d_header = pmt::dict_add(d_header, pmt::mp("cplx"), complex ? pmt::PMT_T : pmt::PMT_F);
- d_header = pmt::dict_add(d_header, pmt::mp("strt"), pmt::from_uint64(METADATA_HEADER_SIZE+d_extra_size));
- d_header = pmt::dict_add(d_header, mp("bytes"), pmt::from_uint64(0));
-
- do_update();
-
- if(d_state == STATE_DETACHED)
- write_header(d_hdr_fp, d_header, d_extra);
- else
- write_header(d_fp, d_header, d_extra);
+ d_extra_size = pmt::serialize_str(d_extra).size();
+
+ d_header = pmt::make_dict();
+ d_header = pmt::dict_add(d_header, pmt::mp("version"), pmt::mp(METADATA_VERSION));
+ d_header = pmt::dict_add(d_header, pmt::mp("rx_rate"), pmt::mp(samp_rate));
+ d_header = pmt::dict_add(d_header, pmt::mp("rx_time"), timestamp);
+ d_header = pmt::dict_add(d_header, pmt::mp("size"), pmt::from_long(d_itemsize));
+ d_header = pmt::dict_add(d_header, pmt::mp("type"), pmt::from_long(type));
+ d_header =
+ pmt::dict_add(d_header, pmt::mp("cplx"), complex ? pmt::PMT_T : pmt::PMT_F);
+ d_header = pmt::dict_add(
+ d_header, pmt::mp("strt"), pmt::from_uint64(METADATA_HEADER_SIZE + d_extra_size));
+ d_header = pmt::dict_add(d_header, mp("bytes"), pmt::from_uint64(0));
+
+ do_update();
+
+ if (d_state == STATE_DETACHED)
+ write_header(d_hdr_fp, d_header, d_extra);
+ else
+ write_header(d_fp, d_header, d_extra);
+}
+
+file_meta_sink_impl::~file_meta_sink_impl() { close(); }
+
+bool file_meta_sink_impl::open(const std::string& filename)
+{
+ bool ret = true;
+ if (d_state == STATE_DETACHED) {
+ std::string s = filename + ".hdr";
+ ret = _open(&d_new_hdr_fp, s.c_str());
}
- file_meta_sink_impl::~file_meta_sink_impl()
- {
- close();
+ ret = ret && _open(&d_new_fp, filename.c_str());
+ d_updated = true;
+ return ret;
+}
+bool file_meta_sink_impl::_open(FILE** fp, const char* filename)
+{
+ gr::thread::scoped_lock guard(d_setlock); // hold mutex for duration of this function
- }
+ bool ret = true;
+ int fd;
- bool
- file_meta_sink_impl::open(const std::string &filename)
- {
- bool ret = true;
- if(d_state == STATE_DETACHED) {
- std::string s = filename + ".hdr";
- ret = _open(&d_new_hdr_fp, s.c_str());
- }
-
- ret = ret && _open(&d_new_fp, filename.c_str());
- d_updated = true;
- return ret;
+ if ((fd = ::open(filename,
+ O_WRONLY | O_CREAT | O_TRUNC | OUR_O_LARGEFILE | OUR_O_BINARY,
+ 0664)) < 0) {
+ perror(filename);
+ return false;
}
- bool
- file_meta_sink_impl::_open(FILE **fp, const char *filename)
- {
- gr::thread::scoped_lock guard(d_setlock); // hold mutex for duration of this function
+ if (*fp) { // if we've already got a new one open, close it
+ fclose(*fp);
+ fp = 0;
+ }
- bool ret = true;
- int fd;
+ if ((*fp = fdopen(fd, "wb")) == NULL) {
+ perror(filename);
+ ::close(fd); // don't leak file descriptor if fdopen fails.
+ }
- if((fd = ::open(filename,
- O_WRONLY|O_CREAT|O_TRUNC|OUR_O_LARGEFILE|OUR_O_BINARY,
- 0664)) < 0){
- perror(filename);
- return false;
- }
+ ret = fp != 0;
- if(*fp) { // if we've already got a new one open, close it
- fclose(*fp);
- fp = 0;
- }
+ return ret;
+}
- if((*fp = fdopen(fd, "wb")) == NULL) {
- perror(filename);
- ::close(fd); // don't leak file descriptor if fdopen fails.
- }
+void file_meta_sink_impl::close()
+{
+ gr::thread::scoped_lock guard(d_setlock); // hold mutex for duration of this function
+ update_last_header();
- ret = fp != 0;
+ if (d_state == STATE_DETACHED) {
+ if (d_new_hdr_fp) {
+ fclose(d_new_hdr_fp);
+ d_new_hdr_fp = 0;
+ }
+ }
- return ret;
+ if (d_new_fp) {
+ fclose(d_new_fp);
+ d_new_fp = 0;
}
+ d_updated = true;
- void
- file_meta_sink_impl::close()
- {
- gr::thread::scoped_lock guard(d_setlock); // hold mutex for duration of this function
- update_last_header();
-
- if(d_state == STATE_DETACHED) {
- if(d_new_hdr_fp) {
- fclose(d_new_hdr_fp);
- d_new_hdr_fp = 0;
- }
- }
-
- if(d_new_fp) {
- fclose(d_new_fp);
- d_new_fp = 0;
- }
- d_updated = true;
-
- if (d_fp) {
+ if (d_fp) {
fclose(d_fp);
d_fp = 0;
- }
+ }
- if (d_state == STATE_DETACHED) {
+ if (d_state == STATE_DETACHED) {
if (d_hdr_fp) {
- fclose(d_hdr_fp);
- d_hdr_fp = 0;
+ fclose(d_hdr_fp);
+ d_hdr_fp = 0;
}
- }
}
+}
+
+void file_meta_sink_impl::do_update()
+{
+ if (d_updated) {
+ gr::thread::scoped_lock guard(d_setlock); // hold mutex for duration of this block
+ if (d_state == STATE_DETACHED) {
+ if (d_hdr_fp)
+ fclose(d_hdr_fp);
+ d_hdr_fp = d_new_hdr_fp; // install new file pointer
+ d_new_hdr_fp = 0;
+ }
- void
- file_meta_sink_impl::do_update()
- {
- if(d_updated) {
- gr::thread::scoped_lock guard(d_setlock); // hold mutex for duration of this block
- if(d_state == STATE_DETACHED) {
- if(d_hdr_fp)
- fclose(d_hdr_fp);
- d_hdr_fp = d_new_hdr_fp; // install new file pointer
- d_new_hdr_fp = 0;
- }
-
- if(d_fp)
- fclose(d_fp);
- d_fp = d_new_fp; // install new file pointer
- d_new_fp = 0;
-
- d_updated = false;
- }
- }
+ if (d_fp)
+ fclose(d_fp);
+ d_fp = d_new_fp; // install new file pointer
+ d_new_fp = 0;
- void
- file_meta_sink_impl::write_header(FILE *fp, pmt::pmt_t header, pmt::pmt_t extra)
- {
- std::string header_str = pmt::serialize_str(header);
- std::string extra_str = pmt::serialize_str(extra);
-
- if((header_str.size() != METADATA_HEADER_SIZE) && (extra_str.size() != d_extra_size))
- throw std::runtime_error("file_meta_sink: header or extra_dict is wrong size.\n");
-
- size_t nwritten = 0;
- while(nwritten < header_str.size()) {
- std::string sub = header_str.substr(nwritten);
- int count = fwrite(sub.c_str(), sizeof(char), sub.size(), fp);
- nwritten += count;
- if((count == 0) && (ferror(fp))) {
- fclose(fp);
- throw std::runtime_error("file_meta_sink: error writing header to file.\n");
- }
- }
-
- nwritten = 0;
- while(nwritten < extra_str.size()) {
- std::string sub = extra_str.substr(nwritten);
- int count = fwrite(sub.c_str(), sizeof(char), sub.size(), fp);
- nwritten += count;
- if((count == 0) && (ferror(fp))) {
- fclose(fp);
- throw std::runtime_error("file_meta_sink: error writing extra to file.\n");
- }
- }
-
- fflush(fp);
+ d_updated = false;
}
-
- void
- file_meta_sink_impl::update_header(pmt::pmt_t key, pmt::pmt_t value)
- {
- // Special handling caveat to transform rate from radio source into
- // the rate at this sink.
- if(pmt::eq(key, mp("rx_rate"))) {
- d_samp_rate = pmt::to_double(value);
- value = pmt::from_double(d_samp_rate*d_relative_rate);
- }
-
- // If the tag is not part of the standard header, we put it into the
- // extra data, which either updates the current dictionary or adds a
- // new item.
- if(pmt::dict_has_key(d_header, key)) {
- d_header = pmt::dict_add(d_header, key, value);
- }
- else {
- d_extra = pmt::dict_add(d_extra, key, value);
- d_extra_size = pmt::serialize_str(d_extra).size();
- }
+}
+
+void file_meta_sink_impl::write_header(FILE* fp, pmt::pmt_t header, pmt::pmt_t extra)
+{
+ std::string header_str = pmt::serialize_str(header);
+ std::string extra_str = pmt::serialize_str(extra);
+
+ if ((header_str.size() != METADATA_HEADER_SIZE) && (extra_str.size() != d_extra_size))
+ throw std::runtime_error("file_meta_sink: header or extra_dict is wrong size.\n");
+
+ size_t nwritten = 0;
+ while (nwritten < header_str.size()) {
+ std::string sub = header_str.substr(nwritten);
+ int count = fwrite(sub.c_str(), sizeof(char), sub.size(), fp);
+ nwritten += count;
+ if ((count == 0) && (ferror(fp))) {
+ fclose(fp);
+ throw std::runtime_error("file_meta_sink: error writing header to file.\n");
+ }
}
- void
- file_meta_sink_impl::update_last_header()
- {
- if(d_state == STATE_DETACHED) {
- if (d_hdr_fp) update_last_header_detached();
- } else {
- if(d_fp) update_last_header_inline();
- }
+ nwritten = 0;
+ while (nwritten < extra_str.size()) {
+ std::string sub = extra_str.substr(nwritten);
+ int count = fwrite(sub.c_str(), sizeof(char), sub.size(), fp);
+ nwritten += count;
+ if ((count == 0) && (ferror(fp))) {
+ fclose(fp);
+ throw std::runtime_error("file_meta_sink: error writing extra to file.\n");
+ }
}
- void
- file_meta_sink_impl::update_last_header_inline()
- {
- // Update the last header info with the number of samples this
- // block represents.
-
- size_t hdrlen = pmt::to_uint64(pmt::dict_ref(d_header, mp("strt"), pmt::PMT_NIL));
- size_t seg_size = d_itemsize*d_total_seg_size;
- pmt::pmt_t s = pmt::from_uint64(seg_size);
- update_header(mp("bytes"), s);
- update_header(mp("strt"), pmt::from_uint64(METADATA_HEADER_SIZE+d_extra_size));
- fseek(d_fp, -seg_size-hdrlen, SEEK_CUR);
- write_header(d_fp, d_header, d_extra);
- fseek(d_fp, seg_size, SEEK_CUR);
- }
+ fflush(fp);
+}
- void
- file_meta_sink_impl::update_last_header_detached()
- {
- // Update the last header info with the number of samples this
- // block represents.
- size_t hdrlen = pmt::to_uint64(pmt::dict_ref(d_header, mp("strt"), pmt::PMT_NIL));
- size_t seg_size = d_itemsize*d_total_seg_size;
- pmt::pmt_t s = pmt::from_uint64(seg_size);
- update_header(mp("bytes"), s);
- update_header(mp("strt"), pmt::from_uint64(METADATA_HEADER_SIZE+d_extra_size));
- fseek(d_hdr_fp, -hdrlen, SEEK_CUR);
- write_header(d_hdr_fp, d_header, d_extra);
+void file_meta_sink_impl::update_header(pmt::pmt_t key, pmt::pmt_t value)
+{
+ // Special handling caveat to transform rate from radio source into
+ // the rate at this sink.
+ if (pmt::eq(key, mp("rx_rate"))) {
+ d_samp_rate = pmt::to_double(value);
+ value = pmt::from_double(d_samp_rate * d_relative_rate);
}
- void
- file_meta_sink_impl::write_and_update()
- {
- // New header, so set current size of chunk to 0 and start of chunk
- // based on current index + header size.
- //uint64_t loc = get_last_header_loc();
- pmt::pmt_t s = pmt::from_uint64(0);
- update_header(mp("bytes"), s);
-
- // If we have multiple tags on the same offset, this makes
- // sure we just overwrite the same header each time instead
- // of creating a new header per tag.
- s = pmt::from_uint64(METADATA_HEADER_SIZE + d_extra_size);
- update_header(mp("strt"), s);
-
- if(d_state == STATE_DETACHED)
- write_header(d_hdr_fp, d_header, d_extra);
- else
- write_header(d_fp, d_header, d_extra);
+ // If the tag is not part of the standard header, we put it into the
+ // extra data, which either updates the current dictionary or adds a
+ // new item.
+ if (pmt::dict_has_key(d_header, key)) {
+ d_header = pmt::dict_add(d_header, key, value);
+ } else {
+ d_extra = pmt::dict_add(d_extra, key, value);
+ d_extra_size = pmt::serialize_str(d_extra).size();
}
+}
+
+void file_meta_sink_impl::update_last_header()
+{
+ if (d_state == STATE_DETACHED) {
+ if (d_hdr_fp)
+ update_last_header_detached();
+ } else {
+ if (d_fp)
+ update_last_header_inline();
+ }
+}
+
+void file_meta_sink_impl::update_last_header_inline()
+{
+ // Update the last header info with the number of samples this
+ // block represents.
+
+ size_t hdrlen = pmt::to_uint64(pmt::dict_ref(d_header, mp("strt"), pmt::PMT_NIL));
+ size_t seg_size = d_itemsize * d_total_seg_size;
+ pmt::pmt_t s = pmt::from_uint64(seg_size);
+ update_header(mp("bytes"), s);
+ update_header(mp("strt"), pmt::from_uint64(METADATA_HEADER_SIZE + d_extra_size));
+ fseek(d_fp, -seg_size - hdrlen, SEEK_CUR);
+ write_header(d_fp, d_header, d_extra);
+ fseek(d_fp, seg_size, SEEK_CUR);
+}
+
+void file_meta_sink_impl::update_last_header_detached()
+{
+ // Update the last header info with the number of samples this
+ // block represents.
+ size_t hdrlen = pmt::to_uint64(pmt::dict_ref(d_header, mp("strt"), pmt::PMT_NIL));
+ size_t seg_size = d_itemsize * d_total_seg_size;
+ pmt::pmt_t s = pmt::from_uint64(seg_size);
+ update_header(mp("bytes"), s);
+ update_header(mp("strt"), pmt::from_uint64(METADATA_HEADER_SIZE + d_extra_size));
+ fseek(d_hdr_fp, -hdrlen, SEEK_CUR);
+ write_header(d_hdr_fp, d_header, d_extra);
+}
+
+void file_meta_sink_impl::write_and_update()
+{
+ // New header, so set current size of chunk to 0 and start of chunk
+ // based on current index + header size.
+ // uint64_t loc = get_last_header_loc();
+ pmt::pmt_t s = pmt::from_uint64(0);
+ update_header(mp("bytes"), s);
+
+ // If we have multiple tags on the same offset, this makes
+ // sure we just overwrite the same header each time instead
+ // of creating a new header per tag.
+ s = pmt::from_uint64(METADATA_HEADER_SIZE + d_extra_size);
+ update_header(mp("strt"), s);
+
+ if (d_state == STATE_DETACHED)
+ write_header(d_hdr_fp, d_header, d_extra);
+ else
+ write_header(d_fp, d_header, d_extra);
+}
+
+void file_meta_sink_impl::update_rx_time()
+{
+ pmt::pmt_t rx_time = pmt::string_to_symbol("rx_time");
+ pmt::pmt_t r = pmt::dict_ref(d_header, rx_time, pmt::PMT_NIL);
+ uint64_t secs = pmt::to_uint64(pmt::tuple_ref(r, 0));
+ double fracs = pmt::to_double(pmt::tuple_ref(r, 1));
+ double diff = d_total_seg_size / (d_samp_rate * d_relative_rate);
+
+ // std::cerr << "old secs: " << secs << std::endl;
+ // std::cerr << "old fracs: " << fracs << std::endl;
+ // std::cerr << "seg size: " << d_total_seg_size << std::endl;
+ // std::cerr << "diff: " << diff << std::endl;
+
+ fracs += diff;
+ uint64_t new_secs = static_cast<uint64_t>(fracs);
+ secs += new_secs;
+ fracs -= new_secs;
+
+ // std::cerr << "new secs: " << secs << std::endl;
+ // std::cerr << "new fracs: " << fracs << std::endl << std::endl;
+
+ r = pmt::make_tuple(pmt::from_uint64(secs), pmt::from_double(fracs));
+ d_header = pmt::dict_add(d_header, rx_time, r);
+}
+
+int file_meta_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
+
+ uint64_t abs_N = nitems_read(0);
+ uint64_t end_N = abs_N + (uint64_t)(noutput_items);
+ std::vector<tag_t> all_tags;
+ get_tags_in_range(all_tags, 0, abs_N, end_N);
+
+ std::vector<tag_t>::iterator itr;
+ for (itr = all_tags.begin(); itr != all_tags.end(); itr++) {
+ int item_offset = (int)(itr->offset - abs_N);
+
+ // Write date to file up to the next tag location
+ while (nwritten < item_offset) {
+ size_t towrite = std::min(d_max_seg_size - d_total_seg_size,
+ (size_t)(item_offset - nwritten));
+ int count = fwrite(inbuf, d_itemsize, towrite, d_fp);
+ if (count == 0) // FIXME add error handling
+ break;
+ nwritten += count;
+ inbuf += count * d_itemsize;
+
+ d_total_seg_size += count;
+
+ // Only add a new header if we are not at the position of the
+ // next tag
+ if ((d_total_seg_size == d_max_seg_size) && (nwritten < item_offset)) {
+ update_last_header();
+ update_rx_time();
+ write_and_update();
+ d_total_seg_size = 0;
+ }
+ }
- void
- file_meta_sink_impl::update_rx_time()
- {
- pmt::pmt_t rx_time = pmt::string_to_symbol("rx_time");
- pmt::pmt_t r = pmt::dict_ref(d_header, rx_time, pmt::PMT_NIL);
- uint64_t secs = pmt::to_uint64(pmt::tuple_ref(r, 0));
- double fracs = pmt::to_double(pmt::tuple_ref(r, 1));
- double diff = d_total_seg_size / (d_samp_rate*d_relative_rate);
-
- //std::cerr << "old secs: " << secs << std::endl;
- //std::cerr << "old fracs: " << fracs << std::endl;
- //std::cerr << "seg size: " << d_total_seg_size << std::endl;
- //std::cerr << "diff: " << diff << std::endl;
-
- fracs += diff;
- uint64_t new_secs = static_cast<uint64_t>(fracs);
- secs += new_secs;
- fracs -= new_secs;
-
- //std::cerr << "new secs: " << secs << std::endl;
- //std::cerr << "new fracs: " << fracs << std::endl << std::endl;
-
- r = pmt::make_tuple(pmt::from_uint64(secs), pmt::from_double(fracs));
- d_header = pmt::dict_add(d_header, rx_time, r);
+ if (d_total_seg_size > 0) {
+ update_last_header();
+ update_header(itr->key, itr->value);
+ write_and_update();
+ d_total_seg_size = 0;
+ } else {
+ update_header(itr->key, itr->value);
+ update_last_header();
+ }
}
- int
- file_meta_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
-
- uint64_t abs_N = nitems_read(0);
- uint64_t end_N = abs_N + (uint64_t)(noutput_items);
- std::vector<tag_t> all_tags;
- get_tags_in_range(all_tags, 0, abs_N, end_N);
-
- std::vector<tag_t>::iterator itr;
- for(itr = all_tags.begin(); itr != all_tags.end(); itr++) {
- int item_offset = (int)(itr->offset - abs_N);
-
- // Write date to file up to the next tag location
- while(nwritten < item_offset) {
- size_t towrite = std::min(d_max_seg_size - d_total_seg_size,
- (size_t)(item_offset - nwritten));
- int count = fwrite(inbuf, d_itemsize, towrite, d_fp);
- if(count == 0) // FIXME add error handling
- break;
- nwritten += count;
- inbuf += count * d_itemsize;
-
- d_total_seg_size += count;
-
- // Only add a new header if we are not at the position of the
- // next tag
- if((d_total_seg_size == d_max_seg_size) &&
- (nwritten < item_offset)) {
- update_last_header();
- update_rx_time();
- write_and_update();
- d_total_seg_size = 0;
- }
- }
-
- if(d_total_seg_size > 0) {
- update_last_header();
- update_header(itr->key, itr->value);
- write_and_update();
- d_total_seg_size = 0;
- }
- else {
- update_header(itr->key, itr->value);
- update_last_header();
- }
- }
-
- // Finish up the rest of the data after tags
- while(nwritten < noutput_items) {
- size_t towrite = std::min(d_max_seg_size - d_total_seg_size,
- (size_t)(noutput_items - nwritten));
- int count = fwrite(inbuf, d_itemsize, towrite, d_fp);
- if(count == 0) // FIXME add error handling
- break;
- nwritten += count;
- inbuf += count * d_itemsize;
-
- d_total_seg_size += count;
- if(d_total_seg_size == d_max_seg_size) {
- update_last_header();
- update_rx_time();
- write_and_update();
- d_total_seg_size = 0;
- }
- }
-
- if(d_unbuffered)
- fflush(d_fp);
-
- return nwritten;
+ // Finish up the rest of the data after tags
+ while (nwritten < noutput_items) {
+ size_t towrite = std::min(d_max_seg_size - d_total_seg_size,
+ (size_t)(noutput_items - nwritten));
+ int count = fwrite(inbuf, d_itemsize, towrite, d_fp);
+ if (count == 0) // FIXME add error handling
+ break;
+ nwritten += count;
+ inbuf += count * d_itemsize;
+
+ d_total_seg_size += count;
+ if (d_total_seg_size == d_max_seg_size) {
+ update_last_header();
+ update_rx_time();
+ write_and_update();
+ d_total_seg_size = 0;
+ }
}
- } /* namespace blocks */
+ if (d_unbuffered)
+ fflush(d_fp);
+
+ return nwritten;
+}
+
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/file_meta_sink_impl.h b/gr-blocks/lib/file_meta_sink_impl.h
index b274b3e8ed..80ce1f8306 100644
--- a/gr-blocks/lib/file_meta_sink_impl.h
+++ b/gr-blocks/lib/file_meta_sink_impl.h
@@ -29,68 +29,63 @@
using namespace pmt;
namespace gr {
- namespace blocks {
+namespace blocks {
- class file_meta_sink_impl : public file_meta_sink
- {
- private:
- enum meta_state_t {
- STATE_INLINE=0,
- STATE_DETACHED
- };
+class file_meta_sink_impl : public file_meta_sink
+{
+private:
+ enum meta_state_t { STATE_INLINE = 0, STATE_DETACHED };
- size_t d_itemsize;
- double d_samp_rate;
- double d_relative_rate;
- size_t d_max_seg_size;
- size_t d_total_seg_size;
- pmt_t d_header;
- pmt_t d_extra;
- size_t d_extra_size;
- bool d_updated;
- bool d_unbuffered;
+ size_t d_itemsize;
+ double d_samp_rate;
+ double d_relative_rate;
+ size_t d_max_seg_size;
+ size_t d_total_seg_size;
+ pmt_t d_header;
+ pmt_t d_extra;
+ size_t d_extra_size;
+ bool d_updated;
+ bool d_unbuffered;
- FILE *d_new_fp, *d_new_hdr_fp;
- FILE *d_fp, *d_hdr_fp;
- meta_state_t d_state;
+ FILE *d_new_fp, *d_new_hdr_fp;
+ FILE *d_fp, *d_hdr_fp;
+ meta_state_t d_state;
- protected:
- void write_header(FILE *fp, pmt_t header, pmt_t extra);
- void update_header(pmt_t key, pmt_t value);
- void update_last_header();
- void update_last_header_inline();
- void update_last_header_detached();
- void write_and_update();
- void update_rx_time();
+protected:
+ void write_header(FILE* fp, pmt_t header, pmt_t extra);
+ void update_header(pmt_t key, pmt_t value);
+ void update_last_header();
+ void update_last_header_inline();
+ void update_last_header_detached();
+ void write_and_update();
+ void update_rx_time();
- bool _open(FILE **fp, const char *filename);
+ bool _open(FILE** fp, const char* filename);
- public:
- file_meta_sink_impl(size_t itemsize, const std::string &filename,
- double samp_rate=1,
- double relative_rate=1,
- gr_file_types type=GR_FILE_FLOAT,
- bool complex=true,
- size_t max_segment_size=1000000,
- pmt::pmt_t extra_dict=pmt::make_dict(),
- bool detached_header=false);
- ~file_meta_sink_impl();
+public:
+ file_meta_sink_impl(size_t itemsize,
+ const std::string& filename,
+ double samp_rate = 1,
+ double relative_rate = 1,
+ gr_file_types type = GR_FILE_FLOAT,
+ bool complex = true,
+ size_t max_segment_size = 1000000,
+ pmt::pmt_t extra_dict = pmt::make_dict(),
+ bool detached_header = false);
+ ~file_meta_sink_impl();
- bool open(const std::string &filename);
- void close();
- void do_update();
+ bool open(const std::string& filename);
+ void close();
+ void do_update();
- void set_unbuffered(bool unbuffered)
- {
- d_unbuffered = unbuffered;
- }
+ void set_unbuffered(bool unbuffered) { d_unbuffered = unbuffered; }
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_BLOCKS_FILE_META_SINK_IMPL_H */
diff --git a/gr-blocks/lib/file_meta_source_impl.cc b/gr-blocks/lib/file_meta_source_impl.cc
index 3c72e2a003..fcf8228de5 100644
--- a/gr-blocks/lib/file_meta_source_impl.cc
+++ b/gr-blocks/lib/file_meta_source_impl.cc
@@ -38,409 +38,391 @@
#include <io.h>
#endif
#ifdef O_BINARY
-#define OUR_O_BINARY O_BINARY
+#define OUR_O_BINARY O_BINARY
#else
-#define OUR_O_BINARY 0
+#define OUR_O_BINARY 0
#endif
// should be handled via configure
#ifdef O_LARGEFILE
-#define OUR_O_LARGEFILE O_LARGEFILE
+#define OUR_O_LARGEFILE O_LARGEFILE
#else
-#define OUR_O_LARGEFILE 0
+#define OUR_O_LARGEFILE 0
#endif
namespace gr {
- namespace blocks {
-
-
- file_meta_source::sptr
- file_meta_source::make(const std::string &filename,
- bool repeat,
- bool detached_header,
- const std::string &hdr_filename)
- {
- return gnuradio::get_initial_sptr
- (new file_meta_source_impl(filename,
- repeat,
- detached_header,
- hdr_filename));
+namespace blocks {
+
+
+file_meta_source::sptr file_meta_source::make(const std::string& filename,
+ bool repeat,
+ bool detached_header,
+ const std::string& hdr_filename)
+{
+ return gnuradio::get_initial_sptr(
+ new file_meta_source_impl(filename, repeat, detached_header, hdr_filename));
+}
+
+file_meta_source_impl::file_meta_source_impl(const std::string& filename,
+ bool repeat,
+ bool detached_header,
+ const std::string& hdr_filename)
+ : sync_block(
+ "file_meta_source", io_signature::make(0, 0, 0), io_signature::make(1, 1, 1)),
+ d_itemsize(0),
+ d_samp_rate(0),
+ d_seg_size(0),
+ d_updated(false),
+ d_repeat(repeat)
+{
+ d_fp = 0;
+ d_new_fp = 0;
+ d_hdr_fp = 0;
+ d_new_hdr_fp = 0;
+
+ if (detached_header == true) {
+ d_state = STATE_DETACHED;
+ } else
+ d_state = STATE_INLINE;
+
+ if (!open(filename, hdr_filename))
+ throw std::runtime_error("file_meta_source: can't open file\n");
+
+ do_update();
+
+ pmt::pmt_t hdr = pmt::PMT_NIL, extras = pmt::PMT_NIL;
+ if (read_header(hdr, extras)) {
+ parse_header(hdr, 0, d_tags);
+ parse_extras(extras, 0, d_tags);
+ } else
+ throw std::runtime_error("file_meta_source: could not read header.\n");
+
+ // Set output signature based on itemsize info in header
+ set_output_signature(io_signature::make(1, 1, d_itemsize));
+}
+
+file_meta_source_impl::~file_meta_source_impl() { close(); }
+
+bool file_meta_source_impl::read_header(pmt::pmt_t& hdr, pmt::pmt_t& extras)
+{
+ // Select which file handle to read from.
+ FILE* fp;
+ if (d_state == STATE_DETACHED)
+ fp = d_hdr_fp;
+ else
+ fp = d_fp;
+
+ size_t ret;
+ size_t size = 0;
+ std::string str;
+ char* hdr_buffer = new char[METADATA_HEADER_SIZE];
+ while (size < METADATA_HEADER_SIZE) {
+ ret = fread(&hdr_buffer[size], sizeof(char), METADATA_HEADER_SIZE - size, fp);
+ if (ret == 0) {
+ delete[] hdr_buffer;
+ if (feof(fp))
+ return false;
+ else {
+ std::stringstream s;
+ s << "file_meta_source: error occurred extracting header: "
+ << strerror(errno) << std::endl;
+ throw std::runtime_error(s.str());
+ }
+ }
+ size += ret;
}
- file_meta_source_impl::file_meta_source_impl(const std::string &filename,
- bool repeat,
- bool detached_header,
- const std::string &hdr_filename)
- : sync_block("file_meta_source",
- io_signature::make(0, 0, 0),
- io_signature::make(1, 1, 1)),
- d_itemsize(0), d_samp_rate(0),
- d_seg_size(0),
- d_updated(false), d_repeat(repeat)
- {
- d_fp = 0;
- d_new_fp = 0;
- d_hdr_fp = 0;
- d_new_hdr_fp = 0;
-
- if(detached_header == true) {
- d_state = STATE_DETACHED;
- }
- else
- d_state = STATE_INLINE;
-
- if(!open(filename, hdr_filename))
- throw std::runtime_error("file_meta_source: can't open file\n");
-
- do_update();
-
- pmt::pmt_t hdr = pmt::PMT_NIL, extras = pmt::PMT_NIL;
- if(read_header(hdr, extras)) {
- parse_header(hdr, 0, d_tags);
- parse_extras(extras, 0, d_tags);
- }
- else
- throw std::runtime_error("file_meta_source: could not read header.\n");
-
- // Set output signature based on itemsize info in header
- set_output_signature(io_signature::make(1, 1, d_itemsize));
+ // Convert to string or the char array gets confused by the \0
+ str.insert(0, hdr_buffer, METADATA_HEADER_SIZE);
+ hdr = pmt::deserialize_str(str);
+ delete[] hdr_buffer;
+
+ uint64_t seg_start, extra_len = 0;
+ pmt::pmt_t r, dump;
+ if (pmt::dict_has_key(hdr, pmt::string_to_symbol("strt"))) {
+ r = pmt::dict_ref(hdr, pmt::string_to_symbol("strt"), dump);
+ seg_start = pmt::to_uint64(r);
+ extra_len = seg_start - METADATA_HEADER_SIZE;
}
- file_meta_source_impl::~file_meta_source_impl()
- {
- close();
-
+ if (extra_len > 0) {
+ size = 0;
+ hdr_buffer = new char[extra_len];
+ while (size < extra_len) {
+ ret = fread(&hdr_buffer[size], sizeof(char), extra_len - size, fp);
+ if (ret == 0) {
+ delete[] hdr_buffer;
+ if (feof(fp))
+ return false;
+ else {
+ std::stringstream s;
+ s << "file_meta_source: error occurred extracting extras: "
+ << strerror(errno) << std::endl;
+ throw std::runtime_error(s.str());
+ }
+ }
+ size += ret;
+ }
+ str.clear();
+ str.insert(0, hdr_buffer, extra_len);
+ extras = pmt::deserialize_str(str);
+ delete[] hdr_buffer;
}
- bool
- file_meta_source_impl::read_header(pmt::pmt_t &hdr, pmt::pmt_t &extras)
- {
- // Select which file handle to read from.
- FILE *fp;
- if(d_state == STATE_DETACHED)
- fp = d_hdr_fp;
- else
- fp = d_fp;
-
- size_t ret;
- size_t size = 0;
- std::string str;
- char *hdr_buffer = new char[METADATA_HEADER_SIZE];
- while(size < METADATA_HEADER_SIZE) {
- ret = fread(&hdr_buffer[size], sizeof(char), METADATA_HEADER_SIZE-size, fp);
- if(ret == 0) {
- delete [] hdr_buffer;
- if(feof(fp))
- return false;
- else {
- std::stringstream s;
- s << "file_meta_source: error occurred extracting header: "
- << strerror(errno) << std::endl;
- throw std::runtime_error(s.str());
- }
- }
- size += ret;
- }
-
- // Convert to string or the char array gets confused by the \0
- str.insert(0, hdr_buffer, METADATA_HEADER_SIZE);
- hdr = pmt::deserialize_str(str);
- delete [] hdr_buffer;
-
- uint64_t seg_start, extra_len = 0;
- pmt::pmt_t r, dump;
- if(pmt::dict_has_key(hdr, pmt::string_to_symbol("strt"))) {
- r = pmt::dict_ref(hdr, pmt::string_to_symbol("strt"), dump);
- seg_start = pmt::to_uint64(r);
- extra_len = seg_start - METADATA_HEADER_SIZE;
- }
-
- if(extra_len > 0) {
- size = 0;
- hdr_buffer = new char[extra_len];
- while(size < extra_len) {
- ret = fread(&hdr_buffer[size], sizeof(char), extra_len-size, fp);
- if(ret == 0) {
- delete [] hdr_buffer;
- if(feof(fp))
- return false;
- else {
- std::stringstream s;
- s << "file_meta_source: error occurred extracting extras: "
- << strerror(errno) << std::endl;
- throw std::runtime_error(s.str());
- }
- }
- size += ret;
- }
-
- str.clear();
- str.insert(0, hdr_buffer, extra_len);
- extras = pmt::deserialize_str(str);
- delete [] hdr_buffer;
- }
-
- return true;
+ return true;
+}
+
+void file_meta_source_impl::parse_header(pmt::pmt_t hdr,
+ uint64_t offset,
+ std::vector<tag_t>& tags)
+{
+ pmt::pmt_t r, key;
+
+ // GET SAMPLE RATE
+ key = pmt::string_to_symbol("rx_rate");
+ if (pmt::dict_has_key(hdr, key)) {
+ r = pmt::dict_ref(hdr, key, pmt::PMT_NIL);
+ d_samp_rate = pmt::to_double(r);
+
+ tag_t t;
+ t.offset = offset;
+ t.key = key;
+ t.value = r;
+ t.srcid = alias_pmt();
+ tags.push_back(t);
+ } else {
+ throw std::runtime_error("file_meta_source: Could not extract sample rate.\n");
}
- void
- file_meta_source_impl::parse_header(pmt::pmt_t hdr, uint64_t offset,
- std::vector<tag_t> &tags)
- {
- pmt::pmt_t r, key;
-
- // GET SAMPLE RATE
- key = pmt::string_to_symbol("rx_rate");
- if(pmt::dict_has_key(hdr, key)) {
- r = pmt::dict_ref(hdr, key, pmt::PMT_NIL);
- d_samp_rate = pmt::to_double(r);
-
- tag_t t;
- t.offset = offset;
- t.key = key;
- t.value = r;
- t.srcid = alias_pmt();
- tags.push_back(t);
- }
- else {
- throw std::runtime_error("file_meta_source: Could not extract sample rate.\n");
- }
-
- // GET TIME STAMP
- key = pmt::string_to_symbol("rx_time");
- if(pmt::dict_has_key(hdr, key)) {
- d_time_stamp = pmt::dict_ref(hdr, key, pmt::PMT_NIL);
-
- tag_t t;
- t.offset = offset;
- t.key = key;
- t.value = d_time_stamp;
- t.srcid = alias_pmt();
- tags.push_back(t);
- }
- else {
- throw std::runtime_error("file_meta_source: Could not extract time stamp.\n");
- }
-
- // GET ITEM SIZE OF DATA
- if(pmt::dict_has_key(hdr, pmt::string_to_symbol("size"))) {
- d_itemsize = pmt::to_long(pmt::dict_ref(hdr, pmt::string_to_symbol("size"), pmt::PMT_NIL));
- }
- else {
- throw std::runtime_error("file_meta_source: Could not extract item size.\n");
- }
-
- // GET SEGMENT SIZE
- if(pmt::dict_has_key(hdr, pmt::string_to_symbol("bytes"))) {
- d_seg_size = pmt::to_uint64(pmt::dict_ref(hdr, pmt::string_to_symbol("bytes"), pmt::PMT_NIL));
-
- // Convert from bytes to items
- d_seg_size /= d_itemsize;
- }
- else {
- throw std::runtime_error("file_meta_source: Could not extract segment size.\n");
- }
+ // GET TIME STAMP
+ key = pmt::string_to_symbol("rx_time");
+ if (pmt::dict_has_key(hdr, key)) {
+ d_time_stamp = pmt::dict_ref(hdr, key, pmt::PMT_NIL);
+
+ tag_t t;
+ t.offset = offset;
+ t.key = key;
+ t.value = d_time_stamp;
+ t.srcid = alias_pmt();
+ tags.push_back(t);
+ } else {
+ throw std::runtime_error("file_meta_source: Could not extract time stamp.\n");
}
- void
- file_meta_source_impl::parse_extras(pmt::pmt_t extras, uint64_t offset,
- std::vector<tag_t> &tags)
- {
- pmt::pmt_t item, key, val;
-
- size_t nitems = pmt::length(extras);
- for(size_t i = 0; i < nitems; i++) {
- item = pmt::nth(i, extras);
- key = pmt::car(item);
- val = pmt::cdr(item);
-
- tag_t t;
- t.offset = offset;
- t.key = key;
- t.value = val;
- t.srcid = alias_pmt();
- tags.push_back(t);
- }
+ // GET ITEM SIZE OF DATA
+ if (pmt::dict_has_key(hdr, pmt::string_to_symbol("size"))) {
+ d_itemsize =
+ pmt::to_long(pmt::dict_ref(hdr, pmt::string_to_symbol("size"), pmt::PMT_NIL));
+ } else {
+ throw std::runtime_error("file_meta_source: Could not extract item size.\n");
}
- bool
- file_meta_source_impl::open(const std::string &filename,
- const std::string &hdr_filename)
- {
- bool ret = true;
- if(d_state == STATE_DETACHED) {
- std::string s;
- if(hdr_filename == "")
- s = filename + ".hdr";
- else
- s = hdr_filename;
- ret = _open(&d_new_hdr_fp, s.c_str());
- }
-
- ret = ret && _open(&d_new_fp, filename.c_str());
- d_updated = true;
- return ret;
+ // GET SEGMENT SIZE
+ if (pmt::dict_has_key(hdr, pmt::string_to_symbol("bytes"))) {
+ d_seg_size = pmt::to_uint64(
+ pmt::dict_ref(hdr, pmt::string_to_symbol("bytes"), pmt::PMT_NIL));
+
+ // Convert from bytes to items
+ d_seg_size /= d_itemsize;
+ } else {
+ throw std::runtime_error("file_meta_source: Could not extract segment size.\n");
+ }
+}
+
+void file_meta_source_impl::parse_extras(pmt::pmt_t extras,
+ uint64_t offset,
+ std::vector<tag_t>& tags)
+{
+ pmt::pmt_t item, key, val;
+
+ size_t nitems = pmt::length(extras);
+ for (size_t i = 0; i < nitems; i++) {
+ item = pmt::nth(i, extras);
+ key = pmt::car(item);
+ val = pmt::cdr(item);
+
+ tag_t t;
+ t.offset = offset;
+ t.key = key;
+ t.value = val;
+ t.srcid = alias_pmt();
+ tags.push_back(t);
+ }
+}
+
+bool file_meta_source_impl::open(const std::string& filename,
+ const std::string& hdr_filename)
+{
+ bool ret = true;
+ if (d_state == STATE_DETACHED) {
+ std::string s;
+ if (hdr_filename == "")
+ s = filename + ".hdr";
+ else
+ s = hdr_filename;
+ ret = _open(&d_new_hdr_fp, s.c_str());
}
- bool
- file_meta_source_impl::_open(FILE **fp, const char *filename)
- {
- gr::thread::scoped_lock guard(d_setlock); // hold mutex for duration of this function
+ ret = ret && _open(&d_new_fp, filename.c_str());
+ d_updated = true;
+ return ret;
+}
- bool ret = true;
- int fd;
+bool file_meta_source_impl::_open(FILE** fp, const char* filename)
+{
+ gr::thread::scoped_lock guard(d_setlock); // hold mutex for duration of this function
- if((fd = ::open(filename,
- O_RDONLY|OUR_O_LARGEFILE|OUR_O_BINARY)) < 0) {
- perror(filename);
- return false;
- }
+ bool ret = true;
+ int fd;
- if(*fp) { // if we've already got a new one open, close it
- fclose(*fp);
- fp = 0;
- }
+ if ((fd = ::open(filename, O_RDONLY | OUR_O_LARGEFILE | OUR_O_BINARY)) < 0) {
+ perror(filename);
+ return false;
+ }
- if((*fp = fdopen(fd, "rb")) == NULL) {
- perror(filename);
- ::close(fd); // don't leak file descriptor if fdopen fails.
- }
+ if (*fp) { // if we've already got a new one open, close it
+ fclose(*fp);
+ fp = 0;
+ }
- ret = fp != 0;
+ if ((*fp = fdopen(fd, "rb")) == NULL) {
+ perror(filename);
+ ::close(fd); // don't leak file descriptor if fdopen fails.
+ }
+
+ ret = fp != 0;
+
+ return ret;
+}
- return ret;
+void file_meta_source_impl::close()
+{
+ gr::thread::scoped_lock guard(d_setlock); // hold mutex for duration of this function
+ if (d_state == STATE_DETACHED) {
+ if (d_new_hdr_fp) {
+ fclose(d_new_hdr_fp);
+ d_new_hdr_fp = 0;
+ }
}
- void
- file_meta_source_impl::close()
- {
- gr::thread::scoped_lock guard(d_setlock); // hold mutex for duration of this function
- if(d_state == STATE_DETACHED) {
- if(d_new_hdr_fp) {
- fclose(d_new_hdr_fp);
- d_new_hdr_fp = 0;
- }
- }
-
- if(d_new_fp) {
- fclose(d_new_fp);
- d_new_fp = 0;
- }
- d_updated = true;
-
- if (d_fp) {
+ if (d_new_fp) {
+ fclose(d_new_fp);
+ d_new_fp = 0;
+ }
+ d_updated = true;
+
+ if (d_fp) {
fclose(d_fp);
d_fp = 0;
- }
+ }
- if (d_state == STATE_DETACHED) {
+ if (d_state == STATE_DETACHED) {
if (d_hdr_fp) {
- fclose(d_hdr_fp);
- d_hdr_fp = 0;
+ fclose(d_hdr_fp);
+ d_hdr_fp = 0;
}
- }
}
+}
+
+void file_meta_source_impl::do_update()
+{
+ if (d_updated) {
+ gr::thread::scoped_lock guard(d_setlock); // hold mutex for duration of this block
+ if (d_state == STATE_DETACHED) {
+ if (d_hdr_fp)
+ fclose(d_hdr_fp);
+ d_hdr_fp = d_new_hdr_fp; // install new file pointer
+ d_new_hdr_fp = 0;
+ }
+
+ if (d_fp)
+ fclose(d_fp);
+ d_fp = d_new_fp; // install new file pointer
+ d_new_fp = 0;
- void
- file_meta_source_impl::do_update()
- {
- if(d_updated) {
- gr::thread::scoped_lock guard(d_setlock); // hold mutex for duration of this block
- if(d_state == STATE_DETACHED) {
- if(d_hdr_fp)
- fclose(d_hdr_fp);
- d_hdr_fp = d_new_hdr_fp; // install new file pointer
- d_new_hdr_fp = 0;
- }
-
- if(d_fp)
- fclose(d_fp);
- d_fp = d_new_fp; // install new file pointer
- d_new_fp = 0;
-
- d_updated = false;
- }
+ d_updated = false;
}
+}
+
+int file_meta_source_impl::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ // We've reached the end of a segment; parse the next header and get
+ // the new tags to send and set the next segment size.
+ if (d_seg_size == 0) {
+ pmt::pmt_t hdr = pmt::PMT_NIL, extras = pmt::PMT_NIL;
+ if (read_header(hdr, extras)) {
+ parse_header(hdr, nitems_written(0), d_tags);
+ parse_extras(extras, nitems_written(0), d_tags);
+ } else {
+ if (!d_repeat)
+ return -1;
+ else {
+ if (fseek(d_fp, 0, SEEK_SET) == -1) {
+ std::stringstream s;
+ s << "[" << __FILE__ << "]"
+ << " fseek failed" << std::endl;
+ throw std::runtime_error(s.str());
+ }
+ }
+ }
+ }
+
+ char* out = (char*)output_items[0];
+ int i;
+ int seg_size = std::min(noutput_items, (int)d_seg_size);
+ int size = seg_size;
+
+ do_update(); // update d_fp is reqd
+ if (d_fp == NULL)
+ throw std::runtime_error("work with file not open");
+
+ // Push all tags onto the stream and remove them from the vector
+ while (!d_tags.empty()) {
+ add_item_tag(0, d_tags.back());
+ d_tags.pop_back();
+ }
+
+ gr::thread::scoped_lock lock(d_setlock); // hold for the rest of this function
+ while (size) {
+ i = fread(out, d_itemsize, size, d_fp);
+
+ size -= i;
+ d_seg_size -= i;
+ out += i * d_itemsize;
- int
- file_meta_source_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- // We've reached the end of a segment; parse the next header and get
- // the new tags to send and set the next segment size.
- if(d_seg_size == 0) {
- pmt::pmt_t hdr=pmt::PMT_NIL, extras=pmt::PMT_NIL;
- if(read_header(hdr, extras)) {
- parse_header(hdr, nitems_written(0), d_tags);
- parse_extras(extras, nitems_written(0), d_tags);
- }
- else {
- if(!d_repeat)
+ if (size == 0) // done
+ break;
+
+ if (i > 0) // short read, try again
+ continue;
+
+ // We got a zero from fread. This is either EOF or error. In
+ // any event, if we're in repeat mode, seek back to the beginning
+ // of the file and try again, else break
+
+ if (!d_repeat)
+ break;
+
+ if (fseek(d_fp, 0, SEEK_SET) == -1) {
+ std::stringstream s;
+ s << "[" << __FILE__ << "]"
+ << " fseek failed" << std::endl;
+ throw std::runtime_error(s.str());
+ }
+ }
+
+ if (size > 0) { // EOF or error
+ if (size == seg_size) // we didn't read anything; say we're done
return -1;
- else {
- if(fseek(d_fp, 0, SEEK_SET) == -1) {
- std::stringstream s;
- s << "[" << __FILE__ << "]" << " fseek failed" << std::endl;
- throw std::runtime_error(s.str());
- }
- }
- }
- }
-
- char *out = (char*)output_items[0];
- int i;
- int seg_size = std::min(noutput_items, (int)d_seg_size);
- int size = seg_size;
-
- do_update(); // update d_fp is reqd
- if(d_fp == NULL)
- throw std::runtime_error("work with file not open");
-
- // Push all tags onto the stream and remove them from the vector
- while(!d_tags.empty()) {
- add_item_tag(0, d_tags.back());
- d_tags.pop_back();
- }
-
- gr::thread::scoped_lock lock(d_setlock); // hold for the rest of this function
- while(size) {
- i = fread(out, d_itemsize, size, d_fp);
-
- size -= i;
- d_seg_size -= i;
- out += i * d_itemsize;
-
- if(size == 0) // done
- break;
-
- if(i > 0) // short read, try again
- continue;
-
- // We got a zero from fread. This is either EOF or error. In
- // any event, if we're in repeat mode, seek back to the beginning
- // of the file and try again, else break
-
- if(!d_repeat)
- break;
-
- if(fseek(d_fp, 0, SEEK_SET) == -1) {
- std::stringstream s;
- s << "[" << __FILE__ << "]" << " fseek failed" << std::endl;
- throw std::runtime_error(s.str());
- }
- }
-
- if(size > 0) { // EOF or error
- if(size == seg_size) // we didn't read anything; say we're done
- return -1;
- return seg_size - size; // else return partial result
- }
-
- return seg_size;
+ return seg_size - size; // else return partial result
}
- } /* namespace blocks */
+ return seg_size;
+}
+
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/file_meta_source_impl.h b/gr-blocks/lib/file_meta_source_impl.h
index bd7d3c1209..242edce56a 100644
--- a/gr-blocks/lib/file_meta_source_impl.h
+++ b/gr-blocks/lib/file_meta_source_impl.h
@@ -33,56 +33,50 @@
using namespace pmt;
namespace gr {
- namespace blocks {
-
- class file_meta_source_impl : public file_meta_source
- {
- private:
- enum meta_state_t {
- STATE_INLINE=0,
- STATE_DETACHED
- };
-
- size_t d_itemsize;
- double d_samp_rate;
- pmt_t d_time_stamp;
- size_t d_seg_size;
- bool d_updated;
- bool d_repeat;
-
- FILE *d_new_fp, *d_new_hdr_fp;
- FILE *d_fp, *d_hdr_fp;
- meta_state_t d_state;
-
- std::vector<tag_t> d_tags;
-
- protected:
- bool _open(FILE **fp, const char *filename);
- bool read_header(pmt_t &hdr, pmt_t &extras);
- void parse_header(pmt_t hdr, uint64_t offset,
- std::vector<tag_t> &tags);
- void parse_extras(pmt_t extras, uint64_t offset,
- std::vector<tag_t> &tags);
-
- public:
- file_meta_source_impl(const std::string &filename,
- bool repeat=false,
- bool detached_header=false,
- const std::string &hdr_filename="");
-
- ~file_meta_source_impl();
-
- bool open(const std::string &filename,
- const std::string &hdr_filename="");
- void close();
- void do_update();
-
- int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
- };
-
- } /* namespace blocks */
+namespace blocks {
+
+class file_meta_source_impl : public file_meta_source
+{
+private:
+ enum meta_state_t { STATE_INLINE = 0, STATE_DETACHED };
+
+ size_t d_itemsize;
+ double d_samp_rate;
+ pmt_t d_time_stamp;
+ size_t d_seg_size;
+ bool d_updated;
+ bool d_repeat;
+
+ FILE *d_new_fp, *d_new_hdr_fp;
+ FILE *d_fp, *d_hdr_fp;
+ meta_state_t d_state;
+
+ std::vector<tag_t> d_tags;
+
+protected:
+ bool _open(FILE** fp, const char* filename);
+ bool read_header(pmt_t& hdr, pmt_t& extras);
+ void parse_header(pmt_t hdr, uint64_t offset, std::vector<tag_t>& tags);
+ void parse_extras(pmt_t extras, uint64_t offset, std::vector<tag_t>& tags);
+
+public:
+ file_meta_source_impl(const std::string& filename,
+ bool repeat = false,
+ bool detached_header = false,
+ const std::string& hdr_filename = "");
+
+ ~file_meta_source_impl();
+
+ bool open(const std::string& filename, const std::string& hdr_filename = "");
+ void close();
+ void do_update();
+
+ 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_FILE_META_SOURCE_IMPL_H */
diff --git a/gr-blocks/lib/file_sink_base.cc b/gr-blocks/lib/file_sink_base.cc
index 81bc94f351..2b10ba93e5 100644
--- a/gr-blocks/lib/file_sink_base.cc
+++ b/gr-blocks/lib/file_sink_base.cc
@@ -38,98 +38,91 @@
#include <io.h>
#endif
#ifdef O_BINARY
-#define OUR_O_BINARY O_BINARY
+#define OUR_O_BINARY O_BINARY
#else
-#define OUR_O_BINARY 0
+#define OUR_O_BINARY 0
#endif
// should be handled via configure
#ifdef O_LARGEFILE
-#define OUR_O_LARGEFILE O_LARGEFILE
+#define OUR_O_LARGEFILE O_LARGEFILE
#else
-#define OUR_O_LARGEFILE 0
+#define OUR_O_LARGEFILE 0
#endif
namespace gr {
- namespace blocks {
-
- file_sink_base::file_sink_base(const char *filename, bool is_binary, bool append)
- : d_fp(0), d_new_fp(0), d_updated(false), d_is_binary(is_binary), d_append(append)
- {
- if (!open(filename))
- throw std::runtime_error ("can't open file");
- }
-
- file_sink_base::~file_sink_base()
- {
- close();
- if(d_fp) {
+namespace blocks {
+
+file_sink_base::file_sink_base(const char* filename, bool is_binary, bool append)
+ : d_fp(0), d_new_fp(0), d_updated(false), d_is_binary(is_binary), d_append(append)
+{
+ 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)
- {
- gr::thread::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;
- int flags;
- if(d_append) {
- flags = O_WRONLY|O_CREAT|O_APPEND|OUR_O_LARGEFILE|OUR_O_BINARY;
- } else {
- flags = O_WRONLY|O_CREAT|O_TRUNC|OUR_O_LARGEFILE|OUR_O_BINARY;
- }
- if((fd = ::open(filename, flags, 0664)) < 0){
+}
+
+bool file_sink_base::open(const char* filename)
+{
+ gr::thread::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;
+ int flags;
+ if (d_append) {
+ flags = O_WRONLY | O_CREAT | O_APPEND | OUR_O_LARGEFILE | OUR_O_BINARY;
+ } else {
+ flags = O_WRONLY | O_CREAT | O_TRUNC | OUR_O_LARGEFILE | OUR_O_BINARY;
+ }
+ if ((fd = ::open(filename, flags, 0664)) < 0) {
perror(filename);
return false;
- }
- if(d_new_fp) { // if we've already got a new one open, close it
+ }
+ 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;
+ if ((d_new_fp = fdopen(fd, d_is_binary ? "wb" : "w")) == NULL) {
+ perror(filename);
+ ::close(fd); // don't leak file descriptor if fdopen fails.
}
- void
- file_sink_base::close()
- {
- gr::thread::scoped_lock guard(d_mutex); // hold mutex for duration of this function
+ d_updated = true;
+ return d_new_fp != 0;
+}
- if(d_new_fp) {
+void file_sink_base::close()
+{
+ gr::thread::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) {
- gr::thread::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_updated = true;
+}
+
+void file_sink_base::do_update()
+{
+ if (d_updated) {
+ gr::thread::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;
- }
+void file_sink_base::set_unbuffered(bool unbuffered) { d_unbuffered = unbuffered; }
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/file_sink_impl.cc b/gr-blocks/lib/file_sink_impl.cc
index ab36dcd4e6..0f49138359 100644
--- a/gr-blocks/lib/file_sink_impl.cc
+++ b/gr-blocks/lib/file_sink_impl.cc
@@ -29,62 +29,55 @@
#include <stdexcept>
namespace gr {
- namespace blocks {
+namespace blocks {
- file_sink::sptr
- file_sink::make(size_t itemsize, const char *filename, bool append)
- {
- return gnuradio::get_initial_sptr
- (new file_sink_impl(itemsize, filename, append));
- }
+file_sink::sptr file_sink::make(size_t itemsize, const char* filename, bool append)
+{
+ return gnuradio::get_initial_sptr(new file_sink_impl(itemsize, filename, append));
+}
- file_sink_impl::file_sink_impl(size_t itemsize, const char *filename, bool append)
- : sync_block("file_sink",
- io_signature::make(1, 1, itemsize),
- io_signature::make(0, 0, 0)),
- file_sink_base(filename, true, append),
- d_itemsize(itemsize)
- {
- }
+file_sink_impl::file_sink_impl(size_t itemsize, const char* filename, bool append)
+ : sync_block(
+ "file_sink", io_signature::make(1, 1, itemsize), io_signature::make(0, 0, 0)),
+ file_sink_base(filename, true, append),
+ d_itemsize(itemsize)
+{
+}
- file_sink_impl::~file_sink_impl()
- {
- }
+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;
+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
+ do_update(); // update d_fp is reqd
- if(!d_fp)
- return noutput_items; // drop output on the floor
+ if (!d_fp)
+ return noutput_items; // drop output on the floor
- while(nwritten < noutput_items) {
+ 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;
- }
+ 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);
+ if (d_unbuffered)
+ fflush(d_fp);
- return nwritten;
- }
+ return nwritten;
+}
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/file_sink_impl.h b/gr-blocks/lib/file_sink_impl.h
index 9e0c81569b..3671aab540 100644
--- a/gr-blocks/lib/file_sink_impl.h
+++ b/gr-blocks/lib/file_sink_impl.h
@@ -26,23 +26,23 @@
#include <gnuradio/blocks/file_sink.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class file_sink_impl : public file_sink
- {
- private:
- size_t d_itemsize;
+class file_sink_impl : public file_sink
+{
+private:
+ size_t d_itemsize;
- public:
- file_sink_impl(size_t itemsize, const char *filename, bool append=false);
- ~file_sink_impl();
+public:
+ file_sink_impl(size_t itemsize, const char* filename, bool append = false);
+ ~file_sink_impl();
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_GR_FILE_SINK_IMPL_H */
diff --git a/gr-blocks/lib/file_source_impl.cc b/gr-blocks/lib/file_source_impl.cc
index e9ef6a2145..b025f449af 100644
--- a/gr-blocks/lib/file_source_impl.cc
+++ b/gr-blocks/lib/file_source_impl.cc
@@ -40,7 +40,7 @@
#define GR_FSTAT _fstat
#define GR_FILENO _fileno
#define GR_STAT _stat
-#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
+#define S_ISREG(m) (((m)&S_IFMT) == S_IFREG)
#else
#define GR_FSEEK fseeko
#define GR_FTELL ftello
@@ -50,223 +50,227 @@
#endif
namespace gr {
- namespace blocks {
-
- file_source::sptr file_source::make(size_t itemsize, const char *filename, bool repeat,
- uint64_t start_offset_items, uint64_t length_items)
- {
- return gnuradio::get_initial_sptr
- (new file_source_impl(itemsize, filename, repeat, start_offset_items, length_items));
- }
-
- file_source_impl::file_source_impl(size_t itemsize, const char *filename, bool repeat,
- uint64_t start_offset_items, uint64_t length_items)
- : sync_block("file_source",
- io_signature::make(0, 0, 0),
- io_signature::make(1, 1, itemsize)),
- d_itemsize(itemsize),
- d_start_offset_items(start_offset_items), d_length_items(length_items),
- d_fp(0), d_new_fp(0), d_repeat(repeat), d_updated(false),
- d_file_begin(true), d_repeat_cnt(0), d_add_begin_tag(pmt::PMT_NIL)
- {
- open(filename, repeat, start_offset_items, length_items);
- do_update();
-
- std::stringstream str;
- str << name() << unique_id();
- _id = pmt::string_to_symbol(str.str());
- }
-
- file_source_impl::~file_source_impl()
- {
- if(d_fp)
- fclose ((FILE*)d_fp);
- if(d_new_fp)
- fclose ((FILE*)d_new_fp);
- }
-
- bool
- file_source_impl::seek(int64_t seek_point, int whence)
- {
- if (d_seekable) {
+namespace blocks {
+
+file_source::sptr file_source::make(size_t itemsize,
+ const char* filename,
+ bool repeat,
+ uint64_t start_offset_items,
+ uint64_t length_items)
+{
+ return gnuradio::get_initial_sptr(new file_source_impl(
+ itemsize, filename, repeat, start_offset_items, length_items));
+}
+
+file_source_impl::file_source_impl(size_t itemsize,
+ const char* filename,
+ bool repeat,
+ uint64_t start_offset_items,
+ uint64_t length_items)
+ : sync_block(
+ "file_source", io_signature::make(0, 0, 0), io_signature::make(1, 1, itemsize)),
+ d_itemsize(itemsize),
+ d_start_offset_items(start_offset_items),
+ d_length_items(length_items),
+ d_fp(0),
+ d_new_fp(0),
+ d_repeat(repeat),
+ d_updated(false),
+ d_file_begin(true),
+ d_repeat_cnt(0),
+ d_add_begin_tag(pmt::PMT_NIL)
+{
+ open(filename, repeat, start_offset_items, length_items);
+ do_update();
+
+ std::stringstream str;
+ str << name() << unique_id();
+ _id = pmt::string_to_symbol(str.str());
+}
+
+file_source_impl::~file_source_impl()
+{
+ if (d_fp)
+ fclose((FILE*)d_fp);
+ if (d_new_fp)
+ fclose((FILE*)d_new_fp);
+}
+
+bool file_source_impl::seek(int64_t seek_point, int whence)
+{
+ if (d_seekable) {
seek_point += d_start_offset_items;
- switch(whence) {
+ switch (whence) {
case SEEK_SET:
- break;
+ break;
case SEEK_CUR:
- seek_point += (d_length_items - d_items_remaining);
- break;
+ seek_point += (d_length_items - d_items_remaining);
+ break;
case SEEK_END:
- seek_point = d_length_items - seek_point;
- break;
+ seek_point = d_length_items - seek_point;
+ break;
default:
- GR_LOG_WARN(d_logger, "bad seek mode");
- return 0;
+ GR_LOG_WARN(d_logger, "bad seek mode");
+ return 0;
}
- if ((seek_point < (int64_t)d_start_offset_items)
- || (seek_point > (int64_t)(d_start_offset_items+d_length_items-1))) {
- GR_LOG_WARN(d_logger, "bad seek point");
- return 0;
+ if ((seek_point < (int64_t)d_start_offset_items) ||
+ (seek_point > (int64_t)(d_start_offset_items + d_length_items - 1))) {
+ GR_LOG_WARN(d_logger, "bad seek point");
+ return 0;
}
return GR_FSEEK((FILE*)d_fp, seek_point * d_itemsize, SEEK_SET) == 0;
- }
- else {
+ } else {
GR_LOG_WARN(d_logger, "file not seekable");
return 0;
- }
}
+}
- void
- file_source_impl::open(const char *filename, bool repeat,
- uint64_t start_offset_items, uint64_t length_items)
- {
- // obtain exclusive access for duration of this function
- gr::thread::scoped_lock lock(fp_mutex);
+void file_source_impl::open(const char* filename,
+ bool repeat,
+ uint64_t start_offset_items,
+ uint64_t length_items)
+{
+ // obtain exclusive access for duration of this function
+ gr::thread::scoped_lock lock(fp_mutex);
- if(d_new_fp) {
+ if (d_new_fp) {
fclose(d_new_fp);
d_new_fp = 0;
- }
+ }
- if((d_new_fp = fopen (filename, "rb")) == NULL) {
+ if ((d_new_fp = fopen(filename, "rb")) == NULL) {
GR_LOG_ERROR(d_logger, boost::format("%s: %s") % filename % strerror(errno));
throw std::runtime_error("can't open file");
- }
+ }
- struct GR_STAT st;
+ struct GR_STAT st;
- if(GR_FSTAT(GR_FILENO(d_new_fp), &st)) {
+ if (GR_FSTAT(GR_FILENO(d_new_fp), &st)) {
GR_LOG_ERROR(d_logger, boost::format("%s: %s") % filename % strerror(errno));
throw std::runtime_error("can't fstat file");
- }
- if(S_ISREG(st.st_mode)) {
+ }
+ if (S_ISREG(st.st_mode)) {
d_seekable = true;
- }
- else {
+ } else {
d_seekable = false;
- }
+ }
- uint64_t file_size;
+ uint64_t file_size;
- if (d_seekable) {
- //Check to ensure the file will be consumed according to item size
+ if (d_seekable) {
+ // Check to ensure the file will be consumed according to item size
GR_FSEEK(d_new_fp, 0, SEEK_END);
file_size = GR_FTELL(d_new_fp);
// Make sure there will be at least one item available
- if ((file_size / d_itemsize) < (start_offset_items+1)) {
- if (start_offset_items) {
- GR_LOG_WARN(d_logger, "file is too small for start offset");
- }
- else {
- GR_LOG_WARN(d_logger, "file is too small");
- }
- fclose(d_new_fp);
- throw std::runtime_error("file is too small");
+ if ((file_size / d_itemsize) < (start_offset_items + 1)) {
+ if (start_offset_items) {
+ GR_LOG_WARN(d_logger, "file is too small for start offset");
+ } else {
+ GR_LOG_WARN(d_logger, "file is too small");
+ }
+ fclose(d_new_fp);
+ throw std::runtime_error("file is too small");
}
- }
- else {
+ } else {
file_size = INT64_MAX;
- }
+ }
- uint64_t items_available = (file_size / d_itemsize - start_offset_items);
+ uint64_t items_available = (file_size / d_itemsize - start_offset_items);
- // If length is not specified, use the remainder of the file. Check alignment at end.
- if (length_items == 0) {
+ // If length is not specified, use the remainder of the file. Check alignment at end.
+ if (length_items == 0) {
length_items = items_available;
- if (file_size % d_itemsize){
- GR_LOG_WARN(d_logger, "file size is not a multiple of item size");
+ if (file_size % d_itemsize) {
+ GR_LOG_WARN(d_logger, "file size is not a multiple of item size");
}
- }
+ }
- // Check specified length. Warn and use available items instead of throwing an exception.
- if (length_items > items_available) {
+ // Check specified length. Warn and use available items instead of throwing an
+ // exception.
+ if (length_items > items_available) {
length_items = items_available;
GR_LOG_WARN(d_logger, "file too short, will read fewer than requested items");
- }
+ }
- // Rewind to start offset
- if (d_seekable) {
+ // Rewind to start offset
+ if (d_seekable) {
GR_FSEEK(d_new_fp, start_offset_items * d_itemsize, SEEK_SET);
- }
-
- d_updated = true;
- d_repeat = repeat;
- d_start_offset_items = start_offset_items;
- d_length_items = length_items;
- d_items_remaining = length_items;
}
- void
- file_source_impl::close()
- {
- // obtain exclusive access for duration of this function
- gr::thread::scoped_lock lock(fp_mutex);
+ d_updated = true;
+ d_repeat = repeat;
+ d_start_offset_items = start_offset_items;
+ d_length_items = length_items;
+ d_items_remaining = length_items;
+}
- if(d_new_fp != NULL) {
+void file_source_impl::close()
+{
+ // obtain exclusive access for duration of this function
+ gr::thread::scoped_lock lock(fp_mutex);
+
+ if (d_new_fp != NULL) {
fclose(d_new_fp);
d_new_fp = NULL;
- }
- d_updated = true;
}
+ d_updated = true;
+}
- void
- file_source_impl::do_update()
- {
- if(d_updated) {
+void file_source_impl::do_update()
+{
+ if (d_updated) {
gr::thread::scoped_lock lock(fp_mutex); // hold while in scope
- if(d_fp)
- fclose(d_fp);
+ if (d_fp)
+ fclose(d_fp);
- d_fp = d_new_fp; // install new file pointer
+ d_fp = d_new_fp; // install new file pointer
d_new_fp = 0;
d_updated = false;
d_file_begin = true;
- }
}
+}
- void
- file_source_impl::set_begin_tag(pmt::pmt_t val)
- {
- d_add_begin_tag = val;
- }
+void file_source_impl::set_begin_tag(pmt::pmt_t val) { d_add_begin_tag = val; }
- int
- file_source_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- char *o = (char*)output_items[0];
- uint64_t size = noutput_items;
+int file_source_impl::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ char* o = (char*)output_items[0];
+ uint64_t size = noutput_items;
- do_update(); // update d_fp is reqd
- if(d_fp == NULL)
+ do_update(); // update d_fp is reqd
+ if (d_fp == NULL)
throw std::runtime_error("work with file not open");
- gr::thread::scoped_lock lock(fp_mutex); // hold for the rest of this function
+ gr::thread::scoped_lock lock(fp_mutex); // hold for the rest of this function
- // No items remaining - all done
- if (d_items_remaining == 0)
+ // No items remaining - all done
+ if (d_items_remaining == 0)
return WORK_DONE;
- while(size) {
+ while (size) {
// Add stream tag whenever the file starts again
if (d_file_begin && d_add_begin_tag != pmt::PMT_NIL) {
- add_item_tag(0, nitems_written(0) + noutput_items - size,
- d_add_begin_tag, pmt::from_long(d_repeat_cnt), _id);
- d_file_begin = false;
+ add_item_tag(0,
+ nitems_written(0) + noutput_items - size,
+ d_add_begin_tag,
+ pmt::from_long(d_repeat_cnt),
+ _id);
+ d_file_begin = false;
}
uint64_t nitems_to_read = std::min(size, d_items_remaining);
// Since the bounds of the file are known, unexpected nitems is an error
if (nitems_to_read != fread(o, d_itemsize, nitems_to_read, (FILE*)d_fp))
- throw std::runtime_error("fread error");
+ throw std::runtime_error("fread error");
size -= nitems_to_read;
d_items_remaining -= nitems_to_read;
@@ -275,25 +279,25 @@ namespace gr {
// Ran out of items ("EOF")
if (d_items_remaining == 0) {
- // Repeat: rewind and request tag
- if (d_repeat && d_seekable) {
- GR_FSEEK(d_fp, d_start_offset_items * d_itemsize, SEEK_SET);
- d_items_remaining = d_length_items;
- if (d_add_begin_tag != pmt::PMT_NIL) {
- d_file_begin = true;
- d_repeat_cnt++;
+ // Repeat: rewind and request tag
+ if (d_repeat && d_seekable) {
+ GR_FSEEK(d_fp, d_start_offset_items * d_itemsize, SEEK_SET);
+ d_items_remaining = d_length_items;
+ if (d_add_begin_tag != pmt::PMT_NIL) {
+ d_file_begin = true;
+ d_repeat_cnt++;
+ }
}
- }
- // No repeat: return
- else {
- break;
- }
+ // No repeat: return
+ else {
+ break;
+ }
}
- }
-
- return (noutput_items - size);
}
- } /* namespace blocks */
+ return (noutput_items - size);
+}
+
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/file_source_impl.h b/gr-blocks/lib/file_source_impl.h
index 6ce87cf7c7..bec21ea8ab 100644
--- a/gr-blocks/lib/file_source_impl.h
+++ b/gr-blocks/lib/file_source_impl.h
@@ -27,46 +27,49 @@
#include <boost/thread/mutex.hpp>
namespace gr {
- namespace blocks {
+namespace blocks {
- class BLOCKS_API file_source_impl : public file_source
- {
- private:
- size_t d_itemsize;
- uint64_t d_start_offset_items;
- uint64_t d_length_items;
- uint64_t d_items_remaining;
- FILE *d_fp;
- FILE *d_new_fp;
- bool d_repeat;
- bool d_updated;
- bool d_file_begin;
- bool d_seekable;
- long d_repeat_cnt;
- pmt::pmt_t d_add_begin_tag;
+class BLOCKS_API file_source_impl : public file_source
+{
+private:
+ size_t d_itemsize;
+ uint64_t d_start_offset_items;
+ uint64_t d_length_items;
+ uint64_t d_items_remaining;
+ FILE* d_fp;
+ FILE* d_new_fp;
+ bool d_repeat;
+ bool d_updated;
+ bool d_file_begin;
+ bool d_seekable;
+ long d_repeat_cnt;
+ pmt::pmt_t d_add_begin_tag;
- boost::mutex fp_mutex;
- pmt::pmt_t _id;
+ boost::mutex fp_mutex;
+ pmt::pmt_t _id;
- void do_update();
+ void do_update();
- public:
- file_source_impl(size_t itemsize, const char *filename, bool repeat,
- uint64_t offset, uint64_t len);
- ~file_source_impl();
+public:
+ file_source_impl(size_t itemsize,
+ const char* filename,
+ bool repeat,
+ uint64_t offset,
+ uint64_t len);
+ ~file_source_impl();
- bool seek(int64_t seek_point, int whence);
- void open(const char *filename, bool repeat, uint64_t offset, uint64_t len);
- void close();
+ bool seek(int64_t seek_point, int whence);
+ void open(const char* filename, bool repeat, uint64_t offset, uint64_t len);
+ void close();
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
- void set_begin_tag(pmt::pmt_t val);
- };
+ void set_begin_tag(pmt::pmt_t val);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_BLOCKS_FILE_SOURCE_IMPL_H */
diff --git a/gr-blocks/lib/float_array_to_int.cc b/gr-blocks/lib/float_array_to_int.cc
index 66cae4b2d2..dbdae45201 100644
--- a/gr-blocks/lib/float_array_to_int.cc
+++ b/gr-blocks/lib/float_array_to_int.cc
@@ -34,18 +34,17 @@ using std::int64_t;
#include <stdint.h>
#endif
-static const int64_t MAX_INT = INT32_MAX;
-static const int64_t MIN_INT = INT32_MIN;
+static const int64_t MAX_INT = INT32_MAX;
+static const int64_t MIN_INT = INT32_MIN;
-void
-float_array_to_int(const float *in, int *out, float scale, int nsamples)
+void float_array_to_int(const float* in, int* out, float scale, int nsamples)
{
- for (int i = 0; i < nsamples; i++){
- int64_t r = llrintf(scale * in[i]);
- if (r < MIN_INT)
- r = MIN_INT;
- else if (r > MAX_INT)
- r = MAX_INT;
- out[i] = static_cast<int>(r);
- }
+ for (int i = 0; i < nsamples; i++) {
+ int64_t r = llrintf(scale * in[i]);
+ if (r < MIN_INT)
+ r = MIN_INT;
+ else if (r > MAX_INT)
+ r = MAX_INT;
+ out[i] = static_cast<int>(r);
+ }
}
diff --git a/gr-blocks/lib/float_array_to_int.h b/gr-blocks/lib/float_array_to_int.h
index 6a528d797a..717dc1d143 100644
--- a/gr-blocks/lib/float_array_to_int.h
+++ b/gr-blocks/lib/float_array_to_int.h
@@ -28,6 +28,6 @@
/*!
* convert array of floats to int with rounding and saturation.
*/
-BLOCKS_API void float_array_to_int (const float *in, int *out, float scale, int nsamples);
+BLOCKS_API void float_array_to_int(const float* in, int* out, float scale, int nsamples);
#endif /* INCLUDED_BLOCKS_FLOAT_ARRAY_TO_INT_H */
diff --git a/gr-blocks/lib/float_array_to_uchar.cc b/gr-blocks/lib/float_array_to_uchar.cc
index 54a66f60e1..4aaa2630dd 100644
--- a/gr-blocks/lib/float_array_to_uchar.cc
+++ b/gr-blocks/lib/float_array_to_uchar.cc
@@ -29,17 +29,16 @@
#include <math.h>
static const int MIN_UCHAR = 0;
-static const int MAX_UCHAR = 255;
+static const int MAX_UCHAR = 255;
-void
-float_array_to_uchar(const float *in, unsigned char *out, int nsamples)
+void float_array_to_uchar(const float* in, unsigned char* out, int nsamples)
{
- for (int i = 0; i < nsamples; i++){
- long int r = (long int) rint (in[i]);
- if (r < MIN_UCHAR)
- r = MIN_UCHAR;
- else if (r > MAX_UCHAR)
- r = MAX_UCHAR;
- out[i] = r;
- }
+ for (int i = 0; i < nsamples; i++) {
+ long int r = (long int)rint(in[i]);
+ if (r < MIN_UCHAR)
+ r = MIN_UCHAR;
+ else if (r > MAX_UCHAR)
+ r = MAX_UCHAR;
+ out[i] = r;
+ }
}
diff --git a/gr-blocks/lib/float_array_to_uchar.h b/gr-blocks/lib/float_array_to_uchar.h
index 2cc3993d50..97e2412d84 100644
--- a/gr-blocks/lib/float_array_to_uchar.h
+++ b/gr-blocks/lib/float_array_to_uchar.h
@@ -28,6 +28,6 @@
/*!
* convert array of floats to unsigned chars with rounding and saturation.
*/
-BLOCKS_API void float_array_to_uchar (const float *in, unsigned char *out, int nsamples);
+BLOCKS_API void float_array_to_uchar(const float* in, unsigned char* out, int nsamples);
#endif /* INCLUDED_FLOAT_ARRAY_TO_UCHAR_H */
diff --git a/gr-blocks/lib/float_to_char_impl.cc b/gr-blocks/lib/float_to_char_impl.cc
index 342187d3ee..c54c023c6e 100644
--- a/gr-blocks/lib/float_to_char_impl.cc
+++ b/gr-blocks/lib/float_to_char_impl.cc
@@ -29,36 +29,35 @@
#include <volk/volk.h>
namespace gr {
- namespace blocks {
-
- float_to_char::sptr float_to_char::make(size_t vlen, float scale)
- {
- return gnuradio::get_initial_sptr(new float_to_char_impl(vlen, scale));
- }
-
- float_to_char_impl::float_to_char_impl(size_t vlen, float scale)
- : sync_block("float_to_char",
- io_signature::make (1, 1, sizeof(float)*vlen),
- io_signature::make (1, 1, sizeof(char)*vlen)),
- d_vlen(vlen), d_scale(scale)
- {
- const int alignment_multiple =
- volk_get_alignment() / sizeof(char);
- set_alignment(std::max(1, alignment_multiple));
- }
-
- int
- float_to_char_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];
- int8_t *out = (int8_t *) output_items[0];
-
- volk_32f_s32f_convert_8i(out, in, d_scale, d_vlen*noutput_items);
-
- return noutput_items;
- }
-
- } /* namespace blocks */
-}/* namespace gr */
+namespace blocks {
+
+float_to_char::sptr float_to_char::make(size_t vlen, float scale)
+{
+ return gnuradio::get_initial_sptr(new float_to_char_impl(vlen, scale));
+}
+
+float_to_char_impl::float_to_char_impl(size_t vlen, float scale)
+ : sync_block("float_to_char",
+ io_signature::make(1, 1, sizeof(float) * vlen),
+ io_signature::make(1, 1, sizeof(char) * vlen)),
+ d_vlen(vlen),
+ d_scale(scale)
+{
+ const int alignment_multiple = volk_get_alignment() / sizeof(char);
+ set_alignment(std::max(1, alignment_multiple));
+}
+
+int float_to_char_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];
+ int8_t* out = (int8_t*)output_items[0];
+
+ volk_32f_s32f_convert_8i(out, in, d_scale, d_vlen * noutput_items);
+
+ return noutput_items;
+}
+
+} /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/float_to_char_impl.h b/gr-blocks/lib/float_to_char_impl.h
index 99376990c5..d7b7c3b1d6 100644
--- a/gr-blocks/lib/float_to_char_impl.h
+++ b/gr-blocks/lib/float_to_char_impl.h
@@ -26,25 +26,25 @@
#include <gnuradio/blocks/float_to_char.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class BLOCKS_API float_to_char_impl : public float_to_char
- {
- size_t d_vlen;
- float d_scale;
+class BLOCKS_API float_to_char_impl : public float_to_char
+{
+ size_t d_vlen;
+ float d_scale;
- public:
- float_to_char_impl(size_t vlen, float scale);
+public:
+ float_to_char_impl(size_t vlen, float scale);
- virtual float scale() const { return d_scale; }
- virtual void set_scale(float scale) { d_scale = scale; }
+ virtual float scale() const { return d_scale; }
+ virtual void set_scale(float scale) { d_scale = scale; }
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/float_to_complex_impl.cc b/gr-blocks/lib/float_to_complex_impl.cc
index d66d05a327..dc2a8d3491 100644
--- a/gr-blocks/lib/float_to_complex_impl.cc
+++ b/gr-blocks/lib/float_to_complex_impl.cc
@@ -29,55 +29,50 @@
#include <volk/volk.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- float_to_complex::sptr
- float_to_complex::make(size_t vlen)
- {
- return gnuradio::get_initial_sptr
- (new float_to_complex_impl(vlen));
- }
-
- float_to_complex_impl::float_to_complex_impl(size_t vlen)
- : sync_block("float_to_complex",
- io_signature::make(1, 2, sizeof(float)*vlen),
- io_signature::make(1, 1, sizeof(gr_complex)*vlen)),
- d_vlen(vlen)
- {
- const int alignment_multiple =
- volk_get_alignment() / sizeof(float);
- set_alignment(std::max(1,alignment_multiple));
- }
+float_to_complex::sptr float_to_complex::make(size_t vlen)
+{
+ return gnuradio::get_initial_sptr(new float_to_complex_impl(vlen));
+}
- int
- float_to_complex_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- float *r = (float *) input_items[0];
- gr_complex *out = (gr_complex *) output_items[0];
+float_to_complex_impl::float_to_complex_impl(size_t vlen)
+ : sync_block("float_to_complex",
+ io_signature::make(1, 2, sizeof(float) * vlen),
+ io_signature::make(1, 1, sizeof(gr_complex) * vlen)),
+ d_vlen(vlen)
+{
+ const int alignment_multiple = volk_get_alignment() / sizeof(float);
+ set_alignment(std::max(1, alignment_multiple));
+}
- switch (input_items.size ()){
- case 1:
- for (size_t j = 0; j < noutput_items*d_vlen; j++)
- out[j] = gr_complex (r[j], 0);
- break;
+int float_to_complex_impl::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ float* r = (float*)input_items[0];
+ gr_complex* out = (gr_complex*)output_items[0];
- case 2:
- {
- //for (size_t j = 0; j < noutput_items*d_vlen; j++)
- // out[j] = gr_complex (r[j], i[j]);
- float *i = (float *) input_items[1];
- volk_32f_x2_interleave_32fc(out, r, i, noutput_items*d_vlen);
- break;
- }
+ switch (input_items.size()) {
+ case 1:
+ for (size_t j = 0; j < noutput_items * d_vlen; j++)
+ out[j] = gr_complex(r[j], 0);
+ break;
- default:
- assert (0);
- }
+ case 2: {
+ // for (size_t j = 0; j < noutput_items*d_vlen; j++)
+ // out[j] = gr_complex (r[j], i[j]);
+ float* i = (float*)input_items[1];
+ volk_32f_x2_interleave_32fc(out, r, i, noutput_items * d_vlen);
+ break;
+ }
- return noutput_items;
+ default:
+ assert(0);
}
- } /* namespace blocks */
-}/* namespace gr */
+ return noutput_items;
+}
+
+} /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/float_to_complex_impl.h b/gr-blocks/lib/float_to_complex_impl.h
index 6e14aba4e5..9219fa1516 100644
--- a/gr-blocks/lib/float_to_complex_impl.h
+++ b/gr-blocks/lib/float_to_complex_impl.h
@@ -26,21 +26,21 @@
#include <gnuradio/blocks/float_to_complex.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class BLOCKS_API float_to_complex_impl : public float_to_complex
- {
- size_t d_vlen;
+class BLOCKS_API float_to_complex_impl : public float_to_complex
+{
+ size_t d_vlen;
- public:
- float_to_complex_impl(size_t vlen);
+public:
+ float_to_complex_impl(size_t vlen);
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/float_to_int_impl.cc b/gr-blocks/lib/float_to_int_impl.cc
index 0dbef975bb..4c8ae689d8 100644
--- a/gr-blocks/lib/float_to_int_impl.cc
+++ b/gr-blocks/lib/float_to_int_impl.cc
@@ -30,49 +30,48 @@
#include <volk/volk.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- float_to_int::sptr float_to_int::make(size_t vlen, float scale)
- {
- return gnuradio::get_initial_sptr(new float_to_int_impl(vlen, scale));
- }
+float_to_int::sptr float_to_int::make(size_t vlen, float scale)
+{
+ return gnuradio::get_initial_sptr(new float_to_int_impl(vlen, scale));
+}
- float_to_int_impl::float_to_int_impl(size_t vlen, float scale)
- : sync_block("float_to_int",
- io_signature::make (1, 1, sizeof(float)*vlen),
- io_signature::make (1, 1, sizeof(int)*vlen)),
- d_vlen(vlen), d_scale(scale)
- {
- const int alignment_multiple =
- volk_get_alignment() / sizeof(int);
- set_alignment(std::max(1, alignment_multiple));
- }
+float_to_int_impl::float_to_int_impl(size_t vlen, float scale)
+ : sync_block("float_to_int",
+ io_signature::make(1, 1, sizeof(float) * vlen),
+ io_signature::make(1, 1, sizeof(int) * vlen)),
+ d_vlen(vlen),
+ d_scale(scale)
+{
+ const int alignment_multiple = volk_get_alignment() / sizeof(int);
+ set_alignment(std::max(1, alignment_multiple));
+}
- int
- float_to_int_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- // Disable the Volk for now. There is a problem for large 32-bit ints that
- // are not properly represented by the precisions of a single float, which
- // can cause wrapping from large, positive numbers to negative.
- // In gri_float_to_int, the value is first promoted to a 64-bit
- // value, clipped, then converted to a float.
+int float_to_int_impl::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ // Disable the Volk for now. There is a problem for large 32-bit ints that
+ // are not properly represented by the precisions of a single float, which
+ // can cause wrapping from large, positive numbers to negative.
+ // In gri_float_to_int, the value is first promoted to a 64-bit
+ // value, clipped, then converted to a float.
#if 0
const float *in = (const float *) input_items[0];
int32_t *out = (int32_t *) output_items[0];
volk_32f_s32f_convert_32i(out, in, d_scale, d_vlen*noutput_items);
#else
- const float *in = (const float *) input_items[0];
- int *out = (int *) output_items[0];
+ const float* in = (const float*)input_items[0];
+ int* out = (int*)output_items[0];
- float_array_to_int (in, out, d_scale, d_vlen*noutput_items);
+ float_array_to_int(in, out, d_scale, d_vlen * noutput_items);
#endif
- return noutput_items;
- }
+ return noutput_items;
+}
- } /* namespace blocks */
-}/* namespace gr */
+} /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/float_to_int_impl.h b/gr-blocks/lib/float_to_int_impl.h
index 7062672738..4bc237313c 100644
--- a/gr-blocks/lib/float_to_int_impl.h
+++ b/gr-blocks/lib/float_to_int_impl.h
@@ -26,25 +26,25 @@
#include <gnuradio/blocks/float_to_int.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class BLOCKS_API float_to_int_impl : public float_to_int
- {
- size_t d_vlen;
- float d_scale;
+class BLOCKS_API float_to_int_impl : public float_to_int
+{
+ size_t d_vlen;
+ float d_scale;
- public:
- float_to_int_impl(size_t vlen, float scale);
+public:
+ float_to_int_impl(size_t vlen, float scale);
- virtual float scale() const { return d_scale; }
- virtual void set_scale(float scale) { d_scale = scale; }
+ virtual float scale() const { return d_scale; }
+ virtual void set_scale(float scale) { d_scale = scale; }
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/float_to_short_impl.cc b/gr-blocks/lib/float_to_short_impl.cc
index 791519002f..a9eef40292 100644
--- a/gr-blocks/lib/float_to_short_impl.cc
+++ b/gr-blocks/lib/float_to_short_impl.cc
@@ -29,36 +29,35 @@
#include <volk/volk.h>
namespace gr {
- namespace blocks {
-
- float_to_short::sptr float_to_short::make(size_t vlen, float scale)
- {
- return gnuradio::get_initial_sptr(new float_to_short_impl(vlen, scale));
- }
-
- float_to_short_impl::float_to_short_impl(size_t vlen, float scale)
- : sync_block("float_to_short",
- io_signature::make (1, 1, sizeof(float)*vlen),
- io_signature::make (1, 1, sizeof(short)*vlen)),
- d_vlen(vlen), d_scale(scale)
- {
- const int alignment_multiple =
- volk_get_alignment() / sizeof(short);
- set_alignment(std::max(1, alignment_multiple));
- }
-
- int
- float_to_short_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];
- short *out = (short *) output_items[0];
-
- volk_32f_s32f_convert_16i(out, in, d_scale, d_vlen*noutput_items);
-
- return noutput_items;
- }
-
- } /* namespace blocks */
-}/* namespace gr */
+namespace blocks {
+
+float_to_short::sptr float_to_short::make(size_t vlen, float scale)
+{
+ return gnuradio::get_initial_sptr(new float_to_short_impl(vlen, scale));
+}
+
+float_to_short_impl::float_to_short_impl(size_t vlen, float scale)
+ : sync_block("float_to_short",
+ io_signature::make(1, 1, sizeof(float) * vlen),
+ io_signature::make(1, 1, sizeof(short) * vlen)),
+ d_vlen(vlen),
+ d_scale(scale)
+{
+ const int alignment_multiple = volk_get_alignment() / sizeof(short);
+ set_alignment(std::max(1, alignment_multiple));
+}
+
+int float_to_short_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];
+ short* out = (short*)output_items[0];
+
+ volk_32f_s32f_convert_16i(out, in, d_scale, d_vlen * noutput_items);
+
+ return noutput_items;
+}
+
+} /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/float_to_short_impl.h b/gr-blocks/lib/float_to_short_impl.h
index fb88092937..c6dbc0a8fb 100644
--- a/gr-blocks/lib/float_to_short_impl.h
+++ b/gr-blocks/lib/float_to_short_impl.h
@@ -26,25 +26,25 @@
#include <gnuradio/blocks/float_to_short.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class BLOCKS_API float_to_short_impl : public float_to_short
- {
- size_t d_vlen;
- float d_scale;
+class BLOCKS_API float_to_short_impl : public float_to_short
+{
+ size_t d_vlen;
+ float d_scale;
- public:
- float_to_short_impl(size_t vlen, float scale);
+public:
+ float_to_short_impl(size_t vlen, float scale);
- virtual float scale() const { return d_scale; }
- virtual void set_scale(float scale) { d_scale = scale; }
+ virtual float scale() const { return d_scale; }
+ virtual void set_scale(float scale) { d_scale = scale; }
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/float_to_uchar_impl.cc b/gr-blocks/lib/float_to_uchar_impl.cc
index eccd36da78..ad75df9eff 100644
--- a/gr-blocks/lib/float_to_uchar_impl.cc
+++ b/gr-blocks/lib/float_to_uchar_impl.cc
@@ -29,32 +29,31 @@
#include <gnuradio/io_signature.h>
namespace gr {
- namespace blocks {
-
- float_to_uchar::sptr float_to_uchar::make()
- {
- return gnuradio::get_initial_sptr(new float_to_uchar_impl());
- }
-
- float_to_uchar_impl::float_to_uchar_impl()
- : sync_block("float_to_uchar",
- io_signature::make (1, 1, sizeof(float)),
- io_signature::make (1, 1, sizeof(unsigned char)))
- {
- }
-
- int
- float_to_uchar_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];
-
- float_array_to_uchar(in, out, noutput_items);
-
- return noutput_items;
- }
-
- } /* namespace blocks */
-}/* namespace gr */
+namespace blocks {
+
+float_to_uchar::sptr float_to_uchar::make()
+{
+ return gnuradio::get_initial_sptr(new float_to_uchar_impl());
+}
+
+float_to_uchar_impl::float_to_uchar_impl()
+ : sync_block("float_to_uchar",
+ io_signature::make(1, 1, sizeof(float)),
+ io_signature::make(1, 1, sizeof(unsigned char)))
+{
+}
+
+int float_to_uchar_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];
+
+ float_array_to_uchar(in, out, noutput_items);
+
+ return noutput_items;
+}
+
+} /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/float_to_uchar_impl.h b/gr-blocks/lib/float_to_uchar_impl.h
index 1e60ae8ebd..f555a6b8be 100644
--- a/gr-blocks/lib/float_to_uchar_impl.h
+++ b/gr-blocks/lib/float_to_uchar_impl.h
@@ -26,19 +26,19 @@
#include <gnuradio/blocks/float_to_uchar.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class BLOCKS_API float_to_uchar_impl : public float_to_uchar
- {
- public:
- float_to_uchar_impl();
+class BLOCKS_API float_to_uchar_impl : public float_to_uchar
+{
+public:
+ float_to_uchar_impl();
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/head_impl.cc b/gr-blocks/lib/head_impl.cc
index 4c33f9f08e..83dc855f55 100644
--- a/gr-blocks/lib/head_impl.cc
+++ b/gr-blocks/lib/head_impl.cc
@@ -29,47 +29,41 @@
#include <string.h>
namespace gr {
- namespace blocks {
+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::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)
- : sync_block("head",
- io_signature::make(1, 1, sizeof_stream_item),
- io_signature::make(1, 1, sizeof_stream_item)),
- d_nitems(nitems), d_ncopied_items(0)
- {
- }
+head_impl::head_impl(size_t sizeof_stream_item, uint64_t nitems)
+ : sync_block("head",
+ io_signature::make(1, 1, sizeof_stream_item),
+ io_signature::make(1, 1, sizeof_stream_item)),
+ d_nitems(nitems),
+ d_ncopied_items(0)
+{
+}
- head_impl::~head_impl()
- {
- }
+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!
+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);
+ unsigned n = std::min(d_nitems - d_ncopied_items, (uint64_t)noutput_items);
- if(n == 0)
+ if (n == 0)
return 0;
- memcpy(output_items[0], input_items[0],
- n * input_signature()->sizeof_stream_item (0));
- d_ncopied_items += n;
+ memcpy(output_items[0], input_items[0], n * input_signature()->sizeof_stream_item(0));
+ d_ncopied_items += n;
- return n;
- }
+ return n;
+}
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/head_impl.h b/gr-blocks/lib/head_impl.h
index 4a2c33864b..0925bbdd26 100644
--- a/gr-blocks/lib/head_impl.h
+++ b/gr-blocks/lib/head_impl.h
@@ -26,27 +26,27 @@
#include <gnuradio/blocks/head.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class head_impl : public head
- {
- private:
- uint64_t d_nitems;
- uint64_t d_ncopied_items;
+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();
+public:
+ head_impl(size_t sizeof_stream_item, uint64_t nitems);
+ ~head_impl();
- void reset() { d_ncopied_items = 0; }
- void set_length(uint64_t nitems) { d_nitems = nitems; }
+ void reset() { d_ncopied_items = 0; }
+ void set_length(uint64_t nitems) { d_nitems = nitems; }
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_GR_HEAD_IMPL_H */
diff --git a/gr-blocks/lib/int_to_float_impl.cc b/gr-blocks/lib/int_to_float_impl.cc
index 33b59e9f4b..64338ce1e5 100644
--- a/gr-blocks/lib/int_to_float_impl.cc
+++ b/gr-blocks/lib/int_to_float_impl.cc
@@ -29,35 +29,34 @@
#include <volk/volk.h>
namespace gr {
- namespace blocks {
-
- int_to_float::sptr int_to_float::make(size_t vlen, float scale)
- {
- return gnuradio::get_initial_sptr(new int_to_float_impl(vlen, scale));
- }
-
- int_to_float_impl::int_to_float_impl(size_t vlen, float scale)
- : sync_block("int_to_float",
- io_signature::make (1, 1, sizeof(int32_t)*vlen),
- io_signature::make (1, 1, sizeof(float)*vlen)),
- d_vlen(vlen), d_scale(scale)
- {
- const int alignment_multiple =
- volk_get_alignment() / sizeof(float);
- set_alignment(std::max(1, alignment_multiple));
- }
-
- int
- int_to_float_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- const int32_t *in = (const int32_t *) input_items[0];
- float *out = (float *) output_items[0];
-
- volk_32i_s32f_convert_32f(out, in, d_scale, d_vlen*noutput_items);
-
- return noutput_items;
- }
- } /* namespace blocks */
-}/* namespace gr */
+namespace blocks {
+
+int_to_float::sptr int_to_float::make(size_t vlen, float scale)
+{
+ return gnuradio::get_initial_sptr(new int_to_float_impl(vlen, scale));
+}
+
+int_to_float_impl::int_to_float_impl(size_t vlen, float scale)
+ : sync_block("int_to_float",
+ io_signature::make(1, 1, sizeof(int32_t) * vlen),
+ io_signature::make(1, 1, sizeof(float) * vlen)),
+ d_vlen(vlen),
+ d_scale(scale)
+{
+ const int alignment_multiple = volk_get_alignment() / sizeof(float);
+ set_alignment(std::max(1, alignment_multiple));
+}
+
+int int_to_float_impl::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ const int32_t* in = (const int32_t*)input_items[0];
+ float* out = (float*)output_items[0];
+
+ volk_32i_s32f_convert_32f(out, in, d_scale, d_vlen * noutput_items);
+
+ return noutput_items;
+}
+} /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/int_to_float_impl.h b/gr-blocks/lib/int_to_float_impl.h
index 53942b1488..6e09585329 100644
--- a/gr-blocks/lib/int_to_float_impl.h
+++ b/gr-blocks/lib/int_to_float_impl.h
@@ -26,25 +26,25 @@
#include <gnuradio/blocks/int_to_float.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class BLOCKS_API int_to_float_impl : public int_to_float
- {
- size_t d_vlen;
- float d_scale;
+class BLOCKS_API int_to_float_impl : public int_to_float
+{
+ size_t d_vlen;
+ float d_scale;
- public:
- int_to_float_impl(size_t vlen, float scale);
+public:
+ int_to_float_impl(size_t vlen, float scale);
- virtual float scale() const { return d_scale; }
- virtual void set_scale(float scale) { d_scale = scale; }
+ virtual float scale() const { return d_scale; }
+ virtual void set_scale(float scale) { d_scale = scale; }
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/integrate_impl.cc b/gr-blocks/lib/integrate_impl.cc
index 3fe3a376c6..499a854b11 100644
--- a/gr-blocks/lib/integrate_impl.cc
+++ b/gr-blocks/lib/integrate_impl.cc
@@ -29,51 +29,50 @@
#include <gnuradio/io_signature.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- template <class T>
- typename integrate<T>::sptr integrate<T>::make(int decim, unsigned int vlen)
- {
- return gnuradio::get_initial_sptr(new integrate_impl<T> (decim, vlen));
- }
+template <class T>
+typename integrate<T>::sptr integrate<T>::make(int decim, unsigned int vlen)
+{
+ return gnuradio::get_initial_sptr(new integrate_impl<T>(decim, vlen));
+}
- template <class T>
- integrate_impl<T> ::integrate_impl(int decim, unsigned int vlen)
- : sync_decimator("integrate",
- io_signature::make(1, 1, sizeof (T) * vlen),
- io_signature::make(1, 1, sizeof (T) * vlen),
- decim),
+template <class T>
+integrate_impl<T>::integrate_impl(int decim, unsigned int vlen)
+ : sync_decimator("integrate",
+ io_signature::make(1, 1, sizeof(T) * vlen),
+ io_signature::make(1, 1, sizeof(T) * vlen),
+ decim),
d_decim(decim),
d_vlen(vlen)
- {
- }
+{
+}
- template <class T>
- int
- integrate_impl<T> ::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- const T *in = (const T *)input_items[0];
- T *out = (T *)output_items[0];
+template <class T>
+int integrate_impl<T>::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ const T* in = (const T*)input_items[0];
+ T* out = (T*)output_items[0];
- for (int i = 0; i < noutput_items; i++) {
+ for (int i = 0; i < noutput_items; i++) {
for (unsigned int j = 0; j < d_vlen; ++j) {
- out[i*d_vlen + j] = (T)0;
+ out[i * d_vlen + j] = (T)0;
}
for (int j = 0; j < d_decim; j++) {
- for (unsigned int k = 0; k < d_vlen; ++k) {
- out[i*d_vlen + k] += in[i*d_decim*d_vlen + j*d_vlen + k];
- }
+ for (unsigned int k = 0; k < d_vlen; ++k) {
+ out[i * d_vlen + k] += in[i * d_decim * d_vlen + j * d_vlen + k];
+ }
}
- }
-
- return noutput_items;
}
+ return noutput_items;
+}
+
template class integrate<std::int16_t>;
template class integrate<std::int32_t>;
template class integrate<float>;
template class integrate<gr_complex>;
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/integrate_impl.h b/gr-blocks/lib/integrate_impl.h
index 30c2142f42..ae0ee841f7 100644
--- a/gr-blocks/lib/integrate_impl.h
+++ b/gr-blocks/lib/integrate_impl.h
@@ -27,23 +27,23 @@
#include <gnuradio/blocks/integrate.h>
namespace gr {
- namespace blocks {
+namespace blocks {
-template<class T>
-class BLOCKS_API integrate_impl : public integrate<T>
- {
- int d_decim;
- unsigned int d_vlen;
+template <class T>
+class BLOCKS_API integrate_impl : public integrate<T>
+{
+ int d_decim;
+ unsigned int d_vlen;
- public:
- integrate_impl (int decim, unsigned int vlen);
+public:
+ integrate_impl(int decim, unsigned int vlen);
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INTEGRATE_IMPL_H */
diff --git a/gr-blocks/lib/interleave_impl.cc b/gr-blocks/lib/interleave_impl.cc
index be0b1c6f73..fac81feeca 100644
--- a/gr-blocks/lib/interleave_impl.cc
+++ b/gr-blocks/lib/interleave_impl.cc
@@ -28,77 +28,70 @@
#include <gnuradio/io_signature.h>
namespace gr {
- namespace blocks {
-
- interleave::sptr interleave::make(size_t itemsize, unsigned int blocksize)
- {
- return gnuradio::get_initial_sptr(new interleave_impl(itemsize, blocksize));
- }
-
- interleave_impl::interleave_impl(size_t itemsize, unsigned int blocksize)
- : block("interleave",
- io_signature::make (1, io_signature::IO_INFINITE, itemsize),
- io_signature::make (1, 1, itemsize)),
- d_itemsize(itemsize), d_blocksize(blocksize)
- {
- set_fixed_rate(true);
- set_output_multiple(d_blocksize);
- }
-
- bool
- interleave_impl::check_topology(int ninputs, int noutputs)
- {
- set_relative_rate((uint64_t)ninputs, 1);
- d_ninputs = ninputs;
- set_output_multiple(d_blocksize * d_ninputs);
- return true;
- }
-
-
- int
- interleave_impl::fixed_rate_ninput_to_noutput(int ninput)
- {
- return ninput * d_ninputs;
- }
-
- int
- interleave_impl::fixed_rate_noutput_to_ninput(int noutput)
- {
- return (noutput / d_ninputs);
- }
-
- void
- interleave_impl::forecast(int noutput_items,
- gr_vector_int& ninput_items_required)
- {
- for(unsigned int i = 0; i < ninput_items_required.size(); ++i) {
+namespace blocks {
+
+interleave::sptr interleave::make(size_t itemsize, unsigned int blocksize)
+{
+ return gnuradio::get_initial_sptr(new interleave_impl(itemsize, blocksize));
+}
+
+interleave_impl::interleave_impl(size_t itemsize, unsigned int blocksize)
+ : block("interleave",
+ io_signature::make(1, io_signature::IO_INFINITE, itemsize),
+ io_signature::make(1, 1, itemsize)),
+ d_itemsize(itemsize),
+ d_blocksize(blocksize)
+{
+ set_fixed_rate(true);
+ set_output_multiple(d_blocksize);
+}
+
+bool interleave_impl::check_topology(int ninputs, int noutputs)
+{
+ set_relative_rate((uint64_t)ninputs, 1);
+ d_ninputs = ninputs;
+ set_output_multiple(d_blocksize * d_ninputs);
+ return true;
+}
+
+
+int interleave_impl::fixed_rate_ninput_to_noutput(int ninput)
+{
+ return ninput * d_ninputs;
+}
+
+int interleave_impl::fixed_rate_noutput_to_ninput(int noutput)
+{
+ return (noutput / d_ninputs);
+}
+
+void interleave_impl::forecast(int noutput_items, gr_vector_int& ninput_items_required)
+{
+ for (unsigned int i = 0; i < ninput_items_required.size(); ++i) {
ninput_items_required[i] = noutput_items / ninput_items_required.size();
- }
}
+}
- int
- interleave_impl::general_work(int noutput_items,
+int interleave_impl::general_work(int noutput_items,
gr_vector_int& ninput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- size_t noutput_blocks = (size_t) (noutput_items/d_blocksize);
- const char **in = (const char**)&input_items[0];
- char *out = (char*)output_items[0];
-
- for (unsigned int i = 0; i < noutput_blocks; i += d_ninputs) {
- for (unsigned int n = 0; n < d_ninputs; n++){
- memcpy(out, in[n], d_itemsize * d_blocksize);
- out += d_itemsize * d_blocksize;
- in[n] += d_itemsize * d_blocksize;
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ size_t noutput_blocks = (size_t)(noutput_items / d_blocksize);
+ const char** in = (const char**)&input_items[0];
+ char* out = (char*)output_items[0];
+
+ for (unsigned int i = 0; i < noutput_blocks; i += d_ninputs) {
+ for (unsigned int n = 0; n < d_ninputs; n++) {
+ memcpy(out, in[n], d_itemsize * d_blocksize);
+ out += d_itemsize * d_blocksize;
+ in[n] += d_itemsize * d_blocksize;
}
- }
- consume_each(noutput_items/d_ninputs);
- return noutput_items;
}
+ consume_each(noutput_items / d_ninputs);
+ return noutput_items;
+}
-
-
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/interleave_impl.h b/gr-blocks/lib/interleave_impl.h
index 7675259c8e..ad010fef36 100644
--- a/gr-blocks/lib/interleave_impl.h
+++ b/gr-blocks/lib/interleave_impl.h
@@ -26,37 +26,36 @@
#include <gnuradio/blocks/interleave.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class BLOCKS_API interleave_impl : public interleave
- {
- size_t d_itemsize;
- unsigned int d_blocksize;
- unsigned int d_ninputs;
+class BLOCKS_API interleave_impl : public interleave
+{
+ size_t d_itemsize;
+ unsigned int d_blocksize;
+ unsigned int d_ninputs;
- public:
- interleave_impl(size_t itemsize, unsigned int blocksize);
+public:
+ interleave_impl(size_t itemsize, unsigned int blocksize);
- bool check_topology(int ninputs, int noutputs);
+ bool check_topology(int ninputs, int noutputs);
- int fixed_rate_ninput_to_noutput(int ninput);
+ int fixed_rate_ninput_to_noutput(int ninput);
- int fixed_rate_noutput_to_ninput(int noutput);
+ int fixed_rate_noutput_to_ninput(int noutput);
- void forecast(int noutput_items,
- gr_vector_int& ninput_items_required);
+ 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);
+ int general_work(int noutput_items,
+ gr_vector_int& ninput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items);
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/interleaved_char_to_complex_impl.cc b/gr-blocks/lib/interleaved_char_to_complex_impl.cc
index ab6364a6d4..ad11b883fa 100644
--- a/gr-blocks/lib/interleaved_char_to_complex_impl.cc
+++ b/gr-blocks/lib/interleaved_char_to_complex_impl.cc
@@ -29,36 +29,34 @@
#include <volk/volk.h>
namespace gr {
- namespace blocks {
-
- interleaved_char_to_complex::sptr interleaved_char_to_complex::make(bool vector_input)
- {
- return gnuradio::get_initial_sptr(new interleaved_char_to_complex_impl(vector_input));
- }
-
- interleaved_char_to_complex_impl::interleaved_char_to_complex_impl(bool vector_input)
- : sync_decimator("interleaved_char_to_complex",
- gr::io_signature::make (1, 1, (vector_input?2:1)*sizeof(char)),
- gr::io_signature::make (1, 1, sizeof(gr_complex)),
- vector_input?1:2)
- {
- const int alignment_multiple =
- volk_get_alignment() / sizeof(gr_complex);
- set_alignment(std::max(1, alignment_multiple));
- }
-
- int
- interleaved_char_to_complex_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- const int8_t *in = (const int8_t *) input_items[0];
- float *out = (float *) output_items[0];
-
- volk_8i_s32f_convert_32f_u(out, in, 1.0, 2*noutput_items);
-
- return noutput_items;
- }
-
- } /* namespace blocks */
-}/* namespace gr */
+namespace blocks {
+
+interleaved_char_to_complex::sptr interleaved_char_to_complex::make(bool vector_input)
+{
+ return gnuradio::get_initial_sptr(new interleaved_char_to_complex_impl(vector_input));
+}
+
+interleaved_char_to_complex_impl::interleaved_char_to_complex_impl(bool vector_input)
+ : sync_decimator("interleaved_char_to_complex",
+ gr::io_signature::make(1, 1, (vector_input ? 2 : 1) * sizeof(char)),
+ gr::io_signature::make(1, 1, sizeof(gr_complex)),
+ vector_input ? 1 : 2)
+{
+ const int alignment_multiple = volk_get_alignment() / sizeof(gr_complex);
+ set_alignment(std::max(1, alignment_multiple));
+}
+
+int interleaved_char_to_complex_impl::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ const int8_t* in = (const int8_t*)input_items[0];
+ float* out = (float*)output_items[0];
+
+ volk_8i_s32f_convert_32f_u(out, in, 1.0, 2 * noutput_items);
+
+ return noutput_items;
+}
+
+} /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/interleaved_char_to_complex_impl.h b/gr-blocks/lib/interleaved_char_to_complex_impl.h
index f07805788c..979e24be3d 100644
--- a/gr-blocks/lib/interleaved_char_to_complex_impl.h
+++ b/gr-blocks/lib/interleaved_char_to_complex_impl.h
@@ -26,20 +26,20 @@
#include <gnuradio/blocks/interleaved_char_to_complex.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class BLOCKS_API interleaved_char_to_complex_impl : public interleaved_char_to_complex
- {
- private:
- public:
- interleaved_char_to_complex_impl(bool vector_input=false);
+class BLOCKS_API interleaved_char_to_complex_impl : public interleaved_char_to_complex
+{
+private:
+public:
+ interleaved_char_to_complex_impl(bool vector_input = false);
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/interleaved_short_array_to_complex.cc b/gr-blocks/lib/interleaved_short_array_to_complex.cc
index 4aac6208a1..78653c76c2 100644
--- a/gr-blocks/lib/interleaved_short_array_to_complex.cc
+++ b/gr-blocks/lib/interleaved_short_array_to_complex.cc
@@ -28,10 +28,8 @@
#include <assert.h>
#include <volk/volk.h>
-void
-interleaved_short_array_to_complex (const short *in,
- gr_complex *out, int nsamples)
+void interleaved_short_array_to_complex(const short* in, gr_complex* out, int nsamples)
{
- assert (nsamples % 2 == 0);
- volk_16i_s32f_convert_32f_u( (float*)out, (const int16_t*) in, 1, nsamples );
+ assert(nsamples % 2 == 0);
+ volk_16i_s32f_convert_32f_u((float*)out, (const int16_t*)in, 1, nsamples);
}
diff --git a/gr-blocks/lib/interleaved_short_array_to_complex.h b/gr-blocks/lib/interleaved_short_array_to_complex.h
index 33f70ccdfa..04a1f785d9 100644
--- a/gr-blocks/lib/interleaved_short_array_to_complex.h
+++ b/gr-blocks/lib/interleaved_short_array_to_complex.h
@@ -31,6 +31,7 @@
* the shorts contains real, imaginary, real, imaginary...
* nsamples is the number of shorts; it must be even.
*/
-BLOCKS_API void interleaved_short_array_to_complex (const short *in, gr_complex *out, int nsamples);
+BLOCKS_API void
+interleaved_short_array_to_complex(const short* in, gr_complex* out, int nsamples);
#endif /* INCLUDED_INTERLEAVED_SHORT_ARRAY_TO_COMPLEX_H */
diff --git a/gr-blocks/lib/interleaved_short_to_complex_impl.cc b/gr-blocks/lib/interleaved_short_to_complex_impl.cc
index ca0dfc9064..ada88cd34a 100644
--- a/gr-blocks/lib/interleaved_short_to_complex_impl.cc
+++ b/gr-blocks/lib/interleaved_short_to_complex_impl.cc
@@ -29,48 +29,47 @@
#include <gnuradio/io_signature.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- interleaved_short_to_complex::sptr interleaved_short_to_complex::make(bool vector_input, bool swap)
- {
- return gnuradio::get_initial_sptr(new interleaved_short_to_complex_impl(vector_input, swap));
- }
+interleaved_short_to_complex::sptr interleaved_short_to_complex::make(bool vector_input,
+ bool swap)
+{
+ return gnuradio::get_initial_sptr(
+ new interleaved_short_to_complex_impl(vector_input, swap));
+}
- interleaved_short_to_complex_impl::interleaved_short_to_complex_impl(bool vector_input, bool swap)
- : sync_decimator("interleaved_short_to_complex",
- gr::io_signature::make (1, 1, (vector_input?2:1)*sizeof(short)),
- gr::io_signature::make (1, 1, sizeof(gr_complex)),
- vector_input?1:2),
- d_swap(swap)
- {
- }
+interleaved_short_to_complex_impl::interleaved_short_to_complex_impl(bool vector_input,
+ bool swap)
+ : sync_decimator("interleaved_short_to_complex",
+ gr::io_signature::make(1, 1, (vector_input ? 2 : 1) * sizeof(short)),
+ gr::io_signature::make(1, 1, sizeof(gr_complex)),
+ vector_input ? 1 : 2),
+ d_swap(swap)
+{
+}
- void interleaved_short_to_complex_impl::set_swap(bool swap)
- {
- d_swap = swap;
- }
+void interleaved_short_to_complex_impl::set_swap(bool swap) { d_swap = swap; }
- int
- interleaved_short_to_complex_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- const short *in = (const short *) input_items[0];
- gr_complex *out = (gr_complex *) output_items[0];
+int interleaved_short_to_complex_impl::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ const short* in = (const short*)input_items[0];
+ gr_complex* out = (gr_complex*)output_items[0];
- interleaved_short_array_to_complex (in, out, 2 * noutput_items);
+ interleaved_short_array_to_complex(in, out, 2 * noutput_items);
- if (d_swap) {
+ if (d_swap) {
float* p = (float*)output_items[0];
for (int i = 0; i < noutput_items; ++i) {
- float f = p[2*i+1];
- p[2*i+1] = p[2*i+0];
- p[2*i+0] = f;
+ float f = p[2 * i + 1];
+ p[2 * i + 1] = p[2 * i + 0];
+ p[2 * i + 0] = f;
}
- }
-
- return noutput_items;
}
- } /* namespace blocks */
-}/* namespace gr */
+ return noutput_items;
+}
+
+} /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/interleaved_short_to_complex_impl.h b/gr-blocks/lib/interleaved_short_to_complex_impl.h
index 7a3ca419c9..2dea401c58 100644
--- a/gr-blocks/lib/interleaved_short_to_complex_impl.h
+++ b/gr-blocks/lib/interleaved_short_to_complex_impl.h
@@ -26,23 +26,24 @@
#include <gnuradio/blocks/interleaved_short_to_complex.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class BLOCKS_API interleaved_short_to_complex_impl : public interleaved_short_to_complex
- {
- private:
- bool d_swap;
- public:
- interleaved_short_to_complex_impl(bool vector_input=false, bool swap=false);
+class BLOCKS_API interleaved_short_to_complex_impl : public interleaved_short_to_complex
+{
+private:
+ bool d_swap;
- void set_swap(bool swap);
+public:
+ interleaved_short_to_complex_impl(bool vector_input = false, bool swap = false);
- int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
- };
+ void set_swap(bool swap);
- } /* namespace blocks */
+ int work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
+
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/keep_m_in_n_impl.cc b/gr-blocks/lib/keep_m_in_n_impl.cc
index 2c67af9c34..d502fcebe8 100644
--- a/gr-blocks/lib/keep_m_in_n_impl.cc
+++ b/gr-blocks/lib/keep_m_in_n_impl.cc
@@ -28,108 +28,101 @@
#include <gnuradio/io_signature.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- keep_m_in_n::sptr
- keep_m_in_n::make(size_t itemsize, int m, int n, int offset)
- {
- return gnuradio::get_initial_sptr
- (new keep_m_in_n_impl(itemsize, m, n, offset));
- }
+keep_m_in_n::sptr keep_m_in_n::make(size_t itemsize, int m, int n, int offset)
+{
+ return gnuradio::get_initial_sptr(new keep_m_in_n_impl(itemsize, m, n, offset));
+}
- keep_m_in_n_impl::keep_m_in_n_impl(size_t itemsize, int m, int n, int offset)
- : block("keep_m_in_n",
- io_signature::make (1, 1, itemsize),
- io_signature::make (1, 1, itemsize)),
- d_m(m),
- d_n(n),
- d_offset(offset),
- d_itemsize(itemsize)
- {
- // sanity checking
- if(d_m <= 0) {
- std::string s = boost::str(boost::format("keep_m_in_n: m=%1% but must be > 0") % d_m);
+keep_m_in_n_impl::keep_m_in_n_impl(size_t itemsize, int m, int n, int offset)
+ : block("keep_m_in_n",
+ io_signature::make(1, 1, itemsize),
+ io_signature::make(1, 1, itemsize)),
+ d_m(m),
+ d_n(n),
+ d_offset(offset),
+ d_itemsize(itemsize)
+{
+ // sanity checking
+ if (d_m <= 0) {
+ std::string s =
+ boost::str(boost::format("keep_m_in_n: m=%1% but must be > 0") % d_m);
throw std::runtime_error(s);
- }
- if(d_n <= 0) {
- std::string s = boost::str(boost::format("keep_m_in_n: n=%1% but must be > 0") % d_n);
+ }
+ if (d_n <= 0) {
+ std::string s =
+ boost::str(boost::format("keep_m_in_n: n=%1% but must be > 0") % d_n);
throw std::runtime_error(s);
- }
- if(d_m > d_n) {
- std::string s = boost::str(boost::format("keep_m_in_n: m (%1%) <= n %2%") % d_m % d_n);
+ }
+ if (d_m > d_n) {
+ std::string s =
+ boost::str(boost::format("keep_m_in_n: m (%1%) <= n %2%") % d_m % d_n);
throw std::runtime_error(s);
- }
- if(d_offset < 0) {
- std::string s = boost::str(boost::format("keep_m_in_n: offset (%1%) must be >= 0") \
- % d_offset);
+ }
+ if (d_offset < 0) {
+ std::string s = boost::str(
+ boost::format("keep_m_in_n: offset (%1%) must be >= 0") % d_offset);
throw std::runtime_error(s);
- }
- if(d_offset >= d_n) {
- std::string s = boost::str(boost::format("keep_m_in_n: offset (%1%) < n (%2%)") \
- % d_offset % d_n);
+ }
+ if (d_offset >= d_n) {
+ std::string s = boost::str(boost::format("keep_m_in_n: offset (%1%) < n (%2%)") %
+ d_offset % d_n);
throw std::runtime_error(s);
- }
-
- set_output_multiple(m);
- set_relative_rate(static_cast<uint64_t>(d_m), static_cast<uint64_t>(d_n));
}
- void
- keep_m_in_n_impl::forecast(int noutput_items, gr_vector_int &ninput_items_required)
- {
- ninput_items_required[0] = d_n*(noutput_items/d_m);
- }
+ set_output_multiple(m);
+ set_relative_rate(static_cast<uint64_t>(d_m), static_cast<uint64_t>(d_n));
+}
- void
- keep_m_in_n_impl::set_m(int m)
- {
- d_m = m;
- set_output_multiple(m);
- set_relative_rate(static_cast<uint64_t>(d_m), static_cast<uint64_t>(d_n));
- }
+void keep_m_in_n_impl::forecast(int noutput_items, gr_vector_int& ninput_items_required)
+{
+ ninput_items_required[0] = d_n * (noutput_items / d_m);
+}
- void
- keep_m_in_n_impl::set_n(int n)
- {
- d_n = n;
- set_relative_rate(static_cast<uint64_t>(d_m), static_cast<uint64_t>(d_n));
- }
+void keep_m_in_n_impl::set_m(int m)
+{
+ d_m = m;
+ set_output_multiple(m);
+ set_relative_rate(static_cast<uint64_t>(d_m), static_cast<uint64_t>(d_n));
+}
- void
- keep_m_in_n_impl::set_offset(int offset)
- {
- d_offset = offset;
- }
+void keep_m_in_n_impl::set_n(int n)
+{
+ d_n = n;
+ set_relative_rate(static_cast<uint64_t>(d_m), static_cast<uint64_t>(d_n));
+}
- int
- keep_m_in_n_impl::general_work(int noutput_items,
- gr_vector_int &ninput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- uint8_t* out = (uint8_t*)output_items[0];
- const uint8_t* in = (const uint8_t*)input_items[0];
+void keep_m_in_n_impl::set_offset(int offset) { d_offset = offset; }
- // iterate over data blocks of size {n, input : m, output}
- int blks = std::min(noutput_items/d_m, ninput_items[0]/d_n);
- int excess = (d_offset + d_m - d_n) * d_itemsize;
+int keep_m_in_n_impl::general_work(int noutput_items,
+ gr_vector_int& ninput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ uint8_t* out = (uint8_t*)output_items[0];
+ const uint8_t* in = (const uint8_t*)input_items[0];
- for(int i=0; i<blks; i++) {
+ // iterate over data blocks of size {n, input : m, output}
+ int blks = std::min(noutput_items / d_m, ninput_items[0] / d_n);
+ int excess = (d_offset + d_m - d_n) * d_itemsize;
+
+ for (int i = 0; i < blks; i++) {
// set up copy pointers
- const uint8_t* iptr = &in[(i*d_n + d_offset)*d_itemsize];
- uint8_t* optr = &out[i*d_m*d_itemsize];
+ const uint8_t* iptr = &in[(i * d_n + d_offset) * d_itemsize];
+ uint8_t* optr = &out[i * d_m * d_itemsize];
// perform copy
- if(excess <= 0) {
- memcpy( optr, iptr, d_m*d_itemsize );
+ if (excess <= 0) {
+ memcpy(optr, iptr, d_m * d_itemsize);
} else {
- memcpy( optr, &in[i*d_n*d_itemsize], excess);
- memcpy( optr + excess, iptr, d_m*d_itemsize - excess);
+ memcpy(optr, &in[i * d_n * d_itemsize], excess);
+ memcpy(optr + excess, iptr, d_m * d_itemsize - excess);
}
- }
-
- consume_each(blks*d_n);
- return blks*d_m;
}
- } /* namespace blocks */
+ consume_each(blks * d_n);
+ return blks * d_m;
+}
+
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/keep_m_in_n_impl.h b/gr-blocks/lib/keep_m_in_n_impl.h
index 4a54b4c336..9f96272a1e 100644
--- a/gr-blocks/lib/keep_m_in_n_impl.h
+++ b/gr-blocks/lib/keep_m_in_n_impl.h
@@ -26,31 +26,31 @@
#include <gnuradio/blocks/keep_m_in_n.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class BLOCKS_API keep_m_in_n_impl : public keep_m_in_n
- {
- int d_m;
- int d_n;
- int d_offset;
- int d_itemsize;
+class BLOCKS_API keep_m_in_n_impl : public keep_m_in_n
+{
+ int d_m;
+ int d_n;
+ int d_offset;
+ int d_itemsize;
- void forecast(int noutput_items, gr_vector_int &ninput_items_required);
+ void forecast(int noutput_items, gr_vector_int& ninput_items_required);
- public:
- keep_m_in_n_impl(size_t itemsize, int m, int n, int offset);
+public:
+ keep_m_in_n_impl(size_t itemsize, int m, int n, int offset);
- int general_work(int noutput_items,
- gr_vector_int &ninput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
+ int general_work(int noutput_items,
+ gr_vector_int& ninput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items);
- void set_m(int m);
- void set_n(int n);
- void set_offset(int offset);
- };
+ void set_m(int m);
+ void set_n(int n);
+ void set_offset(int offset);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/keep_one_in_n_impl.cc b/gr-blocks/lib/keep_one_in_n_impl.cc
index 91c77da829..5c7e4b3a12 100644
--- a/gr-blocks/lib/keep_one_in_n_impl.cc
+++ b/gr-blocks/lib/keep_one_in_n_impl.cc
@@ -28,83 +28,81 @@
#include <gnuradio/io_signature.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- keep_one_in_n::sptr keep_one_in_n::make(size_t itemsize, int n)
- {
- return gnuradio::get_initial_sptr(new keep_one_in_n_impl(itemsize, n));
- }
+keep_one_in_n::sptr keep_one_in_n::make(size_t itemsize, int n)
+{
+ return gnuradio::get_initial_sptr(new keep_one_in_n_impl(itemsize, n));
+}
- keep_one_in_n_impl::keep_one_in_n_impl(size_t itemsize, int n)
- : block("keep_one_in_n",
- io_signature::make (1, 1, itemsize),
- io_signature::make (1, 1, itemsize)),
- d_count(n)
- {
- // To avoid bad behavior with using set_relative_rate in this block with
- // VERY large values of n, we will keep track of things ourselves. Using
- // this to turn off automatic tag propagation, which will be handled
- // locally in general_work().
- set_tag_propagation_policy(TPP_DONT);
+keep_one_in_n_impl::keep_one_in_n_impl(size_t itemsize, int n)
+ : block("keep_one_in_n",
+ io_signature::make(1, 1, itemsize),
+ io_signature::make(1, 1, itemsize)),
+ d_count(n)
+{
+ // To avoid bad behavior with using set_relative_rate in this block with
+ // VERY large values of n, we will keep track of things ourselves. Using
+ // this to turn off automatic tag propagation, which will be handled
+ // locally in general_work().
+ set_tag_propagation_policy(TPP_DONT);
- set_n(n);
- }
+ set_n(n);
+}
- void
- keep_one_in_n_impl::set_n(int n)
- {
- if (n < 1) {
+void keep_one_in_n_impl::set_n(int n)
+{
+ if (n < 1) {
throw std::invalid_argument("N must be at least 1.");
- }
+ }
- d_n = n;
- d_count = n;
+ d_n = n;
+ d_count = n;
- // keep our internal understanding of the relative rate of this block
- // don't set the relative rate, though, and we will handle our own
- // tag propagation.
- d_decim_rate = 1.0/(float)d_n;
- }
+ // keep our internal understanding of the relative rate of this block
+ // don't set the relative rate, though, and we will handle our own
+ // tag propagation.
+ d_decim_rate = 1.0 / (float)d_n;
+}
- int
- keep_one_in_n_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 keep_one_in_n_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];
- size_t item_size = input_signature ()->sizeof_stream_item (0);
- int ni = 0;
- int no = 0;
+ size_t item_size = input_signature()->sizeof_stream_item(0);
+ int ni = 0;
+ int no = 0;
- while (ni < ninput_items[0] && no < noutput_items){
+ while (ni < ninput_items[0] && no < noutput_items) {
d_count--;
- if (d_count <= 0){
- memcpy (out, in, item_size); // copy 1 item
- out += item_size;
- no++;
- d_count = d_n;
+ if (d_count <= 0) {
+ memcpy(out, in, item_size); // copy 1 item
+ out += item_size;
+ no++;
+ d_count = d_n;
}
in += item_size;
ni++;
- }
+ }
- // Because we have set TPP_DONT, we have to propagate the tags here manually.
- // Adjustment of the tag sample value is done using the float d_decim_rate.
- std::vector<tag_t> tags;
- std::vector<tag_t>::iterator t;
- get_tags_in_range(tags, 0, nitems_read(0), nitems_read(0)+ni);
- for(t = tags.begin(); t != tags.end(); t++) {
+ // Because we have set TPP_DONT, we have to propagate the tags here manually.
+ // Adjustment of the tag sample value is done using the float d_decim_rate.
+ std::vector<tag_t> tags;
+ std::vector<tag_t>::iterator t;
+ get_tags_in_range(tags, 0, nitems_read(0), nitems_read(0) + ni);
+ for (t = tags.begin(); t != tags.end(); t++) {
tag_t new_tag = *t;
new_tag.offset *= d_decim_rate;
add_item_tag(0, new_tag);
- }
-
- consume_each (ni);
- return no;
}
- } /* namespace blocks */
+ consume_each(ni);
+ return no;
+}
+
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/keep_one_in_n_impl.h b/gr-blocks/lib/keep_one_in_n_impl.h
index f60bf1a02b..e2882e74bc 100644
--- a/gr-blocks/lib/keep_one_in_n_impl.h
+++ b/gr-blocks/lib/keep_one_in_n_impl.h
@@ -27,26 +27,26 @@
#include <gnuradio/blocks/keep_one_in_n.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class BLOCKS_API keep_one_in_n_impl : public keep_one_in_n
- {
- int d_n;
- int d_count;
- float d_decim_rate;
+class BLOCKS_API keep_one_in_n_impl : public keep_one_in_n
+{
+ int d_n;
+ int d_count;
+ float d_decim_rate;
- public:
- keep_one_in_n_impl(size_t itemsize,int n);
+public:
+ keep_one_in_n_impl(size_t itemsize, int n);
- int general_work(int noutput_items,
- gr_vector_int &ninput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
+ int general_work(int noutput_items,
+ gr_vector_int& ninput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items);
- void set_n(int n);
- };
+ void set_n(int n);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/lfsr_32k_source_s_impl.cc b/gr-blocks/lib/lfsr_32k_source_s_impl.cc
index 58b0ad7def..fe9f227cd6 100644
--- a/gr-blocks/lib/lfsr_32k_source_s_impl.cc
+++ b/gr-blocks/lib/lfsr_32k_source_s_impl.cc
@@ -29,51 +29,46 @@
#include <stdexcept>
namespace gr {
- namespace blocks {
+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::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()
- : sync_block("lfsr_32k_source_s",
- io_signature::make(0, 0, 0),
- io_signature::make(1, 1, sizeof(short))),
- d_index(0)
- {
- lfsr_32k lfsr;
+lfsr_32k_source_s_impl::lfsr_32k_source_s_impl()
+ : sync_block("lfsr_32k_source_s",
+ io_signature::make(0, 0, 0),
+ io_signature::make(1, 1, sizeof(short))),
+ d_index(0)
+{
+ lfsr_32k lfsr;
- for(int i = 0; i < BUFSIZE; i++)
+ for (int i = 0; i < BUFSIZE; i++)
d_buffer[i] = lfsr.next_short();
- }
+}
- lfsr_32k_source_s_impl::~lfsr_32k_source_s_impl()
- {
- }
+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;
+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++) {
+ 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;
+ if (index >= BUFSIZE)
+ index = 0;
}
- } /* namespace blocks */
+ 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
index 40fc6b6d84..7705c9f02f 100644
--- a/gr-blocks/lib/lfsr_32k_source_s_impl.h
+++ b/gr-blocks/lib/lfsr_32k_source_s_impl.h
@@ -28,25 +28,25 @@
#include <gnuradio/sync_block.h>
namespace gr {
- namespace blocks {
+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];
+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();
+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);
- };
+ int work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_GR_LFSR_32K_SOURCE_S_IMPL_H */
diff --git a/gr-blocks/lib/magphase_to_complex_impl.cc b/gr-blocks/lib/magphase_to_complex_impl.cc
index db6240d939..bc8f727e34 100644
--- a/gr-blocks/lib/magphase_to_complex_impl.cc
+++ b/gr-blocks/lib/magphase_to_complex_impl.cc
@@ -29,40 +29,36 @@
#include <volk/volk.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- magphase_to_complex::sptr
- magphase_to_complex::make(size_t vlen)
- {
- return gnuradio::get_initial_sptr
- (new magphase_to_complex_impl(vlen));
- }
+magphase_to_complex::sptr magphase_to_complex::make(size_t vlen)
+{
+ return gnuradio::get_initial_sptr(new magphase_to_complex_impl(vlen));
+}
- magphase_to_complex_impl::magphase_to_complex_impl(size_t vlen)
- : sync_block("magphase_to_complex",
- io_signature::make(2, 2, sizeof(float)*vlen),
- io_signature::make(1, 1, sizeof(gr_complex)*vlen)),
- d_vlen(vlen)
- {
- const int alignment_multiple =
- volk_get_alignment() / sizeof(float);
- set_alignment(std::max(1,alignment_multiple));
- }
+magphase_to_complex_impl::magphase_to_complex_impl(size_t vlen)
+ : sync_block("magphase_to_complex",
+ io_signature::make(2, 2, sizeof(float) * vlen),
+ io_signature::make(1, 1, sizeof(gr_complex) * vlen)),
+ d_vlen(vlen)
+{
+ const int alignment_multiple = volk_get_alignment() / sizeof(float);
+ set_alignment(std::max(1, alignment_multiple));
+}
- int
- magphase_to_complex_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- float *mag = (float *)input_items[0];
- float *phase = (float *)input_items[1];
- gr_complex *out = (gr_complex *) output_items[0];
+int magphase_to_complex_impl::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ float* mag = (float*)input_items[0];
+ float* phase = (float*)input_items[1];
+ gr_complex* out = (gr_complex*)output_items[0];
- for (size_t j = 0; j < noutput_items*d_vlen; j++)
- out[j] = gr_complex (mag[j]*cos(phase[j]),mag[j]*sin(phase[j]));
-
- return noutput_items;
- }
+ for (size_t j = 0; j < noutput_items * d_vlen; j++)
+ out[j] = gr_complex(mag[j] * cos(phase[j]), mag[j] * sin(phase[j]));
- } /* namespace blocks */
-}/* namespace gr */
+ return noutput_items;
+}
+
+} /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/magphase_to_complex_impl.h b/gr-blocks/lib/magphase_to_complex_impl.h
index 114e15321d..d8a1181ec6 100644
--- a/gr-blocks/lib/magphase_to_complex_impl.h
+++ b/gr-blocks/lib/magphase_to_complex_impl.h
@@ -26,21 +26,21 @@
#include <gnuradio/blocks/magphase_to_complex.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class BLOCKS_API magphase_to_complex_impl : public magphase_to_complex
- {
- size_t d_vlen;
+class BLOCKS_API magphase_to_complex_impl : public magphase_to_complex
+{
+ size_t d_vlen;
- public:
- magphase_to_complex_impl(size_t vlen);
+public:
+ magphase_to_complex_impl(size_t vlen);
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/max_blk_impl.cc b/gr-blocks/lib/max_blk_impl.cc
index 82caccf75f..9f2dcaf5a0 100644
--- a/gr-blocks/lib/max_blk_impl.cc
+++ b/gr-blocks/lib/max_blk_impl.cc
@@ -29,74 +29,72 @@
#include <gnuradio/io_signature.h>
namespace gr {
- namespace blocks {
-
- template <class T>
- typename max_blk<T>::sptr
- max_blk<T>::make(size_t vlen, size_t vlen_out)
- {
- return gnuradio::get_initial_sptr
- (new max_blk_impl<T> (vlen,vlen_out));
- }
-
- template <class T>
- max_blk_impl<T> ::max_blk_impl(size_t vlen, size_t vlen_out)
+namespace blocks {
+
+template <class T>
+typename max_blk<T>::sptr max_blk<T>::make(size_t vlen, size_t vlen_out)
+{
+ return gnuradio::get_initial_sptr(new max_blk_impl<T>(vlen, vlen_out));
+}
+
+template <class T>
+max_blk_impl<T>::max_blk_impl(size_t vlen, size_t vlen_out)
: sync_block("max_blk",
- io_signature::make(1, -1, vlen*sizeof(T)),
- io_signature::make(1, 1, vlen_out*sizeof(T))),
- d_vlen(vlen), d_vlen_out(vlen_out)
- {
- assert((vlen_out == vlen) || (vlen_out == 1));
- }
-
- template <class T>
- max_blk_impl<T> ::~max_blk_impl()
- {
- }
-
- template <class T>
- int
- max_blk_impl<T> ::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- T *optr = (T *)output_items[0];
-
- int ninputs = input_items.size();
-
- if(d_vlen_out == 1)
- for(int i = 0; i < noutput_items; i++) {
- T max = ((T *)input_items[0])[i*d_vlen];
-
- for(int j = 0; j < (int)d_vlen; j++ ) {
- for(int k = 0; k < ninputs; k++) {
- if(((T *)input_items[k])[i*d_vlen + j] > max) {
- max = ((T*)input_items[k])[i*d_vlen + j];
- }
- }
- }
-
- *optr++ = (T)max;
- }
-
- else // vector mode output
- for(size_t i = 0; i < (size_t)noutput_items * d_vlen_out; i++) {
- T max = ((T *)input_items[0])[i];
-
- for(int k = 1; k < ninputs; k++) {
- if(((T *)input_items[k])[i] > max) {
- max = ((T*)input_items[k])[i];
- }
- }
-
- *optr++ = (T)max;
- }
-
- return noutput_items;
- }
+ io_signature::make(1, -1, vlen * sizeof(T)),
+ io_signature::make(1, 1, vlen_out * sizeof(T))),
+ d_vlen(vlen),
+ d_vlen_out(vlen_out)
+{
+ assert((vlen_out == vlen) || (vlen_out == 1));
+}
+
+template <class T>
+max_blk_impl<T>::~max_blk_impl()
+{
+}
+
+template <class T>
+int max_blk_impl<T>::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ T* optr = (T*)output_items[0];
+
+ int ninputs = input_items.size();
+
+ if (d_vlen_out == 1)
+ for (int i = 0; i < noutput_items; i++) {
+ T max = ((T*)input_items[0])[i * d_vlen];
+
+ for (int j = 0; j < (int)d_vlen; j++) {
+ for (int k = 0; k < ninputs; k++) {
+ if (((T*)input_items[k])[i * d_vlen + j] > max) {
+ max = ((T*)input_items[k])[i * d_vlen + j];
+ }
+ }
+ }
+
+ *optr++ = (T)max;
+ }
+
+ else // vector mode output
+ for (size_t i = 0; i < (size_t)noutput_items * d_vlen_out; i++) {
+ T max = ((T*)input_items[0])[i];
+
+ for (int k = 1; k < ninputs; k++) {
+ if (((T*)input_items[k])[i] > max) {
+ max = ((T*)input_items[k])[i];
+ }
+ }
+
+ *optr++ = (T)max;
+ }
+
+ return noutput_items;
+}
template class max_blk<std::int16_t>;
template class max_blk<std::int32_t>;
template class max_blk<float>;
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/max_blk_impl.h b/gr-blocks/lib/max_blk_impl.h
index af62d9f4a8..5d4718aec7 100644
--- a/gr-blocks/lib/max_blk_impl.h
+++ b/gr-blocks/lib/max_blk_impl.h
@@ -27,24 +27,24 @@
#include <gnuradio/blocks/max_blk.h>
namespace gr {
- namespace blocks {
+namespace blocks {
-template<class T>
- class max_blk_impl : public max_blk<T>
- {
- private:
- size_t d_vlen, d_vlen_out;
+template <class T>
+class max_blk_impl : public max_blk<T>
+{
+private:
+ size_t d_vlen, d_vlen_out;
- public:
- max_blk_impl (size_t vlen, size_t vlen_out);
- ~max_blk_impl ();
+public:
+ max_blk_impl(size_t vlen, size_t vlen_out);
+ ~max_blk_impl();
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* MAX_BLK_IMPL_H */
diff --git a/gr-blocks/lib/message_debug_impl.cc b/gr-blocks/lib/message_debug_impl.cc
index 8bab788261..a8c84aa509 100644
--- a/gr-blocks/lib/message_debug_impl.cc
+++ b/gr-blocks/lib/message_debug_impl.cc
@@ -30,91 +30,77 @@
#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::print(msg);
- std::cout << "************************************\n";
- }
-
- void
- message_debug_impl::store(pmt::pmt_t msg)
- {
- gr::thread::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::car(pdu);
- pmt::pmt_t vector = pmt::cdr(pdu);
- std::cout << "* MESSAGE DEBUG PRINT PDU VERBOSE *\n";
- pmt::print(meta);
- size_t len = pmt::blob_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){
+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::print(msg);
+ std::cout << "************************************\n";
+}
+
+void message_debug_impl::store(pmt::pmt_t msg)
+{
+ gr::thread::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::car(pdu);
+ pmt::pmt_t vector = pmt::cdr(pdu);
+ std::cout << "* MESSAGE DEBUG PRINT PDU VERBOSE *\n";
+ pmt::print(meta);
+ size_t len = pmt::blob_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] );
+ 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();
- }
+ std::cout << "***********************************\n";
+}
- pmt::pmt_t
- message_debug_impl::get_message(int i)
- {
- gr::thread::scoped_lock guard(d_mutex);
+int message_debug_impl::num_messages() { return (int)d_messages.size(); }
- if((size_t)i >= d_messages.size()) {
- throw std::runtime_error("message_debug: index for message out of bounds.\n");
- }
+pmt::pmt_t message_debug_impl::get_message(int i)
+{
+ gr::thread::scoped_lock guard(d_mutex);
- return d_messages[i];
+ if ((size_t)i >= d_messages.size()) {
+ throw std::runtime_error("message_debug: index for message out of bounds.\n");
}
- message_debug_impl::message_debug_impl()
- : block("message_debug",
- io_signature::make(0, 0, 0),
- io_signature::make(0, 0, 0))
- {
- message_port_register_in(pmt::mp("print"));
- set_msg_handler(pmt::mp("print"), boost::bind(&message_debug_impl::print, this, _1));
+ return d_messages[i];
+}
- message_port_register_in(pmt::mp("store"));
- set_msg_handler(pmt::mp("store"), boost::bind(&message_debug_impl::store, this, _1));
+message_debug_impl::message_debug_impl()
+ : block("message_debug", io_signature::make(0, 0, 0), io_signature::make(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("print_pdu"));
- set_msg_handler(pmt::mp("print_pdu"), boost::bind(&message_debug_impl::print_pdu, this, _1));
- }
+ message_port_register_in(pmt::mp("store"));
+ set_msg_handler(pmt::mp("store"), boost::bind(&message_debug_impl::store, this, _1));
- message_debug_impl::~message_debug_impl()
- {
- }
+ message_port_register_in(pmt::mp("print_pdu"));
+ set_msg_handler(pmt::mp("print_pdu"),
+ boost::bind(&message_debug_impl::print_pdu, this, _1));
+}
- } /* namespace blocks */
-} /* namespace gr */
+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
index 5a6e2e4acb..2faa42a0d0 100644
--- a/gr-blocks/lib/message_debug_impl.h
+++ b/gr-blocks/lib/message_debug_impl.h
@@ -29,61 +29,60 @@
#include <pmt/pmt.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class message_debug_impl : public message_debug
- {
- private:
+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 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 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);
- /*!
- * \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);
+ gr::thread::mutex d_mutex;
+ std::vector<pmt::pmt_t> d_messages;
- gr::thread::mutex d_mutex;
- std::vector<pmt::pmt_t> d_messages;
+public:
+ message_debug_impl();
+ ~message_debug_impl();
- public:
- message_debug_impl();
- ~message_debug_impl();
+ int num_messages();
+ pmt::pmt_t get_message(int i);
+};
- int num_messages();
- pmt::pmt_t get_message(int i);
- };
-
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_GR_MESSAGE_DEBUG_IMPL_H */
diff --git a/gr-blocks/lib/message_strobe_impl.cc b/gr-blocks/lib/message_strobe_impl.cc
index bedec78a57..cf06448ecb 100644
--- a/gr-blocks/lib/message_strobe_impl.cc
+++ b/gr-blocks/lib/message_strobe_impl.cc
@@ -36,69 +36,62 @@
#include <iostream>
namespace gr {
- namespace blocks {
+namespace blocks {
- message_strobe::sptr
- message_strobe::make(pmt::pmt_t msg, long period_ms)
- {
- return gnuradio::get_initial_sptr
- (new message_strobe_impl(msg, period_ms));
- }
+message_strobe::sptr message_strobe::make(pmt::pmt_t msg, long period_ms)
+{
+ return gnuradio::get_initial_sptr(new message_strobe_impl(msg, period_ms));
+}
- message_strobe_impl::message_strobe_impl(pmt::pmt_t msg, long period_ms)
- : block("message_strobe",
- io_signature::make(0, 0, 0),
- io_signature::make(0, 0, 0)),
- d_finished(false),
- d_period_ms(period_ms),
- d_msg(msg),
- d_port(pmt::mp("strobe"))
- {
- message_port_register_out(d_port);
+message_strobe_impl::message_strobe_impl(pmt::pmt_t msg, long period_ms)
+ : block("message_strobe", io_signature::make(0, 0, 0), io_signature::make(0, 0, 0)),
+ d_finished(false),
+ d_period_ms(period_ms),
+ d_msg(msg),
+ d_port(pmt::mp("strobe"))
+{
+ message_port_register_out(d_port);
- 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_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()
- {
- }
+message_strobe_impl::~message_strobe_impl() {}
- bool
- message_strobe_impl::start()
- {
- // NOTE: d_finished should be something explicitly thread safe. But since
- // nothing breaks on concurrent access, I'll just leave it as bool.
- d_finished = false;
- d_thread = boost::shared_ptr<gr::thread::thread>
- (new gr::thread::thread(boost::bind(&message_strobe_impl::run, this)));
+bool message_strobe_impl::start()
+{
+ // NOTE: d_finished should be something explicitly thread safe. But since
+ // nothing breaks on concurrent access, I'll just leave it as bool.
+ d_finished = false;
+ d_thread = boost::shared_ptr<gr::thread::thread>(
+ new gr::thread::thread(boost::bind(&message_strobe_impl::run, this)));
- return block::start();
- }
+ return block::start();
+}
- bool
- message_strobe_impl::stop()
- {
- // Shut down the thread
- d_finished = true;
- d_thread->interrupt();
- d_thread->join();
+bool message_strobe_impl::stop()
+{
+ // Shut down the thread
+ d_finished = true;
+ d_thread->interrupt();
+ d_thread->join();
- return block::stop();
- }
+ return block::stop();
+}
- void message_strobe_impl::run()
- {
- while(!d_finished) {
- boost::this_thread::sleep(boost::posix_time::milliseconds(static_cast<long>(d_period_ms)));
- if(d_finished) {
- return;
+void message_strobe_impl::run()
+{
+ while (!d_finished) {
+ boost::this_thread::sleep(
+ boost::posix_time::milliseconds(static_cast<long>(d_period_ms)));
+ if (d_finished) {
+ return;
}
message_port_pub(d_port, d_msg);
- }
}
+}
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/message_strobe_impl.h b/gr-blocks/lib/message_strobe_impl.h
index 0ee1cf1f3d..956b57da7a 100644
--- a/gr-blocks/lib/message_strobe_impl.h
+++ b/gr-blocks/lib/message_strobe_impl.h
@@ -26,35 +26,35 @@
#include <gnuradio/blocks/message_strobe.h>
namespace gr {
- namespace blocks {
-
- class BLOCKS_API message_strobe_impl : public message_strobe
- {
- private:
- boost::shared_ptr<gr::thread::thread> d_thread;
- bool d_finished;
- long d_period_ms;
- pmt::pmt_t d_msg;
- const pmt::pmt_t d_port;
-
- void run();
-
- public:
- message_strobe_impl(pmt::pmt_t msg, long 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(long period_ms) { d_period_ms = period_ms; }
- long period() const { return d_period_ms; }
-
- // Overloading these to start and stop the internal thread that
- // periodically produces the message.
- bool start();
- bool stop();
- };
-
- } /* namespace blocks */
+namespace blocks {
+
+class BLOCKS_API message_strobe_impl : public message_strobe
+{
+private:
+ boost::shared_ptr<gr::thread::thread> d_thread;
+ bool d_finished;
+ long d_period_ms;
+ pmt::pmt_t d_msg;
+ const pmt::pmt_t d_port;
+
+ void run();
+
+public:
+ message_strobe_impl(pmt::pmt_t msg, long 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(long period_ms) { d_period_ms = period_ms; }
+ long period() const { return d_period_ms; }
+
+ // Overloading these to start and stop the internal thread that
+ // periodically produces the message.
+ bool start();
+ bool stop();
+};
+
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_GR_MESSAGE_STROBE_IMPL_H */
diff --git a/gr-blocks/lib/message_strobe_random_impl.cc b/gr-blocks/lib/message_strobe_random_impl.cc
index 5c2055ddbd..0a36b6d380 100644
--- a/gr-blocks/lib/message_strobe_random_impl.cc
+++ b/gr-blocks/lib/message_strobe_random_impl.cc
@@ -36,88 +36,104 @@
#include <iostream>
namespace gr {
- namespace blocks {
-
- message_strobe_random::sptr
- message_strobe_random::make(pmt::pmt_t msg, message_strobe_random_distribution_t dist, float mean_ms, float std_ms)
- {
- return gnuradio::get_initial_sptr
- (new message_strobe_random_impl(msg, dist, mean_ms, std_ms));
- }
-
-
- message_strobe_random_impl::message_strobe_random_impl(pmt::pmt_t msg, message_strobe_random_distribution_t dist, float mean_ms, float std_ms)
- : block("message_strobe_random",
- io_signature::make(0, 0, 0),
- io_signature::make(0, 0, 0)),
- d_finished(false),
- d_mean_ms(mean_ms),
- d_std_ms(std_ms),
- d_dist(dist),
- d_msg(msg),
- d_rng(),
- d_port(pmt::mp("strobe"))
- {
- // allocate RNGs
- update_dist();
-
- // set up ports
- message_port_register_out(d_port);
- d_thread = boost::shared_ptr<gr::thread::thread>
- (new gr::thread::thread(boost::bind(&message_strobe_random_impl::run, this)));
-
- message_port_register_in(pmt::mp("set_msg"));
- set_msg_handler(pmt::mp("set_msg"),
- boost::bind(&message_strobe_random_impl::set_msg, this, _1));
+namespace blocks {
+
+message_strobe_random::sptr
+message_strobe_random::make(pmt::pmt_t msg,
+ message_strobe_random_distribution_t dist,
+ float mean_ms,
+ float std_ms)
+{
+ return gnuradio::get_initial_sptr(
+ new message_strobe_random_impl(msg, dist, mean_ms, std_ms));
+}
+
+
+message_strobe_random_impl::message_strobe_random_impl(
+ pmt::pmt_t msg,
+ message_strobe_random_distribution_t dist,
+ float mean_ms,
+ float std_ms)
+ : block("message_strobe_random",
+ io_signature::make(0, 0, 0),
+ io_signature::make(0, 0, 0)),
+ d_finished(false),
+ d_mean_ms(mean_ms),
+ d_std_ms(std_ms),
+ d_dist(dist),
+ d_msg(msg),
+ d_rng(),
+ d_port(pmt::mp("strobe"))
+{
+ // allocate RNGs
+ update_dist();
+
+ // set up ports
+ message_port_register_out(d_port);
+ d_thread = boost::shared_ptr<gr::thread::thread>(
+ new gr::thread::thread(boost::bind(&message_strobe_random_impl::run, this)));
+
+ message_port_register_in(pmt::mp("set_msg"));
+ set_msg_handler(pmt::mp("set_msg"),
+ boost::bind(&message_strobe_random_impl::set_msg, this, _1));
+}
+
+long message_strobe_random_impl::next_delay()
+{
+ switch (d_dist) {
+ case STROBE_POISSON:
+ // return d_variate_poisson->operator()();
+ return static_cast<long>(d_variate_poisson->operator()());
+ case STROBE_GAUSSIAN:
+ return static_cast<long>(d_variate_normal->operator()());
+ case STROBE_UNIFORM:
+ return static_cast<long>(d_variate_uniform->operator()());
+ default:
+ throw std::runtime_error(
+ "message_strobe_random_impl::d_distribution is very unhappy with you");
}
-
- long message_strobe_random_impl::next_delay(){
- switch(d_dist){
- case STROBE_POISSON:
- //return d_variate_poisson->operator()();
- return static_cast<long>(d_variate_poisson->operator()());
- case STROBE_GAUSSIAN:
- return static_cast<long>(d_variate_normal->operator()());
- case STROBE_UNIFORM:
- return static_cast<long>(d_variate_uniform->operator()());
- default:
- throw std::runtime_error("message_strobe_random_impl::d_distribution is very unhappy with you");
- }
- }
-
- void message_strobe_random_impl::update_dist(){
- boost::poisson_distribution<> pd(d_mean_ms);
- d_variate_poisson = boost::shared_ptr< boost::variate_generator<boost::mt19937, boost::poisson_distribution<> > > (
- new boost::variate_generator <boost::mt19937, boost::poisson_distribution<> >(d_rng,pd) );
-
- boost::normal_distribution<> nd(d_mean_ms, d_std_ms);
- d_variate_normal = boost::shared_ptr< boost::variate_generator<boost::mt19937, boost::normal_distribution<> > > (
- new boost::variate_generator <boost::mt19937, boost::normal_distribution<> >(d_rng,nd) );
-
- boost::uniform_real<> ud(d_mean_ms-d_std_ms, d_mean_ms+d_std_ms);
- d_variate_uniform = boost::shared_ptr< boost::variate_generator<boost::mt19937, boost::uniform_real<> > > (
- new boost::variate_generator <boost::mt19937, boost::uniform_real<> >(d_rng,ud) );
- }
-
-
- message_strobe_random_impl::~message_strobe_random_impl()
- {
- d_finished = true;
- d_thread->interrupt();
- d_thread->join();
- }
-
- void message_strobe_random_impl::run()
- {
- while(!d_finished) {
- boost::this_thread::sleep(boost::posix_time::milliseconds(std::max(0L, next_delay())));
- if(d_finished) {
- return;
+}
+
+void message_strobe_random_impl::update_dist()
+{
+ boost::poisson_distribution<> pd(d_mean_ms);
+ d_variate_poisson = boost::shared_ptr<
+ boost::variate_generator<boost::mt19937, boost::poisson_distribution<>>>(
+ new boost::variate_generator<boost::mt19937, boost::poisson_distribution<>>(d_rng,
+ pd));
+
+ boost::normal_distribution<> nd(d_mean_ms, d_std_ms);
+ d_variate_normal = boost::shared_ptr<
+ boost::variate_generator<boost::mt19937, boost::normal_distribution<>>>(
+ new boost::variate_generator<boost::mt19937, boost::normal_distribution<>>(d_rng,
+ nd));
+
+ boost::uniform_real<> ud(d_mean_ms - d_std_ms, d_mean_ms + d_std_ms);
+ d_variate_uniform = boost::shared_ptr<
+ boost::variate_generator<boost::mt19937, boost::uniform_real<>>>(
+ new boost::variate_generator<boost::mt19937, boost::uniform_real<>>(d_rng, ud));
+}
+
+
+message_strobe_random_impl::~message_strobe_random_impl()
+{
+ d_finished = true;
+ d_thread->interrupt();
+ d_thread->join();
+}
+
+void message_strobe_random_impl::run()
+{
+ while (!d_finished) {
+ boost::this_thread::sleep(
+ boost::posix_time::milliseconds(std::max(0L, next_delay())));
+ if (d_finished) {
+ return;
}
message_port_pub(d_port, d_msg);
- }
}
+}
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/message_strobe_random_impl.h b/gr-blocks/lib/message_strobe_random_impl.h
index 08f966921c..de70c28419 100644
--- a/gr-blocks/lib/message_strobe_random_impl.h
+++ b/gr-blocks/lib/message_strobe_random_impl.h
@@ -31,45 +31,60 @@
#include <boost/random/uniform_real.hpp>
namespace gr {
- namespace blocks {
+namespace blocks {
- class BLOCKS_API message_strobe_random_impl : public message_strobe_random
- {
- private:
- boost::shared_ptr<gr::thread::thread> d_thread;
- bool d_finished;
- float d_mean_ms;
- float d_std_ms;
- message_strobe_random_distribution_t d_dist;
- pmt::pmt_t d_msg;
- void run();
- long next_delay();
-
- boost::mt19937 d_rng;
- boost::shared_ptr< boost::variate_generator <boost::mt19937, boost::poisson_distribution<> > > d_variate_poisson;
- boost::shared_ptr< boost::variate_generator <boost::mt19937, boost::normal_distribution<> > > d_variate_normal;
- boost::shared_ptr< boost::variate_generator <boost::mt19937, boost::uniform_real<> > > d_variate_uniform;
+class BLOCKS_API message_strobe_random_impl : public message_strobe_random
+{
+private:
+ boost::shared_ptr<gr::thread::thread> d_thread;
+ bool d_finished;
+ float d_mean_ms;
+ float d_std_ms;
+ message_strobe_random_distribution_t d_dist;
+ pmt::pmt_t d_msg;
+ void run();
+ long next_delay();
- const pmt::pmt_t d_port;
+ boost::mt19937 d_rng;
+ boost::shared_ptr<
+ boost::variate_generator<boost::mt19937, boost::poisson_distribution<>>>
+ d_variate_poisson;
+ boost::shared_ptr<
+ boost::variate_generator<boost::mt19937, boost::normal_distribution<>>>
+ d_variate_normal;
+ boost::shared_ptr<boost::variate_generator<boost::mt19937, boost::uniform_real<>>>
+ d_variate_uniform;
- void update_dist();
+ const pmt::pmt_t d_port;
- public:
- message_strobe_random_impl(pmt::pmt_t msg, message_strobe_random_distribution_t dist, float mean_ms, float std_ms);
- ~message_strobe_random_impl();
+ void update_dist();
- void set_msg(pmt::pmt_t msg) { d_msg = msg; }
- pmt::pmt_t msg() const { return d_msg; }
- void set_mean(float mean_ms) { d_mean_ms = mean_ms; update_dist(); }
- float mean() const { return d_mean_ms; }
- void set_std(float std_ms) { d_std_ms = std_ms; update_dist(); }
- float std() const { return d_std_ms; }
- void set_dist(message_strobe_random_distribution_t dist){ d_dist = dist; }
- message_strobe_random_distribution_t dist() const { return d_dist; }
+public:
+ message_strobe_random_impl(pmt::pmt_t msg,
+ message_strobe_random_distribution_t dist,
+ float mean_ms,
+ float std_ms);
+ ~message_strobe_random_impl();
- };
+ void set_msg(pmt::pmt_t msg) { d_msg = msg; }
+ pmt::pmt_t msg() const { return d_msg; }
+ void set_mean(float mean_ms)
+ {
+ d_mean_ms = mean_ms;
+ update_dist();
+ }
+ float mean() const { return d_mean_ms; }
+ void set_std(float std_ms)
+ {
+ d_std_ms = std_ms;
+ update_dist();
+ }
+ float std() const { return d_std_ms; }
+ void set_dist(message_strobe_random_distribution_t dist) { d_dist = dist; }
+ message_strobe_random_distribution_t dist() const { return d_dist; }
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_GR_MESSAGE_STROBE_RANDOM_IMPL_H */
diff --git a/gr-blocks/lib/min_blk_impl.cc b/gr-blocks/lib/min_blk_impl.cc
index 540d1717f1..6ed9635e26 100644
--- a/gr-blocks/lib/min_blk_impl.cc
+++ b/gr-blocks/lib/min_blk_impl.cc
@@ -29,69 +29,67 @@
#include <gnuradio/io_signature.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- template <class T>
- typename min_blk<T>::sptr
- min_blk<T>::make(size_t vlen, size_t vlen_out)
- {
- return gnuradio::get_initial_sptr
- (new min_blk_impl<T> (vlen,vlen_out));
- }
+template <class T>
+typename min_blk<T>::sptr min_blk<T>::make(size_t vlen, size_t vlen_out)
+{
+ return gnuradio::get_initial_sptr(new min_blk_impl<T>(vlen, vlen_out));
+}
- template <class T>
- min_blk_impl<T> ::min_blk_impl(size_t vlen, size_t vlen_out)
+template <class T>
+min_blk_impl<T>::min_blk_impl(size_t vlen, size_t vlen_out)
: sync_block("min",
- io_signature::make(1, -1, vlen*sizeof(T)),
- io_signature::make(1, 1, vlen_out*sizeof(T))),
- d_vlen(vlen), d_vlen_out(vlen_out)
- {
- assert((vlen_out == vlen) || (vlen_out == 1));
- }
+ io_signature::make(1, -1, vlen * sizeof(T)),
+ io_signature::make(1, 1, vlen_out * sizeof(T))),
+ d_vlen(vlen),
+ d_vlen_out(vlen_out)
+{
+ assert((vlen_out == vlen) || (vlen_out == 1));
+}
- template <class T>
- min_blk_impl<T> ::~min_blk_impl()
- {
- }
+template <class T>
+min_blk_impl<T>::~min_blk_impl()
+{
+}
- template <class T>
- int
- min_blk_impl<T> ::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- T *optr = (T *)output_items[0];
+template <class T>
+int min_blk_impl<T>::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ T* optr = (T*)output_items[0];
- int ninputs = input_items.size();
+ int ninputs = input_items.size();
- if(d_vlen_out == 1)
- for(int i = 0; i < noutput_items; i++) {
- T min = ((T *)input_items[0])[i*d_vlen];
- for(int j = 0; j < (int)d_vlen; j++ ) {
- for(int k = 0; k < ninputs; k++) {
- if(((T *)input_items[k])[i*d_vlen + j] < min) {
- min = ((T*)input_items[k])[i*d_vlen + j];
- }
- }
- }
- *optr++ = (T)min;
- }
+ if (d_vlen_out == 1)
+ for (int i = 0; i < noutput_items; i++) {
+ T min = ((T*)input_items[0])[i * d_vlen];
+ for (int j = 0; j < (int)d_vlen; j++) {
+ for (int k = 0; k < ninputs; k++) {
+ if (((T*)input_items[k])[i * d_vlen + j] < min) {
+ min = ((T*)input_items[k])[i * d_vlen + j];
+ }
+ }
+ }
+ *optr++ = (T)min;
+ }
- else // vector mode output
- for(size_t i = 0; i < noutput_items * d_vlen_out; i++) {
- T min = ((T *)input_items[0])[i];
- for(int k = 1; k < ninputs; k++) {
- if(((T *)input_items[k])[i] < min) {
- min = ((T*)input_items[k])[i];
- }
- }
- *optr++ = (T)min;
- }
- return noutput_items;
- }
+ else // vector mode output
+ for (size_t i = 0; i < noutput_items * d_vlen_out; i++) {
+ T min = ((T*)input_items[0])[i];
+ for (int k = 1; k < ninputs; k++) {
+ if (((T*)input_items[k])[i] < min) {
+ min = ((T*)input_items[k])[i];
+ }
+ }
+ *optr++ = (T)min;
+ }
+ return noutput_items;
+}
template class min_blk<std::int16_t>;
template class min_blk<std::int32_t>;
template class min_blk<float>;
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/min_blk_impl.h b/gr-blocks/lib/min_blk_impl.h
index 151b97b391..36e7506679 100644
--- a/gr-blocks/lib/min_blk_impl.h
+++ b/gr-blocks/lib/min_blk_impl.h
@@ -27,24 +27,24 @@
#include <gnuradio/blocks/min_blk.h>
namespace gr {
- namespace blocks {
+namespace blocks {
-template<class T>
- class min_blk_impl : public min_blk<T>
- {
- private:
- size_t d_vlen, d_vlen_out;
+template <class T>
+class min_blk_impl : public min_blk<T>
+{
+private:
+ size_t d_vlen, d_vlen_out;
- public:
- min_blk_impl (size_t vlen, size_t vlen_out);
- ~min_blk_impl ();
+public:
+ min_blk_impl(size_t vlen, size_t vlen_out);
+ ~min_blk_impl();
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* MIN_BLK_IMPL_H */
diff --git a/gr-blocks/lib/moving_average_impl.cc b/gr-blocks/lib/moving_average_impl.cc
index b77a70a440..3342e2c937 100644
--- a/gr-blocks/lib/moving_average_impl.cc
+++ b/gr-blocks/lib/moving_average_impl.cc
@@ -29,21 +29,24 @@
#include <gnuradio/io_signature.h>
namespace gr {
- namespace blocks {
-
- template <class T>
- typename moving_average<T>::sptr
- moving_average<T>::make(int length, T scale, int max_iter, unsigned int vlen)
- {
- return gnuradio::get_initial_sptr
- (new moving_average_impl<T> (length, scale, max_iter, vlen));
- }
-
- template <class T>
- moving_average_impl<T>::moving_average_impl(int length, T scale, int max_iter, unsigned int vlen)
+namespace blocks {
+
+template <class T>
+typename moving_average<T>::sptr
+moving_average<T>::make(int length, T scale, int max_iter, unsigned int vlen)
+{
+ return gnuradio::get_initial_sptr(
+ new moving_average_impl<T>(length, scale, max_iter, vlen));
+}
+
+template <class T>
+moving_average_impl<T>::moving_average_impl(int length,
+ T scale,
+ int max_iter,
+ unsigned int vlen)
: sync_block("moving_average",
- io_signature::make(1, 1, sizeof(T)*vlen),
- io_signature::make(1, 1, sizeof(T)*vlen)),
+ io_signature::make(1, 1, sizeof(T) * vlen),
+ io_signature::make(1, 1, sizeof(T) * vlen)),
d_length(length),
d_scale(scale),
d_max_iter(max_iter),
@@ -51,101 +54,99 @@ namespace gr {
d_new_length(length),
d_new_scale(scale),
d_updated(false)
- {
- this->set_history(length);
- //we don't have C++11's <array>, so initialize the stored vector instead
- //we store this vector so that work() doesn't spend its time allocating and freeing vector storage
- if(d_vlen > 1) {
+{
+ this->set_history(length);
+ // we don't have C++11's <array>, so initialize the stored vector instead
+ // we store this vector so that work() doesn't spend its time allocating and freeing
+ // vector storage
+ if (d_vlen > 1) {
d_sum = std::vector<T>(d_vlen);
- }
- }
-
- template <class T>
- moving_average_impl<T> ::~moving_average_impl()
- {
- }
-
- template <class T>
- void
- moving_average_impl<T> ::set_length_and_scale(int length, T scale)
- {
- d_new_length = length;
- d_new_scale = scale;
- d_updated = true;
}
-
- template <class T>
- void
- moving_average_impl<T> ::set_length(int length)
- {
- d_new_length = length;
- d_updated = true;
- }
-
- template <class T>
- void
- moving_average_impl<T> ::set_scale(T scale)
- {
- d_new_scale = scale;
- d_updated = true;
- }
-
- template <class T>
- int
- moving_average_impl<T> ::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- if(d_updated) {
+}
+
+template <class T>
+moving_average_impl<T>::~moving_average_impl()
+{
+}
+
+template <class T>
+void moving_average_impl<T>::set_length_and_scale(int length, T scale)
+{
+ d_new_length = length;
+ d_new_scale = scale;
+ d_updated = true;
+}
+
+template <class T>
+void moving_average_impl<T>::set_length(int length)
+{
+ d_new_length = length;
+ d_updated = true;
+}
+
+template <class T>
+void moving_average_impl<T>::set_scale(T scale)
+{
+ d_new_scale = scale;
+ d_updated = true;
+}
+
+template <class T>
+int moving_average_impl<T>::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;
this->set_history(d_length);
d_updated = false;
return 0; // history requirements might have changed
- }
+ }
- const T *in = (const T *)input_items[0];
- T *out = (T *)output_items[0];
+ const T* in = (const T*)input_items[0];
+ T* out = (T*)output_items[0];
- unsigned int num_iter = (unsigned int)((noutput_items>d_max_iter) ? d_max_iter : noutput_items);
- if(d_vlen == 1) {
+ unsigned int num_iter =
+ (unsigned int)((noutput_items > d_max_iter) ? d_max_iter : noutput_items);
+ if (d_vlen == 1) {
T sum = in[0];
- for(int i = 1; i < d_length-1; i++) {
- sum += in[i];
+ for (int i = 1; i < d_length - 1; i++) {
+ sum += in[i];
}
- for(unsigned int i = 0; i < num_iter; i++) {
- sum += in[i+d_length-1];
- out[i] = sum * d_scale;
- sum -= in[i];
+ for (unsigned int i = 0; i < num_iter; i++) {
+ sum += in[i + d_length - 1];
+ out[i] = sum * d_scale;
+ sum -= in[i];
}
- } else { // d_vlen > 1
- //gets automatically optimized well
- for(unsigned int elem = 0; elem < d_vlen; elem++) {
- d_sum[elem] = in[elem];
+ } else { // d_vlen > 1
+ // gets automatically optimized well
+ for (unsigned int elem = 0; elem < d_vlen; elem++) {
+ d_sum[elem] = in[elem];
}
- for(int i = 1; i < d_length - 1; i++) {
- for(unsigned int elem = 0; elem < d_vlen; elem++) {
- d_sum[elem] += in[i*d_vlen + elem];
- }
+ for (int i = 1; i < d_length - 1; i++) {
+ for (unsigned int elem = 0; elem < d_vlen; elem++) {
+ d_sum[elem] += in[i * d_vlen + elem];
+ }
}
- for(unsigned int i = 0; i < num_iter; i++) {
- for(unsigned int elem = 0; elem < d_vlen; elem++) {
- d_sum[elem] += in[(i+d_length-1)*d_vlen + elem];
- out[i*d_vlen + elem] = d_sum[elem] * d_scale;
- d_sum[elem] -= in[i*d_vlen + elem];
- }
+ for (unsigned int i = 0; i < num_iter; i++) {
+ for (unsigned int elem = 0; elem < d_vlen; elem++) {
+ d_sum[elem] += in[(i + d_length - 1) * d_vlen + elem];
+ out[i * d_vlen + elem] = d_sum[elem] * d_scale;
+ d_sum[elem] -= in[i * d_vlen + elem];
+ }
}
- }
- return num_iter;
}
+ return num_iter;
+}
template class moving_average<std::int16_t>;
template class moving_average<std::int32_t>;
template class moving_average<float>;
template class moving_average<gr_complex>;
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/moving_average_impl.h b/gr-blocks/lib/moving_average_impl.h
index a4e248d05d..bb29e26d23 100644
--- a/gr-blocks/lib/moving_average_impl.h
+++ b/gr-blocks/lib/moving_average_impl.h
@@ -29,44 +29,41 @@
#include <algorithm>
namespace gr {
- namespace blocks {
+namespace blocks {
-template<class T>
- class moving_average_impl : public moving_average<T>
- {
- private:
- int d_length;
- T d_scale;
- int d_max_iter;
- unsigned int d_vlen;
- std::vector<T> d_sum;
+template <class T>
+class moving_average_impl : public moving_average<T>
+{
+private:
+ int d_length;
+ T d_scale;
+ int d_max_iter;
+ unsigned int d_vlen;
+ std::vector<T> d_sum;
- int d_new_length;
- T d_new_scale;
- bool d_updated;
+ int d_new_length;
+ T d_new_scale;
+ bool d_updated;
- public:
- moving_average_impl (int length, T scale,
- int max_iter = 4096,
- unsigned int vlen = 1);
- ~moving_average_impl ();
+public:
+ moving_average_impl(int length, T scale, int max_iter = 4096, unsigned int vlen = 1);
+ ~moving_average_impl();
- int length() const { return d_new_length; }
- T scale() const { return d_new_scale; }
- unsigned int vlen() const { return d_vlen; }
+ int length() const { return d_new_length; }
+ T scale() const { return d_new_scale; }
+ unsigned int vlen() const { return d_vlen; }
- void set_length_and_scale(int length, T scale);
- void set_length(int length);
- void set_scale(T scale);
+ void set_length_and_scale(int length, T scale);
+ void set_length(int length);
+ void set_scale(T scale);
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- };
-
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* MOVING_AVERAGE_IMPL_H */
diff --git a/gr-blocks/lib/multiply_by_tag_value_cc_impl.cc b/gr-blocks/lib/multiply_by_tag_value_cc_impl.cc
index 01b6a548c6..9907106bc5 100644
--- a/gr-blocks/lib/multiply_by_tag_value_cc_impl.cc
+++ b/gr-blocks/lib/multiply_by_tag_value_cc_impl.cc
@@ -29,100 +29,91 @@
#include <volk/volk.h>
namespace gr {
- namespace blocks {
-
- multiply_by_tag_value_cc::sptr
- multiply_by_tag_value_cc::make(const std::string& tag_name,
- size_t vlen)
- {
- return gnuradio::get_initial_sptr
- (new multiply_by_tag_value_cc_impl(tag_name, vlen));
- }
-
- multiply_by_tag_value_cc_impl::multiply_by_tag_value_cc_impl(const std::string& tag_name,
- size_t vlen)
- : sync_block("multiply_by_tag_value_cc",
- io_signature::make (1, 1, sizeof (gr_complex)*vlen),
- io_signature::make (1, 1, sizeof (gr_complex)*vlen)),
- d_vlen(vlen), d_k(gr_complex(1,0))
- {
- d_tag_key = pmt::intern(tag_name);
-
- const int alignment_multiple =
- volk_get_alignment() / sizeof(gr_complex);
- set_alignment(std::max(1,alignment_multiple));
- }
-
- multiply_by_tag_value_cc_impl::~multiply_by_tag_value_cc_impl()
- {
- }
-
- gr_complex
- multiply_by_tag_value_cc_impl::k() const
- {
- return d_k;
- }
-
- int
- multiply_by_tag_value_cc_impl::work(int noutput_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<tag_t> tags;
- get_tags_in_window(tags, 0, 0, noutput_items, d_tag_key);
-
- std::vector<tag_t>::iterator itag = tags.begin();
-
- int start = 0, end;
- while(itag != tags.end()) {
+namespace blocks {
+
+multiply_by_tag_value_cc::sptr multiply_by_tag_value_cc::make(const std::string& tag_name,
+ size_t vlen)
+{
+ return gnuradio::get_initial_sptr(new multiply_by_tag_value_cc_impl(tag_name, vlen));
+}
+
+multiply_by_tag_value_cc_impl::multiply_by_tag_value_cc_impl(const std::string& tag_name,
+ size_t vlen)
+ : sync_block("multiply_by_tag_value_cc",
+ io_signature::make(1, 1, sizeof(gr_complex) * vlen),
+ io_signature::make(1, 1, sizeof(gr_complex) * vlen)),
+ d_vlen(vlen),
+ d_k(gr_complex(1, 0))
+{
+ d_tag_key = pmt::intern(tag_name);
+
+ const int alignment_multiple = volk_get_alignment() / sizeof(gr_complex);
+ set_alignment(std::max(1, alignment_multiple));
+}
+
+multiply_by_tag_value_cc_impl::~multiply_by_tag_value_cc_impl() {}
+
+gr_complex multiply_by_tag_value_cc_impl::k() const { return d_k; }
+
+int multiply_by_tag_value_cc_impl::work(int noutput_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<tag_t> tags;
+ get_tags_in_window(tags, 0, 0, noutput_items, d_tag_key);
+
+ std::vector<tag_t>::iterator itag = tags.begin();
+
+ int start = 0, end;
+ while (itag != tags.end()) {
end = itag->offset - nitems_read(0);
end *= d_vlen;
// Multiply based on the current value of k from 'start' to 'end'
- volk_32fc_s32fc_multiply_32fc(&out[start], &in[start], d_k, (end-start));
+ volk_32fc_s32fc_multiply_32fc(&out[start], &in[start], d_k, (end - start));
start = end;
// Extract new value of k
pmt::pmt_t k = itag->value;
- if(pmt::is_complex(k)) {
- d_k = pmt::to_complex(k);
- }
- else if(pmt::is_number(k)) {
- d_k = gr_complex(pmt::to_double(k), 0);
- }
- else {
- GR_LOG_WARN(d_logger,
- boost::format("Got key '%1%' with incompatible value of '%2%'") \
- % pmt::write_string(d_tag_key) % pmt::write_string(k));
+ if (pmt::is_complex(k)) {
+ d_k = pmt::to_complex(k);
+ } else if (pmt::is_number(k)) {
+ d_k = gr_complex(pmt::to_double(k), 0);
+ } else {
+ GR_LOG_WARN(d_logger,
+ boost::format("Got key '%1%' with incompatible value of '%2%'") %
+ pmt::write_string(d_tag_key) % pmt::write_string(k));
}
itag++;
- }
+ }
- volk_32fc_s32fc_multiply_32fc(&out[start], &in[start], d_k,
- (d_vlen*noutput_items-start));
+ volk_32fc_s32fc_multiply_32fc(
+ &out[start], &in[start], d_k, (d_vlen * noutput_items - start));
- return noutput_items;
- }
+ return noutput_items;
+}
- void
- multiply_by_tag_value_cc_impl::setup_rpc()
- {
+void multiply_by_tag_value_cc_impl::setup_rpc()
+{
#ifdef GR_CTRLPORT
- add_rpc_variable(
+ add_rpc_variable(
rpcbasic_sptr(new rpcbasic_register_get<multiply_by_tag_value_cc, gr_complex>(
- alias(), "Constant",
- &multiply_by_tag_value_cc::k,
- pmt::from_complex(-1024.0f, 0.0f),
- pmt::from_complex(1024.0f, 0.0f),
- pmt::from_complex(0.0f, 0.0f),
- "", "Constant to multiply", RPC_PRIVLVL_MIN,
- DISPTIME | DISPOPTCPLX | DISPOPTSTRIP)));
+ alias(),
+ "Constant",
+ &multiply_by_tag_value_cc::k,
+ pmt::from_complex(-1024.0f, 0.0f),
+ pmt::from_complex(1024.0f, 0.0f),
+ pmt::from_complex(0.0f, 0.0f),
+ "",
+ "Constant to multiply",
+ RPC_PRIVLVL_MIN,
+ DISPTIME | DISPOPTCPLX | DISPOPTSTRIP)));
#endif /* GR_CTRLPORT */
- }
+}
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/multiply_by_tag_value_cc_impl.h b/gr-blocks/lib/multiply_by_tag_value_cc_impl.h
index 23adcc9aab..ff45ee3c6c 100644
--- a/gr-blocks/lib/multiply_by_tag_value_cc_impl.h
+++ b/gr-blocks/lib/multiply_by_tag_value_cc_impl.h
@@ -26,31 +26,29 @@
#include <gnuradio/blocks/multiply_by_tag_value_cc.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class BLOCKS_API multiply_by_tag_value_cc_impl
- : public multiply_by_tag_value_cc
- {
- private:
- size_t d_vlen;
- pmt::pmt_t d_tag_key;
- gr_complex d_k;
+class BLOCKS_API multiply_by_tag_value_cc_impl : public multiply_by_tag_value_cc
+{
+private:
+ size_t d_vlen;
+ pmt::pmt_t d_tag_key;
+ gr_complex d_k;
- public:
- multiply_by_tag_value_cc_impl(const std::string& tag_name,
- size_t vlen);
- ~multiply_by_tag_value_cc_impl();
+public:
+ multiply_by_tag_value_cc_impl(const std::string& tag_name, size_t vlen);
+ ~multiply_by_tag_value_cc_impl();
- gr_complex k() const;
+ gr_complex k() const;
- void setup_rpc();
+ void setup_rpc();
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_MULTIPLY_BY_TAG_VALUE_CC_IMPL_H */
diff --git a/gr-blocks/lib/multiply_conjugate_cc_impl.cc b/gr-blocks/lib/multiply_conjugate_cc_impl.cc
index a6d47cb070..7bb57f8792 100644
--- a/gr-blocks/lib/multiply_conjugate_cc_impl.cc
+++ b/gr-blocks/lib/multiply_conjugate_cc_impl.cc
@@ -29,38 +29,36 @@
#include <volk/volk.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- multiply_conjugate_cc::sptr multiply_conjugate_cc::make(size_t vlen)
- {
- return gnuradio::get_initial_sptr(new multiply_conjugate_cc_impl(vlen));
- }
+multiply_conjugate_cc::sptr multiply_conjugate_cc::make(size_t vlen)
+{
+ return gnuradio::get_initial_sptr(new multiply_conjugate_cc_impl(vlen));
+}
- multiply_conjugate_cc_impl::multiply_conjugate_cc_impl(size_t vlen)
- : sync_block("multiply_conjugate_cc",
- io_signature::make (2, 2, sizeof(gr_complex)*vlen),
- io_signature::make (1, 1, sizeof(gr_complex)*vlen)),
- d_vlen(vlen)
- {
- const int alignment_multiple =
- volk_get_alignment() / sizeof(gr_complex);
- set_alignment(std::max(1, alignment_multiple));
- }
+multiply_conjugate_cc_impl::multiply_conjugate_cc_impl(size_t vlen)
+ : sync_block("multiply_conjugate_cc",
+ io_signature::make(2, 2, sizeof(gr_complex) * vlen),
+ io_signature::make(1, 1, sizeof(gr_complex) * vlen)),
+ d_vlen(vlen)
+{
+ const int alignment_multiple = volk_get_alignment() / sizeof(gr_complex);
+ set_alignment(std::max(1, alignment_multiple));
+}
- int
- multiply_conjugate_cc_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- gr_complex *in0 = (gr_complex *) input_items[0];
- gr_complex *in1 = (gr_complex *) input_items[1];
- gr_complex *out = (gr_complex *) output_items[0];
- int noi = d_vlen*noutput_items;
+int multiply_conjugate_cc_impl::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ gr_complex* in0 = (gr_complex*)input_items[0];
+ gr_complex* in1 = (gr_complex*)input_items[1];
+ gr_complex* out = (gr_complex*)output_items[0];
+ int noi = d_vlen * noutput_items;
- volk_32fc_x2_multiply_conjugate_32fc(out, in0, in1, noi);
+ volk_32fc_x2_multiply_conjugate_32fc(out, in0, in1, noi);
- return noutput_items;
- }
+ return noutput_items;
+}
- } /* namespace blocks */
-}/* namespace gr */
+} /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/multiply_conjugate_cc_impl.h b/gr-blocks/lib/multiply_conjugate_cc_impl.h
index ef4d73bb32..1f7f31091d 100644
--- a/gr-blocks/lib/multiply_conjugate_cc_impl.h
+++ b/gr-blocks/lib/multiply_conjugate_cc_impl.h
@@ -26,21 +26,21 @@
#include <gnuradio/blocks/multiply_conjugate_cc.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class BLOCKS_API multiply_conjugate_cc_impl : public multiply_conjugate_cc
- {
- size_t d_vlen;
+class BLOCKS_API multiply_conjugate_cc_impl : public multiply_conjugate_cc
+{
+ size_t d_vlen;
- public:
- multiply_conjugate_cc_impl(size_t vlen);
+public:
+ multiply_conjugate_cc_impl(size_t vlen);
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/multiply_const_impl.cc b/gr-blocks/lib/multiply_const_impl.cc
index 03ac054a0e..bd6f442fc2 100644
--- a/gr-blocks/lib/multiply_const_impl.cc
+++ b/gr-blocks/lib/multiply_const_impl.cc
@@ -30,110 +30,108 @@
#include <volk/volk.h>
namespace gr {
- namespace blocks {
-
- template <class T>
- typename multiply_const<T>::sptr multiply_const<T>::make(T k, size_t vlen)
- {
- return gnuradio::get_initial_sptr(new multiply_const_impl<T> (k, vlen));
- }
-
- template <>
- multiply_const_impl<float>::multiply_const_impl(float k, size_t vlen)
- : sync_block ("multiply_const_ff",
- io_signature::make (1, 1, sizeof (float)*vlen),
- io_signature::make (1, 1, sizeof (float)*vlen)),
- d_k(k), d_vlen(vlen)
- {
- const int alignment_multiple =
- volk_get_alignment() / sizeof(float);
- set_alignment(std::max(1,alignment_multiple));
- }
-
- template<>
- int
- multiply_const_impl<float>::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];
- int noi = noutput_items * d_vlen;
-
- volk_32f_s32f_multiply_32f(out, in, d_k, noi);
-
- return noutput_items;
- }
-
- template <>
- multiply_const_impl<gr_complex>::multiply_const_impl(gr_complex k, size_t vlen)
- : sync_block ("multiply_const_cc",
- io_signature::make (1, 1, sizeof (gr_complex)*vlen),
- io_signature::make (1, 1, sizeof (gr_complex)*vlen)),
- d_k(k), d_vlen(vlen)
- {
- const int alignment_multiple =
- volk_get_alignment() / sizeof(gr_complex);
- set_alignment(std::max(1,alignment_multiple));
- }
-
- template <>
- int
- multiply_const_impl<gr_complex>::work(int noutput_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 noi = noutput_items * d_vlen;
-
- volk_32fc_s32fc_multiply_32fc(out, in, d_k, noi);
-
- return noutput_items;
+namespace blocks {
+
+template <class T>
+typename multiply_const<T>::sptr multiply_const<T>::make(T k, size_t vlen)
+{
+ return gnuradio::get_initial_sptr(new multiply_const_impl<T>(k, vlen));
+}
+
+template <>
+multiply_const_impl<float>::multiply_const_impl(float k, size_t vlen)
+ : sync_block("multiply_const_ff",
+ io_signature::make(1, 1, sizeof(float) * vlen),
+ io_signature::make(1, 1, sizeof(float) * vlen)),
+ d_k(k),
+ d_vlen(vlen)
+{
+ const int alignment_multiple = volk_get_alignment() / sizeof(float);
+ set_alignment(std::max(1, alignment_multiple));
+}
+
+template <>
+int multiply_const_impl<float>::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];
+ int noi = noutput_items * d_vlen;
+
+ volk_32f_s32f_multiply_32f(out, in, d_k, noi);
+
+ return noutput_items;
+}
+
+template <>
+multiply_const_impl<gr_complex>::multiply_const_impl(gr_complex k, size_t vlen)
+ : sync_block("multiply_const_cc",
+ io_signature::make(1, 1, sizeof(gr_complex) * vlen),
+ io_signature::make(1, 1, sizeof(gr_complex) * vlen)),
+ d_k(k),
+ d_vlen(vlen)
+{
+ const int alignment_multiple = volk_get_alignment() / sizeof(gr_complex);
+ set_alignment(std::max(1, alignment_multiple));
+}
+
+template <>
+int multiply_const_impl<gr_complex>::work(int noutput_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 noi = noutput_items * d_vlen;
+
+ volk_32fc_s32fc_multiply_32fc(out, in, d_k, noi);
+
+ return noutput_items;
+}
+
+
+template <class T>
+multiply_const_impl<T>::multiply_const_impl(T k, size_t vlen)
+ : sync_block("multiply_const",
+ io_signature::make(1, 1, sizeof(T) * vlen),
+ io_signature::make(1, 1, sizeof(T) * vlen)),
+ d_k(k),
+ d_vlen(vlen)
+{
+}
+
+template <class T>
+int multiply_const_impl<T>::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ T* iptr = (T*)input_items[0];
+ T* optr = (T*)output_items[0];
+
+ int size = noutput_items * d_vlen;
+
+ while (size >= 8) {
+ *optr++ = *iptr++ * d_k;
+ *optr++ = *iptr++ * d_k;
+ *optr++ = *iptr++ * d_k;
+ *optr++ = *iptr++ * d_k;
+ *optr++ = *iptr++ * d_k;
+ *optr++ = *iptr++ * d_k;
+ *optr++ = *iptr++ * d_k;
+ *optr++ = *iptr++ * d_k;
+ size -= 8;
}
+ while (size-- > 0)
+ *optr++ = *iptr++ * d_k;
- template <class T>
- multiply_const_impl<T> ::multiply_const_impl(T k, size_t vlen)
- : sync_block ("multiply_const",
- io_signature::make (1, 1, sizeof (T)*vlen),
- io_signature::make (1, 1, sizeof (T)*vlen)),
- d_k(k), d_vlen(vlen)
- {
- }
-
- template <class T>
- int
- multiply_const_impl<T> ::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- T *iptr = (T *) input_items[0];
- T *optr = (T *) output_items[0];
-
- int size = noutput_items * d_vlen;
-
- while (size >= 8){
- *optr++ = *iptr++ * d_k;
- *optr++ = *iptr++ * d_k;
- *optr++ = *iptr++ * d_k;
- *optr++ = *iptr++ * d_k;
- *optr++ = *iptr++ * d_k;
- *optr++ = *iptr++ * d_k;
- *optr++ = *iptr++ * d_k;
- *optr++ = *iptr++ * d_k;
- size -= 8;
- }
-
- while (size-- > 0)
- *optr++ = *iptr++ * d_k;
-
- return noutput_items;
- }
+ return noutput_items;
+}
template class multiply_const<std::int16_t>;
template class multiply_const<std::int32_t>;
template class multiply_const<float>;
template class multiply_const<gr_complex>;
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/multiply_const_impl.h b/gr-blocks/lib/multiply_const_impl.h
index 674fc66609..19501efd80 100644
--- a/gr-blocks/lib/multiply_const_impl.h
+++ b/gr-blocks/lib/multiply_const_impl.h
@@ -27,26 +27,26 @@
#include <gnuradio/blocks/multiply_const.h>
namespace gr {
- namespace blocks {
+namespace blocks {
-template<class T>
- class BLOCKS_API multiply_const_impl : public multiply_const<T>
- {
- T d_k;
- size_t d_vlen;
+template <class T>
+class BLOCKS_API multiply_const_impl : public multiply_const<T>
+{
+ T d_k;
+ size_t d_vlen;
- public:
- multiply_const_impl (T k, size_t vlen);
+public:
+ multiply_const_impl(T k, size_t vlen);
- T k() const { return d_k; }
- void set_k(T k) { d_k = k; }
+ T k() const { return d_k; }
+ void set_k(T k) { d_k = k; }
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* MULTIPLY_CONST_IMPL_H */
diff --git a/gr-blocks/lib/multiply_const_v_impl.cc b/gr-blocks/lib/multiply_const_v_impl.cc
index cab920d90c..172d327d52 100644
--- a/gr-blocks/lib/multiply_const_v_impl.cc
+++ b/gr-blocks/lib/multiply_const_v_impl.cc
@@ -29,110 +29,106 @@
#include <volk/volk.h>
namespace gr {
- namespace blocks {
-
- template <class T>
- typename multiply_const_v<T>::sptr multiply_const_v<T>::make(std::vector<T> k)
- {
- return gnuradio::get_initial_sptr(new multiply_const_v_impl<T>(k));
- }
-
- template <>
- multiply_const_v_impl<float>::multiply_const_v_impl(std::vector<float> k)
- : sync_block("multiply_const_vff",
- io_signature::make(1, 1, sizeof(float)*k.size()),
- io_signature::make(1, 1, sizeof(float)*k.size())),
- d_k(k)
- {
- const int alignment_multiple =
- volk_get_alignment() / sizeof(float);
- set_alignment(std::max(1,alignment_multiple));
- }
-
- template <>
- int
- multiply_const_v_impl<float>::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- float *iptr = (float*)input_items[0];
- float *optr = (float*)output_items[0];
-
- int nitems_per_block = this->output_signature()->sizeof_stream_item(0)/sizeof(float);
-
- for(int i = 0; i < noutput_items; i++) {
- for(int j = 0; j < nitems_per_block; j++) {
- *optr++ = *iptr++ * d_k[j];
+namespace blocks {
+
+template <class T>
+typename multiply_const_v<T>::sptr multiply_const_v<T>::make(std::vector<T> k)
+{
+ return gnuradio::get_initial_sptr(new multiply_const_v_impl<T>(k));
+}
+
+template <>
+multiply_const_v_impl<float>::multiply_const_v_impl(std::vector<float> k)
+ : sync_block("multiply_const_vff",
+ io_signature::make(1, 1, sizeof(float) * k.size()),
+ io_signature::make(1, 1, sizeof(float) * k.size())),
+ d_k(k)
+{
+ const int alignment_multiple = volk_get_alignment() / sizeof(float);
+ set_alignment(std::max(1, alignment_multiple));
+}
+
+template <>
+int multiply_const_v_impl<float>::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ float* iptr = (float*)input_items[0];
+ float* optr = (float*)output_items[0];
+
+ int nitems_per_block =
+ this->output_signature()->sizeof_stream_item(0) / sizeof(float);
+
+ for (int i = 0; i < noutput_items; i++) {
+ for (int j = 0; j < nitems_per_block; j++) {
+ *optr++ = *iptr++ * d_k[j];
}
- }
-
- return noutput_items;
- }
-
- template <>
- multiply_const_v_impl<gr_complex>::multiply_const_v_impl(std::vector<gr_complex> k)
- : sync_block("multiply_const_vcc",
- io_signature::make(1, 1, sizeof(gr_complex)*k.size()),
- io_signature::make(1, 1, sizeof(gr_complex)*k.size())),
- d_k(k)
- {
- const int alignment_multiple =
- volk_get_alignment() / sizeof(gr_complex);
- set_alignment(std::max(1,alignment_multiple));
}
- template <>
- int
- multiply_const_v_impl<gr_complex>::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- gr_complex *iptr = (gr_complex*)input_items[0];
- gr_complex *optr = (gr_complex*)output_items[0];
+ return noutput_items;
+}
- int nitems_per_block = this->output_signature()->sizeof_stream_item(0)/sizeof(gr_complex);
-
- for(int i = 0; i < noutput_items; i++) {
- for(int j = 0; j < nitems_per_block; j++) {
- *optr++ = *iptr++ * d_k[j];
+template <>
+multiply_const_v_impl<gr_complex>::multiply_const_v_impl(std::vector<gr_complex> k)
+ : sync_block("multiply_const_vcc",
+ io_signature::make(1, 1, sizeof(gr_complex) * k.size()),
+ io_signature::make(1, 1, sizeof(gr_complex) * k.size())),
+ d_k(k)
+{
+ const int alignment_multiple = volk_get_alignment() / sizeof(gr_complex);
+ set_alignment(std::max(1, alignment_multiple));
+}
+
+template <>
+int multiply_const_v_impl<gr_complex>::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ gr_complex* iptr = (gr_complex*)input_items[0];
+ gr_complex* optr = (gr_complex*)output_items[0];
+
+ int nitems_per_block =
+ this->output_signature()->sizeof_stream_item(0) / sizeof(gr_complex);
+
+ for (int i = 0; i < noutput_items; i++) {
+ for (int j = 0; j < nitems_per_block; j++) {
+ *optr++ = *iptr++ * d_k[j];
}
- }
-
- return noutput_items;
}
+ return noutput_items;
+}
- template <class T>
- multiply_const_v_impl<T>::multiply_const_v_impl(std::vector<T> k)
- : sync_block ("multiply_const_v<T>",
- io_signature::make (1, 1, sizeof (T)*k.size()),
- io_signature::make (1, 1, sizeof (T)*k.size())),
+template <class T>
+multiply_const_v_impl<T>::multiply_const_v_impl(std::vector<T> k)
+ : sync_block("multiply_const_v<T>",
+ io_signature::make(1, 1, sizeof(T) * k.size()),
+ io_signature::make(1, 1, sizeof(T) * k.size())),
d_k(k)
- {
- }
-
- template <class T>
- int
- multiply_const_v_impl<T>::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- T *iptr = (T *)input_items[0];
- T *optr = (T *)output_items[0];
-
- int nitems_per_block = this->output_signature()->sizeof_stream_item(0)/sizeof(T);
-
- for (int i = 0; i < noutput_items; i++)
- for (int j = 0; j < nitems_per_block; j++)
- *optr++ = *iptr++ * d_k[j];
-
- return noutput_items;
- }
-
- template class multiply_const_v<std::int16_t>;
- template class multiply_const_v<std::int32_t>;
- template class multiply_const_v<float>;
- template class multiply_const_v<gr_complex>;
- } /* namespace blocks */
+{
+}
+
+template <class T>
+int multiply_const_v_impl<T>::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ T* iptr = (T*)input_items[0];
+ T* optr = (T*)output_items[0];
+
+ int nitems_per_block = this->output_signature()->sizeof_stream_item(0) / sizeof(T);
+
+ for (int i = 0; i < noutput_items; i++)
+ for (int j = 0; j < nitems_per_block; j++)
+ *optr++ = *iptr++ * d_k[j];
+
+ return noutput_items;
+}
+
+template class multiply_const_v<std::int16_t>;
+template class multiply_const_v<std::int32_t>;
+template class multiply_const_v<float>;
+template class multiply_const_v<gr_complex>;
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/multiply_const_v_impl.h b/gr-blocks/lib/multiply_const_v_impl.h
index a329c12dd3..70bae818ac 100644
--- a/gr-blocks/lib/multiply_const_v_impl.h
+++ b/gr-blocks/lib/multiply_const_v_impl.h
@@ -26,25 +26,25 @@
#include <gnuradio/blocks/multiply_const_v.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- template <class T>
- class BLOCKS_API multiply_const_v_impl : public multiply_const_v<T>
- {
- std::vector<T> d_k;
+template <class T>
+class BLOCKS_API multiply_const_v_impl : public multiply_const_v<T>
+{
+ std::vector<T> d_k;
- public:
- multiply_const_v_impl(std::vector<T> k);
+public:
+ multiply_const_v_impl(std::vector<T> k);
- std::vector<T> k() const { return d_k; }
- void set_k(std::vector<T> k) { d_k = k; }
+ std::vector<T> k() const { return d_k; }
+ void set_k(std::vector<T> k) { d_k = k; }
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* MULTIPLY_CONST_V_IMPL_H */
diff --git a/gr-blocks/lib/multiply_impl.cc b/gr-blocks/lib/multiply_impl.cc
index 22845251fb..5778f17ba7 100644
--- a/gr-blocks/lib/multiply_impl.cc
+++ b/gr-blocks/lib/multiply_impl.cc
@@ -30,103 +30,98 @@
#include <volk/volk.h>
namespace gr {
- namespace blocks {
-
- template <class T>
- typename multiply<T>::sptr multiply<T>::make(size_t vlen)
- {
- return gnuradio::get_initial_sptr(new multiply_impl<T> (vlen));
- }
-
- template <>
- multiply_impl<float>::multiply_impl(size_t vlen)
- : sync_block("multiply_ff",
- io_signature::make (1, -1, sizeof(float)*vlen),
- io_signature::make (1, 1, sizeof(float)*vlen)),
- d_vlen(vlen)
- {
- const int alignment_multiple =
- volk_get_alignment() / sizeof(float);
- set_alignment(std::max(1, alignment_multiple));
- }
-
- template<>
- int
- multiply_impl<float>::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- float *out = (float *) output_items[0];
- int noi = d_vlen*noutput_items;
-
- memcpy(out, input_items[0], noi*sizeof(float));
- for(size_t i = 1; i < input_items.size(); i++)
+namespace blocks {
+
+template <class T>
+typename multiply<T>::sptr multiply<T>::make(size_t vlen)
+{
+ return gnuradio::get_initial_sptr(new multiply_impl<T>(vlen));
+}
+
+template <>
+multiply_impl<float>::multiply_impl(size_t vlen)
+ : sync_block("multiply_ff",
+ io_signature::make(1, -1, sizeof(float) * vlen),
+ io_signature::make(1, 1, sizeof(float) * vlen)),
+ d_vlen(vlen)
+{
+ const int alignment_multiple = volk_get_alignment() / sizeof(float);
+ set_alignment(std::max(1, alignment_multiple));
+}
+
+template <>
+int multiply_impl<float>::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ float* out = (float*)output_items[0];
+ int noi = d_vlen * noutput_items;
+
+ memcpy(out, input_items[0], noi * sizeof(float));
+ for (size_t i = 1; i < input_items.size(); i++)
volk_32f_x2_multiply_32f(out, out, (float*)input_items[i], noi);
- return noutput_items;
- }
-
- template <>
- multiply_impl<gr_complex>::multiply_impl(size_t vlen)
- : sync_block("multiply_cc",
- io_signature::make (1, -1, sizeof(gr_complex)*vlen),
- io_signature::make (1, 1, sizeof(gr_complex)*vlen)),
- d_vlen(vlen)
- {
- const int alignment_multiple =
- volk_get_alignment() / sizeof(gr_complex);
- set_alignment(std::max(1, alignment_multiple));
- }
+ return noutput_items;
+}
- template <>
- int
- multiply_impl<gr_complex>::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- gr_complex *out = (gr_complex *) output_items[0];
- int noi = d_vlen*noutput_items;
-
- memcpy(out, input_items[0], noi*sizeof(gr_complex));
- for(size_t i = 1; i < input_items.size(); i++)
+template <>
+multiply_impl<gr_complex>::multiply_impl(size_t vlen)
+ : sync_block("multiply_cc",
+ io_signature::make(1, -1, sizeof(gr_complex) * vlen),
+ io_signature::make(1, 1, sizeof(gr_complex) * vlen)),
+ d_vlen(vlen)
+{
+ const int alignment_multiple = volk_get_alignment() / sizeof(gr_complex);
+ set_alignment(std::max(1, alignment_multiple));
+}
+
+template <>
+int multiply_impl<gr_complex>::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ gr_complex* out = (gr_complex*)output_items[0];
+ int noi = d_vlen * noutput_items;
+
+ memcpy(out, input_items[0], noi * sizeof(gr_complex));
+ for (size_t i = 1; i < input_items.size(); i++)
volk_32fc_x2_multiply_32fc(out, out, (gr_complex*)input_items[i], noi);
- return noutput_items;
- }
+ return noutput_items;
+}
- template <class T>
- multiply_impl<T> ::multiply_impl(size_t vlen)
- : sync_block ("multiply",
- io_signature::make (1, -1, sizeof (T)*vlen),
- io_signature::make (1, 1, sizeof (T)*vlen)),
+template <class T>
+multiply_impl<T>::multiply_impl(size_t vlen)
+ : sync_block("multiply",
+ io_signature::make(1, -1, sizeof(T) * vlen),
+ io_signature::make(1, 1, sizeof(T) * vlen)),
d_vlen(vlen)
- {
- }
-
- template <class T>
- int
- multiply_impl<T> ::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- T *optr = (T *) output_items[0];
+{
+}
- int ninputs = input_items.size ();
+template <class T>
+int multiply_impl<T>::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ T* optr = (T*)output_items[0];
- for (size_t i = 0; i < noutput_items*d_vlen; i++){
- T acc = ((T *) input_items[0])[i];
- for (int j = 1; j < ninputs; j++)
- acc *= ((T *) input_items[j])[i];
+ int ninputs = input_items.size();
- *optr++ = (T) acc;
- }
+ for (size_t i = 0; i < noutput_items * d_vlen; i++) {
+ T acc = ((T*)input_items[0])[i];
+ for (int j = 1; j < ninputs; j++)
+ acc *= ((T*)input_items[j])[i];
- return noutput_items;
+ *optr++ = (T)acc;
}
+ return noutput_items;
+}
+
template class multiply<std::int16_t>;
template class multiply<std::int32_t>;
template class multiply<gr_complex>;
template class multiply<float>;
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/multiply_impl.h b/gr-blocks/lib/multiply_impl.h
index 7f75f85f9f..4c8d4d3ccb 100644
--- a/gr-blocks/lib/multiply_impl.h
+++ b/gr-blocks/lib/multiply_impl.h
@@ -27,21 +27,21 @@
#include <gnuradio/blocks/multiply.h>
namespace gr {
- namespace blocks {
+namespace blocks {
-template<class T>
- class BLOCKS_API multiply_impl : public multiply<T>
- {
- size_t d_vlen;
+template <class T>
+class BLOCKS_API multiply_impl : public multiply<T>
+{
+ size_t d_vlen;
- public:
- multiply_impl (size_t vlen);
+public:
+ multiply_impl(size_t vlen);
- int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
- };
- } /* namespace blocks */
+ int work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
+} /* namespace blocks */
} /* namespace gr */
#endif /* MULTIPLY_IMPL_H */
diff --git a/gr-blocks/lib/multiply_matrix_impl.cc b/gr-blocks/lib/multiply_matrix_impl.cc
index 60053e7f56..eb0a77409d 100644
--- a/gr-blocks/lib/multiply_matrix_impl.cc
+++ b/gr-blocks/lib/multiply_matrix_impl.cc
@@ -29,299 +29,296 @@
#include "multiply_matrix_impl.h"
namespace gr {
- namespace blocks {
+namespace blocks {
- // Copy tags from input k to output l if A[l][k] is not zero
- template <>
- void
- multiply_matrix_impl<gr_complex>::propagate_tags_by_A(int noutput_items, size_t ninput_ports, size_t noutput_ports)
- {
- std::vector<gr::tag_t> tags;
- for (size_t in_idx = 0; in_idx < ninput_ports; in_idx++) {
- this->get_tags_in_window(
- tags,
- in_idx,
- 0,
- noutput_items
- );
+// Copy tags from input k to output l if A[l][k] is not zero
+template <>
+void multiply_matrix_impl<gr_complex>::propagate_tags_by_A(int noutput_items,
+ size_t ninput_ports,
+ size_t noutput_ports)
+{
+ std::vector<gr::tag_t> tags;
+ for (size_t in_idx = 0; in_idx < ninput_ports; in_idx++) {
+ this->get_tags_in_window(tags, in_idx, 0, noutput_items);
for (size_t out_idx = 0; out_idx < noutput_ports; out_idx++) {
- if (d_A[out_idx][in_idx] == std::complex<float>(0, 0)) {
- continue;
- }
- for (size_t i = 0; i < tags.size(); i++) {
- this->add_item_tag(out_idx, tags[i]);
- }
+ if (d_A[out_idx][in_idx] == std::complex<float>(0, 0)) {
+ continue;
+ }
+ for (size_t i = 0; i < tags.size(); i++) {
+ this->add_item_tag(out_idx, tags[i]);
+ }
}
- }
}
+}
- // Check dimensions before copying
- template <>
- bool
- multiply_matrix_impl<gr_complex>::set_A(const std::vector<std::vector<gr_complex> > &new_A)
- {
- if (d_A.size() != new_A.size()) {
+// Check dimensions before copying
+template <>
+bool multiply_matrix_impl<gr_complex>::set_A(
+ const std::vector<std::vector<gr_complex>>& new_A)
+{
+ if (d_A.size() != new_A.size()) {
GR_LOG_ALERT(d_logger, "Attempted to set matrix with invalid dimensions.");
return false;
- }
- for (size_t i = 0; i < d_A.size(); i++) {
+ }
+ for (size_t i = 0; i < d_A.size(); i++) {
if (d_A[i].size() != new_A[i].size()) {
- GR_LOG_ALERT(d_logger, "Attempted to set matrix with invalid dimensions.");
- return false;
+ GR_LOG_ALERT(d_logger, "Attempted to set matrix with invalid dimensions.");
+ return false;
}
- }
- d_A = new_A;
- return true;
}
+ d_A = new_A;
+ return true;
+}
- template <>
- void
- multiply_matrix_impl<gr_complex>::msg_handler_A(pmt::pmt_t A)
- {
- if (!pmt::is_vector(A) && !pmt::is_tuple(A)) {
- GR_LOG_ALERT(d_logger, "Invalid message to set A (wrong type).");
- return;
- }
- if (pmt::length(A) != d_A.size()) {
- GR_LOG_ALERT(d_logger, "Invalid message to set A (wrong size).");
- return;
- }
+template <>
+void multiply_matrix_impl<gr_complex>::msg_handler_A(pmt::pmt_t A)
+{
+ if (!pmt::is_vector(A) && !pmt::is_tuple(A)) {
+ GR_LOG_ALERT(d_logger, "Invalid message to set A (wrong type).");
+ return;
+ }
+ if (pmt::length(A) != d_A.size()) {
+ GR_LOG_ALERT(d_logger, "Invalid message to set A (wrong size).");
+ return;
+ }
- std::vector<std::vector<gr_complex> > new_A(d_A);
- for (size_t i = 0; i < pmt::length(A); i++) {
+ std::vector<std::vector<gr_complex>> new_A(d_A);
+ for (size_t i = 0; i < pmt::length(A); i++) {
pmt::pmt_t row;
if (pmt::is_vector(A)) {
- row = pmt::vector_ref(A, i);
+ row = pmt::vector_ref(A, i);
} else if (pmt::is_tuple(A)) {
- row = pmt::tuple_ref(A, i);
+ row = pmt::tuple_ref(A, i);
}
if (pmt::is_vector(row) || pmt::is_tuple(row)) {
- if (pmt::length(row) != d_A[0].size()) {
- GR_LOG_ALERT(d_logger, "Invalid message to set A (wrong number of columns).");
- return;
- }
- for (size_t k = 0; k < pmt::length(row); k++) {
- new_A[i][k] = pmt::to_complex(pmt::is_vector(row) ? pmt::vector_ref(row, k) : pmt::tuple_ref(row, k));
- }
+ if (pmt::length(row) != d_A[0].size()) {
+ GR_LOG_ALERT(d_logger,
+ "Invalid message to set A (wrong number of columns).");
+ return;
+ }
+ for (size_t k = 0; k < pmt::length(row); k++) {
+ new_A[i][k] =
+ pmt::to_complex(pmt::is_vector(row) ? pmt::vector_ref(row, k)
+ : pmt::tuple_ref(row, k));
+ }
} else if (pmt::is_c32vector(row)) {
- size_t row_len = 0;
- const gr_complex *elements = pmt::c32vector_elements(row, row_len);
- if (row_len != d_A[0].size()) {
- GR_LOG_ALERT(d_logger, "Invalid message to set A (wrong number of columns).");
- return;
- }
- new_A[i].assign(elements, elements + row_len);
+ size_t row_len = 0;
+ const gr_complex* elements = pmt::c32vector_elements(row, row_len);
+ if (row_len != d_A[0].size()) {
+ GR_LOG_ALERT(d_logger,
+ "Invalid message to set A (wrong number of columns).");
+ return;
+ }
+ new_A[i].assign(elements, elements + row_len);
}
- }
+ }
- if (!set_A(new_A)) {
- GR_LOG_ALERT(d_logger, "Invalid message to set A.");
- }
+ if (!set_A(new_A)) {
+ GR_LOG_ALERT(d_logger, "Invalid message to set A.");
}
+}
- // Copy tags from input k to output l if A[l][k] is not zero
- template <>
- void
- multiply_matrix_impl<float>::propagate_tags_by_A(int noutput_items, size_t ninput_ports, size_t noutput_ports)
- {
- std::vector<gr::tag_t> tags;
- for (size_t in_idx = 0; in_idx < ninput_ports; in_idx++) {
- get_tags_in_window(
- tags,
- in_idx,
- 0,
- noutput_items
- );
+// Copy tags from input k to output l if A[l][k] is not zero
+template <>
+void multiply_matrix_impl<float>::propagate_tags_by_A(int noutput_items,
+ size_t ninput_ports,
+ size_t noutput_ports)
+{
+ std::vector<gr::tag_t> tags;
+ for (size_t in_idx = 0; in_idx < ninput_ports; in_idx++) {
+ get_tags_in_window(tags, in_idx, 0, noutput_items);
for (size_t out_idx = 0; out_idx < noutput_ports; out_idx++) {
- if (d_A[out_idx][in_idx] == 0) {
- continue;
- }
- for (size_t i = 0; i < tags.size(); i++) {
- add_item_tag(out_idx, tags[i]);
- }
+ if (d_A[out_idx][in_idx] == 0) {
+ continue;
+ }
+ for (size_t i = 0; i < tags.size(); i++) {
+ add_item_tag(out_idx, tags[i]);
+ }
}
- }
}
+}
- // Check dimensions before copying
- template <>
- bool
- multiply_matrix_impl<float>::set_A(const std::vector<std::vector<float> > &new_A)
- {
- if (d_A.size() != new_A.size()) {
+// Check dimensions before copying
+template <>
+bool multiply_matrix_impl<float>::set_A(const std::vector<std::vector<float>>& new_A)
+{
+ if (d_A.size() != new_A.size()) {
GR_LOG_ALERT(d_logger, "Attempted to set matrix with invalid dimensions.");
return false;
- }
- for (size_t i = 0; i < d_A.size(); i++) {
+ }
+ for (size_t i = 0; i < d_A.size(); i++) {
if (d_A[i].size() != new_A[i].size()) {
- GR_LOG_ALERT(d_logger, "Attempted to set matrix with invalid dimensions.");
- return false;
+ GR_LOG_ALERT(d_logger, "Attempted to set matrix with invalid dimensions.");
+ return false;
}
- }
- d_A = new_A;
- return true;
}
+ d_A = new_A;
+ return true;
+}
- template <>
- void
- multiply_matrix_impl<float>::msg_handler_A(pmt::pmt_t A)
- {
- if (!pmt::is_vector(A) && !pmt::is_tuple(A)) {
- GR_LOG_ALERT(d_logger, "Invalid message to set A (wrong type).");
- return;
- }
- if (pmt::length(A) != d_A.size()) {
- GR_LOG_ALERT(d_logger, "Invalid message to set A (wrong size).");
- return;
- }
+template <>
+void multiply_matrix_impl<float>::msg_handler_A(pmt::pmt_t A)
+{
+ if (!pmt::is_vector(A) && !pmt::is_tuple(A)) {
+ GR_LOG_ALERT(d_logger, "Invalid message to set A (wrong type).");
+ return;
+ }
+ if (pmt::length(A) != d_A.size()) {
+ GR_LOG_ALERT(d_logger, "Invalid message to set A (wrong size).");
+ return;
+ }
- std::vector<std::vector<float> > new_A(d_A);
- for (size_t i = 0; i < pmt::length(A); i++) {
+ std::vector<std::vector<float>> new_A(d_A);
+ for (size_t i = 0; i < pmt::length(A); i++) {
pmt::pmt_t row;
if (pmt::is_vector(A)) {
- row = pmt::vector_ref(A, i);
+ row = pmt::vector_ref(A, i);
} else if (pmt::is_tuple(A)) {
- row = pmt::tuple_ref(A, i);
+ row = pmt::tuple_ref(A, i);
}
if (pmt::is_vector(row) || pmt::is_tuple(row)) {
- if (pmt::length(row) != d_A[0].size()) {
- GR_LOG_ALERT(d_logger, "Invalid message to set A (wrong number of columns).");
- return;
- }
- for (size_t k = 0; k < pmt::length(row); k++) {
- new_A[i][k] = pmt::to_double(pmt::is_vector(row) ? pmt::vector_ref(row, k) : pmt::tuple_ref(row, k));
- }
+ if (pmt::length(row) != d_A[0].size()) {
+ GR_LOG_ALERT(d_logger,
+ "Invalid message to set A (wrong number of columns).");
+ return;
+ }
+ for (size_t k = 0; k < pmt::length(row); k++) {
+ new_A[i][k] =
+ pmt::to_double(pmt::is_vector(row) ? pmt::vector_ref(row, k)
+ : pmt::tuple_ref(row, k));
+ }
} else if (pmt::is_f32vector(row)) {
- size_t row_len = 0;
- const float *elements = pmt::f32vector_elements(row, row_len);
- if (row_len != d_A[0].size()) {
- GR_LOG_ALERT(d_logger, "Invalid message to set A (wrong number of columns).");
- return;
- }
- new_A[i].assign(elements, elements + row_len);
+ size_t row_len = 0;
+ const float* elements = pmt::f32vector_elements(row, row_len);
+ if (row_len != d_A[0].size()) {
+ GR_LOG_ALERT(d_logger,
+ "Invalid message to set A (wrong number of columns).");
+ return;
+ }
+ new_A[i].assign(elements, elements + row_len);
}
- }
-
- if (!set_A(new_A)) {
- GR_LOG_ALERT(d_logger, "Invalid message to set A.");
- }
}
+ if (!set_A(new_A)) {
+ GR_LOG_ALERT(d_logger, "Invalid message to set A.");
+ }
+}
- template <class T>
- typename multiply_matrix<T>::sptr
- multiply_matrix<T>::make(std::vector<std::vector<T> > A, gr::block::tag_propagation_policy_t tag_propagation_policy)
- {
- if (A.empty() || A[0].size() == 0) {
+template <class T>
+typename multiply_matrix<T>::sptr
+multiply_matrix<T>::make(std::vector<std::vector<T>> A,
+ gr::block::tag_propagation_policy_t tag_propagation_policy)
+{
+ if (A.empty() || A[0].size() == 0) {
throw std::invalid_argument("matrix A has invalid dimensions.");
- }
- return gnuradio::get_initial_sptr
- (new multiply_matrix_impl<T>(A, tag_propagation_policy));
}
+ return gnuradio::get_initial_sptr(
+ new multiply_matrix_impl<T>(A, tag_propagation_policy));
+}
- template <>
- multiply_matrix_impl<gr_complex>::multiply_matrix_impl(std::vector<std::vector<gr_complex> > A, gr::block::tag_propagation_policy_t tag_propagation_policy)
- : gr::sync_block("multiply_matrix_cc",
- gr::io_signature::make(A[0].size(), A[0].size(), sizeof(gr_complex)),
- gr::io_signature::make(A.size(), A.size(), sizeof(gr_complex))),
- d_A(A)
- { this->MSG_PORT_NAME_SET_A = "set_A";
- this->set_tag_propagation_policy(tag_propagation_policy);
- const int alignment_multiple = volk_get_alignment() / sizeof(gr_complex);
- set_alignment(std::max(1, alignment_multiple));
+template <>
+multiply_matrix_impl<gr_complex>::multiply_matrix_impl(
+ std::vector<std::vector<gr_complex>> A,
+ gr::block::tag_propagation_policy_t tag_propagation_policy)
+ : gr::sync_block("multiply_matrix_cc",
+ gr::io_signature::make(A[0].size(), A[0].size(), sizeof(gr_complex)),
+ gr::io_signature::make(A.size(), A.size(), sizeof(gr_complex))),
+ d_A(A)
+{
+ this->MSG_PORT_NAME_SET_A = "set_A";
+ this->set_tag_propagation_policy(tag_propagation_policy);
+ const int alignment_multiple = volk_get_alignment() / sizeof(gr_complex);
+ set_alignment(std::max(1, alignment_multiple));
- pmt::pmt_t port_name = pmt::string_to_symbol("set_A");
- message_port_register_in(port_name);
- set_msg_handler(
- port_name,
- boost::bind(&multiply_matrix_impl<gr_complex>::msg_handler_A, this, _1)
- );
- }
+ pmt::pmt_t port_name = pmt::string_to_symbol("set_A");
+ message_port_register_in(port_name);
+ set_msg_handler(
+ port_name,
+ boost::bind(&multiply_matrix_impl<gr_complex>::msg_handler_A, this, _1));
+}
- template <>
- multiply_matrix_impl<float>::multiply_matrix_impl(std::vector<std::vector<float> > A, gr::block::tag_propagation_policy_t tag_propagation_policy)
- : gr::sync_block("multiply_matrix_ff",
- gr::io_signature::make(A[0].size(), A[0].size(), sizeof(float)),
- gr::io_signature::make(A.size(), A.size(), sizeof(float))),
- d_A(A)
- { this->MSG_PORT_NAME_SET_A = "set_A";
- this->set_tag_propagation_policy(tag_propagation_policy);
- const int alignment_multiple = volk_get_alignment() / sizeof(float);
- set_alignment(std::max(1, alignment_multiple));
+template <>
+multiply_matrix_impl<float>::multiply_matrix_impl(
+ std::vector<std::vector<float>> A,
+ gr::block::tag_propagation_policy_t tag_propagation_policy)
+ : gr::sync_block("multiply_matrix_ff",
+ gr::io_signature::make(A[0].size(), A[0].size(), sizeof(float)),
+ gr::io_signature::make(A.size(), A.size(), sizeof(float))),
+ d_A(A)
+{
+ this->MSG_PORT_NAME_SET_A = "set_A";
+ this->set_tag_propagation_policy(tag_propagation_policy);
+ const int alignment_multiple = volk_get_alignment() / sizeof(float);
+ set_alignment(std::max(1, alignment_multiple));
- pmt::pmt_t port_name = pmt::string_to_symbol("set_A");
- message_port_register_in(port_name);
- set_msg_handler(
- port_name,
- boost::bind(&multiply_matrix_impl<float>::msg_handler_A, this, _1)
- );
- }
+ pmt::pmt_t port_name = pmt::string_to_symbol("set_A");
+ message_port_register_in(port_name);
+ set_msg_handler(port_name,
+ boost::bind(&multiply_matrix_impl<float>::msg_handler_A, this, _1));
+}
+template <class T>
+multiply_matrix_impl<T>::~multiply_matrix_impl()
+{
+}
- template <class T>
- multiply_matrix_impl<T>::~multiply_matrix_impl()
- {
- }
-
- template <>
- int
- multiply_matrix_impl<gr_complex>::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- for (size_t out_idx = 0; out_idx < output_items.size(); out_idx++) {
- gr_complex *out = reinterpret_cast<gr_complex *>(output_items[out_idx]);
+template <>
+int multiply_matrix_impl<gr_complex>::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ for (size_t out_idx = 0; out_idx < output_items.size(); out_idx++) {
+ gr_complex* out = reinterpret_cast<gr_complex*>(output_items[out_idx]);
// Do input 0 first, this saves a memset
- const gr_complex *in = reinterpret_cast<const gr_complex *>(input_items[0]);
+ const gr_complex* in = reinterpret_cast<const gr_complex*>(input_items[0]);
volk_32fc_s32fc_multiply_32fc(out, in, d_A[out_idx][0], noutput_items);
// Then do inputs 1 through N
for (size_t in_idx = 1; in_idx < input_items.size(); in_idx++) {
- in = reinterpret_cast<const gr_complex *>(input_items[in_idx]);
- // Yeah, this needs VOLK-ifying (TODO)
- for (int i = 0; i < noutput_items; i++) {
- out[i] += in[i] * d_A[out_idx][in_idx];
- }
+ in = reinterpret_cast<const gr_complex*>(input_items[in_idx]);
+ // Yeah, this needs VOLK-ifying (TODO)
+ for (int i = 0; i < noutput_items; i++) {
+ out[i] += in[i] * d_A[out_idx][in_idx];
+ }
}
- }
- if (tag_propagation_policy() == TPP_CUSTOM) {
+ }
+ if (tag_propagation_policy() == TPP_CUSTOM) {
propagate_tags_by_A(noutput_items, input_items.size(), output_items.size());
- }
- return noutput_items;
}
+ return noutput_items;
+}
- template <>
- int
- multiply_matrix_impl<float>::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- for (size_t out_idx = 0; out_idx < output_items.size(); out_idx++) {
- float *out = reinterpret_cast<float *>(output_items[out_idx]);
+template <>
+int multiply_matrix_impl<float>::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ for (size_t out_idx = 0; out_idx < output_items.size(); out_idx++) {
+ float* out = reinterpret_cast<float*>(output_items[out_idx]);
// Do input 0 first, this saves a memset
- const float *in = reinterpret_cast<const float *>(input_items[0]);
+ const float* in = reinterpret_cast<const float*>(input_items[0]);
volk_32f_s32f_multiply_32f(out, in, d_A[out_idx][0], noutput_items);
// Then do inputs 1 through N
for (size_t in_idx = 1; in_idx < input_items.size(); in_idx++) {
- in = reinterpret_cast<const float *>(input_items[in_idx]);
- // Yeah, this needs VOLK-ifying (TODO)
- for (int i = 0; i < noutput_items; i++) {
- out[i] += in[i] * d_A[out_idx][in_idx];
- }
+ in = reinterpret_cast<const float*>(input_items[in_idx]);
+ // Yeah, this needs VOLK-ifying (TODO)
+ for (int i = 0; i < noutput_items; i++) {
+ out[i] += in[i] * d_A[out_idx][in_idx];
+ }
}
- }
- if (tag_propagation_policy() == TPP_CUSTOM) {
+ }
+ if (tag_propagation_policy() == TPP_CUSTOM) {
propagate_tags_by_A(noutput_items, input_items.size(), output_items.size());
- }
- return noutput_items;
}
+ return noutput_items;
+}
- template class multiply_matrix<float>;
- template class multiply_matrix<gr_complex>;
+template class multiply_matrix<float>;
+template class multiply_matrix<gr_complex>;
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/multiply_matrix_impl.h b/gr-blocks/lib/multiply_matrix_impl.h
index bb5477e805..6cbac7d5a6 100644
--- a/gr-blocks/lib/multiply_matrix_impl.h
+++ b/gr-blocks/lib/multiply_matrix_impl.h
@@ -1,19 +1,19 @@
/* -*- c++ -*- */
-/*
+/*
* Copyright 2014,2017-2018 Free Software Foundation, Inc.
- *
+ *
* This file is part of GNU Radio
- *
+ *
* GNU Radio is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
- *
+ *
* GNU Radio is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Radio; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
@@ -26,31 +26,33 @@
#include <gnuradio/blocks/multiply_matrix.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- template <class T>
- class multiply_matrix_impl : public multiply_matrix<T>
- {
- private:
- std::vector<std::vector<T> > d_A;
+template <class T>
+class multiply_matrix_impl : public multiply_matrix<T>
+{
+private:
+ std::vector<std::vector<T>> d_A;
- void propagate_tags_by_A(int noutput_items, size_t ninput_ports, size_t noutput_ports);
+ void
+ propagate_tags_by_A(int noutput_items, size_t ninput_ports, size_t noutput_ports);
- void msg_handler_A(pmt::pmt_t A);
+ void msg_handler_A(pmt::pmt_t A);
- public:
- multiply_matrix_impl(std::vector<std::vector<T> > A, gr::block::tag_propagation_policy_t tag_propagation_policy);
- ~multiply_matrix_impl();
+public:
+ multiply_matrix_impl(std::vector<std::vector<T>> A,
+ gr::block::tag_propagation_policy_t tag_propagation_policy);
+ ~multiply_matrix_impl();
- const std::vector<std::vector<T> >& get_A() const { return d_A; };
- bool set_A(const std::vector<std::vector<T> > &new_A);
+ const std::vector<std::vector<T>>& get_A() const { return d_A; };
+ bool set_A(const std::vector<std::vector<T>>& new_A);
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } // namespace blocks
+} // namespace blocks
} // namespace gr
#endif /* INCLUDED_BLOCKS_MULTIPLY_MATRIX_IMPL_H */
diff --git a/gr-blocks/lib/mute_impl.cc b/gr-blocks/lib/mute_impl.cc
index 081dd81b35..34c0d4094e 100644
--- a/gr-blocks/lib/mute_impl.cc
+++ b/gr-blocks/lib/mute_impl.cc
@@ -30,70 +30,66 @@
#include <string.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- template <class T>
- typename mute_blk<T>::sptr
- mute_blk<T>::make(bool mute)
- {
- return gnuradio::get_initial_sptr
- (new mute_impl<T> (mute));
- }
+template <class T>
+typename mute_blk<T>::sptr mute_blk<T>::make(bool mute)
+{
+ return gnuradio::get_initial_sptr(new mute_impl<T>(mute));
+}
- template <class T>
- mute_impl<T> ::mute_impl(bool mute)
+template <class T>
+mute_impl<T>::mute_impl(bool mute)
: sync_block("mute",
- io_signature::make(1, 1, sizeof(T)),
- io_signature::make(1, 1, sizeof(T))),
+ io_signature::make(1, 1, sizeof(T)),
+ io_signature::make(1, 1, sizeof(T))),
d_mute(mute)
- {
- this->message_port_register_in(pmt::intern("set_mute"));
- this->set_msg_handler(pmt::intern("set_mute"),
- boost::bind(&mute_impl<T> ::set_mute_pmt, this, _1));
- }
+{
+ this->message_port_register_in(pmt::intern("set_mute"));
+ this->set_msg_handler(pmt::intern("set_mute"),
+ boost::bind(&mute_impl<T>::set_mute_pmt, this, _1));
+}
- template <class T>
- mute_impl<T> ::~mute_impl()
- {
- }
+template <class T>
+mute_impl<T>::~mute_impl()
+{
+}
- template <class T>
- int
- mute_impl<T> ::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- T *iptr = (T *)input_items[0];
- T *optr = (T *)output_items[0];
+template <class T>
+int mute_impl<T>::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ T* iptr = (T*)input_items[0];
+ T* optr = (T*)output_items[0];
- int size = noutput_items;
+ int size = noutput_items;
- if(d_mute) {
+ if (d_mute) {
memset(optr, 0, noutput_items * sizeof(T));
- }
- else {
- while(size >= 8) {
- *optr++ = *iptr++;
- *optr++ = *iptr++;
- *optr++ = *iptr++;
- *optr++ = *iptr++;
- *optr++ = *iptr++;
- *optr++ = *iptr++;
- *optr++ = *iptr++;
- *optr++ = *iptr++;
- size -= 8;
+ } 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;
+ while (size-- > 0)
+ *optr++ = *iptr++;
}
+ return noutput_items;
+}
+
template class mute_blk<std::int16_t>;
template class mute_blk<std::int32_t>;
template class mute_blk<float>;
template class mute_blk<gr_complex>;
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/mute_impl.h b/gr-blocks/lib/mute_impl.h
index 6943e22739..5d54a0c940 100644
--- a/gr-blocks/lib/mute_impl.h
+++ b/gr-blocks/lib/mute_impl.h
@@ -27,28 +27,28 @@
#include <gnuradio/blocks/mute.h>
namespace gr {
- namespace blocks {
+namespace blocks {
-template<class T>
- class mute_impl : public mute_blk<T>
- {
- private:
- bool d_mute;
+template <class T>
+class mute_impl : public mute_blk<T>
+{
+private:
+ bool d_mute;
- public:
- mute_impl (bool mute);
- ~mute_impl ();
+public:
+ mute_impl(bool mute);
+ ~mute_impl();
- bool mute() const { return d_mute; }
- void set_mute(bool mute) { d_mute = mute; }
- void set_mute_pmt(pmt::pmt_t msg) { set_mute(pmt::to_bool(msg)); }
+ bool mute() const { return d_mute; }
+ void set_mute(bool mute) { d_mute = mute; }
+ void set_mute_pmt(pmt::pmt_t msg) { set_mute(pmt::to_bool(msg)); }
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* MUTE_IMPL_H */
diff --git a/gr-blocks/lib/nlog10_ff_impl.cc b/gr-blocks/lib/nlog10_ff_impl.cc
index beabed66c9..16c0cfc86b 100644
--- a/gr-blocks/lib/nlog10_ff_impl.cc
+++ b/gr-blocks/lib/nlog10_ff_impl.cc
@@ -30,47 +30,47 @@
#include <limits>
namespace gr {
- namespace blocks {
+namespace blocks {
- nlog10_ff::sptr nlog10_ff::make(float n, size_t vlen, float k)
- {
- return gnuradio::get_initial_sptr(new nlog10_ff_impl(n, vlen, k));
- }
-
- nlog10_ff_impl::nlog10_ff_impl(float n, size_t vlen, float k)
- : sync_block("nlog10_ff",
- io_signature::make (1, 1, sizeof(float)*vlen),
- io_signature::make (1, 1, sizeof(float)*vlen)),
- d_n_log2_10(n/log2f(10.0f)), d_10_k_n(std::pow(10.0f, k/n)), d_vlen(vlen)
- {
- const int alignment_multiple =
- volk_get_alignment() / sizeof(float);
- set_alignment(std::max(1,alignment_multiple));
- }
+nlog10_ff::sptr nlog10_ff::make(float n, size_t vlen, float k)
+{
+ return gnuradio::get_initial_sptr(new nlog10_ff_impl(n, vlen, k));
+}
- int
- nlog10_ff_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];
- int noi = noutput_items * d_vlen;
+nlog10_ff_impl::nlog10_ff_impl(float n, size_t vlen, float k)
+ : sync_block("nlog10_ff",
+ io_signature::make(1, 1, sizeof(float) * vlen),
+ io_signature::make(1, 1, sizeof(float) * vlen)),
+ d_n_log2_10(n / log2f(10.0f)),
+ d_10_k_n(std::pow(10.0f, k / n)),
+ d_vlen(vlen)
+{
+ const int alignment_multiple = volk_get_alignment() / sizeof(float);
+ set_alignment(std::max(1, alignment_multiple));
+}
- constexpr float float_min = std::numeric_limits<float>::min();
+int nlog10_ff_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];
+ int noi = noutput_items * d_vlen;
- for (int i = 0; i < noi; i++) {
- out[i] = std::max(in[i], float_min);
- }
+ constexpr float float_min = std::numeric_limits<float>::min();
- if (d_10_k_n != 1.0f) {
- volk_32f_s32f_multiply_32f(out, out, d_10_k_n, noi);
- }
- volk_32f_log2_32f(out, out, noi);
- volk_32f_s32f_multiply_32f(out, out, d_n_log2_10, noi);
+ for (int i = 0; i < noi; i++) {
+ out[i] = std::max(in[i], float_min);
+ }
- return noutput_items;
+ if (d_10_k_n != 1.0f) {
+ volk_32f_s32f_multiply_32f(out, out, d_10_k_n, noi);
}
+ volk_32f_log2_32f(out, out, noi);
+ volk_32f_s32f_multiply_32f(out, out, d_n_log2_10, noi);
+
+ return noutput_items;
+}
- } /* namespace blocks */
-}/* namespace gr */
+} /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/nlog10_ff_impl.h b/gr-blocks/lib/nlog10_ff_impl.h
index cac3754679..b59492aff3 100644
--- a/gr-blocks/lib/nlog10_ff_impl.h
+++ b/gr-blocks/lib/nlog10_ff_impl.h
@@ -26,23 +26,23 @@
#include <gnuradio/blocks/nlog10_ff.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class BLOCKS_API nlog10_ff_impl : public nlog10_ff
- {
- float d_n_log2_10;
- float d_10_k_n;
- size_t d_vlen;
+class BLOCKS_API nlog10_ff_impl : public nlog10_ff
+{
+ float d_n_log2_10;
+ float d_10_k_n;
+ size_t d_vlen;
- public:
- nlog10_ff_impl(float n, size_t vlen, float k);
+public:
+ nlog10_ff_impl(float n, size_t vlen, float k);
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/nop_impl.cc b/gr-blocks/lib/nop_impl.cc
index da1398e51a..f079886e03 100644
--- a/gr-blocks/lib/nop_impl.cc
+++ b/gr-blocks/lib/nop_impl.cc
@@ -29,72 +29,71 @@
#include <boost/bind.hpp>
namespace gr {
- namespace blocks {
+namespace blocks {
- nop::sptr
- nop::make(size_t sizeof_stream_item)
- {
- return gnuradio::get_initial_sptr
- (new nop_impl(sizeof_stream_item));
- }
+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)
- : block("nop",
- io_signature::make(0, -1, sizeof_stream_item),
- io_signature::make(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(size_t sizeof_stream_item)
+ : block("nop",
+ io_signature::make(0, -1, sizeof_stream_item),
+ io_signature::make(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()
- {
- }
+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++;
- }
+// 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++)
+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;
- }
+ return noutput_items;
+}
- void
- nop_impl::setup_rpc()
- {
+void nop_impl::setup_rpc()
+{
#ifdef GR_CTRLPORT
- d_rpc_vars.push_back(
- rpcbasic_sptr(new rpcbasic_register_get<nop, int>(
- alias(), "test",
- &nop::ctrlport_test,
- pmt::mp(-256), pmt::mp(255), pmt::mp(0),
- "", "Simple testing variable",
- RPC_PRIVLVL_MIN, DISPNULL)));
+ d_rpc_vars.push_back(
+ rpcbasic_sptr(new rpcbasic_register_get<nop, int>(alias(),
+ "test",
+ &nop::ctrlport_test,
+ pmt::mp(-256),
+ pmt::mp(255),
+ pmt::mp(0),
+ "",
+ "Simple testing variable",
+ RPC_PRIVLVL_MIN,
+ DISPNULL)));
- d_rpc_vars.push_back(
- rpcbasic_sptr(new rpcbasic_register_set<nop, int>(
- alias(), "test",
- &nop::set_ctrlport_test,
- pmt::mp(-256), pmt::mp(255), pmt::mp(0),
- "", "Simple testing variable",
- RPC_PRIVLVL_MIN, DISPNULL)));
+ d_rpc_vars.push_back(
+ rpcbasic_sptr(new rpcbasic_register_set<nop, int>(alias(),
+ "test",
+ &nop::set_ctrlport_test,
+ pmt::mp(-256),
+ pmt::mp(255),
+ pmt::mp(0),
+ "",
+ "Simple testing variable",
+ RPC_PRIVLVL_MIN,
+ DISPNULL)));
#endif /* GR_CTRLPORT */
- }
+}
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/nop_impl.h b/gr-blocks/lib/nop_impl.h
index a76b2a3288..d2e13a1c45 100644
--- a/gr-blocks/lib/nop_impl.h
+++ b/gr-blocks/lib/nop_impl.h
@@ -26,35 +26,35 @@
#include <gnuradio/blocks/nop.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class nop_impl : public nop
- {
- protected:
- int d_nmsgs_recvd;
- int d_ctrlport_test;
+class nop_impl : public nop
+{
+protected:
+ int d_nmsgs_recvd;
+ int d_ctrlport_test;
- // Method that just counts any received messages.
- void count_received_msgs(pmt::pmt_t msg);
+ // 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();
+public:
+ nop_impl(size_t sizeof_stream_item);
+ ~nop_impl();
- void setup_rpc();
+ void setup_rpc();
- int nmsgs_received() const { return d_nmsgs_recvd; }
+ int nmsgs_received() const { return d_nmsgs_recvd; }
- int ctrlport_test() const { return d_ctrlport_test; }
- void set_ctrlport_test(int x) { d_ctrlport_test = x; }
+ int ctrlport_test() const { return d_ctrlport_test; }
+ void set_ctrlport_test(int x) { d_ctrlport_test = x; }
- int general_work(int noutput_items,
- gr_vector_int &ninput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
- };
+ 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 blocks */
} /* namespace gr */
#endif /* INCLUDED_GR_NOP_IMPL_H */
diff --git a/gr-blocks/lib/not_blk_impl.cc b/gr-blocks/lib/not_blk_impl.cc
index 3c3dea5a15..366671353d 100644
--- a/gr-blocks/lib/not_blk_impl.cc
+++ b/gr-blocks/lib/not_blk_impl.cc
@@ -29,42 +29,41 @@
#include <gnuradio/io_signature.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- template <class T>
- typename not_blk<T>::sptr not_blk<T>::make(size_t vlen)
- {
- return gnuradio::get_initial_sptr(new not_blk_impl<T> (vlen));
- }
+template <class T>
+typename not_blk<T>::sptr not_blk<T>::make(size_t vlen)
+{
+ return gnuradio::get_initial_sptr(new not_blk_impl<T>(vlen));
+}
- template <class T>
- not_blk_impl<T> ::not_blk_impl(size_t vlen)
- : sync_block ("not_blk",
- io_signature::make (1, 1, sizeof (T)*vlen),
- io_signature::make (1, 1, sizeof (T)*vlen)),
+template <class T>
+not_blk_impl<T>::not_blk_impl(size_t vlen)
+ : sync_block("not_blk",
+ io_signature::make(1, 1, sizeof(T) * vlen),
+ io_signature::make(1, 1, sizeof(T) * vlen)),
d_vlen(vlen)
- {
- }
+{
+}
- template <class T>
- int
- not_blk_impl<T> ::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- T *optr = (T *) output_items[0];
- const T *inptr = (const T *) input_items[0];
+template <class T>
+int not_blk_impl<T>::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ T* optr = (T*)output_items[0];
+ const T* inptr = (const T*)input_items[0];
- int noi = noutput_items*d_vlen;
+ int noi = noutput_items * d_vlen;
- for (int i = 0; i < noi; i++)
- *optr++ = ~(inptr[i]);
+ for (int i = 0; i < noi; i++)
+ *optr++ = ~(inptr[i]);
- return noutput_items;
- }
+ return noutput_items;
+}
template class not_blk<std::uint8_t>;
template class not_blk<std::int16_t>;
template class not_blk<std::int32_t>;
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/not_blk_impl.h b/gr-blocks/lib/not_blk_impl.h
index 77050adee2..432ffbbdd1 100644
--- a/gr-blocks/lib/not_blk_impl.h
+++ b/gr-blocks/lib/not_blk_impl.h
@@ -27,22 +27,22 @@
#include <gnuradio/blocks/not_blk.h>
namespace gr {
- namespace blocks {
+namespace blocks {
-template<class T>
- class BLOCKS_API not_blk_impl : public not_blk<T>
- {
- size_t d_vlen;
+template <class T>
+class BLOCKS_API not_blk_impl : public not_blk<T>
+{
+ size_t d_vlen;
- public:
- not_blk_impl (size_t vlen);
+public:
+ not_blk_impl(size_t vlen);
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* NOT_BLK_IMPL_H */
diff --git a/gr-blocks/lib/null_sink_impl.cc b/gr-blocks/lib/null_sink_impl.cc
index 14dd5eff24..12a32819f5 100644
--- a/gr-blocks/lib/null_sink_impl.cc
+++ b/gr-blocks/lib/null_sink_impl.cc
@@ -28,33 +28,28 @@
#include <gnuradio/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)
- : sync_block("null_sink",
- io_signature::make(1, -1, sizeof_stream_item),
- io_signature::make(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 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)
+ : sync_block("null_sink",
+ io_signature::make(1, -1, sizeof_stream_item),
+ io_signature::make(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
index 948bc19de6..6d307a16c4 100644
--- a/gr-blocks/lib/null_sink_impl.h
+++ b/gr-blocks/lib/null_sink_impl.h
@@ -26,20 +26,20 @@
#include <gnuradio/blocks/null_sink.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class null_sink_impl : public null_sink
- {
- public:
- null_sink_impl(size_t sizeof_stream_item);
- ~null_sink_impl();
+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);
- };
+ int work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* 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
index 9550dd6bce..9c4b3c610b 100644
--- a/gr-blocks/lib/null_source_impl.cc
+++ b/gr-blocks/lib/null_source_impl.cc
@@ -29,38 +29,33 @@
#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)
- : sync_block("null_source",
- io_signature::make(0, 0, 0),
- io_signature::make(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;
- for(size_t n = 0; n < input_items.size(); n++) {
+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)
+ : sync_block("null_source",
+ io_signature::make(0, 0, 0),
+ io_signature::make(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;
+ for (size_t n = 0; n < input_items.size(); n++) {
optr = (void*)output_items[n];
memset(optr, 0, noutput_items * output_signature()->sizeof_stream_item(n));
- }
- return noutput_items;
}
+ return noutput_items;
+}
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/null_source_impl.h b/gr-blocks/lib/null_source_impl.h
index 887c77d424..c514e92ead 100644
--- a/gr-blocks/lib/null_source_impl.h
+++ b/gr-blocks/lib/null_source_impl.h
@@ -26,20 +26,20 @@
#include <gnuradio/blocks/null_source.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class null_source_impl : public null_source
- {
- public:
- null_source_impl(size_t sizeof_stream_item);
- ~null_source_impl();
+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);
- };
+ int work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_GR_NULL_SOURCE_IMPL_H */
diff --git a/gr-blocks/lib/or_blk_impl.cc b/gr-blocks/lib/or_blk_impl.cc
index ca04e8e4fa..f47849b4ba 100644
--- a/gr-blocks/lib/or_blk_impl.cc
+++ b/gr-blocks/lib/or_blk_impl.cc
@@ -30,28 +30,34 @@
namespace gr {
namespace blocks {
-template <class T> typename or_blk<T>::sptr or_blk<T>::make(size_t vlen) {
+template <class T>
+typename or_blk<T>::sptr or_blk<T>::make(size_t vlen)
+{
return gnuradio::get_initial_sptr(new or_blk_impl<T>(vlen));
}
template <class T>
or_blk_impl<T>::or_blk_impl(size_t vlen)
- : sync_block("or_blk", io_signature::make(1, -1, sizeof(T) * vlen),
+ : sync_block("or_blk",
+ io_signature::make(1, -1, sizeof(T) * vlen),
io_signature::make(1, 1, sizeof(T) * vlen)),
- d_vlen(vlen) {}
+ d_vlen(vlen)
+{
+}
template <class T>
int or_blk_impl<T>::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items) {
- T *optr = (T *)output_items[0];
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ T* optr = (T*)output_items[0];
int ninputs = input_items.size();
for (size_t i = 0; i < noutput_items * d_vlen; i++) {
- T acc = ((T *)input_items[0])[i];
+ T acc = ((T*)input_items[0])[i];
for (int j = 1; j < ninputs; j++)
- acc |= ((T *)input_items[j])[i];
+ acc |= ((T*)input_items[j])[i];
*optr++ = (T)acc;
}
diff --git a/gr-blocks/lib/or_blk_impl.h b/gr-blocks/lib/or_blk_impl.h
index fbff19a24d..b4c97c7694 100644
--- a/gr-blocks/lib/or_blk_impl.h
+++ b/gr-blocks/lib/or_blk_impl.h
@@ -26,22 +26,22 @@
#include <gnuradio/blocks/or_blk.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- template<class T>
- class BLOCKS_API or_blk_impl : public or_blk<T>
- {
- size_t d_vlen;
+template <class T>
+class BLOCKS_API or_blk_impl : public or_blk<T>
+{
+ size_t d_vlen;
- public:
- or_blk_impl(size_t vlen);
+public:
+ or_blk_impl(size_t vlen);
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* OR_BLK_IMPL_H */
diff --git a/gr-blocks/lib/pack_k_bits.cc b/gr-blocks/lib/pack_k_bits.cc
index ad6e78ae18..8ff5f638ff 100644
--- a/gr-blocks/lib/pack_k_bits.cc
+++ b/gr-blocks/lib/pack_k_bits.cc
@@ -29,42 +29,39 @@
#include <iostream>
namespace gr {
- namespace blocks {
- namespace kernel {
+namespace blocks {
+namespace kernel {
- pack_k_bits::pack_k_bits(unsigned k)
- : d_k(k)
- {
- if(d_k == 0)
- throw std::out_of_range("pack_k_bits: k must be > 0");
- }
+pack_k_bits::pack_k_bits(unsigned k) : d_k(k)
+{
+ if (d_k == 0)
+ throw std::out_of_range("pack_k_bits: k must be > 0");
+}
- pack_k_bits::~pack_k_bits()
- {
- }
+pack_k_bits::~pack_k_bits() {}
- void
- pack_k_bits::pack(unsigned char *bytes, const unsigned char *bits, int nbytes) const
- {
- for(int i = 0; i < nbytes; i++) {
- bytes[i] = 0x00;
- for(unsigned int j = 0; j < d_k; j++) {
- bytes[i] |= (0x01 & bits[i*d_k+j])<<(d_k-j-1);
- }
+void pack_k_bits::pack(unsigned char* bytes, const unsigned char* bits, int nbytes) const
+{
+ for (int i = 0; i < nbytes; i++) {
+ bytes[i] = 0x00;
+ for (unsigned int j = 0; j < d_k; j++) {
+ bytes[i] |= (0x01 & bits[i * d_k + j]) << (d_k - j - 1);
}
- }
+ }
+}
- void
- pack_k_bits::pack_rev(unsigned char *bytes, const unsigned char *bits, int nbytes) const
- {
- for(int i = 0; i < nbytes; i++) {
- bytes[i] = 0x00;
- for(unsigned int j = 0; j < d_k; j++) {
- bytes[i] |= (0x01 & bits[i*d_k+j])<<j;
- }
+void pack_k_bits::pack_rev(unsigned char* bytes,
+ const unsigned char* bits,
+ int nbytes) const
+{
+ for (int i = 0; i < nbytes; i++) {
+ bytes[i] = 0x00;
+ for (unsigned int j = 0; j < d_k; j++) {
+ bytes[i] |= (0x01 & bits[i * d_k + j]) << j;
}
- }
+ }
+}
- } /* namespace kernel */
- } /* namespace blocks */
+} /* namespace kernel */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/pack_k_bits_bb_impl.cc b/gr-blocks/lib/pack_k_bits_bb_impl.cc
index 889e0d29f4..06c422b923 100644
--- a/gr-blocks/lib/pack_k_bits_bb_impl.cc
+++ b/gr-blocks/lib/pack_k_bits_bb_impl.cc
@@ -30,41 +30,35 @@
#include <iostream>
namespace gr {
- namespace blocks {
+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::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)
- : sync_decimator("pack_k_bits_bb",
- io_signature::make(1, 1, sizeof(unsigned char)),
- io_signature::make(1, 1, sizeof(unsigned char)),
- k)
- {
- d_pack = new kernel::pack_k_bits(k);
- }
+pack_k_bits_bb_impl::pack_k_bits_bb_impl(unsigned k)
+ : sync_decimator("pack_k_bits_bb",
+ io_signature::make(1, 1, sizeof(unsigned char)),
+ io_signature::make(1, 1, sizeof(unsigned char)),
+ k)
+{
+ d_pack = new kernel::pack_k_bits(k);
+}
- pack_k_bits_bb_impl::~pack_k_bits_bb_impl()
- {
- delete d_pack;
- }
+pack_k_bits_bb_impl::~pack_k_bits_bb_impl() { delete d_pack; }
- 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];
+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];
- d_pack->pack(out, in, noutput_items);
+ d_pack->pack(out, in, noutput_items);
- return noutput_items;
- }
+ return noutput_items;
+}
- } /* namespace blocks */
+} /* 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
index 2cf4f28fc3..6459a1e811 100644
--- a/gr-blocks/lib/pack_k_bits_bb_impl.h
+++ b/gr-blocks/lib/pack_k_bits_bb_impl.h
@@ -21,29 +21,29 @@
*/
#ifndef INCLUDED_GR_PACK_K_BITS_BB_IMPL_H
-#define INCLUDED_GR_PACK_K_BITS_BB_IMPL_H
+#define INCLUDED_GR_PACK_K_BITS_BB_IMPL_H
#include <gnuradio/blocks/pack_k_bits_bb.h>
#include <gnuradio/blocks/pack_k_bits.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class pack_k_bits_bb_impl : public pack_k_bits_bb
- {
- private:
- kernel::pack_k_bits *d_pack;
+class pack_k_bits_bb_impl : public pack_k_bits_bb
+{
+private:
+ kernel::pack_k_bits* d_pack;
- public:
- pack_k_bits_bb_impl(unsigned k);
- ~pack_k_bits_bb_impl();
+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);
- };
+ int work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_GR_PACK_K_BITS_BB_IMPL_H */
diff --git a/gr-blocks/lib/packed_to_unpacked_impl.cc b/gr-blocks/lib/packed_to_unpacked_impl.cc
index 8b13371e58..f63e040b2a 100644
--- a/gr-blocks/lib/packed_to_unpacked_impl.cc
+++ b/gr-blocks/lib/packed_to_unpacked_impl.cc
@@ -30,123 +30,125 @@
#include <assert.h>
namespace gr {
- namespace blocks {
-
- template <class T>
- typename packed_to_unpacked<T>::sptr
- packed_to_unpacked<T>::make(unsigned int bits_per_chunk,
- endianness_t endianness)
- {
- return gnuradio::get_initial_sptr
- (new packed_to_unpacked_impl<T> (bits_per_chunk, endianness));
- }
-
- template <class T>
- packed_to_unpacked_impl<T> ::packed_to_unpacked_impl(unsigned int bits_per_chunk,
- endianness_t endianness)
+namespace blocks {
+
+template <class T>
+typename packed_to_unpacked<T>::sptr
+packed_to_unpacked<T>::make(unsigned int bits_per_chunk, endianness_t endianness)
+{
+ return gnuradio::get_initial_sptr(
+ new packed_to_unpacked_impl<T>(bits_per_chunk, endianness));
+}
+
+template <class T>
+packed_to_unpacked_impl<T>::packed_to_unpacked_impl(unsigned int bits_per_chunk,
+ endianness_t endianness)
: block("packed_to_unpacked",
- io_signature::make(1, -1, sizeof(T)),
- io_signature::make(1, -1, sizeof(T))),
- d_bits_per_chunk(bits_per_chunk), d_endianness(endianness), d_index(0)
- {
- assert(bits_per_chunk <= this->d_bits_per_type);
- assert(bits_per_chunk > 0);
-
- this->set_relative_rate((uint64_t)this->d_bits_per_type, (uint64_t)bits_per_chunk);
- }
-
- template <class T>
- packed_to_unpacked_impl<T> ::~packed_to_unpacked_impl()
- {
- }
-
- template <class T>
- void
- packed_to_unpacked_impl<T> ::forecast(int noutput_items,
- gr_vector_int &ninput_items_required)
- {
- int input_required = (int)ceil((d_index + noutput_items * d_bits_per_chunk)
- / (1.0 * this->d_bits_per_type));
- unsigned ninputs = ninput_items_required.size();
- for(unsigned int i = 0; i < ninputs; i++) {
+ io_signature::make(1, -1, sizeof(T)),
+ io_signature::make(1, -1, sizeof(T))),
+ d_bits_per_chunk(bits_per_chunk),
+ d_endianness(endianness),
+ d_index(0)
+{
+ assert(bits_per_chunk <= this->d_bits_per_type);
+ assert(bits_per_chunk > 0);
+
+ this->set_relative_rate((uint64_t)this->d_bits_per_type, (uint64_t)bits_per_chunk);
+}
+
+template <class T>
+packed_to_unpacked_impl<T>::~packed_to_unpacked_impl()
+{
+}
+
+template <class T>
+void packed_to_unpacked_impl<T>::forecast(int noutput_items,
+ gr_vector_int& ninput_items_required)
+{
+ int input_required = (int)ceil((d_index + noutput_items * d_bits_per_chunk) /
+ (1.0 * this->d_bits_per_type));
+ unsigned ninputs = ninput_items_required.size();
+ for (unsigned int i = 0; i < ninputs; i++) {
ninput_items_required[i] = input_required;
- //printf("Forecast wants %d needs %d\n",noutput_items,ninput_items_required[i]);
- }
+ // printf("Forecast wants %d needs %d\n",noutput_items,ninput_items_required[i]);
}
-
- template <class T>
- unsigned int
- packed_to_unpacked_impl<T>::get_bit_le(const T *in_vector, unsigned int bit_addr)
- {
- T x = in_vector[bit_addr >> this->d_log2_l_type];
- return (x >> (bit_addr & (this->d_bits_per_type-1))) & 1;
- }
-
- template <class T>
- unsigned int
- packed_to_unpacked_impl<T>::get_bit_be(const T *in_vector, unsigned int bit_addr)
- {
- T x = in_vector[bit_addr >> this->d_log2_l_type];
- return (x >> ((this->d_bits_per_type-1) - (bit_addr & (this->d_bits_per_type-1)))) & 1;
- }
-
- template <class T>
- int
- packed_to_unpacked_impl<T> ::general_work(int noutput_items,
- gr_vector_int &ninput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- unsigned int index_tmp = d_index;
-
- assert(input_items.size() == output_items.size());
- int nstreams = input_items.size();
-
- for (int m=0; m < nstreams; m++){
- const T *in = (T *)input_items[m];
- T *out = (T *)output_items[m];
+}
+
+template <class T>
+unsigned int packed_to_unpacked_impl<T>::get_bit_le(const T* in_vector,
+ unsigned int bit_addr)
+{
+ T x = in_vector[bit_addr >> this->d_log2_l_type];
+ return (x >> (bit_addr & (this->d_bits_per_type - 1))) & 1;
+}
+
+template <class T>
+unsigned int packed_to_unpacked_impl<T>::get_bit_be(const T* in_vector,
+ unsigned int bit_addr)
+{
+ T x = in_vector[bit_addr >> this->d_log2_l_type];
+ return (x >>
+ ((this->d_bits_per_type - 1) - (bit_addr & (this->d_bits_per_type - 1)))) &
+ 1;
+}
+
+template <class T>
+int packed_to_unpacked_impl<T>::general_work(int noutput_items,
+ gr_vector_int& ninput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ unsigned int index_tmp = d_index;
+
+ assert(input_items.size() == output_items.size());
+ int nstreams = input_items.size();
+
+ for (int m = 0; m < nstreams; m++) {
+ const T* in = (T*)input_items[m];
+ T* out = (T*)output_items[m];
index_tmp = d_index;
// per stream processing
- switch(d_endianness) {
+ switch (d_endianness) {
case GR_MSB_FIRST:
- for(int i = 0; i < noutput_items; i++) {
- //printf("here msb %d\n",i);
- T x = 0;
- for(unsigned int j = 0; j < d_bits_per_chunk; j++, index_tmp++)
- x = (x<<1) | get_bit_be(in, index_tmp);
- out[i] = x;
- }
- break;
+ for (int i = 0; i < noutput_items; i++) {
+ // printf("here msb %d\n",i);
+ T x = 0;
+ for (unsigned int j = 0; j < d_bits_per_chunk; j++, index_tmp++)
+ x = (x << 1) | get_bit_be(in, index_tmp);
+ out[i] = x;
+ }
+ break;
case GR_LSB_FIRST:
- for(int i = 0; i < noutput_items; i++) {
- //printf("here lsb %d\n",i);
- T x = 0;
- for(unsigned int j = 0; j < d_bits_per_chunk; j++, index_tmp++)
- x = (x<<1) | get_bit_le(in, index_tmp);
- out[i] = x;
- }
- break;
+ for (int i = 0; i < noutput_items; i++) {
+ // printf("here lsb %d\n",i);
+ T x = 0;
+ for (unsigned int j = 0; j < d_bits_per_chunk; j++, index_tmp++)
+ x = (x << 1) | get_bit_le(in, index_tmp);
+ out[i] = x;
+ }
+ break;
default:
- assert(0);
+ assert(0);
}
- //printf("almost got to end\n");
- assert(ninput_items[m] >= (int)((d_index+(this->d_bits_per_type-1)) >> this->d_log2_l_type));
- }
-
- d_index = index_tmp;
- this->consume_each(d_index >> this->d_log2_l_type);
- d_index = d_index & (this->d_bits_per_type-1);
- //printf("got to end\n");
- return noutput_items;
+ // printf("almost got to end\n");
+ assert(ninput_items[m] >=
+ (int)((d_index + (this->d_bits_per_type - 1)) >> this->d_log2_l_type));
}
+ d_index = index_tmp;
+ this->consume_each(d_index >> this->d_log2_l_type);
+ d_index = d_index & (this->d_bits_per_type - 1);
+ // printf("got to end\n");
+ return noutput_items;
+}
+
template class packed_to_unpacked<std::uint8_t>;
template class packed_to_unpacked<std::int16_t>;
template class packed_to_unpacked<std::int32_t>;
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/packed_to_unpacked_impl.h b/gr-blocks/lib/packed_to_unpacked_impl.h
index fd65242478..1ef8b17c48 100644
--- a/gr-blocks/lib/packed_to_unpacked_impl.h
+++ b/gr-blocks/lib/packed_to_unpacked_impl.h
@@ -28,37 +28,34 @@
#include <gnuradio/blocks/log2_const.h>
namespace gr {
- namespace blocks {
-
-template<class T>
- class packed_to_unpacked_impl : public packed_to_unpacked<T>
- {
- private:
- unsigned int d_bits_per_chunk;
- endianness_t d_endianness;
- unsigned int d_index;
- const unsigned int d_bits_per_type = sizeof(T) * 8;
- const unsigned int d_log2_l_type = log2_const<sizeof(T) * 8>();
- unsigned int get_bit_le(const T *in_vector, unsigned int bit_addr);
- unsigned int get_bit_be(const T *in_vector, unsigned int bit_addr);
-
- public:
- packed_to_unpacked_impl (unsigned int bits_per_chunk,
- endianness_t endianness);
- ~packed_to_unpacked_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);
-
- bool check_topology(int ninputs, int noutputs)
- { return ninputs == noutputs; }
- };
-
- } /* namespace blocks */
+namespace blocks {
+
+template <class T>
+class packed_to_unpacked_impl : public packed_to_unpacked<T>
+{
+private:
+ unsigned int d_bits_per_chunk;
+ endianness_t d_endianness;
+ unsigned int d_index;
+ const unsigned int d_bits_per_type = sizeof(T) * 8;
+ const unsigned int d_log2_l_type = log2_const<sizeof(T) * 8>();
+ unsigned int get_bit_le(const T* in_vector, unsigned int bit_addr);
+ unsigned int get_bit_be(const T* in_vector, unsigned int bit_addr);
+
+public:
+ packed_to_unpacked_impl(unsigned int bits_per_chunk, endianness_t endianness);
+ ~packed_to_unpacked_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);
+
+ bool check_topology(int ninputs, int noutputs) { return ninputs == noutputs; }
+};
+
+} /* namespace blocks */
} /* namespace gr */
#endif /* PACKED_TO_UNPACKED_IMPL_H */
diff --git a/gr-blocks/lib/patterned_interleaver_impl.cc b/gr-blocks/lib/patterned_interleaver_impl.cc
index 9ed45abb85..26b56c89a3 100644
--- a/gr-blocks/lib/patterned_interleaver_impl.cc
+++ b/gr-blocks/lib/patterned_interleaver_impl.cc
@@ -28,60 +28,66 @@
#include <gnuradio/io_signature.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- patterned_interleaver::sptr patterned_interleaver::make(size_t itemsize, std::vector<int> pattern)
- {
- return gnuradio::get_initial_sptr(new patterned_interleaver_impl(itemsize, pattern));
- }
+patterned_interleaver::sptr patterned_interleaver::make(size_t itemsize,
+ std::vector<int> pattern)
+{
+ return gnuradio::get_initial_sptr(new patterned_interleaver_impl(itemsize, pattern));
+}
- patterned_interleaver_impl::patterned_interleaver_impl(size_t itemsize, std::vector<int> pattern)
- : block ("patterned_interleaver",
- io_signature::make (pattern_max(pattern)+1, pattern_max(pattern)+1, itemsize),
- io_signature::make (1, 1, itemsize)),
- d_pattern(pattern), d_counts( pattern_max(pattern)+1, 0), d_itemsize(itemsize)
- {
- BOOST_FOREACH( int i, d_pattern)
- { d_counts[i]++; }
- set_output_multiple(d_pattern.size());
+patterned_interleaver_impl::patterned_interleaver_impl(size_t itemsize,
+ std::vector<int> pattern)
+ : block("patterned_interleaver",
+ io_signature::make(
+ pattern_max(pattern) + 1, pattern_max(pattern) + 1, itemsize),
+ io_signature::make(1, 1, itemsize)),
+ d_pattern(pattern),
+ d_counts(pattern_max(pattern) + 1, 0),
+ d_itemsize(itemsize)
+{
+ BOOST_FOREACH (int i, d_pattern) {
+ d_counts[i]++;
}
+ set_output_multiple(d_pattern.size());
+}
- int
- patterned_interleaver_impl::general_work(int noutput_items,
- gr_vector_int &ninput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- size_t nblks = noutput_items/d_pattern.size();
+int patterned_interleaver_impl::general_work(int noutput_items,
+ gr_vector_int& ninput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ size_t nblks = noutput_items / d_pattern.size();
- std::vector<const char*> ii;
- for(size_t i=0; i<input_items.size(); i++){
+ std::vector<const char*> ii;
+ for (size_t i = 0; i < input_items.size(); i++) {
ii.push_back((const char*)input_items[i]);
- }
+ }
- char *oo = (char *) output_items[0];
+ char* oo = (char*)output_items[0];
- for(size_t i=0; i<nblks; i++){
- for(size_t j=0; j<d_pattern.size(); j++){
- memcpy(oo, ii[d_pattern[j]], d_itemsize);
- oo += d_itemsize;
- ii[d_pattern[j]] += d_itemsize;
- }
+ for (size_t i = 0; i < nblks; i++) {
+ for (size_t j = 0; j < d_pattern.size(); j++) {
+ memcpy(oo, ii[d_pattern[j]], d_itemsize);
+ oo += d_itemsize;
+ ii[d_pattern[j]] += d_itemsize;
}
+ }
- for(size_t i=0; i<d_counts.size(); i++){
- consume(i, d_counts[i]*nblks );
- }
- return nblks*d_pattern.size();
+ for (size_t i = 0; i < d_counts.size(); i++) {
+ consume(i, d_counts[i] * nblks);
}
+ return nblks * d_pattern.size();
+}
- void patterned_interleaver_impl::forecast (int noutput_items,
- gr_vector_int &ninput_items_required){
- int nblks = noutput_items / d_pattern.size();
- for(size_t i=0; i<ninput_items_required.size(); i++){
- ninput_items_required[i] = d_counts[i] * nblks;
- }
- }
+void patterned_interleaver_impl::forecast(int noutput_items,
+ gr_vector_int& ninput_items_required)
+{
+ int nblks = noutput_items / d_pattern.size();
+ for (size_t i = 0; i < ninput_items_required.size(); i++) {
+ ninput_items_required[i] = d_counts[i] * nblks;
+ }
+}
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/patterned_interleaver_impl.h b/gr-blocks/lib/patterned_interleaver_impl.h
index 4b78b65e0b..7daedfb224 100644
--- a/gr-blocks/lib/patterned_interleaver_impl.h
+++ b/gr-blocks/lib/patterned_interleaver_impl.h
@@ -27,35 +27,35 @@
#include <boost/foreach.hpp>
namespace gr {
- namespace blocks {
+namespace blocks {
- class BLOCKS_API patterned_interleaver_impl : public patterned_interleaver
- {
- public:
- patterned_interleaver_impl(size_t itemsize, std::vector<int> pattern);
+class BLOCKS_API patterned_interleaver_impl : public patterned_interleaver
+{
+public:
+ patterned_interleaver_impl(size_t itemsize, std::vector<int> pattern);
- int general_work(int noutput_items,
- gr_vector_int &ninput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
+ int general_work(int noutput_items,
+ gr_vector_int& ninput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items);
- int pattern_max(std::vector<int> pattern){
+ int pattern_max(std::vector<int> pattern)
+ {
int mval(0);
- BOOST_FOREACH( int i, pattern)
- { mval = std::max(mval, i); }
- return mval;
+ BOOST_FOREACH (int i, pattern) {
+ mval = std::max(mval, i);
}
+ return mval;
+ }
- void forecast (int noutput_items,
- gr_vector_int &ninput_items_required);
-
- std::vector<int> d_pattern;
- std::vector<int> d_counts;
- size_t d_itemsize;
+ void forecast(int noutput_items, gr_vector_int& ninput_items_required);
- };
+ std::vector<int> d_pattern;
+ std::vector<int> d_counts;
+ size_t d_itemsize;
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif
diff --git a/gr-blocks/lib/pdu.cc b/gr-blocks/lib/pdu.cc
index f0e610209f..3d0db4d5b2 100644
--- a/gr-blocks/lib/pdu.cc
+++ b/gr-blocks/lib/pdu.cc
@@ -27,72 +27,68 @@
#include <gnuradio/blocks/pdu.h>
namespace gr {
- namespace blocks {
- namespace pdu {
+namespace blocks {
+namespace pdu {
- const
- pmt::pmt_t pdu_port_id(){
- static const pmt::pmt_t pdu_port_id = pmt::mp("pdus");
- return pdu_port_id;
- }
+const pmt::pmt_t pdu_port_id()
+{
+ static const pmt::pmt_t pdu_port_id = pmt::mp("pdus");
+ return pdu_port_id;
+}
- 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");
- }
- }
+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::is_u8vector(v);
- case float_t:
- return pmt::is_f32vector(v);
- case complex_t:
- return pmt::is_c32vector(v);
- 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::is_u8vector(v);
+ case float_t:
+ return pmt::is_f32vector(v);
+ case complex_t:
+ return pmt::is_c32vector(v);
+ default:
+ throw std::runtime_error("bad PDU type");
+ }
+}
- pmt::pmt_t
- make_pdu_vector(vector_type type, const uint8_t *buf, size_t items)
- {
- switch(type) {
- case byte_t:
- return pmt::init_u8vector(items, buf);
- case float_t:
- return pmt::init_f32vector(items, (const float *)buf);
- case complex_t:
- return pmt::init_c32vector(items, (const gr_complex *)buf);
- default:
- throw std::runtime_error("bad PDU type");
- }
- }
+pmt::pmt_t make_pdu_vector(vector_type type, const uint8_t* buf, size_t items)
+{
+ switch (type) {
+ case byte_t:
+ return pmt::init_u8vector(items, buf);
+ case float_t:
+ return pmt::init_f32vector(items, (const float*)buf);
+ case complex_t:
+ return 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");
- }
+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 pdu */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/pdu_filter_impl.cc b/gr-blocks/lib/pdu_filter_impl.cc
index 31c737af53..10423ae05d 100644
--- a/gr-blocks/lib/pdu_filter_impl.cc
+++ b/gr-blocks/lib/pdu_filter_impl.cc
@@ -29,43 +29,43 @@
#include <gnuradio/blocks/pdu.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- pdu_filter::sptr
- pdu_filter::make(pmt::pmt_t k, pmt::pmt_t v, bool invert)
- {
- return gnuradio::get_initial_sptr(new pdu_filter_impl(k,v,invert));
- }
+pdu_filter::sptr pdu_filter::make(pmt::pmt_t k, pmt::pmt_t v, bool invert)
+{
+ return gnuradio::get_initial_sptr(new pdu_filter_impl(k, v, invert));
+}
- pdu_filter_impl::pdu_filter_impl(pmt::pmt_t k, pmt::pmt_t v, bool invert)
- : block("pdu_filter",
- io_signature::make (0, 0, 0),
- io_signature::make (0, 0, 0)),
- d_k(k), d_v(v), d_invert(invert)
- {
- message_port_register_out(pdu::pdu_port_id());
- message_port_register_in(pdu::pdu_port_id());
- set_msg_handler(pdu::pdu_port_id(), boost::bind(&pdu_filter_impl::handle_msg, this, _1));
- }
+pdu_filter_impl::pdu_filter_impl(pmt::pmt_t k, pmt::pmt_t v, bool invert)
+ : block("pdu_filter", io_signature::make(0, 0, 0), io_signature::make(0, 0, 0)),
+ d_k(k),
+ d_v(v),
+ d_invert(invert)
+{
+ message_port_register_out(pdu::pdu_port_id());
+ message_port_register_in(pdu::pdu_port_id());
+ set_msg_handler(pdu::pdu_port_id(),
+ boost::bind(&pdu_filter_impl::handle_msg, this, _1));
+}
- void
- pdu_filter_impl::handle_msg(pmt::pmt_t pdu)
- {
- pmt::pmt_t meta = pmt::car(pdu);
- bool output = d_invert;
+void pdu_filter_impl::handle_msg(pmt::pmt_t pdu)
+{
+ pmt::pmt_t meta = pmt::car(pdu);
+ bool output = d_invert;
- // check base type
- // key exists
- // value matches
- if(pmt::is_dict(meta) && dict_has_key(meta, d_k) && pmt::eqv(pmt::dict_ref(meta,d_k,pmt::PMT_NIL), d_v)){
+ // check base type
+ // key exists
+ // value matches
+ if (pmt::is_dict(meta) && dict_has_key(meta, d_k) &&
+ pmt::eqv(pmt::dict_ref(meta, d_k, pmt::PMT_NIL), d_v)) {
output = !d_invert;
- }
+ }
- // if all tests pass, propagate the pdu
- if(output){
+ // if all tests pass, propagate the pdu
+ if (output) {
message_port_pub(pdu::pdu_port_id(), pdu);
- }
}
+}
- } /* namespace blocks */
-}/* namespace gr */
+} /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/pdu_filter_impl.h b/gr-blocks/lib/pdu_filter_impl.h
index e54b50427c..33d18d29dc 100644
--- a/gr-blocks/lib/pdu_filter_impl.h
+++ b/gr-blocks/lib/pdu_filter_impl.h
@@ -26,24 +26,24 @@
#include <gnuradio/blocks/pdu_filter.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class pdu_filter_impl : public pdu_filter
- {
- private:
- pmt::pmt_t d_k;
- pmt::pmt_t d_v;
- bool d_invert;
+class pdu_filter_impl : public pdu_filter
+{
+private:
+ pmt::pmt_t d_k;
+ pmt::pmt_t d_v;
+ bool d_invert;
- public:
- pdu_filter_impl(pmt::pmt_t k, pmt::pmt_t v, bool invert);
- void handle_msg(pmt::pmt_t msg);
- void set_key(pmt::pmt_t key) { d_k = key; };
- void set_val(pmt::pmt_t val) { d_v = val; };
- void set_inversion(bool invert) { d_invert = invert; };
- };
+public:
+ pdu_filter_impl(pmt::pmt_t k, pmt::pmt_t v, bool invert);
+ void handle_msg(pmt::pmt_t msg);
+ void set_key(pmt::pmt_t key) { d_k = key; };
+ void set_val(pmt::pmt_t val) { d_v = val; };
+ void set_inversion(bool invert) { d_invert = invert; };
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_BLOCKS_PDU_FILTER_IMPL_H */
diff --git a/gr-blocks/lib/pdu_remove_impl.cc b/gr-blocks/lib/pdu_remove_impl.cc
index ab6dd4a4e7..09c73c5875 100644
--- a/gr-blocks/lib/pdu_remove_impl.cc
+++ b/gr-blocks/lib/pdu_remove_impl.cc
@@ -29,38 +29,35 @@
#include <gnuradio/blocks/pdu.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- pdu_remove::sptr
- pdu_remove::make(pmt::pmt_t k)
- {
- return gnuradio::get_initial_sptr(new pdu_remove_impl(k));
- }
+pdu_remove::sptr pdu_remove::make(pmt::pmt_t k)
+{
+ return gnuradio::get_initial_sptr(new pdu_remove_impl(k));
+}
- pdu_remove_impl::pdu_remove_impl(pmt::pmt_t k)
- : block("pdu_remove",
- io_signature::make (0, 0, 0),
- io_signature::make (0, 0, 0)),
- d_k(k)
- {
- message_port_register_out(pdu::pdu_port_id());
- message_port_register_in(pdu::pdu_port_id());
- set_msg_handler(pdu::pdu_port_id(), boost::bind(&pdu_remove_impl::handle_msg, this, _1));
- }
+pdu_remove_impl::pdu_remove_impl(pmt::pmt_t k)
+ : block("pdu_remove", io_signature::make(0, 0, 0), io_signature::make(0, 0, 0)),
+ d_k(k)
+{
+ message_port_register_out(pdu::pdu_port_id());
+ message_port_register_in(pdu::pdu_port_id());
+ set_msg_handler(pdu::pdu_port_id(),
+ boost::bind(&pdu_remove_impl::handle_msg, this, _1));
+}
- void
- pdu_remove_impl::handle_msg(pmt::pmt_t pdu)
- {
- // add the field and publish
- pmt::pmt_t meta = pmt::car(pdu);
- if(pmt::is_null(meta)){
+void pdu_remove_impl::handle_msg(pmt::pmt_t pdu)
+{
+ // add the field and publish
+ pmt::pmt_t meta = pmt::car(pdu);
+ if (pmt::is_null(meta)) {
meta = pmt::make_dict();
- } else if(!pmt::is_dict(meta)){
+ } else if (!pmt::is_dict(meta)) {
throw std::runtime_error("pdu_remove received non PDU input");
- }
- meta = pmt::dict_delete(meta, d_k);
- message_port_pub(pdu::pdu_port_id(), pmt::cons(meta, pmt::cdr(pdu)));
}
+ meta = pmt::dict_delete(meta, d_k);
+ message_port_pub(pdu::pdu_port_id(), pmt::cons(meta, pmt::cdr(pdu)));
+}
- } /* namespace blocks */
-}/* namespace gr */
+} /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/pdu_remove_impl.h b/gr-blocks/lib/pdu_remove_impl.h
index 6f1a7f1b90..e17e1e6ea8 100644
--- a/gr-blocks/lib/pdu_remove_impl.h
+++ b/gr-blocks/lib/pdu_remove_impl.h
@@ -26,20 +26,20 @@
#include <gnuradio/blocks/pdu_remove.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class pdu_remove_impl : public pdu_remove
- {
- private:
- pmt::pmt_t d_k;
+class pdu_remove_impl : public pdu_remove
+{
+private:
+ pmt::pmt_t d_k;
- public:
- pdu_remove_impl(pmt::pmt_t k);
- void handle_msg(pmt::pmt_t msg);
- void set_key(pmt::pmt_t key) { d_k = key; };
- };
+public:
+ pdu_remove_impl(pmt::pmt_t k);
+ void handle_msg(pmt::pmt_t msg);
+ void set_key(pmt::pmt_t key) { d_k = key; };
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_BLOCKS_PDU_REMOVE_IMPL_H */
diff --git a/gr-blocks/lib/pdu_set_impl.cc b/gr-blocks/lib/pdu_set_impl.cc
index df09e2e9f9..6ef46f370f 100644
--- a/gr-blocks/lib/pdu_set_impl.cc
+++ b/gr-blocks/lib/pdu_set_impl.cc
@@ -29,38 +29,35 @@
#include <gnuradio/blocks/pdu.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- pdu_set::sptr
- pdu_set::make(pmt::pmt_t k, pmt::pmt_t v)
- {
- return gnuradio::get_initial_sptr(new pdu_set_impl(k,v));
- }
+pdu_set::sptr pdu_set::make(pmt::pmt_t k, pmt::pmt_t v)
+{
+ return gnuradio::get_initial_sptr(new pdu_set_impl(k, v));
+}
- pdu_set_impl::pdu_set_impl(pmt::pmt_t k, pmt::pmt_t v)
- : block("pdu_set",
- io_signature::make (0, 0, 0),
- io_signature::make (0, 0, 0)),
- d_k(k), d_v(v)
- {
- message_port_register_out(pdu::pdu_port_id());
- message_port_register_in(pdu::pdu_port_id());
- set_msg_handler(pdu::pdu_port_id(), boost::bind(&pdu_set_impl::handle_msg, this, _1));
- }
+pdu_set_impl::pdu_set_impl(pmt::pmt_t k, pmt::pmt_t v)
+ : block("pdu_set", io_signature::make(0, 0, 0), io_signature::make(0, 0, 0)),
+ d_k(k),
+ d_v(v)
+{
+ message_port_register_out(pdu::pdu_port_id());
+ message_port_register_in(pdu::pdu_port_id());
+ set_msg_handler(pdu::pdu_port_id(), boost::bind(&pdu_set_impl::handle_msg, this, _1));
+}
- void
- pdu_set_impl::handle_msg(pmt::pmt_t pdu)
- {
- // add the field and publish
- pmt::pmt_t meta = pmt::car(pdu);
- if(pmt::is_null(meta)){
+void pdu_set_impl::handle_msg(pmt::pmt_t pdu)
+{
+ // add the field and publish
+ pmt::pmt_t meta = pmt::car(pdu);
+ if (pmt::is_null(meta)) {
meta = pmt::make_dict();
- } else if(!pmt::is_dict(meta)){
+ } else if (!pmt::is_dict(meta)) {
throw std::runtime_error("pdu_set received non PDU input");
- }
- meta = pmt::dict_add(meta, d_k, d_v);
- message_port_pub(pdu::pdu_port_id(), pmt::cons(meta, pmt::cdr(pdu)));
}
+ meta = pmt::dict_add(meta, d_k, d_v);
+ message_port_pub(pdu::pdu_port_id(), pmt::cons(meta, pmt::cdr(pdu)));
+}
- } /* namespace blocks */
-}/* namespace gr */
+} /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/pdu_set_impl.h b/gr-blocks/lib/pdu_set_impl.h
index 3529195aaf..581e177e94 100644
--- a/gr-blocks/lib/pdu_set_impl.h
+++ b/gr-blocks/lib/pdu_set_impl.h
@@ -26,22 +26,22 @@
#include <gnuradio/blocks/pdu_set.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class pdu_set_impl : public pdu_set
- {
- private:
- pmt::pmt_t d_k;
- pmt::pmt_t d_v;
+class pdu_set_impl : public pdu_set
+{
+private:
+ pmt::pmt_t d_k;
+ pmt::pmt_t d_v;
- public:
- pdu_set_impl(pmt::pmt_t k, pmt::pmt_t v);
- void handle_msg(pmt::pmt_t msg);
- void set_key(pmt::pmt_t key) { d_k = key; };
- void set_val(pmt::pmt_t val) { d_v = val; };
- };
+public:
+ pdu_set_impl(pmt::pmt_t k, pmt::pmt_t v);
+ void handle_msg(pmt::pmt_t msg);
+ void set_key(pmt::pmt_t key) { d_k = key; };
+ void set_val(pmt::pmt_t val) { d_v = val; };
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_BLOCKS_PDU_SET_IMPL_H */
diff --git a/gr-blocks/lib/pdu_to_tagged_stream_impl.cc b/gr-blocks/lib/pdu_to_tagged_stream_impl.cc
index 2169d1c33d..556f01eaad 100644
--- a/gr-blocks/lib/pdu_to_tagged_stream_impl.cc
+++ b/gr-blocks/lib/pdu_to_tagged_stream_impl.cc
@@ -29,82 +29,82 @@
#include <gnuradio/io_signature.h>
namespace gr {
- namespace blocks {
-
- pdu_to_tagged_stream::sptr
- pdu_to_tagged_stream::make(pdu::vector_type type, const std::string& tsb_tag_key)
- {
- return gnuradio::get_initial_sptr(new pdu_to_tagged_stream_impl(type, tsb_tag_key));
- }
-
- pdu_to_tagged_stream_impl::pdu_to_tagged_stream_impl(pdu::vector_type type, const std::string& tsb_tag_key)
- : tagged_stream_block("pdu_to_tagged_stream",
- io_signature::make(0, 0, 0),
- io_signature::make(1, 1, pdu::itemsize(type)),
- tsb_tag_key),
- d_itemsize(pdu::itemsize(type)),
- d_curr_len(0)
- {
- message_port_register_in(pdu::pdu_port_id());
- }
-
- int pdu_to_tagged_stream_impl::calculate_output_stream_length(const gr_vector_int &)
- {
- if (d_curr_len == 0) {
+namespace blocks {
+
+pdu_to_tagged_stream::sptr pdu_to_tagged_stream::make(pdu::vector_type type,
+ const std::string& tsb_tag_key)
+{
+ return gnuradio::get_initial_sptr(new pdu_to_tagged_stream_impl(type, tsb_tag_key));
+}
+
+pdu_to_tagged_stream_impl::pdu_to_tagged_stream_impl(pdu::vector_type type,
+ const std::string& tsb_tag_key)
+ : tagged_stream_block("pdu_to_tagged_stream",
+ io_signature::make(0, 0, 0),
+ io_signature::make(1, 1, pdu::itemsize(type)),
+ tsb_tag_key),
+ d_itemsize(pdu::itemsize(type)),
+ d_curr_len(0)
+{
+ message_port_register_in(pdu::pdu_port_id());
+}
+
+int pdu_to_tagged_stream_impl::calculate_output_stream_length(const gr_vector_int&)
+{
+ if (d_curr_len == 0) {
pmt::pmt_t msg(delete_head_nowait(pdu::pdu_port_id()));
if (msg.get() == NULL) {
- return 0;
+ return 0;
}
if (!pmt::is_pair(msg))
- throw std::runtime_error("received a malformed pdu message");
+ throw std::runtime_error("received a malformed pdu message");
d_curr_meta = pmt::car(msg);
d_curr_vect = pmt::cdr(msg);
// do not assume the length of PMT is in items (e.g.: from socket_pdu)
- d_curr_len = pmt::blob_length(d_curr_vect)/d_itemsize;
- }
-
- return d_curr_len;
+ d_curr_len = pmt::blob_length(d_curr_vect) / d_itemsize;
}
- int
- pdu_to_tagged_stream_impl::work (int noutput_items,
- gr_vector_int &ninput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- uint8_t *out = (uint8_t*) output_items[0];
+ return d_curr_len;
+}
+
+int pdu_to_tagged_stream_impl::work(int noutput_items,
+ gr_vector_int& ninput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ uint8_t* out = (uint8_t*)output_items[0];
- if (d_curr_len == 0) {
+ if (d_curr_len == 0) {
return 0;
- }
+ }
- // work() should only be called if the current PDU fits entirely
- // into the output buffer.
- assert(noutput_items >= 0 && (unsigned int) noutput_items >= d_curr_len);
+ // work() should only be called if the current PDU fits entirely
+ // into the output buffer.
+ assert(noutput_items >= 0 && (unsigned int)noutput_items >= d_curr_len);
- // Copy vector output
- size_t nout = d_curr_len;
- size_t io(0);
- const uint8_t* ptr = (const uint8_t*) uniform_vector_elements(d_curr_vect, io);
- memcpy(out, ptr, d_curr_len*d_itemsize);
+ // Copy vector output
+ size_t nout = d_curr_len;
+ size_t io(0);
+ const uint8_t* ptr = (const uint8_t*)uniform_vector_elements(d_curr_vect, io);
+ memcpy(out, ptr, d_curr_len * d_itemsize);
- // Copy tags
- if (!pmt::eq(d_curr_meta, pmt::PMT_NIL) ) {
+ // Copy tags
+ if (!pmt::eq(d_curr_meta, pmt::PMT_NIL)) {
pmt::pmt_t klist(pmt::dict_keys(d_curr_meta));
for (size_t i = 0; i < pmt::length(klist); i++) {
- pmt::pmt_t k(pmt::nth(i, klist));
- pmt::pmt_t v(pmt::dict_ref(d_curr_meta, k, pmt::PMT_NIL));
- add_item_tag(0, nitems_written(0), k, v, alias_pmt());
+ pmt::pmt_t k(pmt::nth(i, klist));
+ pmt::pmt_t v(pmt::dict_ref(d_curr_meta, k, pmt::PMT_NIL));
+ add_item_tag(0, nitems_written(0), k, v, alias_pmt());
}
- }
+ }
- // Reset state
- d_curr_len = 0;
+ // Reset state
+ d_curr_len = 0;
- return nout;
- } /* work() */
+ return nout;
+} /* work() */
- } /* namespace blocks */
+} /* 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
index bce8122b13..76e968ae0e 100644
--- a/gr-blocks/lib/pdu_to_tagged_stream_impl.h
+++ b/gr-blocks/lib/pdu_to_tagged_stream_impl.h
@@ -26,28 +26,28 @@
#include <gnuradio/blocks/pdu_to_tagged_stream.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class BLOCKS_API pdu_to_tagged_stream_impl : public pdu_to_tagged_stream
- {
- size_t d_itemsize;
- pmt::pmt_t d_curr_meta;
- pmt::pmt_t d_curr_vect;
- size_t d_curr_len;
+class BLOCKS_API pdu_to_tagged_stream_impl : public pdu_to_tagged_stream
+{
+ size_t d_itemsize;
+ pmt::pmt_t d_curr_meta;
+ pmt::pmt_t d_curr_vect;
+ size_t d_curr_len;
- public:
- pdu_to_tagged_stream_impl(pdu::vector_type type, const std::string& lengthtagname="packet_len");
+public:
+ pdu_to_tagged_stream_impl(pdu::vector_type type,
+ const std::string& lengthtagname = "packet_len");
- int calculate_output_stream_length(const gr_vector_int &ninput_items);
+ int calculate_output_stream_length(const gr_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
- );
- };
+ 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 blocks */
} /* namespace gr */
#endif /* INCLUDED_PDU_TO_TAGGED_STREAM_IMPL_H */
diff --git a/gr-blocks/lib/peak_detector2_fb_impl.cc b/gr-blocks/lib/peak_detector2_fb_impl.cc
index f361ea18bb..bf1e648cd5 100644
--- a/gr-blocks/lib/peak_detector2_fb_impl.cc
+++ b/gr-blocks/lib/peak_detector2_fb_impl.cc
@@ -30,117 +30,107 @@
#include <limits>
namespace gr {
- namespace blocks {
-
- peak_detector2_fb::sptr
- peak_detector2_fb::make(float threshold_factor_rise,
- int look_ahead, float alpha)
- {
- return gnuradio::get_initial_sptr
- (new peak_detector2_fb_impl(threshold_factor_rise,
- look_ahead, alpha));
- }
-
- peak_detector2_fb_impl::peak_detector2_fb_impl(float threshold_factor_rise,
- int look_ahead, float alpha)
- : sync_block("peak_detector2_fb",
- io_signature::make(1, 1, sizeof(float)),
- io_signature::make2(1, 2, sizeof(char), sizeof(float))),
- d_avg(0.0f), d_found(false)
- {
- set_threshold_factor_rise(threshold_factor_rise);
- set_look_ahead(look_ahead);
- set_alpha(alpha);
- }
-
- peak_detector2_fb_impl::~peak_detector2_fb_impl()
- {
- }
-
- void
- peak_detector2_fb_impl::set_threshold_factor_rise(float thr)
- {
- gr::thread::scoped_lock lock(d_setlock);
- d_threshold_factor_rise = thr;
- invalidate();
- }
-
- void
- peak_detector2_fb_impl::set_look_ahead(int look)
- {
- gr::thread::scoped_lock lock(d_setlock);
- d_look_ahead = look;
- invalidate();
- }
-
- void
- peak_detector2_fb_impl::set_alpha(float alpha)
- {
- d_alpha = alpha;
- }
-
- void
- peak_detector2_fb_impl::invalidate()
- {
- d_found = false;
- set_output_multiple(1);
- }
-
- int
- peak_detector2_fb_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- float *iptr = (float *)input_items[0];
- char *optr = (char *)output_items[0];
- float *sigout;
-
- if(output_items.size() == 2)
- sigout = (float *)output_items[1];
-
- memset(optr, 0, noutput_items*sizeof(char));
-
- gr::thread::scoped_lock lock(d_setlock);
-
- // have not crossed threshold yet
- if(d_found==false) {
- for(int i = 0; i < noutput_items; i++) {
- d_avg = d_alpha*iptr[i] + (1.0f - d_alpha)*d_avg;
- if(output_items.size() == 2)
- sigout[i]=d_avg;
- if(iptr[i] > d_avg * (1.0f + d_threshold_factor_rise)) {
- d_found = true;
- d_peak_val = std::numeric_limits<float>::min();
- set_output_multiple(d_look_ahead);
- return i;
- }
+namespace blocks {
+
+peak_detector2_fb::sptr
+peak_detector2_fb::make(float threshold_factor_rise, int look_ahead, float alpha)
+{
+ return gnuradio::get_initial_sptr(
+ new peak_detector2_fb_impl(threshold_factor_rise, look_ahead, alpha));
+}
+
+peak_detector2_fb_impl::peak_detector2_fb_impl(float threshold_factor_rise,
+ int look_ahead,
+ float alpha)
+ : sync_block("peak_detector2_fb",
+ io_signature::make(1, 1, sizeof(float)),
+ io_signature::make2(1, 2, sizeof(char), sizeof(float))),
+ d_avg(0.0f),
+ d_found(false)
+{
+ set_threshold_factor_rise(threshold_factor_rise);
+ set_look_ahead(look_ahead);
+ set_alpha(alpha);
+}
+
+peak_detector2_fb_impl::~peak_detector2_fb_impl() {}
+
+void peak_detector2_fb_impl::set_threshold_factor_rise(float thr)
+{
+ gr::thread::scoped_lock lock(d_setlock);
+ d_threshold_factor_rise = thr;
+ invalidate();
+}
+
+void peak_detector2_fb_impl::set_look_ahead(int look)
+{
+ gr::thread::scoped_lock lock(d_setlock);
+ d_look_ahead = look;
+ invalidate();
+}
+
+void peak_detector2_fb_impl::set_alpha(float alpha) { d_alpha = alpha; }
+
+void peak_detector2_fb_impl::invalidate()
+{
+ d_found = false;
+ set_output_multiple(1);
+}
+
+int peak_detector2_fb_impl::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ float* iptr = (float*)input_items[0];
+ char* optr = (char*)output_items[0];
+ float* sigout;
+
+ if (output_items.size() == 2)
+ sigout = (float*)output_items[1];
+
+ memset(optr, 0, noutput_items * sizeof(char));
+
+ gr::thread::scoped_lock lock(d_setlock);
+
+ // have not crossed threshold yet
+ if (d_found == false) {
+ for (int i = 0; i < noutput_items; i++) {
+ d_avg = d_alpha * iptr[i] + (1.0f - d_alpha) * d_avg;
+ if (output_items.size() == 2)
+ sigout[i] = d_avg;
+ if (iptr[i] > d_avg * (1.0f + d_threshold_factor_rise)) {
+ d_found = true;
+ d_peak_val = std::numeric_limits<float>::min();
+ set_output_multiple(d_look_ahead);
+ return i;
+ }
}
return noutput_items;
- } // end d_found==false
-
- // can complete in this call
- else if(noutput_items >= d_look_ahead) {
- for(int i = 0; i < d_look_ahead; i++) {
- d_avg = d_alpha*iptr[i] + (1.0f - d_alpha)*d_avg;
- if(output_items.size() == 2)
- sigout[i]=d_avg;
- if(iptr[i] > d_peak_val) {
- d_peak_val = iptr[i];
- d_peak_ind =i;
- }
+ } // end d_found==false
+
+ // can complete in this call
+ else if (noutput_items >= d_look_ahead) {
+ for (int i = 0; i < d_look_ahead; i++) {
+ d_avg = d_alpha * iptr[i] + (1.0f - d_alpha) * d_avg;
+ if (output_items.size() == 2)
+ sigout[i] = d_avg;
+ if (iptr[i] > d_peak_val) {
+ d_peak_val = iptr[i];
+ d_peak_ind = i;
+ }
}
optr[d_peak_ind] = 1;
// restart the search
invalidate();
return d_look_ahead;
- } // end can complete in this call
+ } // end can complete in this call
- // cannot complete in this call
- else {
+ // cannot complete in this call
+ else {
return 0; // ask for more
- }
}
+}
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/peak_detector2_fb_impl.h b/gr-blocks/lib/peak_detector2_fb_impl.h
index 929e302d68..713577a19a 100644
--- a/gr-blocks/lib/peak_detector2_fb_impl.h
+++ b/gr-blocks/lib/peak_detector2_fb_impl.h
@@ -26,40 +26,39 @@
#include <gnuradio/blocks/peak_detector2_fb.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class peak_detector2_fb_impl : public peak_detector2_fb
- {
- private:
- float d_threshold_factor_rise;
- int d_look_ahead;
- int d_peak_ind;
- float d_peak_val;
- float d_alpha;
- float d_avg;
- bool d_found;
+class peak_detector2_fb_impl : public peak_detector2_fb
+{
+private:
+ float d_threshold_factor_rise;
+ int d_look_ahead;
+ int d_peak_ind;
+ float d_peak_val;
+ float d_alpha;
+ float d_avg;
+ bool d_found;
- void invalidate();
+ void invalidate();
- public:
- peak_detector2_fb_impl(float threshold_factor_rise,
- int look_ahead, float alpha);
- ~peak_detector2_fb_impl();
+public:
+ peak_detector2_fb_impl(float threshold_factor_rise, int look_ahead, float alpha);
+ ~peak_detector2_fb_impl();
- void set_threshold_factor_rise(float thr);
- void set_look_ahead(int look);
- void set_alpha(float alpha);
+ void set_threshold_factor_rise(float thr);
+ void set_look_ahead(int look);
+ void set_alpha(float alpha);
- float threshold_factor_rise() { return d_threshold_factor_rise; }
- int look_ahead() { return d_look_ahead; }
- float alpha() { return d_alpha; }
+ float threshold_factor_rise() { return d_threshold_factor_rise; }
+ int look_ahead() { return d_look_ahead; }
+ float alpha() { return d_alpha; }
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_GR_PEAK_DETECTOR2_FB_IMPL_H */
diff --git a/gr-blocks/lib/peak_detector_impl.cc b/gr-blocks/lib/peak_detector_impl.cc
index cda1f6007b..236db4a7aa 100644
--- a/gr-blocks/lib/peak_detector_impl.cc
+++ b/gr-blocks/lib/peak_detector_impl.cc
@@ -30,99 +30,95 @@
#include <limits>
namespace gr {
- namespace blocks {
+namespace blocks {
- template <class T>
- typename peak_detector<T>::sptr
- peak_detector<T>::make(float threshold_factor_rise,
- float threshold_factor_fall,
- int look_ahead, float alpha)
- {
- return gnuradio::get_initial_sptr
- (new peak_detector_impl<T>(threshold_factor_rise,
- threshold_factor_fall,
- look_ahead, alpha));
- }
+template <class T>
+typename peak_detector<T>::sptr peak_detector<T>::make(float threshold_factor_rise,
+ float threshold_factor_fall,
+ int look_ahead,
+ float alpha)
+{
+ return gnuradio::get_initial_sptr(new peak_detector_impl<T>(
+ threshold_factor_rise, threshold_factor_fall, look_ahead, alpha));
+}
- template <class T>
- peak_detector_impl<T>::peak_detector_impl(float threshold_factor_rise,
- float threshold_factor_fall,
- int look_ahead, float alpha)
+template <class T>
+peak_detector_impl<T>::peak_detector_impl(float threshold_factor_rise,
+ float threshold_factor_fall,
+ int look_ahead,
+ float alpha)
: sync_block("peak_detector",
- io_signature::make(1, 1, sizeof(T)),
- io_signature::make(1, 1, sizeof(char))),
+ io_signature::make(1, 1, sizeof(T)),
+ io_signature::make(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_look_ahead(look_ahead),
+ d_avg_alpha(alpha),
+ d_avg(0)
+{
+}
- template <class T>
- peak_detector_impl<T>::~peak_detector_impl()
- {
- }
+template <class T>
+peak_detector_impl<T>::~peak_detector_impl()
+{
+}
- template <class T>
- int
- peak_detector_impl<T>::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- T *iptr = (T*)input_items[0];
- char *optr = (char*)output_items[0];
+template <class T>
+int peak_detector_impl<T>::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ T* iptr = (T*)input_items[0];
+ char* optr = (char*)output_items[0];
- memset(optr, 0, noutput_items*sizeof(char));
+ memset(optr, 0, noutput_items * sizeof(char));
- T peak_val = std::numeric_limits<T>::min();
- int peak_ind = 0;
- unsigned char state = 0;
- int i = 0;
+ T peak_val = std::numeric_limits<T>::min();
+ 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++;
- }
+ // 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 = -(T)INFINITY;
+ // printf("Leaving State 1: Peak: %f Peak Ind: %d i: %d noutput_items:
+ // %d\n", peak_val, peak_ind, i, noutput_items);
+ }
}
- 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 = -(T)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);
+ 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;
- }
+ } 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;
}
+}
- template class peak_detector<float>;
- template class peak_detector<std::int16_t>;
- template class peak_detector<std::int32_t>;
- } /* namespace blocks */
+template class peak_detector<float>;
+template class peak_detector<std::int16_t>;
+template class peak_detector<std::int32_t>;
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/peak_detector_impl.h b/gr-blocks/lib/peak_detector_impl.h
index 5a70c1b060..934d712a9f 100644
--- a/gr-blocks/lib/peak_detector_impl.h
+++ b/gr-blocks/lib/peak_detector_impl.h
@@ -26,39 +26,40 @@
#include <gnuradio/blocks/peak_detector.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- template <class T>
- class peak_detector_impl : public peak_detector<T>
- {
- private:
- float d_threshold_factor_rise;
- float d_threshold_factor_fall;
- int d_look_ahead;
- float d_avg_alpha;
- float d_avg;
+template <class T>
+class peak_detector_impl : public peak_detector<T>
+{
+private:
+ float d_threshold_factor_rise;
+ float d_threshold_factor_fall;
+ int d_look_ahead;
+ float d_avg_alpha;
+ float d_avg;
- public:
- peak_detector_impl(float threshold_factor_rise,
- float threshold_factor_fall,
- int look_ahead, float alpha);
- ~peak_detector_impl();
+public:
+ peak_detector_impl(float threshold_factor_rise,
+ float threshold_factor_fall,
+ int look_ahead,
+ float alpha);
+ ~peak_detector_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(float 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; }
+ 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(float 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);
- };
+ int work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* PEAK_DETECTOR_IMPL_H */
diff --git a/gr-blocks/lib/plateau_detector_fb_impl.cc b/gr-blocks/lib/plateau_detector_fb_impl.cc
index 375c1a3070..6f75702c84 100644
--- a/gr-blocks/lib/plateau_detector_fb_impl.cc
+++ b/gr-blocks/lib/plateau_detector_fb_impl.cc
@@ -28,79 +28,71 @@
#include "plateau_detector_fb_impl.h"
namespace gr {
- namespace blocks {
+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::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)
- : block("plateau_detector_fb",
- io_signature::make(1, 1, sizeof(float)),
- io_signature::make(1, 1, sizeof(char))),
- d_max_len(max_len),
- d_threshold(threshold)
- {}
+plateau_detector_fb_impl::plateau_detector_fb_impl(int max_len, float threshold)
+ : block("plateau_detector_fb",
+ io_signature::make(1, 1, sizeof(float)),
+ io_signature::make(1, 1, sizeof(char))),
+ d_max_len(max_len),
+ d_threshold(threshold)
+{
+}
- plateau_detector_fb_impl::~plateau_detector_fb_impl()
- {
- }
+plateau_detector_fb_impl::~plateau_detector_fb_impl() {}
- void
- plateau_detector_fb_impl::forecast(int, gr_vector_int &ninput_items_required)
- {
- ninput_items_required[0] = 2*d_max_len;
- }
+void plateau_detector_fb_impl::forecast(int, gr_vector_int& ninput_items_required)
+{
+ ninput_items_required[0] = 2 * d_max_len;
+}
- int
- plateau_detector_fb_impl::general_work(int noutput_items,
- gr_vector_int &ninput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- // thread-safe protection from ::set_threshold
- gr::thread::scoped_lock l (d_setlock);
+int plateau_detector_fb_impl::general_work(int noutput_items,
+ gr_vector_int& ninput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ // thread-safe protection from ::set_threshold
+ gr::thread::scoped_lock l(d_setlock);
- const float *in = (const float *) input_items[0];
- unsigned char *out = (unsigned char *) output_items[0];
- int flank_start;
- noutput_items = std::min(noutput_items, ninput_items[0]);
- 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);
- }
+ const float* in = (const float*)input_items[0];
+ unsigned char* out = (unsigned char*)output_items[0];
+ int flank_start;
+ noutput_items = std::min(noutput_items, ninput_items[0]);
+ 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);
+ }
}
- }
-
- this->consume_each(i);
- return i;
}
- void plateau_detector_fb_impl::set_threshold(float threshold)
- {
- // thread-safe protection from ::set_threshold
- gr::thread::scoped_lock l (d_setlock);
- d_threshold = threshold;
- }
+ this->consume_each(i);
+ return i;
+}
- float plateau_detector_fb_impl::threshold() const
- {
- return d_threshold;
- }
+void plateau_detector_fb_impl::set_threshold(float threshold)
+{
+ // thread-safe protection from ::set_threshold
+ gr::thread::scoped_lock l(d_setlock);
+ d_threshold = threshold;
+}
- } /* namespace blocks */
-} /* namespace gr */
+float plateau_detector_fb_impl::threshold() const { return d_threshold; }
+} /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/plateau_detector_fb_impl.h b/gr-blocks/lib/plateau_detector_fb_impl.h
index 1a99745104..198f4083d3 100644
--- a/gr-blocks/lib/plateau_detector_fb_impl.h
+++ b/gr-blocks/lib/plateau_detector_fb_impl.h
@@ -26,31 +26,30 @@
#include <gnuradio/blocks/plateau_detector_fb.h>
namespace gr {
- namespace blocks {
+namespace blocks {
class plateau_detector_fb_impl : public plateau_detector_fb
{
- private:
- int d_max_len;
- float d_threshold;
+private:
+ int d_max_len;
+ float d_threshold;
- public:
- plateau_detector_fb_impl(int max_len, float threshold);
- ~plateau_detector_fb_impl();
+public:
+ plateau_detector_fb_impl(int max_len, float threshold);
+ ~plateau_detector_fb_impl();
- void forecast(int noutput_items, gr_vector_int &ninput_items_required);
+ 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);
+ int general_work(int noutput_items,
+ gr_vector_int& ninput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items);
- virtual void set_threshold(float threshold);
- virtual float threshold() const;
+ virtual void set_threshold(float threshold);
+ virtual float threshold() const;
};
- } // namespace blocks
+} // 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
index 24a736db4d..577959dff2 100644
--- a/gr-blocks/lib/probe_rate_impl.cc
+++ b/gr-blocks/lib/probe_rate_impl.cc
@@ -28,99 +28,106 @@
#include <gnuradio/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) :
- sync_block("probe_rate",
- io_signature::make(1,1,itemsize),
- io_signature::make(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_port(pmt::mp("rate")),
- d_dict_avg(pmt::mp("rate_avg")),
- d_dict_now(pmt::mp("rate_now"))
- {
- message_port_register_out(d_port);
- }
-
- 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;
- }
- pmt::pmt_t d = pmt::make_dict();
- d = pmt::dict_add(d, d_dict_avg, pmt::mp(d_avg));
- d = pmt::dict_add(d, d_dict_now, pmt::mp(rate_this_update));
- message_port_pub(d_port, pmt::cons(d, pmt::PMT_NIL));
+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)
+ : sync_block("probe_rate",
+ io_signature::make(1, 1, itemsize),
+ io_signature::make(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_port(pmt::mp("rate")),
+ d_dict_avg(pmt::mp("rate_avg")),
+ d_dict_now(pmt::mp("rate_now"))
+{
+ message_port_register_out(d_port);
+}
+
+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;
- }
+ pmt::pmt_t d = pmt::make_dict();
+ d = pmt::dict_add(d, d_dict_avg, pmt::mp(d_avg));
+ d = pmt::dict_add(d, d_dict_now, pmt::mp(rate_this_update));
+ message_port_pub(d_port, pmt::cons(d, pmt::PMT_NIL));
+ }
+ return noutput_items;
+}
- void probe_rate_impl::setup_rpc(){
+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)));
+ 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; }
+void probe_rate_impl::set_alpha(double alpha) { d_alpha = alpha; }
- double probe_rate_impl::rate(){ return d_avg; }
+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();
- }
+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;
- }
+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 blocks */
} /* namespace gr */
-
diff --git a/gr-blocks/lib/probe_rate_impl.h b/gr-blocks/lib/probe_rate_impl.h
index 42c3b13fe2..7128981b55 100644
--- a/gr-blocks/lib/probe_rate_impl.h
+++ b/gr-blocks/lib/probe_rate_impl.h
@@ -26,36 +26,36 @@
#include <gnuradio/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;
- void setup_rpc();
-
- const pmt::pmt_t d_port;
- const pmt::pmt_t d_dict_avg, d_dict_now;
-
- 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 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;
+ void setup_rpc();
+
+ const pmt::pmt_t d_port;
+ const pmt::pmt_t d_dict_avg, d_dict_now;
+
+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_impl.cc b/gr-blocks/lib/probe_signal_impl.cc
index 1766464fc6..256df2036e 100644
--- a/gr-blocks/lib/probe_signal_impl.cc
+++ b/gr-blocks/lib/probe_signal_impl.cc
@@ -29,48 +29,45 @@
#include <gnuradio/io_signature.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- template <class T>
- typename probe_signal<T>::sptr
- probe_signal<T>::make()
- {
- return gnuradio::get_initial_sptr
- (new probe_signal_impl<T> ());
- }
+template <class T>
+typename probe_signal<T>::sptr probe_signal<T>::make()
+{
+ return gnuradio::get_initial_sptr(new probe_signal_impl<T>());
+}
- template <class T>
- probe_signal_impl<T> ::probe_signal_impl()
+template <class T>
+probe_signal_impl<T>::probe_signal_impl()
: sync_block("probe_signal",
- io_signature::make(1, 1, sizeof(T)),
- io_signature::make(0, 0, 0)),
+ io_signature::make(1, 1, sizeof(T)),
+ io_signature::make(0, 0, 0)),
d_level(0)
- {
- }
+{
+}
- template <class T>
- probe_signal_impl<T> ::~probe_signal_impl()
- {
- }
+template <class T>
+probe_signal_impl<T>::~probe_signal_impl()
+{
+}
- template <class T>
- int
- probe_signal_impl<T> ::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- const T *in = (const T *)input_items[0];
+template <class T>
+int probe_signal_impl<T>::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ const T* in = (const T*)input_items[0];
- if(noutput_items > 0)
- d_level = in[noutput_items-1];
+ if (noutput_items > 0)
+ d_level = in[noutput_items - 1];
- return noutput_items;
- }
+ return noutput_items;
+}
template class probe_signal<std::uint8_t>;
template class probe_signal<std::int16_t>;
template class probe_signal<std::int32_t>;
template class probe_signal<float>;
template class probe_signal<gr_complex>;
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/probe_signal_impl.h b/gr-blocks/lib/probe_signal_impl.h
index d86f6e6d75..bf0822ff91 100644
--- a/gr-blocks/lib/probe_signal_impl.h
+++ b/gr-blocks/lib/probe_signal_impl.h
@@ -27,26 +27,26 @@
#include <gnuradio/blocks/probe_signal.h>
namespace gr {
- namespace blocks {
+namespace blocks {
-template<class T>
- class probe_signal_impl : public probe_signal<T>
- {
- private:
- T d_level;
+template <class T>
+class probe_signal_impl : public probe_signal<T>
+{
+private:
+ T d_level;
- public:
- probe_signal_impl ();
- ~probe_signal_impl ();
+public:
+ probe_signal_impl();
+ ~probe_signal_impl();
- T level() const { return d_level; }
+ T level() const { return d_level; }
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* PROBE_SIGNAL_IMPL_H */
diff --git a/gr-blocks/lib/probe_signal_v_impl.cc b/gr-blocks/lib/probe_signal_v_impl.cc
index 3b2b942bf5..fb716831f0 100644
--- a/gr-blocks/lib/probe_signal_v_impl.cc
+++ b/gr-blocks/lib/probe_signal_v_impl.cc
@@ -29,48 +29,46 @@
#include <gnuradio/io_signature.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- template <class T>
- typename probe_signal_v<T>::sptr
- probe_signal_v<T>::make(size_t size)
- {
- return gnuradio::get_initial_sptr
- (new probe_signal_v_impl<T>(size));
- }
+template <class T>
+typename probe_signal_v<T>::sptr probe_signal_v<T>::make(size_t size)
+{
+ return gnuradio::get_initial_sptr(new probe_signal_v_impl<T>(size));
+}
- template <class T>
- probe_signal_v_impl<T>::probe_signal_v_impl(size_t size)
+template <class T>
+probe_signal_v_impl<T>::probe_signal_v_impl(size_t size)
: sync_block("probe_signal_v",
- io_signature::make(1, 1, size*sizeof(T)),
- io_signature::make(0, 0, 0)),
- d_level(size, 0), d_size(size)
- {
- }
+ io_signature::make(1, 1, size * sizeof(T)),
+ io_signature::make(0, 0, 0)),
+ d_level(size, 0),
+ d_size(size)
+{
+}
- template <class T>
- probe_signal_v_impl<T>::~probe_signal_v_impl()
- {
- }
+template <class T>
+probe_signal_v_impl<T>::~probe_signal_v_impl()
+{
+}
- template <class T>
- int
- probe_signal_v_impl<T>::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- const T *in = (const T *)input_items[0];
+template <class T>
+int probe_signal_v_impl<T>::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ const T* in = (const T*)input_items[0];
- for(size_t i=0; i<d_size; i++)
- d_level[i] = in[(noutput_items-1)*d_size+i];
+ for (size_t i = 0; i < d_size; i++)
+ d_level[i] = in[(noutput_items - 1) * d_size + i];
- return noutput_items;
- }
- template class probe_signal_v<std::uint8_t>;
- template class probe_signal_v<std::int16_t>;
- template class probe_signal_v<std::int32_t>;
- template class probe_signal_v<float>;
- template class probe_signal_v<gr_complex>;
+ return noutput_items;
+}
+template class probe_signal_v<std::uint8_t>;
+template class probe_signal_v<std::int16_t>;
+template class probe_signal_v<std::int32_t>;
+template class probe_signal_v<float>;
+template class probe_signal_v<gr_complex>;
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/probe_signal_v_impl.h b/gr-blocks/lib/probe_signal_v_impl.h
index dd36ebf741..17d8e348db 100644
--- a/gr-blocks/lib/probe_signal_v_impl.h
+++ b/gr-blocks/lib/probe_signal_v_impl.h
@@ -27,27 +27,27 @@
#include <gnuradio/blocks/probe_signal_v.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- template <class T>
- class probe_signal_v_impl : public probe_signal_v<T>
- {
- private:
- std::vector<T> d_level;
- size_t d_size;
+template <class T>
+class probe_signal_v_impl : public probe_signal_v<T>
+{
+private:
+ std::vector<T> d_level;
+ size_t d_size;
- public:
- probe_signal_v_impl(size_t size);
- ~probe_signal_v_impl();
+public:
+ probe_signal_v_impl(size_t size);
+ ~probe_signal_v_impl();
- std::vector<T> level() const { return d_level; }
+ std::vector<T> level() const { return d_level; }
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* PROBE_SIGNAL_V_IMPL_H */
diff --git a/gr-blocks/lib/qa_block_tags.cc b/gr-blocks/lib/qa_block_tags.cc
index fc61065e95..2c45551e37 100644
--- a/gr-blocks/lib/qa_block_tags.cc
+++ b/gr-blocks/lib/qa_block_tags.cc
@@ -46,408 +46,435 @@
// particular order.
#define QA_TAGS_DEBUG 0
-gr::tag_t make_tag(uint64_t offset, pmt::pmt_t key, pmt::pmt_t value, pmt::pmt_t srcid) {
- gr::tag_t result;
- result.offset = offset;
- result.key = key;
- result.value = value;
- result.srcid = srcid;
- return result;
+gr::tag_t make_tag(uint64_t offset, pmt::pmt_t key, pmt::pmt_t value, pmt::pmt_t srcid)
+{
+ gr::tag_t result;
+ result.offset = offset;
+ result.key = key;
+ result.value = value;
+ result.srcid = srcid;
+ return result;
}
-std::ostream&
-operator << (std::ostream& os, const gr::tag_t &t) {
- return os;
-}
+std::ostream& operator<<(std::ostream& os, const gr::tag_t& t) { return os; }
BOOST_AUTO_TEST_CASE(t0)
{
- unsigned int N = 1000;
- gr::top_block_sptr tb = gr::make_top_block("top");
- gr::block_sptr src (gr::blocks::null_source::make(sizeof(int)));
- gr::block_sptr head (gr::blocks::head::make(sizeof(int), N));
- gr::block_sptr snk (gr::blocks::null_sink::make(sizeof(int)));
+ unsigned int N = 1000;
+ gr::top_block_sptr tb = gr::make_top_block("top");
+ gr::block_sptr src(gr::blocks::null_source::make(sizeof(int)));
+ gr::block_sptr head(gr::blocks::head::make(sizeof(int), N));
+ gr::block_sptr snk(gr::blocks::null_sink::make(sizeof(int)));
- tb->connect(src, 0, head, 0);
- tb->connect(head, 0, snk, 0);
+ tb->connect(src, 0, head, 0);
+ tb->connect(head, 0, snk, 0);
- BOOST_REQUIRE_EQUAL(src->nitems_read(0), (uint64_t)0);
- BOOST_REQUIRE_EQUAL(src->nitems_written(0), (uint64_t)0);
+ BOOST_REQUIRE_EQUAL(src->nitems_read(0), (uint64_t)0);
+ BOOST_REQUIRE_EQUAL(src->nitems_written(0), (uint64_t)0);
- tb->run();
+ tb->run();
- BOOST_REQUIRE_THROW(src->nitems_read(0), std::invalid_argument);
- BOOST_REQUIRE(src->nitems_written(0) >= N);
- BOOST_REQUIRE_EQUAL(snk->nitems_read(0), (uint64_t)1000);
- BOOST_REQUIRE_THROW(snk->nitems_written(0), std::invalid_argument);
+ BOOST_REQUIRE_THROW(src->nitems_read(0), std::invalid_argument);
+ BOOST_REQUIRE(src->nitems_written(0) >= N);
+ BOOST_REQUIRE_EQUAL(snk->nitems_read(0), (uint64_t)1000);
+ BOOST_REQUIRE_THROW(snk->nitems_written(0), std::invalid_argument);
}
BOOST_AUTO_TEST_CASE(t1)
{
- int N = 40000;
- gr::top_block_sptr tb = gr::make_top_block("top");
- gr::block_sptr src (gr::blocks::null_source::make(sizeof(int)));
- gr::block_sptr head (gr::blocks::head::make(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::blocks::null_sink::make(sizeof(int)));
- gr::block_sptr snk1 (gr::blocks::null_sink::make(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
- BOOST_REQUIRE_EQUAL(tags0.size(), (size_t)0);
- BOOST_REQUIRE_EQUAL(tags3.size(), (size_t)8);
- BOOST_REQUIRE_EQUAL(tags4.size(), (size_t)8);
+ int N = 40000;
+ gr::top_block_sptr tb = gr::make_top_block("top");
+ gr::block_sptr src(gr::blocks::null_source::make(sizeof(int)));
+ gr::block_sptr head(gr::blocks::head::make(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::blocks::null_sink::make(sizeof(int)));
+ gr::block_sptr snk1(gr::blocks::null_sink::make(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
+ BOOST_REQUIRE_EQUAL(tags0.size(), (size_t)0);
+ BOOST_REQUIRE_EQUAL(tags3.size(), (size_t)8);
+ BOOST_REQUIRE_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();
-
- gr::tag_t expected_tags3[8];
- expected_tags3[0] = make_tag(0, pmt::mp(str1.str()), pmt::mp("seq"), pmt::mp(0));
- expected_tags3[1] = make_tag(0, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(0));
- expected_tags3[2] = make_tag(10000, pmt::mp(str1.str()), pmt::mp("seq"), pmt::mp(1));
- expected_tags3[3] = make_tag(10000, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(2));
- expected_tags3[4] = make_tag(20000, pmt::mp(str1.str()), pmt::mp("seq"), pmt::mp(2));
- expected_tags3[5] = make_tag(20000, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(4));
- expected_tags3[6] = make_tag(30000, pmt::mp(str1.str()), pmt::mp("seq"), pmt::mp(3));
- expected_tags3[7] = make_tag(30000, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(6));
-
- gr::tag_t expected_tags4[8];
- expected_tags4[0] = make_tag(0, pmt::mp(str2.str()), pmt::mp("seq"), pmt::mp(0));
- expected_tags4[1] = make_tag(0, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(1));
- expected_tags4[2] = make_tag(10000, pmt::mp(str2.str()), pmt::mp("seq"), pmt::mp(1));
- expected_tags4[3] = make_tag(10000, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(3));
- expected_tags4[4] = make_tag(20000, pmt::mp(str2.str()), pmt::mp("seq"), pmt::mp(2));
- expected_tags4[5] = make_tag(20000, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(5));
- expected_tags4[6] = make_tag(30000, pmt::mp(str2.str()), pmt::mp("seq"), pmt::mp(3));
- expected_tags4[7] = make_tag(30000, pmt::mp(str0.str()), pmt::mp("seq"), pmt::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;
- BOOST_REQUIRE_EQUAL(tags3[i], 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;
- BOOST_REQUIRE_EQUAL(tags4[i], expected_tags4[i]);
- }
+ // 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();
+
+ gr::tag_t expected_tags3[8];
+ expected_tags3[0] = make_tag(0, pmt::mp(str1.str()), pmt::mp("seq"), pmt::mp(0));
+ expected_tags3[1] = make_tag(0, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(0));
+ expected_tags3[2] = make_tag(10000, pmt::mp(str1.str()), pmt::mp("seq"), pmt::mp(1));
+ expected_tags3[3] = make_tag(10000, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(2));
+ expected_tags3[4] = make_tag(20000, pmt::mp(str1.str()), pmt::mp("seq"), pmt::mp(2));
+ expected_tags3[5] = make_tag(20000, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(4));
+ expected_tags3[6] = make_tag(30000, pmt::mp(str1.str()), pmt::mp("seq"), pmt::mp(3));
+ expected_tags3[7] = make_tag(30000, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(6));
+
+ gr::tag_t expected_tags4[8];
+ expected_tags4[0] = make_tag(0, pmt::mp(str2.str()), pmt::mp("seq"), pmt::mp(0));
+ expected_tags4[1] = make_tag(0, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(1));
+ expected_tags4[2] = make_tag(10000, pmt::mp(str2.str()), pmt::mp("seq"), pmt::mp(1));
+ expected_tags4[3] = make_tag(10000, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(3));
+ expected_tags4[4] = make_tag(20000, pmt::mp(str2.str()), pmt::mp("seq"), pmt::mp(2));
+ expected_tags4[5] = make_tag(20000, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(5));
+ expected_tags4[6] = make_tag(30000, pmt::mp(str2.str()), pmt::mp("seq"), pmt::mp(3));
+ expected_tags4[7] = make_tag(30000, pmt::mp(str0.str()), pmt::mp("seq"), pmt::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;
+ BOOST_REQUIRE_EQUAL(tags3[i], 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;
+ BOOST_REQUIRE_EQUAL(tags4[i], expected_tags4[i]);
+ }
#endif
}
BOOST_AUTO_TEST_CASE(t2)
{
- int N = 40000;
- gr::top_block_sptr tb = gr::make_top_block("top");
- gr::block_sptr src (gr::blocks::null_source::make(sizeof(int)));
- gr::block_sptr head (gr::blocks::head::make(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::blocks::null_sink::make(sizeof(int)));
- gr::block_sptr snk1 (gr::blocks::null_sink::make(sizeof(int)));
- gr::block_sptr snk2 (gr::blocks::null_sink::make(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
- BOOST_REQUIRE_EQUAL(tags0.size(), (size_t)0);
- BOOST_REQUIRE_EQUAL(tags1.size(), (size_t)8);
-
- // Make sure the rest all have 12 tags
- BOOST_REQUIRE_EQUAL(tags2.size(), (size_t)12);
- BOOST_REQUIRE_EQUAL(tags3.size(), (size_t)12);
- BOOST_REQUIRE_EQUAL(tags4.size(), (size_t)12);
+ int N = 40000;
+ gr::top_block_sptr tb = gr::make_top_block("top");
+ gr::block_sptr src(gr::blocks::null_source::make(sizeof(int)));
+ gr::block_sptr head(gr::blocks::head::make(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::blocks::null_sink::make(sizeof(int)));
+ gr::block_sptr snk1(gr::blocks::null_sink::make(sizeof(int)));
+ gr::block_sptr snk2(gr::blocks::null_sink::make(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
+ BOOST_REQUIRE_EQUAL(tags0.size(), (size_t)0);
+ BOOST_REQUIRE_EQUAL(tags1.size(), (size_t)8);
+
+ // Make sure the rest all have 12 tags
+ BOOST_REQUIRE_EQUAL(tags2.size(), (size_t)12);
+ BOOST_REQUIRE_EQUAL(tags3.size(), (size_t)12);
+ BOOST_REQUIRE_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();
-
- gr::tag_t expected_tags2[12];
- expected_tags2[0] = make_tag(0, pmt::mp(str1.str()), pmt::mp("seq"), pmt::mp(0));
- expected_tags2[1] = make_tag(0, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(0));
- expected_tags2[2] = make_tag(0, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(1));
- expected_tags2[3] = make_tag(10000, pmt::mp(str1.str()), pmt::mp("seq"), pmt::mp(3));
- expected_tags2[4] = make_tag(10000, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(2));
- expected_tags2[5] = make_tag(10000, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(3));
- expected_tags2[6] = make_tag(20000, pmt::mp(str1.str()), pmt::mp("seq"), pmt::mp(6));
- expected_tags2[7] = make_tag(20000, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(4));
- expected_tags2[8] = make_tag(20000, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(5));
- expected_tags2[9] = make_tag(30000, pmt::mp(str1.str()), pmt::mp("seq"), pmt::mp(9));
- expected_tags2[10] = make_tag(30000, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(6));
- expected_tags2[11] = make_tag(30000, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(7));
-
- gr::tag_t expected_tags4[12];
- expected_tags4[0] = make_tag(0, pmt::mp(str1.str()), pmt::mp("seq"), pmt::mp(2));
- expected_tags4[1] = make_tag(0, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(0));
- expected_tags4[2] = make_tag(0, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(1));
- expected_tags4[3] = make_tag(10000, pmt::mp(str1.str()), pmt::mp("seq"), pmt::mp(5));
- expected_tags4[4] = make_tag(10000, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(2));
- expected_tags4[5] = make_tag(10000, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(3));
- expected_tags4[6] = make_tag(20000, pmt::mp(str1.str()), pmt::mp("seq"), pmt::mp(8));
- expected_tags4[7] = make_tag(20000, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(4));
- expected_tags4[8] = make_tag(20000, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(5));
- expected_tags4[9] = make_tag(30000, pmt::mp(str1.str()), pmt::mp("seq"), pmt::mp(11));
- expected_tags4[10] = make_tag(30000, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(6));
- expected_tags4[11] = make_tag(30000, pmt::mp(str0.str()), pmt::mp("seq"), pmt::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;
- BOOST_REQUIRE_EQUAL(tags2[i], 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;
- BOOST_REQUIRE_EQUAL(tags4[i], expected_tags4[i]);
- }
+ // 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();
+
+ gr::tag_t expected_tags2[12];
+ expected_tags2[0] = make_tag(0, pmt::mp(str1.str()), pmt::mp("seq"), pmt::mp(0));
+ expected_tags2[1] = make_tag(0, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(0));
+ expected_tags2[2] = make_tag(0, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(1));
+ expected_tags2[3] = make_tag(10000, pmt::mp(str1.str()), pmt::mp("seq"), pmt::mp(3));
+ expected_tags2[4] = make_tag(10000, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(2));
+ expected_tags2[5] = make_tag(10000, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(3));
+ expected_tags2[6] = make_tag(20000, pmt::mp(str1.str()), pmt::mp("seq"), pmt::mp(6));
+ expected_tags2[7] = make_tag(20000, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(4));
+ expected_tags2[8] = make_tag(20000, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(5));
+ expected_tags2[9] = make_tag(30000, pmt::mp(str1.str()), pmt::mp("seq"), pmt::mp(9));
+ expected_tags2[10] = make_tag(30000, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(6));
+ expected_tags2[11] = make_tag(30000, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(7));
+
+ gr::tag_t expected_tags4[12];
+ expected_tags4[0] = make_tag(0, pmt::mp(str1.str()), pmt::mp("seq"), pmt::mp(2));
+ expected_tags4[1] = make_tag(0, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(0));
+ expected_tags4[2] = make_tag(0, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(1));
+ expected_tags4[3] = make_tag(10000, pmt::mp(str1.str()), pmt::mp("seq"), pmt::mp(5));
+ expected_tags4[4] = make_tag(10000, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(2));
+ expected_tags4[5] = make_tag(10000, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(3));
+ expected_tags4[6] = make_tag(20000, pmt::mp(str1.str()), pmt::mp("seq"), pmt::mp(8));
+ expected_tags4[7] = make_tag(20000, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(4));
+ expected_tags4[8] = make_tag(20000, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(5));
+ expected_tags4[9] = make_tag(30000, pmt::mp(str1.str()), pmt::mp("seq"), pmt::mp(11));
+ expected_tags4[10] = make_tag(30000, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(6));
+ expected_tags4[11] = make_tag(30000, pmt::mp(str0.str()), pmt::mp("seq"), pmt::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;
+ BOOST_REQUIRE_EQUAL(tags2[i], 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;
+ BOOST_REQUIRE_EQUAL(tags4[i], expected_tags4[i]);
+ }
#endif
}
BOOST_AUTO_TEST_CASE(t3)
{
- int N = 40000;
- gr::top_block_sptr tb = gr::make_top_block("top");
- gr::block_sptr src (gr::blocks::null_source::make(sizeof(int)));
- gr::block_sptr head (gr::blocks::head::make(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::blocks::null_sink::make(sizeof(int)));
- gr::block_sptr snk1 (gr::blocks::null_sink::make(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
- BOOST_REQUIRE_EQUAL(tags0.size(), (size_t)0);
- BOOST_REQUIRE_EQUAL(tags3.size(), (size_t)8);
- BOOST_REQUIRE_EQUAL(tags4.size(), (size_t)8);
+ int N = 40000;
+ gr::top_block_sptr tb = gr::make_top_block("top");
+ gr::block_sptr src(gr::blocks::null_source::make(sizeof(int)));
+ gr::block_sptr head(gr::blocks::head::make(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::blocks::null_sink::make(sizeof(int)));
+ gr::block_sptr snk1(gr::blocks::null_sink::make(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
+ BOOST_REQUIRE_EQUAL(tags0.size(), (size_t)0);
+ BOOST_REQUIRE_EQUAL(tags3.size(), (size_t)8);
+ BOOST_REQUIRE_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();
-
- gr::tag_t expected_tags3[8];
- expected_tags3[0] = make_tag(0, pmt::mp(str1.str()), pmt::mp("seq"), pmt::mp(0));
- expected_tags3[1] = make_tag(0, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(0));
- expected_tags3[2] = make_tag(10000, pmt::mp(str1.str()), pmt::mp("seq"), pmt::mp(1));
- expected_tags3[3] = make_tag(10000, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(2));
- expected_tags3[4] = make_tag(20000, pmt::mp(str1.str()), pmt::mp("seq"), pmt::mp(2));
- expected_tags3[5] = make_tag(20000, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(4));
- expected_tags3[6] = make_tag(30000, pmt::mp(str1.str()), pmt::mp("seq"), pmt::mp(3));
- expected_tags3[7] = make_tag(30000, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(6));
-
- gr::tag_t expected_tags4[8];
- expected_tags4[0] = make_tag(0, pmt::mp(str2.str()), pmt::mp("seq"), pmt::mp(0));
- expected_tags4[1] = make_tag(0, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(1));
- expected_tags4[2] = make_tag(10000, pmt::mp(str2.str()), pmt::mp("seq"), pmt::mp(1));
- expected_tags4[3] = make_tag(10000, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(3));
- expected_tags4[4] = make_tag(20000, pmt::mp(str2.str()), pmt::mp("seq"), pmt::mp(2));
- expected_tags4[5] = make_tag(20000, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(5));
- expected_tags4[6] = make_tag(30000, pmt::mp(str2.str()), pmt::mp("seq"), pmt::mp(3));
- expected_tags4[7] = make_tag(30000, pmt::mp(str0.str()), pmt::mp("seq"), pmt::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;
- BOOST_REQUIRE_EQUAL(tags3[i], 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;
- BOOST_REQUIRE_EQUAL(tags4[i], expected_tags4[i]);
- }
+ // 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();
+
+ gr::tag_t expected_tags3[8];
+ expected_tags3[0] = make_tag(0, pmt::mp(str1.str()), pmt::mp("seq"), pmt::mp(0));
+ expected_tags3[1] = make_tag(0, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(0));
+ expected_tags3[2] = make_tag(10000, pmt::mp(str1.str()), pmt::mp("seq"), pmt::mp(1));
+ expected_tags3[3] = make_tag(10000, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(2));
+ expected_tags3[4] = make_tag(20000, pmt::mp(str1.str()), pmt::mp("seq"), pmt::mp(2));
+ expected_tags3[5] = make_tag(20000, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(4));
+ expected_tags3[6] = make_tag(30000, pmt::mp(str1.str()), pmt::mp("seq"), pmt::mp(3));
+ expected_tags3[7] = make_tag(30000, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(6));
+
+ gr::tag_t expected_tags4[8];
+ expected_tags4[0] = make_tag(0, pmt::mp(str2.str()), pmt::mp("seq"), pmt::mp(0));
+ expected_tags4[1] = make_tag(0, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(1));
+ expected_tags4[2] = make_tag(10000, pmt::mp(str2.str()), pmt::mp("seq"), pmt::mp(1));
+ expected_tags4[3] = make_tag(10000, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(3));
+ expected_tags4[4] = make_tag(20000, pmt::mp(str2.str()), pmt::mp("seq"), pmt::mp(2));
+ expected_tags4[5] = make_tag(20000, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(5));
+ expected_tags4[6] = make_tag(30000, pmt::mp(str2.str()), pmt::mp("seq"), pmt::mp(3));
+ expected_tags4[7] = make_tag(30000, pmt::mp(str0.str()), pmt::mp("seq"), pmt::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;
+ BOOST_REQUIRE_EQUAL(tags3[i], 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;
+ BOOST_REQUIRE_EQUAL(tags4[i], expected_tags4[i]);
+ }
#endif
}
BOOST_AUTO_TEST_CASE(t4)
{
- int N = 40000;
- gr::top_block_sptr tb = gr::make_top_block("top");
- gr::block_sptr src (gr::blocks::null_source::make(sizeof(int)));
- gr::block_sptr head (gr::blocks::head::make(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::blocks::null_sink::make(sizeof(int)));
- gr::block_sptr snk1 (gr::blocks::null_sink::make(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 block_executor"
- << std::endl;
- tb->run();
+ int N = 40000;
+ gr::top_block_sptr tb = gr::make_top_block("top");
+ gr::block_sptr src(gr::blocks::null_source::make(sizeof(int)));
+ gr::block_sptr head(gr::blocks::head::make(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::blocks::null_sink::make(sizeof(int)));
+ gr::block_sptr snk1(gr::blocks::null_sink::make(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 block_executor"
+ << std::endl;
+ tb->run();
}
BOOST_AUTO_TEST_CASE(t5)
{
- int N = 40000;
- gr::top_block_sptr tb = gr::make_top_block("top");
- gr::block_sptr src (gr::blocks::null_source::make(sizeof(float)));
- gr::block_sptr head (gr::blocks::head::make(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::blocks::null_sink::make(sizeof(float)));
-
- // Rate change blocks
- gr::blocks::keep_one_in_n::sptr dec10(gr::blocks::keep_one_in_n::make(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
- BOOST_REQUIRE_EQUAL(tags0.size(), (size_t)0);
- BOOST_REQUIRE_EQUAL(tags1.size(), (size_t)4);
- BOOST_REQUIRE_EQUAL(tags2.size(), (size_t)8);
+ int N = 40000;
+ gr::top_block_sptr tb = gr::make_top_block("top");
+ gr::block_sptr src(gr::blocks::null_source::make(sizeof(float)));
+ gr::block_sptr head(gr::blocks::head::make(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::blocks::null_sink::make(sizeof(float)));
+
+ // Rate change blocks
+ gr::blocks::keep_one_in_n::sptr dec10(
+ gr::blocks::keep_one_in_n::make(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
+ BOOST_REQUIRE_EQUAL(tags0.size(), (size_t)0);
+ BOOST_REQUIRE_EQUAL(tags1.size(), (size_t)4);
+ BOOST_REQUIRE_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();
-
- gr::tag_t expected_tags1[5];
- expected_tags1[0] = make_tag(0, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(0));
- expected_tags1[1] = make_tag(10000, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(1));
- expected_tags1[2] = make_tag(20000, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(2));
- expected_tags1[3] = make_tag(30000, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(3));
-
- gr::tag_t expected_tags2[10];
- expected_tags2[0] = make_tag(0, pmt::mp(str1.str()), pmt::mp("seq"), pmt::mp(0));
- expected_tags2[1] = make_tag(0, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(0));
- expected_tags2[2] = make_tag(1000, pmt::mp(str1.str()), pmt::mp("seq"), pmt::mp(1));
- expected_tags2[3] = make_tag(1000, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(1));
- expected_tags2[4] = make_tag(2000, pmt::mp(str1.str()), pmt::mp("seq"), pmt::mp(2));
- expected_tags2[5] = make_tag(2000, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(2));
- expected_tags2[6] = make_tag(3000, pmt::mp(str1.str()), pmt::mp("seq"), pmt::mp(3));
- expected_tags2[7] = make_tag(3000, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(3));
- expected_tags2[8] = make_tag(4000, pmt::mp(str1.str()), pmt::mp("seq"), pmt::mp(4));
- expected_tags2[9] = make_tag(4000, pmt::mp(str0.str()), pmt::mp("seq"), pmt::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;
- BOOST_REQUIRE_EQUAL(tags1[i], 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;
- BOOST_REQUIRE_EQUAL(tags2[i], expected_tags2[i]);
- }
+ // 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();
+
+ gr::tag_t expected_tags1[5];
+ expected_tags1[0] = make_tag(0, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(0));
+ expected_tags1[1] = make_tag(10000, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(1));
+ expected_tags1[2] = make_tag(20000, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(2));
+ expected_tags1[3] = make_tag(30000, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(3));
+
+ gr::tag_t expected_tags2[10];
+ expected_tags2[0] = make_tag(0, pmt::mp(str1.str()), pmt::mp("seq"), pmt::mp(0));
+ expected_tags2[1] = make_tag(0, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(0));
+ expected_tags2[2] = make_tag(1000, pmt::mp(str1.str()), pmt::mp("seq"), pmt::mp(1));
+ expected_tags2[3] = make_tag(1000, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(1));
+ expected_tags2[4] = make_tag(2000, pmt::mp(str1.str()), pmt::mp("seq"), pmt::mp(2));
+ expected_tags2[5] = make_tag(2000, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(2));
+ expected_tags2[6] = make_tag(3000, pmt::mp(str1.str()), pmt::mp("seq"), pmt::mp(3));
+ expected_tags2[7] = make_tag(3000, pmt::mp(str0.str()), pmt::mp("seq"), pmt::mp(3));
+ expected_tags2[8] = make_tag(4000, pmt::mp(str1.str()), pmt::mp("seq"), pmt::mp(4));
+ expected_tags2[9] = make_tag(4000, pmt::mp(str0.str()), pmt::mp("seq"), pmt::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;
+ BOOST_REQUIRE_EQUAL(tags1[i], 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;
+ BOOST_REQUIRE_EQUAL(tags2[i], expected_tags2[i]);
+ }
#endif
}
-
diff --git a/gr-blocks/lib/qa_gr_block.cc b/gr-blocks/lib/qa_gr_block.cc
index 46079165b0..b40a63cd2a 100644
--- a/gr-blocks/lib/qa_gr_block.cc
+++ b/gr-blocks/lib/qa_gr_block.cc
@@ -31,44 +31,43 @@
BOOST_AUTO_TEST_CASE(t0)
{
- // test creation of sources
- gr::block_sptr src1(gr::blocks::null_source::make(sizeof (int)));
- BOOST_REQUIRE_EQUAL(std::string("null_source"), src1->name ());
- BOOST_REQUIRE_EQUAL(0, src1->input_signature()->max_streams ());
- BOOST_REQUIRE_EQUAL(1, src1->output_signature()->min_streams ());
- BOOST_REQUIRE_EQUAL(-1, src1->output_signature()->max_streams ());
- BOOST_REQUIRE_EQUAL((int) sizeof(int),
- src1->output_signature()->sizeof_stream_item (0));
+ // test creation of sources
+ gr::block_sptr src1(gr::blocks::null_source::make(sizeof(int)));
+ BOOST_REQUIRE_EQUAL(std::string("null_source"), src1->name());
+ BOOST_REQUIRE_EQUAL(0, src1->input_signature()->max_streams());
+ BOOST_REQUIRE_EQUAL(1, src1->output_signature()->min_streams());
+ BOOST_REQUIRE_EQUAL(-1, src1->output_signature()->max_streams());
+ BOOST_REQUIRE_EQUAL((int)sizeof(int),
+ src1->output_signature()->sizeof_stream_item(0));
- gr::block_sptr src2(gr::blocks::null_source::make(sizeof(short)));
- BOOST_REQUIRE_EQUAL(std::string ("null_source"), src2->name ());
- BOOST_REQUIRE_EQUAL(0, src2->input_signature()->max_streams ());
- BOOST_REQUIRE_EQUAL(1, src2->output_signature()->min_streams ());
- BOOST_REQUIRE_EQUAL(-1, src2->output_signature()->max_streams ());
- BOOST_REQUIRE_EQUAL((int)sizeof (short),
- src2->output_signature()->sizeof_stream_item (0));
+ gr::block_sptr src2(gr::blocks::null_source::make(sizeof(short)));
+ BOOST_REQUIRE_EQUAL(std::string("null_source"), src2->name());
+ BOOST_REQUIRE_EQUAL(0, src2->input_signature()->max_streams());
+ BOOST_REQUIRE_EQUAL(1, src2->output_signature()->min_streams());
+ BOOST_REQUIRE_EQUAL(-1, src2->output_signature()->max_streams());
+ BOOST_REQUIRE_EQUAL((int)sizeof(short),
+ src2->output_signature()->sizeof_stream_item(0));
}
BOOST_AUTO_TEST_CASE(t1)
{
- // test creation of sinks
- gr::block_sptr dst1 (gr::blocks::null_sink::make (sizeof (int)));
- BOOST_REQUIRE_EQUAL (std::string ("null_sink"), dst1->name ());
- BOOST_REQUIRE_EQUAL (1, dst1->input_signature()->min_streams ());
- BOOST_REQUIRE_EQUAL (-1, dst1->input_signature()->max_streams ());
- BOOST_REQUIRE_EQUAL ((int) sizeof (int),
- dst1->input_signature()->sizeof_stream_item (0));
+ // test creation of sinks
+ gr::block_sptr dst1(gr::blocks::null_sink::make(sizeof(int)));
+ BOOST_REQUIRE_EQUAL(std::string("null_sink"), dst1->name());
+ BOOST_REQUIRE_EQUAL(1, dst1->input_signature()->min_streams());
+ BOOST_REQUIRE_EQUAL(-1, dst1->input_signature()->max_streams());
+ BOOST_REQUIRE_EQUAL((int)sizeof(int), dst1->input_signature()->sizeof_stream_item(0));
- BOOST_REQUIRE_EQUAL (0, dst1->output_signature()->max_streams ());
+ BOOST_REQUIRE_EQUAL(0, dst1->output_signature()->max_streams());
- gr::block_sptr dst2 (gr::blocks::null_sink::make (sizeof (short)));
- BOOST_REQUIRE_EQUAL (std::string ("null_sink"), dst2->name ());
- BOOST_REQUIRE_EQUAL (1, dst2->input_signature()->min_streams ());
- BOOST_REQUIRE_EQUAL (-1, dst2->input_signature()->max_streams ());
- BOOST_REQUIRE_EQUAL ((int) sizeof (short),
- dst2->input_signature()->sizeof_stream_item (0));
- BOOST_REQUIRE_EQUAL (0, dst2->output_signature()->max_streams ());
+ gr::block_sptr dst2(gr::blocks::null_sink::make(sizeof(short)));
+ BOOST_REQUIRE_EQUAL(std::string("null_sink"), dst2->name());
+ BOOST_REQUIRE_EQUAL(1, dst2->input_signature()->min_streams());
+ BOOST_REQUIRE_EQUAL(-1, dst2->input_signature()->max_streams());
+ BOOST_REQUIRE_EQUAL((int)sizeof(short),
+ dst2->input_signature()->sizeof_stream_item(0));
+ BOOST_REQUIRE_EQUAL(0, dst2->output_signature()->max_streams());
}
#include <gnuradio/top_block.h>
@@ -78,26 +77,25 @@ BOOST_AUTO_TEST_CASE(t1)
BOOST_AUTO_TEST_CASE(t2)
{
- gr::block_sptr src1(gr::blocks::null_source::make(sizeof (int)));
- gr::block_sptr nop(gr::blocks::nop::make(sizeof (int)));
- gr::block_sptr dst1 (gr::blocks::null_sink::make (sizeof (int)));
+ gr::block_sptr src1(gr::blocks::null_source::make(sizeof(int)));
+ gr::block_sptr nop(gr::blocks::nop::make(sizeof(int)));
+ gr::block_sptr dst1(gr::blocks::null_sink::make(sizeof(int)));
- gr::top_block_sptr tb(gr::make_top_block("t2"));
- tb->connect(src1, 0, nop, 0);
- tb->connect(nop, 0, dst1, 0);
- tb->start();
+ gr::top_block_sptr tb(gr::make_top_block("t2"));
+ tb->connect(src1, 0, nop, 0);
+ tb->connect(nop, 0, dst1, 0);
+ tb->start();
- const char *obuf = nop->detail()->output(0)->base();
- int obsize = nop->detail()->output(0)->bufsize();
- const char *ibuf = nop->detail()->input(0)->buffer()->base();
- int ibsize = nop->detail()->input(0)->buffer()->bufsize();
+ const char* obuf = nop->detail()->output(0)->base();
+ int obsize = nop->detail()->output(0)->bufsize();
+ const char* ibuf = nop->detail()->input(0)->buffer()->base();
+ int ibsize = nop->detail()->input(0)->buffer()->bufsize();
- BOOST_REQUIRE(obuf != NULL);
- BOOST_REQUIRE(ibuf != NULL);
- BOOST_REQUIRE(obsize > 0);
- BOOST_REQUIRE(ibsize > 0);
+ BOOST_REQUIRE(obuf != NULL);
+ BOOST_REQUIRE(ibuf != NULL);
+ BOOST_REQUIRE(obsize > 0);
+ BOOST_REQUIRE(ibsize > 0);
- tb->stop();
- tb->wait();
+ tb->stop();
+ tb->wait();
}
-
diff --git a/gr-blocks/lib/qa_gr_flowgraph.cc b/gr-blocks/lib/qa_gr_flowgraph.cc
index 2626b9bbda..524c43755e 100644
--- a/gr-blocks/lib/qa_gr_flowgraph.cc
+++ b/gr-blocks/lib/qa_gr_flowgraph.cc
@@ -31,263 +31,280 @@
#include <boost/test/unit_test.hpp>
namespace gr {
- namespace blocks {
- class null_qa_source : virtual public sync_block {
- public:
- typedef boost::shared_ptr<null_qa_source> sptr;
- static sptr make(size_t sizeof_stream_item);
- };
- class null_source_qa_impl : public null_qa_source
+namespace blocks {
+class null_qa_source : virtual public sync_block
+{
+public:
+ typedef boost::shared_ptr<null_qa_source> sptr;
+ static sptr make(size_t sizeof_stream_item);
+};
+class null_source_qa_impl : public null_qa_source
+{
+public:
+ null_source_qa_impl(size_t sizeof_stream_item)
+ : sync_block("null_source",
+ io_signature::make(0, 0, 0),
+ io_signature::make(1, 1, sizeof_stream_item))
+ {
+ }
+ ~null_source_qa_impl() {}
+
+ int work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
{
- public:
- null_source_qa_impl(size_t sizeof_stream_item)
- : sync_block("null_source", io_signature::make(0, 0, 0), io_signature::make(1, 1, sizeof_stream_item)) {}
- ~null_source_qa_impl(){}
-
- int work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) {
- void *optr;
- for(size_t n = 0; n < input_items.size(); n++) {
- optr = (void*)output_items[n];
- memset(optr, 0, noutput_items * output_signature()->sizeof_stream_item(n));
+ void* optr;
+ for (size_t n = 0; n < input_items.size(); n++) {
+ optr = (void*)output_items[n];
+ memset(optr, 0, noutput_items * output_signature()->sizeof_stream_item(n));
}
return noutput_items;
- }
- };
- null_qa_source::sptr null_qa_source::make(size_t sizeof_stream_item)
+ }
+};
+null_qa_source::sptr null_qa_source::make(size_t sizeof_stream_item)
+{
+ return gnuradio::get_initial_sptr(new null_source_qa_impl(sizeof_stream_item));
+}
+class null_qa_sink : virtual public sync_block
+{
+public:
+ typedef boost::shared_ptr<null_qa_sink> sptr;
+ static sptr make(size_t sizeof_stream_item);
+};
+class null_sink_qa_impl : public null_qa_sink
+{
+public:
+ null_sink_qa_impl(size_t sizeof_stream_item)
+ : sync_block("null_qa_sink",
+ io_signature::make(1, 1, sizeof_stream_item),
+ io_signature::make(0, 0, 0))
{
- return gnuradio::get_initial_sptr(new null_source_qa_impl(sizeof_stream_item));
}
- class null_qa_sink : virtual public sync_block
+ ~null_sink_qa_impl() {}
+ int work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
{
- public:
- typedef boost::shared_ptr<null_qa_sink> sptr;
- static sptr make(size_t sizeof_stream_item);
- };
- class null_sink_qa_impl : public null_qa_sink {
- public:
- null_sink_qa_impl(size_t sizeof_stream_item)
- : sync_block("null_qa_sink", io_signature::make(1, 1, sizeof_stream_item), io_signature::make(0, 0, 0)) {}
- ~null_sink_qa_impl() {}
- int work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) {
return noutput_items;
- }
- };
- null_qa_sink::sptr null_qa_sink::make(size_t sizeof_stream_item) {
- return gnuradio::get_initial_sptr(new null_sink_qa_impl(sizeof_stream_item));
}
- } /* namespace blocks */
+};
+null_qa_sink::sptr null_qa_sink::make(size_t sizeof_stream_item)
+{
+ return gnuradio::get_initial_sptr(new null_sink_qa_impl(sizeof_stream_item));
+}
+} /* namespace blocks */
} /* namespace gr */
BOOST_AUTO_TEST_CASE(t0)
{
- gr::flowgraph_sptr fg = gr::make_flowgraph();
+ gr::flowgraph_sptr fg = gr::make_flowgraph();
- BOOST_REQUIRE(fg);
+ BOOST_REQUIRE(fg);
}
BOOST_AUTO_TEST_CASE(t1_connect)
{
- gr::flowgraph_sptr fg = gr::make_flowgraph();
+ gr::flowgraph_sptr fg = gr::make_flowgraph();
- gr::block_sptr nop1 = gr::blocks::nop::make(sizeof(int));
- gr::block_sptr nop2 = gr::blocks::nop::make(sizeof(int));
+ gr::block_sptr nop1 = gr::blocks::nop::make(sizeof(int));
+ gr::block_sptr nop2 = gr::blocks::nop::make(sizeof(int));
- fg->connect(nop1, 0, nop2, 0);
+ fg->connect(nop1, 0, nop2, 0);
}
BOOST_AUTO_TEST_CASE(t2_connect_invalid_src_port_neg)
{
- gr::flowgraph_sptr fg = gr::make_flowgraph();
+ gr::flowgraph_sptr fg = gr::make_flowgraph();
- gr::block_sptr nop1 = gr::blocks::nop::make(sizeof(int));
- gr::block_sptr nop2 = gr::blocks::nop::make(sizeof(int));
+ gr::block_sptr nop1 = gr::blocks::nop::make(sizeof(int));
+ gr::block_sptr nop2 = gr::blocks::nop::make(sizeof(int));
- BOOST_REQUIRE_THROW(fg->connect(nop1, -1, nop2, 0), std::invalid_argument);
+ BOOST_REQUIRE_THROW(fg->connect(nop1, -1, nop2, 0), std::invalid_argument);
}
BOOST_AUTO_TEST_CASE(t3_connect_src_port_exceeds)
{
- gr::flowgraph_sptr fg = gr::make_flowgraph();
+ gr::flowgraph_sptr fg = gr::make_flowgraph();
- gr::block_sptr src = gr::blocks::null_qa_source::make(sizeof(int));
- gr::block_sptr dst = gr::blocks::null_sink::make(sizeof(int));
+ gr::block_sptr src = gr::blocks::null_qa_source::make(sizeof(int));
+ gr::block_sptr dst = gr::blocks::null_sink::make(sizeof(int));
- BOOST_REQUIRE_THROW(fg->connect(src, 1, dst, 0), std::invalid_argument);
+ BOOST_REQUIRE_THROW(fg->connect(src, 1, dst, 0), std::invalid_argument);
}
BOOST_AUTO_TEST_CASE(t4_connect_invalid_dst_port_neg)
{
- gr::flowgraph_sptr fg = gr::make_flowgraph();
+ gr::flowgraph_sptr fg = gr::make_flowgraph();
- gr::block_sptr nop1 = gr::blocks::nop::make(sizeof(int));
- gr::block_sptr nop2 = gr::blocks::nop::make(sizeof(int));
+ gr::block_sptr nop1 = gr::blocks::nop::make(sizeof(int));
+ gr::block_sptr nop2 = gr::blocks::nop::make(sizeof(int));
- BOOST_REQUIRE_THROW(fg->connect(nop1, 0, nop2, -1), std::invalid_argument);
+ BOOST_REQUIRE_THROW(fg->connect(nop1, 0, nop2, -1), std::invalid_argument);
}
BOOST_AUTO_TEST_CASE(t5_connect_dst_port_exceeds)
{
- gr::flowgraph_sptr fg = gr::make_flowgraph();
+ gr::flowgraph_sptr fg = gr::make_flowgraph();
- gr::block_sptr src = gr::blocks::null_source::make(sizeof(int));
- gr::block_sptr dst = gr::blocks::null_qa_sink::make(sizeof(int));
+ gr::block_sptr src = gr::blocks::null_source::make(sizeof(int));
+ gr::block_sptr dst = gr::blocks::null_qa_sink::make(sizeof(int));
- BOOST_REQUIRE_THROW(fg->connect(src, 0, dst, 1), std::invalid_argument);
+ BOOST_REQUIRE_THROW(fg->connect(src, 0, dst, 1), std::invalid_argument);
}
BOOST_AUTO_TEST_CASE(t6_connect_dst_in_use)
{
- gr::flowgraph_sptr fg = gr::make_flowgraph();
+ gr::flowgraph_sptr fg = gr::make_flowgraph();
- gr::block_sptr src1 = gr::blocks::null_source::make(sizeof(int));
- gr::block_sptr src2 = gr::blocks::null_source::make(sizeof(int));
- gr::block_sptr dst = gr::blocks::null_sink::make(sizeof(int));
+ gr::block_sptr src1 = gr::blocks::null_source::make(sizeof(int));
+ gr::block_sptr src2 = gr::blocks::null_source::make(sizeof(int));
+ gr::block_sptr dst = gr::blocks::null_sink::make(sizeof(int));
- fg->connect(src1, 0, dst, 0);
- BOOST_REQUIRE_THROW(fg->connect(src2, 0, dst, 0), std::invalid_argument);
+ fg->connect(src1, 0, dst, 0);
+ BOOST_REQUIRE_THROW(fg->connect(src2, 0, dst, 0), std::invalid_argument);
}
BOOST_AUTO_TEST_CASE(t7_connect_one_src_two_dst)
{
- gr::flowgraph_sptr fg = gr::make_flowgraph();
+ gr::flowgraph_sptr fg = gr::make_flowgraph();
- gr::block_sptr src = gr::blocks::null_source::make(sizeof(int));
- gr::block_sptr dst1 = gr::blocks::null_sink::make(sizeof(int));
- gr::block_sptr dst2 = gr::blocks::null_sink::make(sizeof(int));
+ gr::block_sptr src = gr::blocks::null_source::make(sizeof(int));
+ gr::block_sptr dst1 = gr::blocks::null_sink::make(sizeof(int));
+ gr::block_sptr dst2 = gr::blocks::null_sink::make(sizeof(int));
- fg->connect(src, 0, dst1, 0);
- fg->connect(src, 0, dst2, 0);
+ fg->connect(src, 0, dst1, 0);
+ fg->connect(src, 0, dst2, 0);
}
BOOST_AUTO_TEST_CASE(t8_connect_type_mismatch)
{
- gr::flowgraph_sptr fg = gr::make_flowgraph();
+ gr::flowgraph_sptr fg = gr::make_flowgraph();
- gr::block_sptr nop1 = gr::blocks::nop::make(sizeof(char));
- gr::block_sptr nop2 = gr::blocks::nop::make(sizeof(int));
+ gr::block_sptr nop1 = gr::blocks::nop::make(sizeof(char));
+ gr::block_sptr nop2 = gr::blocks::nop::make(sizeof(int));
- BOOST_REQUIRE_THROW(fg->connect(nop1, 0, nop2, 0), std::invalid_argument);
+ BOOST_REQUIRE_THROW(fg->connect(nop1, 0, nop2, 0), std::invalid_argument);
}
BOOST_AUTO_TEST_CASE(t9_disconnect)
{
- gr::flowgraph_sptr fg = gr::make_flowgraph();
+ gr::flowgraph_sptr fg = gr::make_flowgraph();
- gr::block_sptr nop1 = gr::blocks::nop::make(sizeof(int));
- gr::block_sptr nop2 = gr::blocks::nop::make(sizeof(int));
+ gr::block_sptr nop1 = gr::blocks::nop::make(sizeof(int));
+ gr::block_sptr nop2 = gr::blocks::nop::make(sizeof(int));
- fg->connect(nop1, 0, nop2, 0);
- fg->disconnect(nop1, 0, nop2, 0);
+ fg->connect(nop1, 0, nop2, 0);
+ fg->disconnect(nop1, 0, nop2, 0);
}
BOOST_AUTO_TEST_CASE(t10_disconnect_unconnected_block)
{
- gr::flowgraph_sptr fg = gr::make_flowgraph();
+ gr::flowgraph_sptr fg = gr::make_flowgraph();
- gr::block_sptr nop1 = gr::blocks::nop::make(sizeof(int));
- gr::block_sptr nop2 = gr::blocks::nop::make(sizeof(int));
- gr::block_sptr nop3 = gr::blocks::nop::make(sizeof(int));
+ gr::block_sptr nop1 = gr::blocks::nop::make(sizeof(int));
+ gr::block_sptr nop2 = gr::blocks::nop::make(sizeof(int));
+ gr::block_sptr nop3 = gr::blocks::nop::make(sizeof(int));
- fg->connect(nop1, 0, nop2, 0);
- BOOST_REQUIRE_THROW(fg->disconnect(nop1, 0, nop3, 0), std::invalid_argument);
+ fg->connect(nop1, 0, nop2, 0);
+ BOOST_REQUIRE_THROW(fg->disconnect(nop1, 0, nop3, 0), std::invalid_argument);
}
BOOST_AUTO_TEST_CASE(t11_disconnect_unconnected_port)
{
- gr::flowgraph_sptr fg = gr::make_flowgraph();
+ gr::flowgraph_sptr fg = gr::make_flowgraph();
- gr::block_sptr nop1 = gr::blocks::nop::make(sizeof(int));
- gr::block_sptr nop2 = gr::blocks::nop::make(sizeof(int));
+ gr::block_sptr nop1 = gr::blocks::nop::make(sizeof(int));
+ gr::block_sptr nop2 = gr::blocks::nop::make(sizeof(int));
- fg->connect(nop1, 0, nop2, 0);
- BOOST_REQUIRE_THROW(fg->disconnect(nop1, 0, nop2, 1), std::invalid_argument);
+ fg->connect(nop1, 0, nop2, 0);
+ BOOST_REQUIRE_THROW(fg->disconnect(nop1, 0, nop2, 1), std::invalid_argument);
}
BOOST_AUTO_TEST_CASE(t12_validate)
{
- gr::flowgraph_sptr fg = gr::make_flowgraph();
+ gr::flowgraph_sptr fg = gr::make_flowgraph();
- gr::block_sptr nop1 = gr::blocks::nop::make(sizeof(int));
- gr::block_sptr nop2 = gr::blocks::nop::make(sizeof(int));
+ gr::block_sptr nop1 = gr::blocks::nop::make(sizeof(int));
+ gr::block_sptr nop2 = gr::blocks::nop::make(sizeof(int));
- fg->connect(nop1, 0, nop2, 0);
- fg->validate();
+ fg->connect(nop1, 0, nop2, 0);
+ fg->validate();
}
BOOST_AUTO_TEST_CASE(t13_validate_missing_input_assignment)
{
- gr::flowgraph_sptr fg = gr::make_flowgraph();
+ gr::flowgraph_sptr fg = gr::make_flowgraph();
- gr::block_sptr nop1 = gr::blocks::nop::make(sizeof(int));
- gr::block_sptr nop2 = gr::blocks::nop::make(sizeof(int));
+ gr::block_sptr nop1 = gr::blocks::nop::make(sizeof(int));
+ gr::block_sptr nop2 = gr::blocks::nop::make(sizeof(int));
- fg->connect(nop1, 0, nop2, 0);
- fg->connect(nop1, 0, nop2, 2);
- BOOST_REQUIRE_THROW(fg->validate(), std::runtime_error);
+ fg->connect(nop1, 0, nop2, 0);
+ fg->connect(nop1, 0, nop2, 2);
+ BOOST_REQUIRE_THROW(fg->validate(), std::runtime_error);
}
BOOST_AUTO_TEST_CASE(t14_validate_missing_output_assignment)
{
- gr::flowgraph_sptr fg = gr::make_flowgraph();
+ gr::flowgraph_sptr fg = gr::make_flowgraph();
- gr::block_sptr nop1 = gr::blocks::nop::make(sizeof(int));
- gr::block_sptr nop2 = gr::blocks::nop::make(sizeof(int));
+ gr::block_sptr nop1 = gr::blocks::nop::make(sizeof(int));
+ gr::block_sptr nop2 = gr::blocks::nop::make(sizeof(int));
- fg->connect(nop1, 0, nop2, 0);
- fg->connect(nop1, 2, nop2, 1);
- BOOST_REQUIRE_THROW(fg->validate(), std::runtime_error);
+ fg->connect(nop1, 0, nop2, 0);
+ fg->connect(nop1, 2, nop2, 1);
+ BOOST_REQUIRE_THROW(fg->validate(), std::runtime_error);
}
BOOST_AUTO_TEST_CASE(t15_clear)
{
- gr::flowgraph_sptr fg = gr::make_flowgraph();
+ gr::flowgraph_sptr fg = gr::make_flowgraph();
- gr::block_sptr nop1 = gr::blocks::nop::make(sizeof(int));
- gr::block_sptr nop2 = gr::blocks::nop::make(sizeof(int));
+ gr::block_sptr nop1 = gr::blocks::nop::make(sizeof(int));
+ gr::block_sptr nop2 = gr::blocks::nop::make(sizeof(int));
- fg->connect(nop1, 0, nop2, 0);
+ fg->connect(nop1, 0, nop2, 0);
- BOOST_REQUIRE(fg->edges().size() == 1);
- BOOST_REQUIRE(fg->calc_used_blocks().size() == 2);
+ BOOST_REQUIRE(fg->edges().size() == 1);
+ BOOST_REQUIRE(fg->calc_used_blocks().size() == 2);
- fg->clear();
+ fg->clear();
- BOOST_REQUIRE(fg->edges().size() == 0);
- BOOST_REQUIRE(fg->calc_used_blocks().size() == 0);
+ BOOST_REQUIRE(fg->edges().size() == 0);
+ BOOST_REQUIRE(fg->calc_used_blocks().size() == 0);
}
BOOST_AUTO_TEST_CASE(t16_partition)
{
- gr::flowgraph_sptr fg = gr::make_flowgraph();
+ gr::flowgraph_sptr fg = gr::make_flowgraph();
- gr::block_sptr nop11 = gr::blocks::nop::make(sizeof(int));
- gr::block_sptr nop12 = gr::blocks::nop::make(sizeof(int));
- gr::block_sptr nop13 = gr::blocks::nop::make(sizeof(int));
- gr::block_sptr nop14 = gr::blocks::nop::make(sizeof(int));
+ gr::block_sptr nop11 = gr::blocks::nop::make(sizeof(int));
+ gr::block_sptr nop12 = gr::blocks::nop::make(sizeof(int));
+ gr::block_sptr nop13 = gr::blocks::nop::make(sizeof(int));
+ gr::block_sptr nop14 = gr::blocks::nop::make(sizeof(int));
- gr::block_sptr nop21 = gr::blocks::nop::make(sizeof(int));
- gr::block_sptr nop22 = gr::blocks::nop::make(sizeof(int));
- gr::block_sptr nop23 = gr::blocks::nop::make(sizeof(int));
+ gr::block_sptr nop21 = gr::blocks::nop::make(sizeof(int));
+ gr::block_sptr nop22 = gr::blocks::nop::make(sizeof(int));
+ gr::block_sptr nop23 = gr::blocks::nop::make(sizeof(int));
- gr::block_sptr nop31 = gr::blocks::nop::make(sizeof(int));
- gr::block_sptr nop32 = gr::blocks::nop::make(sizeof(int));
+ gr::block_sptr nop31 = gr::blocks::nop::make(sizeof(int));
+ gr::block_sptr nop32 = gr::blocks::nop::make(sizeof(int));
- // Build disjoint graph #1
- fg->connect(nop11, 0, nop12, 0);
- fg->connect(nop12, 0, nop13, 0);
- fg->connect(nop13, 0, nop14, 0);
+ // Build disjoint graph #1
+ fg->connect(nop11, 0, nop12, 0);
+ fg->connect(nop12, 0, nop13, 0);
+ fg->connect(nop13, 0, nop14, 0);
- // Build disjoint graph #2
- fg->connect(nop21, 0, nop22, 0);
- fg->connect(nop22, 0, nop23, 0);
+ // Build disjoint graph #2
+ fg->connect(nop21, 0, nop22, 0);
+ fg->connect(nop22, 0, nop23, 0);
- // Build disjoint graph #3
- fg->connect(nop31, 0, nop32, 0);
+ // Build disjoint graph #3
+ fg->connect(nop31, 0, nop32, 0);
- std::vector<gr::basic_block_vector_t> graphs = fg->partition();
+ std::vector<gr::basic_block_vector_t> graphs = fg->partition();
- BOOST_REQUIRE(graphs.size() == 3);
- BOOST_REQUIRE(graphs[0].size() == 4);
- BOOST_REQUIRE(graphs[1].size() == 3);
- BOOST_REQUIRE(graphs[2].size() == 2);
+ BOOST_REQUIRE(graphs.size() == 3);
+ BOOST_REQUIRE(graphs[0].size() == 4);
+ BOOST_REQUIRE(graphs[1].size() == 3);
+ BOOST_REQUIRE(graphs[2].size() == 2);
}
diff --git a/gr-blocks/lib/qa_gr_hier_block2.cc b/gr-blocks/lib/qa_gr_hier_block2.cc
index fcc9e6fdc9..6a95c2c1bd 100644
--- a/gr-blocks/lib/qa_gr_hier_block2.cc
+++ b/gr-blocks/lib/qa_gr_hier_block2.cc
@@ -30,24 +30,24 @@
BOOST_AUTO_TEST_CASE(test_make)
{
- gr::hier_block2_sptr src1(gr::make_hier_block2("test",
- gr::io_signature::make(1, 1, 1 * sizeof(int)),
- gr::io_signature::make(1, 1, 1 * sizeof(int))));
+ gr::hier_block2_sptr src1(
+ gr::make_hier_block2("test",
+ gr::io_signature::make(1, 1, 1 * sizeof(int)),
+ gr::io_signature::make(1, 1, 1 * sizeof(int))));
BOOST_REQUIRE(src1);
BOOST_REQUIRE_EQUAL(std::string("test"), src1->name());
- BOOST_REQUIRE_EQUAL(1 * (int) sizeof(int),
- src1->input_signature()->sizeof_stream_item(0));
+ BOOST_REQUIRE_EQUAL(1 * (int)sizeof(int),
+ src1->input_signature()->sizeof_stream_item(0));
BOOST_REQUIRE_EQUAL(1, src1->input_signature()->min_streams());
BOOST_REQUIRE_EQUAL(1, src1->input_signature()->max_streams());
- BOOST_REQUIRE_EQUAL(1 * (int) sizeof(int),
- src1->output_signature()->sizeof_stream_item(0));
+ BOOST_REQUIRE_EQUAL(1 * (int)sizeof(int),
+ src1->output_signature()->sizeof_stream_item(0));
BOOST_REQUIRE_EQUAL(1, src1->output_signature()->min_streams());
BOOST_REQUIRE_EQUAL(1, src1->output_signature()->max_streams());
}
-
diff --git a/gr-blocks/lib/qa_gr_hier_block2_derived.cc b/gr-blocks/lib/qa_gr_hier_block2_derived.cc
index 519a23d97e..9b22568a4c 100644
--- a/gr-blocks/lib/qa_gr_hier_block2_derived.cc
+++ b/gr-blocks/lib/qa_gr_hier_block2_derived.cc
@@ -41,47 +41,44 @@ gr_derived_block_sptr gr_make_derived_block();
class gr_derived_block : public gr::hier_block2
{
private:
- friend gr_derived_block_sptr gr_make_derived_block();
- gr_derived_block();
+ friend gr_derived_block_sptr gr_make_derived_block();
+ gr_derived_block();
public:
- ~gr_derived_block();
+ ~gr_derived_block();
};
-gr_derived_block_sptr
-gr_make_derived_block()
+gr_derived_block_sptr gr_make_derived_block()
{
- return gnuradio::get_initial_sptr(new gr_derived_block());
+ return gnuradio::get_initial_sptr(new gr_derived_block());
}
gr_derived_block::gr_derived_block()
- : gr::hier_block2("gr_derived_block",
- gr::io_signature::make(1, 1, sizeof(int)), // Input signature
- gr::io_signature::make(1, 1, sizeof(int))) // Output signature
+ : gr::hier_block2("gr_derived_block",
+ gr::io_signature::make(1, 1, sizeof(int)), // Input signature
+ gr::io_signature::make(1, 1, sizeof(int))) // Output signature
{
- gr::block_sptr copy(gr::blocks::copy::make(sizeof(int)));
+ gr::block_sptr copy(gr::blocks::copy::make(sizeof(int)));
- connect(self(), 0, copy, 0);
- connect(copy, 0, self(), 0);
+ connect(self(), 0, copy, 0);
+ connect(copy, 0, self(), 0);
}
-gr_derived_block::~gr_derived_block()
-{
-}
+gr_derived_block::~gr_derived_block() {}
BOOST_AUTO_TEST_CASE(test_1)
{
- gr::top_block_sptr tb(gr::make_top_block("test"));
+ gr::top_block_sptr tb(gr::make_top_block("test"));
- gr::block_sptr src(gr::blocks::null_source::make(sizeof(int)));
- gr::block_sptr head(gr::blocks::head::make(sizeof(int), 1000));
- gr_derived_block_sptr blk(gr_make_derived_block());
- gr::block_sptr dst(gr::blocks::null_sink::make(sizeof(int)));
+ gr::block_sptr src(gr::blocks::null_source::make(sizeof(int)));
+ gr::block_sptr head(gr::blocks::head::make(sizeof(int), 1000));
+ gr_derived_block_sptr blk(gr_make_derived_block());
+ gr::block_sptr dst(gr::blocks::null_sink::make(sizeof(int)));
- tb->connect(src, 0, head, 0);
- tb->connect(head, 0, blk, 0);
- tb->connect(blk, 0, dst, 0);
+ tb->connect(src, 0, head, 0);
+ tb->connect(head, 0, blk, 0);
+ tb->connect(blk, 0, dst, 0);
- tb->run();
+ tb->run();
}
diff --git a/gr-blocks/lib/qa_gr_top_block.cc b/gr-blocks/lib/qa_gr_top_block.cc
index 7c456e312a..04e4379e97 100644
--- a/gr-blocks/lib/qa_gr_top_block.cc
+++ b/gr-blocks/lib/qa_gr_top_block.cc
@@ -36,259 +36,261 @@
BOOST_AUTO_TEST_CASE(t0)
{
- if (VERBOSE) std::cout << "qa_top_block::t0()\n";
+ if (VERBOSE)
+ std::cout << "qa_top_block::t0()\n";
- gr::top_block_sptr tb = gr::make_top_block("top");
+ gr::top_block_sptr tb = gr::make_top_block("top");
- BOOST_REQUIRE(tb);
+ BOOST_REQUIRE(tb);
}
BOOST_AUTO_TEST_CASE(t1_run)
{
- if (VERBOSE) std::cout << "qa_top_block::t1()\n";
+ if (VERBOSE)
+ std::cout << "qa_top_block::t1()\n";
- gr::top_block_sptr tb = gr::make_top_block("top");
+ gr::top_block_sptr tb = gr::make_top_block("top");
- gr::block_sptr src = gr::blocks::null_source::make(sizeof(int));
- gr::block_sptr head = gr::blocks::head::make(sizeof(int), 100000);
- gr::block_sptr dst = gr::blocks::null_sink::make(sizeof(int));
+ gr::block_sptr src = gr::blocks::null_source::make(sizeof(int));
+ gr::block_sptr head = gr::blocks::head::make(sizeof(int), 100000);
+ gr::block_sptr dst = gr::blocks::null_sink::make(sizeof(int));
- tb->connect(src, 0, head, 0);
- tb->connect(head, 0, dst, 0);
- tb->run();
+ tb->connect(src, 0, head, 0);
+ tb->connect(head, 0, dst, 0);
+ tb->run();
}
BOOST_AUTO_TEST_CASE(t2_start_stop_wait)
{
- if(VERBOSE)
- std::cout << "qa_top_block::t2()\n";
+ if (VERBOSE)
+ std::cout << "qa_top_block::t2()\n";
- gr::top_block_sptr tb = gr::make_top_block("top");
+ gr::top_block_sptr tb = gr::make_top_block("top");
- gr::block_sptr src = gr::blocks::null_source::make(sizeof(int));
- gr::block_sptr head = gr::blocks::head::make(sizeof(int), 100000);
- gr::block_sptr dst = gr::blocks::null_sink::make(sizeof(int));
+ gr::block_sptr src = gr::blocks::null_source::make(sizeof(int));
+ gr::block_sptr head = gr::blocks::head::make(sizeof(int), 100000);
+ gr::block_sptr dst = gr::blocks::null_sink::make(sizeof(int));
- tb->connect(src, 0, head, 0);
- tb->connect(head, 0, dst, 0);
+ tb->connect(src, 0, head, 0);
+ tb->connect(head, 0, dst, 0);
- tb->start();
- tb->stop();
- tb->wait();
+ tb->start();
+ tb->stop();
+ tb->wait();
}
BOOST_AUTO_TEST_CASE(t3_lock_unlock)
{
- if(VERBOSE)
- std::cout << "qa_top_block::t3()\n";
+ if (VERBOSE)
+ std::cout << "qa_top_block::t3()\n";
- gr::top_block_sptr tb = gr::make_top_block("top");
+ gr::top_block_sptr tb = gr::make_top_block("top");
- gr::block_sptr src = gr::blocks::null_source::make(sizeof(int));
- gr::block_sptr dst = gr::blocks::null_sink::make(sizeof(int));
+ gr::block_sptr src = gr::blocks::null_source::make(sizeof(int));
+ gr::block_sptr dst = gr::blocks::null_sink::make(sizeof(int));
- tb->connect(src, 0, dst, 0);
+ tb->connect(src, 0, dst, 0);
- tb->start();
+ tb->start();
- tb->lock();
- tb->unlock();
+ tb->lock();
+ tb->unlock();
- tb->stop();
- tb->wait();
+ tb->stop();
+ tb->wait();
}
BOOST_AUTO_TEST_CASE(t4_reconfigure)
{
- if(VERBOSE)
- std::cout << "qa_top_block::t4()\n";
+ if (VERBOSE)
+ std::cout << "qa_top_block::t4()\n";
- gr::top_block_sptr tb = gr::make_top_block("top");
+ gr::top_block_sptr tb = gr::make_top_block("top");
- gr::block_sptr src = gr::blocks::null_source::make(sizeof(int));
- gr::block_sptr head = gr::blocks::head::make(sizeof(int), 100000);
- gr::block_sptr dst = gr::blocks::null_sink::make(sizeof(int));
+ gr::block_sptr src = gr::blocks::null_source::make(sizeof(int));
+ gr::block_sptr head = gr::blocks::head::make(sizeof(int), 100000);
+ gr::block_sptr dst = gr::blocks::null_sink::make(sizeof(int));
- // Start infinite flowgraph
- tb->connect(src, 0, dst, 0);
- tb->start();
+ // Start infinite flowgraph
+ tb->connect(src, 0, dst, 0);
+ tb->start();
- // Reconfigure with gr_head in the middle
- tb->lock();
- tb->disconnect(src, 0, dst, 0);
- tb->connect(src, 0, head, 0);
- tb->connect(head, 0, dst, 0);
- tb->unlock();
+ // Reconfigure with gr_head in the middle
+ tb->lock();
+ tb->disconnect(src, 0, dst, 0);
+ tb->connect(src, 0, head, 0);
+ tb->connect(head, 0, dst, 0);
+ tb->unlock();
- // Wait for flowgraph to end on its own
- tb->wait();
+ // Wait for flowgraph to end on its own
+ tb->wait();
}
BOOST_AUTO_TEST_CASE(t5_max_noutputs)
{
- if(VERBOSE)
- std::cout << "qa_top_block::t5()\n";
+ if (VERBOSE)
+ std::cout << "qa_top_block::t5()\n";
- gr::top_block_sptr tb = gr::make_top_block("top");
+ gr::top_block_sptr tb = gr::make_top_block("top");
- gr::block_sptr src = gr::blocks::null_source::make(sizeof(int));
- gr::block_sptr head = gr::blocks::head::make(sizeof(int), 100000);
- gr::block_sptr dst = gr::blocks::null_sink::make(sizeof(int));
+ gr::block_sptr src = gr::blocks::null_source::make(sizeof(int));
+ gr::block_sptr head = gr::blocks::head::make(sizeof(int), 100000);
+ gr::block_sptr dst = gr::blocks::null_sink::make(sizeof(int));
- // Start infinite flowgraph
- tb->connect(src, 0, head, 0);
- tb->connect(head, 0, dst, 0);
- tb->start(100);
- tb->wait();
+ // Start infinite flowgraph
+ tb->connect(src, 0, head, 0);
+ tb->connect(head, 0, dst, 0);
+ tb->start(100);
+ tb->wait();
}
BOOST_AUTO_TEST_CASE(t6_reconfig_max_noutputs)
{
- if(VERBOSE)
- std::cout << "qa_top_block::t6()\n";
-
- gr::top_block_sptr tb = gr::make_top_block("top");
-
- gr::block_sptr src = gr::blocks::null_source::make(sizeof(int));
- gr::block_sptr head = gr::blocks::head::make(sizeof(int), 100000);
- gr::block_sptr dst = gr::blocks::null_sink::make(sizeof(int));
-
- // Start infinite flowgraph
- tb->connect(src, 0, dst, 0);
- tb->start(100);
-
- // Reconfigure with gr_head in the middle
- tb->lock();
- tb->disconnect(src, 0, dst, 0);
- tb->connect(src, 0, head, 0);
- tb->connect(head, 0, dst, 0);
- tb->set_max_noutput_items(1000);
- head->set_max_noutput_items(500);
- tb->unlock();
-
- // Wait for flowgraph to end on its own
- tb->wait();
+ if (VERBOSE)
+ std::cout << "qa_top_block::t6()\n";
+
+ gr::top_block_sptr tb = gr::make_top_block("top");
+
+ gr::block_sptr src = gr::blocks::null_source::make(sizeof(int));
+ gr::block_sptr head = gr::blocks::head::make(sizeof(int), 100000);
+ gr::block_sptr dst = gr::blocks::null_sink::make(sizeof(int));
+
+ // Start infinite flowgraph
+ tb->connect(src, 0, dst, 0);
+ tb->start(100);
+
+ // Reconfigure with gr_head in the middle
+ tb->lock();
+ tb->disconnect(src, 0, dst, 0);
+ tb->connect(src, 0, head, 0);
+ tb->connect(head, 0, dst, 0);
+ tb->set_max_noutput_items(1000);
+ head->set_max_noutput_items(500);
+ tb->unlock();
+
+ // Wait for flowgraph to end on its own
+ tb->wait();
}
BOOST_AUTO_TEST_CASE(t7_max_noutputs_per_block)
{
- if(VERBOSE)
- std::cout << "qa_top_block::t7()\n";
+ if (VERBOSE)
+ std::cout << "qa_top_block::t7()\n";
- gr::top_block_sptr tb = gr::make_top_block("top");
+ gr::top_block_sptr tb = gr::make_top_block("top");
- gr::block_sptr src = gr::blocks::null_source::make(sizeof(int));
- gr::block_sptr head = gr::blocks::head::make(sizeof(int), 100000);
- gr::block_sptr dst = gr::blocks::null_sink::make(sizeof(int));
+ gr::block_sptr src = gr::blocks::null_source::make(sizeof(int));
+ gr::block_sptr head = gr::blocks::head::make(sizeof(int), 100000);
+ gr::block_sptr dst = gr::blocks::null_sink::make(sizeof(int));
- head->set_max_noutput_items(100);
+ head->set_max_noutput_items(100);
- // Start infinite flowgraph
- tb->connect(src, 0, head, 0);
- tb->connect(head, 0, dst, 0);
- tb->start();
- tb->wait();
+ // Start infinite flowgraph
+ tb->connect(src, 0, head, 0);
+ tb->connect(head, 0, dst, 0);
+ tb->start();
+ tb->wait();
}
BOOST_AUTO_TEST_CASE(t8_reconfig_max_noutputs_per_block)
{
- if(VERBOSE)
- std::cout << "qa_top_block::t8()\n";
+ if (VERBOSE)
+ std::cout << "qa_top_block::t8()\n";
- gr::top_block_sptr tb = gr::make_top_block("top");
+ gr::top_block_sptr tb = gr::make_top_block("top");
- gr::block_sptr src = gr::blocks::null_source::make(sizeof(int));
- gr::block_sptr head = gr::blocks::head::make(sizeof(int), 100000);
- gr::block_sptr dst = gr::blocks::null_sink::make(sizeof(int));
+ gr::block_sptr src = gr::blocks::null_source::make(sizeof(int));
+ gr::block_sptr head = gr::blocks::head::make(sizeof(int), 100000);
+ gr::block_sptr dst = gr::blocks::null_sink::make(sizeof(int));
- head->set_max_noutput_items(99);
+ head->set_max_noutput_items(99);
- // Start infinite flowgraph
- tb->connect(src, 0, dst, 0);
- tb->start(201);
+ // Start infinite flowgraph
+ tb->connect(src, 0, dst, 0);
+ tb->start(201);
- // Reconfigure with gr_head in the middle
- tb->lock();
- tb->disconnect(src, 0, dst, 0);
- tb->connect(src, 0, head, 0);
- tb->connect(head, 0, dst, 0);
- tb->set_max_noutput_items(1023);
- head->set_max_noutput_items(513);
- tb->unlock();
+ // Reconfigure with gr_head in the middle
+ tb->lock();
+ tb->disconnect(src, 0, dst, 0);
+ tb->connect(src, 0, head, 0);
+ tb->connect(head, 0, dst, 0);
+ tb->set_max_noutput_items(1023);
+ head->set_max_noutput_items(513);
+ tb->unlock();
- // Wait for flowgraph to end on its own
- tb->wait();
+ // Wait for flowgraph to end on its own
+ tb->wait();
}
BOOST_AUTO_TEST_CASE(t9_max_output_buffer)
{
- if(VERBOSE)
- std::cout << "qa_top_block::t9()\n";
+ if (VERBOSE)
+ std::cout << "qa_top_block::t9()\n";
- gr::top_block_sptr tb = gr::make_top_block("top");
+ gr::top_block_sptr tb = gr::make_top_block("top");
- gr::block_sptr src = gr::blocks::null_source::make(sizeof(int));
- gr::block_sptr head = gr::blocks::head::make(sizeof(int), 100000);
- gr::block_sptr dst = gr::blocks::null_sink::make(sizeof(int));
+ gr::block_sptr src = gr::blocks::null_source::make(sizeof(int));
+ gr::block_sptr head = gr::blocks::head::make(sizeof(int), 100000);
+ gr::block_sptr dst = gr::blocks::null_sink::make(sizeof(int));
- head->set_max_output_buffer(1024);
+ head->set_max_output_buffer(1024);
- // Start infinite flowgraph
- tb->connect(src, 0, head, 0);
- tb->connect(head, 0, dst, 0);
- tb->start();
- tb->wait();
+ // Start infinite flowgraph
+ tb->connect(src, 0, head, 0);
+ tb->connect(head, 0, dst, 0);
+ tb->start();
+ tb->wait();
}
BOOST_AUTO_TEST_CASE(t10_reconfig_max_output_buffer)
{
- if(VERBOSE)
- std::cout << "qa_top_block::t10()\n";
+ if (VERBOSE)
+ std::cout << "qa_top_block::t10()\n";
- gr::top_block_sptr tb = gr::make_top_block("top");
+ gr::top_block_sptr tb = gr::make_top_block("top");
- gr::block_sptr src = gr::blocks::null_source::make(sizeof(int));
- gr::block_sptr head = gr::blocks::head::make(sizeof(int), 100000);
- gr::block_sptr dst = gr::blocks::null_sink::make(sizeof(int));
+ gr::block_sptr src = gr::blocks::null_source::make(sizeof(int));
+ gr::block_sptr head = gr::blocks::head::make(sizeof(int), 100000);
+ gr::block_sptr dst = gr::blocks::null_sink::make(sizeof(int));
- head->set_max_output_buffer(1000);
+ head->set_max_output_buffer(1000);
- // Start infinite flowgraph
- tb->connect(src, 0, dst, 0);
- tb->start(201);
+ // Start infinite flowgraph
+ tb->connect(src, 0, dst, 0);
+ tb->start(201);
- // Reconfigure with gr_head in the middle
- tb->lock();
- gr::block_sptr nop = gr::blocks::nop::make(sizeof(int));
- nop->set_max_output_buffer(4000);
- tb->disconnect(src, 0, dst, 0);
- tb->connect(src, 0, head, 0);
- tb->connect(head, 0, nop, 0);
- tb->connect(nop, 0, dst, 0);
- tb->unlock();
+ // Reconfigure with gr_head in the middle
+ tb->lock();
+ gr::block_sptr nop = gr::blocks::nop::make(sizeof(int));
+ nop->set_max_output_buffer(4000);
+ tb->disconnect(src, 0, dst, 0);
+ tb->connect(src, 0, head, 0);
+ tb->connect(head, 0, nop, 0);
+ tb->connect(nop, 0, dst, 0);
+ tb->unlock();
- // Wait for flowgraph to end on its own
- tb->wait();
+ // Wait for flowgraph to end on its own
+ tb->wait();
}
BOOST_AUTO_TEST_CASE(t11_set_block_affinity)
{
- gr::top_block_sptr tb = gr::make_top_block("top");
- gr::block_sptr src (gr::blocks::null_source::make(sizeof(float)));
- gr::block_sptr snk (gr::blocks::null_sink::make(sizeof(float)));
+ gr::top_block_sptr tb = gr::make_top_block("top");
+ gr::block_sptr src(gr::blocks::null_source::make(sizeof(float)));
+ gr::block_sptr snk(gr::blocks::null_sink::make(sizeof(float)));
- std::vector<int> set(1, 0), ret;
- src->set_processor_affinity(set);
+ std::vector<int> set(1, 0), ret;
+ src->set_processor_affinity(set);
- tb->connect(src, 0, snk, 0);
- tb->start();
- tb->stop();
- tb->wait();
+ tb->connect(src, 0, snk, 0);
+ tb->start();
+ tb->stop();
+ tb->wait();
- ret = src->processor_affinity();
+ ret = src->processor_affinity();
- // We only set the core affinity to 0 because we always know at
- // least one thread core exists to use.
- BOOST_CHECK_EQUAL(set[0], ret[0]);
+ // We only set the core affinity to 0 because we always know at
+ // least one thread core exists to use.
+ BOOST_CHECK_EQUAL(set[0], ret[0]);
}
diff --git a/gr-blocks/lib/qa_rotator.cc b/gr-blocks/lib/qa_rotator.cc
index a39a2bd0fa..7a1426b4b9 100644
--- a/gr-blocks/lib/qa_rotator.cc
+++ b/gr-blocks/lib/qa_rotator.cc
@@ -33,73 +33,72 @@
#include <cmath>
// error vector magnitude
-__GR_ATTR_UNUSED static float
-error_vector_mag(gr_complex a, gr_complex b)
+__GR_ATTR_UNUSED static float error_vector_mag(gr_complex a, gr_complex b)
{
- return abs(a-b);
+ return abs(a - b);
}
BOOST_AUTO_TEST_CASE(t1)
{
- static const unsigned int N = 100000;
+ static const unsigned int N = 100000;
- gr::blocks::rotator r;
+ gr::blocks::rotator r;
- double phase_incr = 2*GR_M_PI / 1003;
- double phase = 0;
+ double phase_incr = 2 * GR_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)));
+ // 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));
+ 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));
+ for (unsigned i = 0; i < N; i++) {
+ gr_complex expected = gr_expj(phase);
+ gr_complex actual = r.rotate(gr_complex(1, 0));
- BOOST_CHECK(std::abs(expected - actual) <= 0.0001);
+ BOOST_CHECK(std::abs(expected - actual) <= 0.0001);
- phase += phase_incr;
- if(phase >= 2*GR_M_PI)
- phase -= 2*GR_M_PI;
- }
+ phase += phase_incr;
+ if (phase >= 2 * GR_M_PI)
+ phase -= 2 * GR_M_PI;
+ }
}
BOOST_AUTO_TEST_CASE(t2)
{
- static const unsigned int N = 100000;
+ static const unsigned int N = 100000;
- gr::blocks::rotator r;
- gr_complex *input = new gr_complex[N];
- gr_complex *output = new gr_complex[N];
+ gr::blocks::rotator r;
+ gr_complex* input = new gr_complex[N];
+ gr_complex* output = new gr_complex[N];
- double phase_incr = 2*GR_M_PI / 1003;
- double phase = 0;
+ double phase_incr = 2 * GR_M_PI / 1003;
+ double phase = 0;
- r.set_phase(gr_complex(1,0));
- r.set_phase_incr(gr_expj(phase_incr));
+ r.set_phase(gr_complex(1, 0));
+ r.set_phase_incr(gr_expj(phase_incr));
- // Generate a unity sequence
- for(unsigned i = 0; i < N; i++)
- input[i] = gr_complex(1.0f, 0.0f);
+ // Generate a unity sequence
+ for (unsigned i = 0; i < N; i++)
+ input[i] = gr_complex(1.0f, 0.0f);
- // Rotate it
- r.rotateN(output, input, N);
+ // Rotate it
+ r.rotateN(output, input, N);
- // Compare with expected result
- for(unsigned i = 0; i < N; i++) {
- gr_complex expected = gr_expj(phase);
- gr_complex actual = output[i];
+ // Compare with expected result
+ for (unsigned i = 0; i < N; i++) {
+ gr_complex expected = gr_expj(phase);
+ gr_complex actual = output[i];
- BOOST_CHECK(std::abs(expected - actual) <= 0.0001);
+ BOOST_CHECK(std::abs(expected - actual) <= 0.0001);
- phase += phase_incr;
- if(phase >= 2*GR_M_PI)
- phase -= 2*GR_M_PI;
- }
+ phase += phase_incr;
+ if (phase >= 2 * GR_M_PI)
+ phase -= 2 * GR_M_PI;
+ }
- delete[] output;
- delete[] input;
+ delete[] output;
+ delete[] input;
}
diff --git a/gr-blocks/lib/qa_set_msg_handler.cc b/gr-blocks/lib/qa_set_msg_handler.cc
index 94bd6e4249..368643bfa7 100644
--- a/gr-blocks/lib/qa_set_msg_handler.cc
+++ b/gr-blocks/lib/qa_set_msg_handler.cc
@@ -41,31 +41,31 @@
*/
BOOST_AUTO_TEST_CASE(t0)
{
- static const int NMSGS = 10;
+ static const int NMSGS = 10;
- gr::top_block_sptr tb = gr::make_top_block("top");
- gr::block_sptr src = gr::blocks::null_source::make(sizeof(int));
- gr::blocks::nop::sptr nop = gr::blocks::nop::make(sizeof(int));
- gr::block_sptr dst = gr::blocks::null_sink::make(sizeof(int));
+ gr::top_block_sptr tb = gr::make_top_block("top");
+ gr::block_sptr src = gr::blocks::null_source::make(sizeof(int));
+ gr::blocks::nop::sptr nop = gr::blocks::nop::make(sizeof(int));
+ gr::block_sptr dst = gr::blocks::null_sink::make(sizeof(int));
- tb->connect(src, 0, nop, 0);
- tb->connect(nop, 0, dst, 0);
+ tb->connect(src, 0, nop, 0);
+ tb->connect(nop, 0, dst, 0);
- // Must start graph before sending messages
- tb->start();
+ // Must start graph before sending messages
+ tb->start();
- // Send them...
- pmt::pmt_t port(pmt::intern("port"));
- for (int i = 0; i < NMSGS; i++){
- send(nop, port, pmt::mp(pmt::mp("example-msg"), pmt::mp(i)));
- }
+ // Send them...
+ pmt::pmt_t port(pmt::intern("port"));
+ for (int i = 0; i < NMSGS; i++) {
+ send(nop, port, pmt::mp(pmt::mp("example-msg"), pmt::mp(i)));
+ }
- // Give the messages a chance to be processed
- boost::this_thread::sleep(boost::posix_time::milliseconds(100));
+ // Give the messages a chance to be processed
+ boost::this_thread::sleep(boost::posix_time::milliseconds(100));
- tb->stop();
- tb->wait();
+ tb->stop();
+ tb->wait();
- // Confirm that the nop block received the right number of messages.
- BOOST_CHECK_EQUAL(NMSGS, nop->nmsgs_received());
+ // Confirm that the nop block received the right number of messages.
+ BOOST_CHECK_EQUAL(NMSGS, nop->nmsgs_received());
}
diff --git a/gr-blocks/lib/random_pdu_impl.cc b/gr-blocks/lib/random_pdu_impl.cc
index 07e729810a..08078cc75b 100644
--- a/gr-blocks/lib/random_pdu_impl.cc
+++ b/gr-blocks/lib/random_pdu_impl.cc
@@ -29,59 +29,60 @@
#include <gnuradio/blocks/pdu.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- random_pdu::sptr
- random_pdu::make(int min_items, int max_items, unsigned char byte_mask, int length_modulo)
- {
- return gnuradio::get_initial_sptr(new random_pdu_impl(min_items, max_items, byte_mask, length_modulo));
- }
+random_pdu::sptr
+random_pdu::make(int min_items, int max_items, unsigned char byte_mask, int length_modulo)
+{
+ return gnuradio::get_initial_sptr(
+ new random_pdu_impl(min_items, max_items, byte_mask, length_modulo));
+}
- random_pdu_impl::random_pdu_impl(int min_items, int max_items, unsigned char byte_mask, int length_modulo)
- : block("random_pdu",
- io_signature::make (0, 0, 0),
- io_signature::make (0, 0, 0)),
- d_urange(min_items, max_items),
- d_brange(0, 255),
- d_rvar(d_rng, d_urange),
- d_bvar(d_rng, d_brange),
- d_mask(byte_mask),
- d_length_modulo(length_modulo)
- {
- message_port_register_out(pdu::pdu_port_id());
- message_port_register_in(pmt::mp("generate"));
- set_msg_handler(pmt::mp("generate"), boost::bind(&random_pdu_impl::generate_pdu, this, _1));
- if(length_modulo < 1)
+random_pdu_impl::random_pdu_impl(int min_items,
+ int max_items,
+ unsigned char byte_mask,
+ int length_modulo)
+ : block("random_pdu", io_signature::make(0, 0, 0), io_signature::make(0, 0, 0)),
+ d_urange(min_items, max_items),
+ d_brange(0, 255),
+ d_rvar(d_rng, d_urange),
+ d_bvar(d_rng, d_brange),
+ d_mask(byte_mask),
+ d_length_modulo(length_modulo)
+{
+ message_port_register_out(pdu::pdu_port_id());
+ message_port_register_in(pmt::mp("generate"));
+ set_msg_handler(pmt::mp("generate"),
+ boost::bind(&random_pdu_impl::generate_pdu, this, _1));
+ if (length_modulo < 1)
throw std::runtime_error("length_module must be >= 1");
- if(max_items < length_modulo)
+ if (max_items < length_modulo)
throw std::runtime_error("max_items must be >= to length_modulo");
- }
+}
- bool
- random_pdu_impl::start()
- {
- output_random();
- return true;
- }
+bool random_pdu_impl::start()
+{
+ output_random();
+ return true;
+}
- void
- random_pdu_impl::output_random()
- {
- // pick a random vector length
- int len = d_rvar();
- len = std::max(d_length_modulo, len - len%d_length_modulo);
+void random_pdu_impl::output_random()
+{
+ // pick a random vector length
+ int len = d_rvar();
+ len = std::max(d_length_modulo, len - len % d_length_modulo);
- // fill it with random bytes
- std::vector<unsigned char> vec(len);
- for (int i=0; i<len; i++)
- vec[i] = ((unsigned char) d_bvar()) & d_mask;
+ // fill it with random bytes
+ std::vector<unsigned char> vec(len);
+ for (int i = 0; i < len; i++)
+ vec[i] = ((unsigned char)d_bvar()) & d_mask;
- // send the vector
- pmt::pmt_t vecpmt(pmt::make_blob(&vec[0], len));
- pmt::pmt_t pdu(pmt::cons(pmt::PMT_NIL, vecpmt));
+ // send the vector
+ pmt::pmt_t vecpmt(pmt::make_blob(&vec[0], len));
+ pmt::pmt_t pdu(pmt::cons(pmt::PMT_NIL, vecpmt));
- message_port_pub(pdu::pdu_port_id(), pdu);
- }
+ message_port_pub(pdu::pdu_port_id(), pdu);
+}
- } /* namespace blocks */
-}/* namespace gr */
+} /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/random_pdu_impl.h b/gr-blocks/lib/random_pdu_impl.h
index b5438cb3cd..ecb8ec770d 100644
--- a/gr-blocks/lib/random_pdu_impl.h
+++ b/gr-blocks/lib/random_pdu_impl.h
@@ -28,29 +28,32 @@
#include <boost/generator_iterator.hpp>
namespace gr {
- namespace blocks {
-
- class random_pdu_impl : public random_pdu
- {
- private:
- boost::mt19937 d_rng;
- boost::uniform_int<> d_urange;
- boost::uniform_int<> d_brange;
- boost::variate_generator< boost::mt19937, boost::uniform_int<> > d_rvar; // pdu length
- boost::variate_generator< boost::mt19937, boost::uniform_int<> > d_bvar; // pdu contents
- unsigned char d_mask;
- int d_length_modulo;
-
- public:
- random_pdu_impl(int min_items, int max_items, unsigned char byte_mask, int length_modulo);
-
- bool start();
- void output_random();
- void generate_pdu(pmt::pmt_t msg) { output_random(); }
- void generate_pdu() { output_random(); }
- };
-
- } /* namespace blocks */
+namespace blocks {
+
+class random_pdu_impl : public random_pdu
+{
+private:
+ boost::mt19937 d_rng;
+ boost::uniform_int<> d_urange;
+ boost::uniform_int<> d_brange;
+ boost::variate_generator<boost::mt19937, boost::uniform_int<>> d_rvar; // pdu length
+ boost::variate_generator<boost::mt19937, boost::uniform_int<>> d_bvar; // pdu contents
+ unsigned char d_mask;
+ int d_length_modulo;
+
+public:
+ random_pdu_impl(int min_items,
+ int max_items,
+ unsigned char byte_mask,
+ int length_modulo);
+
+ bool start();
+ void output_random();
+ void generate_pdu(pmt::pmt_t msg) { output_random(); }
+ void generate_pdu() { output_random(); }
+};
+
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_BLOCKS_RANDOM_PDU_IMPL_H */
diff --git a/gr-blocks/lib/regenerate_bb_impl.cc b/gr-blocks/lib/regenerate_bb_impl.cc
index 1e2427d4ad..51806471da 100644
--- a/gr-blocks/lib/regenerate_bb_impl.cc
+++ b/gr-blocks/lib/regenerate_bb_impl.cc
@@ -28,76 +28,68 @@
#include <gnuradio/io_signature.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- regenerate_bb::sptr
- regenerate_bb::make(int period, unsigned int max_regen)
- {
- return gnuradio::get_initial_sptr
- (new regenerate_bb_impl(period, max_regen));
- }
+regenerate_bb::sptr regenerate_bb::make(int period, unsigned int max_regen)
+{
+ return gnuradio::get_initial_sptr(new regenerate_bb_impl(period, max_regen));
+}
- regenerate_bb_impl::regenerate_bb_impl(int period, unsigned int max_regen)
- : sync_block("regenerate_bb",
- io_signature::make(1, 1, sizeof(char)),
- io_signature::make(1, 1, sizeof(char))),
- d_period(period),
- d_countdown(0),
- d_max_regen(max_regen),
- d_regen_count(max_regen)
- {
- }
+regenerate_bb_impl::regenerate_bb_impl(int period, unsigned int max_regen)
+ : sync_block("regenerate_bb",
+ io_signature::make(1, 1, sizeof(char)),
+ io_signature::make(1, 1, sizeof(char))),
+ d_period(period),
+ d_countdown(0),
+ d_max_regen(max_regen),
+ d_regen_count(max_regen)
+{
+}
- regenerate_bb_impl::~regenerate_bb_impl()
- {
- }
+regenerate_bb_impl::~regenerate_bb_impl() {}
- void
- regenerate_bb_impl::set_max_regen(unsigned int regen)
- {
- d_max_regen = regen;
- d_countdown = 0;
- d_regen_count = d_max_regen;
- }
+void regenerate_bb_impl::set_max_regen(unsigned int regen)
+{
+ d_max_regen = regen;
+ d_countdown = 0;
+ d_regen_count = d_max_regen;
+}
- void
- regenerate_bb_impl::set_period(int period)
- {
- d_period = period;
- d_countdown = 0;
- d_regen_count = d_max_regen;
- }
+void regenerate_bb_impl::set_period(int period)
+{
+ d_period = period;
+ d_countdown = 0;
+ d_regen_count = d_max_regen;
+}
- int
- regenerate_bb_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- const char *iptr = (const char *)input_items[0];
- char *optr = (char *)output_items[0];
+int regenerate_bb_impl::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ const char* iptr = (const char*)input_items[0];
+ char* optr = (char*)output_items[0];
- for(int i = 0; i < noutput_items; i++) {
+ for (int i = 0; i < noutput_items; i++) {
optr[i] = 0;
- if(d_regen_count < d_max_regen) {
- d_countdown--;
+ if (d_regen_count < d_max_regen) {
+ d_countdown--;
- if(d_countdown == 0) {
- optr[i] = 1;
- d_countdown = d_period;
- d_regen_count++;
- }
+ if (d_countdown == 0) {
+ optr[i] = 1;
+ d_countdown = d_period;
+ d_regen_count++;
+ }
}
- if(iptr[i] == 1) {
- d_countdown = d_period;
- optr[i] = 1;
- d_regen_count = 0;
+ if (iptr[i] == 1) {
+ d_countdown = d_period;
+ optr[i] = 1;
+ d_regen_count = 0;
}
-
- }
- return noutput_items;
}
+ return noutput_items;
+}
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/regenerate_bb_impl.h b/gr-blocks/lib/regenerate_bb_impl.h
index 5cb7f573e7..84b8b78f78 100644
--- a/gr-blocks/lib/regenerate_bb_impl.h
+++ b/gr-blocks/lib/regenerate_bb_impl.h
@@ -26,32 +26,32 @@
#include <gnuradio/blocks/regenerate_bb.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class regenerate_bb_impl : public regenerate_bb
- {
- private:
- int d_period;
- int d_countdown;
- unsigned int d_max_regen;
- unsigned int d_regen_count;
+class regenerate_bb_impl : public regenerate_bb
+{
+private:
+ int d_period;
+ int d_countdown;
+ unsigned int d_max_regen;
+ unsigned int d_regen_count;
- public:
- regenerate_bb_impl(int period, unsigned int max_regen=500);
- ~regenerate_bb_impl();
+public:
+ regenerate_bb_impl(int period, unsigned int max_regen = 500);
+ ~regenerate_bb_impl();
- void set_max_regen(unsigned int regen);
- void set_period(int period);
+ void set_max_regen(unsigned int regen);
+ void set_period(int period);
- unsigned int max_regen() const { return d_max_regen; };
- int period() const { return d_period; };
+ unsigned int max_regen() const { return d_max_regen; };
+ int period() const { return d_period; };
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_GR_REGENERATE_BB_IMPL_H */
diff --git a/gr-blocks/lib/repack_bits_bb_impl.cc b/gr-blocks/lib/repack_bits_bb_impl.cc
index a8185a95dc..240cac4a1f 100644
--- a/gr-blocks/lib/repack_bits_bb_impl.cc
+++ b/gr-blocks/lib/repack_bits_bb_impl.cc
@@ -28,149 +28,150 @@
#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, endianness_t endianness)
- {
- return gnuradio::get_initial_sptr
- (new repack_bits_bb_impl(k, l, len_tag_key,
- align_output, endianness));
+namespace blocks {
+
+repack_bits_bb::sptr repack_bits_bb::make(int k,
+ int l,
+ const std::string& len_tag_key,
+ bool align_output,
+ endianness_t endianness)
+{
+ return gnuradio::get_initial_sptr(
+ new repack_bits_bb_impl(k, l, len_tag_key, align_output, endianness));
+}
+
+repack_bits_bb_impl::repack_bits_bb_impl(int k,
+ int l,
+ const std::string& len_tag_key,
+ bool align_output,
+ endianness_t endianness)
+ : tagged_stream_block("repack_bits_bb",
+ io_signature::make(1, 1, sizeof(char)),
+ io_signature::make(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),
+ d_endianness(endianness)
+{
+ 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]");
}
- repack_bits_bb_impl::repack_bits_bb_impl(int k, int l, const std::string &len_tag_key,
- bool align_output, endianness_t endianness)
- : tagged_stream_block("repack_bits_bb",
- io_signature::make(1, 1, sizeof(char)),
- io_signature::make(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),
- d_endianness(endianness)
- {
- 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((uint64_t) d_k, (uint64_t) d_l);
+ set_relative_rate((uint64_t)d_k, (uint64_t)d_l);
+}
+
+void repack_bits_bb_impl::set_k_and_l(int k, int l)
+{
+ gr::thread::scoped_lock guard(d_setlock);
+ d_k = k;
+ d_l = l;
+ set_relative_rate((uint64_t)d_k, (uint64_t)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++;
}
- void
- repack_bits_bb_impl::set_k_and_l(int k, int l)
- {
- gr::thread::scoped_lock guard(d_setlock);
- d_k = k;
- d_l = l;
- set_relative_rate((uint64_t) d_k, (uint64_t) 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;
+ 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)
+{
+ gr::thread::scoped_lock guard(d_setlock);
+ 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
- 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)
- {
- gr::thread::scoped_lock guard(d_setlock);
- 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;
- switch(d_endianness) {
- case GR_LSB_FIRST:
- 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;
- }
+ int n_read = 0;
+ int n_written = 0;
+ switch (d_endianness) {
+ case GR_LSB_FIRST:
+ 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);
+ if (d_packet_mode) {
+ if (d_out_index) {
+ n_written++;
+ d_out_index = 0;
+ }
+ } else {
+ consume_each(n_read);
}
break;
- case GR_MSB_FIRST:
- 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_k - 1 - d_in_index)) & 0x01) << (d_l - 1 - 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;
- }
+ case GR_MSB_FIRST:
+ 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_k - 1 - d_in_index)) & 0x01)
+ << (d_l - 1 - 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);
+ if (d_packet_mode) {
+ if (d_out_index) {
+ n_written++;
+ d_out_index = 0;
+ }
+ } else {
+ consume_each(n_read);
}
break;
- default:
+ default:
throw std::runtime_error("repack_bits_bb: unrecognized endianness value.");
- }
-
- return n_written;
}
- } /* namespace blocks */
+ 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
index 8dfb0600a6..39d0c06897 100644
--- a/gr-blocks/lib/repack_bits_bb_impl.h
+++ b/gr-blocks/lib/repack_bits_bb_impl.h
@@ -26,34 +26,40 @@
#include <gnuradio/blocks/repack_bits_bb.h>
namespace gr {
- namespace blocks {
-
- class repack_bits_bb_impl : public repack_bits_bb
- {
- private:
- int d_k; //! Bits on input stream
- 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
- endianness_t d_endianness;
-
- 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, endianness_t endianness=GR_LSB_FIRST);
- ~repack_bits_bb_impl();
- void set_k_and_l(int k, int l);//callback function for bits per input byte k and bits per output byte l
- 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 blocks {
+
+class repack_bits_bb_impl : public repack_bits_bb
+{
+private:
+ int d_k; //! Bits on input stream
+ 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
+ endianness_t d_endianness;
+
+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,
+ endianness_t endianness = GR_LSB_FIRST);
+ ~repack_bits_bb_impl();
+ void set_k_and_l(
+ int k,
+ int l); // callback function for bits per input byte k and bits per output byte l
+ 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/repeat_impl.cc b/gr-blocks/lib/repeat_impl.cc
index fb62265134..189fbc8948 100644
--- a/gr-blocks/lib/repeat_impl.cc
+++ b/gr-blocks/lib/repeat_impl.cc
@@ -28,62 +28,59 @@
#include <gnuradio/io_signature.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- repeat::sptr repeat::make(size_t itemsize, int interp)
- {
- return gnuradio::get_initial_sptr(new repeat_impl(itemsize, interp));
- }
-
- repeat_impl::repeat_impl(size_t itemsize, int interp)
- : sync_interpolator("repeat",
- io_signature::make (1, 1, itemsize),
- io_signature::make (1, 1, itemsize),
- interp),
- d_itemsize(itemsize),
- d_interp(interp)
- {
- message_port_register_in(pmt::mp("interpolation"));
- set_msg_handler(pmt::mp("interpolation"),
- boost::bind(&repeat_impl::msg_set_interpolation, this, _1));
- }
+repeat::sptr repeat::make(size_t itemsize, int interp)
+{
+ return gnuradio::get_initial_sptr(new repeat_impl(itemsize, interp));
+}
- void
- repeat_impl::msg_set_interpolation(pmt::pmt_t msg)
- {
- // Dynamization by Kevin McQuiggin:
- d_interp = pmt::to_long(pmt::cdr(msg));
- sync_interpolator::set_interpolation(d_interp);
- }
- void
- repeat_impl::set_interpolation(int interp)
- {
- // This ensures that interpolation is only changed between calls to work
- // (and not in the middle of an ongoing work)
- _post( pmt::mp("interpolation"), /* port */
- pmt::cons(pmt::mp("interpolation"), pmt::from_long(interp)) /* pair */
- );
- }
+repeat_impl::repeat_impl(size_t itemsize, int interp)
+ : sync_interpolator("repeat",
+ io_signature::make(1, 1, itemsize),
+ io_signature::make(1, 1, itemsize),
+ interp),
+ d_itemsize(itemsize),
+ d_interp(interp)
+{
+ message_port_register_in(pmt::mp("interpolation"));
+ set_msg_handler(pmt::mp("interpolation"),
+ boost::bind(&repeat_impl::msg_set_interpolation, this, _1));
+}
- int
- repeat_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];
+void repeat_impl::msg_set_interpolation(pmt::pmt_t msg)
+{
+ // Dynamization by Kevin McQuiggin:
+ d_interp = pmt::to_long(pmt::cdr(msg));
+ sync_interpolator::set_interpolation(d_interp);
+}
+void repeat_impl::set_interpolation(int interp)
+{
+ // This ensures that interpolation is only changed between calls to work
+ // (and not in the middle of an ongoing work)
+ _post(pmt::mp("interpolation"), /* port */
+ pmt::cons(pmt::mp("interpolation"), pmt::from_long(interp)) /* pair */
+ );
+}
- for (int i = 0; i < noutput_items/d_interp; i++) {
- for (int j = 0; j < d_interp; j++) {
- memcpy(out, in, d_itemsize);
- out += d_itemsize;
- }
+int repeat_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];
- in += d_itemsize;
- }
+ for (int i = 0; i < noutput_items / d_interp; i++) {
+ for (int j = 0; j < d_interp; j++) {
+ memcpy(out, in, d_itemsize);
+ out += d_itemsize;
+ }
- return noutput_items;
+ in += d_itemsize;
}
- } /* namespace blocks */
+ return noutput_items;
+}
+
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/repeat_impl.h b/gr-blocks/lib/repeat_impl.h
index 486a47a1ad..871b963e46 100644
--- a/gr-blocks/lib/repeat_impl.h
+++ b/gr-blocks/lib/repeat_impl.h
@@ -26,28 +26,29 @@
#include <gnuradio/blocks/repeat.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class BLOCKS_API repeat_impl : public repeat
- {
- size_t d_itemsize;
- int d_interp;
+class BLOCKS_API repeat_impl : public repeat
+{
+ size_t d_itemsize;
+ int d_interp;
- public:
- repeat_impl(size_t itemsize, int d_interp);
+public:
+ repeat_impl(size_t itemsize, int d_interp);
- int interpolation() const { return d_interp; }
- void set_interpolation(int interp);
+ int interpolation() const { return d_interp; }
+ void set_interpolation(int interp);
- int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
- private:
- void msg_set_interpolation(pmt::pmt_t msg);
- };
+ int work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items);
- } /* namespace blocks */
+private:
+ void msg_set_interpolation(pmt::pmt_t msg);
+};
+
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_REPEAT_IMPL_H */
diff --git a/gr-blocks/lib/rms_cf_impl.cc b/gr-blocks/lib/rms_cf_impl.cc
index 9ef243beba..11586a4ae2 100644
--- a/gr-blocks/lib/rms_cf_impl.cc
+++ b/gr-blocks/lib/rms_cf_impl.cc
@@ -29,51 +29,45 @@
#include <cmath>
namespace gr {
- namespace blocks {
+namespace blocks {
- rms_cf::sptr
- rms_cf::make(double alpha)
- {
- return gnuradio::get_initial_sptr
- (new rms_cf_impl(alpha));
- }
+rms_cf::sptr rms_cf::make(double alpha)
+{
+ return gnuradio::get_initial_sptr(new rms_cf_impl(alpha));
+}
- rms_cf_impl::rms_cf_impl(double alpha)
- : sync_block("rms_cf",
- io_signature::make(1, 1, sizeof(gr_complex)),
- io_signature::make(1, 1, sizeof(float)))
- {
- set_alpha(alpha);
- }
+rms_cf_impl::rms_cf_impl(double alpha)
+ : sync_block("rms_cf",
+ io_signature::make(1, 1, sizeof(gr_complex)),
+ io_signature::make(1, 1, sizeof(float)))
+{
+ set_alpha(alpha);
+}
- rms_cf_impl::~rms_cf_impl()
- {
- }
+rms_cf_impl::~rms_cf_impl() {}
- void
- rms_cf_impl::set_alpha(double alpha)
- {
- d_alpha = alpha;
- d_beta = 1 - d_alpha;
- d_avg = 0;
- }
+void rms_cf_impl::set_alpha(double alpha)
+{
+ d_alpha = alpha;
+ d_beta = 1 - d_alpha;
+ d_avg = 0;
+}
- int
- rms_cf_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- const gr_complex *in = (const gr_complex *)input_items[0];
- float *out = (float *)output_items[0];
+int rms_cf_impl::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ const gr_complex* in = (const gr_complex*)input_items[0];
+ float* out = (float*)output_items[0];
- for(int i = 0; i < noutput_items; i++) {
- double mag_sqrd = in[i].real()*in[i].real() + in[i].imag()*in[i].imag();
- d_avg = d_beta*d_avg + d_alpha*mag_sqrd;
+ for (int i = 0; i < noutput_items; i++) {
+ double mag_sqrd = in[i].real() * in[i].real() + in[i].imag() * in[i].imag();
+ d_avg = d_beta * d_avg + d_alpha * mag_sqrd;
out[i] = sqrt(d_avg);
- }
-
- return noutput_items;
}
- } /* namespace blocks */
+ return noutput_items;
+}
+
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/rms_cf_impl.h b/gr-blocks/lib/rms_cf_impl.h
index 75bc8f3524..84663cb121 100644
--- a/gr-blocks/lib/rms_cf_impl.h
+++ b/gr-blocks/lib/rms_cf_impl.h
@@ -26,30 +26,29 @@
#include <gnuradio/blocks/rms_cf.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- /*!
- * \brief RMS average power
- * \ingroup math_blk
- */
- class rms_cf_impl : public rms_cf
- {
- private:
- double d_alpha, d_beta, d_avg;
-
- public:
- rms_cf_impl(double alpha = 0.0001);
- ~rms_cf_impl();
+/*!
+ * \brief RMS average power
+ * \ingroup math_blk
+ */
+class rms_cf_impl : public rms_cf
+{
+private:
+ double d_alpha, d_beta, d_avg;
- void set_alpha(double alpha);
+public:
+ rms_cf_impl(double alpha = 0.0001);
+ ~rms_cf_impl();
- int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
+ void set_alpha(double alpha);
- };
+ int work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_BLOCKS_RMS_CF_IMPL_H */
diff --git a/gr-blocks/lib/rms_ff_impl.cc b/gr-blocks/lib/rms_ff_impl.cc
index c84193c9f3..ae758b2449 100644
--- a/gr-blocks/lib/rms_ff_impl.cc
+++ b/gr-blocks/lib/rms_ff_impl.cc
@@ -29,51 +29,45 @@
#include <cmath>
namespace gr {
- namespace blocks {
+namespace blocks {
- rms_ff::sptr
- rms_ff::make(double alpha)
- {
- return gnuradio::get_initial_sptr
- (new rms_ff_impl(alpha));
- }
+rms_ff::sptr rms_ff::make(double alpha)
+{
+ return gnuradio::get_initial_sptr(new rms_ff_impl(alpha));
+}
- rms_ff_impl::rms_ff_impl(double alpha)
- : sync_block("rms_ff",
- io_signature::make(1, 1, sizeof(float)),
- io_signature::make(1, 1, sizeof(float)))
- {
- set_alpha(alpha);
- }
+rms_ff_impl::rms_ff_impl(double alpha)
+ : sync_block("rms_ff",
+ io_signature::make(1, 1, sizeof(float)),
+ io_signature::make(1, 1, sizeof(float)))
+{
+ set_alpha(alpha);
+}
- rms_ff_impl::~rms_ff_impl()
- {
- }
+rms_ff_impl::~rms_ff_impl() {}
- void
- rms_ff_impl::set_alpha(double alpha)
- {
- d_alpha = alpha;
- d_beta = 1 - d_alpha;
- d_avg = 0;
- }
+void rms_ff_impl::set_alpha(double alpha)
+{
+ d_alpha = alpha;
+ d_beta = 1 - d_alpha;
+ d_avg = 0;
+}
- int
- rms_ff_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];
+int rms_ff_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];
- for(int i = 0; i < noutput_items; i++) {
- double mag_sqrd = in[i]*in[i];
- d_avg = d_beta*d_avg + d_alpha*mag_sqrd;
+ for (int i = 0; i < noutput_items; i++) {
+ double mag_sqrd = in[i] * in[i];
+ d_avg = d_beta * d_avg + d_alpha * mag_sqrd;
out[i] = sqrt(d_avg);
- }
-
- return noutput_items;
}
- } /* namespace blocks */
+ return noutput_items;
+}
+
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/rms_ff_impl.h b/gr-blocks/lib/rms_ff_impl.h
index 49ef1e07b3..a25fff6ecb 100644
--- a/gr-blocks/lib/rms_ff_impl.h
+++ b/gr-blocks/lib/rms_ff_impl.h
@@ -26,29 +26,29 @@
#include <gnuradio/blocks/rms_ff.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- /*!
- * \brief RMS average power
- * \ingroup math_blk
- */
- class rms_ff_impl : public rms_ff
- {
- private:
- double d_alpha, d_beta, d_avg;
+/*!
+ * \brief RMS average power
+ * \ingroup math_blk
+ */
+class rms_ff_impl : public rms_ff
+{
+private:
+ double d_alpha, d_beta, d_avg;
- public:
- rms_ff_impl(double alpha = 0.0001);
- ~rms_ff_impl();
+public:
+ rms_ff_impl(double alpha = 0.0001);
+ ~rms_ff_impl();
- void set_alpha(double alpha);
+ void set_alpha(double alpha);
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_BLOCKS_RMS_FF_IMPL_H */
diff --git a/gr-blocks/lib/rotator_cc_impl.cc b/gr-blocks/lib/rotator_cc_impl.cc
index 3760d09c2e..a58040ef11 100644
--- a/gr-blocks/lib/rotator_cc_impl.cc
+++ b/gr-blocks/lib/rotator_cc_impl.cc
@@ -30,50 +30,44 @@
#include <cmath>
namespace gr {
- namespace blocks {
+namespace blocks {
- rotator_cc::sptr
- rotator_cc::make(double phase_inc)
- {
- return gnuradio::get_initial_sptr
- (new rotator_cc_impl(phase_inc));
- }
+rotator_cc::sptr rotator_cc::make(double phase_inc)
+{
+ return gnuradio::get_initial_sptr(new rotator_cc_impl(phase_inc));
+}
- rotator_cc_impl::rotator_cc_impl(double phase_inc)
- : sync_block("rotator_cc",
- io_signature::make(1, 1, sizeof(gr_complex)),
- io_signature::make(1, 1, sizeof(gr_complex)))
- {
- set_phase_inc(phase_inc);
- }
+rotator_cc_impl::rotator_cc_impl(double phase_inc)
+ : sync_block("rotator_cc",
+ io_signature::make(1, 1, sizeof(gr_complex)),
+ io_signature::make(1, 1, sizeof(gr_complex)))
+{
+ set_phase_inc(phase_inc);
+}
- rotator_cc_impl::~rotator_cc_impl()
- {
- }
+rotator_cc_impl::~rotator_cc_impl() {}
- void
- rotator_cc_impl::set_phase_inc(double phase_inc)
- {
- d_r.set_phase_incr( exp(gr_complex(0, phase_inc)) );
- }
+void rotator_cc_impl::set_phase_inc(double phase_inc)
+{
+ d_r.set_phase_incr(exp(gr_complex(0, phase_inc)));
+}
- int
- rotator_cc_impl::work(int noutput_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 rotator_cc_impl::work(int noutput_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];
#if 0
for (int i=0; i<noutput_items; i++)
out[i] = d_r.rotate(in[i]);
#else
- d_r.rotateN(out, in, noutput_items);
+ d_r.rotateN(out, in, noutput_items);
#endif
- return noutput_items;
- }
+ return noutput_items;
+}
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/rotator_cc_impl.h b/gr-blocks/lib/rotator_cc_impl.h
index 105fd1c534..415b49cd49 100644
--- a/gr-blocks/lib/rotator_cc_impl.h
+++ b/gr-blocks/lib/rotator_cc_impl.h
@@ -27,30 +27,29 @@
#include <gnuradio/blocks/rotator.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- /*!
- * \brief Complex rotator
- * \ingroup math_blk
- */
- class rotator_cc_impl : public rotator_cc
- {
- private:
- rotator d_r;
-
- public:
- rotator_cc_impl(double phase_inc = 0.0);
- ~rotator_cc_impl();
+/*!
+ * \brief Complex rotator
+ * \ingroup math_blk
+ */
+class rotator_cc_impl : public rotator_cc
+{
+private:
+ rotator d_r;
- void set_phase_inc(double phase_inc);
+public:
+ rotator_cc_impl(double phase_inc = 0.0);
+ ~rotator_cc_impl();
- int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
+ void set_phase_inc(double phase_inc);
- };
+ int work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_BLOCKS_ROTATOR_CC_IMPL_H */
diff --git a/gr-blocks/lib/sample_and_hold_impl.cc b/gr-blocks/lib/sample_and_hold_impl.cc
index c5e25bca6c..1520593500 100644
--- a/gr-blocks/lib/sample_and_hold_impl.cc
+++ b/gr-blocks/lib/sample_and_hold_impl.cc
@@ -29,52 +29,49 @@
#include <gnuradio/io_signature.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- template <class T>
- typename sample_and_hold<T>::sptr
- sample_and_hold<T>::make()
- {
- return gnuradio::get_initial_sptr
- (new sample_and_hold_impl<T> ());
- }
+template <class T>
+typename sample_and_hold<T>::sptr sample_and_hold<T>::make()
+{
+ return gnuradio::get_initial_sptr(new sample_and_hold_impl<T>());
+}
- template <class T>
- sample_and_hold_impl<T> ::sample_and_hold_impl()
+template <class T>
+sample_and_hold_impl<T>::sample_and_hold_impl()
: sync_block("sample_and_hold",
- io_signature::make2(2, 2, sizeof(T), sizeof(char)),
- io_signature::make(1, 1, sizeof(T))),
+ io_signature::make2(2, 2, sizeof(T), sizeof(char)),
+ io_signature::make(1, 1, sizeof(T))),
d_data(0)
- {
- }
+{
+}
- template <class T>
- sample_and_hold_impl<T> ::~sample_and_hold_impl()
- {
- }
+template <class T>
+sample_and_hold_impl<T>::~sample_and_hold_impl()
+{
+}
- template <class T>
- int
- sample_and_hold_impl<T> ::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- T *iptr = (T *)input_items[0];
- const char *ctrl = (const char *)input_items[1];
- T *optr = (T *)output_items[0];
+template <class T>
+int sample_and_hold_impl<T>::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ T* iptr = (T*)input_items[0];
+ const char* ctrl = (const char*)input_items[1];
+ T* optr = (T*)output_items[0];
- for(int i = 0; i < noutput_items; i++) {
- if(ctrl[i]) {
- d_data = iptr[i];
+ for (int i = 0; i < noutput_items; i++) {
+ if (ctrl[i]) {
+ d_data = iptr[i];
}
optr[i] = d_data;
- }
- return noutput_items;
}
+ return noutput_items;
+}
template class sample_and_hold<std::uint8_t>;
template class sample_and_hold<std::int16_t>;
template class sample_and_hold<std::int32_t>;
template class sample_and_hold<float>;
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/sample_and_hold_impl.h b/gr-blocks/lib/sample_and_hold_impl.h
index f2ba032073..a264663422 100644
--- a/gr-blocks/lib/sample_and_hold_impl.h
+++ b/gr-blocks/lib/sample_and_hold_impl.h
@@ -27,24 +27,24 @@
#include <gnuradio/blocks/sample_and_hold.h>
namespace gr {
- namespace blocks {
+namespace blocks {
-template<class T>
- class sample_and_hold_impl : public sample_and_hold<T>
- {
- private:
- T d_data;
+template <class T>
+class sample_and_hold_impl : public sample_and_hold<T>
+{
+private:
+ T d_data;
- public:
- sample_and_hold_impl ();
- ~sample_and_hold_impl ();
+public:
+ sample_and_hold_impl();
+ ~sample_and_hold_impl();
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* SAMPLE_AND_HOLD_IMPL_H */
diff --git a/gr-blocks/lib/short_to_char_impl.cc b/gr-blocks/lib/short_to_char_impl.cc
index 5ef6f203d5..ffde32fd3a 100644
--- a/gr-blocks/lib/short_to_char_impl.cc
+++ b/gr-blocks/lib/short_to_char_impl.cc
@@ -29,36 +29,34 @@
#include <volk/volk.h>
namespace gr {
- namespace blocks {
-
- short_to_char::sptr short_to_char::make(size_t vlen)
- {
- return gnuradio::get_initial_sptr(new short_to_char_impl(vlen));
- }
-
- short_to_char_impl::short_to_char_impl(size_t vlen)
- : sync_block("short_to_char",
- io_signature::make (1, 1, sizeof(short)*vlen),
- io_signature::make (1, 1, sizeof(char)*vlen)),
- d_vlen(vlen)
- {
- const int alignment_multiple =
- volk_get_alignment() / sizeof(char);
- set_alignment(std::max(1, alignment_multiple));
- }
-
- int
- short_to_char_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- const int16_t *in = (const int16_t *) input_items[0];
- int8_t *out = (int8_t *) output_items[0];
-
- volk_16i_convert_8i(out, in, d_vlen*noutput_items);
-
- return noutput_items;
- }
-
- } /* namespace blocks */
-}/* namespace gr */
+namespace blocks {
+
+short_to_char::sptr short_to_char::make(size_t vlen)
+{
+ return gnuradio::get_initial_sptr(new short_to_char_impl(vlen));
+}
+
+short_to_char_impl::short_to_char_impl(size_t vlen)
+ : sync_block("short_to_char",
+ io_signature::make(1, 1, sizeof(short) * vlen),
+ io_signature::make(1, 1, sizeof(char) * vlen)),
+ d_vlen(vlen)
+{
+ const int alignment_multiple = volk_get_alignment() / sizeof(char);
+ set_alignment(std::max(1, alignment_multiple));
+}
+
+int short_to_char_impl::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ const int16_t* in = (const int16_t*)input_items[0];
+ int8_t* out = (int8_t*)output_items[0];
+
+ volk_16i_convert_8i(out, in, d_vlen * noutput_items);
+
+ return noutput_items;
+}
+
+} /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/short_to_char_impl.h b/gr-blocks/lib/short_to_char_impl.h
index 387b5b4cb3..9f5702006f 100644
--- a/gr-blocks/lib/short_to_char_impl.h
+++ b/gr-blocks/lib/short_to_char_impl.h
@@ -26,21 +26,21 @@
#include <gnuradio/blocks/short_to_char.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class BLOCKS_API short_to_char_impl : public short_to_char
- {
- size_t d_vlen;
+class BLOCKS_API short_to_char_impl : public short_to_char
+{
+ size_t d_vlen;
- public:
- short_to_char_impl(size_t vlen);
+public:
+ short_to_char_impl(size_t vlen);
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/short_to_float_impl.cc b/gr-blocks/lib/short_to_float_impl.cc
index 609cc7fdb6..7bce7ef907 100644
--- a/gr-blocks/lib/short_to_float_impl.cc
+++ b/gr-blocks/lib/short_to_float_impl.cc
@@ -29,36 +29,35 @@
#include <volk/volk.h>
namespace gr {
- namespace blocks {
-
- short_to_float::sptr short_to_float::make(size_t vlen, float scale)
- {
- return gnuradio::get_initial_sptr(new short_to_float_impl(vlen, scale));
- }
-
- short_to_float_impl::short_to_float_impl(size_t vlen, float scale)
- : sync_block("short_to_float",
- io_signature::make (1, 1, sizeof(short)*vlen),
- io_signature::make (1, 1, sizeof(float)*vlen)),
- d_vlen(vlen), d_scale(scale)
- {
- const int alignment_multiple =
- volk_get_alignment() / sizeof(float);
- set_alignment(std::max(1, alignment_multiple));
- }
-
- int
- short_to_float_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- const short *in = (const short *) input_items[0];
- float *out = (float *) output_items[0];
-
- volk_16i_s32f_convert_32f(out, in, d_scale, d_vlen*noutput_items);
-
- return noutput_items;
- }
-
- } /* namespace blocks */
-}/* namespace gr */
+namespace blocks {
+
+short_to_float::sptr short_to_float::make(size_t vlen, float scale)
+{
+ return gnuradio::get_initial_sptr(new short_to_float_impl(vlen, scale));
+}
+
+short_to_float_impl::short_to_float_impl(size_t vlen, float scale)
+ : sync_block("short_to_float",
+ io_signature::make(1, 1, sizeof(short) * vlen),
+ io_signature::make(1, 1, sizeof(float) * vlen)),
+ d_vlen(vlen),
+ d_scale(scale)
+{
+ const int alignment_multiple = volk_get_alignment() / sizeof(float);
+ set_alignment(std::max(1, alignment_multiple));
+}
+
+int short_to_float_impl::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ const short* in = (const short*)input_items[0];
+ float* out = (float*)output_items[0];
+
+ volk_16i_s32f_convert_32f(out, in, d_scale, d_vlen * noutput_items);
+
+ return noutput_items;
+}
+
+} /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/short_to_float_impl.h b/gr-blocks/lib/short_to_float_impl.h
index 7976b58a09..0ded27bc1d 100644
--- a/gr-blocks/lib/short_to_float_impl.h
+++ b/gr-blocks/lib/short_to_float_impl.h
@@ -26,25 +26,25 @@
#include <gnuradio/blocks/short_to_float.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class BLOCKS_API short_to_float_impl : public short_to_float
- {
- size_t d_vlen;
- float d_scale;
+class BLOCKS_API short_to_float_impl : public short_to_float
+{
+ size_t d_vlen;
+ float d_scale;
- public:
- short_to_float_impl(size_t vlen, float scale);
+public:
+ short_to_float_impl(size_t vlen, float scale);
- virtual float scale() const { return d_scale; }
- virtual void set_scale(float scale) { d_scale = scale; }
+ virtual float scale() const { return d_scale; }
+ virtual void set_scale(float scale) { d_scale = scale; }
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/skiphead_impl.cc b/gr-blocks/lib/skiphead_impl.cc
index 0a1685b732..ed6082c2d3 100644
--- a/gr-blocks/lib/skiphead_impl.cc
+++ b/gr-blocks/lib/skiphead_impl.cc
@@ -29,77 +29,74 @@
#include <string.h>
namespace gr {
- namespace blocks {
+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::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)
- : block("skiphead",
- io_signature::make(1, 1, itemsize),
- io_signature::make(1, 1, itemsize)),
- d_nitems_to_skip(nitems_to_skip), d_nitems(0)
- {
- // Reserve space for a few tags to avoid constant re-allocation
- // in the call to get_tags_in_window
- d_tags.reserve(8);
+skiphead_impl::skiphead_impl(size_t itemsize, uint64_t nitems_to_skip)
+ : block("skiphead",
+ io_signature::make(1, 1, itemsize),
+ io_signature::make(1, 1, itemsize)),
+ d_nitems_to_skip(nitems_to_skip),
+ d_nitems(0)
+{
+ // Reserve space for a few tags to avoid constant re-allocation
+ // in the call to get_tags_in_window
+ d_tags.reserve(8);
- // We'll handle propagating tags our selves to handle shifting offsets of tags
- set_tag_propagation_policy(TPP_DONT);
- }
+ // We'll handle propagating tags our selves to handle shifting offsets of tags
+ set_tag_propagation_policy(TPP_DONT);
+}
- skiphead_impl::~skiphead_impl()
- {
- }
+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 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
+ 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
+ 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;
+ 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
- // Grab all tags in the window and shift their offsets appropriately
- get_tags_in_window(d_tags, 0, ii, ninput_items);
- for(std::vector<tag_t>::iterator it = d_tags.begin(); it != d_tags.end(); it++) {
- (*it).offset -= d_nitems_to_skip;
- add_item_tag(0, *it);
- }
- 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);
- }
+ // Grab all tags in the window and shift their offsets appropriately
+ get_tags_in_window(d_tags, 0, ii, ninput_items);
+ for (std::vector<tag_t>::iterator it = d_tags.begin(); it != d_tags.end();
+ it++) {
+ (*it).offset -= d_nitems_to_skip;
+ add_item_tag(0, *it);
+ }
+ 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 n_to_copy;
}
- }
-
- d_nitems += ninput_items;
- consume_each(ninput_items);
- return 0;
}
- } /* namespace blocks */
+ 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
index 738fa86a61..e85873289a 100644
--- a/gr-blocks/lib/skiphead_impl.h
+++ b/gr-blocks/lib/skiphead_impl.h
@@ -26,26 +26,26 @@
#include <gnuradio/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
- std::vector<tag_t> d_tags;
-
- 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 blocks {
+
+class skiphead_impl : public skiphead
+{
+private:
+ uint64_t d_nitems_to_skip;
+ uint64_t d_nitems; // total items seen
+ std::vector<tag_t> d_tags;
+
+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
index 168d74ebb2..b3a96d350a 100644
--- a/gr-blocks/lib/socket_pdu_impl.cc
+++ b/gr-blocks/lib/socket_pdu_impl.cc
@@ -30,65 +30,79 @@
#include <gnuradio/blocks/pdu.h>
namespace gr {
- namespace blocks {
-
- socket_pdu::sptr
- socket_pdu::make(std::string type, std::string addr, std::string port, int MTU/*= 10000*/, bool tcp_no_delay/*= false*/)
- {
- return gnuradio::get_initial_sptr(new socket_pdu_impl(type, addr, port, MTU, tcp_no_delay));
- }
-
- socket_pdu_impl::socket_pdu_impl(std::string type, std::string addr, std::string port, int MTU/*= 10000*/, bool tcp_no_delay/*= false*/)
- : block("socket_pdu",
- io_signature::make (0, 0, 0),
- io_signature::make (0, 0, 0)),
+namespace blocks {
+
+socket_pdu::sptr socket_pdu::make(std::string type,
+ std::string addr,
+ std::string port,
+ int MTU /*= 10000*/,
+ bool tcp_no_delay /*= false*/)
+{
+ return gnuradio::get_initial_sptr(
+ new socket_pdu_impl(type, addr, port, MTU, tcp_no_delay));
+}
+
+socket_pdu_impl::socket_pdu_impl(std::string type,
+ std::string addr,
+ std::string port,
+ int MTU /*= 10000*/,
+ bool tcp_no_delay /*= false*/)
+ : block("socket_pdu", io_signature::make(0, 0, 0), io_signature::make(0, 0, 0)),
d_tcp_no_delay(tcp_no_delay)
- {
- d_rxbuf.resize(MTU);
+{
+ d_rxbuf.resize(MTU);
- message_port_register_in(pdu::pdu_port_id());
- message_port_register_out(pdu::pdu_port_id());
+ message_port_register_in(pdu::pdu_port_id());
+ message_port_register_out(pdu::pdu_port_id());
- if ((type == "TCP_SERVER") && ((addr.empty()) || (addr == "0.0.0.0"))) { // Bind on all interfaces
+ if ((type == "TCP_SERVER") &&
+ ((addr.empty()) || (addr == "0.0.0.0"))) { // Bind on all interfaces
int port_num = atoi(port.c_str());
if (port_num == 0)
- throw std::invalid_argument("gr::blocks:socket_pdu: invalid port for TCP_SERVER");
- d_tcp_endpoint = boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), port_num);
- }
- else if ((type == "TCP_SERVER") || (type == "TCP_CLIENT")) {
+ throw std::invalid_argument(
+ "gr::blocks:socket_pdu: invalid port for TCP_SERVER");
+ d_tcp_endpoint =
+ boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), port_num);
+ } else 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,
- boost::asio::ip::resolver_query_base::passive);
+ boost::asio::ip::tcp::resolver::query query(
+ boost::asio::ip::tcp::v4(),
+ addr,
+ port,
+ boost::asio::ip::resolver_query_base::passive);
d_tcp_endpoint = *resolver.resolve(query);
- }
- else if ((type == "UDP_SERVER") && ((addr.empty()) || (addr == "0.0.0.0"))) { // Bind on all interfaces
+ } else if ((type == "UDP_SERVER") &&
+ ((addr.empty()) || (addr == "0.0.0.0"))) { // Bind on all interfaces
int port_num = atoi(port.c_str());
if (port_num == 0)
- throw std::invalid_argument("gr::blocks:socket_pdu: invalid port for UDP_SERVER");
- d_udp_endpoint = boost::asio::ip::udp::endpoint(boost::asio::ip::udp::v4(), port_num);
- }
- else if ((type == "UDP_SERVER") || (type == "UDP_CLIENT")) {
+ throw std::invalid_argument(
+ "gr::blocks:socket_pdu: invalid port for UDP_SERVER");
+ d_udp_endpoint =
+ boost::asio::ip::udp::endpoint(boost::asio::ip::udp::v4(), port_num);
+ } else 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,
- boost::asio::ip::resolver_query_base::passive);
+ boost::asio::ip::udp::resolver::query query(
+ boost::asio::ip::udp::v4(),
+ addr,
+ port,
+ boost::asio::ip::resolver_query_base::passive);
if (type == "UDP_SERVER")
- d_udp_endpoint = *resolver.resolve(query);
+ d_udp_endpoint = *resolver.resolve(query);
else
- d_udp_endpoint_other = *resolver.resolve(query);
- }
+ 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));
+ 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::pdu_port_id(), boost::bind(&socket_pdu_impl::tcp_server_send, this, _1));
- }
- else if (type =="TCP_CLIENT") {
+ set_msg_handler(pdu::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);
@@ -96,163 +110,174 @@ namespace gr {
throw boost::system::system_error(error);
d_tcp_socket->set_option(boost::asio::ip::tcp::no_delay(d_tcp_no_delay));
- set_msg_handler(pdu::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::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::pdu_port_id(), boost::bind(&socket_pdu_impl::udp_send, this, _1));
- }
- else
+ set_msg_handler(pdu::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::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::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 = gr::thread::thread(boost::bind(&socket_pdu_impl::run_io_service, this));
- d_started = true;
- }
+ d_thread = gr::thread::thread(boost::bind(&socket_pdu_impl::run_io_service, this));
+ d_started = true;
+}
- socket_pdu_impl::~socket_pdu_impl()
- {
- stop();
- }
+socket_pdu_impl::~socket_pdu_impl() { stop(); }
- bool
- socket_pdu_impl::stop()
- {
- if (d_started) {
+bool socket_pdu_impl::stop()
+{
+ if (d_started) {
d_io_service.stop();
d_thread.interrupt();
d_thread.join();
- }
- d_started = false;
- return 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::init_u8vector(bytes_transferred, (const uint8_t *)&d_rxbuf[0]);
+ d_started = false;
+ return 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::init_u8vector(bytes_transferred, (const uint8_t*)&d_rxbuf[0]);
pmt::pmt_t pdu = pmt::cons(pmt::PMT_NIL, vector);
message_port_pub(pdu::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
+ 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()
- {
+void socket_pdu_impl::start_tcp_accept()
+{
#if (BOOST_VERSION >= 107000)
- tcp_connection::sptr new_connection = tcp_connection::make(d_io_service, d_rxbuf.size(), d_tcp_no_delay);
+ tcp_connection::sptr new_connection =
+ tcp_connection::make(d_io_service, d_rxbuf.size(), d_tcp_no_delay);
#else
- tcp_connection::sptr new_connection = tcp_connection::make(d_acceptor_tcp->get_io_service(), d_rxbuf.size(), d_tcp_no_delay);
+ tcp_connection::sptr new_connection = tcp_connection::make(
+ d_acceptor_tcp->get_io_service(), d_rxbuf.size(), d_tcp_no_delay);
#endif
- 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::cdr(msg);
- for(size_t i = 0; i < d_tcp_connections.size(); i++)
+ 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::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) {
+void socket_pdu_impl::handle_tcp_accept(tcp_connection::sptr new_connection,
+ const boost::system::error_code& error)
+{
+ if (!error) {
// Garbage collect closed sockets
std::vector<tcp_connection::sptr>::iterator it = d_tcp_connections.begin();
- while(it != d_tcp_connections.end()) {
- if (! (**it).socket().is_open())
- it = d_tcp_connections.erase(it);
- else
- ++it;
+ while (it != d_tcp_connections.end()) {
+ if (!(**it).socket().is_open())
+ it = d_tcp_connections.erase(it);
+ else
+ ++it;
}
new_connection->start(this);
d_tcp_connections.push_back(new_connection);
start_tcp_accept();
- }
- else
+ } else
std::cout << error << std::endl;
- }
-
- void
- socket_pdu_impl::tcp_client_send(pmt::pmt_t msg)
- {
- pmt::pmt_t vector = pmt::cdr(msg);
- size_t len = pmt::blob_length(vector);
- size_t offset = 0;
- std::vector<char> txbuf(std::min(len, d_rxbuf.size()));
- while (offset < len) {
+}
+
+void socket_pdu_impl::tcp_client_send(pmt::pmt_t msg)
+{
+ pmt::pmt_t vector = pmt::cdr(msg);
+ size_t len = pmt::blob_length(vector);
+ size_t offset = 0;
+ std::vector<char> txbuf(std::min(len, d_rxbuf.size()));
+ while (offset < len) {
size_t send_len = std::min((len - offset), txbuf.size());
memcpy(&txbuf[0], pmt::uniform_vector_elements(vector, offset), send_len);
offset += send_len;
d_tcp_socket->send(boost::asio::buffer(txbuf, send_len));
- }
}
+}
- void
- socket_pdu_impl::udp_send(pmt::pmt_t msg)
- {
- if (d_udp_endpoint_other.address().to_string() == "0.0.0.0")
+void socket_pdu_impl::udp_send(pmt::pmt_t msg)
+{
+ if (d_udp_endpoint_other.address().to_string() == "0.0.0.0")
return;
- pmt::pmt_t vector = pmt::cdr(msg);
- size_t len = pmt::blob_length(vector);
- size_t offset = 0;
- std::vector<char> txbuf(std::min(len, d_rxbuf.size()));
- while (offset < len) {
+ pmt::pmt_t vector = pmt::cdr(msg);
+ size_t len = pmt::blob_length(vector);
+ size_t offset = 0;
+ std::vector<char> txbuf(std::min(len, d_rxbuf.size()));
+ while (offset < len) {
size_t send_len = std::min((len - offset), txbuf.size());
memcpy(&txbuf[0], pmt::uniform_vector_elements(vector, offset), send_len);
offset += send_len;
d_udp_socket->send_to(boost::asio::buffer(txbuf, send_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::init_u8vector(bytes_transferred, (const uint8_t*)&d_rxbuf[0]);
+}
+
+void socket_pdu_impl::handle_udp_read(const boost::system::error_code& error,
+ size_t bytes_transferred)
+{
+ if (!error) {
+ pmt::pmt_t vector =
+ pmt::init_u8vector(bytes_transferred, (const uint8_t*)&d_rxbuf[0]);
pmt::pmt_t pdu = pmt::cons(pmt::PMT_NIL, vector);
message_port_pub(pdu::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));
- }
+ 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 */
+} /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/socket_pdu_impl.h b/gr-blocks/lib/socket_pdu_impl.h
index ad42996cd1..c05ef7bbc9 100644
--- a/gr-blocks/lib/socket_pdu_impl.h
+++ b/gr-blocks/lib/socket_pdu_impl.h
@@ -27,47 +27,54 @@
#include "tcp_connection.h"
namespace gr {
- namespace blocks {
+namespace blocks {
- class socket_pdu_impl : public socket_pdu
- {
- private:
- boost::asio::io_service d_io_service;
- std::vector<char> d_rxbuf;
- void run_io_service() { d_io_service.run(); }
- gr::thread::thread d_thread;
- bool d_started;
+class socket_pdu_impl : public socket_pdu
+{
+private:
+ boost::asio::io_service d_io_service;
+ std::vector<char> d_rxbuf;
+ void run_io_service() { d_io_service.run(); }
+ gr::thread::thread d_thread;
+ bool d_started;
- // 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);
- bool d_tcp_no_delay;
+ // 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);
+ bool d_tcp_no_delay;
- // 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 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);
+ // 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);
+ // 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 = 10000, bool tcp_no_delay = false);
- ~socket_pdu_impl();
- bool stop();
- };
+public:
+ socket_pdu_impl(std::string type,
+ std::string addr,
+ std::string port,
+ int MTU = 10000,
+ bool tcp_no_delay = false);
+ ~socket_pdu_impl();
+ bool stop();
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_BLOCKS_SOCKET_PDU_IMPL_H */
diff --git a/gr-blocks/lib/stream_mux_impl.cc b/gr-blocks/lib/stream_mux_impl.cc
index 4d5e71baca..000caf5454 100644
--- a/gr-blocks/lib/stream_mux_impl.cc
+++ b/gr-blocks/lib/stream_mux_impl.cc
@@ -30,94 +30,93 @@
#include <cstring>
namespace gr {
- namespace blocks {
+namespace blocks {
- stream_mux::sptr stream_mux::make(size_t itemsize, const std::vector<int> &lengths)
- {
- return gnuradio::get_initial_sptr(new stream_mux_impl(itemsize, lengths));
- }
+stream_mux::sptr stream_mux::make(size_t itemsize, const std::vector<int>& lengths)
+{
+ return gnuradio::get_initial_sptr(new stream_mux_impl(itemsize, lengths));
+}
- stream_mux_impl::stream_mux_impl(size_t itemsize, const std::vector<int> &lengths)
- : block("stream_mux",
- io_signature::make (1, -1, itemsize),
- io_signature::make (1, 1, itemsize)),
- d_itemsize(itemsize),
- d_stream(0),
- d_residual(0),
- d_lengths(lengths)
- {
- while (d_lengths[d_stream] == 0) {
+stream_mux_impl::stream_mux_impl(size_t itemsize, const std::vector<int>& lengths)
+ : block("stream_mux",
+ io_signature::make(1, -1, itemsize),
+ io_signature::make(1, 1, itemsize)),
+ d_itemsize(itemsize),
+ d_stream(0),
+ d_residual(0),
+ d_lengths(lengths)
+{
+ while (d_lengths[d_stream] == 0) {
d_stream++;
if (d_stream == d_lengths.size()) {
- throw std::invalid_argument("At least one size must be non-zero.");
+ throw std::invalid_argument("At least one size must be non-zero.");
}
- }
- d_residual = d_lengths[d_stream];
- set_tag_propagation_policy(TPP_DONT);
}
+ d_residual = d_lengths[d_stream];
+ set_tag_propagation_policy(TPP_DONT);
+}
- void
- stream_mux_impl::forecast(int noutput_items, gr_vector_int &ninput_items_required)
- {
- unsigned ninputs = ninput_items_required.size ();
- for (unsigned i = 0; i < ninputs; i++) {
- // Only active inputs *need* items, for the rest, it would just be nice
- ninput_items_required[i] = (d_stream == i ? 1 : 0);
- }
+void stream_mux_impl::forecast(int noutput_items, gr_vector_int& ninput_items_required)
+{
+ unsigned ninputs = ninput_items_required.size();
+ for (unsigned i = 0; i < ninputs; i++) {
+ // Only active inputs *need* items, for the rest, it would just be nice
+ ninput_items_required[i] = (d_stream == i ? 1 : 0);
}
+}
- int
- stream_mux_impl::general_work(int noutput_items,
- gr_vector_int &ninput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items
- ){
- char *out = (char *) output_items[0];
- const char *in;
- int out_index = 0; // Items written
- gr_vector_int input_index(d_lengths.size(), 0); // Items read
- std::vector<gr::tag_t> stream_t;
+int stream_mux_impl::general_work(int noutput_items,
+ gr_vector_int& ninput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ char* out = (char*)output_items[0];
+ const char* in;
+ int out_index = 0; // Items written
+ gr_vector_int input_index(d_lengths.size(), 0); // Items read
+ std::vector<gr::tag_t> stream_t;
- while (out_index < noutput_items) {
+ while (out_index < noutput_items) {
if (ninput_items[d_stream] <= input_index[d_stream]) {
- break;
+ break;
}
int space_left_in_buffers = std::min(
- noutput_items - out_index, // Space left in output buffer
- ninput_items[d_stream] - input_index[d_stream] // Space left in input buffer
- );
- int items_to_copy = std::min(
- space_left_in_buffers,
- d_residual
+ noutput_items - out_index, // Space left in output buffer
+ ninput_items[d_stream] - input_index[d_stream] // Space left in input buffer
);
- in = (const char *) input_items[d_stream] + input_index[d_stream]*d_itemsize;
- memcpy(&out[out_index*d_itemsize], in, items_to_copy*d_itemsize);
- get_tags_in_window(stream_t, d_stream,input_index[d_stream],input_index[d_stream] + items_to_copy);
- BOOST_FOREACH(gr::tag_t t, stream_t){
- t.offset = t.offset - nitems_read(d_stream) - input_index[d_stream] + nitems_written(0) + out_index;
- add_item_tag(0, t);
+ int items_to_copy = std::min(space_left_in_buffers, d_residual);
+ in = (const char*)input_items[d_stream] + input_index[d_stream] * d_itemsize;
+ memcpy(&out[out_index * d_itemsize], in, items_to_copy * d_itemsize);
+ get_tags_in_window(stream_t,
+ d_stream,
+ input_index[d_stream],
+ input_index[d_stream] + items_to_copy);
+ BOOST_FOREACH (gr::tag_t t, stream_t) {
+ t.offset = t.offset - nitems_read(d_stream) - input_index[d_stream] +
+ nitems_written(0) + out_index;
+ add_item_tag(0, t);
}
-
+
out_index += items_to_copy;
input_index[d_stream] += items_to_copy;
d_residual -= items_to_copy;
if (d_residual == 0) {
- do { // Skip all those inputs with zero length
- d_stream = (d_stream+1) % d_lengths.size();
- } while (d_lengths[d_stream] == 0);
- d_residual = d_lengths[d_stream];
+ do { // Skip all those inputs with zero length
+ d_stream = (d_stream + 1) % d_lengths.size();
+ } while (d_lengths[d_stream] == 0);
+ d_residual = d_lengths[d_stream];
} else {
- break;
+ break;
}
- } // while
+ } // while
- for (size_t i = 0; i < input_index.size(); i++) {
- consume((int) i, input_index[i]);
- }
+ for (size_t i = 0; i < input_index.size(); i++) {
+ consume((int)i, input_index[i]);
+ }
- return out_index;
- } /* work */
+ return out_index;
+} /* work */
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/stream_mux_impl.h b/gr-blocks/lib/stream_mux_impl.h
index 67be9381af..3805790373 100644
--- a/gr-blocks/lib/stream_mux_impl.h
+++ b/gr-blocks/lib/stream_mux_impl.h
@@ -26,28 +26,28 @@
#include <gnuradio/blocks/stream_mux.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class BLOCKS_API stream_mux_impl : public stream_mux
- {
- private:
- size_t d_itemsize;
- unsigned int d_stream; // index of currently selected stream
- int d_residual; // number if items left to put into current stream
- gr_vector_int d_lengths; // number if items to pack per stream
+class BLOCKS_API stream_mux_impl : public stream_mux
+{
+private:
+ size_t d_itemsize;
+ unsigned int d_stream; // index of currently selected stream
+ int d_residual; // number if items left to put into current stream
+ gr_vector_int d_lengths; // number if items to pack per stream
- void forecast(int noutput_items, gr_vector_int &ninput_items_required);
+ void forecast(int noutput_items, gr_vector_int& ninput_items_required);
- public:
- stream_mux_impl(size_t itemsize, const std::vector<int> &lengths);
+public:
+ stream_mux_impl(size_t itemsize, const std::vector<int>& lengths);
- int general_work(int noutput_items,
- gr_vector_int &ninput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
- };
+ 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 blocks */
} /* namespace gr */
#endif /* INCLUDED_STREAM_MUX_IMPL_H */
diff --git a/gr-blocks/lib/stream_pdu_base.cc b/gr-blocks/lib/stream_pdu_base.cc
index a698f85d55..1cbcb0485c 100644
--- a/gr-blocks/lib/stream_pdu_base.cc
+++ b/gr-blocks/lib/stream_pdu_base.cc
@@ -37,94 +37,85 @@
#include "stream_pdu_base.h"
#include <boost/format.hpp>
-static const long timeout_us = 100*1000; //100ms
+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);
- }
+namespace blocks {
- stream_pdu_base::~stream_pdu_base()
- {
- stop_rxthread();
- }
+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);
+}
- void
- stream_pdu_base::start_rxthread(basic_block *blk, pmt::pmt_t port)
- {
- d_blk = blk;
- d_port = port;
- d_thread = gr::thread::thread(boost::bind(&stream_pdu_base::run, this));
- d_started = true;
- }
+stream_pdu_base::~stream_pdu_base() { stop_rxthread(); }
+
+void stream_pdu_base::start_rxthread(basic_block* blk, pmt::pmt_t port)
+{
+ d_blk = blk;
+ d_port = port;
+ d_thread = gr::thread::thread(boost::bind(&stream_pdu_base::run, this));
+ d_started = true;
+}
- void
- stream_pdu_base::stop_rxthread()
- {
- d_finished = true;
+void stream_pdu_base::stop_rxthread()
+{
+ d_finished = true;
- if (d_started) {
+ if (d_started) {
d_thread.interrupt();
d_thread.join();
- }
}
+}
- void
- stream_pdu_base::run()
- {
- while(!d_finished) {
+void stream_pdu_base::run()
+{
+ while (!d_finished) {
if (!wait_ready())
- continue;
+ 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!");
+ throw std::runtime_error("stream_pdu_base, bad socket read!");
pmt::pmt_t vector = pmt::init_u8vector(result, &d_rxbuf[0]);
pmt::pmt_t pdu = 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::cdr(msg);
- size_t offset(0);
- size_t itemsize(pdu::itemsize(pdu::type_from_pmt(vector)));
- int len(pmt::length(vector)*itemsize);
-
- const int rv = write(d_fd, 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;
- }
+}
+
+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::cdr(msg);
+ size_t offset(0);
+ size_t itemsize(pdu::itemsize(pdu::type_from_pmt(vector)));
+ int len(pmt::length(vector) * itemsize);
+
+ const int rv = write(d_fd, 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 blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/stream_pdu_base.h b/gr-blocks/lib/stream_pdu_base.h
index e15aec1787..cc3394d6f0 100644
--- a/gr-blocks/lib/stream_pdu_base.h
+++ b/gr-blocks/lib/stream_pdu_base.h
@@ -30,32 +30,32 @@
class 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;
- gr::thread::thread d_thread;
-
- pmt::pmt_t d_port;
- basic_block *d_blk;
-
- void run();
- void send(pmt::pmt_t msg);
- bool wait_ready();
- void start_rxthread(basic_block *blk, pmt::pmt_t rxport);
- void stop_rxthread();
- };
-
- } /* namespace blocks */
+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;
+ gr::thread::thread d_thread;
+
+ pmt::pmt_t d_port;
+ basic_block* d_blk;
+
+ void run();
+ void send(pmt::pmt_t msg);
+ bool wait_ready();
+ void start_rxthread(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/stream_to_streams_impl.cc b/gr-blocks/lib/stream_to_streams_impl.cc
index 2832a21563..a25786b5b3 100644
--- a/gr-blocks/lib/stream_to_streams_impl.cc
+++ b/gr-blocks/lib/stream_to_streams_impl.cc
@@ -29,44 +29,41 @@
#include <string.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- stream_to_streams::sptr
- stream_to_streams::make(size_t itemsize, size_t nstreams)
- {
- return gnuradio::get_initial_sptr
- (new stream_to_streams_impl(itemsize, nstreams));
- }
-
- stream_to_streams_impl::stream_to_streams_impl(size_t itemsize, size_t nstreams)
- : sync_decimator("stream_to_streams",
- io_signature::make(1, 1, itemsize),
- io_signature::make(nstreams, nstreams, itemsize),
- nstreams)
- {
- }
+stream_to_streams::sptr stream_to_streams::make(size_t itemsize, size_t nstreams)
+{
+ return gnuradio::get_initial_sptr(new stream_to_streams_impl(itemsize, nstreams));
+}
- int
- stream_to_streams_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- size_t item_size = output_signature()->sizeof_stream_item(0);
+stream_to_streams_impl::stream_to_streams_impl(size_t itemsize, size_t nstreams)
+ : sync_decimator("stream_to_streams",
+ io_signature::make(1, 1, itemsize),
+ io_signature::make(nstreams, nstreams, itemsize),
+ nstreams)
+{
+}
- const char *in = (const char *)input_items[0];
- char **outv = (char **)&output_items[0];
- int nstreams = output_items.size();
+int stream_to_streams_impl::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ size_t item_size = output_signature()->sizeof_stream_item(0);
- for (int i = 0; i < noutput_items; i++) {
- for (int j = 0; j < nstreams; j++) {
- memcpy(outv[j], in, item_size);
- outv[j] += item_size;
- in += item_size;
- }
- }
+ const char* in = (const char*)input_items[0];
+ char** outv = (char**)&output_items[0];
+ int nstreams = output_items.size();
- return noutput_items;
+ for (int i = 0; i < noutput_items; i++) {
+ for (int j = 0; j < nstreams; j++) {
+ memcpy(outv[j], in, item_size);
+ outv[j] += item_size;
+ in += item_size;
+ }
}
- } /* namespace blocks */
+ return noutput_items;
+}
+
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/stream_to_streams_impl.h b/gr-blocks/lib/stream_to_streams_impl.h
index bd3763572b..09057e18de 100644
--- a/gr-blocks/lib/stream_to_streams_impl.h
+++ b/gr-blocks/lib/stream_to_streams_impl.h
@@ -26,19 +26,19 @@
#include <gnuradio/blocks/stream_to_streams.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class BLOCKS_API stream_to_streams_impl : public stream_to_streams
- {
- public:
- stream_to_streams_impl(size_t itemsize, size_t nstreams);
+class BLOCKS_API stream_to_streams_impl : public stream_to_streams
+{
+public:
+ stream_to_streams_impl(size_t itemsize, size_t nstreams);
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_STREAM_TO_STREAMS_IMPL_H */
diff --git a/gr-blocks/lib/stream_to_tagged_stream_impl.cc b/gr-blocks/lib/stream_to_tagged_stream_impl.cc
index c38f09abaa..2873e98042 100644
--- a/gr-blocks/lib/stream_to_tagged_stream_impl.cc
+++ b/gr-blocks/lib/stream_to_tagged_stream_impl.cc
@@ -29,68 +29,68 @@
#include "stream_to_tagged_stream_impl.h"
namespace gr {
- namespace blocks {
+namespace blocks {
- stream_to_tagged_stream::sptr
- stream_to_tagged_stream::make(size_t itemsize, unsigned int vlen, unsigned packet_len, const std::string &len_tag_key)
- {
- return gnuradio::get_initial_sptr
- (new stream_to_tagged_stream_impl(itemsize, vlen, packet_len, len_tag_key));
- }
+stream_to_tagged_stream::sptr
+stream_to_tagged_stream::make(size_t itemsize,
+ unsigned int vlen,
+ unsigned packet_len,
+ const std::string& len_tag_key)
+{
+ return gnuradio::get_initial_sptr(
+ new stream_to_tagged_stream_impl(itemsize, vlen, packet_len, len_tag_key));
+}
- stream_to_tagged_stream_impl::stream_to_tagged_stream_impl(size_t itemsize, unsigned int vlen, unsigned packet_len, const std::string &len_tag_key)
- : gr::sync_block("stream_to_tagged_stream",
- gr::io_signature::make(1, 1, itemsize * vlen),
- gr::io_signature::make(1, 1, itemsize * vlen)),
+stream_to_tagged_stream_impl::stream_to_tagged_stream_impl(size_t itemsize,
+ unsigned int vlen,
+ unsigned packet_len,
+ const std::string& len_tag_key)
+ : gr::sync_block("stream_to_tagged_stream",
+ gr::io_signature::make(1, 1, itemsize * vlen),
+ gr::io_signature::make(1, 1, itemsize * vlen)),
d_itemsize(itemsize * vlen),
d_packet_len(packet_len),
d_packet_len_pmt(pmt::from_long(packet_len)),
d_len_tag_key(pmt::string_to_symbol(len_tag_key)),
d_next_tag_pos(0)
- {}
-
- stream_to_tagged_stream_impl::~stream_to_tagged_stream_impl()
- {
- }
+{
+}
- void
- stream_to_tagged_stream_impl::set_packet_len(unsigned packet_len)
- {
- gr::thread::scoped_lock guard(d_setlock);
- d_packet_len = packet_len;
- }
- void
- stream_to_tagged_stream_impl::set_packet_len_pmt(unsigned packet_len)
- {
- gr::thread::scoped_lock guard(d_setlock);
- d_packet_len_pmt=pmt::from_long(packet_len);
- }
- int
- stream_to_tagged_stream_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- gr::thread::scoped_lock guard(d_setlock);
- const unsigned char *in = (const unsigned char *) input_items[0];
- unsigned char *out = (unsigned char *) output_items[0];
- // Copy data
- memcpy(out, in, noutput_items * d_itemsize);
- // Add tags every d_packet_len
- while(d_next_tag_pos < nitems_written(0) + noutput_items) {
- add_item_tag(0, d_next_tag_pos, d_len_tag_key, d_packet_len_pmt);
- d_next_tag_pos += d_packet_len;
- }
+stream_to_tagged_stream_impl::~stream_to_tagged_stream_impl() {}
- return noutput_items;
+void stream_to_tagged_stream_impl::set_packet_len(unsigned packet_len)
+{
+ gr::thread::scoped_lock guard(d_setlock);
+ d_packet_len = packet_len;
+}
+void stream_to_tagged_stream_impl::set_packet_len_pmt(unsigned packet_len)
+{
+ gr::thread::scoped_lock guard(d_setlock);
+ d_packet_len_pmt = pmt::from_long(packet_len);
+}
+int stream_to_tagged_stream_impl::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ gr::thread::scoped_lock guard(d_setlock);
+ const unsigned char* in = (const unsigned char*)input_items[0];
+ unsigned char* out = (unsigned char*)output_items[0];
+ // Copy data
+ memcpy(out, in, noutput_items * d_itemsize);
+ // Add tags every d_packet_len
+ while (d_next_tag_pos < nitems_written(0) + noutput_items) {
+ add_item_tag(0, d_next_tag_pos, d_len_tag_key, d_packet_len_pmt);
+ d_next_tag_pos += d_packet_len;
}
- bool
- stream_to_tagged_stream_impl::start()
- {
- d_next_tag_pos = 0;
- return true;
- }
+ return noutput_items;
+}
- } /* namespace blocks */
-} /* namespace gr */
+bool stream_to_tagged_stream_impl::start()
+{
+ d_next_tag_pos = 0;
+ return true;
+}
+} /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/stream_to_tagged_stream_impl.h b/gr-blocks/lib/stream_to_tagged_stream_impl.h
index 82c920296f..111b8df601 100644
--- a/gr-blocks/lib/stream_to_tagged_stream_impl.h
+++ b/gr-blocks/lib/stream_to_tagged_stream_impl.h
@@ -26,32 +26,34 @@
#include <gnuradio/blocks/stream_to_tagged_stream.h>
namespace gr {
- namespace blocks {
-
- class stream_to_tagged_stream_impl : public stream_to_tagged_stream
- {
- private:
- size_t d_itemsize;
- unsigned d_packet_len;
- pmt::pmt_t d_packet_len_pmt;
- pmt::pmt_t d_len_tag_key;
- uint64_t d_next_tag_pos;
-
- public:
- stream_to_tagged_stream_impl(size_t itemsize, unsigned int vlen, unsigned packet_len, const std::string &tag_len_key);
- ~stream_to_tagged_stream_impl();
- void set_packet_len(unsigned packet_len);
- void set_packet_len_pmt(unsigned packet_len);
-
- int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
-
- bool start();
- };
-
- } // namespace blocks
+namespace blocks {
+
+class stream_to_tagged_stream_impl : public stream_to_tagged_stream
+{
+private:
+ size_t d_itemsize;
+ unsigned d_packet_len;
+ pmt::pmt_t d_packet_len_pmt;
+ pmt::pmt_t d_len_tag_key;
+ uint64_t d_next_tag_pos;
+
+public:
+ stream_to_tagged_stream_impl(size_t itemsize,
+ unsigned int vlen,
+ unsigned packet_len,
+ const std::string& tag_len_key);
+ ~stream_to_tagged_stream_impl();
+ void set_packet_len(unsigned packet_len);
+ void set_packet_len_pmt(unsigned packet_len);
+
+ int work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+
+ bool start();
+};
+
+} // namespace blocks
} // namespace gr
#endif /* INCLUDED_BLOCKS_STREAM_TO_TAGGED_STREAM_IMPL_H */
-
diff --git a/gr-blocks/lib/stream_to_vector_impl.cc b/gr-blocks/lib/stream_to_vector_impl.cc
index 60b330c246..bd518312a1 100644
--- a/gr-blocks/lib/stream_to_vector_impl.cc
+++ b/gr-blocks/lib/stream_to_vector_impl.cc
@@ -28,35 +28,35 @@
#include <gnuradio/io_signature.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- stream_to_vector::sptr stream_to_vector::make(size_t itemsize, size_t nitems_per_block)
- {
- return gnuradio::get_initial_sptr(new stream_to_vector_impl(itemsize, nitems_per_block));
- }
+stream_to_vector::sptr stream_to_vector::make(size_t itemsize, size_t nitems_per_block)
+{
+ return gnuradio::get_initial_sptr(
+ new stream_to_vector_impl(itemsize, nitems_per_block));
+}
- stream_to_vector_impl::stream_to_vector_impl(size_t itemsize, size_t nitems_per_block)
- : sync_decimator ("stream_to_vector",
- io_signature::make (1, 1, itemsize),
- io_signature::make (1, 1, itemsize * nitems_per_block),
- nitems_per_block)
- {
- }
+stream_to_vector_impl::stream_to_vector_impl(size_t itemsize, size_t nitems_per_block)
+ : sync_decimator("stream_to_vector",
+ io_signature::make(1, 1, itemsize),
+ io_signature::make(1, 1, itemsize * nitems_per_block),
+ nitems_per_block)
+{
+}
- int
- stream_to_vector_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- size_t block_size = output_signature()->sizeof_stream_item (0);
+int stream_to_vector_impl::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ size_t block_size = output_signature()->sizeof_stream_item(0);
- const char *in = (const char *) input_items[0];
- char *out = (char *) output_items[0];
+ const char* in = (const char*)input_items[0];
+ char* out = (char*)output_items[0];
- memcpy (out, in, noutput_items * block_size);
+ memcpy(out, in, noutput_items * block_size);
- return noutput_items;
- }
+ return noutput_items;
+}
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/stream_to_vector_impl.h b/gr-blocks/lib/stream_to_vector_impl.h
index 3484d397ed..ca79d2d0e3 100644
--- a/gr-blocks/lib/stream_to_vector_impl.h
+++ b/gr-blocks/lib/stream_to_vector_impl.h
@@ -26,19 +26,19 @@
#include <gnuradio/blocks/stream_to_vector.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class BLOCKS_API stream_to_vector_impl : public stream_to_vector
- {
- public:
- stream_to_vector_impl(size_t itemsize, size_t nitems_per_block);
+class BLOCKS_API stream_to_vector_impl : public stream_to_vector
+{
+public:
+ stream_to_vector_impl(size_t itemsize, size_t nitems_per_block);
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_STREAM_TO_VECTOR_IMPL_H */
diff --git a/gr-blocks/lib/streams_to_stream_impl.cc b/gr-blocks/lib/streams_to_stream_impl.cc
index cbd31c4b72..146c456f3e 100644
--- a/gr-blocks/lib/streams_to_stream_impl.cc
+++ b/gr-blocks/lib/streams_to_stream_impl.cc
@@ -28,45 +28,44 @@
#include <gnuradio/io_signature.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- streams_to_stream::sptr streams_to_stream::make(size_t itemsize, size_t nstreams)
- {
- return gnuradio::get_initial_sptr(new streams_to_stream_impl(itemsize, nstreams));
- }
-
- streams_to_stream_impl::streams_to_stream_impl(size_t itemsize, size_t nstreams)
- : sync_interpolator ("streams_to_stream",
- io_signature::make (nstreams, nstreams, itemsize),
- io_signature::make (1, 1, itemsize),
- nstreams)
- {
- }
+streams_to_stream::sptr streams_to_stream::make(size_t itemsize, size_t nstreams)
+{
+ return gnuradio::get_initial_sptr(new streams_to_stream_impl(itemsize, nstreams));
+}
- int
- streams_to_stream_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- size_t itemsize = output_signature()->sizeof_stream_item (0);
+streams_to_stream_impl::streams_to_stream_impl(size_t itemsize, size_t nstreams)
+ : sync_interpolator("streams_to_stream",
+ io_signature::make(nstreams, nstreams, itemsize),
+ io_signature::make(1, 1, itemsize),
+ nstreams)
+{
+}
- const char **inv = (const char **) &input_items[0];
- char *out = (char *) output_items[0];
- int nstreams = input_items.size();
+int streams_to_stream_impl::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ size_t itemsize = output_signature()->sizeof_stream_item(0);
- assert (noutput_items % nstreams == 0);
- int ni = noutput_items / nstreams;
+ const char** inv = (const char**)&input_items[0];
+ char* out = (char*)output_items[0];
+ int nstreams = input_items.size();
- for (int i = 0; i < ni; i++){
- for (int j = 0; j < nstreams; j++){
- memcpy(out, inv[j], itemsize);
- out += itemsize;
- inv[j] += itemsize;
- }
- }
+ assert(noutput_items % nstreams == 0);
+ int ni = noutput_items / nstreams;
- return noutput_items;
+ for (int i = 0; i < ni; i++) {
+ for (int j = 0; j < nstreams; j++) {
+ memcpy(out, inv[j], itemsize);
+ out += itemsize;
+ inv[j] += itemsize;
+ }
}
- } /* namespace blocks */
+ return noutput_items;
+}
+
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/streams_to_stream_impl.h b/gr-blocks/lib/streams_to_stream_impl.h
index e3ffde504c..3dec237c14 100644
--- a/gr-blocks/lib/streams_to_stream_impl.h
+++ b/gr-blocks/lib/streams_to_stream_impl.h
@@ -26,19 +26,19 @@
#include <gnuradio/blocks/streams_to_stream.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class BLOCKS_API streams_to_stream_impl : public streams_to_stream
- {
- public:
- streams_to_stream_impl(size_t itemsize, size_t nstreams);
+class BLOCKS_API streams_to_stream_impl : public streams_to_stream
+{
+public:
+ streams_to_stream_impl(size_t itemsize, size_t nstreams);
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_STREAMS_TO_STREAM_IMPL_H */
diff --git a/gr-blocks/lib/streams_to_vector_impl.cc b/gr-blocks/lib/streams_to_vector_impl.cc
index fc6c5c44a9..6c8eb2ac6f 100644
--- a/gr-blocks/lib/streams_to_vector_impl.cc
+++ b/gr-blocks/lib/streams_to_vector_impl.cc
@@ -28,41 +28,40 @@
#include <gnuradio/io_signature.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- streams_to_vector::sptr streams_to_vector::make(size_t itemsize, size_t nstreams)
- {
- return gnuradio::get_initial_sptr(new streams_to_vector_impl(itemsize, nstreams));
- }
-
- streams_to_vector_impl::streams_to_vector_impl(size_t itemsize, size_t nstreams)
- : sync_block ("streams_to_vector",
- io_signature::make (nstreams, nstreams, itemsize),
- io_signature::make (1, 1, nstreams * itemsize))
- {
- }
+streams_to_vector::sptr streams_to_vector::make(size_t itemsize, size_t nstreams)
+{
+ return gnuradio::get_initial_sptr(new streams_to_vector_impl(itemsize, nstreams));
+}
- int
- streams_to_vector_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- size_t itemsize = input_signature()->sizeof_stream_item(0);
- int nstreams = input_items.size();
+streams_to_vector_impl::streams_to_vector_impl(size_t itemsize, size_t nstreams)
+ : sync_block("streams_to_vector",
+ io_signature::make(nstreams, nstreams, itemsize),
+ io_signature::make(1, 1, nstreams * itemsize))
+{
+}
- const char **inv = (const char **) &input_items[0];
- char *out = (char *) output_items[0];
+int streams_to_vector_impl::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ size_t itemsize = input_signature()->sizeof_stream_item(0);
+ int nstreams = input_items.size();
- for (int i = 0; i < noutput_items; i++){
- for (int j = 0; j < nstreams; j++){
- memcpy(out, inv[j], itemsize);
- inv[j] += itemsize;
- out += itemsize;
- }
- }
+ const char** inv = (const char**)&input_items[0];
+ char* out = (char*)output_items[0];
- return noutput_items;
+ for (int i = 0; i < noutput_items; i++) {
+ for (int j = 0; j < nstreams; j++) {
+ memcpy(out, inv[j], itemsize);
+ inv[j] += itemsize;
+ out += itemsize;
+ }
}
- } /* namespace blocks */
+ return noutput_items;
+}
+
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/streams_to_vector_impl.h b/gr-blocks/lib/streams_to_vector_impl.h
index 5590e416b2..841b8acd71 100644
--- a/gr-blocks/lib/streams_to_vector_impl.h
+++ b/gr-blocks/lib/streams_to_vector_impl.h
@@ -26,19 +26,19 @@
#include <gnuradio/blocks/streams_to_vector.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class BLOCKS_API streams_to_vector_impl : public streams_to_vector
- {
- public:
- streams_to_vector_impl(size_t itemsize, size_t nstreams);
+class BLOCKS_API streams_to_vector_impl : public streams_to_vector
+{
+public:
+ streams_to_vector_impl(size_t itemsize, size_t nstreams);
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_STREAMS_TO_VECTOR_IMPL_H */
diff --git a/gr-blocks/lib/stretch_ff_impl.cc b/gr-blocks/lib/stretch_ff_impl.cc
index 4d43d13d68..2d788c9461 100644
--- a/gr-blocks/lib/stretch_ff_impl.cc
+++ b/gr-blocks/lib/stretch_ff_impl.cc
@@ -28,57 +28,53 @@
#include <gnuradio/io_signature.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- stretch_ff::sptr
- stretch_ff::make(float lo, size_t vlen)
- {
- return gnuradio::get_initial_sptr
- (new stretch_ff_impl(lo, vlen));
- }
+stretch_ff::sptr stretch_ff::make(float lo, size_t vlen)
+{
+ return gnuradio::get_initial_sptr(new stretch_ff_impl(lo, vlen));
+}
- stretch_ff_impl::stretch_ff_impl(float lo, size_t vlen)
- : sync_block("stretch_ff",
- io_signature::make(1, 1, vlen * sizeof(float)),
- io_signature::make(1, 1, vlen * sizeof(float))),
- d_lo(lo), d_vlen(vlen)
- {
- }
+stretch_ff_impl::stretch_ff_impl(float lo, size_t vlen)
+ : sync_block("stretch_ff",
+ io_signature::make(1, 1, vlen * sizeof(float)),
+ io_signature::make(1, 1, vlen * sizeof(float))),
+ d_lo(lo),
+ d_vlen(vlen)
+{
+}
- stretch_ff_impl::~stretch_ff_impl()
- {
- }
+stretch_ff_impl::~stretch_ff_impl() {}
- int
- stretch_ff_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];
+int stretch_ff_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];
- for(int count = 0; count < noutput_items; count++) {
+ for (int count = 0; count < noutput_items; count++) {
float vmax = in[0] - d_lo;
- for(unsigned int i = 1; i < d_vlen; i++) {
- float vtmp = in[i] - d_lo;
- if(vtmp > vmax)
- vmax = vtmp;
+ for (unsigned int i = 1; i < d_vlen; i++) {
+ float vtmp = in[i] - d_lo;
+ if (vtmp > vmax)
+ vmax = vtmp;
}
- if(vmax != 0.0)
- for(unsigned int i = 0; i < d_vlen; i++)
- out[i] = d_lo * (1.0 - (in[i] - d_lo) / vmax);
+ if (vmax != 0.0)
+ for (unsigned int i = 0; i < d_vlen; i++)
+ out[i] = d_lo * (1.0 - (in[i] - d_lo) / vmax);
else
- for(unsigned int i = 0; i < d_vlen; i++)
- out[i] = in[i];
+ for (unsigned int i = 0; i < d_vlen; i++)
+ out[i] = in[i];
- in += d_vlen;
+ in += d_vlen;
out += d_vlen;
- }
-
- return noutput_items;
}
- } /* namespace blocks */
+ return noutput_items;
+}
+
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/stretch_ff_impl.h b/gr-blocks/lib/stretch_ff_impl.h
index 69cf95ac73..c2228c93a6 100644
--- a/gr-blocks/lib/stretch_ff_impl.h
+++ b/gr-blocks/lib/stretch_ff_impl.h
@@ -26,28 +26,28 @@
#include <gnuradio/blocks/stretch_ff.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class stretch_ff_impl : public stretch_ff
- {
- private:
- float d_lo; // the constant
- size_t d_vlen;
+class stretch_ff_impl : public stretch_ff
+{
+private:
+ float d_lo; // the constant
+ size_t d_vlen;
- public:
- stretch_ff_impl(float lo, size_t vlen);
- ~stretch_ff_impl();
+public:
+ stretch_ff_impl(float lo, size_t vlen);
+ ~stretch_ff_impl();
- float lo() const { return d_lo; }
- void set_lo(float lo) { d_lo = lo; }
- size_t vlen() const { return d_vlen; }
+ float lo() const { return d_lo; }
+ void set_lo(float lo) { d_lo = lo; }
+ size_t vlen() const { return d_vlen; }
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_GR_STRETCH_FF_IMPL_H */
diff --git a/gr-blocks/lib/sub_impl.cc b/gr-blocks/lib/sub_impl.cc
index 5d618d3467..67ca84ec36 100644
--- a/gr-blocks/lib/sub_impl.cc
+++ b/gr-blocks/lib/sub_impl.cc
@@ -30,80 +30,77 @@
#include <volk/volk.h>
namespace gr {
- namespace blocks {
-
- template <class T>
- typename sub<T>::sptr sub<T>::make(size_t vlen)
- {
- return gnuradio::get_initial_sptr(new sub_impl<T> (vlen));
- }
-
- template <>
- sub_impl<float>::sub_impl(size_t vlen)
- : sync_block("sub_ff",
- io_signature::make(1, -1, sizeof(float)*vlen),
- io_signature::make(1, 1, sizeof(float)*vlen)),
+namespace blocks {
+
+template <class T>
+typename sub<T>::sptr sub<T>::make(size_t vlen)
+{
+ return gnuradio::get_initial_sptr(new sub_impl<T>(vlen));
+}
+
+template <>
+sub_impl<float>::sub_impl(size_t vlen)
+ : sync_block("sub_ff",
+ io_signature::make(1, -1, sizeof(float) * vlen),
+ io_signature::make(1, 1, sizeof(float) * vlen)),
d_vlen(vlen)
- {
- const int alignment_multiple =
- volk_get_alignment() / sizeof(float);
- set_alignment(std::max(1, alignment_multiple));
- }
-
- template <>
- int
- sub_impl<float>::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- float *out = (float*)output_items[0];
-
- int ninputs = input_items.size();
- int noi = noutput_items*d_vlen;
-
- const float *in = (const float*)input_items[0];
- memcpy(out, in, noi*sizeof(float));
- for(int i = 1; i < ninputs; i++) {
+{
+ const int alignment_multiple = volk_get_alignment() / sizeof(float);
+ set_alignment(std::max(1, alignment_multiple));
+}
+
+template <>
+int sub_impl<float>::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ float* out = (float*)output_items[0];
+
+ int ninputs = input_items.size();
+ int noi = noutput_items * d_vlen;
+
+ const float* in = (const float*)input_items[0];
+ memcpy(out, in, noi * sizeof(float));
+ for (int i = 1; i < ninputs; i++) {
in = (const float*)input_items[i];
volk_32f_x2_subtract_32f(out, out, in, noi);
- }
-
- return noutput_items;
}
- template <class T>
- sub_impl<T> ::sub_impl(size_t vlen)
- : sync_block ("sub",
- io_signature::make (1, -1, sizeof (T)*vlen),
- io_signature::make (1, 1, sizeof (T)*vlen)),
- d_vlen(vlen)
- {
- }
+ return noutput_items;
+}
- template <class T>
- int
- sub_impl<T> ::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- T *optr = (T *) output_items[0];
+template <class T>
+sub_impl<T>::sub_impl(size_t vlen)
+ : sync_block("sub",
+ io_signature::make(1, -1, sizeof(T) * vlen),
+ io_signature::make(1, 1, sizeof(T) * vlen)),
+ d_vlen(vlen)
+{
+}
- int ninputs = input_items.size ();
+template <class T>
+int sub_impl<T>::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ T* optr = (T*)output_items[0];
- for (size_t i = 0; i < noutput_items*d_vlen; i++){
- T acc = ((T *) input_items[0])[i];
- for (int j = 1; j < ninputs; j++)
- acc -= ((T *) input_items[j])[i];
+ int ninputs = input_items.size();
- *optr++ = (T) acc;
- }
+ for (size_t i = 0; i < noutput_items * d_vlen; i++) {
+ T acc = ((T*)input_items[0])[i];
+ for (int j = 1; j < ninputs; j++)
+ acc -= ((T*)input_items[j])[i];
- return noutput_items;
+ *optr++ = (T)acc;
}
+ return noutput_items;
+}
+
template class sub<std::int16_t>;
template class sub<std::int32_t>;
template class sub<gr_complex>;
template class sub<float>;
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/sub_impl.h b/gr-blocks/lib/sub_impl.h
index 66e46995fd..97f4cf5156 100644
--- a/gr-blocks/lib/sub_impl.h
+++ b/gr-blocks/lib/sub_impl.h
@@ -27,22 +27,22 @@
#include <gnuradio/blocks/sub.h>
namespace gr {
- namespace blocks {
+namespace blocks {
-template<class T>
- class BLOCKS_API sub_impl : public sub<T>
- {
- size_t d_vlen;
+template <class T>
+class BLOCKS_API sub_impl : public sub<T>
+{
+ size_t d_vlen;
- public:
- sub_impl (size_t vlen);
+public:
+ sub_impl(size_t vlen);
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* SUB_IMPL_H */
diff --git a/gr-blocks/lib/tag_debug_impl.cc b/gr-blocks/lib/tag_debug_impl.cc
index a4c4c694b8..450e5f87fe 100644
--- a/gr-blocks/lib/tag_debug_impl.cc
+++ b/gr-blocks/lib/tag_debug_impl.cc
@@ -30,137 +30,128 @@
#include <iomanip>
namespace gr {
- namespace blocks {
-
- tag_debug::sptr
- tag_debug::make(size_t sizeof_stream_item,
- const std::string &name,
- const std::string &key_filter)
- {
- return gnuradio::get_initial_sptr
- (new tag_debug_impl(sizeof_stream_item, name, key_filter));
- }
-
- tag_debug_impl::tag_debug_impl(size_t sizeof_stream_item,
- const std::string &name,
- const std::string &key_filter)
- : sync_block("tag_debug",
- io_signature::make(1, -1, sizeof_stream_item),
- io_signature::make(0, 0, 0)),
- d_name(name), d_display(true)
- {
- set_key_filter(key_filter);
- }
-
- tag_debug_impl::~tag_debug_impl()
- {
- }
-
- std::vector<tag_t>
- tag_debug_impl::current_tags()
- {
- gr::thread::scoped_lock l(d_mutex);
- return d_tags;
- }
-
- int
- tag_debug_impl::num_tags()
- {
- std::vector<tag_t> t;
- get_tags_in_range(t, 0, 0, nitems_read(0));
- return static_cast<int>(t.size());
- }
-
- void
- tag_debug_impl::set_display(bool d)
- {
- d_display = d;
- }
-
- void
- tag_debug_impl::set_key_filter(const std::string &key_filter)
- {
- if(key_filter == "")
+namespace blocks {
+
+tag_debug::sptr tag_debug::make(size_t sizeof_stream_item,
+ const std::string& name,
+ const std::string& key_filter)
+{
+ return gnuradio::get_initial_sptr(
+ new tag_debug_impl(sizeof_stream_item, name, key_filter));
+}
+
+tag_debug_impl::tag_debug_impl(size_t sizeof_stream_item,
+ const std::string& name,
+ const std::string& key_filter)
+ : sync_block("tag_debug",
+ io_signature::make(1, -1, sizeof_stream_item),
+ io_signature::make(0, 0, 0)),
+ d_name(name),
+ d_display(true)
+{
+ set_key_filter(key_filter);
+}
+
+tag_debug_impl::~tag_debug_impl() {}
+
+std::vector<tag_t> tag_debug_impl::current_tags()
+{
+ gr::thread::scoped_lock l(d_mutex);
+ return d_tags;
+}
+
+int tag_debug_impl::num_tags()
+{
+ std::vector<tag_t> t;
+ get_tags_in_range(t, 0, 0, nitems_read(0));
+ return static_cast<int>(t.size());
+}
+
+void tag_debug_impl::set_display(bool d) { d_display = d; }
+
+void tag_debug_impl::set_key_filter(const std::string& key_filter)
+{
+ if (key_filter == "")
d_filter = pmt::PMT_NIL;
- else
+ else
d_filter = pmt::intern(key_filter);
- }
+}
- std::string
- tag_debug_impl::key_filter() const
- {
- return pmt::symbol_to_string(d_filter);
- }
+std::string tag_debug_impl::key_filter() const { return pmt::symbol_to_string(d_filter); }
- int
- tag_debug_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- gr::thread::scoped_lock l(d_mutex);
- bool toprint = false;
+int tag_debug_impl::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ gr::thread::scoped_lock l(d_mutex);
+ bool toprint = false;
- std::stringstream sout;
- if(d_display) {
+ 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++) {
+ 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();
- if(pmt::is_null(d_filter))
- get_tags_in_range(d_tags, i, abs_N, end_N);
+ if (pmt::is_null(d_filter))
+ get_tags_in_range(d_tags, i, abs_N, end_N);
else
- get_tags_in_range(d_tags, i, abs_N, end_N, d_filter);
+ get_tags_in_range(d_tags, i, abs_N, end_N, d_filter);
- if(d_tags.size() > 0) {
- toprint = true;
+ if (d_tags.size() > 0) {
+ toprint = true;
}
- 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::is_symbol(d_tags_itr->srcid) ? pmt::symbol_to_string(d_tags_itr->srcid) : "n/a")
- << std::setw(10) << "Key: " << pmt::symbol_to_string(d_tags_itr->key)
- << std::setw(10) << "Value: ";
- sout << d_tags_itr->value << std::endl;
- }
+ 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::is_symbol(d_tags_itr->srcid)
+ ? pmt::symbol_to_string(d_tags_itr->srcid)
+ : "n/a")
+ << std::setw(10) << "Key: " << pmt::symbol_to_string(d_tags_itr->key)
+ << std::setw(10) << "Value: ";
+ sout << d_tags_itr->value << std::endl;
+ }
}
- }
+ }
- if(d_display) {
+ if (d_display) {
sout << "----------------------------------------------------------------------";
sout << std::endl;
- if(toprint) {
- std::cout << sout.str();
+ if (toprint) {
+ std::cout << sout.str();
}
- }
-
- return noutput_items;
}
- void
- tag_debug_impl::setup_rpc()
- {
+ return noutput_items;
+}
+
+void tag_debug_impl::setup_rpc()
+{
#ifdef GR_CTRLPORT
- add_rpc_variable(
- rpcbasic_sptr(new rpcbasic_register_get<tag_debug, int>(
- alias(), "num. tags",
- &tag_debug::num_tags,
- pmt::from_long(0), pmt::from_long(10000), pmt::from_long(0),
- "", "Number of Tags", RPC_PRIVLVL_MIN,
- DISPTIME | DISPOPTSTRIP)));
+ add_rpc_variable(rpcbasic_sptr(
+ new rpcbasic_register_get<tag_debug, int>(alias(),
+ "num. tags",
+ &tag_debug::num_tags,
+ pmt::from_long(0),
+ pmt::from_long(10000),
+ pmt::from_long(0),
+ "",
+ "Number of Tags",
+ RPC_PRIVLVL_MIN,
+ DISPTIME | DISPOPTSTRIP)));
#endif /* GR_CTRLPORT */
- }
+}
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/tag_debug_impl.h b/gr-blocks/lib/tag_debug_impl.h
index 1d28f123d3..6fad5761c8 100644
--- a/gr-blocks/lib/tag_debug_impl.h
+++ b/gr-blocks/lib/tag_debug_impl.h
@@ -28,39 +28,40 @@
#include <stddef.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class tag_debug_impl : public tag_debug
- {
- private:
- std::string d_name;
- std::vector<tag_t> d_tags;
- std::vector<tag_t>::iterator d_tags_itr;
- bool d_display;
- pmt::pmt_t d_filter;
- gr::thread::mutex d_mutex;
+class tag_debug_impl : public tag_debug
+{
+private:
+ std::string d_name;
+ std::vector<tag_t> d_tags;
+ std::vector<tag_t>::iterator d_tags_itr;
+ bool d_display;
+ pmt::pmt_t d_filter;
+ gr::thread::mutex d_mutex;
- public:
- tag_debug_impl(size_t sizeof_stream_item, const std::string &name,
- const std::string &key_filter="");
- ~tag_debug_impl();
+public:
+ tag_debug_impl(size_t sizeof_stream_item,
+ const std::string& name,
+ const std::string& key_filter = "");
+ ~tag_debug_impl();
- void setup_rpc();
+ void setup_rpc();
- std::vector<tag_t> current_tags();
- int num_tags();
+ std::vector<tag_t> current_tags();
+ int num_tags();
- void set_display(bool d);
+ void set_display(bool d);
- void set_key_filter(const std::string &key_filter);
- std::string key_filter() const;
+ void set_key_filter(const std::string& key_filter);
+ std::string key_filter() const;
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_GR_TAG_DEBUG_IMPL_H */
diff --git a/gr-blocks/lib/tag_gate_impl.cc b/gr-blocks/lib/tag_gate_impl.cc
index ad55c8af9a..08390beca2 100644
--- a/gr-blocks/lib/tag_gate_impl.cc
+++ b/gr-blocks/lib/tag_gate_impl.cc
@@ -28,87 +28,81 @@
#include "tag_gate_impl.h"
namespace gr {
- namespace blocks {
+namespace blocks {
- tag_gate::sptr
- tag_gate::make(size_t item_size, bool propagate_tags)
- {
- return gnuradio::get_initial_sptr (new tag_gate_impl(item_size, propagate_tags));
- }
+tag_gate::sptr tag_gate::make(size_t item_size, bool propagate_tags)
+{
+ return gnuradio::get_initial_sptr(new tag_gate_impl(item_size, propagate_tags));
+}
- tag_gate_impl::tag_gate_impl(size_t item_size, bool propagate_tags)
- : gr::sync_block("tag_gate",
- gr::io_signature::make(1, 1, item_size),
- gr::io_signature::make(1, 1, item_size)),
+tag_gate_impl::tag_gate_impl(size_t item_size, bool propagate_tags)
+ : gr::sync_block("tag_gate",
+ gr::io_signature::make(1, 1, item_size),
+ gr::io_signature::make(1, 1, item_size)),
d_item_size(item_size),
d_propagate_tags(propagate_tags),
d_single_key_set(false)
- {
- if (!d_propagate_tags) {
- set_tag_propagation_policy(TPP_DONT);
- }
- d_single_key = pmt::PMT_NIL;
+{
+ if (!d_propagate_tags) {
+ set_tag_propagation_policy(TPP_DONT);
}
+ d_single_key = pmt::PMT_NIL;
+}
- tag_gate_impl::~tag_gate_impl()
- {
- }
+tag_gate_impl::~tag_gate_impl() {}
- void tag_gate_impl::set_propagation(bool propagate_tags)
- {
- d_propagate_tags = propagate_tags;
+void tag_gate_impl::set_propagation(bool propagate_tags)
+{
+ d_propagate_tags = propagate_tags;
- if (propagate_tags) {
+ if (propagate_tags) {
set_tag_propagation_policy(TPP_ALL_TO_ALL);
- } else {
+ } else {
set_tag_propagation_policy(TPP_DONT);
- }
}
+}
- void tag_gate_impl::set_single_key(const std::string &single_key)
- {
- if(single_key == "") {
+void tag_gate_impl::set_single_key(const std::string& single_key)
+{
+ if (single_key == "") {
d_single_key = pmt::PMT_NIL;
d_single_key_set = false;
- }
- else {
+ } else {
d_single_key = pmt::intern(single_key);
d_single_key_set = true;
- }
}
+}
- std::string tag_gate_impl::single_key() const
- {
- if(pmt::equal(d_single_key, pmt::PMT_NIL)) {
+std::string tag_gate_impl::single_key() const
+{
+ if (pmt::equal(d_single_key, pmt::PMT_NIL)) {
return "";
- }
- else {
+ } else {
return pmt::symbol_to_string(d_single_key);
- }
}
+}
- int
- tag_gate_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];
- std::vector<tag_t> tags;
+int tag_gate_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];
+ std::vector<tag_t> tags;
- memcpy((void *) out, (void *) in, d_item_size * noutput_items);
+ memcpy((void*)out, (void*)in, d_item_size * noutput_items);
- if (d_single_key_set && (!d_propagate_tags)) {
+ if (d_single_key_set && (!d_propagate_tags)) {
get_tags_in_range(tags, 0, nitems_read(0), nitems_read(0) + noutput_items);
- for (unsigned int i=0; i < tags.size(); i++) {
- if (!pmt::equal(tags[i].key, d_single_key))
- add_item_tag(0, tags[i].offset, tags[i].key, tags[i].value, tags[i].srcid);
+ for (unsigned int i = 0; i < tags.size(); i++) {
+ if (!pmt::equal(tags[i].key, d_single_key))
+ add_item_tag(
+ 0, tags[i].offset, tags[i].key, tags[i].value, tags[i].srcid);
}
- }
-
- return noutput_items;
}
- } /* namespace blocks */
-} /* namespace gr */
+ return noutput_items;
+}
+} /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/tag_gate_impl.h b/gr-blocks/lib/tag_gate_impl.h
index 129fb78cb8..62dbc9a251 100644
--- a/gr-blocks/lib/tag_gate_impl.h
+++ b/gr-blocks/lib/tag_gate_impl.h
@@ -26,33 +26,32 @@
#include <gnuradio/blocks/tag_gate.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class tag_gate_impl : public tag_gate
- {
- private:
- size_t d_item_size;
- bool d_propagate_tags;
- bool d_single_key_set;
+class tag_gate_impl : public tag_gate
+{
+private:
+ size_t d_item_size;
+ bool d_propagate_tags;
+ bool d_single_key_set;
- pmt::pmt_t d_single_key;
+ pmt::pmt_t d_single_key;
- public:
- tag_gate_impl(size_t item_size, bool propagate_tags);
- ~tag_gate_impl();
+public:
+ tag_gate_impl(size_t item_size, bool propagate_tags);
+ ~tag_gate_impl();
- void set_propagation(bool propagate_tags);
+ void set_propagation(bool propagate_tags);
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
- void set_single_key(const std::string &single_key);
- std::string single_key() const;
- };
+ void set_single_key(const std::string& single_key);
+ std::string single_key() const;
+};
- } // namespace blocks
+} // namespace blocks
} // namespace gr
#endif /* INCLUDED_BLOCKS_TAG_GATE_IMPL_H */
-
diff --git a/gr-blocks/lib/tag_share_impl.cc b/gr-blocks/lib/tag_share_impl.cc
index 26a54dbf8c..f8a1129704 100644
--- a/gr-blocks/lib/tag_share_impl.cc
+++ b/gr-blocks/lib/tag_share_impl.cc
@@ -1,19 +1,19 @@
/* -*- c++ -*- */
-/*
+/*
* Copyright 2017 Free Software Foundation, Inc.
- *
+ *
* This file is part of GNU Radio
- *
+ *
* GNU Radio is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
- *
+ *
* GNU Radio is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Radio; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
@@ -28,52 +28,51 @@
#include "tag_share_impl.h"
namespace gr {
- namespace blocks {
+namespace blocks {
- tag_share::sptr
- tag_share::make(size_t sizeof_io_item, size_t sizeof_share_item, size_t vlen)
- {
- return gnuradio::get_initial_sptr
- (new tag_share_impl(sizeof_io_item, sizeof_share_item, vlen));
- }
+tag_share::sptr
+tag_share::make(size_t sizeof_io_item, size_t sizeof_share_item, size_t vlen)
+{
+ return gnuradio::get_initial_sptr(
+ new tag_share_impl(sizeof_io_item, sizeof_share_item, vlen));
+}
- /*
- * The private constructor
- */
- tag_share_impl::tag_share_impl(size_t sizeof_io_item, size_t sizeof_share_item, size_t vlen)
- : gr::sync_block("tag_share",
- gr::io_signature::make2(2, 2, sizeof_io_item*vlen, sizeof_share_item*vlen),
- gr::io_signature::make(1, 1, sizeof_io_item*vlen)),
- d_sizeof_io_item(sizeof_io_item),
- d_vlen(vlen)
- {
- // This is the entire premise of the block -- to have the GNU Radio runtime
- // propagate all the tags from Input 0 and Input 1 to Output 0.
- set_tag_propagation_policy(TPP_ALL_TO_ALL);
- }
+/*
+ * The private constructor
+ */
+tag_share_impl::tag_share_impl(size_t sizeof_io_item,
+ size_t sizeof_share_item,
+ size_t vlen)
+ : gr::sync_block(
+ "tag_share",
+ gr::io_signature::make2(2, 2, sizeof_io_item * vlen, sizeof_share_item * vlen),
+ gr::io_signature::make(1, 1, sizeof_io_item * vlen)),
+ d_sizeof_io_item(sizeof_io_item),
+ d_vlen(vlen)
+{
+ // This is the entire premise of the block -- to have the GNU Radio runtime
+ // propagate all the tags from Input 0 and Input 1 to Output 0.
+ set_tag_propagation_policy(TPP_ALL_TO_ALL);
+}
- /*
- * Our virtual destructor.
- */
- tag_share_impl::~tag_share_impl()
- {
- }
+/*
+ * Our virtual destructor.
+ */
+tag_share_impl::~tag_share_impl() {}
- int
- tag_share_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- const void *in = (const void *) input_items[0];
- void *out = (void *) output_items[0];
+int tag_share_impl::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ const void* in = (const void*)input_items[0];
+ void* out = (void*)output_items[0];
- // Input 0 passes through to Output 0
- memcpy(out, in, d_sizeof_io_item*d_vlen*noutput_items);
+ // Input 0 passes through to Output 0
+ memcpy(out, in, d_sizeof_io_item * d_vlen * noutput_items);
- // Tell runtime system how many output items we produced.
- return noutput_items;
- }
+ // Tell runtime system how many output items we produced.
+ return noutput_items;
+}
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
-
diff --git a/gr-blocks/lib/tag_share_impl.h b/gr-blocks/lib/tag_share_impl.h
index e5df8e3a0c..f91b0de61f 100644
--- a/gr-blocks/lib/tag_share_impl.h
+++ b/gr-blocks/lib/tag_share_impl.h
@@ -1,19 +1,19 @@
/* -*- c++ -*- */
-/*
+/*
* Copyright 2017 Free Software Foundation, Inc.
- *
+ *
* This file is part of GNU Radio
- *
+ *
* GNU Radio is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
- *
+ *
* GNU Radio is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Radio; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
@@ -26,26 +26,25 @@
#include <gnuradio/blocks/tag_share.h>
namespace gr {
- namespace blocks {
-
- class tag_share_impl : public tag_share
- {
- private:
- size_t d_sizeof_io_item;
- size_t d_vlen;
-
- public:
- tag_share_impl(size_t sizeof_io_item, size_t sizeof_share_item, size_t vlen);
- ~tag_share_impl();
-
- // Where all the action really happens
- int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
- };
-
- } // namespace blocks
+namespace blocks {
+
+class tag_share_impl : public tag_share
+{
+private:
+ size_t d_sizeof_io_item;
+ size_t d_vlen;
+
+public:
+ tag_share_impl(size_t sizeof_io_item, size_t sizeof_share_item, size_t vlen);
+ ~tag_share_impl();
+
+ // Where all the action really happens
+ 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_TAG_SHARE_IMPL_H */
-
diff --git a/gr-blocks/lib/tagged_file_sink_impl.cc b/gr-blocks/lib/tagged_file_sink_impl.cc
index e81209ab6e..83b0432253 100644
--- a/gr-blocks/lib/tagged_file_sink_impl.cc
+++ b/gr-blocks/lib/tagged_file_sink_impl.cc
@@ -38,198 +38,193 @@
#endif
#ifdef O_BINARY
-#define OUR_O_BINARY O_BINARY
+#define OUR_O_BINARY O_BINARY
#else
-#define OUR_O_BINARY 0
+#define OUR_O_BINARY 0
#endif
// should be handled via configure
#ifdef O_LARGEFILE
-#define OUR_O_LARGEFILE O_LARGEFILE
+#define OUR_O_LARGEFILE O_LARGEFILE
#else
-#define OUR_O_LARGEFILE 0
+#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)
- : sync_block("tagged_file_sink",
- io_signature::make(1, 1, itemsize),
- io_signature::make(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;
+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)
+ : sync_block("tagged_file_sink",
+ io_signature::make(1, 1, itemsize),
+ io_signature::make(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::string_to_symbol("burst");
+ pmt::pmt_t tkey = pmt::string_to_symbol("rx_time"); // use gr_tags::key_time
+
+ std::vector<tag_t> all_tags;
+ get_tags_in_range(all_tags, 0, start_N, end_N);
+
+ std::sort(all_tags.begin(), all_tags.end(), tag_t::offset_compare);
+
+ std::vector<tag_t>::iterator vitr = all_tags.begin();
+
+ // Look for a time tag and initialize d_timeval.
+ std::vector<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 tag_t tag = time_tags_outer[0];
+ uint64_t offset = tag.offset;
+ pmt::pmt_t time = tag.value;
+ uint64_t tsecs = pmt::to_uint64(pmt::tuple_ref(time, 0));
+ double tfrac = pmt::to_double(pmt::tuple_ref(time, 1));
+ double delta = (double)offset / d_sample_rate;
+ d_timeval = (double)tsecs + tfrac + delta;
+ d_last_N = offset;
}
- tagged_file_sink_impl::~tagged_file_sink_impl()
- {
+ int idx = 0, idx_stop = 0;
+ while (idx < noutput_items) {
+ if (d_state == NOT_IN_BURST) {
+ while (vitr != all_tags.end()) {
+ if ((pmt::eqv((*vitr).key, bkey)) && 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<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 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::to_uint64(pmt::tuple_ref(time, 0));
+ double tfrac = pmt::to_double(pmt::tuple_ref(time, 1));
+
+ // Get new time from last time tag + difference in time to when
+ // burst tag occurred 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::eqv((*vitr).key, bkey)) && 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;
+ }
+ }
}
- 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::string_to_symbol("burst");
- pmt::pmt_t tkey = pmt::string_to_symbol("rx_time"); // use gr_tags::key_time
-
- std::vector<tag_t> all_tags;
- get_tags_in_range(all_tags, 0, start_N, end_N);
-
- std::sort(all_tags.begin(), all_tags.end(), tag_t::offset_compare);
-
- std::vector<tag_t>::iterator vitr = all_tags.begin();
-
- // Look for a time tag and initialize d_timeval.
- std::vector<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 tag_t tag = time_tags_outer[0];
- uint64_t offset = tag.offset;
- pmt::pmt_t time = tag.value;
- uint64_t tsecs = pmt::to_uint64(pmt::tuple_ref(time, 0));
- double tfrac = pmt::to_double(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::eqv((*vitr).key, bkey)) &&
- 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<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 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::to_uint64(pmt::tuple_ref(time, 0));
- double tfrac = pmt::to_double(pmt::tuple_ref(time, 1));
-
- // Get new time from last time tag + difference in time to when
- // burst tag occurred 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::eqv((*vitr).key, bkey)) &&
- 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;
- }
+ return noutput_items;
+}
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/tagged_file_sink_impl.h b/gr-blocks/lib/tagged_file_sink_impl.h
index 7b1d43e641..836f46dbca 100644
--- a/gr-blocks/lib/tagged_file_sink_impl.h
+++ b/gr-blocks/lib/tagged_file_sink_impl.h
@@ -24,37 +24,34 @@
#define INCLUDED_GR_TAGGED_FILE_SINK_IMPL_H
#include <gnuradio/blocks/tagged_file_sink.h>
-#include <cstdio> // for FILE
+#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 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 */
diff --git a/gr-blocks/lib/tagged_stream_align_impl.cc b/gr-blocks/lib/tagged_stream_align_impl.cc
index 80b5286278..c2050e1556 100644
--- a/gr-blocks/lib/tagged_stream_align_impl.cc
+++ b/gr-blocks/lib/tagged_stream_align_impl.cc
@@ -28,60 +28,59 @@
#include "tagged_stream_align_impl.h"
namespace gr {
- namespace blocks {
+namespace blocks {
- tagged_stream_align::sptr
- tagged_stream_align::make(size_t itemsize, const std::string &lengthtagname)
- {
- return gnuradio::get_initial_sptr (new tagged_stream_align_impl(itemsize, lengthtagname));
- }
+tagged_stream_align::sptr tagged_stream_align::make(size_t itemsize,
+ const std::string& lengthtagname)
+{
+ return gnuradio::get_initial_sptr(
+ new tagged_stream_align_impl(itemsize, lengthtagname));
+}
- tagged_stream_align_impl::tagged_stream_align_impl(size_t itemsize, const std::string &lengthtagname)
- : block("tagged_stream_align",
- io_signature::make(1, 1, itemsize),
- io_signature::make(1, 1, itemsize)),
- d_itemsize(itemsize),
- d_lengthtag(pmt::mp(lengthtagname)),
- d_have_sync(false)
- {
- set_tag_propagation_policy(TPP_DONT);
- }
+tagged_stream_align_impl::tagged_stream_align_impl(size_t itemsize,
+ const std::string& lengthtagname)
+ : block("tagged_stream_align",
+ io_signature::make(1, 1, itemsize),
+ io_signature::make(1, 1, itemsize)),
+ d_itemsize(itemsize),
+ d_lengthtag(pmt::mp(lengthtagname)),
+ d_have_sync(false)
+{
+ set_tag_propagation_policy(TPP_DONT);
+}
- tagged_stream_align_impl::~tagged_stream_align_impl()
- {
- }
+tagged_stream_align_impl::~tagged_stream_align_impl() {}
- int
- tagged_stream_align_impl::general_work(int noutput_items,
- gr_vector_int &ninput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- std::vector<tag_t> tags;
- if(d_have_sync){
+int tagged_stream_align_impl::general_work(int noutput_items,
+ gr_vector_int& ninput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ std::vector<tag_t> tags;
+ if (d_have_sync) {
int ncp = std::min(noutput_items, ninput_items[0]);
get_tags_in_range(tags, 0, nitems_read(0), nitems_read(0) + noutput_items);
- for(size_t i=0; i<tags.size(); i++){
+ for (size_t i = 0; i < tags.size(); i++) {
gr::tag_t t = tags[i];
int offset = (nitems_read(0) - nitems_written(0));
t.offset -= offset;
- add_item_tag(0,t);
- }
- memcpy(output_items[0], input_items[0], ncp*d_itemsize);
+ add_item_tag(0, t);
+ }
+ memcpy(output_items[0], input_items[0], ncp * d_itemsize);
consume_each(ncp);
return ncp;
- } else {
- get_tags_in_range(tags, 0, nitems_read(0), nitems_read(0) + ninput_items[0], d_lengthtag);
- if(tags.size() > 0){
+ } else {
+ get_tags_in_range(
+ tags, 0, nitems_read(0), nitems_read(0) + ninput_items[0], d_lengthtag);
+ if (tags.size() > 0) {
d_have_sync = true;
- consume_each( tags[0].offset - nitems_read(0) );
+ consume_each(tags[0].offset - nitems_read(0));
} else {
consume_each(ninput_items[0]);
}
return 0;
- }
}
+}
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
-
diff --git a/gr-blocks/lib/tagged_stream_align_impl.h b/gr-blocks/lib/tagged_stream_align_impl.h
index 0481f88d5c..8b203115c2 100644
--- a/gr-blocks/lib/tagged_stream_align_impl.h
+++ b/gr-blocks/lib/tagged_stream_align_impl.h
@@ -27,27 +27,26 @@
#include <gnuradio/blocks/tagged_stream_align.h>
namespace gr {
- namespace blocks {
-
- class tagged_stream_align_impl : public tagged_stream_align
- {
- private:
- size_t d_itemsize;
- pmt::pmt_t d_lengthtag;
- bool d_have_sync;
-
- public:
- tagged_stream_align_impl(size_t itemsize, const std::string &lengthtagname);
- ~tagged_stream_align_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 blocks {
+
+class tagged_stream_align_impl : public tagged_stream_align
+{
+private:
+ size_t d_itemsize;
+ pmt::pmt_t d_lengthtag;
+ bool d_have_sync;
+
+public:
+ tagged_stream_align_impl(size_t itemsize, const std::string& lengthtagname);
+ ~tagged_stream_align_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
-
diff --git a/gr-blocks/lib/tagged_stream_multiply_length_impl.cc b/gr-blocks/lib/tagged_stream_multiply_length_impl.cc
index 266b967e69..96d77401ae 100644
--- a/gr-blocks/lib/tagged_stream_multiply_length_impl.cc
+++ b/gr-blocks/lib/tagged_stream_multiply_length_impl.cc
@@ -28,62 +28,66 @@
#include "tagged_stream_multiply_length_impl.h"
namespace gr {
- namespace blocks {
+namespace blocks {
- tagged_stream_multiply_length::sptr
- tagged_stream_multiply_length::make(size_t itemsize, const std::string &lengthtagname, double scalar)
- {
- return gnuradio::get_initial_sptr (new tagged_stream_multiply_length_impl(itemsize, lengthtagname, scalar));
- }
+tagged_stream_multiply_length::sptr tagged_stream_multiply_length::make(
+ size_t itemsize, const std::string& lengthtagname, double scalar)
+{
+ return gnuradio::get_initial_sptr(
+ new tagged_stream_multiply_length_impl(itemsize, lengthtagname, scalar));
+}
- tagged_stream_multiply_length_impl::tagged_stream_multiply_length_impl(size_t itemsize, const std::string &lengthtagname, double scalar)
- : block("tagged_stream_multiply_length",
- io_signature::make(1, 1, itemsize),
- io_signature::make(1, 1, itemsize)),
- d_lengthtag(pmt::mp(lengthtagname)),
- d_scalar(scalar),
- d_itemsize(itemsize)
- {
- set_tag_propagation_policy(TPP_DONT);
- set_relative_rate(1, 1);
- message_port_register_in(pmt::intern("set_scalar"));
- set_msg_handler(pmt::intern("set_scalar"),
+tagged_stream_multiply_length_impl::tagged_stream_multiply_length_impl(
+ size_t itemsize, const std::string& lengthtagname, double scalar)
+ : block("tagged_stream_multiply_length",
+ io_signature::make(1, 1, itemsize),
+ io_signature::make(1, 1, itemsize)),
+ d_lengthtag(pmt::mp(lengthtagname)),
+ d_scalar(scalar),
+ d_itemsize(itemsize)
+{
+ set_tag_propagation_policy(TPP_DONT);
+ set_relative_rate(1, 1);
+ message_port_register_in(pmt::intern("set_scalar"));
+ set_msg_handler(
+ pmt::intern("set_scalar"),
boost::bind(&tagged_stream_multiply_length_impl::set_scalar_pmt, this, _1));
- }
+}
- tagged_stream_multiply_length_impl::~tagged_stream_multiply_length_impl()
- {
- }
+tagged_stream_multiply_length_impl::~tagged_stream_multiply_length_impl() {}
- int
- tagged_stream_multiply_length_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 void* in = input_items[0];
- void* out = output_items[0];
+int tagged_stream_multiply_length_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 void* in = input_items[0];
+ void* out = output_items[0];
- // move data across ( wasteful memcopy :< )
- memcpy(out, in, noutput_items*d_itemsize);
+ // move data across ( wasteful memcopy :< )
+ memcpy(out, in, noutput_items * d_itemsize);
- // move and update tags
- std::vector<tag_t> tags;
- get_tags_in_range(tags, 0, nitems_read(0), nitems_read(0)+noutput_items);
- for(size_t i=0; i<tags.size(); i++){
- if(pmt::eqv( tags[i].key , d_lengthtag)){
- // propagate with value update (scaled)
- add_item_tag(0, tags[i].offset, tags[i].key, pmt::from_long(pmt::to_long(tags[i].value) * d_scalar), tags[i].srcid );
- } else {
- // propagate unmodified
- add_item_tag(0, tags[i].offset, tags[i].key, tags[i].value, tags[i].srcid );
- }
+ // move and update tags
+ std::vector<tag_t> tags;
+ get_tags_in_range(tags, 0, nitems_read(0), nitems_read(0) + noutput_items);
+ for (size_t i = 0; i < tags.size(); i++) {
+ if (pmt::eqv(tags[i].key, d_lengthtag)) {
+ // propagate with value update (scaled)
+ add_item_tag(0,
+ tags[i].offset,
+ tags[i].key,
+ pmt::from_long(pmt::to_long(tags[i].value) * d_scalar),
+ tags[i].srcid);
+ } else {
+ // propagate unmodified
+ add_item_tag(0, tags[i].offset, tags[i].key, tags[i].value, tags[i].srcid);
}
-
- consume_each(noutput_items);
- return noutput_items;
}
- } /* namespace blocks */
-} /* namespace gr */
+ consume_each(noutput_items);
+ return noutput_items;
+}
+} /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/tagged_stream_multiply_length_impl.h b/gr-blocks/lib/tagged_stream_multiply_length_impl.h
index 5d61650369..f54c71b3c7 100644
--- a/gr-blocks/lib/tagged_stream_multiply_length_impl.h
+++ b/gr-blocks/lib/tagged_stream_multiply_length_impl.h
@@ -27,36 +27,32 @@
#include <gnuradio/blocks/tagged_stream_multiply_length.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class tagged_stream_multiply_length_impl : public tagged_stream_multiply_length
- {
- private:
- pmt::pmt_t d_lengthtag;
- double d_scalar;
- size_t d_itemsize;
+class tagged_stream_multiply_length_impl : public tagged_stream_multiply_length
+{
+private:
+ pmt::pmt_t d_lengthtag;
+ double d_scalar;
+ size_t d_itemsize;
- public:
- tagged_stream_multiply_length_impl(size_t itemsize, const std::string &lengthtagname, double scalar);
- ~tagged_stream_multiply_length_impl();
+public:
+ tagged_stream_multiply_length_impl(size_t itemsize,
+ const std::string& lengthtagname,
+ double scalar);
+ ~tagged_stream_multiply_length_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);
+ int general_work(int noutput_items,
+ gr_vector_int& ninput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items);
- void set_scalar(double scalar){
- d_scalar = scalar;
- }
+ void set_scalar(double scalar) { d_scalar = scalar; }
- void set_scalar_pmt(pmt::pmt_t msg){
- set_scalar(pmt::to_double(msg));
- }
+ void set_scalar_pmt(pmt::pmt_t msg) { set_scalar(pmt::to_double(msg)); }
+};
- };
-
- } // namespace blocks
+} // namespace blocks
} // namespace gr
#endif
-
diff --git a/gr-blocks/lib/tagged_stream_mux_impl.cc b/gr-blocks/lib/tagged_stream_mux_impl.cc
index 90587639ce..1742340d89 100644
--- a/gr-blocks/lib/tagged_stream_mux_impl.cc
+++ b/gr-blocks/lib/tagged_stream_mux_impl.cc
@@ -28,73 +28,71 @@
#include "tagged_stream_mux_impl.h"
namespace gr {
- namespace blocks {
+namespace blocks {
- tagged_stream_mux::sptr
- tagged_stream_mux::make(size_t itemsize, const std::string &lengthtagname,
- unsigned int tag_preserve_head_pos)
- {
- return gnuradio::get_initial_sptr
- (new tagged_stream_mux_impl(itemsize, lengthtagname,
- tag_preserve_head_pos));
- }
+tagged_stream_mux::sptr tagged_stream_mux::make(size_t itemsize,
+ const std::string& lengthtagname,
+ unsigned int tag_preserve_head_pos)
+{
+ return gnuradio::get_initial_sptr(
+ new tagged_stream_mux_impl(itemsize, lengthtagname, tag_preserve_head_pos));
+}
- tagged_stream_mux_impl::tagged_stream_mux_impl(size_t itemsize, const std::string &lengthtagname,
- unsigned int tag_preserve_head_pos)
- : tagged_stream_block("tagged_stream_mux",
- io_signature::make(1, -1, itemsize),
- io_signature::make(1, 1, itemsize),
- lengthtagname),
- d_itemsize(itemsize),
- d_tag_preserve_head_pos(tag_preserve_head_pos)
- {
- set_tag_propagation_policy(TPP_DONT);
- }
+tagged_stream_mux_impl::tagged_stream_mux_impl(size_t itemsize,
+ const std::string& lengthtagname,
+ unsigned int tag_preserve_head_pos)
+ : tagged_stream_block("tagged_stream_mux",
+ io_signature::make(1, -1, itemsize),
+ io_signature::make(1, 1, itemsize),
+ lengthtagname),
+ d_itemsize(itemsize),
+ d_tag_preserve_head_pos(tag_preserve_head_pos)
+{
+ set_tag_propagation_policy(TPP_DONT);
+}
- tagged_stream_mux_impl::~tagged_stream_mux_impl()
- {
- }
+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::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;
+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((uint64_t)ninput_items.size(), 1);
+ set_relative_rate((uint64_t)ninput_items.size(), 1);
- for (unsigned int i = 0; i < input_items.size(); i++) {
- const unsigned char *in = (const unsigned char *) input_items[i];
+ for (unsigned int i = 0; i < input_items.size(); i++) {
+ const unsigned char* in = (const unsigned char*)input_items[i];
- std::vector<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++) {
- uint64_t offset = tags[j].offset - nitems_read(i) + nitems_written(0) + n_produced;
- if (i == d_tag_preserve_head_pos && tags[j].offset == nitems_read(i)) {
- offset -= 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;
+ std::vector<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++) {
+ uint64_t offset =
+ tags[j].offset - nitems_read(i) + nitems_written(0) + n_produced;
+ if (i == d_tag_preserve_head_pos && tags[j].offset == nitems_read(i)) {
+ offset -= 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];
}
- } /* namespace blocks */
+ 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
index 3a61956a07..03804a6253 100644
--- a/gr-blocks/lib/tagged_stream_mux_impl.h
+++ b/gr-blocks/lib/tagged_stream_mux_impl.h
@@ -27,29 +27,30 @@
#include <gnuradio/blocks/tagged_stream_mux.h>
namespace gr {
- namespace blocks {
-
- class tagged_stream_mux_impl : public tagged_stream_mux
- {
- private:
- size_t d_itemsize;
- unsigned int d_tag_preserve_head_pos;
-
- protected:
- int calculate_output_stream_length(const gr_vector_int &ninput_items);
-
- public:
- tagged_stream_mux_impl(size_t itemsize, const std::string &lengthtagname, unsigned int d_tag_preserve_head_pos);
- ~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 blocks {
+
+class tagged_stream_mux_impl : public tagged_stream_mux
+{
+private:
+ size_t d_itemsize;
+ unsigned int d_tag_preserve_head_pos;
+
+protected:
+ int calculate_output_stream_length(const gr_vector_int& ninput_items);
+
+public:
+ tagged_stream_mux_impl(size_t itemsize,
+ const std::string& lengthtagname,
+ unsigned int d_tag_preserve_head_pos);
+ ~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
index feada488c7..6411ad0c41 100644
--- a/gr-blocks/lib/tagged_stream_to_pdu_impl.cc
+++ b/gr-blocks/lib/tagged_stream_to_pdu_impl.cc
@@ -29,52 +29,50 @@
#include <gnuradio/io_signature.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- tagged_stream_to_pdu::sptr
- tagged_stream_to_pdu::make(pdu::vector_type type, const std::string& lengthtagname)
- {
- return gnuradio::get_initial_sptr(new tagged_stream_to_pdu_impl(type, lengthtagname));
- }
+tagged_stream_to_pdu::sptr tagged_stream_to_pdu::make(pdu::vector_type type,
+ const std::string& lengthtagname)
+{
+ return gnuradio::get_initial_sptr(new tagged_stream_to_pdu_impl(type, lengthtagname));
+}
- tagged_stream_to_pdu_impl::tagged_stream_to_pdu_impl(pdu::vector_type type, const std::string& lengthtagname)
- : tagged_stream_block("tagged_stream_to_pdu",
- io_signature::make(1, 1, pdu::itemsize(type)),
- io_signature::make(0, 0, 0), lengthtagname),
- d_type(type),
- d_pdu_meta(pmt::PMT_NIL),
- d_pdu_vector(pmt::PMT_NIL)
- {
- message_port_register_out(pdu::pdu_port_id());
- }
+tagged_stream_to_pdu_impl::tagged_stream_to_pdu_impl(pdu::vector_type type,
+ const std::string& lengthtagname)
+ : tagged_stream_block("tagged_stream_to_pdu",
+ io_signature::make(1, 1, pdu::itemsize(type)),
+ io_signature::make(0, 0, 0),
+ lengthtagname),
+ d_type(type),
+ d_pdu_meta(pmt::PMT_NIL),
+ d_pdu_vector(pmt::PMT_NIL)
+{
+ message_port_register_out(pdu::pdu_port_id());
+}
- int
- tagged_stream_to_pdu_impl::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];
+int tagged_stream_to_pdu_impl::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];
- // Grab tags, throw them into dict
- get_tags_in_range(d_tags, 0,
- nitems_read(0),
- nitems_read(0) + ninput_items[0]
- );
- d_pdu_meta = pmt::make_dict();
- for (d_tags_itr = d_tags.begin(); d_tags_itr != d_tags.end(); d_tags_itr++) {
- d_pdu_meta = dict_add(d_pdu_meta, (*d_tags_itr).key, (*d_tags_itr).value);
- }
+ // Grab tags, throw them into dict
+ get_tags_in_range(d_tags, 0, nitems_read(0), nitems_read(0) + ninput_items[0]);
+ d_pdu_meta = pmt::make_dict();
+ for (d_tags_itr = d_tags.begin(); d_tags_itr != d_tags.end(); d_tags_itr++) {
+ d_pdu_meta = dict_add(d_pdu_meta, (*d_tags_itr).key, (*d_tags_itr).value);
+ }
- // Grab data, throw into vector
- d_pdu_vector = pdu::make_pdu_vector(d_type, in, ninput_items[0]);
+ // Grab data, throw into vector
+ d_pdu_vector = pdu::make_pdu_vector(d_type, in, ninput_items[0]);
- // Send msg
- pmt::pmt_t msg = pmt::cons(d_pdu_meta, d_pdu_vector);
- message_port_pub(pdu::pdu_port_id(), msg);
+ // Send msg
+ pmt::pmt_t msg = pmt::cons(d_pdu_meta, d_pdu_vector);
+ message_port_pub(pdu::pdu_port_id(), msg);
- return ninput_items[0];
- }
+ return ninput_items[0];
+}
- } /* namespace blocks */
+} /* 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
index 2c3a7ca44a..1894aad7c3 100644
--- a/gr-blocks/lib/tagged_stream_to_pdu_impl.h
+++ b/gr-blocks/lib/tagged_stream_to_pdu_impl.h
@@ -26,27 +26,26 @@
#include <gnuradio/blocks/tagged_stream_to_pdu.h>
namespace gr {
- namespace blocks {
-
- class BLOCKS_API tagged_stream_to_pdu_impl : public tagged_stream_to_pdu
- {
- pdu::vector_type d_type;
- pmt::pmt_t d_pdu_meta;
- pmt::pmt_t d_pdu_vector;
- std::vector<tag_t>::iterator d_tags_itr;
- std::vector<tag_t> d_tags;
-
- public:
- tagged_stream_to_pdu_impl(pdu::vector_type type, const std::string& lengthtagname);
-
- 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 blocks {
+
+class BLOCKS_API tagged_stream_to_pdu_impl : public tagged_stream_to_pdu
+{
+ pdu::vector_type d_type;
+ pmt::pmt_t d_pdu_meta;
+ pmt::pmt_t d_pdu_vector;
+ std::vector<tag_t>::iterator d_tags_itr;
+ std::vector<tag_t> d_tags;
+
+public:
+ tagged_stream_to_pdu_impl(pdu::vector_type type, const std::string& lengthtagname);
+
+ 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/tags_strobe_impl.cc b/gr-blocks/lib/tags_strobe_impl.cc
index f821cefccd..51391fb082 100644
--- a/gr-blocks/lib/tags_strobe_impl.cc
+++ b/gr-blocks/lib/tags_strobe_impl.cc
@@ -36,72 +36,59 @@
#include <iostream>
namespace gr {
- namespace blocks {
+namespace blocks {
- tags_strobe::sptr
- tags_strobe::make(size_t sizeof_stream_item,
- pmt::pmt_t value, uint64_t nsamps, pmt::pmt_t key)
- {
- return gnuradio::get_initial_sptr
- (new tags_strobe_impl(sizeof_stream_item, value, nsamps, key));
- }
+tags_strobe::sptr tags_strobe::make(size_t sizeof_stream_item,
+ pmt::pmt_t value,
+ uint64_t nsamps,
+ pmt::pmt_t key)
+{
+ return gnuradio::get_initial_sptr(
+ new tags_strobe_impl(sizeof_stream_item, value, nsamps, key));
+}
- tags_strobe_impl::tags_strobe_impl(size_t sizeof_stream_item,
- pmt::pmt_t value, uint64_t nsamps,
- pmt::pmt_t key)
- : sync_block("tags_strobe",
- io_signature::make(0, 0, 0),
- io_signature::make(1, 1, sizeof_stream_item)),
- d_itemsize(sizeof_stream_item)
- {
- d_tag.offset = 0;
- d_tag.key = pmt::intern("strobe");
- d_tag.srcid = alias_pmt();
- set_value(value);
- set_key(key);
- set_nsamps(nsamps);
- d_offset = 0;
- }
+tags_strobe_impl::tags_strobe_impl(size_t sizeof_stream_item,
+ pmt::pmt_t value,
+ uint64_t nsamps,
+ pmt::pmt_t key)
+ : sync_block("tags_strobe",
+ io_signature::make(0, 0, 0),
+ io_signature::make(1, 1, sizeof_stream_item)),
+ d_itemsize(sizeof_stream_item)
+{
+ d_tag.offset = 0;
+ d_tag.key = pmt::intern("strobe");
+ d_tag.srcid = alias_pmt();
+ set_value(value);
+ set_key(key);
+ set_nsamps(nsamps);
+ d_offset = 0;
+}
- tags_strobe_impl::~tags_strobe_impl()
- {
- }
+tags_strobe_impl::~tags_strobe_impl() {}
- void
- tags_strobe_impl::set_value(pmt::pmt_t value)
- {
- d_tag.value = value;
- }
+void tags_strobe_impl::set_value(pmt::pmt_t value) { d_tag.value = value; }
- void
- tags_strobe_impl::set_key(pmt::pmt_t key)
- {
- d_tag.key = key;
- }
+void tags_strobe_impl::set_key(pmt::pmt_t key) { d_tag.key = key; }
- void
- tags_strobe_impl::set_nsamps(uint64_t nsamps)
- {
- d_nsamps = nsamps;
- }
+void tags_strobe_impl::set_nsamps(uint64_t nsamps) { d_nsamps = nsamps; }
- int
- tags_strobe_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 * d_itemsize);
+int tags_strobe_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 * d_itemsize);
- uint64_t nitems = static_cast<uint64_t>(noutput_items) + nitems_written(0);
- while((nitems - d_offset) > d_nsamps) {
+ uint64_t nitems = static_cast<uint64_t>(noutput_items) + nitems_written(0);
+ while ((nitems - d_offset) > d_nsamps) {
d_offset += d_nsamps;
d_tag.offset = d_offset;
add_item_tag(0, d_tag);
- }
-
- return noutput_items;
}
- } /* namespace blocks */
+ return noutput_items;
+}
+
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/tags_strobe_impl.h b/gr-blocks/lib/tags_strobe_impl.h
index e99d3e1b44..2d0537de26 100644
--- a/gr-blocks/lib/tags_strobe_impl.h
+++ b/gr-blocks/lib/tags_strobe_impl.h
@@ -26,37 +26,38 @@
#include <gnuradio/blocks/tags_strobe.h>
namespace gr {
- namespace blocks {
-
- class BLOCKS_API tags_strobe_impl : public tags_strobe
- {
- private:
- size_t d_itemsize;
- uint64_t d_nsamps;
- tag_t d_tag;
- uint64_t d_offset;
-
- void run();
-
- public:
- tags_strobe_impl(size_t sizeof_stream_item,
- pmt::pmt_t value, uint64_t nsamps,
- pmt::pmt_t key);
- ~tags_strobe_impl();
-
- void set_value(pmt::pmt_t value);
- void set_key(pmt::pmt_t key);
- pmt::pmt_t value() const { return d_tag.value; }
- pmt::pmt_t key() const { return d_tag.key; }
- void set_nsamps(uint64_t nsamps);
- uint64_t nsamps() const { return d_nsamps; }
-
- int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
- };
-
- } /* namespace blocks */
+namespace blocks {
+
+class BLOCKS_API tags_strobe_impl : public tags_strobe
+{
+private:
+ size_t d_itemsize;
+ uint64_t d_nsamps;
+ tag_t d_tag;
+ uint64_t d_offset;
+
+ void run();
+
+public:
+ tags_strobe_impl(size_t sizeof_stream_item,
+ pmt::pmt_t value,
+ uint64_t nsamps,
+ pmt::pmt_t key);
+ ~tags_strobe_impl();
+
+ void set_value(pmt::pmt_t value);
+ void set_key(pmt::pmt_t key);
+ pmt::pmt_t value() const { return d_tag.value; }
+ pmt::pmt_t key() const { return d_tag.key; }
+ void set_nsamps(uint64_t nsamps);
+ uint64_t nsamps() const { return d_nsamps; }
+
+ 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_TAGS_STROBE_IMPL_H */
diff --git a/gr-blocks/lib/tcp_connection.cc b/gr-blocks/lib/tcp_connection.cc
index 4c0dfc27ac..bef89fb523 100644
--- a/gr-blocks/lib/tcp_connection.cc
+++ b/gr-blocks/lib/tcp_connection.cc
@@ -29,83 +29,90 @@
#include <gnuradio/blocks/pdu.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- tcp_connection::sptr tcp_connection::make(boost::asio::io_service& io_service, int MTU/*= 10000*/, bool no_delay/*=false*/)
- {
- return sptr(new tcp_connection(io_service, MTU, no_delay));
- }
+tcp_connection::sptr tcp_connection::make(boost::asio::io_service& io_service,
+ int MTU /*= 10000*/,
+ bool no_delay /*=false*/)
+{
+ return sptr(new tcp_connection(io_service, MTU, no_delay));
+}
- tcp_connection::tcp_connection(boost::asio::io_service& io_service, int MTU/*= 10000*/, bool no_delay/*=false*/)
- : d_socket(io_service)
- , d_block(NULL)
- , d_no_delay(no_delay)
- {
- d_buf.resize(MTU);
- try {
+tcp_connection::tcp_connection(boost::asio::io_service& io_service,
+ int MTU /*= 10000*/,
+ bool no_delay /*=false*/)
+ : d_socket(io_service), d_block(NULL), d_no_delay(no_delay)
+{
+ d_buf.resize(MTU);
+ try {
d_socket.set_option(boost::asio::ip::tcp::no_delay(no_delay));
- }
- catch (...) {
- // Silently ignore failure (socket might be current in accept stage) and try again in 'start'
- }
+ } catch (...) {
+ // Silently ignore failure (socket might be current in accept stage) and try again
+ // in 'start'
}
+}
- void
- tcp_connection::send(pmt::pmt_t vector)
- {
- size_t len = pmt::blob_length(vector);
+void tcp_connection::send(pmt::pmt_t vector)
+{
+ size_t len = pmt::blob_length(vector);
- // Asio async_write() requires the buffer to remain valid until the handler is called.
- boost::shared_ptr<char[]> txbuf(new char[len]);
+ // Asio async_write() requires the buffer to remain valid until the handler is called.
+ boost::shared_ptr<char[]> txbuf(new char[len]);
- size_t temp = 0;
- memcpy(txbuf.get(), pmt::uniform_vector_elements(vector, temp), len);
+ size_t temp = 0;
+ memcpy(txbuf.get(), pmt::uniform_vector_elements(vector, temp), len);
- size_t offset = 0;
- while (offset < len) {
+ size_t offset = 0;
+ while (offset < len) {
// Limit the size of each write() to the MTU.
- // FIXME: Note that this has the effect of breaking a large PDU into several smaller PDUs, each
- // containing <= MTU bytes. Is this the desired behavior?
+ // FIXME: Note that this has the effect of breaking a large PDU into several
+ // smaller PDUs, each containing <= MTU bytes. Is this the desired behavior?
size_t send_len = std::min((len - offset), d_buf.size());
- boost::asio::async_write(d_socket, boost::asio::buffer(txbuf.get() + offset, send_len),
- boost::bind(&tcp_connection::handle_write, this, txbuf,
- boost::asio::placeholders::error,
- boost::asio::placeholders::bytes_transferred));
+ boost::asio::async_write(
+ d_socket,
+ boost::asio::buffer(txbuf.get() + offset, send_len),
+ boost::bind(&tcp_connection::handle_write,
+ this,
+ txbuf,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred));
offset += send_len;
- }
}
+}
- void
- tcp_connection::start(gr::basic_block *block)
- {
- d_block = block;
- d_socket.set_option(boost::asio::ip::tcp::no_delay(d_no_delay));
- 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::start(gr::basic_block* block)
+{
+ d_block = block;
+ d_socket.set_option(boost::asio::ip::tcp::no_delay(d_no_delay));
+ 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) {
+void tcp_connection::handle_read(const boost::system::error_code& error,
+ size_t bytes_transferred)
+{
+ if (!error) {
if (d_block) {
- pmt::pmt_t vector = pmt::init_u8vector(bytes_transferred, (const uint8_t*)&d_buf[0]);
- pmt::pmt_t pdu = pmt::cons(pmt::PMT_NIL, vector);
+ pmt::pmt_t vector =
+ pmt::init_u8vector(bytes_transferred, (const uint8_t*)&d_buf[0]);
+ pmt::pmt_t pdu = pmt::cons(pmt::PMT_NIL, vector);
- d_block->message_port_pub(pdu::pdu_port_id(), pdu);
+ d_block->message_port_pub(pdu::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));
- }
- else {
+ 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));
+ } else {
d_socket.shutdown(boost::asio::ip::tcp::socket::shutdown_both);
d_socket.close();
- }
}
- } /* namespace blocks */
-}/* namespace gr */
+}
+} /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/tcp_connection.h b/gr-blocks/lib/tcp_connection.h
index eb4c0df285..4c5a67c54b 100644
--- a/gr-blocks/lib/tcp_connection.h
+++ b/gr-blocks/lib/tcp_connection.h
@@ -30,35 +30,41 @@
namespace gr {
- class basic_block;
+class basic_block;
- namespace blocks {
+namespace blocks {
- class tcp_connection
- {
- private:
- boost::asio::ip::tcp::socket d_socket;
- std::vector<char> d_buf;
- basic_block *d_block;
- bool d_no_delay;
+class tcp_connection
+{
+private:
+ boost::asio::ip::tcp::socket d_socket;
+ std::vector<char> d_buf;
+ basic_block* d_block;
+ bool d_no_delay;
- tcp_connection(boost::asio::io_service& io_service, int MTU=10000, bool no_delay=false);
+ tcp_connection(boost::asio::io_service& io_service,
+ int MTU = 10000,
+ bool no_delay = false);
- public:
- typedef boost::shared_ptr<tcp_connection> sptr;
+public:
+ typedef boost::shared_ptr<tcp_connection> sptr;
- static sptr make(boost::asio::io_service& io_service, int MTU=10000, bool no_delay=false);
+ static sptr
+ make(boost::asio::io_service& io_service, int MTU = 10000, bool no_delay = false);
- boost::asio::ip::tcp::socket& socket() { return d_socket; };
+ 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(boost::shared_ptr<char[]> txbuf, const boost::system::error_code& error,
- size_t bytes_transferred) { }
- };
+ 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(boost::shared_ptr<char[]> txbuf,
+ const boost::system::error_code& error,
+ size_t bytes_transferred)
+ {
+ }
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_TCP_CONNECTION_H */
diff --git a/gr-blocks/lib/tcp_server_sink_impl.cc b/gr-blocks/lib/tcp_server_sink_impl.cc
index 44f0765cb2..dd6a9d2e44 100644
--- a/gr-blocks/lib/tcp_server_sink_impl.cc
+++ b/gr-blocks/lib/tcp_server_sink_impl.cc
@@ -36,126 +36,130 @@
#include <string.h>
namespace gr {
- namespace blocks {
-
- tcp_server_sink::sptr
- tcp_server_sink::make(size_t itemsize,
- const std::string &host, int port,
- bool noblock)
- {
- return gnuradio::get_initial_sptr
- (new tcp_server_sink_impl(itemsize, host, port, noblock));
- }
-
- tcp_server_sink_impl::tcp_server_sink_impl(size_t itemsize,
- const std::string &host, int port,
- bool noblock)
- : sync_block("tcp_server_sink",
- io_signature::make(1, 1, itemsize),
- io_signature::make(0, 0, 0)),
+namespace blocks {
+
+tcp_server_sink::sptr
+tcp_server_sink::make(size_t itemsize, const std::string& host, int port, bool noblock)
+{
+ return gnuradio::get_initial_sptr(
+ new tcp_server_sink_impl(itemsize, host, port, noblock));
+}
+
+tcp_server_sink_impl::tcp_server_sink_impl(size_t itemsize,
+ const std::string& host,
+ int port,
+ bool noblock)
+ : sync_block("tcp_server_sink",
+ io_signature::make(1, 1, itemsize),
+ io_signature::make(0, 0, 0)),
d_itemsize(itemsize),
d_acceptor(d_io_service),
d_buf(new uint8_t[BUF_SIZE]),
d_writing(0)
- {
- std::string s__port = (boost::format("%d") % port).str();
- std::string s__host = host.empty() ? std::string("localhost") : host;
- boost::asio::ip::tcp::resolver resolver(d_io_service);
- boost::asio::ip::tcp::resolver::query query(s__host, s__port,
- boost::asio::ip::resolver_query_base::passive);
- d_endpoint = *resolver.resolve(query);
-
- d_acceptor.open(d_endpoint.protocol());
- d_acceptor.set_option(boost::asio::ip::tcp::acceptor::reuse_address(true));
- d_acceptor.bind(d_endpoint);
- d_acceptor.listen();
-
- if (!noblock) {
- d_socket.reset(new boost::asio::ip::tcp::socket(d_io_service));
- d_acceptor.accept(*d_socket, d_endpoint);
- d_sockets.insert(d_socket.release());
- }
-
+{
+ std::string s__port = (boost::format("%d") % port).str();
+ std::string s__host = host.empty() ? std::string("localhost") : host;
+ boost::asio::ip::tcp::resolver resolver(d_io_service);
+ boost::asio::ip::tcp::resolver::query query(
+ s__host, s__port, boost::asio::ip::resolver_query_base::passive);
+ d_endpoint = *resolver.resolve(query);
+
+ d_acceptor.open(d_endpoint.protocol());
+ d_acceptor.set_option(boost::asio::ip::tcp::acceptor::reuse_address(true));
+ d_acceptor.bind(d_endpoint);
+ d_acceptor.listen();
+
+ if (!noblock) {
d_socket.reset(new boost::asio::ip::tcp::socket(d_io_service));
- d_acceptor.async_accept(*d_socket, boost::bind(&tcp_server_sink_impl::do_accept,
- this, boost::asio::placeholders::error));
- d_io_serv_thread = boost::thread(
- boost::bind(&boost::asio::io_service::run, &d_io_service));
- }
-
- void
- tcp_server_sink_impl::do_accept(const boost::system::error_code& error)
- {
- if (!error) {
+ d_acceptor.accept(*d_socket, d_endpoint);
+ d_sockets.insert(d_socket.release());
+ }
+
+ d_socket.reset(new boost::asio::ip::tcp::socket(d_io_service));
+ d_acceptor.async_accept(*d_socket,
+ boost::bind(&tcp_server_sink_impl::do_accept,
+ this,
+ boost::asio::placeholders::error));
+ d_io_serv_thread =
+ boost::thread(boost::bind(&boost::asio::io_service::run, &d_io_service));
+}
+
+void tcp_server_sink_impl::do_accept(const boost::system::error_code& error)
+{
+ if (!error) {
gr::thread::scoped_lock guard(d_writing_mut);
d_sockets.insert(d_socket.release());
d_socket.reset(new boost::asio::ip::tcp::socket(d_io_service));
- d_acceptor.async_accept(*d_socket, boost::bind(&tcp_server_sink_impl::do_accept,
- this, boost::asio::placeholders::error));
- }
+ d_acceptor.async_accept(*d_socket,
+ boost::bind(&tcp_server_sink_impl::do_accept,
+ this,
+ boost::asio::placeholders::error));
}
+}
- void
- tcp_server_sink_impl::do_write(const boost::system::error_code& error,
- size_t len, std::set<boost::asio::ip::tcp::socket *>::iterator i)
+void tcp_server_sink_impl::do_write(const boost::system::error_code& error,
+ size_t len,
+ std::set<boost::asio::ip::tcp::socket*>::iterator i)
+{
{
- {
gr::thread::scoped_lock guard(d_writing_mut);
--d_writing;
if (error) {
- delete *i;
- d_sockets.erase(i);
+ delete *i;
+ d_sockets.erase(i);
}
- }
- d_writing_cond.notify_one();
}
+ d_writing_cond.notify_one();
+}
- tcp_server_sink_impl::~tcp_server_sink_impl()
- {
- gr::thread::scoped_lock guard(d_writing_mut);
- while (d_writing) {
+tcp_server_sink_impl::~tcp_server_sink_impl()
+{
+ gr::thread::scoped_lock guard(d_writing_mut);
+ while (d_writing) {
d_writing_cond.wait(guard);
- }
+ }
- for (std::set<boost::asio::ip::tcp::socket *>::iterator i = d_sockets.begin();
- i != d_sockets.end(); ++i ) {
+ for (std::set<boost::asio::ip::tcp::socket*>::iterator i = d_sockets.begin();
+ i != d_sockets.end();
+ ++i) {
delete *i;
- }
- d_sockets.clear();
-
- d_io_service.reset();
- d_io_service.stop();
- d_io_serv_thread.join();
}
+ d_sockets.clear();
- int
- tcp_server_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];
+ d_io_service.reset();
+ d_io_service.stop();
+ d_io_serv_thread.join();
+}
- gr::thread::scoped_lock guard(d_writing_mut);
- while (d_writing) {
+int tcp_server_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];
+
+ gr::thread::scoped_lock guard(d_writing_mut);
+ while (d_writing) {
d_writing_cond.wait(guard);
- }
-
- size_t data_len = std::min(size_t(BUF_SIZE), noutput_items * d_itemsize);
- data_len -= data_len % d_itemsize;
- memcpy(d_buf.get(), in, data_len);
- for (std::set<boost::asio::ip::tcp::socket *>::iterator i = d_sockets.begin();
- i != d_sockets.end(); ++i ) {
- boost::asio::async_write(**i, boost::asio::buffer(d_buf.get(), data_len),
- boost::bind(&tcp_server_sink_impl::do_write, this,
- boost::asio::placeholders::error,
- boost::asio::placeholders::bytes_transferred,
- i));
- }
- d_writing = d_sockets.size();
-
- return data_len / d_itemsize;
}
- } /* namespace blocks */
-} /* namespace gr */
+ size_t data_len = std::min(size_t(BUF_SIZE), noutput_items * d_itemsize);
+ data_len -= data_len % d_itemsize;
+ memcpy(d_buf.get(), in, data_len);
+ for (std::set<boost::asio::ip::tcp::socket*>::iterator i = d_sockets.begin();
+ i != d_sockets.end();
+ ++i) {
+ boost::asio::async_write(**i,
+ boost::asio::buffer(d_buf.get(), data_len),
+ boost::bind(&tcp_server_sink_impl::do_write,
+ this,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ i));
+ }
+ d_writing = d_sockets.size();
+
+ return data_len / d_itemsize;
+}
+} /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/tcp_server_sink_impl.h b/gr-blocks/lib/tcp_server_sink_impl.h
index db26b705fe..6c4b0f938f 100644
--- a/gr-blocks/lib/tcp_server_sink_impl.h
+++ b/gr-blocks/lib/tcp_server_sink_impl.h
@@ -29,45 +29,47 @@
#include <boost/ptr_container/ptr_vector.hpp>
namespace gr {
- namespace blocks {
+namespace blocks {
- class tcp_server_sink_impl : public tcp_server_sink
- {
- private:
- size_t d_itemsize;
+class tcp_server_sink_impl : public tcp_server_sink
+{
+private:
+ size_t d_itemsize;
- boost::asio::io_service d_io_service;
- gr::thread::thread d_io_serv_thread;
- boost::asio::ip::tcp::endpoint d_endpoint;
- std::unique_ptr<boost::asio::ip::tcp::socket> d_socket;
- std::set<boost::asio::ip::tcp::socket *> d_sockets;
- boost::asio::ip::tcp::acceptor d_acceptor;
+ boost::asio::io_service d_io_service;
+ gr::thread::thread d_io_serv_thread;
+ boost::asio::ip::tcp::endpoint d_endpoint;
+ std::unique_ptr<boost::asio::ip::tcp::socket> d_socket;
+ std::set<boost::asio::ip::tcp::socket*> d_sockets;
+ boost::asio::ip::tcp::acceptor d_acceptor;
- boost::shared_ptr<uint8_t[]> d_buf;
- enum {
- BUF_SIZE = 256 * 1024,
- };
+ boost::shared_ptr<uint8_t[]> d_buf;
+ enum {
+ BUF_SIZE = 256 * 1024,
+ };
- int d_writing;
- boost::condition_variable d_writing_cond;
- boost::mutex d_writing_mut;
+ int d_writing;
+ boost::condition_variable d_writing_cond;
+ boost::mutex d_writing_mut;
- void do_accept(const boost::system::error_code& error);
- void do_write(const boost::system::error_code& error, std::size_t len,
- std::set<boost::asio::ip::tcp::socket *>::iterator);
+ void do_accept(const boost::system::error_code& error);
+ void do_write(const boost::system::error_code& error,
+ std::size_t len,
+ std::set<boost::asio::ip::tcp::socket*>::iterator);
- public:
- tcp_server_sink_impl(size_t itemsize,
- const std::string &host, int port,
- bool noblock);
- ~tcp_server_sink_impl();
+public:
+ tcp_server_sink_impl(size_t itemsize,
+ const std::string& host,
+ int port,
+ bool noblock);
+ ~tcp_server_sink_impl();
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_GR_TCP_SERVER_SINK_IMPL_H */
diff --git a/gr-blocks/lib/test_tag_variable_rate_ff_impl.cc b/gr-blocks/lib/test_tag_variable_rate_ff_impl.cc
index cc9e1eeab9..5a825710e6 100644
--- a/gr-blocks/lib/test_tag_variable_rate_ff_impl.cc
+++ b/gr-blocks/lib/test_tag_variable_rate_ff_impl.cc
@@ -36,106 +36,103 @@
using namespace pmt;
namespace gr {
- namespace blocks {
-
- test_tag_variable_rate_ff::sptr
- test_tag_variable_rate_ff::make(bool update_once, double update_step)
- {
- return gnuradio::get_initial_sptr
- (new test_tag_variable_rate_ff_impl(update_once, update_step));
- }
-
- test_tag_variable_rate_ff_impl::test_tag_variable_rate_ff_impl(bool update_once, double update_step)
- : block("test_tag_variable_rate_ff",
- io_signature::make(1, 1, sizeof(float)),
- io_signature::make(1, 1, sizeof(float))),
- d_update_once(update_once), d_update_step(update_step)
- {
- set_tag_propagation_policy(TPP_DONT);
- set_relative_rate(1, 2);
- d_accum = 0;
- d_rrate = 0.5;
- d_old_in = 0;
- d_new_in = 0;
- d_last_out = 0;
-
- xoroshiro128p_seed(d_rng_state, 4 /* chosen by fair dice roll */);
- }
-
- test_tag_variable_rate_ff_impl::~test_tag_variable_rate_ff_impl()
- {
- }
-
- int
- test_tag_variable_rate_ff_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 float *in = (const float*)input_items[0];
- float *out = (float*)output_items[0];
-
- GR_LOG_DEBUG(d_logger, "\n");
- GR_LOG_DEBUG(d_logger, boost::format("ninput_items: %1%") % ninput_items[0]);
- GR_LOG_DEBUG(d_logger, boost::format("noutput_items: %1%") % noutput_items);
-
- if(d_update_once) {
- if (xoroshiro128p_next(d_rng_state) > (UINT64_MAX / 2)){
- d_rrate += d_update_step;
- }
- else {
- d_rrate -= d_update_step;
- if(d_rrate < d_update_step)
- d_rrate = d_update_step;
+namespace blocks {
+
+test_tag_variable_rate_ff::sptr test_tag_variable_rate_ff::make(bool update_once,
+ double update_step)
+{
+ return gnuradio::get_initial_sptr(
+ new test_tag_variable_rate_ff_impl(update_once, update_step));
+}
+
+test_tag_variable_rate_ff_impl::test_tag_variable_rate_ff_impl(bool update_once,
+ double update_step)
+ : block("test_tag_variable_rate_ff",
+ io_signature::make(1, 1, sizeof(float)),
+ io_signature::make(1, 1, sizeof(float))),
+ d_update_once(update_once),
+ d_update_step(update_step)
+{
+ set_tag_propagation_policy(TPP_DONT);
+ set_relative_rate(1, 2);
+ d_accum = 0;
+ d_rrate = 0.5;
+ d_old_in = 0;
+ d_new_in = 0;
+ d_last_out = 0;
+
+ xoroshiro128p_seed(d_rng_state, 4 /* chosen by fair dice roll */);
+}
+
+test_tag_variable_rate_ff_impl::~test_tag_variable_rate_ff_impl() {}
+
+int test_tag_variable_rate_ff_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 float* in = (const float*)input_items[0];
+ float* out = (float*)output_items[0];
+
+ GR_LOG_DEBUG(d_logger, "\n");
+ GR_LOG_DEBUG(d_logger, boost::format("ninput_items: %1%") % ninput_items[0]);
+ GR_LOG_DEBUG(d_logger, boost::format("noutput_items: %1%") % noutput_items);
+
+ if (d_update_once) {
+ if (xoroshiro128p_next(d_rng_state) > (UINT64_MAX / 2)) {
+ d_rrate += d_update_step;
+ } else {
+ d_rrate -= d_update_step;
+ if (d_rrate < d_update_step)
+ d_rrate = d_update_step;
}
- }
+ }
- std::vector<tag_t> tags;
- std::vector<tag_t>::iterator itags;
+ std::vector<tag_t> tags;
+ std::vector<tag_t>::iterator itags;
- int i = 0, j = 0;
- while(i < ninput_items[0]) {
+ int i = 0, j = 0;
+ while (i < ninput_items[0]) {
- if(!d_update_once) {
- if (xoroshiro128p_next(d_rng_state) > (UINT64_MAX / 2)){
- d_rrate += d_update_step;
- }
- else {
- d_rrate -= d_update_step;
- if(d_rrate < d_update_step)
- d_rrate = d_update_step;
- }
+ if (!d_update_once) {
+ if (xoroshiro128p_next(d_rng_state) > (UINT64_MAX / 2)) {
+ d_rrate += d_update_step;
+ } else {
+ d_rrate -= d_update_step;
+ if (d_rrate < d_update_step)
+ d_rrate = d_update_step;
+ }
}
d_accum += d_rrate;
- if(d_accum >= 1.0) {
- out[j] = in[i];
-
- // Manage Tags
- d_new_in = nitems_read(0) + i;
- get_tags_in_range(tags, 0, d_old_in, d_new_in);
- for(itags = tags.begin(); itags != tags.end(); itags++) {
- tag_t new_tag = *itags;
- new_tag.offset = d_last_out;
- add_item_tag(0, new_tag);
- }
- d_old_in = d_new_in;
- d_last_out = nitems_written(0) + j;
-
- // Book keeping
- j++;
- d_accum -= 1.0;
+ if (d_accum >= 1.0) {
+ out[j] = in[i];
+
+ // Manage Tags
+ d_new_in = nitems_read(0) + i;
+ get_tags_in_range(tags, 0, d_old_in, d_new_in);
+ for (itags = tags.begin(); itags != tags.end(); itags++) {
+ tag_t new_tag = *itags;
+ new_tag.offset = d_last_out;
+ add_item_tag(0, new_tag);
+ }
+ d_old_in = d_new_in;
+ d_last_out = nitems_written(0) + j;
+
+ // Book keeping
+ j++;
+ d_accum -= 1.0;
}
i++;
- }
+ }
- GR_LOG_DEBUG(d_logger, boost::format("consuming: %1%") % i);
- GR_LOG_DEBUG(d_logger, boost::format("producing: %1%") % j);
- GR_LOG_DEBUG(d_logger, boost::format("block's rel rate: %1%") % d_rrate);
+ GR_LOG_DEBUG(d_logger, boost::format("consuming: %1%") % i);
+ GR_LOG_DEBUG(d_logger, boost::format("producing: %1%") % j);
+ GR_LOG_DEBUG(d_logger, boost::format("block's rel rate: %1%") % d_rrate);
- consume_each(i);
- return j;
- }
+ consume_each(i);
+ return j;
+}
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/test_tag_variable_rate_ff_impl.h b/gr-blocks/lib/test_tag_variable_rate_ff_impl.h
index a02bce1ccf..9bd6468c0a 100644
--- a/gr-blocks/lib/test_tag_variable_rate_ff_impl.h
+++ b/gr-blocks/lib/test_tag_variable_rate_ff_impl.h
@@ -26,32 +26,31 @@
#include <gnuradio/blocks/test_tag_variable_rate_ff.h>
namespace gr {
- namespace blocks {
-
- class test_tag_variable_rate_ff_impl : public test_tag_variable_rate_ff
- {
- protected:
- bool d_update_once;
- double d_update_step;
- double d_accum;
- double d_rrate;
- uint64_t d_old_in, d_new_in, d_last_out;
- uint64_t d_rng_state[2];
-
- public:
- test_tag_variable_rate_ff_impl(bool update_once=false,
- double update_step=0.001);
- ~test_tag_variable_rate_ff_impl();
-
- //void setup_rpc();
-
- 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 blocks {
+
+class test_tag_variable_rate_ff_impl : public test_tag_variable_rate_ff
+{
+protected:
+ bool d_update_once;
+ double d_update_step;
+ double d_accum;
+ double d_rrate;
+ uint64_t d_old_in, d_new_in, d_last_out;
+ uint64_t d_rng_state[2];
+
+public:
+ test_tag_variable_rate_ff_impl(bool update_once = false, double update_step = 0.001);
+ ~test_tag_variable_rate_ff_impl();
+
+ // void setup_rpc();
+
+ 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_TEST_TAG_VARIABLE_RATE_FF_IMPL_H */
diff --git a/gr-blocks/lib/threshold_ff_impl.cc b/gr-blocks/lib/threshold_ff_impl.cc
index 86432de113..3dcaccd44c 100644
--- a/gr-blocks/lib/threshold_ff_impl.cc
+++ b/gr-blocks/lib/threshold_ff_impl.cc
@@ -28,51 +28,45 @@
#include <gnuradio/io_signature.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- threshold_ff::sptr
- threshold_ff::make(float lo, float hi, float initial_state)
- {
- return gnuradio::get_initial_sptr
- (new threshold_ff_impl(lo, hi, initial_state));
- }
+threshold_ff::sptr threshold_ff::make(float lo, float hi, float initial_state)
+{
+ return gnuradio::get_initial_sptr(new threshold_ff_impl(lo, hi, initial_state));
+}
- threshold_ff_impl::threshold_ff_impl(float lo, float hi,
- float initial_state)
- : sync_block("threshold_ff",
- io_signature::make(1, 1, sizeof(float)),
- io_signature::make(1, 1, sizeof(float))),
- d_lo(lo), d_hi(hi), d_last_state(initial_state)
- {
- }
+threshold_ff_impl::threshold_ff_impl(float lo, float hi, float initial_state)
+ : sync_block("threshold_ff",
+ io_signature::make(1, 1, sizeof(float)),
+ io_signature::make(1, 1, sizeof(float))),
+ d_lo(lo),
+ d_hi(hi),
+ d_last_state(initial_state)
+{
+}
- threshold_ff_impl::~threshold_ff_impl()
- {
- }
+threshold_ff_impl::~threshold_ff_impl() {}
- int
- threshold_ff_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];
+int threshold_ff_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];
- for(int i = 0; i < noutput_items; i++) {
- if(in[i] > d_hi) {
- out[i] = 1.0;
- d_last_state = 1.0;
- }
- else if(in[i] < d_lo) {
- out[i] = 0.0;
- d_last_state = 0.0;
- }
- else
- out[i] = d_last_state;
- }
-
- return noutput_items;
+ for (int i = 0; i < noutput_items; i++) {
+ if (in[i] > d_hi) {
+ out[i] = 1.0;
+ d_last_state = 1.0;
+ } else if (in[i] < d_lo) {
+ out[i] = 0.0;
+ d_last_state = 0.0;
+ } else
+ out[i] = d_last_state;
}
- } /* namespace blocks */
+ return noutput_items;
+}
+
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/threshold_ff_impl.h b/gr-blocks/lib/threshold_ff_impl.h
index 13d71c433f..541ba291f4 100644
--- a/gr-blocks/lib/threshold_ff_impl.h
+++ b/gr-blocks/lib/threshold_ff_impl.h
@@ -26,32 +26,31 @@
#include <gnuradio/blocks/threshold_ff.h>
namespace gr {
- namespace blocks {
-
- class threshold_ff_impl : public threshold_ff
- {
- private:
- float d_lo, d_hi; // the constant
- float d_last_state;
-
- public:
- threshold_ff_impl(float lo, float hi,
- float initial_state=0);
- ~threshold_ff_impl();
-
- float lo() const { return d_lo; }
- void set_lo(float lo) { d_lo = lo; }
- float hi() const { return d_hi; }
- void set_hi(float hi) { d_hi = hi; }
- float last_state() const { return d_last_state; }
- void set_last_state(float last_state) { d_last_state = last_state; }
-
- int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
- };
-
- } /* namespace blocks */
+namespace blocks {
+
+class threshold_ff_impl : public threshold_ff
+{
+private:
+ float d_lo, d_hi; // the constant
+ float d_last_state;
+
+public:
+ threshold_ff_impl(float lo, float hi, float initial_state = 0);
+ ~threshold_ff_impl();
+
+ float lo() const { return d_lo; }
+ void set_lo(float lo) { d_lo = lo; }
+ float hi() const { return d_hi; }
+ void set_hi(float hi) { d_hi = hi; }
+ float last_state() const { return d_last_state; }
+ void set_last_state(float last_state) { d_last_state = last_state; }
+
+ 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_THRESHOLD_FF_IMPL_H */
diff --git a/gr-blocks/lib/throttle_impl.cc b/gr-blocks/lib/throttle_impl.cc
index d818ce192b..d5614c5676 100644
--- a/gr-blocks/lib/throttle_impl.cc
+++ b/gr-blocks/lib/throttle_impl.cc
@@ -33,117 +33,114 @@
pmt::pmt_t throttle_rx_rate_pmt(pmt::intern("rx_rate"));
namespace gr {
- namespace blocks {
-
- throttle::sptr
- throttle::make(size_t itemsize, double samples_per_sec, bool ignore_tags)
- {
- return gnuradio::get_initial_sptr
- (new throttle_impl(itemsize, samples_per_sec, ignore_tags));
- }
-
- throttle_impl::throttle_impl(size_t itemsize,
- double samples_per_second,
- bool ignore_tags)
- : sync_block("throttle",
- io_signature::make(1, 1, itemsize),
- io_signature::make(1, 1, itemsize)),
- d_itemsize(itemsize),
- d_ignore_tags(ignore_tags)
- {
- set_sample_rate(samples_per_second);
- }
-
- throttle_impl::~throttle_impl()
- {
- }
-
- bool
- throttle_impl::start()
- {
- d_start = boost::get_system_time();
- d_total_samples = 0;
- return block::start();
- }
-
- void
- throttle_impl::set_sample_rate(double rate)
- {
- //changing the sample rate performs a reset of state params
- d_start = boost::get_system_time();
- d_total_samples = 0;
- d_samps_per_tick = rate/boost::posix_time::time_duration::ticks_per_second();
- d_samps_per_us = rate/1e6;
- }
-
- double
- throttle_impl::sample_rate() const
- {
- return d_samps_per_us * 1e6;
- }
-
- int
- throttle_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- // check for updated rx_rate tag
- if(!d_ignore_tags){
+namespace blocks {
+
+throttle::sptr throttle::make(size_t itemsize, double samples_per_sec, bool ignore_tags)
+{
+ return gnuradio::get_initial_sptr(
+ new throttle_impl(itemsize, samples_per_sec, ignore_tags));
+}
+
+throttle_impl::throttle_impl(size_t itemsize, double samples_per_second, bool ignore_tags)
+ : sync_block("throttle",
+ io_signature::make(1, 1, itemsize),
+ io_signature::make(1, 1, itemsize)),
+ d_itemsize(itemsize),
+ d_ignore_tags(ignore_tags)
+{
+ set_sample_rate(samples_per_second);
+}
+
+throttle_impl::~throttle_impl() {}
+
+bool throttle_impl::start()
+{
+ d_start = boost::get_system_time();
+ d_total_samples = 0;
+ return block::start();
+}
+
+void throttle_impl::set_sample_rate(double rate)
+{
+ // changing the sample rate performs a reset of state params
+ d_start = boost::get_system_time();
+ d_total_samples = 0;
+ d_samps_per_tick = rate / boost::posix_time::time_duration::ticks_per_second();
+ d_samps_per_us = rate / 1e6;
+}
+
+double throttle_impl::sample_rate() const { return d_samps_per_us * 1e6; }
+
+int throttle_impl::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ // check for updated rx_rate tag
+ if (!d_ignore_tags) {
uint64_t abs_N = nitems_read(0);
std::vector<tag_t> all_tags;
get_tags_in_range(all_tags, 0, abs_N, abs_N + noutput_items);
std::vector<tag_t>::iterator itr;
- for(itr = all_tags.begin(); itr != all_tags.end(); itr++) {
- if(pmt::eq( (*itr).key, throttle_rx_rate_pmt)){
- double new_rate = pmt::to_double( (*itr).value );
- set_sample_rate(new_rate);
+ for (itr = all_tags.begin(); itr != all_tags.end(); itr++) {
+ if (pmt::eq((*itr).key, throttle_rx_rate_pmt)) {
+ double new_rate = pmt::to_double((*itr).value);
+ set_sample_rate(new_rate);
}
- }
}
+ }
- //calculate the expected number of samples to have passed through
- boost::system_time now = boost::get_system_time();
- boost::int64_t ticks = (now - d_start).ticks();
- uint64_t expected_samps = uint64_t(d_samps_per_tick*ticks);
+ // calculate the expected number of samples to have passed through
+ boost::system_time now = boost::get_system_time();
+ boost::int64_t ticks = (now - d_start).ticks();
+ uint64_t expected_samps = uint64_t(d_samps_per_tick * ticks);
- //if the expected samples was less, we need to throttle back
- if(d_total_samples > expected_samps) {
- double sleep_time = (d_total_samples - expected_samps)/d_samps_per_us;
+ // if the expected samples was less, we need to throttle back
+ if (d_total_samples > expected_samps) {
+ double sleep_time = (d_total_samples - expected_samps) / d_samps_per_us;
if (std::numeric_limits<long>::max() < sleep_time) {
- GR_LOG_ALERT(d_logger, "WARNING: Throttle sleep time overflow! You "
- "are probably using a very low sample rate.");
+ GR_LOG_ALERT(d_logger,
+ "WARNING: Throttle sleep time overflow! You "
+ "are probably using a very low sample rate.");
}
- boost::this_thread::sleep(boost::posix_time::microseconds
- (long(sleep_time)));
- }
-
- //copy all samples output[i] <= input[i]
- const char *in = (const char *)input_items[0];
- char *out = (char *)output_items[0];
- std::memcpy(out, in, noutput_items * d_itemsize);
- d_total_samples += noutput_items;
- return noutput_items;
+ boost::this_thread::sleep(boost::posix_time::microseconds(long(sleep_time)));
}
- void
- throttle_impl::setup_rpc()
- {
+ // copy all samples output[i] <= input[i]
+ const char* in = (const char*)input_items[0];
+ char* out = (char*)output_items[0];
+ std::memcpy(out, in, noutput_items * d_itemsize);
+ d_total_samples += noutput_items;
+ return noutput_items;
+}
+
+void throttle_impl::setup_rpc()
+{
#ifdef GR_CTRLPORT
- d_rpc_vars.push_back(
- rpcbasic_sptr(new rpcbasic_register_get<throttle, double>(
- alias(), "sample_rate", &throttle::sample_rate,
- pmt::mp(0.0), pmt::mp(100.0e6), pmt::mp(0.0),
- "Hz", "Sample Rate", RPC_PRIVLVL_MIN,
- DISPTIME | DISPOPTSTRIP)));
-
- d_rpc_vars.push_back(
- rpcbasic_sptr(new rpcbasic_register_set<throttle, double>(
- alias(), "sample_rate", &throttle::set_sample_rate,
- pmt::mp(0.0), pmt::mp(100.0e6), pmt::mp(0.0),
- "Hz", "Sample Rate", RPC_PRIVLVL_MIN,
- DISPTIME | DISPOPTSTRIP)));
+ d_rpc_vars.push_back(rpcbasic_sptr(
+ new rpcbasic_register_get<throttle, double>(alias(),
+ "sample_rate",
+ &throttle::sample_rate,
+ pmt::mp(0.0),
+ pmt::mp(100.0e6),
+ pmt::mp(0.0),
+ "Hz",
+ "Sample Rate",
+ RPC_PRIVLVL_MIN,
+ DISPTIME | DISPOPTSTRIP)));
+
+ d_rpc_vars.push_back(rpcbasic_sptr(
+ new rpcbasic_register_set<throttle, double>(alias(),
+ "sample_rate",
+ &throttle::set_sample_rate,
+ pmt::mp(0.0),
+ pmt::mp(100.0e6),
+ pmt::mp(0.0),
+ "Hz",
+ "Sample Rate",
+ RPC_PRIVLVL_MIN,
+ DISPTIME | DISPOPTSTRIP)));
#endif /* GR_CTRLPORT */
- }
+}
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/throttle_impl.h b/gr-blocks/lib/throttle_impl.h
index 6afacbba5d..9fbff3664f 100644
--- a/gr-blocks/lib/throttle_impl.h
+++ b/gr-blocks/lib/throttle_impl.h
@@ -26,35 +26,35 @@
#include <gnuradio/blocks/throttle.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class throttle_impl : public throttle
- {
- private:
- boost::system_time d_start;
- size_t d_itemsize;
- uint64_t d_total_samples;
- double d_samps_per_tick, d_samps_per_us;
- bool d_ignore_tags;
+class throttle_impl : public throttle
+{
+private:
+ boost::system_time d_start;
+ size_t d_itemsize;
+ uint64_t d_total_samples;
+ double d_samps_per_tick, d_samps_per_us;
+ bool d_ignore_tags;
- public:
- throttle_impl(size_t itemsize, double samples_per_sec, bool ignore_tags=true);
- ~throttle_impl();
+public:
+ throttle_impl(size_t itemsize, double samples_per_sec, bool ignore_tags = true);
+ ~throttle_impl();
- // Overloading gr::block::start to reset timer
- bool start();
+ // Overloading gr::block::start to reset timer
+ bool start();
- void setup_rpc();
+ void setup_rpc();
- void set_sample_rate(double rate);
- double sample_rate() const;
+ void set_sample_rate(double rate);
+ double sample_rate() const;
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_GR_THROTTLE_IMPL_H */
diff --git a/gr-blocks/lib/transcendental_impl.cc b/gr-blocks/lib/transcendental_impl.cc
index d9a635fdc2..a29a1e75da 100644
--- a/gr-blocks/lib/transcendental_impl.cc
+++ b/gr-blocks/lib/transcendental_impl.cc
@@ -24,127 +24,120 @@
#include <gnuradio/io_signature.h>
#include <stdexcept>
#include <complex> //complex math
-#include <cmath> //real math
+#include <cmath> //real math
#include <map>
namespace gr {
- namespace blocks {
-
- /***********************************************************************
- * work function creation and registration
- **********************************************************************/
- struct map_val_type
- {
- work_fcn_type work_fcn;
- size_t io_size;
- };
- typedef std::map<std::string, map_val_type> map_type;
-
- //construct map on first use idiom
- static map_type &
- get_map(void)
- {
- static map_type map;
- return map;
- }
-
- //static initialization of this object registers a function
- struct transcendental_registrant
+namespace blocks {
+
+/***********************************************************************
+ * work function creation and registration
+ **********************************************************************/
+struct map_val_type {
+ work_fcn_type work_fcn;
+ size_t io_size;
+};
+typedef std::map<std::string, map_val_type> map_type;
+
+// construct map on first use idiom
+static map_type& get_map(void)
+{
+ static map_type map;
+ return map;
+}
+
+// static initialization of this object registers a function
+struct transcendental_registrant {
+ transcendental_registrant(const std::string& key,
+ const work_fcn_type& work_fcn,
+ const size_t io_size)
{
- transcendental_registrant(const std::string &key,
- const work_fcn_type &work_fcn,
- const size_t io_size)
- {
map_val_type val;
val.work_fcn = work_fcn;
val.io_size = io_size;
get_map()[key] = val;
- }
- };
-
- //macro to create a work function and register it
-#define REGISTER_FUNCTION(__fcn__, __type__, __key__) \
- static int __key__ ## _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]; \
- __type__ *out = (__type__ *) output_items[0]; \
- for (size_t i = 0; i < size_t(noutput_items); i++){ \
- out[i] = std::__fcn__(in[i]); \
- } \
- return noutput_items; \
- } \
- transcendental_registrant __key__ ## _registrant(#__key__, &__key__ ## _work, sizeof(__type__));
-
- //register work functions for real types
-#define REGISTER_REAL_FUNCTIONS(__fcn__) \
- REGISTER_FUNCTION(__fcn__, float, __fcn__ ## _float) \
- REGISTER_FUNCTION(__fcn__, double, __fcn__ ## _double)
-
- //register work functions for complex types
-#define REGISTER_COMPLEX_FUNCTIONS(__fcn__) \
- REGISTER_FUNCTION(__fcn__, std::complex<float>, __fcn__ ## _complex_float) \
- REGISTER_FUNCTION(__fcn__, std::complex<double>, __fcn__ ## _complex_double)
-
- //register both complex and real
+ }
+};
+
+// macro to create a work function and register it
+#define REGISTER_FUNCTION(__fcn__, __type__, __key__) \
+ static int __key__##_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]; \
+ __type__* out = (__type__*)output_items[0]; \
+ for (size_t i = 0; i < size_t(noutput_items); i++) { \
+ out[i] = std::__fcn__(in[i]); \
+ } \
+ return noutput_items; \
+ } \
+ transcendental_registrant __key__##_registrant( \
+ #__key__, &__key__##_work, sizeof(__type__));
+
+// register work functions for real types
+#define REGISTER_REAL_FUNCTIONS(__fcn__) \
+ REGISTER_FUNCTION(__fcn__, float, __fcn__##_float) \
+ REGISTER_FUNCTION(__fcn__, double, __fcn__##_double)
+
+// register work functions for complex types
+#define REGISTER_COMPLEX_FUNCTIONS(__fcn__) \
+ REGISTER_FUNCTION(__fcn__, std::complex<float>, __fcn__##_complex_float) \
+ REGISTER_FUNCTION(__fcn__, std::complex<double>, __fcn__##_complex_double)
+
+// register both complex and real
#define REGISTER_FUNCTIONS(__fcn__) \
- REGISTER_REAL_FUNCTIONS(__fcn__) \
+ REGISTER_REAL_FUNCTIONS(__fcn__) \
REGISTER_COMPLEX_FUNCTIONS(__fcn__)
- //create and register transcendental work functions
- REGISTER_FUNCTIONS(cos)
- REGISTER_FUNCTIONS(sin)
- REGISTER_FUNCTIONS(tan)
- REGISTER_REAL_FUNCTIONS(acos)
- REGISTER_REAL_FUNCTIONS(asin)
- REGISTER_REAL_FUNCTIONS(atan)
- REGISTER_FUNCTIONS(cosh)
- REGISTER_FUNCTIONS(sinh)
- REGISTER_FUNCTIONS(tanh)
- REGISTER_FUNCTIONS(exp)
- REGISTER_FUNCTIONS(log)
- REGISTER_FUNCTIONS(log10)
- REGISTER_FUNCTIONS(sqrt)
-
-
- transcendental::sptr
- transcendental::make(const std::string &name,
- const std::string &type)
- {
- //search for an entry in the map
- const std::string key = name + "_" + type;
- const bool has_key = get_map().count(key) != 0;
- if(!has_key)
+// create and register transcendental work functions
+REGISTER_FUNCTIONS(cos)
+REGISTER_FUNCTIONS(sin)
+REGISTER_FUNCTIONS(tan)
+REGISTER_REAL_FUNCTIONS(acos)
+REGISTER_REAL_FUNCTIONS(asin)
+REGISTER_REAL_FUNCTIONS(atan)
+REGISTER_FUNCTIONS(cosh)
+REGISTER_FUNCTIONS(sinh)
+REGISTER_FUNCTIONS(tanh)
+REGISTER_FUNCTIONS(exp)
+REGISTER_FUNCTIONS(log)
+REGISTER_FUNCTIONS(log10)
+REGISTER_FUNCTIONS(sqrt)
+
+
+transcendental::sptr transcendental::make(const std::string& name,
+ const std::string& type)
+{
+ // search for an entry in the map
+ const std::string key = name + "_" + type;
+ const bool has_key = get_map().count(key) != 0;
+ if (!has_key)
throw std::runtime_error("could not find transcendental function for " + key);
- //make a new block with found work function
- return gnuradio::get_initial_sptr
- (new transcendental_impl(get_map()[key].work_fcn, get_map()[key].io_size));
- }
-
- transcendental_impl::transcendental_impl(const work_fcn_type &work_fcn,
- const size_t io_size)
- : sync_block("transcendental",
- io_signature::make(1, 1, io_size),
- io_signature::make(1, 1, io_size)),
- _work_fcn(work_fcn)
- {
- // NOP
- }
-
- transcendental_impl::~transcendental_impl()
- {
- }
-
- int
- transcendental_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- return _work_fcn(noutput_items, input_items, output_items);
- }
-
- } /* namespace blocks */
+ // make a new block with found work function
+ return gnuradio::get_initial_sptr(
+ new transcendental_impl(get_map()[key].work_fcn, get_map()[key].io_size));
+}
+
+transcendental_impl::transcendental_impl(const work_fcn_type& work_fcn,
+ const size_t io_size)
+ : sync_block("transcendental",
+ io_signature::make(1, 1, io_size),
+ io_signature::make(1, 1, io_size)),
+ _work_fcn(work_fcn)
+{
+ // NOP
+}
+
+transcendental_impl::~transcendental_impl() {}
+
+int transcendental_impl::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ return _work_fcn(noutput_items, input_items, output_items);
+}
+
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/transcendental_impl.h b/gr-blocks/lib/transcendental_impl.h
index bb82b23b66..359e6bcf6a 100644
--- a/gr-blocks/lib/transcendental_impl.h
+++ b/gr-blocks/lib/transcendental_impl.h
@@ -26,26 +26,25 @@
#include <gnuradio/blocks/transcendental.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- typedef int(*work_fcn_type)(int, gr_vector_const_void_star &, gr_vector_void_star &);
+typedef int (*work_fcn_type)(int, gr_vector_const_void_star&, gr_vector_void_star&);
- class transcendental_impl : public transcendental
- {
- private:
- const work_fcn_type &_work_fcn;
+class transcendental_impl : public transcendental
+{
+private:
+ const work_fcn_type& _work_fcn;
- public:
- transcendental_impl(const work_fcn_type &work_fcn,
- const size_t io_size);
- ~transcendental_impl();
+public:
+ transcendental_impl(const work_fcn_type& work_fcn, const size_t io_size);
+ ~transcendental_impl();
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_GR_TRANSCENDENTAL_IMPL_H */
diff --git a/gr-blocks/lib/tsb_vector_sink_impl.cc b/gr-blocks/lib/tsb_vector_sink_impl.cc
index 79c1fe7c73..676af1b705 100644
--- a/gr-blocks/lib/tsb_vector_sink_impl.cc
+++ b/gr-blocks/lib/tsb_vector_sink_impl.cc
@@ -29,67 +29,65 @@
#include <gnuradio/io_signature.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- template <class T>
- typename tsb_vector_sink<T>::sptr
- tsb_vector_sink<T>::make(unsigned int vlen, const std::string &tsb_key)
- {
- return gnuradio::get_initial_sptr
- (new tsb_vector_sink_impl<T> (vlen, tsb_key));
- }
+template <class T>
+typename tsb_vector_sink<T>::sptr tsb_vector_sink<T>::make(unsigned int vlen,
+ const std::string& tsb_key)
+{
+ return gnuradio::get_initial_sptr(new tsb_vector_sink_impl<T>(vlen, tsb_key));
+}
- template <class T>
- tsb_vector_sink_impl<T> ::tsb_vector_sink_impl(unsigned int vlen, const std::string &tsb_key)
- : gr::tagged_stream_block("tsb_vector_sink",
- gr::io_signature::make(1, 1, vlen * sizeof(T)),
- gr::io_signature::make(0, 0, 0), tsb_key),
+template <class T>
+tsb_vector_sink_impl<T>::tsb_vector_sink_impl(unsigned int vlen,
+ const std::string& tsb_key)
+ : gr::tagged_stream_block("tsb_vector_sink",
+ gr::io_signature::make(1, 1, vlen * sizeof(T)),
+ gr::io_signature::make(0, 0, 0),
+ tsb_key),
d_vlen(vlen)
- {}
+{
+}
- template <class T>
- tsb_vector_sink_impl<T> ::~tsb_vector_sink_impl()
- {
- }
+template <class T>
+tsb_vector_sink_impl<T>::~tsb_vector_sink_impl()
+{
+}
- template <class T>
- std::vector<std::vector<T> >
- tsb_vector_sink_impl<T> ::data() const
- {
- return d_data;
- }
+template <class T>
+std::vector<std::vector<T>> tsb_vector_sink_impl<T>::data() const
+{
+ return d_data;
+}
- template <class T>
- std::vector<tag_t>
- tsb_vector_sink_impl<T> ::tags() const
- {
- return d_tags;
- }
+template <class T>
+std::vector<tag_t> tsb_vector_sink_impl<T>::tags() const
+{
+ return d_tags;
+}
- template <class T>
- int
- tsb_vector_sink_impl<T> ::work (int noutput_items,
- gr_vector_int &ninput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- const T *in = (const T *) input_items[0];
+template <class T>
+int tsb_vector_sink_impl<T>::work(int noutput_items,
+ gr_vector_int& ninput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ const T* in = (const T*)input_items[0];
- std::vector<T> new_data(in, in + (ninput_items[0] * d_vlen));
- d_data.push_back(new_data);
+ std::vector<T> new_data(in, in + (ninput_items[0] * d_vlen));
+ d_data.push_back(new_data);
- std::vector<tag_t> tags;
- this->get_tags_in_window(tags, 0, 0, ninput_items[0]);
- d_tags.insert(d_tags.end(), tags.begin(), tags.end());
+ std::vector<tag_t> tags;
+ this->get_tags_in_window(tags, 0, 0, ninput_items[0]);
+ d_tags.insert(d_tags.end(), tags.begin(), tags.end());
- return ninput_items[0];
- }
+ return ninput_items[0];
+}
template class tsb_vector_sink<std::uint8_t>;
template class tsb_vector_sink<std::int16_t>;
template class tsb_vector_sink<std::int32_t>;
template class tsb_vector_sink<float>;
template class tsb_vector_sink<gr_complex>;
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
-
diff --git a/gr-blocks/lib/tsb_vector_sink_impl.h b/gr-blocks/lib/tsb_vector_sink_impl.h
index 6da7e2de6e..0a703ec865 100644
--- a/gr-blocks/lib/tsb_vector_sink_impl.h
+++ b/gr-blocks/lib/tsb_vector_sink_impl.h
@@ -27,32 +27,31 @@
#include <gnuradio/blocks/tsb_vector_sink.h>
namespace gr {
- namespace blocks {
-
-template<class T>
- class tsb_vector_sink_impl : public tsb_vector_sink<T>
- {
- private:
- std::vector<std::vector<T> > d_data;
- std::vector<tag_t> d_tags;
- unsigned int d_vlen;
-
- public:
- tsb_vector_sink_impl (unsigned int vlen, const std::string &tsb_key);
- ~tsb_vector_sink_impl ();
-
- void reset() { d_data.clear(); }
- std::vector<std::vector<T> > data() const;
- std::vector<tag_t> tags() const;
-
- 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 blocks {
+
+template <class T>
+class tsb_vector_sink_impl : public tsb_vector_sink<T>
+{
+private:
+ std::vector<std::vector<T>> d_data;
+ std::vector<tag_t> d_tags;
+ unsigned int d_vlen;
+
+public:
+ tsb_vector_sink_impl(unsigned int vlen, const std::string& tsb_key);
+ ~tsb_vector_sink_impl();
+
+ void reset() { d_data.clear(); }
+ std::vector<std::vector<T>> data() const;
+ std::vector<tag_t> tags() const;
+
+ 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 /* TSB_VECTOR_SINK_IMPL_H */
-
diff --git a/gr-blocks/lib/tuntap_pdu_impl.cc b/gr-blocks/lib/tuntap_pdu_impl.cc
index 64eeb02255..fa16683510 100644
--- a/gr-blocks/lib/tuntap_pdu_impl.cc
+++ b/gr-blocks/lib/tuntap_pdu_impl.cc
@@ -40,143 +40,140 @@
#endif
namespace gr {
- namespace blocks {
+namespace blocks {
- tuntap_pdu::sptr
- tuntap_pdu::make(std::string dev, int MTU, bool istunflag)
- {
+tuntap_pdu::sptr tuntap_pdu::make(std::string dev, int MTU, bool istunflag)
+{
#if (defined(linux) || defined(__linux) || defined(__linux__))
- return gnuradio::get_initial_sptr(new tuntap_pdu_impl(dev, MTU, istunflag));
+ return gnuradio::get_initial_sptr(new tuntap_pdu_impl(dev, MTU, istunflag));
#else
- throw std::runtime_error("tuntap_pdu not implemented on this platform");
+ 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, bool istunflag)
- : block("tuntap_pdu",
- io_signature::make (0, 0, 0),
- io_signature::make (0, 0, 0)),
- stream_pdu_base(istunflag ? MTU : MTU + 14),
- d_dev(dev),
- d_istunflag(istunflag)
- {
- // 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()));
-
- bool istun = d_istunflag;
- if(istun){
- d_fd = tun_alloc(dev_cstr, (IFF_TUN | IFF_NO_PI));
- } else {
- d_fd = tun_alloc(dev_cstr, (IFF_TAP | IFF_NO_PI));
- }
-
- if (d_fd <= 0)
- throw std::runtime_error("gr::tuntap_pdu::make: tun_alloc failed (are you running as root?)");
-
- int err = set_mtu(dev_cstr, MTU);
- if(err < 0)
- std::cerr << boost::format(
- "gr::tuntap_pdu: failed to set MTU to %d.\n"
- "You should use ifconfig to set the MTU. E.g.,\n"
- " $ sudo ifconfig %s mtu %d\n"
- ) % MTU % dev % MTU << std::endl;
-
- 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::pdu_port_id());
- start_rxthread(this, pdu::pdu_port_id());
-
- // set up input message port
- message_port_register_in(pdu::pdu_port_id());
- set_msg_handler(pdu::pdu_port_id(), boost::bind(&tuntap_pdu_impl::send, this, _1));
+tuntap_pdu_impl::tuntap_pdu_impl(std::string dev, int MTU, bool istunflag)
+ : block("tuntap_pdu", io_signature::make(0, 0, 0), io_signature::make(0, 0, 0)),
+ stream_pdu_base(istunflag ? MTU : MTU + 14),
+ d_dev(dev),
+ d_istunflag(istunflag)
+{
+ // 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()));
+
+ bool istun = d_istunflag;
+ if (istun) {
+ d_fd = tun_alloc(dev_cstr, (IFF_TUN | IFF_NO_PI));
+ } else {
+ d_fd = tun_alloc(dev_cstr, (IFF_TAP | IFF_NO_PI));
}
- 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)
+ if (d_fd <= 0)
+ throw std::runtime_error(
+ "gr::tuntap_pdu::make: tun_alloc failed (are you running as root?)");
+
+ int err = set_mtu(dev_cstr, MTU);
+ if (err < 0)
+ std::cerr << boost::format("gr::tuntap_pdu: failed to set MTU to %d.\n"
+ "You should use ifconfig to set the MTU. E.g.,\n"
+ " $ sudo ifconfig %s mtu %d\n") %
+ MTU % dev % MTU
+ << std::endl;
+
+ 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::pdu_port_id());
+ start_rxthread(this, pdu::pdu_port_id());
+
+ // set up input message port
+ message_port_register_in(pdu::pdu_port_id());
+ set_msg_handler(pdu::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));
+ /* 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 */
+ 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)
+ /* 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 - 1);
- /* try to create the device */
- if ((err = ioctl(fd, TUNSETIFF, (void *) &ifr)) < 0) {
+ /* 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;
}
- int
- tuntap_pdu_impl::set_mtu(const char *dev, int MTU)
- {
- struct ifreq ifr;
- int sfd, err;
-
- /* MTU must be set by passing a socket fd to ioctl;
- * create an arbitrary socket for this purpose
- */
- if ((sfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
- return sfd;
-
- /* preparation of the struct ifr, of type "struct ifreq" */
- memset(&ifr, 0, sizeof(ifr));
- strncpy(ifr.ifr_name, dev, IFNAMSIZ);
- ifr.ifr_addr.sa_family = AF_INET; /* address family */
- ifr.ifr_mtu = MTU;
-
- /* try to set MTU */
- if ((err = ioctl(sfd, SIOCSIFMTU, (void *) &ifr)) < 0) {
- close(sfd);
- return err;
- }
-
- close(sfd);
- return MTU;
+ /* 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;
+}
+
+int tuntap_pdu_impl::set_mtu(const char* dev, int MTU)
+{
+ struct ifreq ifr;
+ int sfd, err;
+
+ /* MTU must be set by passing a socket fd to ioctl;
+ * create an arbitrary socket for this purpose
+ */
+ if ((sfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
+ return sfd;
+
+ /* preparation of the struct ifr, of type "struct ifreq" */
+ memset(&ifr, 0, sizeof(ifr));
+ strncpy(ifr.ifr_name, dev, IFNAMSIZ);
+ ifr.ifr_addr.sa_family = AF_INET; /* address family */
+ ifr.ifr_mtu = MTU;
+
+ /* try to set MTU */
+ if ((err = ioctl(sfd, SIOCSIFMTU, (void*)&ifr)) < 0) {
+ close(sfd);
+ return err;
}
+
+ close(sfd);
+ return MTU;
+}
#endif
- } /* namespace blocks */
-}/* namespace gr */
+} /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/tuntap_pdu_impl.h b/gr-blocks/lib/tuntap_pdu_impl.h
index 3a53e3acb5..31afc445e7 100644
--- a/gr-blocks/lib/tuntap_pdu_impl.h
+++ b/gr-blocks/lib/tuntap_pdu_impl.h
@@ -31,23 +31,23 @@
#endif
namespace gr {
- namespace blocks {
+namespace blocks {
- class tuntap_pdu_impl : public tuntap_pdu, public stream_pdu_base
- {
+class tuntap_pdu_impl : public tuntap_pdu, public stream_pdu_base
+{
#if (defined(linux) || defined(__linux) || defined(__linux__))
- private:
- std::string d_dev;
- bool d_istunflag;
- int tun_alloc(char *dev, int flags);
- int set_mtu(const char *dev, int MTU);
-
- public:
- tuntap_pdu_impl(std::string dev, int MTU, bool istunflag);
+private:
+ std::string d_dev;
+ bool d_istunflag;
+ int tun_alloc(char* dev, int flags);
+ int set_mtu(const char* dev, int MTU);
+
+public:
+ tuntap_pdu_impl(std::string dev, int MTU, bool istunflag);
#endif
- };
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_BLOCKS_TUNTAP_PDU_IMPL_H */
diff --git a/gr-blocks/lib/uchar_array_to_float.cc b/gr-blocks/lib/uchar_array_to_float.cc
index c3e2c3f369..4a2efe8da5 100644
--- a/gr-blocks/lib/uchar_array_to_float.cc
+++ b/gr-blocks/lib/uchar_array_to_float.cc
@@ -22,19 +22,18 @@
#include "uchar_array_to_float.h"
-void
-uchar_array_to_float (const unsigned char *in, float *out, int nsamples)
+void uchar_array_to_float(const unsigned char* in, float* out, int nsamples)
{
- while (nsamples >= 4){
- out[0] = in[0];
- out[1] = in[1];
- out[2] = in[2];
- out[3] = in[3];
- out += 4;
- in += 4;
- nsamples -= 4;
- }
+ while (nsamples >= 4) {
+ out[0] = in[0];
+ out[1] = in[1];
+ out[2] = in[2];
+ out[3] = in[3];
+ out += 4;
+ in += 4;
+ nsamples -= 4;
+ }
- while (nsamples-- > 0)
- *out++ = *in++;
+ while (nsamples-- > 0)
+ *out++ = *in++;
}
diff --git a/gr-blocks/lib/uchar_array_to_float.h b/gr-blocks/lib/uchar_array_to_float.h
index 9b499760aa..93ba88d9f7 100644
--- a/gr-blocks/lib/uchar_array_to_float.h
+++ b/gr-blocks/lib/uchar_array_to_float.h
@@ -28,7 +28,7 @@
/*
* convert array of unsigned chars to floats
*/
-BLOCKS_API void uchar_array_to_float (const unsigned char *in, float *out, int nsamples);
+BLOCKS_API void uchar_array_to_float(const unsigned char* in, float* out, int nsamples);
#endif /* INCLUDED_UCHAR_ARRAY_TO_FLOAT_H */
diff --git a/gr-blocks/lib/uchar_to_float_impl.cc b/gr-blocks/lib/uchar_to_float_impl.cc
index 0068094861..ec666da349 100644
--- a/gr-blocks/lib/uchar_to_float_impl.cc
+++ b/gr-blocks/lib/uchar_to_float_impl.cc
@@ -29,32 +29,31 @@
#include <gnuradio/io_signature.h>
namespace gr {
- namespace blocks {
-
- uchar_to_float::sptr uchar_to_float::make()
- {
- return gnuradio::get_initial_sptr(new uchar_to_float_impl());
- }
-
- uchar_to_float_impl::uchar_to_float_impl()
- : sync_block("uchar_to_float",
- io_signature::make (1, 1, sizeof(unsigned char)),
- io_signature::make (1, 1, sizeof(float)))
- {
- }
-
- int
- uchar_to_float_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];
- float *out = (float *) output_items[0];
-
- uchar_array_to_float (in, out, noutput_items);
-
- return noutput_items;
- }
-
- } /* namespace blocks */
-}/* namespace gr */
+namespace blocks {
+
+uchar_to_float::sptr uchar_to_float::make()
+{
+ return gnuradio::get_initial_sptr(new uchar_to_float_impl());
+}
+
+uchar_to_float_impl::uchar_to_float_impl()
+ : sync_block("uchar_to_float",
+ io_signature::make(1, 1, sizeof(unsigned char)),
+ io_signature::make(1, 1, sizeof(float)))
+{
+}
+
+int uchar_to_float_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];
+ float* out = (float*)output_items[0];
+
+ uchar_array_to_float(in, out, noutput_items);
+
+ return noutput_items;
+}
+
+} /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/uchar_to_float_impl.h b/gr-blocks/lib/uchar_to_float_impl.h
index 602662c54f..d22a72cde2 100644
--- a/gr-blocks/lib/uchar_to_float_impl.h
+++ b/gr-blocks/lib/uchar_to_float_impl.h
@@ -26,19 +26,19 @@
#include <gnuradio/blocks/uchar_to_float.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class BLOCKS_API uchar_to_float_impl : public uchar_to_float
- {
- public:
- uchar_to_float_impl();
+class BLOCKS_API uchar_to_float_impl : public uchar_to_float
+{
+public:
+ uchar_to_float_impl();
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/udp_sink_impl.cc b/gr-blocks/lib/udp_sink_impl.cc
index b540a7da19..cb44ba0b6f 100644
--- a/gr-blocks/lib/udp_sink_impl.cc
+++ b/gr-blocks/lib/udp_sink_impl.cc
@@ -35,49 +35,45 @@
#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)
- : sync_block("udp_sink",
- io_signature::make(1, 1, itemsize),
- io_signature::make(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)
+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)
+ : sync_block(
+ "udp_sink", io_signature::make(1, 1, itemsize), io_signature::make(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)
+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) {
+ 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(host, s_port,
- boost::asio::ip::resolver_query_base::passive);
+ boost::asio::ip::udp::resolver::query query(
+ host, s_port, boost::asio::ip::resolver_query_base::passive);
d_endpoint = *resolver.resolve(query);
d_socket = new boost::asio::ip::udp::socket(d_io_service);
@@ -87,63 +83,59 @@ namespace gr {
d_socket->set_option(roption);
d_connected = true;
- }
}
+}
- void
- udp_sink_impl::disconnect()
- {
- if(!d_connected)
+void udp_sink_impl::disconnect()
+{
+ if (!d_connected)
return;
- gr::thread::scoped_lock guard(d_mutex); // protect d_socket from work()
+ gr::thread::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, 0> send_buf;
- if(d_eof) {
+ // Send a few zero-length packets to signal receiver we are done
+ boost::array<char, 0> send_buf;
+ 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;
+ for (i = 0; i < 3; i++)
+ d_socket->send_to(boost::asio::buffer(send_buf), d_endpoint);
}
- 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;
-
- gr::thread::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
+ 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;
+
+ gr::thread::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 */
+ 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
index c593e6e809..5b3a2bd015 100644
--- a/gr-blocks/lib/udp_sink_impl.h
+++ b/gr-blocks/lib/udp_sink_impl.h
@@ -27,39 +27,38 @@
#include <boost/asio.hpp>
namespace gr {
- namespace blocks {
+namespace blocks {
- class udp_sink_impl : public udp_sink
- {
- private:
- size_t d_itemsize;
+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?
- gr::thread::mutex d_mutex; // protects d_socket and d_connected
+ int d_payload_size; // maximum transmission unit (packet length)
+ bool d_eof; // send zero-length packet on disconnect
+ bool d_connected; // are we connected?
+ gr::thread::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;
+ 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();
+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; }
+ int payload_size() { return d_payload_size; }
- void connect(const std::string &host, int port);
- void disconnect();
+ 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);
- };
+ int work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* 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
index 66fb68741a..c948410c02 100644
--- a/gr-blocks/lib/udp_source_impl.cc
+++ b/gr-blocks/lib/udp_source_impl.cc
@@ -34,62 +34,60 @@
#include <string.h>
namespace gr {
- namespace blocks {
-
- const int udp_source_impl::BUF_SIZE_PAYLOADS =
- gr::prefs::singleton()->get_long("udp_blocks", "buf_size_payloads", 50);
-
- 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)
- : sync_block("udp_source",
- io_signature::make(0, 0, 0),
- io_signature::make(1, 1, itemsize)),
- d_itemsize(itemsize), d_payload_size(payload_size),
- d_eof(eof), d_connected(false), d_residual(0), d_sent(0)
- {
- // Give us some more room to play.
- d_rxbuf = new char[4*d_payload_size];
- d_residbuf = new char[BUF_SIZE_PAYLOADS*d_payload_size];
-
- connect(host, port);
- }
-
- udp_source_impl::~udp_source_impl()
- {
- if(d_connected)
+namespace blocks {
+
+const int udp_source_impl::BUF_SIZE_PAYLOADS =
+ gr::prefs::singleton()->get_long("udp_blocks", "buf_size_payloads", 50);
+
+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)
+ : sync_block(
+ "udp_source", io_signature::make(0, 0, 0), io_signature::make(1, 1, itemsize)),
+ d_itemsize(itemsize),
+ d_payload_size(payload_size),
+ d_eof(eof),
+ d_connected(false),
+ d_residual(0),
+ d_sent(0)
+{
+ // Give us some more room to play.
+ d_rxbuf = new char[4 * d_payload_size];
+ d_residbuf = new char[BUF_SIZE_PAYLOADS * d_payload_size];
+
+ connect(host, port);
+}
+
+udp_source_impl::~udp_source_impl()
+{
+ if (d_connected)
disconnect();
- delete [] d_rxbuf;
- delete [] d_residbuf;
- }
+ delete[] d_rxbuf;
+ delete[] d_residbuf;
+}
- void
- udp_source_impl::connect(const std::string &host, int port)
- {
- if(d_connected)
+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);
+ d_host = host;
+ d_port = static_cast<unsigned short>(port);
- std::string s_port;
- s_port = (boost::format("%d")%d_port).str();
+ std::string s_port;
+ s_port = (boost::format("%d") % d_port).str();
- if(host.size() > 0) {
+ if (host.size() > 0) {
boost::asio::ip::udp::resolver resolver(d_io_service);
- boost::asio::ip::udp::resolver::query query(d_host, s_port,
- boost::asio::ip::resolver_query_base::passive);
+ boost::asio::ip::udp::resolver::query query(
+ d_host, s_port, boost::asio::ip::resolver_query_base::passive);
d_endpoint = *resolver.resolve(query);
d_socket = new boost::asio::ip::udp::socket(d_io_service);
@@ -101,121 +99,118 @@ namespace gr {
d_socket->bind(d_endpoint);
start_receive();
- d_udp_thread = gr::thread::thread(boost::bind(&udp_source_impl::run_io_service, this));
+ d_udp_thread =
+ gr::thread::thread(boost::bind(&udp_source_impl::run_io_service, this));
d_connected = true;
- }
}
+}
- void
- udp_source_impl::disconnect()
- {
- gr::thread::scoped_lock lock(d_setlock);
+void udp_source_impl::disconnect()
+{
+ gr::thread::scoped_lock lock(d_setlock);
- if(!d_connected)
+ if (!d_connected)
return;
- d_io_service.reset();
- d_io_service.stop();
- d_udp_thread.join();
-
- 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) {
+ d_io_service.reset();
+ d_io_service.stop();
+ d_udp_thread.join();
+
+ 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<gr::thread::mutex> lock(d_udp_mutex);
- if(d_eof && (bytes_transferred == 0)) {
- // If we are using EOF notification, test for it and don't
- // add anything to the output.
- d_residual = WORK_DONE;
- 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) >= (BUF_SIZE_PAYLOADS*d_payload_size)) {
- GR_LOG_WARN(d_logger, "Too much data; dropping packet.");
- }
- else {
- // otherwise, copy received data into local buffer for
- // copying later.
- memcpy(d_residbuf+d_residual, d_rxbuf, bytes_transferred);
- d_residual += bytes_transferred;
+ boost::lock_guard<gr::thread::mutex> lock(d_udp_mutex);
+ if (d_eof && (bytes_transferred == 0)) {
+ // If we are using EOF notification, test for it and don't
+ // add anything to the output.
+ d_residual = WORK_DONE;
+ 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) >=
+ (BUF_SIZE_PAYLOADS * d_payload_size)) {
+ GR_LOG_WARN(d_logger, "Too much data; dropping packet.");
+ } else {
+ // otherwise, copy received 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();
+ d_cond_wait.notify_one();
}
- }
- start_receive();
}
+ start_receive();
+}
- int
- udp_source_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- gr::thread::scoped_lock l(d_setlock);
+int udp_source_impl::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ gr::thread::scoped_lock l(d_setlock);
- char *out = (char*)output_items[0];
+ 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 interruptible while a
- // synchronous receive_from is not.
- boost::unique_lock<boost::mutex> lock(d_udp_mutex);
+ // 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 interruptible while a
+ // synchronous receive_from is not.
+ boost::unique_lock<boost::mutex> lock(d_udp_mutex);
- //use timed_wait to avoid permanent blocking in the work function
- d_cond_wait.timed_wait(lock, boost::posix_time::milliseconds(10));
+ // use timed_wait to avoid permanent blocking in the work function
+ d_cond_wait.timed_wait(lock, boost::posix_time::milliseconds(10));
- if (d_residual < 0) {
+ if (d_residual < 0) {
return d_residual;
- }
+ }
- int bytes_left_in_buffer = (int)(d_residual - d_sent);
- int bytes_to_send = std::min<int>(d_itemsize * noutput_items, bytes_left_in_buffer);
+ int bytes_left_in_buffer = (int)(d_residual - d_sent);
+ int bytes_to_send = std::min<int>(d_itemsize * noutput_items, bytes_left_in_buffer);
- // Copy the received data in the residual buffer to the output stream
- memcpy(out, d_residbuf+d_sent, bytes_to_send);
- int nitems = bytes_to_send/d_itemsize;
+ // Copy the received data in the residual buffer to the output stream
+ memcpy(out, d_residbuf + d_sent, bytes_to_send);
+ int nitems = bytes_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 (bytes_to_send == bytes_left_in_buffer) {
+ // Keep track of where we are if we don't have enough output
+ // space to send all the data in the residbuf.
+ if (bytes_to_send == bytes_left_in_buffer) {
d_residual = 0;
d_sent = 0;
- }
- else {
+ } else {
d_sent += bytes_to_send;
- }
-
- return nitems;
}
- } /* namespace blocks */
+ return nitems;
+}
+
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/udp_source_impl.h b/gr-blocks/lib/udp_source_impl.h
index 5b4b6996ab..a1f0b3b06d 100644
--- a/gr-blocks/lib/udp_source_impl.h
+++ b/gr-blocks/lib/udp_source_impl.h
@@ -29,57 +29,56 @@
#include <gnuradio/thread/thread.h>
namespace gr {
- namespace blocks {
+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
+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
- static const int BUF_SIZE_PAYLOADS; //!< The d_residbuf size in multiples of d_payload_size
+ static const int
+ BUF_SIZE_PAYLOADS; //!< The d_residbuf size in multiples of d_payload_size
- std::string d_host;
- unsigned short d_port;
+ 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;
+ 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;
- gr::thread::condition_variable d_cond_wait;
- gr::thread::mutex d_udp_mutex;
- gr::thread::thread d_udp_thread;
+ gr::thread::condition_variable d_cond_wait;
+ gr::thread::mutex d_udp_mutex;
+ gr::thread::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(); }
+ 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();
+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();
+ void connect(const std::string& host, int port);
+ void disconnect();
- int payload_size() { return d_payload_size; }
- int get_port();
+ 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);
- };
+ int work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_GR_UDP_SOURCE_H */
diff --git a/gr-blocks/lib/unpack_k_bits.cc b/gr-blocks/lib/unpack_k_bits.cc
index 967d7e17d9..0865121d02 100644
--- a/gr-blocks/lib/unpack_k_bits.cc
+++ b/gr-blocks/lib/unpack_k_bits.cc
@@ -30,48 +30,43 @@
#include <iostream>
namespace gr {
- namespace blocks {
- namespace kernel {
+namespace blocks {
+namespace kernel {
- unpack_k_bits::unpack_k_bits(unsigned k)
- : d_k(k)
- {
- if(d_k == 0)
- throw std::out_of_range("unpack_k_bits: k must be > 0");
- }
+unpack_k_bits::unpack_k_bits(unsigned k) : d_k(k)
+{
+ if (d_k == 0)
+ throw std::out_of_range("unpack_k_bits: k must be > 0");
+}
- unpack_k_bits::~unpack_k_bits()
- {
- }
+unpack_k_bits::~unpack_k_bits() {}
- void
- unpack_k_bits::unpack(unsigned char *bits, const unsigned char *bytes, int nbytes) const
- {
- int n = 0;
- for(int i = 0; i < nbytes; i++) {
- unsigned int t = bytes[i];
- for(int j = d_k - 1; j >= 0; j--)
+void unpack_k_bits::unpack(unsigned char* bits,
+ const unsigned char* bytes,
+ int nbytes) const
+{
+ int n = 0;
+ for (int i = 0; i < nbytes; i++) {
+ unsigned int t = bytes[i];
+ for (int j = d_k - 1; j >= 0; j--)
bits[n++] = (t >> j) & 0x01;
- }
- }
+ }
+}
- void
- unpack_k_bits::unpack_rev(unsigned char *bits, const unsigned char *bytes, int nbytes) const
- {
- int n = 0;
- for(int i = 0; i < nbytes; i++) {
- unsigned int t = bytes[i];
- for(unsigned int j = 0; j < d_k; j++)
+void unpack_k_bits::unpack_rev(unsigned char* bits,
+ const unsigned char* bytes,
+ int nbytes) const
+{
+ int n = 0;
+ for (int i = 0; i < nbytes; i++) {
+ unsigned int t = bytes[i];
+ for (unsigned int j = 0; j < d_k; j++)
bits[n++] = (t >> j) & 0x01;
- }
- }
+ }
+}
- int
- unpack_k_bits::k() const
- {
- return d_k;
- }
+int unpack_k_bits::k() const { return d_k; }
- } /* namespace kernel */
- } /* namespace blocks */
+} /* namespace kernel */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/unpack_k_bits_bb_impl.cc b/gr-blocks/lib/unpack_k_bits_bb_impl.cc
index caf3d059d6..49849e9285 100644
--- a/gr-blocks/lib/unpack_k_bits_bb_impl.cc
+++ b/gr-blocks/lib/unpack_k_bits_bb_impl.cc
@@ -30,41 +30,35 @@
#include <iostream>
namespace gr {
- namespace blocks {
+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::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)
- : sync_interpolator("unpack_k_bits_bb",
- io_signature::make(1, 1, sizeof(unsigned char)),
- io_signature::make(1, 1, sizeof(unsigned char)),
- k)
- {
- d_unpack = new kernel::unpack_k_bits(k);
- }
+unpack_k_bits_bb_impl::unpack_k_bits_bb_impl(unsigned k)
+ : sync_interpolator("unpack_k_bits_bb",
+ io_signature::make(1, 1, sizeof(unsigned char)),
+ io_signature::make(1, 1, sizeof(unsigned char)),
+ k)
+{
+ d_unpack = new kernel::unpack_k_bits(k);
+}
- unpack_k_bits_bb_impl::~unpack_k_bits_bb_impl()
- {
- delete d_unpack;
- }
+unpack_k_bits_bb_impl::~unpack_k_bits_bb_impl() { delete d_unpack; }
- 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 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];
- d_unpack->unpack(out, in, noutput_items/d_unpack->k());
+ d_unpack->unpack(out, in, noutput_items / d_unpack->k());
- return noutput_items;
- }
+ return noutput_items;
+}
- } /* namespace blocks */
+} /* 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
index 246c4ea724..b677de81e1 100644
--- a/gr-blocks/lib/unpack_k_bits_bb_impl.h
+++ b/gr-blocks/lib/unpack_k_bits_bb_impl.h
@@ -21,29 +21,29 @@
*/
#ifndef INCLUDED_GR_UNPACK_K_BITS_BB_IMPL_H
-#define INCLUDED_GR_UNPACK_K_BITS_BB_IMPL_H
+#define INCLUDED_GR_UNPACK_K_BITS_BB_IMPL_H
#include <gnuradio/blocks/unpack_k_bits_bb.h>
#include <gnuradio/blocks/unpack_k_bits.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class unpack_k_bits_bb_impl : public unpack_k_bits_bb
- {
- private:
- kernel::unpack_k_bits *d_unpack;
+class unpack_k_bits_bb_impl : public unpack_k_bits_bb
+{
+private:
+ kernel::unpack_k_bits* d_unpack;
- public:
- unpack_k_bits_bb_impl(unsigned k);
- ~unpack_k_bits_bb_impl();
+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);
- };
+ int work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_GR_UNPACK_K_BITS_BB_IMPL_H */
diff --git a/gr-blocks/lib/unpacked_to_packed_impl.cc b/gr-blocks/lib/unpacked_to_packed_impl.cc
index ff0fac1050..cdca25dd7e 100644
--- a/gr-blocks/lib/unpacked_to_packed_impl.cc
+++ b/gr-blocks/lib/unpacked_to_packed_impl.cc
@@ -30,121 +30,123 @@
#include <assert.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- template <class T>
- typename unpacked_to_packed<T>::sptr
- unpacked_to_packed<T>::make(unsigned int bits_per_chunk,
- endianness_t endianness)
- {
- return gnuradio::get_initial_sptr
- (new unpacked_to_packed_impl<T> (bits_per_chunk, endianness));
- }
+template <class T>
+typename unpacked_to_packed<T>::sptr
+unpacked_to_packed<T>::make(unsigned int bits_per_chunk, endianness_t endianness)
+{
+ return gnuradio::get_initial_sptr(
+ new unpacked_to_packed_impl<T>(bits_per_chunk, endianness));
+}
- template <class T>
- unpacked_to_packed_impl<T> ::unpacked_to_packed_impl(unsigned int bits_per_chunk,
- endianness_t endianness)
+template <class T>
+unpacked_to_packed_impl<T>::unpacked_to_packed_impl(unsigned int bits_per_chunk,
+ endianness_t endianness)
: block("unpacked_to_packed",
- io_signature::make(1, -1, sizeof(T)),
- io_signature::make(1, -1, sizeof(T))),
- d_bits_per_chunk(bits_per_chunk), d_endianness(endianness), d_index(0)
- {
- assert(bits_per_chunk <= d_bits_per_type);
- assert(bits_per_chunk > 0);
-
- this->set_relative_rate((uint64_t)bits_per_chunk, (uint64_t)this->d_bits_per_type);
- }
-
- template <class T>
- unpacked_to_packed_impl<T> ::~unpacked_to_packed_impl()
- {
- }
-
- template <class T>
- void
- unpacked_to_packed_impl<T> ::forecast(int noutput_items,
- gr_vector_int &ninput_items_required)
- {
- int input_required = (int)ceil((d_index+noutput_items * 1.0 * d_bits_per_type)
- / d_bits_per_chunk);
- unsigned ninputs = ninput_items_required.size();
- for(unsigned int i = 0; i < ninputs; i++) {
+ io_signature::make(1, -1, sizeof(T)),
+ io_signature::make(1, -1, sizeof(T))),
+ d_bits_per_chunk(bits_per_chunk),
+ d_endianness(endianness),
+ d_index(0)
+{
+ assert(bits_per_chunk <= d_bits_per_type);
+ assert(bits_per_chunk > 0);
+
+ this->set_relative_rate((uint64_t)bits_per_chunk, (uint64_t)this->d_bits_per_type);
+}
+
+template <class T>
+unpacked_to_packed_impl<T>::~unpacked_to_packed_impl()
+{
+}
+
+template <class T>
+void unpacked_to_packed_impl<T>::forecast(int noutput_items,
+ gr_vector_int& ninput_items_required)
+{
+ int input_required =
+ (int)ceil((d_index + noutput_items * 1.0 * d_bits_per_type) / d_bits_per_chunk);
+ unsigned ninputs = ninput_items_required.size();
+ for (unsigned int i = 0; i < ninputs; i++) {
ninput_items_required[i] = input_required;
- }
- }
-
- template <class T>
- unsigned int
- unpacked_to_packed_impl<T>::get_bit_be1(const T *in_vector, unsigned int bit_addr,
- unsigned int bits_per_chunk)
- {
- unsigned int byte_addr = (int)bit_addr/bits_per_chunk;
- T x = in_vector[byte_addr];
- unsigned int residue = bit_addr - byte_addr * bits_per_chunk;
- //printf("Bit addr %d byte addr %d residue %d val %d\n",bit_addr,byte_addr,residue,(x>>(bits_per_chunk-1-residue))&1);
- return (x >> (bits_per_chunk-1-residue)) & 1;
}
-
- template <class T>
- int
- unpacked_to_packed_impl<T> ::general_work(int noutput_items,
- gr_vector_int &ninput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- unsigned int index_tmp = d_index;
-
- assert(input_items.size() == output_items.size());
- int nstreams = input_items.size();
-
- for(int m=0; m< nstreams; m++) {
- const T *in = (T *)input_items[m];
- T *out = (T *)output_items[m];
- index_tmp=d_index;
+}
+
+template <class T>
+unsigned int unpacked_to_packed_impl<T>::get_bit_be1(const T* in_vector,
+ unsigned int bit_addr,
+ unsigned int bits_per_chunk)
+{
+ unsigned int byte_addr = (int)bit_addr / bits_per_chunk;
+ T x = in_vector[byte_addr];
+ unsigned int residue = bit_addr - byte_addr * bits_per_chunk;
+ // printf("Bit addr %d byte addr %d residue %d val
+ // %d\n",bit_addr,byte_addr,residue,(x>>(bits_per_chunk-1-residue))&1);
+ return (x >> (bits_per_chunk - 1 - residue)) & 1;
+}
+
+template <class T>
+int unpacked_to_packed_impl<T>::general_work(int noutput_items,
+ gr_vector_int& ninput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ unsigned int index_tmp = d_index;
+
+ assert(input_items.size() == output_items.size());
+ int nstreams = input_items.size();
+
+ for (int m = 0; m < nstreams; m++) {
+ const T* in = (T*)input_items[m];
+ T* out = (T*)output_items[m];
+ index_tmp = d_index;
// per stream processing
- //assert((ninput_items[m]-d_index)*d_bits_per_chunk >= noutput_items*d_bits_per_type);
+ // assert((ninput_items[m]-d_index)*d_bits_per_chunk >=
+ // noutput_items*d_bits_per_type);
- switch(d_endianness) {
+ switch (d_endianness) {
case GR_MSB_FIRST:
- for(int i = 0; i < noutput_items; i++) {
- T tmp=0;
- for(unsigned int j = 0; j < d_bits_per_type; j++) {
- tmp = (tmp<<1) | get_bit_be1(in, index_tmp, d_bits_per_chunk);
- index_tmp++;
+ for (int i = 0; i < noutput_items; i++) {
+ T tmp = 0;
+ for (unsigned int j = 0; j < d_bits_per_type; j++) {
+ tmp = (tmp << 1) | get_bit_be1(in, index_tmp, d_bits_per_chunk);
+ index_tmp++;
+ }
+ out[i] = tmp;
}
- out[i] = tmp;
- }
- break;
+ break;
case GR_LSB_FIRST:
- for(int i = 0; i < noutput_items; i++) {
- unsigned long tmp=0;
- for(unsigned int j = 0; j < d_bits_per_type; j++) {
- tmp = (tmp>>1) | (get_bit_be1(in, index_tmp, d_bits_per_chunk) << (d_bits_per_type-1));
- index_tmp++;
+ for (int i = 0; i < noutput_items; i++) {
+ unsigned long tmp = 0;
+ for (unsigned int j = 0; j < d_bits_per_type; j++) {
+ tmp = (tmp >> 1) | (get_bit_be1(in, index_tmp, d_bits_per_chunk)
+ << (d_bits_per_type - 1));
+ index_tmp++;
+ }
+ out[i] = tmp;
}
- out[i] = tmp;
- }
- break;
+ break;
default:
- assert(0);
+ assert(0);
}
- }
+ }
- d_index = index_tmp;
- this->consume_each((int)(d_index/d_bits_per_chunk));
- d_index = d_index%d_bits_per_chunk;
+ d_index = index_tmp;
+ this->consume_each((int)(d_index / d_bits_per_chunk));
+ d_index = d_index % d_bits_per_chunk;
- return noutput_items;
- }
+ return noutput_items;
+}
template class unpacked_to_packed<std::uint8_t>;
template class unpacked_to_packed<std::int16_t>;
template class unpacked_to_packed<std::int32_t>;
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/unpacked_to_packed_impl.h b/gr-blocks/lib/unpacked_to_packed_impl.h
index 78b39b0f2d..daa2ba6949 100644
--- a/gr-blocks/lib/unpacked_to_packed_impl.h
+++ b/gr-blocks/lib/unpacked_to_packed_impl.h
@@ -27,35 +27,33 @@
#include <gnuradio/blocks/unpacked_to_packed.h>
namespace gr {
- namespace blocks {
-
-template<class T>
- class unpacked_to_packed_impl : public unpacked_to_packed<T>
- {
- private:
- unsigned int d_bits_per_chunk;
- endianness_t d_endianness;
- unsigned int d_index;
- const unsigned int d_bits_per_type = sizeof(T) * 8;
- unsigned int get_bit_be1(const T *in_vector, unsigned int bit_addr, unsigned int bits_per_chunk);
-
- public:
- unpacked_to_packed_impl (unsigned int bits_per_chunk,
- endianness_t endianness);
- ~unpacked_to_packed_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);
-
- bool check_topology(int ninputs, int noutputs)
- { return ninputs == noutputs; }
- };
-
- } /* namespace blocks */
+namespace blocks {
+
+template <class T>
+class unpacked_to_packed_impl : public unpacked_to_packed<T>
+{
+private:
+ unsigned int d_bits_per_chunk;
+ endianness_t d_endianness;
+ unsigned int d_index;
+ const unsigned int d_bits_per_type = sizeof(T) * 8;
+ unsigned int
+ get_bit_be1(const T* in_vector, unsigned int bit_addr, unsigned int bits_per_chunk);
+
+public:
+ unpacked_to_packed_impl(unsigned int bits_per_chunk, endianness_t endianness);
+ ~unpacked_to_packed_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);
+
+ bool check_topology(int ninputs, int noutputs) { return ninputs == noutputs; }
+};
+
+} /* namespace blocks */
} /* namespace gr */
#endif /* UNPACKED_TO_PACKED_IMPL_H */
diff --git a/gr-blocks/lib/vco_c_impl.cc b/gr-blocks/lib/vco_c_impl.cc
index 5103ce1851..c83818475e 100644
--- a/gr-blocks/lib/vco_c_impl.cc
+++ b/gr-blocks/lib/vco_c_impl.cc
@@ -29,40 +29,38 @@
#include <math.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- vco_c::sptr
- vco_c::make(double sampling_rate, double sensitivity, double amplitude)
- {
- return gnuradio::get_initial_sptr
- (new vco_c_impl(sampling_rate, sensitivity, amplitude));
- }
+vco_c::sptr vco_c::make(double sampling_rate, double sensitivity, double amplitude)
+{
+ return gnuradio::get_initial_sptr(
+ new vco_c_impl(sampling_rate, sensitivity, amplitude));
+}
- vco_c_impl::vco_c_impl(double sampling_rate, double sensitivity, double amplitude)
- : sync_block("vco_c",
- io_signature::make(1, 1, sizeof(float)),
- io_signature::make(1, 1, sizeof(gr_complex))),
- d_sampling_rate(sampling_rate), d_sensitivity(sensitivity),
- d_amplitude(amplitude), d_k(d_sensitivity/d_sampling_rate)
- {
- }
+vco_c_impl::vco_c_impl(double sampling_rate, double sensitivity, double amplitude)
+ : sync_block("vco_c",
+ io_signature::make(1, 1, sizeof(float)),
+ io_signature::make(1, 1, sizeof(gr_complex))),
+ d_sampling_rate(sampling_rate),
+ d_sensitivity(sensitivity),
+ d_amplitude(amplitude),
+ d_k(d_sensitivity / d_sampling_rate)
+{
+}
- vco_c_impl::~vco_c_impl()
- {
- }
+vco_c_impl::~vco_c_impl() {}
- int
- vco_c_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];
- gr_complex *output = (gr_complex*)output_items[0];
+int vco_c_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];
+ gr_complex* output = (gr_complex*)output_items[0];
- d_vco.sincos(output, input, noutput_items, d_k, d_amplitude);
+ d_vco.sincos(output, input, noutput_items, d_k, d_amplitude);
- return noutput_items;
- }
+ return noutput_items;
+}
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/vco_c_impl.h b/gr-blocks/lib/vco_c_impl.h
index 53def4f1da..70b1f81e39 100644
--- a/gr-blocks/lib/vco_c_impl.h
+++ b/gr-blocks/lib/vco_c_impl.h
@@ -27,27 +27,27 @@
#include <gnuradio/fxpt_vco.h>
namespace gr {
- namespace blocks {
-
- class vco_c_impl : public vco_c
- {
- private:
- double d_sampling_rate;
- double d_sensitivity;
- double d_amplitude;
- double d_k;
- gr::fxpt_vco d_vco;
-
- public:
- vco_c_impl(double sampling_rate, double sensitivity, double amplitude);
- ~vco_c_impl();
-
- int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
- };
-
- } /* namespace blocks */
+namespace blocks {
+
+class vco_c_impl : public vco_c
+{
+private:
+ double d_sampling_rate;
+ double d_sensitivity;
+ double d_amplitude;
+ double d_k;
+ gr::fxpt_vco d_vco;
+
+public:
+ vco_c_impl(double sampling_rate, double sensitivity, double amplitude);
+ ~vco_c_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_C_H */
diff --git a/gr-blocks/lib/vco_f_impl.cc b/gr-blocks/lib/vco_f_impl.cc
index 42be98ad4e..16119f3431 100644
--- a/gr-blocks/lib/vco_f_impl.cc
+++ b/gr-blocks/lib/vco_f_impl.cc
@@ -29,40 +29,38 @@
#include <math.h>
namespace gr {
- namespace blocks {
+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::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)
- : sync_block("vco_f",
- io_signature::make(1, 1, sizeof(float)),
- io_signature::make(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(double sampling_rate, double sensitivity, double amplitude)
+ : sync_block("vco_f",
+ io_signature::make(1, 1, sizeof(float)),
+ io_signature::make(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()
- {
- }
+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];
+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);
+ d_vco.cos(output, input, noutput_items, d_k, d_amplitude);
- return noutput_items;
- }
+ return noutput_items;
+}
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/vco_f_impl.h b/gr-blocks/lib/vco_f_impl.h
index 6e7a6dd7b6..049d595111 100644
--- a/gr-blocks/lib/vco_f_impl.h
+++ b/gr-blocks/lib/vco_f_impl.h
@@ -27,27 +27,27 @@
#include <gnuradio/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 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_impl.cc b/gr-blocks/lib/vector_insert_impl.cc
index a39b0779ac..8f13dfa421 100644
--- a/gr-blocks/lib/vector_insert_impl.cc
+++ b/gr-blocks/lib/vector_insert_impl.cc
@@ -33,93 +33,100 @@
#include <stdio.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- template <class T>
- typename vector_insert<T>::sptr
- vector_insert<T>::make(const std::vector<T> &data, int periodicity, int offset)
- {
- return gnuradio::get_initial_sptr
- (new vector_insert_impl<T> (data, periodicity, offset));
- }
+template <class T>
+typename vector_insert<T>::sptr
+vector_insert<T>::make(const std::vector<T>& data, int periodicity, int offset)
+{
+ return gnuradio::get_initial_sptr(
+ new vector_insert_impl<T>(data, periodicity, offset));
+}
- template <class T>
- vector_insert_impl<T>::vector_insert_impl(const std::vector<T> &data,
- int periodicity, int offset)
+template <class T>
+vector_insert_impl<T>::vector_insert_impl(const std::vector<T>& data,
+ int periodicity,
+ int offset)
: block("vector_insert",
- io_signature::make(1, 1, sizeof(T)),
- io_signature::make(1, 1, sizeof(T))),
+ io_signature::make(1, 1, sizeof(T)),
+ io_signature::make(1, 1, sizeof(T))),
d_data(data),
d_offset(offset),
d_periodicity(periodicity)
- {
- this->set_tag_propagation_policy(gr::block::TPP_DONT); // handle tags manually
- // some sanity checks
- assert(offset < periodicity);
- assert(offset >= 0);
- assert((size_t)periodicity > data.size());
- }
+{
+ this->set_tag_propagation_policy(gr::block::TPP_DONT); // handle tags manually
+ // some sanity checks
+ assert(offset < periodicity);
+ assert(offset >= 0);
+ assert((size_t)periodicity > data.size());
+}
- template <class T>
- vector_insert_impl<T>::~vector_insert_impl()
- {}
+template <class T>
+vector_insert_impl<T>::~vector_insert_impl()
+{
+}
- template <class T>
- int
- vector_insert_impl<T> ::general_work(int noutput_items,
- gr_vector_int &ninput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- T *out = (T *)output_items[0];
- const T *in = (const T *)input_items[0];
+template <class T>
+int vector_insert_impl<T>::general_work(int noutput_items,
+ gr_vector_int& ninput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ T* out = (T*)output_items[0];
+ const T* in = (const T*)input_items[0];
- int ii(0), oo(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);
+ 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);
- std::vector<tag_t> tags;
- this->get_tags_in_range(tags, 0, this->nitems_read(0) + ii, this->nitems_read(0) + max_copy + ii);
- for(unsigned i = 0; i < tags.size(); i++)
- {
- //printf("copy tag from in@%d to out@%d\n", int(tags[i].offset), int(nitems_written(0) + oo + (tags[i].offset-nitems_read(0)-ii)));
- this->add_item_tag(0, this->nitems_written(0) + oo + (tags[i].offset-this->nitems_read(0)-ii), tags[i].key, tags[i].value, tags[i].srcid);
- }
- //printf("copy %d from input\n", max_copy);
- memcpy( &out[oo], &in[ii], sizeof(T)*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(T)*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);
+ 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);
+ std::vector<tag_t> tags;
+ this->get_tags_in_range(
+ tags, 0, this->nitems_read(0) + ii, this->nitems_read(0) + max_copy + ii);
+ for (unsigned i = 0; i < tags.size(); i++) {
+ // printf("copy tag from in@%d to out@%d\n", int(tags[i].offset),
+ // int(nitems_written(0) + oo + (tags[i].offset-nitems_read(0)-ii)));
+ this->add_item_tag(0,
+ this->nitems_written(0) + oo +
+ (tags[i].offset - this->nitems_read(0) - ii),
+ tags[i].key,
+ tags[i].value,
+ tags[i].srcid);
+ }
+ // printf("copy %d from input\n", max_copy);
+ memcpy(&out[oo], &in[ii], sizeof(T) * 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(T) * 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);
- this->consume_each(ii);
- return oo;
+ // printf(" # exit else, on to next loop.\n");
}
+ // printf(" # got out of loop\n");
+
+ // printf("consume = %d, produce = %d\n", ii, oo);
+ this->consume_each(ii);
+ return oo;
+}
template class vector_insert<std::uint8_t>;
template class vector_insert<std::int16_t>;
template class vector_insert<std::int32_t>;
template class vector_insert<float>;
template class vector_insert<gr_complex>;
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/vector_insert_impl.h b/gr-blocks/lib/vector_insert_impl.h
index a24fe4fc43..79ebd86e8a 100644
--- a/gr-blocks/lib/vector_insert_impl.h
+++ b/gr-blocks/lib/vector_insert_impl.h
@@ -27,32 +27,34 @@
#include <gnuradio/blocks/vector_insert.h>
namespace gr {
- namespace blocks {
-
-template<class T>
- class vector_insert_impl : public vector_insert<T>
+namespace blocks {
+
+template <class T>
+class vector_insert_impl : public vector_insert<T>
+{
+private:
+ std::vector<T> d_data;
+ int d_offset;
+ int d_periodicity;
+
+public:
+ vector_insert_impl(const std::vector<T>& data, int periodicity, int offset);
+ ~vector_insert_impl();
+
+ void rewind() { d_offset = 0; }
+ void set_data(const std::vector<T>& data)
{
- private:
- std::vector<T> d_data;
- int d_offset;
- int d_periodicity;
-
- public:
- vector_insert_impl (const std::vector<T> &data,
- int periodicity, int offset);
- ~vector_insert_impl ();
-
- void rewind() { d_offset=0; }
- void set_data(const std::vector<T> &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 */
+ 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 /* VECTOR_INSERT_IMPL_H */
diff --git a/gr-blocks/lib/vector_map_impl.cc b/gr-blocks/lib/vector_map_impl.cc
index 883d6a3195..def5b51544 100644
--- a/gr-blocks/lib/vector_map_impl.cc
+++ b/gr-blocks/lib/vector_map_impl.cc
@@ -29,99 +29,102 @@
#include <string.h>
namespace gr {
- namespace blocks {
+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_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;
+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::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)
- : sync_block("vector_map",
- io_signature::makev(in_vlens.size(), in_vlens.size(),
- get_in_sizeofs(item_size, in_vlens)),
- io_signature::makev(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(size_t item_size,
+ std::vector<size_t> in_vlens,
+ std::vector<std::vector<std::vector<size_t>>> mapping)
+ : sync_block(
+ "vector_map",
+ io_signature::makev(
+ in_vlens.size(), in_vlens.size(), get_in_sizeofs(item_size, in_vlens)),
+ io_signature::makev(
+ 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()
- {
- }
+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 >= d_in_vlens[s]) {
- throw std::runtime_error ("Indices in mapping must be greater than 0 and less than the input vector lengths.");
- }
+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 >= d_in_vlens[s]) {
+ throw std::runtime_error("Indices in mapping must be greater than 0 and "
+ "less than the input vector lengths.");
+ }
}
- }
- gr::thread::scoped_lock guard(d_mutex);
- d_mapping = mapping;
}
+ gr::thread::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];
+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);
- }
+ 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 */
+ 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
index 64f5e091e6..c6d9abda40 100644
--- a/gr-blocks/lib/vector_map_impl.h
+++ b/gr-blocks/lib/vector_map_impl.h
@@ -27,29 +27,30 @@
#include <gnuradio/thread/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;
- gr::thread::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 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;
+ gr::thread::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_impl.cc b/gr-blocks/lib/vector_sink_impl.cc
index b09c8e81b7..ec5c05f2b0 100644
--- a/gr-blocks/lib/vector_sink_impl.cc
+++ b/gr-blocks/lib/vector_sink_impl.cc
@@ -32,80 +32,77 @@
#include <iostream>
namespace gr {
- namespace blocks {
+namespace blocks {
- template <class T>
- typename vector_sink<T>::sptr
- vector_sink<T>::make(unsigned int vlen, const int reserve_items)
- {
- return gnuradio::get_initial_sptr
- (new vector_sink_impl<T> (vlen, reserve_items));
- }
+template <class T>
+typename vector_sink<T>::sptr vector_sink<T>::make(unsigned int vlen,
+ const int reserve_items)
+{
+ return gnuradio::get_initial_sptr(new vector_sink_impl<T>(vlen, reserve_items));
+}
- template <class T>
- vector_sink_impl<T> ::vector_sink_impl(unsigned int vlen, const int reserve_items)
+template <class T>
+vector_sink_impl<T>::vector_sink_impl(unsigned int vlen, const int reserve_items)
: sync_block("vector_sink",
- io_signature::make(1, 1, sizeof(T) * vlen),
- io_signature::make(0, 0, 0)),
- d_vlen(vlen)
- {
- gr::thread::scoped_lock guard(d_data_mutex);
- d_data.reserve(d_vlen * reserve_items);
- }
+ io_signature::make(1, 1, sizeof(T) * vlen),
+ io_signature::make(0, 0, 0)),
+ d_vlen(vlen)
+{
+ gr::thread::scoped_lock guard(d_data_mutex);
+ d_data.reserve(d_vlen * reserve_items);
+}
- template <class T>
- vector_sink_impl<T> ::~vector_sink_impl()
- {}
+template <class T>
+vector_sink_impl<T>::~vector_sink_impl()
+{
+}
- template <class T>
- std::vector<T>
- vector_sink_impl<T> ::data() const
- {
- gr::thread::scoped_lock guard(d_data_mutex);
- return d_data;
- }
+template <class T>
+std::vector<T> vector_sink_impl<T>::data() const
+{
+ gr::thread::scoped_lock guard(d_data_mutex);
+ return d_data;
+}
- template <class T>
- std::vector<tag_t>
- vector_sink_impl<T> ::tags() const
- {
- gr::thread::scoped_lock guard(d_data_mutex);
- return d_tags;
- }
+template <class T>
+std::vector<tag_t> vector_sink_impl<T>::tags() const
+{
+ gr::thread::scoped_lock guard(d_data_mutex);
+ return d_tags;
+}
- template <class T>
- void
- vector_sink_impl<T> ::reset()
- {
- gr::thread::scoped_lock guard(d_data_mutex);
- d_tags.clear();
- d_data.clear();
- }
+template <class T>
+void vector_sink_impl<T>::reset()
+{
+ gr::thread::scoped_lock guard(d_data_mutex);
+ d_tags.clear();
+ d_data.clear();
+}
- template <class T>
- int
- vector_sink_impl<T> ::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- T *iptr = (T*)input_items[0];
+template <class T>
+int vector_sink_impl<T>::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ T* iptr = (T*)input_items[0];
- // can't touch this (as long as work() is working, the accessors shall not
- // read the data
- gr::thread::scoped_lock guard(d_data_mutex);
- for(unsigned int i = 0; i < noutput_items * d_vlen; i++)
- d_data.push_back (iptr[i]);
- std::vector<tag_t> tags;
- this->get_tags_in_range(tags, 0, this->nitems_read(0), this->nitems_read(0) + noutput_items);
- d_tags.insert(d_tags.end(), tags.begin(), tags.end());
- return noutput_items;
- }
+ // can't touch this (as long as work() is working, the accessors shall not
+ // read the data
+ gr::thread::scoped_lock guard(d_data_mutex);
+ for (unsigned int i = 0; i < noutput_items * d_vlen; i++)
+ d_data.push_back(iptr[i]);
+ std::vector<tag_t> tags;
+ this->get_tags_in_range(
+ tags, 0, this->nitems_read(0), this->nitems_read(0) + noutput_items);
+ d_tags.insert(d_tags.end(), tags.begin(), tags.end());
+ return noutput_items;
+}
template class vector_sink<std::uint8_t>;
template class vector_sink<std::int16_t>;
template class vector_sink<std::int32_t>;
template class vector_sink<float>;
template class vector_sink<gr_complex>;
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/vector_sink_impl.h b/gr-blocks/lib/vector_sink_impl.h
index 6e18e0b006..fd1263957b 100644
--- a/gr-blocks/lib/vector_sink_impl.h
+++ b/gr-blocks/lib/vector_sink_impl.h
@@ -28,31 +28,31 @@
#include <gnuradio/thread/thread.h>
namespace gr {
- namespace blocks {
-
-template<class T>
- class vector_sink_impl : public vector_sink<T>
- {
- private:
- std::vector<T> d_data;
- std::vector<tag_t> d_tags;
- mutable gr::thread::mutex d_data_mutex; // protects internal data access.
- unsigned int d_vlen;
-
- public:
- vector_sink_impl (unsigned int vlen, const int reserve_items);
- ~vector_sink_impl ();
-
- void reset();
- std::vector<T> data() const;
- std::vector<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 blocks {
+
+template <class T>
+class vector_sink_impl : public vector_sink<T>
+{
+private:
+ std::vector<T> d_data;
+ std::vector<tag_t> d_tags;
+ mutable gr::thread::mutex d_data_mutex; // protects internal data access.
+ unsigned int d_vlen;
+
+public:
+ vector_sink_impl(unsigned int vlen, const int reserve_items);
+ ~vector_sink_impl();
+
+ void reset();
+ std::vector<T> data() const;
+ std::vector<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 /* VECTOR_SINK_IMPL_H */
diff --git a/gr-blocks/lib/vector_source_impl.cc b/gr-blocks/lib/vector_source_impl.cc
index 24a21854f2..b7f9409631 100644
--- a/gr-blocks/lib/vector_source_impl.cc
+++ b/gr-blocks/lib/vector_source_impl.cc
@@ -31,123 +31,122 @@
#include <stdexcept>
namespace gr {
- namespace blocks {
+namespace blocks {
- template <class T>
- typename vector_source<T>::sptr
- vector_source<T>::make(const std::vector<T> &data,
- bool repeat, unsigned int vlen,
- const std::vector<tag_t> &tags)
- {
- return gnuradio::get_initial_sptr
- (new vector_source_impl<T> (data, repeat, vlen, tags));
- }
+template <class T>
+typename vector_source<T>::sptr vector_source<T>::make(const std::vector<T>& data,
+ bool repeat,
+ unsigned int vlen,
+ const std::vector<tag_t>& tags)
+{
+ return gnuradio::get_initial_sptr(
+ new vector_source_impl<T>(data, repeat, vlen, tags));
+}
- template <class T>
- vector_source_impl<T> ::vector_source_impl(const std::vector<T> &data,
- bool repeat, unsigned int vlen,
- const std::vector<tag_t> &tags)
+template <class T>
+vector_source_impl<T>::vector_source_impl(const std::vector<T>& data,
+ bool repeat,
+ unsigned int vlen,
+ const std::vector<tag_t>& tags)
: sync_block("vector_source",
- io_signature::make(0, 0, 0),
- io_signature::make(1, 1, sizeof(T) * vlen)),
+ io_signature::make(0, 0, 0),
+ io_signature::make(1, 1, sizeof(T) * vlen)),
d_data(data),
d_repeat(repeat),
d_offset(0),
d_vlen(vlen),
d_tags(tags)
- {
- if(tags.size() == 0) {
+{
+ if (tags.size() == 0) {
d_settags = 0;
- }
- else {
+ } else {
d_settags = 1;
this->set_output_multiple(data.size() / vlen);
- }
- if((data.size() % vlen) != 0)
- throw std::invalid_argument("data length must be a multiple of vlen");
}
+ if ((data.size() % vlen) != 0)
+ throw std::invalid_argument("data length must be a multiple of vlen");
+}
- template <class T>
- vector_source_impl<T> ::~vector_source_impl()
- {}
+template <class T>
+vector_source_impl<T>::~vector_source_impl()
+{
+}
- template <class T>
- void
- vector_source_impl<T> ::set_data (const std::vector<T> &data,
- const std::vector<tag_t> &tags)
- {
- d_data = data;
- d_tags = tags;
- rewind();
- if(tags.size() == 0) {
+template <class T>
+void vector_source_impl<T>::set_data(const std::vector<T>& data,
+ const std::vector<tag_t>& tags)
+{
+ d_data = data;
+ d_tags = tags;
+ rewind();
+ if (tags.size() == 0) {
d_settags = false;
- }
- else {
+ } else {
d_settags = true;
- }
}
+}
- template <class T>
- int
- vector_source_impl<T> ::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- T *optr = (T *) output_items[0];
+template <class T>
+int vector_source_impl<T>::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ T* optr = (T*)output_items[0];
- if(d_repeat) {
- unsigned int size = d_data.size ();
+ if (d_repeat) {
+ unsigned int size = d_data.size();
unsigned int offset = d_offset;
- if(size == 0)
- return -1;
+ 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 (T));
- optr += size;
- for(unsigned t = 0; t < d_tags.size(); t++) {
- this->add_item_tag(0, this->nitems_written(0)+i+d_tags[t].offset,
- d_tags[t].key, d_tags[t].value, d_tags[t].srcid);
+ 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(T));
+ optr += size;
+ for (unsigned t = 0; t < d_tags.size(); t++) {
+ this->add_item_tag(0,
+ this->nitems_written(0) + i + d_tags[t].offset,
+ d_tags[t].key,
+ d_tags[t].value,
+ d_tags[t].srcid);
+ }
}
- }
- }
- else {
- for(int i = 0; i < static_cast<int>(noutput_items*d_vlen); i++) {
- optr[i] = d_data[offset++];
- if(offset >= size) {
- offset = 0;
+ } else {
+ for (int i = 0; i < static_cast<int>(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!
+ } 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];
+ (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))
- this->add_item_tag(0, d_tags[t].offset, d_tags[t].key, d_tags[t].value,
- d_tags[t].srcid);
+ for (unsigned t = 0; t < d_tags.size(); t++) {
+ if ((d_tags[t].offset >= d_offset) && (d_tags[t].offset < d_offset + n))
+ this->add_item_tag(
+ 0, d_tags[t].offset, d_tags[t].key, d_tags[t].value, d_tags[t].srcid);
}
d_offset += n;
- return n/d_vlen;
- }
+ return n / d_vlen;
}
+}
template class vector_source<std::uint8_t>;
template class vector_source<std::int16_t>;
template class vector_source<std::int32_t>;
template class vector_source<float>;
template class vector_source<gr_complex>;
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/vector_source_impl.h b/gr-blocks/lib/vector_source_impl.h
index 19966d01e8..eaa8a0b6b0 100644
--- a/gr-blocks/lib/vector_source_impl.h
+++ b/gr-blocks/lib/vector_source_impl.h
@@ -27,36 +27,36 @@
#include <gnuradio/blocks/vector_source.h>
namespace gr {
- namespace blocks {
-
-template<class T>
- class vector_source_impl : public vector_source<T>
- {
- private:
- std::vector<T> d_data;
- bool d_repeat;
- unsigned int d_offset;
- unsigned int d_vlen;
- bool d_settags;
- std::vector<tag_t> d_tags;
-
- public:
- vector_source_impl (const std::vector<T> &data,
- bool repeat, unsigned int vlen,
- const std::vector<tag_t> &tags);
- ~vector_source_impl ();
-
- void rewind() { d_offset=0; }
- void set_data(const std::vector<T> &data,
- const std::vector<tag_t> &tags);
- void set_repeat(bool repeat) { d_repeat=repeat; };
-
- int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
- };
-
- } /* namespace blocks */
+namespace blocks {
+
+template <class T>
+class vector_source_impl : public vector_source<T>
+{
+private:
+ std::vector<T> d_data;
+ bool d_repeat;
+ unsigned int d_offset;
+ unsigned int d_vlen;
+ bool d_settags;
+ std::vector<tag_t> d_tags;
+
+public:
+ vector_source_impl(const std::vector<T>& data,
+ bool repeat,
+ unsigned int vlen,
+ const std::vector<tag_t>& tags);
+ ~vector_source_impl();
+
+ void rewind() { d_offset = 0; }
+ void set_data(const std::vector<T>& data, const std::vector<tag_t>& tags);
+ void set_repeat(bool repeat) { d_repeat = repeat; };
+
+ int work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
+
+} /* namespace blocks */
} /* namespace gr */
#endif /* VECTOR_SOURCE_IMPL_H */
diff --git a/gr-blocks/lib/vector_to_stream_impl.cc b/gr-blocks/lib/vector_to_stream_impl.cc
index 941a1f1752..2769dc13ae 100644
--- a/gr-blocks/lib/vector_to_stream_impl.cc
+++ b/gr-blocks/lib/vector_to_stream_impl.cc
@@ -28,35 +28,35 @@
#include <gnuradio/io_signature.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- vector_to_stream::sptr vector_to_stream::make(size_t itemsize, size_t nitems_per_block)
- {
- return gnuradio::get_initial_sptr(new vector_to_stream_impl(itemsize, nitems_per_block));
- }
+vector_to_stream::sptr vector_to_stream::make(size_t itemsize, size_t nitems_per_block)
+{
+ return gnuradio::get_initial_sptr(
+ new vector_to_stream_impl(itemsize, nitems_per_block));
+}
- vector_to_stream_impl::vector_to_stream_impl(size_t itemsize, size_t nitems_per_block)
- : sync_interpolator ("vector_to_stream",
- io_signature::make (1, 1, itemsize * nitems_per_block),
- io_signature::make (1, 1, itemsize),
- nitems_per_block)
- {
- }
+vector_to_stream_impl::vector_to_stream_impl(size_t itemsize, size_t nitems_per_block)
+ : sync_interpolator("vector_to_stream",
+ io_signature::make(1, 1, itemsize * nitems_per_block),
+ io_signature::make(1, 1, itemsize),
+ nitems_per_block)
+{
+}
- int
- vector_to_stream_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- size_t block_size = output_signature()->sizeof_stream_item (0);
+int vector_to_stream_impl::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ size_t block_size = output_signature()->sizeof_stream_item(0);
- const char *in = (const char *) input_items[0];
- char *out = (char *) output_items[0];
+ const char* in = (const char*)input_items[0];
+ char* out = (char*)output_items[0];
- memcpy (out, in, noutput_items * block_size);
+ memcpy(out, in, noutput_items * block_size);
- return noutput_items;
- }
+ return noutput_items;
+}
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/vector_to_stream_impl.h b/gr-blocks/lib/vector_to_stream_impl.h
index d2f4759cd9..6bb48390d5 100644
--- a/gr-blocks/lib/vector_to_stream_impl.h
+++ b/gr-blocks/lib/vector_to_stream_impl.h
@@ -26,19 +26,19 @@
#include <gnuradio/blocks/vector_to_stream.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class BLOCKS_API vector_to_stream_impl : public vector_to_stream
- {
- public:
- vector_to_stream_impl(size_t itemsize, size_t nitems_per_block);
+class BLOCKS_API vector_to_stream_impl : public vector_to_stream
+{
+public:
+ vector_to_stream_impl(size_t itemsize, size_t nitems_per_block);
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_VECTOR_TO_STREAM_IMPL_H */
diff --git a/gr-blocks/lib/vector_to_streams_impl.cc b/gr-blocks/lib/vector_to_streams_impl.cc
index 87f3e8e23c..66fc217eff 100644
--- a/gr-blocks/lib/vector_to_streams_impl.cc
+++ b/gr-blocks/lib/vector_to_streams_impl.cc
@@ -28,41 +28,40 @@
#include <gnuradio/io_signature.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- vector_to_streams::sptr vector_to_streams::make(size_t itemsize, size_t nstreams)
- {
- return gnuradio::get_initial_sptr(new vector_to_streams_impl(itemsize, nstreams));
- }
-
- vector_to_streams_impl::vector_to_streams_impl(size_t itemsize, size_t nstreams)
- : sync_block ("vector_to_streams",
- io_signature::make (1, 1, nstreams * itemsize),
- io_signature::make (nstreams, nstreams, itemsize))
+vector_to_streams::sptr vector_to_streams::make(size_t itemsize, size_t nstreams)
+{
+ return gnuradio::get_initial_sptr(new vector_to_streams_impl(itemsize, nstreams));
+}
- {
- }
+vector_to_streams_impl::vector_to_streams_impl(size_t itemsize, size_t nstreams)
+ : sync_block("vector_to_streams",
+ io_signature::make(1, 1, nstreams * itemsize),
+ io_signature::make(nstreams, nstreams, itemsize))
- int
- vector_to_streams_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- size_t itemsize = output_signature()->sizeof_stream_item(0);
- int nstreams = output_items.size();
+{
+}
- const char *in = (const char *) input_items[0];
- char **outv = (char **) &output_items[0];
+int vector_to_streams_impl::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ size_t itemsize = output_signature()->sizeof_stream_item(0);
+ int nstreams = output_items.size();
- for (int i = 0; i < noutput_items; i++){
- for (int j = 0; j < nstreams; j++){
- memcpy(outv[j], in, itemsize);
- outv[j] += itemsize;
- in += itemsize;
- }
- }
+ const char* in = (const char*)input_items[0];
+ char** outv = (char**)&output_items[0];
- return noutput_items;
+ for (int i = 0; i < noutput_items; i++) {
+ for (int j = 0; j < nstreams; j++) {
+ memcpy(outv[j], in, itemsize);
+ outv[j] += itemsize;
+ in += itemsize;
+ }
}
- } /* namespace blocks */
+
+ return noutput_items;
+}
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/vector_to_streams_impl.h b/gr-blocks/lib/vector_to_streams_impl.h
index b5393729eb..eb336bdbfb 100644
--- a/gr-blocks/lib/vector_to_streams_impl.h
+++ b/gr-blocks/lib/vector_to_streams_impl.h
@@ -26,19 +26,19 @@
#include <gnuradio/blocks/vector_to_streams.h>
namespace gr {
- namespace blocks {
+namespace blocks {
- class BLOCKS_API vector_to_streams_impl : public vector_to_streams
- {
- public:
- vector_to_streams_impl(size_t itemsize, size_t nstreams);
+class BLOCKS_API vector_to_streams_impl : public vector_to_streams
+{
+public:
+ vector_to_streams_impl(size_t itemsize, size_t nstreams);
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_VECTOR_TO_STREAMS_IMPL_H */
diff --git a/gr-blocks/lib/wavfile.cc b/gr-blocks/lib/wavfile.cc
index e191f763c2..72cec7d8bc 100644
--- a/gr-blocks/lib/wavfile.cc
+++ b/gr-blocks/lib/wavfile.cc
@@ -30,250 +30,239 @@
#include <boost/detail/endian.hpp> //BOOST_BIG_ENDIAN
namespace gr {
- namespace blocks {
+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
+// 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 __gri_wav_bs16(uint16_t x)
- {
- return (x>>8) | (x<<8);
- }
+static inline uint16_t __gri_wav_bs16(uint16_t x) { return (x >> 8) | (x << 8); }
- static inline uint32_t __gri_wav_bs32(uint32_t x)
- {
- return (uint32_t(__gri_wav_bs16(uint16_t(x&0xfffful)))<<16) | (__gri_wav_bs16(uint16_t(x>>16)));
- }
+static inline uint32_t __gri_wav_bs32(uint32_t x)
+{
+ return (uint32_t(__gri_wav_bs16(uint16_t(x & 0xfffful))) << 16) |
+ (__gri_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)
+#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)
+#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) {
- if (fseek(fp, fmt_hdr_skip, SEEK_CUR) != 0) {
- return false;
- }
- }
-
- // find data chunk
- fresult = fread(str_buf, 1, 4, fp);
- // keep parsing chunk until we hit the data chunk
- while(fresult != 4 || strncmp(str_buf, "data", 4))
- {
- // all good?
- if(fresult != 4 || ferror(fp) || feof(fp)) {
- return false;
- }
- // get chunk body size and skip
- fresult = fread(&chunk_size, 1, 4, fp);
- if(fresult != 4 || ferror(fp) || feof(fp)) {
- return false;
+// 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) {
+ if (fseek(fp, fmt_hdr_skip, SEEK_CUR) != 0) {
+ return false;
+ }
+ }
+
+ // find data chunk
+ fresult = fread(str_buf, 1, 4, fp);
+ // keep parsing chunk until we hit the data chunk
+ while (fresult != 4 || strncmp(str_buf, "data", 4)) {
+ // all good?
+ if (fresult != 4 || ferror(fp) || feof(fp)) {
+ return false;
+ }
+ // get chunk body size and skip
+ fresult = fread(&chunk_size, 1, 4, fp);
+ if (fresult != 4 || ferror(fp) || feof(fp)) {
+ return false;
+ }
+ chunk_size = wav_to_host(chunk_size);
+ if (fseek(fp, chunk_size, SEEK_CUR) != 0) {
+ return false;
}
- chunk_size = wav_to_host(chunk_size);
- if(fseek(fp, chunk_size, SEEK_CUR) != 0) {
- return false;
- }
// read next chunk type
fresult = fread(str_buf, 1, 4, fp);
- }
-
- 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;
}
+ fresult = fread(&chunk_size, 1, 4, fp);
+ if (ferror(fp)) {
+ return false;
+ }
+
+ // More byte swapping
+ chunk_size = wav_to_host(chunk_size);
- short int
- wav_read_sample(FILE *fp, int bytes_per_sample)
- {
- int16_t buf_16bit = 0;
+ // 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;
+}
- if(fread(&buf_16bit, bytes_per_sample, 1, fp) != 1) {
- return 0;
- }
- if(bytes_per_sample == 1) {
- return (short)buf_16bit;
- }
- return (short)wav_to_host(buf_16bit);
- }
+short int wav_read_sample(FILE* fp, int bytes_per_sample)
+{
+ int16_t buf_16bit = 0;
- 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;
+ if (fread(&buf_16bit, bytes_per_sample, 1, fp) != 1) {
+ 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;
- }
+void wav_write_sample(FILE* fp, short int sample, int bytes_per_sample)
+{
+ void* data_ptr;
+ unsigned char buf_8bit;
+ int16_t buf_16bit;
- fwrite(data_ptr, 1, bytes_per_sample, fp);
+ 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);
- if (fseek(fp, 40, SEEK_SET) != 0) {
- return false;
- }
- fwrite(&chunk_size, 1, 4, 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);
- chunk_size = (uint32_t)byte_count + 36; // fmt chunk and data header
- chunk_size = host_to_wav(chunk_size);
- if (fseek(fp, 4, SEEK_SET) != 0) {
- return false;
- }
+ if (fseek(fp, 40, SEEK_SET) != 0) {
+ return false;
+ }
+ fwrite(&chunk_size, 1, 4, fp);
- 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);
+ if (fseek(fp, 4, SEEK_SET) != 0) {
+ return false;
+ }
- if(ferror(fp)) {
- return false;
- }
+ fwrite(&chunk_size, 1, 4, fp);
- return true;
+ if (ferror(fp)) {
+ return false;
}
- } /* namespace blocks */
+ return true;
+}
+
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/wavfile_sink_impl.cc b/gr-blocks/lib/wavfile_sink_impl.cc
index dfa5ce425a..8ce5d94b96 100644
--- a/gr-blocks/lib/wavfile_sink_impl.cc
+++ b/gr-blocks/lib/wavfile_sink_impl.cc
@@ -53,246 +53,220 @@
#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));
+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)
+ : sync_block("wavfile_sink",
+ io_signature::make(1, n_channels, sizeof(float)),
+ io_signature::make(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;
- wavfile_sink_impl::wavfile_sink_impl(const char *filename,
- int n_channels,
- unsigned int sample_rate,
- int bits_per_sample)
- : sync_block("wavfile_sink",
- io_signature::make(1, n_channels, sizeof(float)),
- io_signature::make(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 (!open(filename)) {
+ throw std::runtime_error("can't open file");
}
- bool
- wavfile_sink_impl::open(const char* filename)
- {
- gr::thread::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;
+ 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;
+ }
+}
+
+bool wavfile_sink_impl::open(const char* filename)
+{
+ gr::thread::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;
}
- void
- wavfile_sink_impl::close()
- {
- gr::thread::scoped_lock guard(d_mutex);
+ 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_fp)
- return;
+ 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;
- close_wav();
+ 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);
}
- void
- wavfile_sink_impl::close_wav()
- {
- unsigned int byte_count = d_sample_count * d_bytes_per_sample;
+ return true;
+}
- wavheader_complete(d_fp, byte_count);
+void wavfile_sink_impl::close()
+{
+ gr::thread::scoped_lock guard(d_mutex);
- fclose(d_fp);
- d_fp = NULL;
- }
+ if (!d_fp)
+ return;
- wavfile_sink_impl::~wavfile_sink_impl()
- {
- stop();
- }
+ close_wav();
+}
- bool wavfile_sink_impl::stop()
- {
- if(d_new_fp) {
- fclose(d_new_fp);
- d_new_fp = NULL;
- }
+void wavfile_sink_impl::close_wav()
+{
+ unsigned int byte_count = d_sample_count * d_bytes_per_sample;
- close();
+ wavheader_complete(d_fp, byte_count);
- return true;
- }
+ fclose(d_fp);
+ d_fp = NULL;
+}
- 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;
-
- gr::thread::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;
+wavfile_sink_impl::~wavfile_sink_impl() { stop(); }
+
+bool wavfile_sink_impl::stop()
+{
+ if (d_new_fp) {
+ fclose(d_new_fp);
+ d_new_fp = NULL;
}
- 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);
+ close();
+
+ return true;
+}
+
+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;
+
+ gr::thread::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++;
+ }
}
- void
- wavfile_sink_impl::set_bits_per_sample(int bits_per_sample)
- {
- gr::thread::scoped_lock guard(d_mutex);
- if(bits_per_sample == 8 || bits_per_sample == 16) {
- d_bytes_per_sample_new = bits_per_sample / 8;
- }
+ 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;
}
- void
- wavfile_sink_impl::set_sample_rate(unsigned int sample_rate)
- {
- gr::thread::scoped_lock guard(d_mutex);
- d_sample_rate = sample_rate;
+ return (short int)boost::math::iround(sample);
+}
+
+void wavfile_sink_impl::set_bits_per_sample(int bits_per_sample)
+{
+ gr::thread::scoped_lock guard(d_mutex);
+ if (bits_per_sample == 8 || bits_per_sample == 16) {
+ d_bytes_per_sample_new = bits_per_sample / 8;
}
+}
- int
- wavfile_sink_impl::bits_per_sample()
- {
- return d_bytes_per_sample_new;
+void wavfile_sink_impl::set_sample_rate(unsigned int sample_rate)
+{
+ gr::thread::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;
}
- unsigned int
- wavfile_sink_impl::sample_rate()
- {
- return d_sample_rate;
+ if (d_fp) {
+ close_wav();
}
- 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;
+ 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;
}
- } /* namespace blocks */
+ 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
index 0e77f9799e..38a757704b 100644
--- a/gr-blocks/lib/wavfile_sink_impl.h
+++ b/gr-blocks/lib/wavfile_sink_impl.h
@@ -26,72 +26,72 @@
#include <gnuradio/blocks/wavfile_sink.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();
-
- protected:
- bool stop();
-
- 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 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();
+
+protected:
+ bool stop();
+
+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
index 7538792d1c..b1950f2deb 100644
--- a/gr-blocks/lib/wavfile_source_impl.cc
+++ b/gr-blocks/lib/wavfile_source_impl.cc
@@ -36,139 +36,138 @@
#include <io.h>
#endif
#ifdef O_BINARY
-#define OUR_O_BINARY O_BINARY
+#define OUR_O_BINARY O_BINARY
#else
-#define OUR_O_BINARY 0
+#define OUR_O_BINARY 0
#endif
// should be handled via configure
#ifdef O_LARGEFILE
-#define OUR_O_LARGEFILE O_LARGEFILE
+#define OUR_O_LARGEFILE O_LARGEFILE
#else
-#define OUR_O_LARGEFILE 0
+#define OUR_O_LARGEFILE 0
#endif
namespace gr {
- namespace blocks {
+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)
+ : sync_block("wavfile_source",
+ io_signature::make(0, 0, 0),
+ io_signature::make(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");
+ }
- wavfile_source::sptr
- wavfile_source::make(const char *filename, bool repeat)
- {
- return gnuradio::get_initial_sptr
- (new wavfile_source_impl(filename, repeat));
+ if ((d_fp = fdopen(fd, "rb")) == NULL) {
+ perror(filename);
+ throw std::runtime_error("can't open file");
}
- wavfile_source_impl::wavfile_source_impl (const char *filename, bool repeat)
- : sync_block("wavfile_source",
- io_signature::make(0, 0, 0),
- io_signature::make(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(io_signature::make(1, d_nchans, sizeof(float)));
+ // 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");
}
- wavfile_source_impl::~wavfile_source_impl ()
- {
- fclose(d_fp);
+ if (d_samples_per_chan == 0) {
+ throw std::runtime_error("WAV file does not contain any samples");
}
- 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;
+ if (d_bytes_per_sample == 1) {
+ d_normalize_fac = 128;
+ d_normalize_shift = 1;
+ } else {
+ d_normalize_fac = 0x7FFF;
+ d_normalize_shift = 0;
}
- 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;
+ // Re-set the output signature
+ set_output_signature(io_signature::make(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;
+ }
}
- } /* namespace blocks */
+ 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
index 3996cb0606..677c95562b 100644
--- a/gr-blocks/lib/wavfile_source_impl.h
+++ b/gr-blocks/lib/wavfile_source_impl.h
@@ -24,47 +24,47 @@
#define INCLUDED_GR_WAVFILE_SOURCE_IMPL_H
#include <gnuradio/blocks/wavfile_source.h>
-#include <cstdio> // for FILE
+#include <cstdio> // for FILE
namespace gr {
- namespace blocks {
+namespace blocks {
- class wavfile_source_impl : public wavfile_source
- {
- private:
- FILE *d_fp;
- bool d_repeat;
+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;
+ 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);
+ /*!
+ * \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();
+public:
+ wavfile_source_impl(const char* filename, bool repeat);
+ ~wavfile_source_impl();
- unsigned int sample_rate() const { return d_sample_rate; };
+ unsigned int sample_rate() const { return d_sample_rate; };
- int bits_per_sample() const { return d_bytes_per_sample * 8; };
+ int bits_per_sample() const { return d_bytes_per_sample * 8; };
- int channels() const { return d_nchans; };
+ int channels() const { return d_nchans; };
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* INCLUDED_GR_WAVFILE_SOURCE_IMPL_H */
diff --git a/gr-blocks/lib/xor_blk_impl.cc b/gr-blocks/lib/xor_blk_impl.cc
index 5180e6a600..ca8c623a65 100644
--- a/gr-blocks/lib/xor_blk_impl.cc
+++ b/gr-blocks/lib/xor_blk_impl.cc
@@ -29,45 +29,44 @@
#include <gnuradio/io_signature.h>
namespace gr {
- namespace blocks {
- template <class T>
- typename xor_blk<T>::sptr xor_blk<T>::make(size_t vlen)
- {
- return gnuradio::get_initial_sptr(new xor_blk_impl<T> (vlen));
- }
+namespace blocks {
+template <class T>
+typename xor_blk<T>::sptr xor_blk<T>::make(size_t vlen)
+{
+ return gnuradio::get_initial_sptr(new xor_blk_impl<T>(vlen));
+}
- template <class T>
- xor_blk_impl<T> ::xor_blk_impl(size_t vlen)
- : sync_block ("xor_blk",
- io_signature::make (1, -1, sizeof (T)*vlen),
- io_signature::make (1, 1, sizeof (T)*vlen)),
+template <class T>
+xor_blk_impl<T>::xor_blk_impl(size_t vlen)
+ : sync_block("xor_blk",
+ io_signature::make(1, -1, sizeof(T) * vlen),
+ io_signature::make(1, 1, sizeof(T) * vlen)),
d_vlen(vlen)
- {
- }
+{
+}
- template <class T>
- int
- xor_blk_impl<T> ::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- T *optr = (T *) output_items[0];
+template <class T>
+int xor_blk_impl<T>::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ T* optr = (T*)output_items[0];
- int ninputs = input_items.size ();
+ int ninputs = input_items.size();
- for (size_t i = 0; i < noutput_items*d_vlen; i++){
- T acc = ((T *) input_items[0])[i];
- for (int j = 1; j < ninputs; j++)
- acc ^= ((T *) input_items[j])[i];
+ for (size_t i = 0; i < noutput_items * d_vlen; i++) {
+ T acc = ((T*)input_items[0])[i];
+ for (int j = 1; j < ninputs; j++)
+ acc ^= ((T*)input_items[j])[i];
- *optr++ = (T) acc;
- }
-
- return noutput_items;
+ *optr++ = (T)acc;
}
+ return noutput_items;
+}
+
template class xor_blk<std::uint8_t>;
template class xor_blk<std::int16_t>;
template class xor_blk<std::int32_t>;
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/xor_blk_impl.h b/gr-blocks/lib/xor_blk_impl.h
index 72caa0a799..73ebe486d1 100644
--- a/gr-blocks/lib/xor_blk_impl.h
+++ b/gr-blocks/lib/xor_blk_impl.h
@@ -27,22 +27,22 @@
#include <gnuradio/blocks/xor_blk.h>
namespace gr {
- namespace blocks {
+namespace blocks {
-template<class T>
- class BLOCKS_API xor_blk_impl : public xor_blk<T>
- {
- size_t d_vlen;
+template <class T>
+class BLOCKS_API xor_blk_impl : public xor_blk<T>
+{
+ size_t d_vlen;
- public:
- xor_blk_impl (size_t vlen);
+public:
+ xor_blk_impl(size_t vlen);
- 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_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace blocks */
+} /* namespace blocks */
} /* namespace gr */
#endif /* XOR_BLK_IMPL_H */
diff --git a/gr-blocks/tests/benchmark_nco.cc b/gr-blocks/tests/benchmark_nco.cc
index ac172bf79d..71946dc3fe 100644
--- a/gr-blocks/tests/benchmark_nco.cc
+++ b/gr-blocks/tests/benchmark_nco.cc
@@ -40,188 +40,183 @@
#include <cstring>
#define ITERATIONS 20000000
-#define BLOCK_SIZE (10 * 1000) // fits in cache
+#define BLOCK_SIZE (10 * 1000) // fits in cache
#define FREQ 5003.123
-static double
-timeval_to_double(const struct timeval *tv)
+static double timeval_to_double(const struct timeval* tv)
{
- return (double)tv->tv_sec + (double)tv->tv_usec * 1e-6;
+ return (double)tv->tv_sec + (double)tv->tv_usec * 1e-6;
}
-static void
-benchmark(void test (float *x, float *y), const char *implementation_name)
+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;
+ struct rusage rusage_start;
+ struct rusage rusage_stop;
#else
- double clock_start;
- double clock_end;
+ double clock_start;
+ double clock_end;
#endif
- float output[2*BLOCK_SIZE];
- float *x = &output[0], *y = &output[BLOCK_SIZE];
+ float output[2 * BLOCK_SIZE];
+ float *x = &output[0], *y = &output[BLOCK_SIZE];
- // touch memory
- memset(output, 0, 2*BLOCK_SIZE*sizeof(float));
+ // touch memory
+ memset(output, 0, 2 * BLOCK_SIZE * sizeof(float));
- // get starting CPU usage
+ // get starting CPU usage
#ifdef HAVE_SYS_RESOURCE_H
- if(getrusage(RUSAGE_SELF, &rusage_start) < 0) {
- perror("getrusage");
- exit(1);
- }
+ if (getrusage(RUSAGE_SELF, &rusage_start) < 0) {
+ perror("getrusage");
+ exit(1);
+ }
#else
- clock_start = (double)clock() * (1000000. / CLOCKS_PER_SEC);
+ clock_start = (double)clock() * (1000000. / CLOCKS_PER_SEC);
#endif
- // do the actual work
+ // do the actual work
- test(x, y);
+ test(x, y);
- // get ending CPU usage
+ // get ending CPU usage
#ifdef HAVE_SYS_RESOURCE_H
- if(getrusage(RUSAGE_SELF, &rusage_stop) < 0) {
- perror("getrusage");
- exit(1);
- }
+ if (getrusage(RUSAGE_SELF, &rusage_stop) < 0) {
+ perror("getrusage");
+ exit(1);
+ }
- // compute results
+ // compute results
- double user =
- timeval_to_double(&rusage_stop.ru_utime)
- - timeval_to_double(&rusage_start.ru_utime);
+ 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 sys = timeval_to_double(&rusage_stop.ru_stime) -
+ timeval_to_double(&rusage_start.ru_stime);
- double total = user + sys;
+ double total = user + sys;
#else
- clock_end = (double)clock() * (1000000. / CLOCKS_PER_SEC);
- double total = clock_end - clock_start;
+ 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);
+ 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)
+void basic_sincos_vec(float* x, float* y)
{
- gr::blocks::nco<float,float> nco;
+ gr::blocks::nco<float, float> nco;
- nco.set_freq(2 * GR_M_PI / FREQ);
+ nco.set_freq(2 * GR_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();
+ 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)
+void native_sincos_vec(float* x, float* y)
{
- gr::blocks::nco<float,float> nco;
+ gr::blocks::nco<float, float> nco;
- nco.set_freq(2 * GR_M_PI / FREQ);
+ nco.set_freq(2 * GR_M_PI / FREQ);
- for(int i = 0; i < ITERATIONS/BLOCK_SIZE; i++) {
- nco.sincos((gr_complex*)x, BLOCK_SIZE);
- }
+ for (int i = 0; i < ITERATIONS / BLOCK_SIZE; i++) {
+ nco.sincos((gr_complex*)x, BLOCK_SIZE);
+ }
}
-void fxpt_sincos_vec(float *x, float *y)
+void fxpt_sincos_vec(float* x, float* y)
{
- gr::blocks::fxpt_nco nco;
+ gr::blocks::fxpt_nco nco;
- nco.set_freq (2 * GR_M_PI / FREQ);
+ nco.set_freq(2 * GR_M_PI / FREQ);
- for(int i = 0; i < ITERATIONS/BLOCK_SIZE; i++) {
- nco.sincos((gr_complex*)x, BLOCK_SIZE);
- }
+ for (int i = 0; i < ITERATIONS / BLOCK_SIZE; i++) {
+ nco.sincos((gr_complex*)x, BLOCK_SIZE);
+ }
}
// ----------------------------------------------------------------
-void native_sincos(float *x, float *y)
+void native_sincos(float* x, float* y)
{
- gr::blocks::nco<float,float> nco;
+ gr::blocks::nco<float, float> nco;
- nco.set_freq(2 * GR_M_PI / FREQ);
+ nco.set_freq(2 * GR_M_PI / FREQ);
- for(int i = 0; i < ITERATIONS; i++) {
- nco.sincos(x, y);
- nco.step();
- }
+ for (int i = 0; i < ITERATIONS; i++) {
+ nco.sincos(x, y);
+ nco.step();
+ }
}
-void fxpt_sincos(float *x, float *y)
+void fxpt_sincos(float* x, float* y)
{
- gr::blocks::fxpt_nco nco;
+ gr::blocks::fxpt_nco nco;
- nco.set_freq(2 * GR_M_PI / FREQ);
+ nco.set_freq(2 * GR_M_PI / FREQ);
- for(int i = 0; i < ITERATIONS; i++) {
- nco.sincos(x, y);
- nco.step();
- }
+ for (int i = 0; i < ITERATIONS; i++) {
+ nco.sincos(x, y);
+ nco.step();
+ }
}
// ----------------------------------------------------------------
-void native_sin(float *x, float *y)
+void native_sin(float* x, float* y)
{
- gr::blocks::nco<float,float> nco;
+ gr::blocks::nco<float, float> nco;
- nco.set_freq(2 * GR_M_PI / FREQ);
+ nco.set_freq(2 * GR_M_PI / FREQ);
- for(int i = 0; i < ITERATIONS; i++) {
- *x = nco.sin();
- nco.step();
- }
+ for (int i = 0; i < ITERATIONS; i++) {
+ *x = nco.sin();
+ nco.step();
+ }
}
-void fxpt_sin(float *x, float *y)
+void fxpt_sin(float* x, float* y)
{
- gr::blocks::fxpt_nco nco;
+ gr::blocks::fxpt_nco nco;
- nco.set_freq(2 * GR_M_PI / FREQ);
+ nco.set_freq(2 * GR_M_PI / FREQ);
- for(int i = 0; i < ITERATIONS; i++) {
- *x = nco.sin();
- nco.step();
- }
+ for (int i = 0; i < ITERATIONS; i++) {
+ *x = nco.sin();
+ nco.step();
+ }
}
// ----------------------------------------------------------------
-void nop_fct(float *x, float *y)
-{
-}
+void nop_fct(float* x, float* y) {}
-void nop_loop(float *x, float *y)
+void nop_loop(float* x, float* y)
{
- for(int i = 0; i < ITERATIONS; i++) {
- nop_fct(x, y);
- }
+ for (int i = 0; i < ITERATIONS; i++) {
+ nop_fct(x, y);
+ }
}
-int
-main(int argc, char **argv)
+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");
+ 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
index 5c5aad30fc..a8fae75a47 100644
--- a/gr-blocks/tests/benchmark_vco.cc
+++ b/gr-blocks/tests/benchmark_vco.cc
@@ -40,135 +40,131 @@
#include <cstring>
#define ITERATIONS 5000000
-#define BLOCK_SIZE (10 * 1000) // fits in cache
+#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)
+static double timeval_to_double(const struct timeval* tv)
{
- return (double) tv->tv_sec + (double) tv->tv_usec * 1e-6;
+ 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)
+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;
+ struct rusage rusage_start;
+ struct rusage rusage_stop;
#else
- double clock_start;
- double clock_end;
+ double clock_start;
+ double clock_end;
#endif
- float output[BLOCK_SIZE];
- float input[BLOCK_SIZE];
+ 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));
+ // 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
+ // get starting CPU usage
#ifdef HAVE_SYS_RESOURCE_H
- if(getrusage (RUSAGE_SELF, &rusage_start) < 0) {
- perror("getrusage");
- exit(1);
- }
+ if (getrusage(RUSAGE_SELF, &rusage_start) < 0) {
+ perror("getrusage");
+ exit(1);
+ }
#else
- clock_start = (double)clock() * (1000000. / CLOCKS_PER_SEC);
+ clock_start = (double)clock() * (1000000. / CLOCKS_PER_SEC);
#endif
- // do the actual work
+ // do the actual work
- test(output, input);
+ test(output, input);
- // get ending CPU usage
+ // get ending CPU usage
#ifdef HAVE_SYS_RESOURCE_H
- if(getrusage (RUSAGE_SELF, &rusage_stop) < 0) {
- perror("getrusage");
- exit(1);
- }
+ if (getrusage(RUSAGE_SELF, &rusage_stop) < 0) {
+ perror("getrusage");
+ exit(1);
+ }
- // compute results
+ // compute results
- double user =
- timeval_to_double(&rusage_stop.ru_utime)
- - timeval_to_double(&rusage_start.ru_utime);
+ 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 sys = timeval_to_double(&rusage_stop.ru_stime) -
+ timeval_to_double(&rusage_start.ru_stime);
- double total = user + sys;
+ double total = user + sys;
#else
- clock_end = (double)clock() * (1000000. / CLOCKS_PER_SEC);
- double total = clock_end - clock_start;
+ 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);
+ printf("%18s: cpu: %6.3f steps/sec: %10.3e\n",
+ implementation_name,
+ total,
+ ITERATIONS / total);
}
// ----------------------------------------------------------------
-void basic_vco(float *output, const float *input)
+void basic_vco(float* output, const float* input)
{
- double phase = 0;
+ 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;
+ 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 * GR_M_PI)
- phase -= 2 * GR_M_PI;
+ while (phase > 2 * GR_M_PI)
+ phase -= 2 * GR_M_PI;
- while(phase < -2 * GR_M_PI)
- phase += 2 * GR_M_PI;
+ while (phase < -2 * GR_M_PI)
+ phase += 2 * GR_M_PI;
+ }
}
- }
}
-void native_vco(float *output, const float *input)
+void native_vco(float* output, const float* input)
{
- gr::blocks::vco<float,float> vco;
+ gr::blocks::vco<float, float> vco;
- for(int j = 0; j < ITERATIONS/BLOCK_SIZE; j++) {
- vco.cos(output, input, BLOCK_SIZE, K, AMPLITUDE);
- }
+ 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)
+void fxpt_vco(float* output, const float* input)
{
- gr::blocks::fxpt_vco vco;
+ gr::blocks::fxpt_vco vco;
- for(int j = 0; j < ITERATIONS/BLOCK_SIZE; j++) {
- vco.cos(output, input, BLOCK_SIZE, K, AMPLITUDE);
- }
+ 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_fct(float* x, const float* y) {}
-void nop_loop(float *x, const float *y)
+void nop_loop(float* x, const float* y)
{
- for(int i = 0; i < ITERATIONS; i++) {
- nop_fct(x, y);
- }
+ for (int i = 0; i < ITERATIONS; i++) {
+ nop_fct(x, y);
+ }
}
-int
-main(int argc, char **argv)
+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");
+ benchmark(nop_loop, "nop loop");
+ benchmark(basic_vco, "basic vco");
+ benchmark(native_vco, "native vco");
+ benchmark(fxpt_vco, "fxpt vco");
}