commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] [gnuradio] 12/16: qtgui: protect PDU handling waterfal


From: git
Subject: [Commit-gnuradio] [gnuradio] 12/16: qtgui: protect PDU handling waterfall port for wrong data type.
Date: Tue, 21 Jul 2015 19:27:52 +0000 (UTC)

This is an automated email from the git hooks/post-receive script.

trondeau pushed a commit to branch master
in repository gnuradio.

commit 75e5faa73a3ec79a499cf027d68ae0b3cbb6cd6d
Author: Tom Rondeau <address@hidden>
Date:   Mon Jul 20 17:30:03 2015 -0400

    qtgui: protect PDU handling waterfall port for wrong data type.
---
 gr-qtgui/lib/waterfall_sink_c_impl.cc | 15 +++++++++++----
 gr-qtgui/lib/waterfall_sink_c_impl.h  |  4 ++--
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/gr-qtgui/lib/waterfall_sink_c_impl.cc 
b/gr-qtgui/lib/waterfall_sink_c_impl.cc
index 268b013..870b291 100644
--- a/gr-qtgui/lib/waterfall_sink_c_impl.cc
+++ b/gr-qtgui/lib/waterfall_sink_c_impl.cc
@@ -78,10 +78,10 @@ namespace gr {
                       boost::bind(&waterfall_sink_c_impl::handle_set_freq, 
this, _1));
 
 
-      // setup such samples pdu port
+      // setup PDU handling input port
       message_port_register_in(pmt::mp("pdus"));
       set_msg_handler(pmt::mp("pdus"),
-                      boost::bind(&waterfall_sink_c_impl::handle_such_samples, 
this, _1));
+                      boost::bind(&waterfall_sink_c_impl::handle_pdus, this, 
_1));
 
       d_main_gui = NULL;
 
@@ -553,7 +553,7 @@ namespace gr {
     }
 
     void
-    waterfall_sink_c_impl::handle_such_samples(pmt::pmt_t msg)
+    waterfall_sink_c_impl::handle_pdus(pmt::pmt_t msg)
     {
       int j = 0;
       size_t len = 0;
@@ -571,7 +571,14 @@ namespace gr {
 
         gr::high_res_timer_type ref_start = (uint64_t)start * 
(double)(1.0/d_bandwidth) * 1000000;
 
-        const gr_complex *in = (const gr_complex*) 
pmt::c32vector_elements(samples, len);
+        const gr_complex *in;
+        if(pmt::is_c32vector(samples)) {
+          in = (const gr_complex*)pmt::c32vector_elements(samples, len);
+        }
+        else {
+          throw std::runtime_error("waterfall sink: unknown data type of 
samples; must be complex.");
+        }
+
         int stride = (len - d_fftsize)/199;
 
         set_time_per_fft(1.0/d_bandwidth * stride);
diff --git a/gr-qtgui/lib/waterfall_sink_c_impl.h 
b/gr-qtgui/lib/waterfall_sink_c_impl.h
index c243799..5251dfc 100644
--- a/gr-qtgui/lib/waterfall_sink_c_impl.h
+++ b/gr-qtgui/lib/waterfall_sink_c_impl.h
@@ -75,8 +75,8 @@ namespace gr {
       // The message is a PMT pair (intern('freq'), double(frequency)).
       void handle_set_freq(pmt::pmt_t msg);
 
-      // Handles message input port for displaying such samples pdus.
-      void handle_such_samples(pmt::pmt_t msg);
+      // Handles message input port for displaying PDU samples.
+      void handle_pdus(pmt::pmt_t msg);
 
     public:
       waterfall_sink_c_impl(int size, int wintype,



reply via email to

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