commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] gnuradio-examples/python/gmsk2 benchmark_mpsk_r...


From: Thomas W. Rondeau
Subject: [Commit-gnuradio] gnuradio-examples/python/gmsk2 benchmark_mpsk_r...
Date: Wed, 28 Jun 2006 20:44:57 +0000

CVSROOT:        /sources/gnuradio
Module name:    gnuradio-examples
Changes by:     Thomas W. Rondeau <trondeau1122>        06/06/28 20:44:57

Modified files:
        python/gmsk2   : benchmark_mpsk_rx.py receive_path.py 
Removed files:
        python/gmsk2   : mpsk.py mpsk_pkt.py mpsk_receive_path.py 
                         mpsk_transmit_path.py pkt.py 

Log message:
        removed mpsk*.py and pkt.py to be handled by generic packet and path 
scripts.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnuradio-examples/python/gmsk2/benchmark_mpsk_rx.py?cvsroot=gnuradio&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/gnuradio-examples/python/gmsk2/receive_path.py?cvsroot=gnuradio&r1=1.13&r2=1.14
http://cvs.savannah.gnu.org/viewcvs/gnuradio-examples/python/gmsk2/mpsk.py?cvsroot=gnuradio&r1=1.6&r2=0
http://cvs.savannah.gnu.org/viewcvs/gnuradio-examples/python/gmsk2/mpsk_pkt.py?cvsroot=gnuradio&r1=1.4&r2=0
http://cvs.savannah.gnu.org/viewcvs/gnuradio-examples/python/gmsk2/mpsk_receive_path.py?cvsroot=gnuradio&r1=1.2&r2=0
http://cvs.savannah.gnu.org/viewcvs/gnuradio-examples/python/gmsk2/mpsk_transmit_path.py?cvsroot=gnuradio&r1=1.2&r2=0
http://cvs.savannah.gnu.org/viewcvs/gnuradio-examples/python/gmsk2/pkt.py?cvsroot=gnuradio&r1=1.1&r2=0

Patches:
Index: benchmark_mpsk_rx.py
===================================================================
RCS file: 
/sources/gnuradio/gnuradio-examples/python/gmsk2/benchmark_mpsk_rx.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- benchmark_mpsk_rx.py        28 Jun 2006 18:15:23 -0000      1.2
+++ benchmark_mpsk_rx.py        28 Jun 2006 20:44:57 -0000      1.3
@@ -44,11 +44,11 @@
 class my_graph(gr.flow_graph):
 
     def __init__(self, demod_class, rx_subdev_spec,
-                 bitrate, decim_rate, spb, arity,
+                 bitrate, decim_rate, spb,
                  rx_callback, options, demod_kwargs):
         gr.flow_graph.__init__(self)
         self.rxpath = receive_path(self, demod_class, rx_subdev_spec,
-                                   bitrate, decim_rate, spb, arity,
+                                   bitrate, decim_rate, spb,
                                    rx_callback, options, demod_kwargs)
 
 # /////////////////////////////////////////////////////////////////////////////
@@ -111,18 +111,15 @@
     #       once static class definitions for modulations are defined
     if(options.modulation=='bpsk'):
         modulation=bpsk_demod
-        m_arity=2
     elif(options.modulation=='dbpsk'):
         modulation=dbpsk_demod
-        m_arity=2
     else:
         modulation=dqpsk_demod
-        m_arity=4
 
     # build the graph
     fg = my_graph(modulation,
                   options.rx_subdev_spec, options.bitrate,
-                  options.decim, options.spb, m_arity,
+                  options.decim, options.spb,
                   rx_callback, options, demod_kwargs)
 
     print "bitrate: %sb/sec" % (eng_notation.num_to_str(fg.rxpath.bitrate()),)

Index: receive_path.py
===================================================================
RCS file: /sources/gnuradio/gnuradio-examples/python/gmsk2/receive_path.py,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- receive_path.py     28 Jun 2006 18:15:23 -0000      1.13
+++ receive_path.py     28 Jun 2006 20:44:57 -0000      1.14
@@ -24,7 +24,6 @@
 from gnuradio import usrp
 
 # from current dir
