[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] gnuradio-core ChangeLog src/python/gnuradio/pac...
From: |
Eric Blossom |
Subject: |
[Commit-gnuradio] gnuradio-core ChangeLog src/python/gnuradio/pac... |
Date: |
Tue, 20 Jun 2006 22:24:32 +0000 |
CVSROOT: /sources/gnuradio
Module name: gnuradio-core
Changes by: Eric Blossom <eb> 06/06/20 22:24:32
Modified files:
. : ChangeLog
src/python/gnuradio: packet_utils.py
src/python/gnuradio/blksimpl: Makefile.am gmsk2.py gmsk2_pkt.py
Added files:
src/python/gnuradio/blksimpl: pkt.py
Log message:
Refactored gmsk2_pkt.py into modulation independent pkt.py.
gmsk2_mod_pkts and gmsk2_demod_pkts are now deprecated.
Added new arg to make_packet to support bits_per_baud > 1.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnuradio-core/ChangeLog?cvsroot=gnuradio&r1=1.238&r2=1.239
http://cvs.savannah.gnu.org/viewcvs/gnuradio-core/src/python/gnuradio/packet_utils.py?cvsroot=gnuradio&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/gnuradio-core/src/python/gnuradio/blksimpl/Makefile.am?cvsroot=gnuradio&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/gnuradio-core/src/python/gnuradio/blksimpl/gmsk2.py?cvsroot=gnuradio&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/gnuradio-core/src/python/gnuradio/blksimpl/gmsk2_pkt.py?cvsroot=gnuradio&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/gnuradio-core/src/python/gnuradio/blksimpl/pkt.py?cvsroot=gnuradio&rev=1.1
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnuradio/gnuradio-core/ChangeLog,v
retrieving revision 1.238
retrieving revision 1.239
diff -u -b -r1.238 -r1.239
--- ChangeLog 17 Jun 2006 19:28:09 -0000 1.238
+++ ChangeLog 20 Jun 2006 22:24:31 -0000 1.239
@@ -1,3 +1,14 @@
+2006-06-20 Eric Blossom <address@hidden>
+
+ * src/python/gnuradio/blksimpl/pkt.py: result of refactoring
+ gmsk2_pkt.py. This is the common packet handling framework, and
+ is modulation independent. gmsk2_pkt is now deprecated.
+
+ * src/python/gnuradio/blksimpl/gmsk2_pkt.py: added deprecation warning.
+
+ * src/python/gnuradio/packet_utils.py (make_packet): added
+ bits_per_baud parameter to handle QPSK, etc in the future.
+
2006-06-17 Eric Blossom <address@hidden>
* src/lib/runtime/gr_realtime.{h,cc,i}: new function to enable
@@ -1817,7 +1828,7 @@
This code was derived from gnuradio-0.9 with a massive amount of hacking.
#
-# Copyright 2001,2002,2003,2004,2005 Free Software Foundation, Inc.
+# Copyright 2001,2002,2003,2004,2005,2006 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
Index: src/python/gnuradio/packet_utils.py
===================================================================
RCS file: /sources/gnuradio/gnuradio-core/src/python/gnuradio/packet_utils.py,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- src/python/gnuradio/packet_utils.py 6 Jun 2006 01:25:07 -0000 1.8
+++ src/python/gnuradio/packet_utils.py 20 Jun 2006 22:24:32 -0000 1.9
@@ -97,13 +97,15 @@
def make_header(payload_len):
return struct.pack('!HH', payload_len, payload_len)
-def make_packet(payload, spb, access_code=default_access_code,
pad_for_usrp=True):
+def make_packet(payload, spb, bits_per_baud, access_code=default_access_code,
pad_for_usrp=True):
"""
Build a packet, given access code and payload.
- @param payload: packet payload, len [0, 1500]
+ @param payload: packet payload, len [0, 4096]
@param spb: samples per baud (needed for padding calculation)
@type spb: int
+ @param bits_per_baud: (needed for padding calculation)
+ @type bits_per_baud: int
@param access_code: string of ascii 0's and 1's
Packet will have access code at the beginning, followed by length, payload
@@ -112,6 +114,9 @@
if not is_1_0_string(access_code):
raise ValueError, "access_code must be a string containing only 0's
and 1's (%r)" % (access_code,)
+ if bits_per_baud != 1:
+ raise NotImplemented, "bits_per_baud currently must == 1. Please fix
this."
+
(packed_access_code, padded) =
conv_1_0_string_to_packed_binary_string(access_code)
payload_with_crc = gru.gen_and_append_crc32(payload)
Index: src/python/gnuradio/blksimpl/Makefile.am
===================================================================
RCS file:
/sources/gnuradio/gnuradio-core/src/python/gnuradio/blksimpl/Makefile.am,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- src/python/gnuradio/blksimpl/Makefile.am 14 Nov 2005 05:00:02 -0000
1.11
+++ src/python/gnuradio/blksimpl/Makefile.am 20 Jun 2006 22:24:32 -0000
1.12
@@ -35,6 +35,7 @@
gmsk2_pkt.py \
nbfm_rx.py \
nbfm_tx.py \
+ pkt.py \
rational_resampler.py \
standard_squelch.py \
wfm_rcv.py \
Index: src/python/gnuradio/blksimpl/gmsk2.py
===================================================================
RCS file:
/sources/gnuradio/gnuradio-core/src/python/gnuradio/blksimpl/gmsk2.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- src/python/gnuradio/blksimpl/gmsk2.py 20 Jun 2006 20:06:05 -0000
1.6
+++ src/python/gnuradio/blksimpl/gmsk2.py 20 Jun 2006 22:24:32 -0000
1.7
@@ -73,7 +73,6 @@
self.taps =
Numeric.convolve(Numeric.array(self.gaussian_taps),Numeric.array(self.sqwave))
self.gaussian_filter = gr.interp_fir_filter_fff(spb, self.taps)
-
# FM modulation
self.fmmod = gr.frequency_modulator_fc(sensitivity)
@@ -83,10 +82,17 @@
# Initialize base class
gr.hier_block.__init__(self, fg, self.nrz, self.fmmod)
+ def samples_per_baud(self):
+ return self.spb
+
+ def bits_per_baud(self=None): # staticmethod that's also callable on an
instance
+ return 1
+ bits_per_baud = staticmethod(bits_per_baud) # make it a static
method. RTFM
+
class gmsk2_demod(gr.hier_block):
- def __init__(self, fg, spb = 2, omega=None, gain_mu=0.03, mu=0.5,
+ def __init__(self, fg, spb=2, omega=None, gain_mu=0.03, mu=0.5,
omega_relative_limit=0.000200, freq_error=0.0):
"""
Hierarchical block for Gaussian Minimum Shift Key (GMSK)
@@ -136,11 +142,14 @@
# slice the floats at 0, outputting 1 bit (the LSB of the output byte)
per sample
self.slicer = gr.binary_slicer_fb()
- #fg.connect(self.sub, self.clock_recovery, self.slicer)
fg.connect(self.fmdemod, self.clock_recovery, self.slicer)
- if 0:
- fg.connect(self.fmdemod, gr.file_sink(gr.sizeof_float,
'demod.dat'))
-
# Initialize base class
gr.hier_block.__init__(self, fg, self.fmdemod, self.slicer)
+
+ def samples_per_baud(self):
+ return self.spb
+
+ def bits_per_baud(self=None): # staticmethod that's also callable on an
instance
+ return 1
+ bits_per_baud = staticmethod(bits_per_baud) # make it a static
method. RTFM
Index: src/python/gnuradio/blksimpl/gmsk2_pkt.py
===================================================================
RCS file:
/sources/gnuradio/gnuradio-core/src/python/gnuradio/blksimpl/gmsk2_pkt.py,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- src/python/gnuradio/blksimpl/gmsk2_pkt.py 31 May 2006 14:10:39 -0000
1.9
+++ src/python/gnuradio/blksimpl/gmsk2_pkt.py 20 Jun 2006 22:24:32 -0000
1.10
@@ -27,6 +27,13 @@
import gmsk2
+def _deprecation_warning(old_name, new_name):
+ print "#"
+ print '#'
+ print '# Warning: %s is deprecated and will be removed soon.' %
(old_name,)
+ print '# Please use the modulation independent block, %s.' %
(new_name,)
+
+
# /////////////////////////////////////////////////////////////////////////////
# GMSK mod/demod with packets as i/o
# /////////////////////////////////////////////////////////////////////////////
@@ -54,6 +61,8 @@
See gmsk_mod for remaining parameters
"""
+ _deprecation_warning('gmsk2_mod_pkts', 'mod_pkts')
+
self.pad_for_usrp = pad_for_usrp
if access_code is None:
access_code = packet_utils.default_access_code
@@ -79,7 +88,8 @@
else:
# print "original_payload =", string_to_hex_list(payload)
pkt = packet_utils.make_packet(payload,
- self.gmsk_mod.spb,
+ self.gmsk_mod.samples_per_baud(),
+ self.gmsk_mod.bits_per_baud(),
self._access_code,
self.pad_for_usrp)
#print "pkt =", string_to_hex_list(pkt)
@@ -116,6 +126,8 @@
See gmsk_demod for remaining parameters.
"""
+ _deprecation_warning('gmsk2_demod_pkts', 'demod_pkts')
+
if access_code is None:
access_code = packet_utils.default_access_code
if not packet_utils.is_1_0_string(access_code):
Index: src/python/gnuradio/blksimpl/pkt.py
===================================================================
RCS file: src/python/gnuradio/blksimpl/pkt.py
diff -N src/python/gnuradio/blksimpl/pkt.py
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/python/gnuradio/blksimpl/pkt.py 20 Jun 2006 22:24:32 -0000 1.1
@@ -0,0 +1,156 @@
+#
+# 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)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] gnuradio-core ChangeLog src/python/gnuradio/pac...,
Eric Blossom <=