Created
December 16, 2013 22:30
-
-
Save dudmuck/7995634 to your computer and use it in GitHub Desktop.
start/stop test with UHD src and file sink only
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: Uhdrx Filesink | |
| # Generated: Mon Dec 16 14:23:53 2013 | |
| # | |
| # to use: watch -n1 'ls -l rx_out' # in another terminal | |
| ################################################## | |
| from gnuradio import blocks | |
| from gnuradio import eng_notation | |
| 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 time | |
| class uhdrx_filesink(gr.top_block): | |
| def __init__(self): | |
| gr.top_block.__init__(self, "Uhdrx Filesink") | |
| ################################################## | |
| # 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(25, 0) | |
| self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex*1, "rx_out", False) | |
| self.blocks_file_sink_0.set_unbuffered(False) | |
| ################################################## | |
| # Connections | |
| ################################################## | |
| self.connect((self.uhd_usrp_source_0, 0), (self.blocks_file_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 = uhdrx_filesink() | |
| tb.start() | |
| running = True | |
| while (1): | |
| if running: | |
| s = raw_input('Enter stop: ') | |
| else: | |
| s = raw_input('Enter start: ') | |
| if (len(s) == 0): | |
| if running: | |
| tb.stop() | |
| tb.wait() | |
| running = False | |
| else: | |
| tb.start() | |
| running = True | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment