diff options
author | Johnathan Corgan <jcorgan@corganenterprises.com> | 2012-08-28 12:52:09 -0700 |
---|---|---|
committer | Johnathan Corgan <jcorgan@corganenterprises.com> | 2012-08-28 12:52:09 -0700 |
commit | 5892c29ee0509ff8aa226f14da524f7ec30f9654 (patch) | |
tree | 759624a4c9f9b5d6c2e2da13906be99aebf25152 /gr-digital | |
parent | 7adff515181de5cfbd7392d934cac9083a8a6a58 (diff) | |
parent | fc4d37062c46886d3bc1fb0b6c3626d779be4ecd (diff) |
Merge remote branch 'reynwar/comments_next' into next
Conflicts:
gr-digital/include/digital_constellation.h
gr-digital/python/bpsk.py
gr-digital/python/qpsk.py
Diffstat (limited to 'gr-digital')
-rw-r--r-- | gr-digital/examples/narrowband/receive_path.py | 4 | ||||
-rw-r--r-- | gr-digital/examples/narrowband/transmit_path.py | 4 | ||||
-rwxr-xr-x | gr-digital/examples/narrowband/tunnel.py | 5 | ||||
-rw-r--r-- | gr-digital/examples/ofdm/receive_path.py | 4 | ||||
-rw-r--r-- | gr-digital/examples/ofdm/transmit_path.py | 4 | ||||
-rwxr-xr-x | gr-digital/examples/ofdm/tunnel.py | 5 | ||||
-rw-r--r-- | gr-digital/python/__init__.py | 3 | ||||
-rw-r--r-- | gr-digital/python/bpsk.py | 102 | ||||
-rw-r--r-- | gr-digital/python/cpm.py | 61 | ||||
-rw-r--r-- | gr-digital/python/generic_mod_demod.py | 95 | ||||
-rw-r--r-- | gr-digital/python/gfsk.py | 37 | ||||
-rw-r--r-- | gr-digital/python/gmsk.py | 72 | ||||
-rw-r--r-- | gr-digital/python/modulation_utils.py | 9 | ||||
-rw-r--r-- | gr-digital/python/ofdm.py | 18 | ||||
-rw-r--r-- | gr-digital/python/ofdm_packet_utils.py | 34 | ||||
-rw-r--r-- | gr-digital/python/ofdm_receiver.py | 19 | ||||
-rw-r--r-- | gr-digital/python/packet_utils.py | 28 | ||||
-rw-r--r-- | gr-digital/python/pkt.py | 31 | ||||
-rw-r--r-- | gr-digital/python/psk.py | 47 | ||||
-rw-r--r-- | gr-digital/python/qam.py | 45 | ||||
-rw-r--r-- | gr-digital/python/qpsk.py | 90 | ||||
-rw-r--r-- | gr-digital/python/utils/mod_codes.py | 1 |
22 files changed, 354 insertions, 364 deletions
diff --git a/gr-digital/examples/narrowband/receive_path.py b/gr-digital/examples/narrowband/receive_path.py index 9aa6dc488d..308f955645 100644 --- a/gr-digital/examples/narrowband/receive_path.py +++ b/gr-digital/examples/narrowband/receive_path.py @@ -119,8 +119,8 @@ class receive_path(gr.hier_block2): """ Set carrier threshold. - @param threshold_in_db: set detection threshold - @type threshold_in_db: float (dB) + Args: + threshold_in_db: set detection threshold (float (dB)) """ self.probe.set_threshold(threshold_in_db) diff --git a/gr-digital/examples/narrowband/transmit_path.py b/gr-digital/examples/narrowband/transmit_path.py index 4d6162ed61..ec87ecd825 100644 --- a/gr-digital/examples/narrowband/transmit_path.py +++ b/gr-digital/examples/narrowband/transmit_path.py @@ -71,7 +71,9 @@ class transmit_path(gr.hier_block2): def set_tx_amplitude(self, ampl): """ Sets the transmit amplitude sent to the USRP in volts - @param: ampl 0 <= ampl < 1. + + Args: + : ampl 0 <= ampl < 1. """ self._tx_amplitude = max(0.0, min(ampl, 1)) self.amp.set_k(self._tx_amplitude) diff --git a/gr-digital/examples/narrowband/tunnel.py b/gr-digital/examples/narrowband/tunnel.py index 65205b9f6f..7b9b69cc8a 100755 --- a/gr-digital/examples/narrowband/tunnel.py +++ b/gr-digital/examples/narrowband/tunnel.py @@ -161,8 +161,9 @@ class cs_mac(object): """ Invoked by thread associated with PHY to pass received packet up. - @param ok: bool indicating whether payload CRC was OK - @param payload: contents of the packet (string) + Args: + ok: bool indicating whether payload CRC was OK + payload: contents of the packet (string) """ if self.verbose: print "Rx: ok = %r len(payload) = %4d" % (ok, len(payload)) diff --git a/gr-digital/examples/ofdm/receive_path.py b/gr-digital/examples/ofdm/receive_path.py index e1c7868a0e..b5094ac24d 100644 --- a/gr-digital/examples/ofdm/receive_path.py +++ b/gr-digital/examples/ofdm/receive_path.py @@ -77,8 +77,8 @@ class receive_path(gr.hier_block2): """ Set carrier threshold. - @param threshold_in_db: set detection threshold - @type threshold_in_db: float (dB) + Args: + threshold_in_db: set detection threshold (float (dB)) """ self.probe.set_threshold(threshold_in_db) diff --git a/gr-digital/examples/ofdm/transmit_path.py b/gr-digital/examples/ofdm/transmit_path.py index ec357d6173..6fb66e4076 100644 --- a/gr-digital/examples/ofdm/transmit_path.py +++ b/gr-digital/examples/ofdm/transmit_path.py @@ -62,7 +62,9 @@ class transmit_path(gr.hier_block2): def set_tx_amplitude(self, ampl): """ Sets the transmit amplitude sent to the USRP - @param: ampl 0 <= ampl < 1.0. Try 0.10 + + Args: + : ampl 0 <= ampl < 1.0. Try 0.10 """ self._tx_amplitude = max(0.0, min(ampl, 1)) self.amp.set_k(self._tx_amplitude) diff --git a/gr-digital/examples/ofdm/tunnel.py b/gr-digital/examples/ofdm/tunnel.py index e253cf5161..f407aef8d6 100755 --- a/gr-digital/examples/ofdm/tunnel.py +++ b/gr-digital/examples/ofdm/tunnel.py @@ -146,8 +146,9 @@ class cs_mac(object): """ Invoked by thread associated with PHY to pass received packet up. - @param ok: bool indicating whether payload CRC was OK - @param payload: contents of the packet (string) + Args: + ok: bool indicating whether payload CRC was OK + payload: contents of the packet (string) """ if self.verbose: print "Rx: ok = %r len(payload) = %4d" % (ok, len(payload)) diff --git a/gr-digital/python/__init__.py b/gr-digital/python/__init__.py index 3fdbca769a..662bb2d8f8 100644 --- a/gr-digital/python/__init__.py +++ b/gr-digital/python/__init__.py @@ -19,8 +19,7 @@ # ''' -This is the gr-digital package. It contains all of the blocks, -utilities, and examples for doing digital modulation and demodulation. +Blocks and utilities for digital modulation and demodulation. ''' # The presence of this file turns this directory into a Python package diff --git a/gr-digital/python/bpsk.py b/gr-digital/python/bpsk.py index d55db15256..57cf2534f4 100644 --- a/gr-digital/python/bpsk.py +++ b/gr-digital/python/bpsk.py @@ -28,6 +28,7 @@ from cmath import exp from gnuradio import gr from gnuradio.digital.generic_mod_demod import generic_mod, generic_demod +from gnuradio.digital.generic_mod_demod import shared_mod_args, shared_demod_args import digital_swig import modulation_utils @@ -43,50 +44,51 @@ def bpsk_constellation(): # ///////////////////////////////////////////////////////////////////////////// class bpsk_mod(generic_mod): + """ + Hierarchical block for RRC-filtered BPSK modulation. + + The input is a byte stream (unsigned char) and the + output is the complex modulated signal at baseband. + + + Args: + mod_code: Argument is not used. It exists purely to simplify generation of the block in grc. + differential: Whether to use differential encoding (boolean). + """ + # See generic_mod for additional arguments + __doc__ += shared_mod_args def __init__(self, mod_code=None, differential=False, *args, **kwargs): - """ - Hierarchical block for RRC-filtered BPSK modulation. - - The input is a byte stream (unsigned char) and the - output is the complex modulated signal at baseband. - - See generic_mod block for list of parameters. - - 'mod_code' argument is not used. - It exists purely to simplify generation of the block in grc. - """ - constellation = digital_swig.constellation_bpsk() super(bpsk_mod, self).__init__(constellation=constellation, differential=differential, *args, **kwargs) - + + # ///////////////////////////////////////////////////////////////////////////// # BPSK demodulator # # ///////////////////////////////////////////////////////////////////////////// class bpsk_demod(generic_demod): + """ + Hierarchical block for RRC-filtered BPSK modulation. + + The input is a byte stream (unsigned char) and the + output is the complex modulated signal at baseband. + + Args: + mod_code: Argument is not used. It exists purely to simplify generation of the block in grc. + differential: whether to use differential encoding (boolean) + """ + # See generic_demod for additional arguments + __doc__ += shared_demod_args def __init__(self, mod_code=None, differential=False, *args, **kwargs): - - """ - Hierarchical block for RRC-filtered BPSK modulation. - - The input is a byte stream (unsigned char) and the - output is the complex modulated signal at baseband. - - See generic_demod block for list of parameters. - - 'mod_code' argument is not used. - It exists purely to simplify generation of the block in grc. - """ - constellation = digital_swig.constellation_bpsk() super(bpsk_demod, self).__init__(constellation=constellation, differential=differential, *args, **kwargs) - +#bpsk_demod.__doc__ += shared_demod_args # ///////////////////////////////////////////////////////////////////////////// @@ -101,21 +103,20 @@ def dbpsk_constellation(): # ///////////////////////////////////////////////////////////////////////////// class dbpsk_mod(bpsk_mod): + """ + Hierarchical block for RRC-filtered DBPSK modulation. + + The input is a byte stream (unsigned char) and the + output is the complex modulated signal at baseband. + + Args: + mod_code: Argument is not used. It exists purely to simplify generation of the block in grc. + """ + # See generic_mod for additional arguments + __doc__ += shared_mod_args def __init__(self, mod_code=None, *args, **kwargs): - """ - Hierarchical block for RRC-filtered DBPSK modulation. - - The input is a byte stream (unsigned char) and the - output is the complex modulated signal at baseband. - - See generic_mod block for list of parameters. - - 'mod_code' argument is not used. - It exists purely to simplify generation of the block in grc. - """ - super(dbpsk_mod, self).__init__(*args, **kwargs) # ///////////////////////////////////////////////////////////////////////////// @@ -124,21 +125,20 @@ class dbpsk_mod(bpsk_mod): # ///////////////////////////////////////////////////////////////////////////// class dbpsk_demod(bpsk_demod): + """ + Hierarchical block for RRC-filtered DBPSK modulation. + + The input is a byte stream (unsigned char) and the + output is the complex modulated signal at baseband. + + Args: + mod_code: Argument is not used. It exists purely to simplify generation of the block in grc. + """ + # See generic_demod for additional arguments + __doc__ += shared_demod_args def __init__(self, mod_code=None, *args, **kwargs): - """ - Hierarchical block for RRC-filtered DBPSK modulation. - - The input is a byte stream (unsigned char) and the - output is the complex modulated signal at baseband. - - See generic_demod block for list of parameters. - - 'mod_code' argument is not used. - It exists purely to simplify generation of the block in grc. - """ - super(dbpsk_demod, self).__init__(*args, **kwargs) # diff --git a/gr-digital/python/cpm.py b/gr-digital/python/cpm.py index eaefa194cf..a2c9f2f0e0 100644 --- a/gr-digital/python/cpm.py +++ b/gr-digital/python/cpm.py @@ -49,6 +49,31 @@ _def_log = False # ///////////////////////////////////////////////////////////////////////////// class cpm_mod(gr.hier_block2): + """ + Hierarchical block for Continuous Phase modulation. + + The input is a byte stream (unsigned char) representing packed + bits and the output is the complex modulated signal at baseband. + + See Proakis for definition of generic CPM signals: + s(t)=exp(j phi(t)) + phi(t)= 2 pi h int_0^t f(t') dt' + f(t)=sum_k a_k g(t-kT) + (normalizing assumption: int_0^infty g(t) dt = 1/2) + + Args: + samples_per_symbol: samples per baud >= 2 (integer) + bits_per_symbol: bits per symbol (integer) + h_numerator: numerator of modulation index (integer) + h_denominator: denominator of modulation index (numerator and denominator must be relative primes) (integer) + cpm_type: supported types are: 0=CPFSK, 1=GMSK, 2=RC, 3=GENERAL (integer) + bt: bandwidth symbol time product for GMSK (float) + symbols_per_pulse: shaping pulse duration in symbols (integer) + generic_taps: define a generic CPM pulse shape (sum = samples_per_symbol/2) (list/array of floats) + verbose: Print information about modulator? (boolean) + debug: Print modulation data to files? (boolean) + """ + def __init__(self, samples_per_symbol=_def_samples_per_symbol, bits_per_symbol=_def_bits_per_symbol, @@ -60,42 +85,6 @@ class cpm_mod(gr.hier_block2): generic_taps=_def_generic_taps, verbose=_def_verbose, log=_def_log): - """ - Hierarchical block for Continuous Phase - modulation. - - The input is a byte stream (unsigned char) - representing packed bits and the - output is the complex modulated signal at baseband. - - See Proakis for definition of generic CPM signals: - s(t)=exp(j phi(t)) - phi(t)= 2 pi h int_0^t f(t') dt' - f(t)=sum_k a_k g(t-kT) - (normalizing assumption: int_0^infty g(t) dt = 1/2) - - @param samples_per_symbol: samples per baud >= 2 - @type samples_per_symbol: integer - @param bits_per_symbol: bits per symbol - @type bits_per_symbol: integer - @param h_numerator: numerator of modulation index - @type h_numerator: integer - @param h_denominator: denominator of modulation index (numerator and denominator must be relative primes) - @type h_denominator: integer - @param cpm_type: supported types are: 0=CPFSK, 1=GMSK, 2=RC, 3=GENERAL - @type cpm_type: integer - @param bt: bandwidth symbol time product for GMSK - @type bt: float - @param symbols_per_pulse: shaping pulse duration in symbols - @type symbols_per_pulse: integer - @param generic_taps: define a generic CPM pulse shape (sum = samples_per_symbol/2) - @type generic_taps: array of floats - - @param verbose: Print information about modulator? - @type verbose: bool - @param debug: Print modulation data to files? - @type debug: bool - """ gr.hier_block2.__init__(self, "cpm_mod", gr.io_signature(1, 1, gr.sizeof_char), # Input signature diff --git a/gr-digital/python/generic_mod_demod.py b/gr-digital/python/generic_mod_demod.py index 73d93b0157..855249dc63 100644 --- a/gr-digital/python/generic_mod_demod.py +++ b/gr-digital/python/generic_mod_demod.py @@ -79,6 +79,21 @@ def add_common_options(parser): # ///////////////////////////////////////////////////////////////////////////// class generic_mod(gr.hier_block2): + """ + Hierarchical block for RRC-filtered differential generic modulation. + + The input is a byte stream (unsigned char) and the + output is the complex modulated signal at baseband. + + Args: + constellation: determines the modulation type (gnuradio.digital.digital_constellation) + samples_per_symbol: samples per baud >= 2 (float) + differential: whether to use differential encoding (boolean) + pre_diff_code: whether to use apply a pre-differential mapping (boolean) + excess_bw: Root-raised cosine filter excess bandwidth (float) + verbose: Print information about modulator? (boolean) + log: Log modulation data to files? (boolean) + """ def __init__(self, constellation, differential=_def_differential, @@ -87,27 +102,6 @@ class generic_mod(gr.hier_block2): excess_bw=_def_excess_bw, verbose=_def_verbose, log=_def_log): - """ - Hierarchical block for RRC-filtered differential generic modulation. - - The input is a byte stream (unsigned char) and the - output is the complex modulated signal at baseband. - - @param constellation: determines the modulation type - @type constellation: gnuradio.digital.gr_constellation - @param samples_per_symbol: samples per baud >= 2 - @type samples_per_symbol: float - @param differential: whether to use differential encoding - @type differential: boolean - @param pre_diff_code: whether to use apply a pre-differential mapping - @type pre_diff_code: boolean - @param excess_bw: Root-raised cosine filter excess bandwidth - @type excess_bw: float - @param verbose: Print information about modulator? - @type verbose: bool - @param log: Log modulation data to files? - @type log: bool - """ gr.hier_block2.__init__(self, "generic_mod", gr.io_signature(1, 1, gr.sizeof_char), # Input signature @@ -215,6 +209,24 @@ class generic_mod(gr.hier_block2): # ///////////////////////////////////////////////////////////////////////////// class generic_demod(gr.hier_block2): + """ + Hierarchical block for RRC-filtered differential generic demodulation. + + The input is the complex modulated signal at baseband. + The output is a stream of bits packed 1 bit per byte (LSB) + + Args: + constellation: determines the modulation type (gnuradio.digital.digital_constellation) + samples_per_symbol: samples per baud >= 2 (float) + differential: whether to use differential encoding (boolean) + pre_diff_code: whether to use apply a pre-differential mapping (boolean) + excess_bw: Root-raised cosine filter excess bandwidth (float) + freq_bw: loop filter lock-in bandwidth (float) + timing_bw: timing recovery loop lock-in bandwidth (float) + phase_bw: phase recovery loop bandwidth (float) + verbose: Print information about modulator? (boolean) + log: Log modulation data to files? (boolean) + """ def __init__(self, constellation, differential=_def_differential, @@ -226,33 +238,6 @@ class generic_demod(gr.hier_block2): phase_bw=_def_phase_bw, verbose=_def_verbose, log=_def_log): - """ - Hierarchical block for RRC-filtered differential generic demodulation. - - The input is the complex modulated signal at baseband. - The output is a stream of bits packed 1 bit per byte (LSB) - - @param constellation: determines the modulation type - @type constellation: gnuradio.digital.gr_constellation - @param samples_per_symbol: samples per symbol >= 2 - @type samples_per_symbol: float - @param differential: whether to use differential encoding - @type differential: boolean - @param pre_diff_code: whether to use apply a pre-differential mapping - @type pre_diff_code: boolean - @param excess_bw: Root-raised cosine filter excess bandwidth - @type excess_bw: float - @param freq_bw: loop filter lock-in bandwidth - @type freq_bw: float - @param timing_bw: timing recovery loop lock-in bandwidth - @type timing_bw: float - @param phase_bw: phase recovery loop bandwidth - @type phase_bw: float - @param verbose: Print information about modulator? - @type verbose: bool - @param debug: Print modualtion data to files? - @type debug: bool - """ gr.hier_block2.__init__(self, "generic_demod", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature @@ -399,3 +384,17 @@ class generic_demod(gr.hier_block2): return extract_kwargs_from_options_for_class(cls, options) extract_kwargs_from_options=classmethod(extract_kwargs_from_options) +shared_demod_args = """ samples_per_symbol: samples per baud >= 2 (float) + excess_bw: Root-raised cosine filter excess bandwidth (float) + freq_bw: loop filter lock-in bandwidth (float) + timing_bw: timing recovery loop lock-in bandwidth (float) + phase_bw: phase recovery loop bandwidth (float) + verbose: Print information about modulator? (boolean) + log: Log modulation data to files? (boolean) +""" + +shared_mod_args = """ samples_per_symbol: samples per baud >= 2 (float) + excess_bw: Root-raised cosine filter excess bandwidth (float) + verbose: Print information about modulator? (boolean) + log: Log modulation data to files? (boolean) +""" diff --git a/gr-digital/python/gfsk.py b/gr-digital/python/gfsk.py index 215583dd8c..09f12ebc30 100644 --- a/gr-digital/python/gfsk.py +++ b/gr-digital/python/gfsk.py @@ -73,14 +73,11 @@ class gfsk_mod(gr.hier_block2): The input is a byte stream (unsigned char) and the output is the complex modulated signal at baseband. - @param samples_per_symbol: samples per baud >= 2 - @type samples_per_symbol: integer - @param bt: Gaussian filter bandwidth * symbol time - @type bt: float - @param verbose: Print information about modulator? - @type verbose: bool - @param debug: Print modualtion data to files? - @type debug: bool + Args: + samples_per_symbol: samples per baud >= 2 (integer) + bt: Gaussian filter bandwidth * symbol time (float) + verbose: Print information about modulator? (bool) + debug: Print modualtion data to files? (bool) """ gr.hier_block2.__init__(self, "gfsk_mod", @@ -195,23 +192,19 @@ class gfsk_demod(gr.hier_block2): The input is the complex modulated signal at baseband. The output is a stream of bits packed 1 bit per byte (the LSB) - @param samples_per_symbol: samples per baud - @type samples_per_symbol: integer - @param verbose: Print information about modulator? - @type verbose: bool - @param log: Print modualtion data to files? - @type log: bool + Args: + samples_per_symbol: samples per baud (integer) + verbose: Print information about modulator? (bool) + log: Print modualtion data to files? (bool) Clock recovery parameters. These all have reasonble defaults. - @param gain_mu: controls rate of mu adjustment - @type gain_mu: float - @param mu: fractional delay [0.0, 1.0] - @type mu: float - @param omega_relative_limit: sets max variation in omega - @type omega_relative_limit: float, typically 0.000200 (200 ppm) - @param freq_error: bit rate error as a fraction - @param float + Args: + gain_mu: controls rate of mu adjustment (float) + mu: fractional delay [0.0, 1.0] (float) + omega_relative_limit: sets max variation in omega (float, typically 0.000200 (200 ppm)) + freq_error: bit rate error as a fraction + float: """ gr.hier_block2.__init__(self, "gfsk_demod", diff --git a/gr-digital/python/gmsk.py b/gr-digital/python/gmsk.py index 8f8c659010..e7853dd0af 100644 --- a/gr-digital/python/gmsk.py +++ b/gr-digital/python/gmsk.py @@ -59,28 +59,25 @@ _def_omega_relative_limit = 0.005 # ///////////////////////////////////////////////////////////////////////////// class gmsk_mod(gr.hier_block2): + """ + Hierarchical block for Gaussian Minimum Shift Key (GMSK) + modulation. + + The input is a byte stream (unsigned char) and the + output is the complex modulated signal at baseband. + + Args: + samples_per_symbol: samples per baud >= 2 (integer) + bt: Gaussian filter bandwidth * symbol time (float) + verbose: Print information about modulator? (boolean) + debug: Print modulation data to files? (boolean) + """ def __init__(self, samples_per_symbol=_def_samples_per_symbol, bt=_def_bt, verbose=_def_verbose, log=_def_log): - """ - Hierarchical block for Gaussian Minimum Shift Key (GMSK) - modulation. - - The input is a byte stream (unsigned char) and the - output is the complex modulated signal at baseband. - - @param samples_per_symbol: samples per baud >= 2 - @type samples_per_symbol: integer - @param bt: Gaussian filter bandwidth * symbol time - @type bt: float - @param verbose: Print information about modulator? - @type verbose: bool - @param debug: Print modualtion data to files? - @type debug: bool - """ gr.hier_block2.__init__(self, "gmsk_mod", gr.io_signature(1, 1, gr.sizeof_char), # Input signature @@ -174,7 +171,23 @@ class gmsk_mod(gr.hier_block2): # ///////////////////////////////////////////////////////////////////////////// class gmsk_demod(gr.hier_block2): - + """ + Hierarchical block for Gaussian Minimum Shift Key (GMSK) + demodulation. + + The input is the complex modulated signal at baseband. + The output is a stream of bits packed 1 bit per byte (the LSB) + + Args: + samples_per_symbol: samples per baud (integer) + verbose: Print information about modulator? (boolean) + log: Print modualtion data to files? (boolean) + gain_mu: controls rate of mu adjustment (float) + mu: fractional delay [0.0, 1.0] (float) + omega_relative_limit: sets max variation in omega (float) + freq_error: bit rate error as a fraction (float) + """ + def __init__(self, samples_per_symbol=_def_samples_per_symbol, gain_mu=_def_gain_mu, @@ -183,31 +196,6 @@ class gmsk_demod(gr.hier_block2): freq_error=_def_freq_error, verbose=_def_verbose, log=_def_log): - """ - Hierarchical block for Gaussian Minimum Shift Key (GMSK) - demodulation. - - The input is the complex modulated signal at baseband. - The output is a stream of bits packed 1 bit per byte (the LSB) - - @param samples_per_symbol: samples per baud - @type samples_per_symbol: integer - @param verbose: Print information about modulator? - @type verbose: bool - @param log: Print modualtion data to files? - @type log: bool - - Clock recovery parameters. These all have reasonble defaults. - - @param gain_mu: controls rate of mu adjustment - @type gain_mu: float - @param mu: fractional delay [0.0, 1.0] - @type mu: float - @param omega_relative_limit: sets max variation in omega - @type omega_relative_limit: float, typically 0.000200 (200 ppm) - @param freq_error: bit rate error as a fraction - @param float - """ gr.hier_block2.__init__(self, "gmsk_demod", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature diff --git a/gr-digital/python/modulation_utils.py b/gr-digital/python/modulation_utils.py index cb3a9812d4..d499094d05 100644 --- a/gr-digital/python/modulation_utils.py +++ b/gr-digital/python/modulation_utils.py @@ -74,11 +74,10 @@ def extract_kwargs_from_options(function, excluded_args, options): but in that case the default provided in the __init__ argument list will be used since there is no kwargs entry.) - @param function: the function whose parameter list will be examined - @param excluded_args: function arguments that are NOT to be added to the dictionary - @type excluded_args: sequence of strings - @param options: result of command argument parsing - @type options: optparse.Values + Args: + function: the function whose parameter list will be examined + excluded_args: function arguments that are NOT to be added to the dictionary (sequence of strings) + options: result of command argument parsing (optparse.Values) """ # Try this in C++ ;) diff --git a/gr-digital/python/ofdm.py b/gr-digital/python/ofdm.py index 00f52e3730..4113a552eb 100644 --- a/gr-digital/python/ofdm.py +++ b/gr-digital/python/ofdm.py @@ -46,10 +46,10 @@ class ofdm_mod(gr.hier_block2): Packets to be sent are enqueued by calling send_pkt. The output is the complex modulated signal at baseband. - @param options: pass modulation options from higher layers (fft length, occupied tones, etc.) - @param msgq_limit: maximum number of messages in message queue - @type msgq_limit: int - @param pad_for_usrp: If true, packets are padded such that they end up a multiple of 128 samples + Args: + options: pass modulation options from higher layers (fft length, occupied tones, etc.) + msgq_limit: maximum number of messages in message queue (int) + pad_for_usrp: If true, packets are padded such that they end up a multiple of 128 samples """ gr.hier_block2.__init__(self, "ofdm_mod", @@ -130,8 +130,8 @@ class ofdm_mod(gr.hier_block2): """ Send the payload. - @param payload: data to send - @type payload: string + Args: + payload: data to send (string) """ if eof: msg = gr.message(1) # tell self._pkt_input we're not sending any more packets @@ -188,9 +188,9 @@ class ofdm_demod(gr.hier_block2): The input is the complex modulated signal at baseband. Demodulated packets are sent to the handler. - @param options: pass modulation options from higher layers (fft length, occupied tones, etc.) - @param callback: function of two args: ok, payload - @type callback: ok: bool; payload: string + Args: + options: pass modulation options from higher layers (fft length, occupied tones, etc.) + callback: function of two args: ok, payload (ok: bool; payload: string) """ gr.hier_block2.__init__(self, "ofdm_demod", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature diff --git a/gr-digital/python/ofdm_packet_utils.py b/gr-digital/python/ofdm_packet_utils.py index d0000e6db5..c49dfe4f8e 100644 --- a/gr-digital/python/ofdm_packet_utils.py +++ b/gr-digital/python/ofdm_packet_utils.py @@ -101,14 +101,12 @@ def make_packet(payload, samples_per_symbol, bits_per_symbol, """ Build a packet, given access code, payload, and whitener offset - @param payload: packet payload, len [0, 4096] - @param samples_per_symbol: samples per symbol (needed for padding calculation) - @type samples_per_symbol: int - @param bits_per_symbol: (needed for padding calculation) - @type bits_per_symbol: int - @param whitener_offset offset into whitener string to use [0-16) - @param whitening: Turn whitener on or off - @type whitening: bool + Args: + payload: packet payload, len [0, 4096] + samples_per_symbol: samples per symbol (needed for padding calculation) (int) + bits_per_symbol: (needed for padding calculation) (int) + whitener_offset: offset into whitener string to use [0-16) + whitening: Turn whitener on or off (bool) Packet will have access code at the beginning, followed by length, payload and finally CRC-32. @@ -150,13 +148,13 @@ def _npadding_bytes(pkt_byte_len, samples_per_symbol, bits_per_symbol): we want to pad so that after modulation the resulting packet is a multiple of 128 samples. - @param ptk_byte_len: len in bytes of packet, not including padding. - @param samples_per_symbol: samples per bit (1 bit / symbolwidth GMSK) - @type samples_per_symbol: int - @param bits_per_symbol: bits per symbol (log2(modulation order)) - @type bits_per_symbol: int + Args: + ptk_byte_len: len in bytes of packet, not including padding. + samples_per_symbol: samples per bit (1 bit / symbolwidth GMSK) (int) + bits_per_symbol: bits per symbol (log2(modulation order)) (int) - @returns number of bytes of padding to append. + Returns: + number of bytes of padding to append. """ modulus = 128 byte_modulus = gru.lcm(modulus/8, samples_per_symbol) * bits_per_symbol / samples_per_symbol @@ -170,10 +168,10 @@ def unmake_packet(whitened_payload_with_crc, whitener_offset=0, dewhitening=1): """ Return (ok, payload) - @param whitened_payload_with_crc: string - @param whitener_offset offset into whitener string to use [0-16) - @param dewhitening: Turn whitener on or off - @type dewhitening: bool + Args: + whitened_payload_with_crc: string + whitener_offset: offset into whitener string to use [0-16) + dewhitening: Turn whitener on or off (bool) """ if dewhitening: diff --git a/gr-digital/python/ofdm_receiver.py b/gr-digital/python/ofdm_receiver.py index 8290042e6f..1dc3cdf7cd 100644 --- a/gr-digital/python/ofdm_receiver.py +++ b/gr-digital/python/ofdm_receiver.py @@ -52,18 +52,13 @@ class ofdm_receiver(gr.hier_block2): The input is the complex modulated signal at baseband. Synchronized packets are sent back to the demodulator. - @param fft_length: total number of subcarriers - @type fft_length: int - @param cp_length: length of cyclic prefix as specified in subcarriers (<= fft_length) - @type cp_length: int - @param occupied_tones: number of subcarriers used for data - @type occupied_tones: int - @param snr: estimated signal to noise ratio used to guide cyclic prefix synchronizer - @type snr: float - @param ks: known symbols used as preambles to each packet - @type ks: list of lists - @param logging: turn file logging on or off - @type logging: bool + Args: + fft_length: total number of subcarriers (int) + cp_length: length of cyclic prefix as specified in subcarriers (<= fft_length) (int) + occupied_tones: number of subcarriers used for data (int) + snr: estimated signal to noise ratio used to guide cyclic prefix synchronizer (float) + ks: known symbols used as preambles to each packet (list of lists) + logging: turn file logging on or off (bool) """ gr.hier_block2.__init__(self, "ofdm_receiver", diff --git a/gr-digital/python/packet_utils.py b/gr-digital/python/packet_utils.py index 2e216ff50e..2929758ef0 100644 --- a/gr-digital/python/packet_utils.py +++ b/gr-digital/python/packet_utils.py @@ -107,13 +107,12 @@ def make_packet(payload, samples_per_symbol, bits_per_symbol, """ Build a packet, given access code, payload, and whitener offset - @param payload: packet payload, len [0, 4096] - @param samples_per_symbol: samples per symbol (needed for padding calculation) - @type samples_per_symbol: int - @param bits_per_symbol: (needed for padding calculation) - @type bits_per_symbol: int - @param access_code: string of ascii 0's and 1's - @param whitener_offset offset into whitener string to use [0-16) + Args: + payload: packet payload, len [0, 4096] + samples_per_symbol: samples per symbol (needed for padding calculation) (int) + bits_per_symbol: (needed for padding calculation) (int) + access_code: string of ascii 0's and 1's + whitener_offset: offset into whitener string to use [0-16) Packet will have access code at the beginning, followed by length, payload and finally CRC-32. @@ -156,13 +155,13 @@ def _npadding_bytes(pkt_byte_len, samples_per_symbol, bits_per_symbol): we want to pad so that after modulation the resulting packet is a multiple of 128 samples. - @param ptk_byte_len: len in bytes of packet, not including padding. - @param samples_per_symbol: samples per bit (1 bit / symbolwidth GMSK) - @type samples_per_symbol: int - @param bits_per_symbol: bits per symbol (log2(modulation order)) - @type bits_per_symbol: int + Args: + ptk_byte_len: len in bytes of packet, not including padding. + samples_per_symbol: samples per bit (1 bit / symbolwidth GMSK) (int) + bits_per_symbol: bits per symbol (log2(modulation order)) (int) - @returns number of bytes of padding to append. + Returns: + number of bytes of padding to append. """ modulus = 128 byte_modulus = gru.lcm(modulus/8, samples_per_symbol) * bits_per_symbol / samples_per_symbol @@ -176,7 +175,8 @@ def unmake_packet(whitened_payload_with_crc, whitener_offset=0, dewhitening=True """ Return (ok, payload) - @param whitened_payload_with_crc: string + Args: + whitened_payload_with_crc: string """ if dewhitening: diff --git a/gr-digital/python/pkt.py b/gr-digital/python/pkt.py index b294066f17..d084c3ff0f 100644 --- a/gr-digital/python/pkt.py +++ b/gr-digital/python/pkt.py @@ -44,14 +44,12 @@ class mod_pkts(gr.hier_block2): Packets to be sent are enqueued by calling send_pkt. The output is the complex modulated signal at baseband. - @param modulator: instance of modulator class (gr_block or hier_block2) - @type modulator: complex baseband out - @param access_code: AKA sync vector - @type access_code: string of 1's and 0's between 1 and 64 long - @param msgq_limit: maximum number of messages in message queue - @type msgq_limit: int - @param pad_for_usrp: If true, packets are padded such that they end up a multiple of 128 samples - @param use_whitener_offset: If true, start of whitener XOR string is incremented each packet + Args: + modulator: instance of modulator class (gr_block or hier_block2) (complex baseband out) + access_code: AKA sync vector (string of 1's and 0's between 1 and 64 long) + msgq_limit: maximum number of messages in message queue (int) + pad_for_usrp: If true, packets are padded such that they end up a multiple of 128 samples + use_whitener_offset: If true, start of whitener XOR string is incremented each packet See gmsk_mod for remaining parameters """ @@ -79,8 +77,8 @@ class mod_pkts(gr.hier_block2): """ Send the payload. - @param payload: data to send - @type payload: string + Args: + payload: data to send (string) """ if eof: msg = gr.message(1) # tell self._pkt_input we're not sending any more packets @@ -116,14 +114,11 @@ class demod_pkts(gr.hier_block2): The input is the complex modulated signal at baseband. Demodulated packets are sent to the handler. - @param demodulator: instance of demodulator class (gr_block or hier_block2) - @type demodulator: complex baseband in - @param access_code: AKA sync vector - @type access_code: string of 1's and 0's - @param callback: function of two args: ok, payload - @type callback: ok: bool; payload: string - @param threshold: detect access_code with up to threshold bits wrong (-1 -> use default) - @type threshold: int + Args: + demodulator: instance of demodulator class (gr_block or hier_block2) (complex baseband in) + access_code: AKA sync vector (string of 1's and 0's) + callback: function of two args: ok, payload (ok: bool; payload: string) + threshold: detect access_code with up to threshold bits wrong (-1 -> use default) (int) """ gr.hier_block2.__init__(self, "demod_pkts", diff --git a/gr-digital/python/psk.py b/gr-digital/python/psk.py index 4b35447278..1816ffb4ba 100644 --- a/gr-digital/python/psk.py +++ b/gr-digital/python/psk.py @@ -30,6 +30,7 @@ import digital_swig import modulation_utils from utils import mod_codes, gray_code from generic_mod_demod import generic_mod, generic_demod +from generic_mod_demod import shared_mod_args, shared_demod_args # Default number of points in constellation. _def_constellation_points = 4 @@ -81,21 +82,24 @@ def psk_constellation(m=_def_constellation_points, mod_code=_def_mod_code, # ///////////////////////////////////////////////////////////////////////////// class psk_mod(generic_mod): + """ + Hierarchical block for RRC-filtered PSK modulation. + + The input is a byte stream (unsigned char) and the + output is the complex modulated signal at baseband. + + Args: + constellation_points: Number of constellation points (must be a power of two) (integer). + mod_code: Whether to use a gray_code (digital.mod_codes.GRAY_CODE) or not (digital.mod_codes.NO_CODE). + differential: Whether to use differential encoding (boolean). + """ + # See generic_mod for additional arguments + __doc__ += shared_mod_args def __init__(self, constellation_points=_def_constellation_points, mod_code=_def_mod_code, differential=_def_differential, *args, **kwargs): - - """ - Hierarchical block for RRC-filtered PSK modulation. - - The input is a byte stream (unsigned char) and the - output is the complex modulated signal at baseband. - - See generic_mod block for list of parameters. - """ - constellation = psk_constellation(constellation_points, mod_code, differential) super(psk_mod, self).__init__(constellation, differential, *args, **kwargs) @@ -106,20 +110,23 @@ class psk_mod(generic_mod): class psk_demod(generic_demod): + """ + Hierarchical block for RRC-filtered PSK modulation. + + The input is a byte stream (unsigned char) and the + output is the complex modulated signal at baseband. + + Args: + constellation_points: Number of constellation points (must be a power of two) (integer). + mod_code: Whether to use a gray_code (digital.mod_codes.GRAY_CODE) or not (digital.mod_codes.NO_CODE). + differential: Whether to use differential encoding (boolean). + """ + # See generic_mod for additional arguments + __doc__ += shared_mod_args def __init__(self, constellation_points=_def_constellation_points, mod_code=_def_mod_code, differential=_def_differential, *args, **kwargs): - - """ - Hierarchical block for RRC-filtered PSK modulation. - - The input is a byte stream (unsigned char) and the - output is the complex modulated signal at baseband. - - See generic_demod block for list of parameters. - """ - constellation = psk_constellation(constellation_points, mod_code, differential) super(psk_demod, self).__init__(constellation, differential, *args, **kwargs) diff --git a/gr-digital/python/qam.py b/gr-digital/python/qam.py index 73bad2f75b..8584c59c6f 100644 --- a/gr-digital/python/qam.py +++ b/gr-digital/python/qam.py @@ -27,6 +27,7 @@ from math import pi, sqrt, log from gnuradio import gr from generic_mod_demod import generic_mod, generic_demod +from generic_mod_demod import shared_mod_args, shared_demod_args from utils.gray_code import gray_code from utils import mod_codes import modulation_utils @@ -180,21 +181,25 @@ def qam_constellation(constellation_points=_def_constellation_points, # ///////////////////////////////////////////////////////////////////////////// class qam_mod(generic_mod): + """ + Hierarchical block for RRC-filtered QAM modulation. + + The input is a byte stream (unsigned char) and the + output is the complex modulated signal at baseband. + + Args: + constellation_points: Number of constellation points (must be a power of four) (integer). + mod_code: Whether to use a gray_code (digital.mod_codes.GRAY_CODE) or not (digital.mod_codes.NO_CODE). + differential: Whether to use differential encoding (boolean). + """ + # See generic_mod for additional arguments + __doc__ += shared_mod_args def __init__(self, constellation_points=_def_constellation_points, differential=_def_differential, mod_code=_def_mod_code, *args, **kwargs): - """ - Hierarchical block for RRC-filtered QAM modulation. - - The input is a byte stream (unsigned char) and the - output is the complex modulated signal at baseband. - - See generic_mod block for list of parameters. - """ - constellation = qam_constellation(constellation_points, differential, mod_code) # We take care of the gray coding in the constellation generation so it doesn't # need to be done in the block. @@ -207,20 +212,24 @@ class qam_mod(generic_mod): # ///////////////////////////////////////////////////////////////////////////// class qam_demod(generic_demod): + """ + Hierarchical block for RRC-filtered QAM modulation. + + The input is a byte stream (unsigned char) and the + output is the complex modulated signal at baseband. + + Args: + constellation_points: Number of constellation points (must be a power of four) (integer). + mod_code: Whether to use a gray_code (digital.mod_codes.GRAY_CODE) or not (digital.mod_codes.NO_CODE). + differential: Whether to use differential encoding (boolean). + """ + # See generic_demod for additional arguments + __doc__ += shared_mod_args def __init__(self, constellation_points=_def_constellation_points, differential=_def_differential, mod_code=_def_mod_code, *args, **kwargs): - - """ - Hierarchical block for RRC-filtered QAM modulation. - - The input is a byte stream (unsigned char) and the - output is the complex modulated signal at baseband. - - See generic_demod block for list of parameters. - """ constellation = qam_constellation(constellation_points, differential, mod_code) # We take care of the gray coding in the constellation generation so it doesn't # need to be done in the block. diff --git a/gr-digital/python/qpsk.py b/gr-digital/python/qpsk.py index d6c06bc83f..859d981367 100644 --- a/gr-digital/python/qpsk.py +++ b/gr-digital/python/qpsk.py @@ -27,6 +27,7 @@ Demodulation is not included since the generic_mod_demod from gnuradio import gr from gnuradio.digital.generic_mod_demod import generic_mod, generic_demod +from gnuradio.digital.generic_mod_demod import shared_mod_args, shared_demod_args from utils import mod_codes import digital_swig as digital import modulation_utils @@ -39,6 +40,9 @@ _def_mod_code = mod_codes.GRAY_CODE # ///////////////////////////////////////////////////////////////////////////// def qpsk_constellation(mod_code=_def_mod_code): + """ + Creates a QPSK constellation. + """ if mod_code != mod_codes.GRAY_CODE: raise ValueError("This QPSK mod/demod works only for gray-coded constellations.") return digital.constellation_qpsk() @@ -48,18 +52,20 @@ def qpsk_constellation(mod_code=_def_mod_code): # ///////////////////////////////////////////////////////////////////////////// class qpsk_mod(generic_mod): - - def __init__(self, mod_code=_def_mod_code, differential=False, *args, **kwargs): - - """ - Hierarchical block for RRC-filtered QPSK modulation. - - The input is a byte stream (unsigned char) and the - output is the complex modulated signal at baseband. - - See generic_mod block for list of parameters. - """ + """ + Hierarchical block for RRC-filtered QPSK modulation. + + The input is a byte stream (unsigned char) and the + output is the complex modulated signal at baseband. + + Args: + mod_code: Whether to use a gray_code (digital.mod_codes.GRAY_CODE) or not (digital.mod_codes.NO_CODE). + differential: Whether to use differential encoding (boolean). + """ + # See generic_mod for additional arguments + __doc__ += shared_mod_args + def __init__(self, mod_code=_def_mod_code, differential=False, *args, **kwargs): pre_diff_code = True if not differential: constellation = digital.constellation_qpsk() @@ -83,19 +89,21 @@ class qpsk_mod(generic_mod): # ///////////////////////////////////////////////////////////////////////////// class qpsk_demod(generic_demod): + """ + Hierarchical block for RRC-filtered QPSK modulation. + + The input is a byte stream (unsigned char) and the + output is the complex modulated signal at baseband. + + Args: + mod_code: Whether to use a gray_code (digital.mod_codes.GRAY_CODE) or not (digital.mod_codes.NO_CODE). + differential: Whether to use differential encoding (boolean). + """ + # See generic_mod for additional arguments + __doc__ += shared_demod_args def __init__(self, mod_code=_def_mod_code, differential=False, *args, **kwargs): - - """ - Hierarchical block for RRC-filtered QPSK modulation. - - The input is a byte stream (unsigned char) and the - output is the complex modulated signal at baseband. - - See generic_demod block for list of parameters. - """ - pre_diff_code = True if not differential: constellation = digital.constellation_qpsk() @@ -128,16 +136,19 @@ def dqpsk_constellation(mod_code=_def_mod_code): # ///////////////////////////////////////////////////////////////////////////// class dqpsk_mod(qpsk_mod): + """ + Hierarchical block for RRC-filtered DQPSK modulation. + + The input is a byte stream (unsigned char) and the + output is the complex modulated signal at baseband. + + Args: + mod_code: Whether to use a gray_code (digital.mod_codes.GRAY_CODE) or not (digital.mod_codes.NO_CODE). + """ + # See generic_mod for additional arguments + __doc__ += shared_mod_args def __init__(self, mod_code=_def_mod_code, *args, **kwargs): - """ - Hierarchical block for RRC-filtered DQPSK modulation. - - The input is a byte stream (unsigned char) and the - output is the complex modulated signal at baseband. - - See generic_mod block for list of parameters. - """ super(dqpsk_mod, self).__init__(mod_code, *args, **kwargs) @@ -147,17 +158,19 @@ class dqpsk_mod(qpsk_mod): # ///////////////////////////////////////////////////////////////////////////// class dqpsk_demod(qpsk_demod): + """ + Hierarchical block for RRC-filtered DQPSK modulation. + + The input is a byte stream (unsigned char) and the + output is the complex modulated signal at baseband. + + Args: + mod_code: Whether to use a gray_code (digital.mod_codes.GRAY_CODE) or not (digital.mod_codes.NO_CODE). + """ + # See generic_mod for additional arguments + __doc__ += shared_demod_args def __init__(self, mod_code=_def_mod_code, *args, **kwargs): - - """ - Hierarchical block for RRC-filtered DQPSK modulation. - - The input is a byte stream (unsigned char) and the - output is the complex modulated signal at baseband. - - See generic_demod block for list of parameters. - """ super(dqpsk_demod, self).__init__(mod_code, *args, **kwargs) @@ -170,4 +183,3 @@ modulation_utils.add_type_1_constellation('qpsk', qpsk_constellation) modulation_utils.add_type_1_mod('dqpsk', dqpsk_mod) modulation_utils.add_type_1_demod('dqpsk', dqpsk_demod) modulation_utils.add_type_1_constellation('dqpsk', dqpsk_constellation) - diff --git a/gr-digital/python/utils/mod_codes.py b/gr-digital/python/utils/mod_codes.py index caacda5cc6..f55fe41b8b 100644 --- a/gr-digital/python/utils/mod_codes.py +++ b/gr-digital/python/utils/mod_codes.py @@ -20,6 +20,7 @@ # Boston, MA 02110-1301, USA. # +# Constants used to represent what coding to use. GRAY_CODE = 'gray' SET_PARTITION_CODE = 'set-partition' NO_CODE = 'none' |