diff options
Diffstat (limited to 'gr-digital/examples')
-rw-r--r-- | gr-digital/examples/narrowband/README (renamed from gr-digital/examples/README) | 0 | ||||
-rwxr-xr-x | gr-digital/examples/narrowband/benchmark_rx.py | 6 | ||||
-rwxr-xr-x | gr-digital/examples/narrowband/benchmark_tx.py | 6 | ||||
-rwxr-xr-x | gr-digital/examples/narrowband/digital_bert_rx.py | 2 | ||||
-rwxr-xr-x | gr-digital/examples/narrowband/digital_bert_tx.py | 2 | ||||
-rwxr-xr-x | gr-digital/examples/narrowband/rx_voice.py | 2 | ||||
-rwxr-xr-x | gr-digital/examples/narrowband/tunnel.py | 8 | ||||
-rw-r--r-- | gr-digital/examples/narrowband/uhd_interface.py | 38 | ||||
-rwxr-xr-x | gr-digital/examples/ofdm/benchmark_rx.py | 2 | ||||
-rwxr-xr-x | gr-digital/examples/ofdm/benchmark_tx.py | 2 | ||||
-rwxr-xr-x | gr-digital/examples/ofdm/tunnel.py | 4 | ||||
-rw-r--r-- | gr-digital/examples/ofdm/uhd_interface.py | 28 |
12 files changed, 56 insertions, 44 deletions
diff --git a/gr-digital/examples/README b/gr-digital/examples/narrowband/README index 1c50ad69b..1c50ad69b 100644 --- a/gr-digital/examples/README +++ b/gr-digital/examples/narrowband/README diff --git a/gr-digital/examples/narrowband/benchmark_rx.py b/gr-digital/examples/narrowband/benchmark_rx.py index 65aac3638..32c3222ae 100755 --- a/gr-digital/examples/narrowband/benchmark_rx.py +++ b/gr-digital/examples/narrowband/benchmark_rx.py @@ -44,7 +44,11 @@ class my_top_block(gr.top_block): gr.top_block.__init__(self) if(options.rx_freq is not None): - self.source = uhd_receiver(options.address, options.bitrate, + # Work-around to get the modulation's bits_per_symbol + args = demodulator.extract_kwargs_from_options(options) + symbol_rate = options.bitrate / demodulator(**args).bits_per_symbol() + + self.source = uhd_receiver(options.args, symbol_rate, options.samples_per_symbol, options.rx_freq, options.rx_gain, options.antenna, options.verbose) diff --git a/gr-digital/examples/narrowband/benchmark_tx.py b/gr-digital/examples/narrowband/benchmark_tx.py index 1fd881981..25ed355da 100755 --- a/gr-digital/examples/narrowband/benchmark_tx.py +++ b/gr-digital/examples/narrowband/benchmark_tx.py @@ -43,7 +43,11 @@ class my_top_block(gr.top_block): gr.top_block.__init__(self) if(options.tx_freq is not None): - self.sink = uhd_transmitter(options.address, options.bitrate, + # Work-around to get the modulation's bits_per_symbol + args = modulator.extract_kwargs_from_options(options) + symbol_rate = options.bitrate / modulator(**args).bits_per_symbol() + + self.sink = uhd_transmitter(options.args, symbol_rate, options.samples_per_symbol, options.tx_freq, options.tx_gain, options.antenna, options.verbose) diff --git a/gr-digital/examples/narrowband/digital_bert_rx.py b/gr-digital/examples/narrowband/digital_bert_rx.py index 9878f55e1..28331310d 100755 --- a/gr-digital/examples/narrowband/digital_bert_rx.py +++ b/gr-digital/examples/narrowband/digital_bert_rx.py @@ -113,7 +113,7 @@ class rx_psk_block(gr.top_block): self._demodulator = self._demodulator_class(**demod_kwargs) if(options.rx_freq is not None): - self._source = uhd_receiver(options.address, options.bitrate, + self._source = uhd_receiver(options.args, options.bitrate, options.samples_per_symbol, options.rx_freq, options.rx_gain, options.antenna, options.verbose) diff --git a/gr-digital/examples/narrowband/digital_bert_tx.py b/gr-digital/examples/narrowband/digital_bert_tx.py index 96cb338fe..46f4f9097 100755 --- a/gr-digital/examples/narrowband/digital_bert_tx.py +++ b/gr-digital/examples/narrowband/digital_bert_tx.py @@ -67,7 +67,7 @@ class tx_psk_block(gr.top_block): self._modulator = self._modulator_class(**mod_kwargs) if(options.tx_freq is not None): - self._sink = uhd_transmitter(options.address, options.bitrate, + self._sink = uhd_transmitter(options.args, options.bitrate, options.samples_per_symbol, options.tx_freq, options.tx_gain, options.antenna, options.verbose) diff --git a/gr-digital/examples/narrowband/rx_voice.py b/gr-digital/examples/narrowband/rx_voice.py index 42d7b893b..100caff8e 100755 --- a/gr-digital/examples/narrowband/rx_voice.py +++ b/gr-digital/examples/narrowband/rx_voice.py @@ -66,7 +66,7 @@ class my_top_block(gr.top_block): self.audio_tx = audio_tx(options.audio_output) if(options.rx_freq is not None): - self.source = uhd_receiver(options.address, options.bitrate, + self.source = uhd_receiver(options.args, options.bitrate, options.samples_per_symbol, options.rx_freq, options.rx_gain, options.antenna, options.verbose) diff --git a/gr-digital/examples/narrowband/tunnel.py b/gr-digital/examples/narrowband/tunnel.py index 7f40bb1c3..7414a7227 100755 --- a/gr-digital/examples/narrowband/tunnel.py +++ b/gr-digital/examples/narrowband/tunnel.py @@ -92,12 +92,16 @@ class my_top_block(gr.top_block): gr.top_block.__init__(self) - self.source = uhd_receiver(options.address, options.bitrate, + # Get the modulation's bits_per_symbol + args = mod_class.extract_kwargs_from_options(options) + symbol_rate = options.bitrate / mod_class(**args).bits_per_symbol() + + self.source = uhd_receiver(options.args, symbol_rate, options.samples_per_symbol, options.rx_freq, options.rx_gain, options.antenna, options.verbose) - self.sink = uhd_transmitter(options.address, options.bitrate, + self.sink = uhd_transmitter(options.args, symbol_rate, options.samples_per_symbol, options.tx_freq, options.tx_gain, options.antenna, options.verbose) diff --git a/gr-digital/examples/narrowband/uhd_interface.py b/gr-digital/examples/narrowband/uhd_interface.py index 8420f3eec..a0be516ec 100644 --- a/gr-digital/examples/narrowband/uhd_interface.py +++ b/gr-digital/examples/narrowband/uhd_interface.py @@ -42,36 +42,36 @@ def add_freq_option(parser): metavar="FREQ") class uhd_interface: - def __init__(self, istx, address, bitrate, sps, freq=None, + def __init__(self, istx, args, sym_rate, sps, freq=None, gain=None, antenna=None): if(istx): - self.u = uhd.usrp_sink(device_addr=address, + self.u = uhd.usrp_sink(device_addr=args, io_type=uhd.io_type.COMPLEX_FLOAT32, num_channels=1) else: - self.u = uhd.usrp_source(device_addr=address, + self.u = uhd.usrp_source(device_addr=args, io_type=uhd.io_type.COMPLEX_FLOAT32, num_channels=1) - self._addr = address + self._args = args self._ant = antenna self._gain = self.set_gain(gain) self._freq = self.set_freq(freq) - self._rate, self._sps = self.set_sample_rate(bitrate, sps) + self._rate, self._sps = self.set_sample_rate(sym_rate, sps) if(antenna): self.u.set_antenna(antenna, 0) - def set_sample_rate(self, bitrate, req_sps): + def set_sample_rate(self, sym_rate, req_sps): start_sps = req_sps while(True): - asked_samp_rate = bitrate * req_sps + asked_samp_rate = sym_rate * req_sps self.u.set_samp_rate(asked_samp_rate) actual_samp_rate = self.u.get_samp_rate() - sps = actual_samp_rate/bitrate + sps = actual_samp_rate/sym_rate if(sps < 2): req_sps +=1 else: @@ -79,7 +79,7 @@ class uhd_interface: break if(sps != req_sps): - print "\nBit Rate: %f" % (bitrate) + print "\nSymbol Rate: %f" % (sym_rate) print "Requested sps: %f" % (start_sps) print "Given sample rate: %f" % (actual_samp_rate) print "Actual sps for rate: %f" % (actual_sps) @@ -124,14 +124,14 @@ class uhd_interface: #-------------------------------------------------------------------# class uhd_transmitter(uhd_interface, gr.hier_block2): - def __init__(self, address, bitrate, sps, freq=None, gain=None, + def __init__(self, args, sym_rate, sps, freq=None, gain=None, antenna=None, verbose=False): gr.hier_block2.__init__(self, "uhd_transmitter", gr.io_signature(1,1,gr.sizeof_gr_complex), gr.io_signature(0,0,0)) # Set up the UHD interface as a transmitter - uhd_interface.__init__(self, True, address, bitrate, sps, + uhd_interface.__init__(self, True, args, sym_rate, sps, freq, gain, antenna) self.connect(self, self.u) @@ -141,8 +141,8 @@ class uhd_transmitter(uhd_interface, gr.hier_block2): def add_options(parser): add_freq_option(parser) - parser.add_option("-a", "--address", type="string", default="addr=192.168.10.2", - help="Address of UHD device, [default=%default]") + parser.add_option("-a", "--args", type="string", default="", + help="UHD device address args [default=%default]") parser.add_option("-A", "--antenna", type="string", default=None, help="select Rx Antenna where appropriate") parser.add_option("", "--tx-freq", type="eng_float", default=None, @@ -160,7 +160,7 @@ class uhd_transmitter(uhd_interface, gr.hier_block2): Prints information about the UHD transmitter """ print "\nUHD Transmitter:" - print "Address: %s" % (self._addr) + print "Args: %s" % (self._args) print "Freq: %sHz" % (eng_notation.num_to_str(self._freq)) print "Gain: %f dB" % (self._gain) print "Sample Rate: %ssps" % (eng_notation.num_to_str(self._rate)) @@ -174,14 +174,14 @@ class uhd_transmitter(uhd_interface, gr.hier_block2): class uhd_receiver(uhd_interface, gr.hier_block2): - def __init__(self, address, bitrate, sps, freq=None, gain=None, + def __init__(self, args, sym_rate, sps, freq=None, gain=None, antenna=None, verbose=False): gr.hier_block2.__init__(self, "uhd_receiver", gr.io_signature(0,0,0), gr.io_signature(1,1,gr.sizeof_gr_complex)) # Set up the UHD interface as a receiver - uhd_interface.__init__(self, False, address, bitrate, sps, + uhd_interface.__init__(self, False, args, sym_rate, sps, freq, gain, antenna) self.connect(self.u, self) @@ -191,8 +191,8 @@ class uhd_receiver(uhd_interface, gr.hier_block2): def add_options(parser): add_freq_option(parser) - parser.add_option("-a", "--address", type="string", default="addr=192.168.10.2", - help="Address of UHD device, [default=%default]") + parser.add_option("-a", "--args", type="string", default="", + help="UHD device address args [default=%default]") parser.add_option("-A", "--antenna", type="string", default=None, help="select Rx Antenna where appropriate") parser.add_option("", "--rx-freq", type="eng_float", default=None, @@ -211,7 +211,7 @@ class uhd_receiver(uhd_interface, gr.hier_block2): Prints information about the UHD transmitter """ print "\nUHD Receiver:" - print "Address: %s" % (self._addr) + print "UHD Args: %s" % (self._args) print "Freq: %sHz" % (eng_notation.num_to_str(self._freq)) print "Gain: %f dB" % (self._gain) print "Sample Rate: %ssps" % (eng_notation.num_to_str(self._rate)) diff --git a/gr-digital/examples/ofdm/benchmark_rx.py b/gr-digital/examples/ofdm/benchmark_rx.py index f2ed3b8ff..a386a80e4 100755 --- a/gr-digital/examples/ofdm/benchmark_rx.py +++ b/gr-digital/examples/ofdm/benchmark_rx.py @@ -38,7 +38,7 @@ class my_top_block(gr.top_block): gr.top_block.__init__(self) if(options.rx_freq is not None): - self.source = uhd_receiver(options.address, + self.source = uhd_receiver(options.args, options.bandwidth, options.rx_freq, options.rx_gain, options.antenna, options.verbose) diff --git a/gr-digital/examples/ofdm/benchmark_tx.py b/gr-digital/examples/ofdm/benchmark_tx.py index ad3609b52..dd0c69b57 100755 --- a/gr-digital/examples/ofdm/benchmark_tx.py +++ b/gr-digital/examples/ofdm/benchmark_tx.py @@ -37,7 +37,7 @@ class my_top_block(gr.top_block): gr.top_block.__init__(self) if(options.tx_freq is not None): - self.sink = uhd_transmitter(options.address, + self.sink = uhd_transmitter(options.args, options.bandwidth, options.tx_freq, options.tx_gain, options.antenna, options.verbose) diff --git a/gr-digital/examples/ofdm/tunnel.py b/gr-digital/examples/ofdm/tunnel.py index 74f2667fa..dc862fbec 100755 --- a/gr-digital/examples/ofdm/tunnel.py +++ b/gr-digital/examples/ofdm/tunnel.py @@ -87,12 +87,12 @@ class my_top_block(gr.top_block): def __init__(self, callback, options): gr.top_block.__init__(self) - self.source = uhd_receiver(options.address, + self.source = uhd_receiver(options.args, options.bandwidth, options.rx_freq, options.rx_gain, options.antenna, options.verbose) - self.sink = uhd_transmitter(options.address, + self.sink = uhd_transmitter(options.args, options.bandwidth, options.tx_freq, options.tx_gain, options.antenna, options.verbose) diff --git a/gr-digital/examples/ofdm/uhd_interface.py b/gr-digital/examples/ofdm/uhd_interface.py index d03bd7f46..cd2d3152d 100644 --- a/gr-digital/examples/ofdm/uhd_interface.py +++ b/gr-digital/examples/ofdm/uhd_interface.py @@ -42,19 +42,19 @@ def add_freq_option(parser): metavar="FREQ") class uhd_interface: - def __init__(self, istx, address, bandwidth, freq=None, + def __init__(self, istx, args, bandwidth, freq=None, gain=None, antenna=None): if(istx): - self.u = uhd.usrp_sink(device_addr=address, + self.u = uhd.usrp_sink(device_addr=args, io_type=uhd.io_type.COMPLEX_FLOAT32, num_channels=1) else: - self.u = uhd.usrp_source(device_addr=address, + self.u = uhd.usrp_source(device_addr=args, io_type=uhd.io_type.COMPLEX_FLOAT32, num_channels=1) - self._addr = address + self._args = args self._ant = antenna self._gain = self.set_gain(gain) self._freq = self.set_freq(freq) @@ -104,14 +104,14 @@ class uhd_interface: #-------------------------------------------------------------------# class uhd_transmitter(uhd_interface, gr.hier_block2): - def __init__(self, address, bandwidth, freq=None, gain=None, + def __init__(self, args, bandwidth, freq=None, gain=None, antenna=None, verbose=False): gr.hier_block2.__init__(self, "uhd_transmitter", gr.io_signature(1,1,gr.sizeof_gr_complex), gr.io_signature(0,0,0)) # Set up the UHD interface as a transmitter - uhd_interface.__init__(self, True, address, bandwidth, + uhd_interface.__init__(self, True, args, bandwidth, freq, gain, antenna) self.connect(self, self.u) @@ -121,8 +121,8 @@ class uhd_transmitter(uhd_interface, gr.hier_block2): def add_options(parser): add_freq_option(parser) - parser.add_option("-a", "--address", type="string", default="addr=192.168.10.2", - help="Address of UHD device, [default=%default]") + parser.add_option("-a", "--args", type="string", default="", + help="UHD device address args [default=%default]") parser.add_option("-A", "--antenna", type="string", default=None, help="select Rx Antenna where appropriate") parser.add_option("", "--tx-freq", type="eng_float", default=None, @@ -140,7 +140,7 @@ class uhd_transmitter(uhd_interface, gr.hier_block2): Prints information about the UHD transmitter """ print "\nUHD Transmitter:" - print "Address: %s" % (self._addr) + print "UHD Args: %s" % (self._args) print "Freq: %sHz" % (eng_notation.num_to_str(self._freq)) print "Gain: %f dB" % (self._gain) print "Sample Rate: %ssps" % (eng_notation.num_to_str(self._rate)) @@ -154,14 +154,14 @@ class uhd_transmitter(uhd_interface, gr.hier_block2): class uhd_receiver(uhd_interface, gr.hier_block2): - def __init__(self, address, bandwidth, freq=None, gain=None, + def __init__(self, args, bandwidth, freq=None, gain=None, antenna=None, verbose=False): gr.hier_block2.__init__(self, "uhd_receiver", gr.io_signature(0,0,0), gr.io_signature(1,1,gr.sizeof_gr_complex)) # Set up the UHD interface as a receiver - uhd_interface.__init__(self, False, address, bandwidth, + uhd_interface.__init__(self, False, args, bandwidth, freq, gain, antenna) self.connect(self.u, self) @@ -171,8 +171,8 @@ class uhd_receiver(uhd_interface, gr.hier_block2): def add_options(parser): add_freq_option(parser) - parser.add_option("-a", "--address", type="string", default="addr=192.168.10.2", - help="Address of UHD device, [default=%default]") + parser.add_option("-a", "--args", type="string", default="", + help="UHD device address args [default=%default]") parser.add_option("-A", "--antenna", type="string", default=None, help="select Rx Antenna where appropriate") parser.add_option("", "--rx-freq", type="eng_float", default=None, @@ -191,7 +191,7 @@ class uhd_receiver(uhd_interface, gr.hier_block2): Prints information about the UHD transmitter """ print "\nUHD Receiver:" - print "Address: %s" % (self._addr) + print "UHD Args: %s" % (self._args) print "Freq: %sHz" % (eng_notation.num_to_str(self._freq)) print "Gain: %f dB" % (self._gain) print "Sample Rate: %ssps" % (eng_notation.num_to_str(self._rate)) |