aboutsummaryrefslogtreecommitdiffstats
path: root/python/misc_utils
diff options
context:
space:
mode:
authorPiotr Krysik <ptrkrysik@gmail.com>2017-11-08 14:34:02 +0100
committerPiotr Krysik <ptrkrysik@gmail.com>2017-11-08 14:34:02 +0100
commit8d7b64d109c1b11aaea963092303b13098520c1d (patch)
tree5c25961d5856a8b28f6d2bacb4fc48bc2db38703 /python/misc_utils
parent52f7416b3f46f49e805a38fd5dda2340e504028e (diff)
Added Python version of bursts to fn_time converter
Diffstat (limited to 'python/misc_utils')
-rw-r--r--python/misc_utils/CMakeLists.txt1
-rw-r--r--python/misc_utils/burst_to_fn_time.py28
2 files changed, 29 insertions, 0 deletions
diff --git a/python/misc_utils/CMakeLists.txt b/python/misc_utils/CMakeLists.txt
index ec732a4..8c7c175 100644
--- a/python/misc_utils/CMakeLists.txt
+++ b/python/misc_utils/CMakeLists.txt
@@ -23,5 +23,6 @@ GR_PYTHON_INSTALL(
clock_offset_corrector_tagged.py
hier_block.py
fn_time.py
+ burst_to_fn_time.py
DESTINATION ${GR_PYTHON_DIR}/grgsm
)
diff --git a/python/misc_utils/burst_to_fn_time.py b/python/misc_utils/burst_to_fn_time.py
new file mode 100644
index 0000000..e31cf92
--- /dev/null
+++ b/python/misc_utils/burst_to_fn_time.py
@@ -0,0 +1,28 @@
+"""
+Embedded Python Blocks:
+
+Each this file is saved, GRC will instantiate the first class it finds to get
+ports and parameters of your block. The arguments to __init__ will be the
+parameters. All of them are required to have default values!
+"""
+import numpy as np
+from gnuradio import gr
+import pmt
+
+class burst_to_fn_time(gr.basic_block):
+ def __init__(self): # only default arguments here
+ gr.basic_block.__init__(
+ self,
+ name='Burst to fn_time',
+ in_sig=[],
+ out_sig=[]
+ )
+ self.message_port_register_in(pmt.intern("bursts_in"))
+ self.message_port_register_out(pmt.intern("fn_time_out"))
+ self.set_msg_handler(pmt.intern("bursts_in"), self.convert)
+
+ def convert(self, msg):
+ fn_time = pmt.dict_ref(pmt.car(msg),pmt.intern("fn_time"),pmt.PMT_NIL)
+ fn_time_msg = pmt.dict_add(pmt.make_dict(), pmt.intern("fn_time"), fn_time)
+ if pmt.to_python(fn_time) is not None:
+ self.message_port_pub(pmt.intern("fn_time_out"), fn_time_msg)