-from pkt import demod_pkts
 from pick_bitrate import pick_rx_bitrate
 
 # /////////////////////////////////////////////////////////////////////////////
@@ -33,7 +32,7 @@
 
 class receive_path(gr.hier_block):
     def __init__(self, fg, demod_class, rx_subdev_spec,
-                 bitrate, decim, spb, m_arity,
+                 bitrate, decim, spb,
                  rx_callback, options, demod_kwargs):
 
         self.u = usrp.source_c (fusb_block_size=options.fusb_block_size,

Index: mpsk.py
===================================================================
RCS file: mpsk.py
diff -N mpsk.py
--- mpsk.py     16 Jun 2006 06:21:52 -0000      1.6
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,278 +0,0 @@
-#
-# Copyright 2005,2006 Free Software Foundation, Inc.
-# 
-# This file is part of GNU Radio
-# 
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-# 
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING.  If not, write to
-# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-# Boston, MA 02111-1307, USA.
-# 
-
-# See gnuradio-examples/python/gmsk2 for examples
-
-"""
-m-PSK and differential m-PSK modulation and demodulation.
-"""
-
-from gnuradio import gr, gru
-from math import pi, sqrt
-import cmath
-import Numeric
-from pprint import pprint
-
-_use_gray_code = True
-
-def make_constellation(m):
-    return [cmath.exp(i * 2 * pi / m * 1j) for i in range(m)]
-        
-# Common definition of constellations for Tx and Rx
-constellation = {
-    2 : make_constellation(2),           # BPSK
-    4 : make_constellation(4),           # QPSK
-    8 : make_constellation(8)            # 8PSK
-    }
-
-if 0:
-    print "const(2) ="
-    pprint(constellation[2])
-    print "const(4) ="
-    pprint(constellation[4])
-    print "const(8) ="
-    pprint(constellation[8])
-
-
-if _use_gray_code:
-    # -----------------------
-    # Do Gray code
-    # -----------------------
-    # binary to gray coding
-    binary_to_gray = {
-        2 : (0, 1),
-        4 : (0, 1, 3, 2),
-        8 : (0, 1, 3, 2, 7, 6, 4, 5)
-        }
-    
-    # gray to binary
-    gray_to_binary = {
-        2 : (0, 1),
-        4 : (0, 1, 3, 2),
-        8 : (0, 1, 3, 2, 6, 7, 5, 4)
-        }
-else:
-    # -----------------------
-    # Don't Gray code
-    # -----------------------
-    # identity mapping
-    binary_to_gray = {
-        2 : (0, 1),
-        4 : (0, 1, 2, 3),
-        8 : (0, 1, 2, 3, 4, 5, 6, 7)
-        }
-    
-    # identity mapping
-    gray_to_binary = {
-        2 : (0, 1),
-        4 : (0, 1, 2, 3),
-        8 : (0, 1, 2, 3, 4, 5, 6, 7)
-        }
-
-
-# /////////////////////////////////////////////////////////////////////////////
-#            mPSK mod/demod with steams of bytes as data i/o
-# /////////////////////////////////////////////////////////////////////////////
-
-
-class mpsk_mod(gr.hier_block):
-
-    def __init__(self, fg, spb, excess_bw, arity, diff):
-        """
-       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.
-
-       @param fg: flow graph
-       @type fg: flow graph
-       @param spb: samples per baud >= 2
-       @type spb: integer
-       @param excess_bw: Root-raised cosine filter excess bandwidth
-       @type excess_bw: float
-        @param arity: whick PSK: 2, 4, 8
-        @type arity: int in {2, 4, 8}
-        @param diff: differential PSK if true
-        @type diff: bool
-       """
-        if not isinstance(spb, int) or spb < 2:
-            raise TypeError, "sbp must be an integer >= 2"
-        self.spb = spb
-
-        if not arity in (2, 4):
-            raise ValueError, "n must be 2, 4, or 8"
-
-       ntaps = 11 * spb
-
-        bits_per_symbol = int(gru.log2(arity))
-        print "bits_per_symbol =", bits_per_symbol
-        
-        # turn bytes into k-bit vectors
-        self.bytes2chunks = \
-          gr.packed_to_unpacked_bb(bits_per_symbol, gr.GR_MSB_FIRST)
-
-        if True or arity > 2:
-            self.gray_coder = gr.map_bb(binary_to_gray[arity])
-        else:
-            self.gray_coder = None
-
-        if diff:
-            self.diffenc = gr.diff_encoder_bb(arity)
-        else:
-            self.diffenc = None
-
-        self.chunks2symbols = gr.chunks_to_symbols_bc(constellation[arity])
-
-        # pulse shaping filter
-       self.rrc_taps = gr.firdes.root_raised_cosine(
-               spb,            # gain  (spb since we're interpolating by spb)
-               spb,            # sampling rate
-               1.0,            # symbol rate
-               excess_bw,      # excess bandwidth (roll-off factor)
-                ntaps)
-
-       self.rrc_filter = gr.interp_fir_filter_ccf(spb, self.rrc_taps)
-
-       # Connect
-        if self.gray_coder:
-            fg.connect(self.bytes2chunks, self.gray_coder)
-            t = self.gray_coder
-        else:
-            t = self.bytes2chunks
-
-        if diff:
-            fg.connect(t, self.diffenc, self.chunks2symbols, self.rrc_filter)
-        else:
-            fg.connect(t, self.chunks2symbols, self.rrc_filter)
-
-        if 1:
-            fg.connect(self.gray_coder,
-                       gr.file_sink(gr.sizeof_char, "graycoder.dat"))
-            fg.connect(self.diffenc,
-                       gr.file_sink(gr.sizeof_char, "diffenc.dat"))
-            
-       # Initialize base class
-       gr.hier_block.__init__(self, fg, self.bytes2chunks, self.rrc_filter)
-
-
-class 
mpsk_demod__coherent_detection_of_differentially_encoded_psk(gr.hier_block):
-    def __init__(self, fg, spb, excess_bw, arity, diff=False, 
costas_alpha=0.005, gain_mu=0.05):
-        """
-       Hierarchical block for RRC-filtered PSK demodulation
-
-       The input is the complex modulated signal at baseband.
-       The output is a stream of bits packed 1 bit per byte (LSB)
-
-       @param fg: flow graph
-       @type fg: flow graph
-       @param spb: samples per baud >= 2
-       @type spb: float
-       @param excess_bw: Root-raised cosine filter excess bandwidth
-       @type excess_bw: float
-        @param arity: whick PSK: 2, 4, 8
-        @type arity: int in {2, 4, 8}
-        @param diff: differential PSK if true
-        @type diff: bool
-        @param costas_alpha: loop filter gain
-        @type costas_alphas: float
-        @param gain_mu:
-        @type gain_mu: float
-       """
-        if spb < 2:
-            raise TypeError, "sbp must be >= 2"
-        self.spb = spb
-
-        if not arity in (2, 4):
-            raise ValueError, "n must be 2, 4, or 8"
-
-        if not diff:
-            raise NotImplementedError, "mpsk_demod only implements 
differentially encoded PSK"
-
-        bits_per_symbol = int(gru.log2(arity))
-        print "bits_per_symbol =", bits_per_symbol
-
-        # Automatic gain control
-        self.agc = gr.agc_cc(1e-4, 1, 1)
-        
-        # Costas loop (carrier tracking)
-        # FIXME may need different versions for BPSK, QPSK, 8PSK
-        beta = .25 * costas_alpha * costas_alpha
-        self.costas_loop = gr.costas_loop_cc(costas_alpha, beta, 0.05, -0.05, 
0)
-
-        # RRC data filter
-        ntaps = 11 * spb
-        self.rrc_taps = gr.firdes.root_raised_cosine(
-            1.0,                # gain 
-            spb,                # sampling rate
-            1.0,                # symbol rate
-            excess_bw,          # excess bandwidth (roll-off factor)
-            ntaps)
-
-        self.rrc_filter=gr.fir_filter_ccf(1, self.rrc_taps)
-
-        # symbol clock recovery
-        omega = spb
-        #gain_omega = .25 * gain_mu * gain_mu / spb / spb
-        gain_omega = .25 * gain_mu * gain_mu
-        omega_rel_limit = 0.05
-        mu = 0.05
-        self.clock_recovery=gr.clock_recovery_mm_cc(omega, gain_omega,
-                                                    mu, gain_mu, 
omega_rel_limit)
-
-        # find closest constellation point
-        rot = .707 + .707j
-        #rot = 1
-        rotated_const = map(lambda pt: pt * rot, constellation[arity])
-        print "rotated_const =", rotated_const
-
-        self.slicer = gr.constellation_decoder_cb(rotated_const, range(arity))
-        self.diffdec = gr.diff_decoder_bb(arity)
-        self.gray_decoder = gr.map_bb(gray_to_binary[arity])
-        
-        # unpack the k bit vector into a stream of bits
-        self.unpack = gr.unpack_k_bits_bb(bits_per_symbol)
-
-        fg.connect(self.agc, self.costas_loop, self.rrc_filter, 
self.clock_recovery,
-                   self.slicer, self.diffdec, self.gray_decoder, self.unpack)
-        
-        # Debug sinks
-        if 1:
-            fg.connect(self.agc,
-                       gr.file_sink(gr.sizeof_gr_complex, "agc.dat"))
-            fg.connect(self.costas_loop,
-                       gr.file_sink(gr.sizeof_gr_complex, "costas_loop.dat"))
-            fg.connect(self.rrc_filter,
-                       gr.file_sink(gr.sizeof_gr_complex, "rrc.dat"))
-            fg.connect(self.clock_recovery,
-                       gr.file_sink(gr.sizeof_gr_complex, 
"clock_recovery.dat"))
-            fg.connect(self.slicer,
-                       gr.file_sink(gr.sizeof_char, "slicer.dat"))
-            fg.connect(self.diffdec,
-                       gr.file_sink(gr.sizeof_char, "diffdec.dat"))
-            fg.connect(self.unpack,
-                       gr.file_sink(gr.sizeof_char, "unpack.dat"))
-
-        # Initialize base class
-        gr.hier_block.__init__(self, fg, self.agc, self.unpack)
-
-
-
-mpsk_demod = mpsk_demod__coherent_detection_of_differentially_encoded_psk

Index: mpsk_pkt.py
===================================================================
RCS file: mpsk_pkt.py
diff -N mpsk_pkt.py
--- mpsk_pkt.py 7 Jun 2006 02:15:24 -0000       1.4
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,158 +0,0 @@
-#
-# Copyright 2005 Free Software Foundation, Inc.
-# 
-# This file is part of GNU Radio
-# 
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-# 
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING.  If not, write to
-# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-# Boston, MA 02111-1307, USA.
-# 
-
-from math import pi
-import Numeric
-
-from gnuradio import gr, packet_utils
-import gnuradio.gr.gr_threading as _threading
-import mpsk
-
-
-# /////////////////////////////////////////////////////////////////////////////
-#                   xPSK mod/demod with packets as i/o
-# /////////////////////////////////////////////////////////////////////////////
-
-class mpsk_mod_pkts(gr.hier_block):
-    """
-    PSK modulator that is a GNU Radio source.
-
-    Send packets by calling send_pkt
-    """
-    def __init__(self, fg, access_code=None, msgq_limit=2, pad_for_usrp=True,
-                 *args, **kwargs):
-        """
-       Hierarchical block for PSK modulation.
-
-        Packets to be sent are enqueued by calling send_pkt.
-        The output is the complex modulated signal at baseband.
-
-       @param fg: flow graph
-       @type fg: flow graph
-        @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
-
-        See mpsk_mod for remaining parameters
-        """
-        self.pad_for_usrp = pad_for_usrp
-        if access_code is None:
-            access_code = packet_utils.default_access_code
-        if not packet_utils.is_1_0_string(access_code):
-            raise ValueError, "Invalid access_code %r. Must be string of 1's 
and 0's" % (access_code,)
-        self._access_code = access_code
-
-        # accepts messages from the outside world
-        self.pkt_input = gr.message_source(gr.sizeof_char, msgq_limit)
-        self.mpsk_mod = mpsk.mpsk_mod(fg, *args, **kwargs)
-        fg.connect(self.pkt_input, self.mpsk_mod)
-        gr.hier_block.__init__(self, fg, None, self.mpsk_mod)
-
-    def send_pkt(self, payload='', eof=False):
-        """
-        Send the payload.
-
-        @param payload: data to send
-        @type payload: string
-        """
-        if eof:
-            msg = gr.message(1) # tell self.pkt_input we're not sending any 
more packets
-        else:
-            # print "original_payload =", string_to_hex_list(payload)
-            pkt = packet_utils.make_packet(payload,
-                                           self.mpsk_mod.spb,
-                                           self._access_code,
-                                           self.pad_for_usrp)
-            #print "pkt =", string_to_hex_list(pkt)
-            msg = gr.message_from_string(pkt)
-        self.pkt_input.msgq().insert_tail(msg)
-
-
-
-class mpsk_demod_pkts(gr.hier_block):
-    """
-    PSK demodulator that is a GNU Radio sink.
-
-    The input is complex baseband.  When packets are demodulated, they are 
passed to the
-    app via the callback.
-    """
-
-    def __init__(self, fg, access_code=None, callback=None, threshold=-1,
-                 *args, **kwargs):
-        """
-       Hierarchical block for PSK demodulation.
-
-       The input is the complex modulated signal at baseband.
-        Demodulated packets are sent to the handler.
-
-       @param fg: flow graph
-       @type fg: flow graph
-        @param access_code: AKA sync vector
-        @type access_code: string of 1's and 0's between 1 and 64 long
-        @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
-        @type threshold: int
-
-        See mpsk_demod for remaining parameters.
-       """
-
-        if access_code is None:
-            access_code = packet_utils.default_access_code
-        if not packet_utils.is_1_0_string(access_code):
-            raise ValueError, "Invalid access_code %r. Must be string of 1's 
and 0's" % (access_code,)
-        self._access_code = access_code
-
-        if threshold == -1:
-            threshold = 12              # FIXEM raise exception
-
-        self._rcvd_pktq = gr.msg_queue()          # holds packets from the PHY
-
-        self.mpsk_demod = mpsk.mpsk_demod(fg, *args, **kwargs)
-        self.correlator = gr.correlate_access_code_bb(access_code, threshold)
-        self.framer_sink = gr.framer_sink_1(self._rcvd_pktq)
-
-        fg.connect(self.mpsk_demod, self.correlator, self.framer_sink)
-        
-        gr.hier_block.__init__(self, fg, self.mpsk_demod, None)
-        self._watcher = _queue_watcher_thread(self._rcvd_pktq, callback)
-
-
-class _queue_watcher_thread(_threading.Thread):
-    def __init__(self, rcvd_pktq, callback):
-        _threading.Thread.__init__(self)
-        self.setDaemon(1)
-        self.rcvd_pktq = rcvd_pktq
-        self.callback = callback
-        self.keep_running = True
-        self.start()
-
-    #def stop(self):
-    #    self.keep_running = False
-        
-    def run(self):
-        while self.keep_running:
-            msg = self.rcvd_pktq.delete_head()
-            ok, payload = packet_utils.unmake_packet(msg.to_string())
-            if self.callback:
-                self.callback(ok, payload)

Index: mpsk_receive_path.py
===================================================================
RCS file: mpsk_receive_path.py
diff -N mpsk_receive_path.py
--- mpsk_receive_path.py        6 Jun 2006 05:01:22 -0000       1.2
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,127 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2005,2006 Free Software Foundation, Inc.
-# 
-# This file is part of GNU Radio
-# 
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-# 
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING.  If not, write to
-# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-# Boston, MA 02111-1307, USA.
-# 
-
-from gnuradio import gr, gru, blks
-from gnuradio import usrp
-
-# from current dir
-from pick_bitrate import pick_rx_bitrate
-from mpsk_pkt import *
-
-# /////////////////////////////////////////////////////////////////////////////
-#                              receive path
-# /////////////////////////////////////////////////////////////////////////////
-
-class mpsk_receive_path(gr.hier_block):
-    def __init__(self, fg, subdev_spec, bitrate, decim, spb, arity, 
-                 excess_bw, rx_callback, log_p=False):
-
-        gain_mu = 0.03     # default
-        threshold = -1     # use system default
-        
-        self.u = usrp.source_c ()
-        adc_rate = self.u.adc_rate()
-
-        (self._bitrate, self._spb, self._decim) = \
-            pick_rx_bitrate(bitrate, 1, spb, decim, adc_rate)
-
-        self.u.set_decim_rate(self._decim)
-        sw_decim = 1
-
-        if subdev_spec is None:
-            subdev_spec = usrp.pick_rx_subdevice(self.u)
-        self.subdev = usrp.selected_subdev(self.u, subdev_spec)
-        print "Using RX d'board %s" % (self.subdev.side_and_name(),)
-
-        self.u.set_mux(usrp.determine_rx_mux_value(self.u, subdev_spec))
-
-        # receiver
-        self.packet_receiver = \
-          mpsk_demod_pkts(fg, callback=rx_callback, 
-                          excess_bw=excess_bw, diff=True, arity=arity,
-                          costas_alpha=0.005, 
-                          spb=self._spb,
-                          gain_mu=gain_mu,
-                          threshold=threshold)
-
-        fg.connect(self.u, self.packet_receiver)
-        gr.hier_block.__init__(self, fg, None, None)
-
-        g = self.subdev.gain_range()
-        #self.set_gain((g[0] + g[1])/2)        # set gain to midpoint
-        self.set_gain(g[1])                    # set gain to max
-        self.set_auto_tr(True)                 # enable Auto Transmit/Receive 
switching
-
-        if log_p:
-            self._add_logging(fg)
-
-    def set_freq(self, target_freq):
-        """
-        Set the center frequency we're interested in.
-
-        @param target_freq: frequency in Hz
-        @rypte: bool
-
-        Tuning is a two step process.  First we ask the front-end to
-        tune as close to the desired frequency as it can.  Then we use
-        the result of that operation and our target_frequency to
-        determine the value for the digital up converter.  Finally, we could
-        feed any residual_freq to the s/w freq translater.
-        """
-        r = self.u.tune(0, self.subdev, target_freq)
-        if r:
-            # Could use residual_freq in s/w freq translator
-            return True
-
-        return False
-
-    def set_gain(self, gain):
-        if gain is None:
-            r = self.subdev.gain_range()
-            gain = (r[0] + r[1])/2               # set gain to midpoint
-        self.gain = gain
-        return self.subdev.set_gain(gain)
-
-    def set_auto_tr(self, enable):
-        return self.subdev.set_auto_tr(enable)
-        
-    def bitrate(self):
-        return self._bitrate
-
-    def spb(self):
-        return self._spb
-
-    def decim(self):
-        return self._decim
-
-    def carrier_sensed(self):
-        """
-        Return True if we think carrier is present
-        """
-        #return self.packet_receiver.carrier_sensed()
-        return False  # FIXME
-    
-    def _add_logging(self, fg):
-        pass
-        #fg.connect(self.packet_receiver.gmsk_demod.freq_offset,
-        #           gr.file_sink(gr.sizeof_float, "freq_offset.dat"))
-

Index: mpsk_transmit_path.py
===================================================================
RCS file: mpsk_transmit_path.py
diff -N mpsk_transmit_path.py
--- mpsk_transmit_path.py       6 Jun 2006 05:01:22 -0000       1.2
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,105 +0,0 @@
-#
-# Copyright 2005,2006 Free Software Foundation, Inc.
-# 
-# This file is part of GNU Radio
-# 
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-# 
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING.  If not, write to
-# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-# Boston, MA 02111-1307, USA.
-# 
-
-from gnuradio import gr, gru, blks
-from gnuradio import usrp
-from math import log
-
-# from current dir
-from pick_bitrate import pick_tx_bitrate
-from mpsk_pkt import *
-
-# /////////////////////////////////////////////////////////////////////////////
-#                              transmit path
-# /////////////////////////////////////////////////////////////////////////////
-
-class mpsk_transmit_path(gr.hier_block):
-    def __init__(self, fg, subdev_spec, bitrate, interp, spb, arity,
-                 excess_bw, log_p=False):
-
-        self.normal_gain = 8000
-
-        self.u = usrp.sink_c()
-        dac_rate = self.u.dac_rate();
-
-        
-        bits_per_symbol = int(gru.log2(arity))
-
-        (self._bitrate, self._spb, self._interp) = \
-          pick_tx_bitrate(bitrate, bits_per_symbol, spb, interp, dac_rate)
-
-        self.u.set_interp_rate(self._interp)
-
-        # determine the daughterboard subdevice we're using
-        if subdev_spec is None:
-            subdev_spec = usrp.pick_tx_subdevice(self.u)
-        self.subdev = usrp.selected_subdev(self.u, subdev_spec)
-        print "Using TX d'board %s" % (self.subdev.side_and_name(),)
-
-        # transmitter
-        self.packet_transmitter = \
-            mpsk_mod_pkts(fg, spb=self._spb, excess_bw=excess_bw, diff=True,
-                          arity=arity, msgq_limit=2)
-        self.amp = gr.multiply_const_cc (self.normal_gain)
-
-        fg.connect(self.packet_transmitter, self.amp, self.u)
-        gr.hier_block.__init__(self, fg, None, None)
-
-        self.set_gain(self.subdev.gain_range()[1])  # set max Tx gain
-        self.set_auto_tr(True)                      # enable Auto 
Transmit/Receive switching
-
-    def set_freq(self, target_freq):
-        """
-        Set the center frequency we're interested in.
-
-        @param target_freq: frequency in Hz
-        @rypte: bool
-
-        Tuning is a two step process.  First we ask the front-end to
-        tune as close to the desired frequency as it can.  Then we use
-        the result of that operation and our target_frequency to
-        determine the value for the digital up converter.  Finally, we feed
-        any residual_freq to the s/w freq translater.
-        """
-        r = self.u.tune(0, self.subdev, target_freq)
-        if r:
-            return True
-
-        return False
-
-    def set_gain(self, gain):
-        self.gain = gain
-        self.subdev.set_gain(gain)
-
-    def set_auto_tr(self, enable):
-        return self.subdev.set_auto_tr(enable)
-        
-    def send_pkt(self, payload='', eof=False):
-        return self.packet_transmitter.send_pkt(payload, eof)
-        
-    def bitrate(self):
-        return self._bitrate
-
-    def spb(self):
-        return self._spb
-
-    def interp(self):
-        return self._interp

Index: pkt.py
===================================================================
RCS file: pkt.py
diff -N pkt.py
--- pkt.py      28 Jun 2006 18:15:23 -0000      1.1
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,156 +0,0 @@
-#
-# Copyright 2005,2006 Free Software Foundation, Inc.
-# 
-# This file is part of GNU Radio
-# 
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-# 
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING.  If not, write to
-# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-# Boston, MA 02111-1307, USA.
-# 
-
-from math import pi
-import Numeric
-
-from gnuradio import gr, packet_utils
-import gnuradio.gr.gr_threading as _threading
-
-
-# /////////////////////////////////////////////////////////////////////////////
-#                   mod/demod with packets as i/o
-# /////////////////////////////////////////////////////////////////////////////
-
-class mod_pkts(gr.hier_block):
-    """
-    Wrap an arbitrary digital modulator in our packet handling framework.
-
-    Send packets by calling send_pkt
-    """
-    def __init__(self, fg, modulator, access_code=None, msgq_limit=2, 
pad_for_usrp=True):
-        """
-       Hierarchical block for sending packets
-
-        Packets to be sent are enqueued by calling send_pkt.
-        The output is the complex modulated signal at baseband.
-
-       @param fg: flow graph
-       @type fg: flow graph
-        @param modulator: instance of modulator class (gr_block or hier_block)
-        @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
-
-        See gmsk_mod for remaining parameters
-        """
-        self._modulator = modulator
-        self._pad_for_usrp = pad_for_usrp
-
-        if access_code is None:
-            access_code = packet_utils.default_access_code
-        if not packet_utils.is_1_0_string(access_code):
-            raise ValueError, "Invalid access_code %r. Must be string of 1's 
and 0's" % (access_code,)
-        self._access_code = access_code
-
-        # accepts messages from the outside world
-        self._pkt_input = gr.message_source(gr.sizeof_char, msgq_limit)
-        fg.connect(self._pkt_input, self._modulator)
-        gr.hier_block.__init__(self, fg, None, self._modulator)
-
-    def send_pkt(self, payload='', eof=False):
-        """
-        Send the payload.
-
-        @param payload: data to send
-        @type payload: string
-        """
-        if eof:
-            msg = gr.message(1) # tell self._pkt_input we're not sending any 
more packets
-        else:
-            # print "original_payload =", string_to_hex_list(payload)
-            pkt = packet_utils.make_packet(payload,
-                                           self._modulator.samples_per_baud(),
-                                           self._modulator.bits_per_baud(),
-                                           self._access_code,
-                                           self._pad_for_usrp)
-            #print "pkt =", string_to_hex_list(pkt)
-            msg = gr.message_from_string(pkt)
-        self._pkt_input.msgq().insert_tail(msg)
-
-
-
-class demod_pkts(gr.hier_block):
-    """
-    Wrap an arbitrary digital demodulator in our packet handling framework.
-
-    The input is complex baseband.  When packets are demodulated, they are 
passed to the
-    app via the callback.
-    """
-
-    def __init__(self, fg, demodulator, access_code=None, callback=None, 
threshold=-1):
-        """
-       Hierarchical block for demodulating and deframing packets.
-
-       The input is the complex modulated signal at baseband.
-        Demodulated packets are sent to the handler.
-
-       @param fg: flow graph
-       @type fg: flow graph
-        @param demodulator: instance of demodulator class (gr_block or 
hier_block)
-        @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
-       """
-
-        self._demodulator = demodulator
-        if access_code is None:
-            access_code = packet_utils.default_access_code
-        if not packet_utils.is_1_0_string(access_code):
-            raise ValueError, "Invalid access_code %r. Must be string of 1's 
and 0's" % (access_code,)
-        self._access_code = access_code
-
-        if threshold == -1:
-            threshold = 12              # FIXME raise exception
-
-        self._rcvd_pktq = gr.msg_queue()          # holds packets from the PHY
-        self.correlator = gr.correlate_access_code_bb(access_code, threshold)
-
-        self.framer_sink = gr.framer_sink_1(self._rcvd_pktq)
-        fg.connect(self._demodulator, self.correlator, self.framer_sink)
-        
-        gr.hier_block.__init__(self, fg, self._demodulator, None)
-        self._watcher = _queue_watcher_thread(self._rcvd_pktq, callback)
-
-
-class _queue_watcher_thread(_threading.Thread):
-    def __init__(self, rcvd_pktq, callback):
-        _threading.Thread.__init__(self)
-        self.setDaemon(1)
-        self.rcvd_pktq = rcvd_pktq
-        self.callback = callback
-        self.keep_running = True
-        self.start()
-
-
-    def run(self):
-        while self.keep_running:
-            msg = self.rcvd_pktq.delete_head()
-            ok, payload = packet_utils.unmake_packet(msg.to_string())
-            if self.callback:
-                self.callback(ok, payload)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]