[hamradio-commits] [gnss-sdr] 60/303: Add a queue listener to the control thread

Carles Fernandez carles_fernandez-guest at moszumanska.debian.org
Mon Feb 13 22:35:48 UTC 2017


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

carles_fernandez-guest pushed a commit to branch master
in repository gnss-sdr.

commit 32445c986479bc39dd0366f2e44d98b67f83cb06
Author: Carles Fernandez <carles.fernandez at gmail.com>
Date:   Sat Oct 1 17:32:38 2016 +0200

    Add a queue listener to the control thread
---
 src/core/receiver/control_thread.cc | 40 +++++++++++++++++++++++++++++++++++++
 src/core/receiver/control_thread.h  |  2 ++
 2 files changed, 42 insertions(+)

diff --git a/src/core/receiver/control_thread.cc b/src/core/receiver/control_thread.cc
index ac7f9de..c691688 100644
--- a/src/core/receiver/control_thread.cc
+++ b/src/core/receiver/control_thread.cc
@@ -37,6 +37,9 @@
 #include <iostream>
 #include <map>
 #include <string>
+#include <sys/types.h>
+#include <sys/ipc.h>
+#include <sys/msg.h>
 #include <boost/lexical_cast.hpp>
 #include <boost/chrono.hpp>
 #include <gnuradio/message.h>
@@ -126,6 +129,7 @@ void ControlThread::run()
     assist_GNSS();
     // start the keyboard_listener thread
     keyboard_thread_ = boost::thread(&ControlThread::keyboard_listener, this);
+    sysv_queue_thread_ = boost::thread(&ControlThread::sysv_queue_listener, this);
 
     // Main loop to read and process the control messages
     while (flowgraph_->running() && !stop_)
@@ -141,9 +145,11 @@ void ControlThread::run()
     //Join keyboard thread
 #ifdef OLD_BOOST
     keyboard_thread_.timed_join(boost::posix_time::seconds(1));
+    sysv_queue_thread_.timed_join(boost::posix_time::seconds(1));
 #endif
 #ifndef OLD_BOOST
     keyboard_thread_.try_join_until(boost::chrono::steady_clock::now() + boost::chrono::milliseconds(1000));
+    sysv_queue_thread_.try_join_until(boost::chrono::steady_clock::now() + boost::chrono::milliseconds(1000));
 #endif
 
     LOG(INFO) << "Flowgraph stopped";
@@ -510,6 +516,40 @@ void ControlThread::gps_acq_assist_data_collector()
         }
 }
 
+void ControlThread::sysv_queue_listener()
+{
+    typedef struct  {
+        long mtype; //required by sys v message
+        double ttff;
+    } ttff_msgbuf;
+    bool read_queue = true;
+    ttff_msgbuf msg;
+    double ttff_msg = 0.0;
+    int msgrcv_size = sizeof(msg.ttff);
+    int msqid;
+    key_t key = 1102;
+    // wait for the queue to be created
+    while((msqid = msgget(key, 0644)) == -1){}
+    while(read_queue)
+        {
+            if (msgrcv(msqid, &msg, msgrcv_size, 1, 0) != -1)
+                {
+
+                    ttff_msg = msg.ttff;
+                    if(ttff_msg == 200)
+                        {
+                            std::cout << "Quit order received, stopping GNSS-SDR !!" << std::endl;
+                            std::unique_ptr<ControlMessageFactory> cmf(new ControlMessageFactory());
+                            if (control_queue_ != gr::msg_queue::sptr())
+                                {
+                                    control_queue_->handle(cmf->GetQueueMessage(200, 0));
+                                }
+                            read_queue = false;
+                        }
+                }
+        }
+}
+
 
 void ControlThread::keyboard_listener()
 {
diff --git a/src/core/receiver/control_thread.h b/src/core/receiver/control_thread.h
index 5d893c9..b44a818 100644
--- a/src/core/receiver/control_thread.h
+++ b/src/core/receiver/control_thread.h
@@ -155,9 +155,11 @@ private:
     unsigned int processed_control_messages_;
     unsigned int applied_actions_;
     boost::thread keyboard_thread_;
+    boost::thread sysv_queue_thread_;
     boost::thread gps_acq_assist_data_collector_thread_;
     
     void keyboard_listener();
+    void sysv_queue_listener();
 
     // default filename for assistance data
     const std::string eph_default_xml_filename = "./gps_ephemeris.xml";

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-hamradio/gnss-sdr.git



More information about the pkg-hamradio-commits mailing list