diff options
Diffstat (limited to 'gnuradio-core/src')
35 files changed, 477 insertions, 103 deletions
diff --git a/gnuradio-core/src/lib/general/CMakeLists.txt b/gnuradio-core/src/lib/general/CMakeLists.txt index 2bc639cd3..ee6e4c4e6 100644 --- a/gnuradio-core/src/lib/general/CMakeLists.txt +++ b/gnuradio-core/src/lib/general/CMakeLists.txt @@ -252,7 +252,6 @@ set(gr_core_general_triple_threats gr_probe_avg_mag_sqrd_c gr_probe_avg_mag_sqrd_cf gr_probe_avg_mag_sqrd_f - gr_probe_signal_f gr_pwr_squelch_cc gr_pwr_squelch_ff gr_quadrature_demod_cf diff --git a/gnuradio-core/src/lib/general/Makefile.am b/gnuradio-core/src/lib/general/Makefile.am index 5b4a702e1..ba1f686ab 100644 --- a/gnuradio-core/src/lib/general/Makefile.am +++ b/gnuradio-core/src/lib/general/Makefile.am @@ -117,7 +117,6 @@ libgeneral_la_SOURCES = \ gr_probe_avg_mag_sqrd_c.cc \ gr_probe_avg_mag_sqrd_cf.cc \ gr_probe_avg_mag_sqrd_f.cc \ - gr_probe_signal_f.cc \ gr_pwr_squelch_cc.cc \ gr_pwr_squelch_ff.cc \ gr_quadrature_demod_cf.cc \ @@ -279,7 +278,6 @@ grinclude_HEADERS = \ gr_probe_avg_mag_sqrd_c.h \ gr_probe_avg_mag_sqrd_cf.h \ gr_probe_avg_mag_sqrd_f.h \ - gr_probe_signal_f.h \ gr_pwr_squelch_cc.h \ gr_pwr_squelch_ff.h \ gr_quadrature_demod_cf.h \ @@ -443,7 +441,6 @@ swiginclude_HEADERS = \ gr_probe_avg_mag_sqrd_c.i \ gr_probe_avg_mag_sqrd_cf.i \ gr_probe_avg_mag_sqrd_f.i \ - gr_probe_signal_f.i \ gr_pwr_squelch_cc.i \ gr_pwr_squelch_ff.i \ gr_quadrature_demod_cf.i \ diff --git a/gnuradio-core/src/lib/general/general.i b/gnuradio-core/src/lib/general/general.i index 89738b01a..fcf60c927 100644 --- a/gnuradio-core/src/lib/general/general.i +++ b/gnuradio-core/src/lib/general/general.i @@ -92,7 +92,6 @@ #include <gr_probe_avg_mag_sqrd_c.h> #include <gr_probe_avg_mag_sqrd_cf.h> #include <gr_probe_avg_mag_sqrd_f.h> -#include <gr_probe_signal_f.h> #include <gr_regenerate_bb.h> #include <gr_pa_2x2_phase_combiner.h> #include <gr_kludge_copy.h> @@ -214,7 +213,6 @@ %include "gr_probe_avg_mag_sqrd_c.i" %include "gr_probe_avg_mag_sqrd_cf.i" %include "gr_probe_avg_mag_sqrd_f.i" -%include "gr_probe_signal_f.i" %include "gr_regenerate_bb.i" %include "gr_pa_2x2_phase_combiner.i" %include "gr_kludge_copy.i" diff --git a/gnuradio-core/src/lib/general/general_generated.i b/gnuradio-core/src/lib/general/general_generated.i index e12f2b0ec..89b7e1776 100644 --- a/gnuradio-core/src/lib/general/general_generated.i +++ b/gnuradio-core/src/lib/general/general_generated.i @@ -51,6 +51,16 @@ #include <gr_packed_to_unpacked_bb.h> #include <gr_packed_to_unpacked_ii.h> #include <gr_packed_to_unpacked_ss.h> +#include <gr_probe_signal_b.h> +#include <gr_probe_signal_s.h> +#include <gr_probe_signal_i.h> +#include <gr_probe_signal_f.h> +#include <gr_probe_signal_c.h> +#include <gr_probe_signal_vb.h> +#include <gr_probe_signal_vs.h> +#include <gr_probe_signal_vi.h> +#include <gr_probe_signal_vf.h> +#include <gr_probe_signal_vc.h> #include <gr_sig_source_c.h> #include <gr_sig_source_f.h> #include <gr_sig_source_i.h> @@ -123,6 +133,16 @@ %include <gr_packed_to_unpacked_bb.i> %include <gr_packed_to_unpacked_ii.i> %include <gr_packed_to_unpacked_ss.i> +%include <gr_probe_signal_b.i> +%include <gr_probe_signal_s.i> +%include <gr_probe_signal_i.i> +%include <gr_probe_signal_f.i> +%include <gr_probe_signal_c.i> +%include <gr_probe_signal_vb.i> +%include <gr_probe_signal_vs.i> +%include <gr_probe_signal_vi.i> +%include <gr_probe_signal_vf.i> +%include <gr_probe_signal_vc.i> %include <gr_sig_source_c.i> %include <gr_sig_source_f.i> %include <gr_sig_source_i.i> diff --git a/gnuradio-core/src/lib/general/gr_char_to_float.h b/gnuradio-core/src/lib/general/gr_char_to_float.h index 4ad8e59a8..1ab53a087 100644 --- a/gnuradio-core/src/lib/general/gr_char_to_float.h +++ b/gnuradio-core/src/lib/general/gr_char_to_float.h @@ -35,6 +35,9 @@ gr_make_char_to_float (size_t vlen=1, float scale=1); /*! * \brief Convert stream of chars to a stream of float * \ingroup converter_blk + * + * \param vlen vector length of data streams. + * \param scale a scalar divider to change the output signal scale. */ class GR_CORE_API gr_char_to_float : public gr_sync_block @@ -48,7 +51,14 @@ class GR_CORE_API gr_char_to_float : public gr_sync_block float d_scale; public: + /*! + * Get the scalar divider value. + */ float scale() const; + + /*! + * Set the scalar divider value. + */ void set_scale(float scale); virtual int work (int noutput_items, diff --git a/gnuradio-core/src/lib/general/gr_char_to_short.h b/gnuradio-core/src/lib/general/gr_char_to_short.h index 58f9a62b0..e93c15b12 100644 --- a/gnuradio-core/src/lib/general/gr_char_to_short.h +++ b/gnuradio-core/src/lib/general/gr_char_to_short.h @@ -35,6 +35,8 @@ gr_make_char_to_short (size_t vlen=1); /*! * \brief Convert stream of chars to a stream of float * \ingroup converter_blk + * + * \param vlen vector length of data streams. */ class GR_CORE_API gr_char_to_short : public gr_sync_block diff --git a/gnuradio-core/src/lib/general/gr_float_to_char.h b/gnuradio-core/src/lib/general/gr_float_to_char.h index c88645a18..00e83d465 100644 --- a/gnuradio-core/src/lib/general/gr_float_to_char.h +++ b/gnuradio-core/src/lib/general/gr_float_to_char.h @@ -35,6 +35,9 @@ gr_make_float_to_char (size_t vlen=1, float scale=1); /*! * \brief Convert stream of float to a stream of char * \ingroup converter_blk + * + * \param vlen vector length of data streams. + * \param scale a scalar multiplier to change the output signal scale. */ class GR_CORE_API gr_float_to_char : public gr_sync_block @@ -48,7 +51,14 @@ class GR_CORE_API gr_float_to_char : public gr_sync_block float d_scale; public: + /*! + * Get the scalar multiplier value. + */ float scale() const; + + /*! + * Set the scalar multiplier value. + */ void set_scale(float scale); virtual int work (int noutput_items, diff --git a/gnuradio-core/src/lib/general/gr_float_to_int.h b/gnuradio-core/src/lib/general/gr_float_to_int.h index 0b42c0aab..ef1987a76 100644 --- a/gnuradio-core/src/lib/general/gr_float_to_int.h +++ b/gnuradio-core/src/lib/general/gr_float_to_int.h @@ -35,6 +35,9 @@ gr_make_float_to_int (size_t vlen=1, float scale=1); /*! * \brief Convert stream of float to a stream of short * \ingroup converter_blk + * + * \param vlen vector length of data streams. + * \param scale a scalar multiplier to change the output signal scale. */ class GR_CORE_API gr_float_to_int : public gr_sync_block @@ -48,7 +51,14 @@ class GR_CORE_API gr_float_to_int : public gr_sync_block float d_scale; public: + /*! + * Get the scalar multiplier value. + */ float scale() const; + + /*! + * Set the scalar multiplier value. + */ void set_scale(float scale); virtual int work (int noutput_items, diff --git a/gnuradio-core/src/lib/general/gr_float_to_short.h b/gnuradio-core/src/lib/general/gr_float_to_short.h index 93e441f41..beb95486f 100644 --- a/gnuradio-core/src/lib/general/gr_float_to_short.h +++ b/gnuradio-core/src/lib/general/gr_float_to_short.h @@ -35,6 +35,9 @@ gr_make_float_to_short (size_t vlen=1, float scale=1); /*! * \brief Convert stream of float to a stream of short * \ingroup converter_blk + * + * \param vlen vector length of data streams. + * \param scale a scalar multiplier to change the output signal scale. */ class GR_CORE_API gr_float_to_short : public gr_sync_block @@ -47,7 +50,14 @@ class GR_CORE_API gr_float_to_short : public gr_sync_block float d_scale; public: + /*! + * Get the scalar multiplier value. + */ float scale() const; + + /*! + * Set the scalar multiplier value. + */ void set_scale(float scale); virtual int work (int noutput_items, diff --git a/gnuradio-core/src/lib/general/gr_frequency_modulator_fc.cc b/gnuradio-core/src/lib/general/gr_frequency_modulator_fc.cc index bff22be25..34f2f88bc 100644 --- a/gnuradio-core/src/lib/general/gr_frequency_modulator_fc.cc +++ b/gnuradio-core/src/lib/general/gr_frequency_modulator_fc.cc @@ -26,7 +26,7 @@ #include <gr_frequency_modulator_fc.h> #include <gr_io_signature.h> -#include <gr_sincos.h> +#include <gr_fxpt.h> #include <math.h> #include <boost/math/special_functions/trunc.hpp> @@ -54,17 +54,17 @@ gr_frequency_modulator_fc::work (int noutput_items, for (int i = 0; i < noutput_items; i++){ d_phase = d_phase + d_sensitivity * in[i]; - float oi, oq; - gr_sincosf (d_phase, &oq, &oi); - out[i] = gr_complex (oi, oq); - } - // Limit the phase accumulator to [-16*pi,16*pi] - // to avoid loss of precision in the addition above. + while (d_phase > (float)(M_PI)) + d_phase -= (float)(2.0 * M_PI); + while (d_phase < (float)(-M_PI)) + d_phase += (float)(2.0 * M_PI); - if (fabs (d_phase) > 16 * M_PI){ - double ii = boost::math::trunc (d_phase / (2 * M_PI)); - d_phase = d_phase - (ii * 2 * M_PI); + float oi, oq; + + gr_int32 angle = gr_fxpt::float_to_fixed (d_phase); + gr_fxpt::sincos (angle, &oq, &oi); + out[i] = gr_complex (oi, oq); } return noutput_items; diff --git a/gnuradio-core/src/lib/general/gr_frequency_modulator_fc.h b/gnuradio-core/src/lib/general/gr_frequency_modulator_fc.h index 932e7da36..e3aaafb1a 100644 --- a/gnuradio-core/src/lib/general/gr_frequency_modulator_fc.h +++ b/gnuradio-core/src/lib/general/gr_frequency_modulator_fc.h @@ -39,8 +39,8 @@ GR_CORE_API gr_frequency_modulator_fc_sptr gr_make_frequency_modulator_fc (doubl */ class GR_CORE_API gr_frequency_modulator_fc : public gr_sync_block { - double d_sensitivity; - double d_phase; + float d_sensitivity; + float d_phase; friend GR_CORE_API gr_frequency_modulator_fc_sptr gr_make_frequency_modulator_fc (double sensitivity); diff --git a/gnuradio-core/src/lib/general/gr_fxpt.cc b/gnuradio-core/src/lib/general/gr_fxpt.cc index fae02c71e..67f44a471 100644 --- a/gnuradio-core/src/lib/general/gr_fxpt.cc +++ b/gnuradio-core/src/lib/general/gr_fxpt.cc @@ -33,24 +33,3 @@ const float gr_fxpt::s_sine_table[1 << NBITS][2] = { const float gr_fxpt::PI = 3.14159265358979323846; const float gr_fxpt::TWO_TO_THE_31 = 2147483648.0; -#if 0 -/* - * Compute sine using table lookup with linear interpolation. - * Each table entry contains slope and intercept. - */ -float -gr_fxpt::sin (gr_int32 x) -{ - gr_uint32 ux = x; - int index = ux >> (WORDBITS - NBITS); - return s_sine_table[index][0] * (ux >> 1) + s_sine_table[index][1]; -} - -float -gr_fxpt::cos (gr_int32 x) -{ - gr_uint32 ux = x + 0x40000000; - int index = ux >> (WORDBITS - NBITS); - return s_sine_table[index][0] * (ux >> 1) + s_sine_table[index][1]; -} -#endif diff --git a/gnuradio-core/src/lib/general/gr_fxpt.h b/gnuradio-core/src/lib/general/gr_fxpt.h index 9f5937d1a..431102569 100644 --- a/gnuradio-core/src/lib/general/gr_fxpt.h +++ b/gnuradio-core/src/lib/general/gr_fxpt.h @@ -83,6 +83,22 @@ public: return s_sine_table[index][0] * (ux >> 1) + s_sine_table[index][1]; } + /* + * \brief Given a fixedpoint angle x, return float cos(x) and sin (x) + */ + static void sincos(gr_int32 x, float *s, float *c) + { + gr_uint32 ux = x; + int sin_index = ux >> (WORDBITS - NBITS); + *s = s_sine_table[sin_index][0] * (ux >> 1) + s_sine_table[sin_index][1]; + + ux = x + 0x40000000; + int cos_index = ux >> (WORDBITS - NBITS); + *c = s_sine_table[cos_index][0] * (ux >> 1) + s_sine_table[cos_index][1]; + + return; + } + }; #endif /* INCLUDED_GR_FXPT_H */ diff --git a/gnuradio-core/src/lib/general/gr_int_to_float.h b/gnuradio-core/src/lib/general/gr_int_to_float.h index af6488a50..7c55e3b3c 100644 --- a/gnuradio-core/src/lib/general/gr_int_to_float.h +++ b/gnuradio-core/src/lib/general/gr_int_to_float.h @@ -35,6 +35,9 @@ gr_make_int_to_float (size_t vlen=1, float scale=1); /*! * \brief Convert stream of int to a stream of float * \ingroup converter_blk + * + * \param vlen vector length of data streams. + * \param scale a scalar divider to change the output signal scale. */ class GR_CORE_API gr_int_to_float : public gr_sync_block @@ -48,7 +51,14 @@ class GR_CORE_API gr_int_to_float : public gr_sync_block float d_scale; public: + /*! + * Get the scalar divider value. + */ float scale() const; + + /*! + * Set the scalar divider value. + */ void set_scale(float scale); virtual int work (int noutput_items, diff --git a/gnuradio-core/src/lib/general/gr_short_to_char.h b/gnuradio-core/src/lib/general/gr_short_to_char.h index 9682d86ec..f6b3b41ca 100644 --- a/gnuradio-core/src/lib/general/gr_short_to_char.h +++ b/gnuradio-core/src/lib/general/gr_short_to_char.h @@ -35,6 +35,8 @@ gr_make_short_to_char (size_t vlen=1); /*! * \brief Convert stream of short to a stream of float * \ingroup converter_blk + * + * \param vlen vector length of data streams. */ class GR_CORE_API gr_short_to_char : public gr_sync_block diff --git a/gnuradio-core/src/lib/general/gr_short_to_float.h b/gnuradio-core/src/lib/general/gr_short_to_float.h index efdc81ecd..e45d0b14b 100644 --- a/gnuradio-core/src/lib/general/gr_short_to_float.h +++ b/gnuradio-core/src/lib/general/gr_short_to_float.h @@ -35,6 +35,9 @@ gr_make_short_to_float (size_t vlen=1, float scale=1); /*! * \brief Convert stream of short to a stream of float * \ingroup converter_blk + * + * \param vlen vector length of data streams. + * \param scale a scalar divider to change the output signal scale. */ class GR_CORE_API gr_short_to_float : public gr_sync_block @@ -48,7 +51,14 @@ class GR_CORE_API gr_short_to_float : public gr_sync_block float d_scale; public: + /*! + * Get the scalar divider value. + */ float scale() const; + + /*! + * Set the scalar divider value. + */ void set_scale(float scale); virtual int work (int noutput_items, diff --git a/gnuradio-core/src/lib/general/qa_gr_fxpt.cc b/gnuradio-core/src/lib/general/qa_gr_fxpt.cc index 83bb05b2d..00487714e 100644 --- a/gnuradio-core/src/lib/general/qa_gr_fxpt.cc +++ b/gnuradio-core/src/lib/general/qa_gr_fxpt.cc @@ -91,4 +91,13 @@ qa_gr_fxpt::t2 () void qa_gr_fxpt::t3 () { + for (float p = -M_PI; p < M_PI; p += 2 * M_PI / 3600){ + float expected_sin = sin (p); + float expected_cos = cos (p); + float actual_sin; + float actual_cos; + gr_fxpt::sincos (gr_fxpt::float_to_fixed (p), &actual_sin, &actual_cos); + CPPUNIT_ASSERT_DOUBLES_EQUAL (expected_sin, actual_sin, SIN_COS_TOLERANCE); + CPPUNIT_ASSERT_DOUBLES_EQUAL (expected_cos, actual_cos, SIN_COS_TOLERANCE); + } } diff --git a/gnuradio-core/src/lib/gengen/.gitignore b/gnuradio-core/src/lib/gengen/.gitignore index b91d2f197..2f53eba9a 100644 --- a/gnuradio-core/src/lib/gengen/.gitignore +++ b/gnuradio-core/src/lib/gengen/.gitignore @@ -293,6 +293,36 @@ /gr_peak_detector_ss.h /gr_peak_detector_ss.i /gr_prefix.cc +/gr_probe_signal_b.cc +/gr_probe_signal_b.h +/gr_probe_signal_b.i +/gr_probe_signal_s.cc +/gr_probe_signal_s.h +/gr_probe_signal_s.i +/gr_probe_signal_i.cc +/gr_probe_signal_i.h +/gr_probe_signal_i.i +/gr_probe_signal_f.cc +/gr_probe_signal_f.h +/gr_probe_signal_f.i +/gr_probe_signal_c.cc +/gr_probe_signal_c.h +/gr_probe_signal_c.i +/gr_probe_signal_vb.cc +/gr_probe_signal_vb.h +/gr_probe_signal_vb.i +/gr_probe_signal_vs.cc +/gr_probe_signal_vs.h +/gr_probe_signal_vs.i +/gr_probe_signal_vi.cc +/gr_probe_signal_vi.h +/gr_probe_signal_vi.i +/gr_probe_signal_vf.cc +/gr_probe_signal_vf.h +/gr_probe_signal_vf.i +/gr_probe_signal_vc.cc +/gr_probe_signal_vc.h +/gr_probe_signal_vc.i /gr_sample_and_hold_bb.cc /gr_sample_and_hold_bb.h /gr_sample_and_hold_bb.i diff --git a/gnuradio-core/src/lib/gengen/CMakeLists.txt b/gnuradio-core/src/lib/gengen/CMakeLists.txt index 98b149e97..8a43a8880 100644 --- a/gnuradio-core/src/lib/gengen/CMakeLists.txt +++ b/gnuradio-core/src/lib/gengen/CMakeLists.txt @@ -84,6 +84,8 @@ expand_h_cc_i(gr_vector_source_X b s i f c) expand_h_cc_i(gr_vector_sink_X b s i f c) expand_h_cc_i(gr_noise_source_X s i f c) expand_h_cc_i(gr_sig_source_X s i f c) +expand_h_cc_i(gr_probe_signal_X b s i f c) +expand_h_cc_i(gr_probe_signal_vX b s i f c) expand_h_cc_i(gr_add_const_XX ss ii ff cc sf) expand_h_cc_i(gr_multiply_const_XX ss ii) diff --git a/gnuradio-core/src/lib/gengen/Makefile.am b/gnuradio-core/src/lib/gengen/Makefile.am index 5fbb6f52c..e2f65c5da 100644 --- a/gnuradio-core/src/lib/gengen/Makefile.am +++ b/gnuradio-core/src/lib/gengen/Makefile.am @@ -77,6 +77,12 @@ core_generator = \ gr_peak_detector_XX.cc.t \ gr_peak_detector_XX.h.t \ gr_peak_detector_XX.i.t \ + gr_probe_signal_X.cc.t \ + gr_probe_signal_X.h.t \ + gr_probe_signal_X.i.t \ + gr_probe_signal_vX.cc.t \ + gr_probe_signal_vX.h.t \ + gr_probe_signal_vX.i.t \ gr_sample_and_hold_XX.cc.t \ gr_sample_and_hold_XX.h.t \ gr_sample_and_hold_XX.i.t \ diff --git a/gnuradio-core/src/lib/gengen/Makefile.gen b/gnuradio-core/src/lib/gengen/Makefile.gen index db260585f..b4a255dc0 100644 --- a/gnuradio-core/src/lib/gengen/Makefile.gen +++ b/gnuradio-core/src/lib/gengen/Makefile.gen @@ -72,6 +72,16 @@ GENERATED_H = \ gr_peak_detector_fb.h \ gr_peak_detector_ib.h \ gr_peak_detector_sb.h \ + gr_probe_signal_b.h \ + gr_probe_signal_s.h \ + gr_probe_signal_i.h \ + gr_probe_signal_f.h \ + gr_probe_signal_c.h \ + gr_probe_signal_vb.h \ + gr_probe_signal_vs.h \ + gr_probe_signal_vi.h \ + gr_probe_signal_vf.h \ + gr_probe_signal_vc.h \ gr_sample_and_hold_bb.h \ gr_sample_and_hold_ff.h \ gr_sample_and_hold_ii.h \ @@ -172,6 +182,16 @@ GENERATED_I = \ gr_peak_detector_fb.i \ gr_peak_detector_ib.i \ gr_peak_detector_sb.i \ + gr_probe_signal_b.i \ + gr_probe_signal_s.i \ + gr_probe_signal_i.i \ + gr_probe_signal_f.i \ + gr_probe_signal_c.i \ + gr_probe_signal_vb.i \ + gr_probe_signal_vs.i \ + gr_probe_signal_vi.i \ + gr_probe_signal_vf.i \ + gr_probe_signal_vc.i \ gr_sample_and_hold_bb.i \ gr_sample_and_hold_ff.i \ gr_sample_and_hold_ii.i \ @@ -272,6 +292,16 @@ GENERATED_CC = \ gr_peak_detector_fb.cc \ gr_peak_detector_ib.cc \ gr_peak_detector_sb.cc \ + gr_probe_signal_b.cc \ + gr_probe_signal_s.cc \ + gr_probe_signal_i.cc \ + gr_probe_signal_f.cc \ + gr_probe_signal_c.cc \ + gr_probe_signal_vb.cc \ + gr_probe_signal_vs.cc \ + gr_probe_signal_vi.cc \ + gr_probe_signal_vf.cc \ + gr_probe_signal_vc.cc \ gr_sample_and_hold_bb.cc \ gr_sample_and_hold_ff.cc \ gr_sample_and_hold_ii.cc \ diff --git a/gnuradio-core/src/lib/gengen/generate_common.py b/gnuradio-core/src/lib/gengen/generate_common.py index 6da2044e0..70f805711 100755 --- a/gnuradio-core/src/lib/gengen/generate_common.py +++ b/gnuradio-core/src/lib/gengen/generate_common.py @@ -33,7 +33,9 @@ ss_roots = [ 'gr_vector_source_X', 'gr_vector_sink_X', 'gr_noise_source_X', - 'gr_sig_source_X' + 'gr_sig_source_X', + 'gr_probe_signal_X', + 'gr_probe_signal_vX' ] # regular blocks @@ -83,6 +85,8 @@ def generate (): expand_h_cc_i ('gr_add_const_XX', 'sf') # for MC4020 expand_h_cc_i ('gr_vector_sink_X', 'b') expand_h_cc_i ('gr_vector_source_X', 'b') + expand_h_cc_i ('gr_probe_signal_X', 'b') + expand_h_cc_i ('gr_probe_signal_vX', 'b') for r in ss_roots: for s in ss_signatures: expand_h_cc_i (r, s) diff --git a/gnuradio-core/src/lib/gengen/gr_noise_source_X.h.t b/gnuradio-core/src/lib/gengen/gr_noise_source_X.h.t index ab5992257..196501c4d 100644 --- a/gnuradio-core/src/lib/gengen/gr_noise_source_X.h.t +++ b/gnuradio-core/src/lib/gengen/gr_noise_source_X.h.t @@ -34,22 +34,38 @@ class @NAME@; typedef boost::shared_ptr<@NAME@> @NAME@_sptr; +/*! \brief Make a noise source + * \param type the random distribution to use (see gr_noise_type.h) + * \param ampl a scaling factor for the output + * \param seed seed for random generators. Note that for uniform and + * Gaussian distributions, this should be a negative number. + */ GR_CORE_API @NAME@_sptr -gr_make_@BASE_NAME@ (gr_noise_type_t type, float ampl, long seed = 3021); +gr_make_@BASE_NAME@ (gr_noise_type_t type, float ampl, long seed = 0); /*! - * \brief random number source + * \brief Random number source * \ingroup source_blk + * + * \details + * Generate random values from different distributions. + * Currently, only Gaussian and uniform are enabled. + * + * \param type the random distribution to use (see gr_noise_type.h) + * \param ampl a scaling factor for the output + * \param seed seed for random generators. Note that for uniform and + * Gaussian distributions, this should be a negative number. */ class GR_CORE_API @NAME@ : public gr_sync_block { friend GR_CORE_API @NAME@_sptr + gr_make_@BASE_NAME@ (gr_noise_type_t type, float ampl, long seed); gr_noise_type_t d_type; float d_ampl; gr_random d_rng; - @NAME@ (gr_noise_type_t type, float ampl, long seed = 3021); + @NAME@ (gr_noise_type_t type, float ampl, long seed = 0); public: void set_type (gr_noise_type_t type) { d_type = type; } diff --git a/gnuradio-core/src/lib/gengen/gr_noise_source_X.i.t b/gnuradio-core/src/lib/gengen/gr_noise_source_X.i.t index 179dc0343..36a51f31a 100644 --- a/gnuradio-core/src/lib/gengen/gr_noise_source_X.i.t +++ b/gnuradio-core/src/lib/gengen/gr_noise_source_X.i.t @@ -25,11 +25,11 @@ GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@); @NAME@_sptr -gr_make_@BASE_NAME@ (gr_noise_type_t type, float ampl, long seed = 3021); +gr_make_@BASE_NAME@ (gr_noise_type_t type, float ampl, long seed = 0); class @NAME@ : public gr_block { private: - @NAME@ (gr_noise_type_t type, float ampl, long seed = 3021); + @NAME@ (gr_noise_type_t type, float ampl, long seed = 0); public: void set_type (gr_noise_type_t type) { d_type = type; } diff --git a/gnuradio-core/src/lib/general/gr_probe_signal_f.cc b/gnuradio-core/src/lib/gengen/gr_probe_signal_X.cc.t index ee1a18e89..d60a5126a 100644 --- a/gnuradio-core/src/lib/general/gr_probe_signal_f.cc +++ b/gnuradio-core/src/lib/gengen/gr_probe_signal_X.cc.t @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2005,2010 Free Software Foundation, Inc. + * Copyright 2005,2010,2012 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -23,38 +23,37 @@ #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include <gr_probe_signal_f.h> +#include <@NAME@.h> #include <gr_io_signature.h> -gr_probe_signal_f_sptr -gr_make_probe_signal_f() +@NAME@_sptr +gr_make_@BASE_NAME@() { - return gnuradio::get_initial_sptr(new gr_probe_signal_f()); + return gnuradio::get_initial_sptr(new @NAME@()); } -gr_probe_signal_f::gr_probe_signal_f () - : gr_sync_block ("probe_signal_f", - gr_make_io_signature(1, 1, sizeof(float)), +@NAME@::@NAME@ () +: gr_sync_block ("@BASE_NAME@", + gr_make_io_signature(1, 1, sizeof(@TYPE@)), gr_make_io_signature(0, 0, 0)), d_level(0) { } -gr_probe_signal_f::~gr_probe_signal_f() +@NAME@::~@NAME@() { } int -gr_probe_signal_f::work(int noutput_items, +@NAME@::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]; + const @TYPE@ *in = (const @TYPE@ *) input_items[0]; if (noutput_items > 0) d_level = in[noutput_items-1]; return noutput_items; } - diff --git a/gnuradio-core/src/lib/general/gr_probe_signal_f.h b/gnuradio-core/src/lib/gengen/gr_probe_signal_X.h.t index b99c76976..26a95b9b2 100644 --- a/gnuradio-core/src/lib/general/gr_probe_signal_f.h +++ b/gnuradio-core/src/lib/gengen/gr_probe_signal_X.h.t @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2005 Free Software Foundation, Inc. + * Copyright 2005, 2012 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -19,40 +19,40 @@ * the Free Software Foundation, Inc., 51 Franklin Street, * Boston, MA 02110-1301, USA. */ -#ifndef INCLUDED_GR_PROBE_SIGNAL_F_H -#define INCLUDED_GR_PROBE_SIGNAL_F_H +#ifndef @GUARD_NAME@ +#define @GUARD_NAME@ #include <gr_core_api.h> #include <gr_sync_block.h> -class gr_probe_signal_f; -typedef boost::shared_ptr<gr_probe_signal_f> gr_probe_signal_f_sptr; +class @NAME@; +typedef boost::shared_ptr<@NAME@> @NAME@_sptr; -GR_CORE_API gr_probe_signal_f_sptr -gr_make_probe_signal_f (); +GR_CORE_API @NAME@_sptr +gr_make_@BASE_NAME@ (); /*! * \brief Sink that allows a sample to be grabbed from Python. * \ingroup sink_blk */ -class GR_CORE_API gr_probe_signal_f : public gr_sync_block +class GR_CORE_API @NAME@ : public gr_sync_block { - float d_level; + @TYPE@ d_level; - friend GR_CORE_API gr_probe_signal_f_sptr - gr_make_probe_signal_f(); + friend GR_CORE_API @NAME@_sptr + gr_make_@BASE_NAME@(); - gr_probe_signal_f(); + @NAME@(); public: - ~gr_probe_signal_f(); + ~@NAME@(); int work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items); - float level() const { return d_level; } + @TYPE@ level() const { return d_level; } }; -#endif /* INCLUDED_GR_PROBE_SIGNAL_F_H */ +#endif /* @GUARD_NAME@ */ diff --git a/gnuradio-core/src/lib/general/gr_probe_signal_f.i b/gnuradio-core/src/lib/gengen/gr_probe_signal_X.i.t index 4255e5dfd..3f1ef8ffd 100644 --- a/gnuradio-core/src/lib/general/gr_probe_signal_f.i +++ b/gnuradio-core/src/lib/gengen/gr_probe_signal_X.i.t @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2005 Free Software Foundation, Inc. + * Copyright 2005, 2012 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,13 +20,13 @@ * Boston, MA 02110-1301, USA. */ -GR_SWIG_BLOCK_MAGIC(gr,probe_signal_f); +GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@); -gr_probe_signal_f_sptr -gr_make_probe_signal_f (); +@NAME@_sptr +gr_make_@BASE_NAME@ (); -class gr_probe_signal_f : public gr_sync_block +class @NAME@ : public gr_sync_block { public: - float level () const { return d_level; } + @TYPE@ level (); }; diff --git a/gnuradio-core/src/lib/gengen/gr_probe_signal_vX.cc.t b/gnuradio-core/src/lib/gengen/gr_probe_signal_vX.cc.t new file mode 100644 index 000000000..712b55b9a --- /dev/null +++ b/gnuradio-core/src/lib/gengen/gr_probe_signal_vX.cc.t @@ -0,0 +1,59 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,2010,2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif +#include <@NAME@.h> +#include <gr_io_signature.h> +#include <iostream> + +@NAME@_sptr +gr_make_@BASE_NAME@(size_t size) +{ + return gnuradio::get_initial_sptr(new @NAME@(size)); +} + +@NAME@::@NAME@ (size_t size) +: gr_sync_block ("@BASE_NAME@", + gr_make_io_signature(1, 1, size*sizeof(@TYPE@)), + gr_make_io_signature(0, 0, 0)), + d_level(size, 0), d_size(size) +{ +} + +@NAME@::~@NAME@() +{ +} + +int +@NAME@::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + const @TYPE@ *in = (const @TYPE@ *) input_items[0]; + + for (int i=0; i<d_size; i++) + d_level[i] = in[(noutput_items-1)*d_size+i]; + + return noutput_items; +} diff --git a/gnuradio-core/src/lib/gengen/gr_probe_signal_vX.h.t b/gnuradio-core/src/lib/gengen/gr_probe_signal_vX.h.t new file mode 100644 index 000000000..3a7277b93 --- /dev/null +++ b/gnuradio-core/src/lib/gengen/gr_probe_signal_vX.h.t @@ -0,0 +1,62 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005, 2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ +#ifndef @GUARD_NAME@ +#define @GUARD_NAME@ + +#include <vector> + +#include <gr_core_api.h> +#include <gr_sync_block.h> + +class @NAME@; +typedef boost::shared_ptr<@NAME@> @NAME@_sptr; + +GR_CORE_API @NAME@_sptr +gr_make_@BASE_NAME@ (size_t size); + +/*! + * \brief Sink that allows a sample to be grabbed from Python. + * \ingroup sink_blk + */ +class GR_CORE_API @NAME@ : public gr_sync_block +{ + std::vector<@TYPE@> d_level; + + friend GR_CORE_API @NAME@_sptr + gr_make_@BASE_NAME@(size_t size); + + @NAME@(size_t size); + + size_t d_size; + +public: + ~@NAME@(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + + std::vector<@TYPE@> level() const { return d_level; } + +}; + +#endif /* @GUARD_NAME@ */ diff --git a/gnuradio-core/src/lib/gengen/gr_probe_signal_vX.i.t b/gnuradio-core/src/lib/gengen/gr_probe_signal_vX.i.t new file mode 100644 index 000000000..20191948a --- /dev/null +++ b/gnuradio-core/src/lib/gengen/gr_probe_signal_vX.i.t @@ -0,0 +1,32 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005, 2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@); + +@NAME@_sptr +gr_make_@BASE_NAME@ (size_t size); + +class @NAME@ : public gr_sync_block +{ +public: + std::vector<@TYPE@> level (); +}; diff --git a/gnuradio-core/src/lib/runtime/gr_msg_queue.i b/gnuradio-core/src/lib/runtime/gr_msg_queue.i index c9214bef3..0a4eda78a 100644 --- a/gnuradio-core/src/lib/runtime/gr_msg_queue.i +++ b/gnuradio-core/src/lib/runtime/gr_msg_queue.i @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2005,2009,2010 Free Software Foundation, Inc. + * Copyright 2005,2009,2010,2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -85,16 +85,16 @@ public: %inline %{ gr_message_sptr gr_py_msg_queue__delete_head(gr_msg_queue_sptr q) { gr_message_sptr msg; - Py_BEGIN_ALLOW_THREADS; // release global interpreter lock - msg = q->delete_head(); // possibly blocking call - Py_END_ALLOW_THREADS; // acquire global interpreter lock + GR_PYTHON_BLOCKING_CODE( + msg = q->delete_head(); + ) return msg; } void gr_py_msg_queue__insert_tail(gr_msg_queue_sptr q, gr_message_sptr msg) { - Py_BEGIN_ALLOW_THREADS; // release global interpreter lock - q->insert_tail(msg); // possibly blocking call - Py_END_ALLOW_THREADS; // acquire global interpreter lock + GR_PYTHON_BLOCKING_CODE( + q->insert_tail(msg); + ) } %} diff --git a/gnuradio-core/src/lib/swig/gnuradio.i b/gnuradio-core/src/lib/swig/gnuradio.i index e365aeac7..972d56c84 100644 --- a/gnuradio-core/src/lib/swig/gnuradio.i +++ b/gnuradio-core/src/lib/swig/gnuradio.i @@ -25,23 +25,7 @@ // SWIG interface definition //////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////// -// Language independent exception handler -//////////////////////////////////////////////////////////////////////// -%include exception.i - -%exception { - try { - $action - } - catch(std::exception &e) { - SWIG_exception(SWIG_RuntimeError, e.what()); - } - catch(...) { - SWIG_exception(SWIG_RuntimeError, "Unknown exception"); - } - -} +%include <gruel_common.i> //////////////////////////////////////////////////////////////////////// // Headers diff --git a/gnuradio-core/src/python/gnuradio/gr/Makefile.am b/gnuradio-core/src/python/gnuradio/gr/Makefile.am index 9853766f9..b1550fc57 100644 --- a/gnuradio-core/src/python/gnuradio/gr/Makefile.am +++ b/gnuradio-core/src/python/gnuradio/gr/Makefile.am @@ -90,6 +90,7 @@ noinst_PYTHON = \ qa_pll_freqdet.py \ qa_pll_refout.py \ qa_pn_correlator_cc.py \ + qa_probe_signal.py \ qa_rational_resampler.py \ qa_sig_source.py \ qa_single_pole_iir.py \ diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_frequency_modulator.py b/gnuradio-core/src/python/gnuradio/gr/qa_frequency_modulator.py index 829185c34..7328f041d 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_frequency_modulator.py +++ b/gnuradio-core/src/python/gnuradio/gr/qa_frequency_modulator.py @@ -48,7 +48,7 @@ class test_frequency_modulator (gr_unittest.TestCase): self.tb.connect (op, dst) self.tb.run () result_data = dst.data () - self.assertComplexTuplesAlmostEqual (expected_result, result_data) + self.assertComplexTuplesAlmostEqual (expected_result, result_data, 5) if __name__ == '__main__': diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_probe_signal.py b/gnuradio-core/src/python/gnuradio/gr/qa_probe_signal.py new file mode 100644 index 000000000..ed0756f5b --- /dev/null +++ b/gnuradio-core/src/python/gnuradio/gr/qa_probe_signal.py @@ -0,0 +1,67 @@ +#!/usr/bin/env python +# +# Copyright 2012 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +import time + +from gnuradio import gr, gr_unittest + +class test_probe_signal (gr_unittest.TestCase): + + def setUp (self): + self.tb = gr.top_block() + + def tearDown (self): + self.tb = None + + def test_001(self): + + value = 12.3 + repeats = 100 + src_data = [value] * repeats + + src = gr.vector_source_f(src_data) + dst = gr.probe_signal_f() + + self.tb.connect(src, dst) + self.tb.run() + output = dst.level() + self.assertAlmostEqual(value, output, places=6) + + def test_002(self): + + vector_length = 10 + repeats = 10 + value = [0.5+i for i in range(0, vector_length)] + src_data = value * repeats + + src = gr.vector_source_f(src_data) + s2v = gr.stream_to_vector(gr.sizeof_float, vector_length) + dst = gr.probe_signal_vf(vector_length) + + self.tb.connect(src, s2v, dst) + self.tb.run() + output = dst.level() + self.assertEqual(len(output), vector_length) + self.assertAlmostEqual(value[3], output[3], places=6) + +if __name__ == '__main__': + gr_unittest.run(test_probe_signal, "test_probe_signal.xml") |