aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorVadim Yanitskiy <axilirator@gmail.com>2017-12-01 19:24:14 +0700
committerVadim Yanitskiy <axilirator@gmail.com>2017-12-04 01:48:43 +0700
commit0aafe2856de2286e5b88e43f81785a1aa5284f3f (patch)
tree8594a79d711fda39ba1e294ad75b197d7c65dc15 /lib
parentd222ee58bbc260ea70cc995c70d797768f00f895 (diff)
Implement the 'burst_to_fn_time' block in C++
Diffstat (limited to 'lib')
-rw-r--r--lib/misc_utils/CMakeLists.txt1
-rw-r--r--lib/misc_utils/burst_to_fn_time_impl.cc84
-rw-r--r--lib/misc_utils/burst_to_fn_time_impl.h45
3 files changed, 130 insertions, 0 deletions
diff --git a/lib/misc_utils/CMakeLists.txt b/lib/misc_utils/CMakeLists.txt
index 370f11c..c3edde5 100644
--- a/lib/misc_utils/CMakeLists.txt
+++ b/lib/misc_utils/CMakeLists.txt
@@ -36,5 +36,6 @@ add_sources(
fn_time.cc
udp_socket.cc
trx_burst_if_impl.cc
+ burst_to_fn_time_impl.cc
)
diff --git a/lib/misc_utils/burst_to_fn_time_impl.cc b/lib/misc_utils/burst_to_fn_time_impl.cc
new file mode 100644
index 0000000..3e587f0
--- /dev/null
+++ b/lib/misc_utils/burst_to_fn_time_impl.cc
@@ -0,0 +1,84 @@
+/* -*- c++ -*- */
+/* @file
+ * @author Piotr Krysik <ptrkrysik@gmail.com>
+ * @author Vadim Yanitskiy <axilirator@gmail.com>
+ * @section LICENSE
+ *
+ * Gr-gsm 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 3, or (at your option)
+ * any later version.
+ *
+ * Gr-gsm 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 gr-gsm; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gnuradio/io_signature.h>
+#include "burst_to_fn_time_impl.h"
+
+namespace gr {
+ namespace gsm {
+
+ burst_to_fn_time::sptr
+ burst_to_fn_time::make(void)
+ {
+ return gnuradio::get_initial_sptr
+ (new burst_to_fn_time_impl());
+ }
+
+ /*
+ * The private constructor
+ */
+ burst_to_fn_time_impl::burst_to_fn_time_impl(void)
+ : gr::block("burst_to_fn_time",
+ gr::io_signature::make(0, 0, 0),
+ gr::io_signature::make(0, 0, 0))
+ {
+ // Register I/O ports
+ message_port_register_in(pmt::mp("bursts_in"));
+ message_port_register_out(pmt::mp("fn_time_out"));
+
+ // Bind a port handler
+ set_msg_handler(pmt::mp("bursts_in"),
+ boost::bind(&burst_to_fn_time_impl::handle_burst, this, _1));
+ }
+
+ /*
+ * Our virtual destructor.
+ */
+ burst_to_fn_time_impl::~burst_to_fn_time_impl()
+ {
+ }
+
+ void
+ burst_to_fn_time_impl::handle_burst(pmt::pmt_t msg_in)
+ {
+ // Obtain fn_time tag from message
+ pmt::pmt_t blob = pmt::car(msg_in);
+ pmt::pmt_t fn_time = pmt::dict_ref(blob,
+ pmt::intern("fn_time"), pmt::PMT_NIL);
+
+ // Drop messages without required tag
+ if (fn_time == pmt::PMT_NIL)
+ return;
+
+ // Compose and send a new message
+ pmt::pmt_t msg_out = pmt::dict_add(pmt::make_dict(),
+ pmt::intern("fn_time"), fn_time);
+ message_port_pub(pmt::mp("fn_time_out"), msg_out);
+ }
+
+ } /* namespace gsm */
+} /* namespace gr */
diff --git a/lib/misc_utils/burst_to_fn_time_impl.h b/lib/misc_utils/burst_to_fn_time_impl.h
new file mode 100644
index 0000000..e96c2bb
--- /dev/null
+++ b/lib/misc_utils/burst_to_fn_time_impl.h
@@ -0,0 +1,45 @@
+/* -*- c++ -*- */
+/* @file
+ * @author Piotr Krysik <ptrkrysik@gmail.com>
+ * @author Vadim Yanitskiy <axilirator@gmail.com>
+ * @section LICENSE
+ *
+ * Gr-gsm 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 3, or (at your option)
+ * any later version.
+ *
+ * Gr-gsm 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 gr-gsm; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef INCLUDED_GRGSM_BURST_TO_FN_TIME_IMPL_H
+#define INCLUDED_GRGSM_BURST_TO_FN_TIME_IMPL_H
+
+#include <grgsm/misc_utils/burst_to_fn_time.h>
+
+namespace gr {
+ namespace gsm {
+
+ class burst_to_fn_time_impl : public burst_to_fn_time
+ {
+ private:
+ void handle_burst(pmt::pmt_t msg_in);
+
+ public:
+ burst_to_fn_time_impl(void);
+ ~burst_to_fn_time_impl(void);
+ };
+
+ } // namespace gsm
+} // namespace gr
+
+#endif /* INCLUDED_GRGSM_BURST_TO_FN_TIME_IMPL_H */