diff options
author | Tom Rondeau <trondeau@vt.edu> | 2011-09-13 12:28:57 -0400 |
---|---|---|
committer | Tom Rondeau <trondeau@vt.edu> | 2011-09-13 12:28:57 -0400 |
commit | 46168fbd1e3dfb68cafe2b512641c67e2a6b5d80 (patch) | |
tree | efd8140b2f4d0e2e59253a275d3a4b99fc952510 | |
parent | 74f835a3168db5336d36e6c9651eb5d6a0d35ec4 (diff) |
digital: moved tx/rx_voice from gnuradio-examples into gr-digital. Tested and working with new dbpsk,dqpsk,d8psk.
-rw-r--r-- | gnuradio-examples/python/digital/Makefile.am | 4 | ||||
-rw-r--r-- | gr-digital/examples/Makefile.am | 2 | ||||
-rwxr-xr-x | gr-digital/examples/benchmark_tx.py | 4 | ||||
-rwxr-xr-x | gr-digital/examples/rx_voice.py (renamed from gnuradio-examples/python/digital/rx_voice.py) | 42 | ||||
-rwxr-xr-x | gr-digital/examples/tx_voice.py (renamed from gnuradio-examples/python/digital/tx_voice.py) | 39 |
5 files changed, 59 insertions, 32 deletions
diff --git a/gnuradio-examples/python/digital/Makefile.am b/gnuradio-examples/python/digital/Makefile.am index 91f662dc78..f9d1294001 100644 --- a/gnuradio-examples/python/digital/Makefile.am +++ b/gnuradio-examples/python/digital/Makefile.am @@ -41,6 +41,4 @@ dist_ourdata_SCRIPTS = \ benchmark_tx.py \ benchmark_qt_rx.py \ benchmark_qt_loopback.py\ - rx_voice.py \ - tunnel.py \ - tx_voice.py + tunnel.py
\ No newline at end of file diff --git a/gr-digital/examples/Makefile.am b/gr-digital/examples/Makefile.am index 0643363c09..849e826a15 100644 --- a/gr-digital/examples/Makefile.am +++ b/gr-digital/examples/Makefile.am @@ -33,6 +33,8 @@ dist_ourdata_SCRIPTS = \ receive_path.py \ benchmark_tx.py \ benchmark_rx.py \ + tx_voice.py \ + rx_voice.py \ run_length.py \ gen_whitener.py diff --git a/gr-digital/examples/benchmark_tx.py b/gr-digital/examples/benchmark_tx.py index e5d24915af..92013a532d 100755 --- a/gr-digital/examples/benchmark_tx.py +++ b/gr-digital/examples/benchmark_tx.py @@ -20,8 +20,8 @@ # Boston, MA 02110-1301, USA. # -from gnuradio import gr, gru -from gnuradio import usrp +from gnuradio import gr +from gnuradio import uhd from gnuradio import eng_notation from gnuradio.eng_option import eng_option from optparse import OptionParser diff --git a/gnuradio-examples/python/digital/rx_voice.py b/gr-digital/examples/rx_voice.py index 1aad1ff8e6..d29d64ed69 100755 --- a/gnuradio-examples/python/digital/rx_voice.py +++ b/gr-digital/examples/rx_voice.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2005,2006,2009 Free Software Foundation, Inc. +# Copyright 2005,2006,2009,2011 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -20,8 +20,8 @@ # Boston, MA 02110-1301, USA. # -from gnuradio import gr, gru, modulation_utils -from gnuradio import usrp +from gnuradio import gr +from gnuradio import uhd from gnuradio import audio from gnuradio import eng_notation from gnuradio.eng_option import eng_option @@ -29,12 +29,15 @@ from optparse import OptionParser from gnuradio.vocoder import gsm_full_rate +# From gr-digital +from gnuradio import digital + import random import struct import sys # from current dir -import usrp_receive_path +from receive_path import receive_path #import os #print os.getpid() @@ -47,11 +50,12 @@ class audio_tx(gr.hier_block2): gr.io_signature(0, 0, 0), # Input signature gr.io_signature(0, 0, 0)) # Output signature + sample_rate = 8000 self.packet_src = gr.message_source(33) voice_decoder = gsm_full_rate.decode_ps() s2f = gr.short_to_float () sink_scale = gr.multiply_const_ff(1.0/32767.) - audio_sink = audio.sink(8000, audio_output_dev) + audio_sink = audio.sink(sample_rate, audio_output_dev) self.connect(self.packet_src, voice_decoder, s2f, sink_scale, audio_sink) def msgq(self): @@ -61,9 +65,18 @@ class audio_tx(gr.hier_block2): class my_top_block(gr.top_block): def __init__(self, demod_class, rx_callback, options): gr.top_block.__init__(self) - self.rxpath = usrp_receive_path.usrp_receive_path(demod_class, rx_callback, options) + self.rxpath = receive_path(demod_class, rx_callback, options) self.audio_tx = audio_tx(options.audio_output) - self.connect(self.rxpath) + + if(options.from_file is not None): + self.thr = gr.throttle(gr.sizeof_gr_complex, options.bitrate) + self.source = gr.file_source(gr.sizeof_gr_complex, options.from_file) + self.connect(self.source, self.thr, self.rxpath) + else: + self.thr = gr.throttle(gr.sizeof_gr_complex, 1e6) + self.source = gr.null_source(gr.sizeof_gr_complex) + self.connect(self.source, self.thr, self.rxpath) + self.connect(self.audio_tx) # ///////////////////////////////////////////////////////////////////////////// @@ -89,7 +102,7 @@ def main(): print "ok = %r n_rcvd = %4d n_right = %4d" % ( ok, n_rcvd, n_right) - demods = modulation_utils.type_1_demods() + demods = digital.modulation_utils2.type_1_demods() # Create Options Parser: parser = OptionParser (option_class=eng_option, conflict_handler="resolve") @@ -101,7 +114,9 @@ def main(): % (', '.join(demods.keys()),)) parser.add_option("-O", "--audio-output", type="string", default="", help="pcm output device name. E.g., hw:0,0 or /dev/dsp") - usrp_receive_path.add_options(parser, expert_grp) + parser.add_option("","--from-file", default=None, + help="input file of samples to demod") + receive_path.add_options(parser, expert_grp) for mod in demods.values(): mod.add_options(expert_grp) @@ -113,10 +128,11 @@ def main(): parser.print_help(sys.stderr) sys.exit(1) - if options.rx_freq is None: - sys.stderr.write("You must specify -f FREQ or --freq FREQ\n") - parser.print_help(sys.stderr) - sys.exit(1) + if options.from_file is None: + if options.rx_freq is None: + sys.stderr.write("You must specify -f FREQ or --freq FREQ\n") + parser.print_help(sys.stderr) + sys.exit(1) # build the graph diff --git a/gnuradio-examples/python/digital/tx_voice.py b/gr-digital/examples/tx_voice.py index d8692beb40..f4f2c3a86f 100755 --- a/gnuradio-examples/python/digital/tx_voice.py +++ b/gr-digital/examples/tx_voice.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2005,2006,2007,2009 Free Software Foundation, Inc. +# Copyright 2005-2007,2009,2011 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -20,8 +20,8 @@ # Boston, MA 02110-1301, USA. # -from gnuradio import gr, gru, modulation_utils -from gnuradio import usrp +from gnuradio import gr +from gnuradio import uhd from gnuradio import audio from gnuradio import eng_notation from gnuradio.eng_option import eng_option @@ -29,13 +29,16 @@ from optparse import OptionParser from gnuradio.vocoder import gsm_full_rate +# From gr-digital +from gnuradio import digital + import random import time import struct import sys # from current dir -import usrp_transmit_path +from transmit_path import transmit_path #import os #print os.getpid() @@ -64,11 +67,17 @@ class my_top_block(gr.top_block): def __init__(self, modulator_class, options): gr.top_block.__init__(self) - self.txpath = usrp_transmit_path.usrp_transmit_path(modulator_class, options) + self.txpath = transmit_path(modulator_class, options) self.audio_rx = audio_rx(options.audio_input) - self.connect(self.txpath) - self.connect(self.audio_rx) + if(options.to_file is not None): + self.sink = gr.file_sink(gr.sizeof_gr_complex, options.to_file) + else: + self.sink = gr.null_sink(gr.sizeof_gr_complex) + + self.connect(self.audio_rx) + self.connect(self.txpath, self.sink) + # ///////////////////////////////////////////////////////////////////////////// # main @@ -82,7 +91,7 @@ def main(): def rx_callback(ok, payload): print "ok = %r, payload = '%s'" % (ok, payload) - mods = modulation_utils.type_1_mods() + mods = digital.modulation_utils2.type_1_mods() parser = OptionParser(option_class=eng_option, conflict_handler="resolve") expert_grp = parser.add_option_group("Expert") @@ -95,7 +104,9 @@ def main(): help="set megabytes to transmit [default=inf]") parser.add_option("-I", "--audio-input", type="string", default="", help="pcm input device name. E.g., hw:0,0 or /dev/dsp") - usrp_transmit_path.add_options(parser, expert_grp) + parser.add_option("","--to-file", default=None, + help="Output file for modulated samples") + transmit_path.add_options(parser, expert_grp) for mod in mods.values(): mod.add_options(expert_grp) @@ -107,11 +118,11 @@ def main(): parser.print_help() sys.exit(1) - if options.tx_freq is None: - sys.stderr.write("You must specify -f FREQ or --freq FREQ\n") - parser.print_help(sys.stderr) - sys.exit(1) - + if options.to_file is None: + if options.tx_freq is None: + sys.stderr.write("You must specify -f FREQ or --freq FREQ\n") + parser.print_help(sys.stderr) + sys.exit(1) # build the graph tb = my_top_block(mods[options.modulation], options) |