diff options
Diffstat (limited to 'gr-digital')
-rwxr-xr-x | gr-digital/examples/ofdm/benchmark_ofdm_rx.py | 16 | ||||
-rw-r--r-- | gr-digital/examples/ofdm/receive_path.py | 7 | ||||
-rw-r--r-- | gr-digital/python/ofdm.py | 22 | ||||
-rw-r--r-- | gr-digital/python/ofdm_packet_utils.py | 3 | ||||
-rw-r--r-- | gr-digital/python/ofdm_receiver.py | 39 |
5 files changed, 52 insertions, 35 deletions
diff --git a/gr-digital/examples/ofdm/benchmark_ofdm_rx.py b/gr-digital/examples/ofdm/benchmark_ofdm_rx.py index 5ba161d28..6f8e59d98 100755 --- a/gr-digital/examples/ofdm/benchmark_ofdm_rx.py +++ b/gr-digital/examples/ofdm/benchmark_ofdm_rx.py @@ -25,6 +25,8 @@ from gnuradio import eng_notation from gnuradio.eng_option import eng_option from optparse import OptionParser +from gnuradio import digital + # from current dir from receive_path import receive_path from uhd_interface import uhd_receiver @@ -90,15 +92,21 @@ def main(): expert_grp = parser.add_option_group("Expert") parser.add_option("","--discontinuous", action="store_true", default=False, help="enable discontinuous") + parser.add_option("","--from-file", default=None, + help="input file of samples to demod") - my_top_block.add_options(parser, expert_grp) receive_path.add_options(parser, expert_grp) - blks2.ofdm_mod.add_options(parser, expert_grp) - blks2.ofdm_demod.add_options(parser, expert_grp) - fusb_options.add_options(expert_grp) + uhd_receiver.add_options(parser) + digital.ofdm_demod.add_options(parser, expert_grp) (options, args) = parser.parse_args () + 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 tb = my_top_block(rx_callback, options) diff --git a/gr-digital/examples/ofdm/receive_path.py b/gr-digital/examples/ofdm/receive_path.py index 06c9fb27a..8807b0dc2 100644 --- a/gr-digital/examples/ofdm/receive_path.py +++ b/gr-digital/examples/ofdm/receive_path.py @@ -19,9 +19,10 @@ # Boston, MA 02110-1301, USA. # -from gnuradio import gr, blks2 +from gnuradio import gr from gnuradio import eng_notation from gnuradio import digital + import copy import sys @@ -44,8 +45,8 @@ class receive_path(gr.hier_block2): self._rx_callback = rx_callback # this callback is fired when there's a packet available # receiver - self.ofdm_rx = blks2.ofdm_demod(options, - callback=self._rx_callback) + self.ofdm_rx = digital.ofdm_demod(options, + callback=self._rx_callback) # Carrier Sensing Blocks alpha = 0.001 diff --git a/gr-digital/python/ofdm.py b/gr-digital/python/ofdm.py index 806f0a7ad..ba49c6250 100644 --- a/gr-digital/python/ofdm.py +++ b/gr-digital/python/ofdm.py @@ -24,6 +24,7 @@ import math from gnuradio import gr import digital_swig import ofdm_packet_utils +from ofdm_receiver import ofdm_receiver import gnuradio.gr.gr_threading as _threading import psk, qam @@ -206,13 +207,13 @@ class ofdm_demod(gr.hier_block2): # hard-coded known symbols preambles = (ksfreq,) - + symbol_length = self._fft_length + self._cp_length - self.ofdm_recv = digital_swig.ofdm_receiver(self._fft_length, - self._cp_length, - self._occupied_tones, - self._snr, preambles, - options.log) + self.ofdm_recv = ofdm_receiver(self._fft_length, + self._cp_length, + self._occupied_tones, + self._snr, preambles, + options.log) mods = {"bpsk": 2, "qpsk": 4, "8psk": 8, "qam8": 8, "qam16": 16, "qam64": 64, "qam256": 256} arity = mods[self._modulation] @@ -243,9 +244,12 @@ class ofdm_demod(gr.hier_block2): self.connect(self.ofdm_recv.chan_filt, self) if options.log: - self.connect(self.ofdm_demod, gr.file_sink(gr.sizeof_gr_complex*self._occupied_tones, "ofdm_frame_sink_c.dat")) + self.connect(self.ofdm_demod, + gr.file_sink(gr.sizeof_gr_complex*self._occupied_tones, + "ofdm_frame_sink_c.dat")) else: - self.connect(self.ofdm_demod, gr.null_sink(gr.sizeof_gr_complex*self._occupied_tones)) + self.connect(self.ofdm_demod, + gr.null_sink(gr.sizeof_gr_complex*self._occupied_tones)) if options.verbose: self._print_verbage() @@ -264,6 +268,8 @@ class ofdm_demod(gr.hier_block2): help="set the number of occupied FFT bins [default=%default]") expert.add_option("", "--cp-length", type="intx", default=128, help="set the number of bits in the cyclic prefix [default=%default]") + expert.add_option("", "--snr", type="float", default=30.0, + help="SNR estimate [default=%default]") # Make a static method to call before instantiation add_options = staticmethod(add_options) diff --git a/gr-digital/python/ofdm_packet_utils.py b/gr-digital/python/ofdm_packet_utils.py index ccd4be27c..d0000e6db 100644 --- a/gr-digital/python/ofdm_packet_utils.py +++ b/gr-digital/python/ofdm_packet_utils.py @@ -22,7 +22,6 @@ import struct import numpy from gnuradio import gru -import digital_swig import crc def conv_packed_binary_string_to_1_0_string(s): @@ -182,7 +181,7 @@ def unmake_packet(whitened_payload_with_crc, whitener_offset=0, dewhitening=1): else: payload_with_crc = whitened_payload_with_crc - ok, payload = gru.check_crc32(payload_with_crc) + ok, payload = crc.check_crc32(payload_with_crc) if 0: print "payload_with_crc =", string_to_hex_list(payload_with_crc) diff --git a/gr-digital/python/ofdm_receiver.py b/gr-digital/python/ofdm_receiver.py index d89c79c4d..6c19cb32e 100644 --- a/gr-digital/python/ofdm_receiver.py +++ b/gr-digital/python/ofdm_receiver.py @@ -23,7 +23,10 @@ import math from numpy import fft from gnuradio import gr -import digital_swig +from ofdm_sync_pn import ofdm_sync_pn +from ofdm_sync_fixed import ofdm_sync_fixed +from ofdm_sync_pnac import ofdm_sync_pnac +from ofdm_sync_ml import ofdm_sync_ml class ofdm_receiver(gr.hier_block2): """ @@ -83,22 +86,22 @@ class ofdm_receiver(gr.hier_block2): SYNC = "pn" if SYNC == "ml": nco_sensitivity = -1.0/fft_length # correct for fine frequency - self.ofdm_sync = digital_swig.ofdm_sync_ml(fft_length, - cp_length, - snr, - ks0time, - logging) + self.ofdm_sync = ofdm_sync_ml(fft_length, + cp_length, + snr, + ks0time, + logging) elif SYNC == "pn": nco_sensitivity = -2.0/fft_length # correct for fine frequency - self.ofdm_sync = digital_swig.ofdm_sync_pn(fft_length, - cp_length, - logging) + self.ofdm_sync = ofdm_sync_pn(fft_length, + cp_length, + logging) elif SYNC == "pnac": nco_sensitivity = -2.0/fft_length # correct for fine frequency - self.ofdm_sync = digital_swig.ofdm_sync_pnac(fft_length, - cp_length, - ks0time, - logging) + self.ofdm_sync = ofdm_sync_pnac(fft_length, + cp_length, + ks0time, + logging) # for testing only; do not user over the air # remove filter and filter delay for this elif SYNC == "fixed": @@ -106,11 +109,11 @@ class ofdm_receiver(gr.hier_block2): nsymbols = 18 # enter the number of symbols per packet freq_offset = 0.0 # if you use a frequency offset, enter it here nco_sensitivity = -2.0/fft_length # correct for fine frequency - self.ofdm_sync = digital_swig.ofdm_sync_fixed(fft_length, - cp_length, - nsymbols, - freq_offset, - logging) + self.ofdm_sync = ofdm_sync_fixed(fft_length, + cp_length, + nsymbols, + freq_offset, + logging) # Set up blocks |