Created
December 16, 2013 22:15
-
-
Save dudmuck/7995420 to your computer and use it in GitHub Desktop.
uhd RX start/stop test on top_block
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| ################################################## | |
| # Gnuradio Python Flow Graph | |
| # Title: Uhd Rx | |
| # Generated: Mon Dec 16 14:05:31 2013 | |
| ################################################## | |
| from gnuradio import analog | |
| from gnuradio import audio | |
| from gnuradio import blocks | |
| from gnuradio import eng_notation | |
| from gnuradio import filter | |
| from gnuradio import gr | |
| from gnuradio import uhd | |
| from gnuradio.eng_option import eng_option | |
| from gnuradio.filter import firdes | |
| from optparse import OptionParser | |
| import math | |
| import time | |
| class uhd_rx(gr.top_block): | |
| def __init__(self): | |
| gr.top_block.__init__(self, "Uhd Rx") | |
| ################################################## | |
| # Variables | |
| ################################################## | |
| self.samp_rate = samp_rate = 160000 | |
| ################################################## | |
| # Blocks | |
| ################################################## | |
| self.uhd_usrp_source_0 = uhd.usrp_source( | |
| device_addr="", | |
| stream_args=uhd.stream_args( | |
| cpu_format="fc32", | |
| channels=range(1), | |
| ), | |
| ) | |
| self.uhd_usrp_source_0.set_samp_rate(samp_rate) | |
| self.uhd_usrp_source_0.set_center_freq(88.3e6, 0) | |
| self.uhd_usrp_source_0.set_gain(20, 0) | |
| self.rational_resampler_xxx_0 = filter.rational_resampler_fff( | |
| interpolation=3, | |
| decimation=10, | |
| taps=None, | |
| fractional_bw=None, | |
| ) | |
| self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((.1, )) | |
| self.audio_sink_0 = audio.sink(48000, "", True) | |
| self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(1) | |
| ################################################## | |
| # Connections | |
| ################################################## | |
| self.connect((self.uhd_usrp_source_0, 0), (self.analog_quadrature_demod_cf_0, 0)) | |
| self.connect((self.analog_quadrature_demod_cf_0, 0), (self.rational_resampler_xxx_0, 0)) | |
| self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) | |
| self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 0)) | |
| # QT sink close method reimplementation | |
| def get_samp_rate(self): | |
| return self.samp_rate | |
| def set_samp_rate(self, samp_rate): | |
| self.samp_rate = samp_rate | |
| self.uhd_usrp_source_0.set_samp_rate(self.samp_rate) | |
| if __name__ == '__main__': | |
| parser = OptionParser(option_class=eng_option, usage="%prog: [options]") | |
| (options, args) = parser.parse_args() | |
| tb = uhd_rx() | |
| tb.start() | |
| running = True | |
| while (1): | |
| if running: | |
| s = raw_input('(x to exit) Enter stop: ') | |
| else: | |
| s = raw_input('(x to exit) Enter start: ') | |
| if (len(s) == 0): | |
| if running: | |
| tb.stop() | |
| tb.wait() | |
| running = False | |
| else: | |
| tb.start() | |
| running = True | |
| elif s == "x": | |
| tb.stop() | |
| sys.exit() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment