[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 07/12: runtime: Added packet_utils and mark
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 07/12: runtime: Added packet_utils and marked tagged_streams.py for removal in future |
Date: |
Fri, 23 May 2014 17:35:56 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
jcorgan pushed a commit to branch master
in repository gnuradio.
commit f21fee1fa80692a3ee3cfcba2b811fff4d405677
Author: Martin Braun <address@hidden>
Date: Sun May 18 18:10:13 2014 +0200
runtime: Added packet_utils and marked tagged_streams.py for removal in
future
---
gnuradio-runtime/python/gnuradio/gr/CMakeLists.txt | 1 +
.../python/gnuradio/gr/packet_utils.py | 32 ++++++++++++----------
gr-digital/python/digital/utils/tagged_streams.py | 2 ++
3 files changed, 21 insertions(+), 14 deletions(-)
diff --git a/gnuradio-runtime/python/gnuradio/gr/CMakeLists.txt
b/gnuradio-runtime/python/gnuradio/gr/CMakeLists.txt
index 9d6f4dd..ddad2c4 100644
--- a/gnuradio-runtime/python/gnuradio/gr/CMakeLists.txt
+++ b/gnuradio-runtime/python/gnuradio/gr/CMakeLists.txt
@@ -23,6 +23,7 @@ include(GrPython)
GR_PYTHON_INSTALL(FILES
__init__.py
tag_utils.py
+ packet_utils.py
gateway.py
gr_threading.py
gr_threading_23.py
diff --git a/gr-digital/python/digital/utils/tagged_streams.py
b/gnuradio-runtime/python/gnuradio/gr/packet_utils.py
similarity index 80%
copy from gr-digital/python/digital/utils/tagged_streams.py
copy to gnuradio-runtime/python/gnuradio/gr/packet_utils.py
index c7edbf6..7ae42e8 100644
--- a/gr-digital/python/digital/utils/tagged_streams.py
+++ b/gnuradio-runtime/python/gnuradio/gr/packet_utils.py
@@ -40,9 +40,9 @@ def string_to_vector(string):
v.append(ord(s))
return v
-def strings_to_vectors(strings, lengthtagname):
+def strings_to_vectors(strings, tsb_tag_key):
vs = [string_to_vector(string) for string in strings]
- return packets_to_vectors(vs, lengthtagname)
+ return packets_to_vectors(vs, tsb_tag_key)
def vector_to_string(v):
s = []
@@ -50,19 +50,19 @@ def vector_to_string(v):
s.append(chr(d))
return ''.join(s)
-def vectors_to_strings(data, tags, lengthtagname):
- packets = vectors_to_packets(data, tags, lengthtagname)
+def vectors_to_strings(data, tags, tsb_tag_key):
+ packets = vectors_to_packets(data, tags, tsb_tag_key)
return [vector_to_string(packet) for packet in packets]
-def count_bursts(data, tags, lengthtagname, vlen=1):
+def count_bursts(data, tags, tsb_tag_key, vlen=1):
lengthtags = [t for t in tags
- if pmt.symbol_to_string(t.key) == lengthtagname]
+ if pmt.symbol_to_string(t.key) == tsb_tag_key]
lengths = {}
for tag in lengthtags:
if tag.offset in lengths:
raise ValueError(
"More than one tags with key {0} with the same offset={1}."
- .format(lengthtagname, tag.offset))
+ .format(tsb_tag_key, tag.offset))
lengths[tag.offset] = pmt.to_long(tag.value)*vlen
in_burst = False
in_packet = False
@@ -89,26 +89,26 @@ def count_bursts(data, tags, lengthtagname, vlen=1):
packet_pos = None
return burst_count
-def vectors_to_packets(data, tags, lengthtagname, vlen=1):
+def vectors_to_packets(data, tags, tsb_tag_key, vlen=1):
lengthtags = [t for t in tags
- if pmt.symbol_to_string(t.key) == lengthtagname]
+ if pmt.symbol_to_string(t.key) == tsb_tag_key]
lengths = {}
for tag in lengthtags:
if tag.offset in lengths:
raise ValueError(
"More than one tags with key {0} with the same offset={1}."
- .format(lengthtagname, tag.offset))
+ .format(tsb_tag_key, tag.offset))
lengths[tag.offset] = pmt.to_long(tag.value)*vlen
if 0 not in lengths:
raise ValueError("There is no tag with key {0} and an offset of 0"
- .format(lengthtagname))
+ .format(tsb_tag_key))
pos = 0
packets = []
while pos < len(data):
if pos not in lengths:
raise ValueError("There is no tag with key {0} and an offset of
{1}."
"We were expecting one."
- .format(lengthtagname, pos))
+ .format(tsb_tag_key, pos))
length = lengths[pos]
if length == 0:
raise ValueError("Packets cannot have zero length.")
@@ -118,7 +118,10 @@ def vectors_to_packets(data, tags, lengthtagname, vlen=1):
pos += length
return packets
-def packets_to_vectors(packets, lengthtagname, vlen=1):
+def packets_to_vectors(packets, tsb_tag_key, vlen=1):
+ """ Returns a single data vector and a set of tags.
+ If used with blocks.vector_source_X, this set of data
+ and tags will produced a correct tagged stream. """
tags = []
data = []
offset = 0
@@ -126,8 +129,9 @@ def packets_to_vectors(packets, lengthtagname, vlen=1):
data.extend(packet)
tag = gr.tag_t()
tag.offset = offset/vlen
- tag.key = pmt.string_to_symbol(lengthtagname)
+ tag.key = pmt.string_to_symbol(tsb_tag_key)
tag.value = pmt.from_long(len(packet)/vlen)
tags.append(tag)
offset = offset + len(packet)
return data, tags
+
diff --git a/gr-digital/python/digital/utils/tagged_streams.py
b/gr-digital/python/digital/utils/tagged_streams.py
index c7edbf6..4b393bf 100644
--- a/gr-digital/python/digital/utils/tagged_streams.py
+++ b/gr-digital/python/digital/utils/tagged_streams.py
@@ -20,6 +20,8 @@
# Boston, MA 02110-1301, USA.
#
+# DEPRECATED -- Marked for removal in 3.8
+
from gnuradio import gr
import pmt
- [Commit-gnuradio] [gnuradio] branch master updated (cba2d18 -> 5cb67ce), git, 2014/05/23
- [Commit-gnuradio] [gnuradio] 10/12: Merge branch 'maint', git, 2014/05/23
- [Commit-gnuradio] [gnuradio] 04/12: blocks: Added tsb_vector_sinks, git, 2014/05/23
- [Commit-gnuradio] [gnuradio] 07/12: runtime: Added packet_utils and marked tagged_streams.py for removal in future,
git <=
- [Commit-gnuradio] [gnuradio] 05/12: blocks: updated some QAs to use proper tsb functions, git, 2014/05/23
- [Commit-gnuradio] [gnuradio] 06/12: digital: updated some QAs to use proper tsb functions, git, 2014/05/23
- [Commit-gnuradio] [gnuradio] 11/12: Merge remote-tracking branch 'martin/tsb/prep_for_38', git, 2014/05/23
- [Commit-gnuradio] [gnuradio] 08/12: uhd: Nicer labels for device args and addres in GRC, git, 2014/05/23
- [Commit-gnuradio] [gnuradio] 09/12: Merge branch 'uint64_sugar' of git://github.com/osh/gnuradio, git, 2014/05/23
- [Commit-gnuradio] [gnuradio] 02/12: pmt: support conversion of basic pmt pairs to python, git, 2014/05/23
- [Commit-gnuradio] [gnuradio] 01/12: pmt: adding uint64 sugar, git, 2014/05/23
- [Commit-gnuradio] [gnuradio] 03/12: pmt: making uint64_t sugar more friendly, git, 2014/05/23
- [Commit-gnuradio] [gnuradio] 12/12: Merge remote-tracking branch 'martin/uhd/clearer_grc_args', git, 2014/05/23