diff options
author | Sylvain Munaut <tnt@246tNt.com> | 2015-04-04 22:53:44 +0200 |
---|---|---|
committer | Sylvain Munaut <tnt@246tNt.com> | 2016-09-14 10:14:32 -0600 |
commit | 909ce7c57d5517374e6fdef7ba289a0a34134804 (patch) | |
tree | 0772599dd29aa10a7d23ac6e7245e89ccb7b1f79 | |
parent | 9803a371942d6d6e03c24231d8e151a64fa2ad55 (diff) |
gr-gmr1: Switch the 'freq' tag to be in Hertz
This also required adapting the file_sink. It now has an option to
specify if the spectrum was inverted or not. It's necessary to know
if the received frequency has to be added or substracted from the
center frequency.
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
-rw-r--r-- | gr-gmr1/apps/gmr_rach_scan.grc | 4 | ||||
-rw-r--r-- | gr-gmr1/grc/rach_file_sink.xml | 10 | ||||
-rw-r--r-- | gr-gmr1/include/gnuradio/gmr1/rach_file_sink.h | 6 | ||||
-rw-r--r-- | gr-gmr1/lib/rach_detect_fft_impl.cc | 2 | ||||
-rw-r--r-- | gr-gmr1/lib/rach_file_sink_impl.cc | 23 | ||||
-rw-r--r-- | gr-gmr1/lib/rach_file_sink_impl.h | 8 |
6 files changed, 28 insertions, 25 deletions
diff --git a/gr-gmr1/apps/gmr_rach_scan.grc b/gr-gmr1/apps/gmr_rach_scan.grc index 46e5dfa..2ade8a8 100644 --- a/gr-gmr1/apps/gmr_rach_scan.grc +++ b/gr-gmr1/apps/gmr_rach_scan.grc @@ -604,8 +604,8 @@ <value>0</value> </param> <param> - <key>sample_rate</key> - <value>samp_rate</value> + <key>invert_freq</key> + <value>True</value> </param> <param> <key>alias</key> diff --git a/gr-gmr1/grc/rach_file_sink.xml b/gr-gmr1/grc/rach_file_sink.xml index b72160f..4ff5c6d 100644 --- a/gr-gmr1/grc/rach_file_sink.xml +++ b/gr-gmr1/grc/rach_file_sink.xml @@ -4,7 +4,7 @@ <key>rach_file_sink</key> <category>GMR-1</category> <import>from gnuradio import gmr1</import> - <make>gmr1.rach_file_sink($filename, $center_freq, $sample_rate)</make> + <make>gmr1.rach_file_sink($filename, $center_freq, $invert_freq)</make> <param> <name>Filename</name> <key>filename</key> @@ -17,10 +17,10 @@ <type>float</type> </param> <param> - <name>Sample Rate</name> - <key>sample_rate</key> - <value>0</value> - <type>float</type> + <name>Inverted Spectrum</name> + <key>invert_freq</key> + <value>False</value> + <type>bool</type> </param> <sink> <name>pdus</name> diff --git a/gr-gmr1/include/gnuradio/gmr1/rach_file_sink.h b/gr-gmr1/include/gnuradio/gmr1/rach_file_sink.h index 51d5aea..13c2ed1 100644 --- a/gr-gmr1/include/gnuradio/gmr1/rach_file_sink.h +++ b/gr-gmr1/include/gnuradio/gmr1/rach_file_sink.h @@ -39,15 +39,15 @@ namespace gr { typedef boost::shared_ptr<rach_file_sink> sptr; static sptr make(const std::string &filename, - const double center_freq, const double sample_rate); + const double center_freq, const bool invert_freq); virtual std::string filename() const = 0; virtual double center_freq() const = 0; - virtual double sample_rate() const = 0; + virtual bool invert_freq() const = 0; virtual void set_center_freq(const double center_freq) = 0; - virtual void set_sample_rate(const double sample_rate) = 0; + virtual void set_invert_freq(const bool invert_freq) = 0; }; } // namespace gmr1 diff --git a/gr-gmr1/lib/rach_detect_fft_impl.cc b/gr-gmr1/lib/rach_detect_fft_impl.cc index a5bcc0b..b03b6fa 100644 --- a/gr-gmr1/lib/rach_detect_fft_impl.cc +++ b/gr-gmr1/lib/rach_detect_fft_impl.cc @@ -268,7 +268,7 @@ rach_detect_fft_impl::general_work( 0, this->nitems_written(0), FREQ_KEY, - pmt::from_double(phase_inc) + pmt::from_double(- this->d_sample_rate * phase_inc / (2.0 * M_PI)) ); /* Burst first sample index */ diff --git a/gr-gmr1/lib/rach_file_sink_impl.cc b/gr-gmr1/lib/rach_file_sink_impl.cc index 0051966..20c0aaa 100644 --- a/gr-gmr1/lib/rach_file_sink_impl.cc +++ b/gr-gmr1/lib/rach_file_sink_impl.cc @@ -36,21 +36,21 @@ namespace gr { rach_file_sink::sptr rach_file_sink::make(const std::string &filename, - const double center_freq, const double sample_rate) + const double center_freq, const bool invert_freq) { return gnuradio::get_initial_sptr( - new rach_file_sink_impl(filename, center_freq, sample_rate) + new rach_file_sink_impl(filename, center_freq, invert_freq) ); } rach_file_sink_impl::rach_file_sink_impl(const std::string &filename, const double center_freq, - const double sample_rate) + const bool invert_freq) : gr::block("rach_file_sink", io_signature::make(0, 0, 0), io_signature::make(0, 0, 0)), d_filename(filename), - d_center_freq(center_freq), d_sample_rate(sample_rate) + d_center_freq(center_freq), d_invert_freq(invert_freq) { message_port_register_in(PDU_PORT_ID); set_msg_handler(PDU_PORT_ID, boost::bind(&rach_file_sink_impl::send_pdu, this, _1)); @@ -78,10 +78,10 @@ rach_file_sink_impl::center_freq() const return this->d_center_freq; } -double -rach_file_sink_impl::sample_rate() const +bool +rach_file_sink_impl::invert_freq() const { - return this->d_sample_rate; + return this->d_invert_freq; } void @@ -91,9 +91,9 @@ rach_file_sink_impl::set_center_freq(const double center_freq) } void -rach_file_sink_impl::set_sample_rate(const double sample_rate) +rach_file_sink_impl::set_invert_freq(const bool invert_freq) { - this->d_sample_rate = sample_rate; + this->d_invert_freq = invert_freq; } @@ -140,10 +140,13 @@ rach_file_sink_impl::send_pdu(pmt::pmt_t pdu) uint8_t sb_mask = pmt::to_long(pmt::dict_ref(meta, key_sb_mask, pmt::PMT_NIL)); double freq = pmt::to_double(pmt::dict_ref(meta, key_freq, pmt::PMT_NIL)); + if (this->d_invert_freq) + freq = -freq; + fprintf(this->d_fh, "%02hhx %.17g %.17g ", sb_mask, freq, - this->d_center_freq + (this->d_sample_rate * freq / (2.0 * M_PI)) + this->d_center_freq + freq ); /* Raw bytes */ diff --git a/gr-gmr1/lib/rach_file_sink_impl.h b/gr-gmr1/lib/rach_file_sink_impl.h index 6738f01..12dd3ce 100644 --- a/gr-gmr1/lib/rach_file_sink_impl.h +++ b/gr-gmr1/lib/rach_file_sink_impl.h @@ -38,7 +38,7 @@ namespace gr { private: std::string d_filename; double d_center_freq; - double d_sample_rate; + bool d_invert_freq; FILE *d_fh; @@ -46,15 +46,15 @@ namespace gr { public: rach_file_sink_impl(const std::string &filename, - const double center_freq, const double sample_rate); + const double center_freq, const bool invert_freq); virtual ~rach_file_sink_impl(); std::string filename() const; double center_freq() const; - double sample_rate() const; + bool invert_freq() const; void set_center_freq(const double center_freq); - void set_sample_rate(const double sample_rate); + void set_invert_freq(const bool invert_freq); bool start(); bool stop(); |