From 3583952a5c0a1f20e4f87dd3cb9e84ff38613e0d Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Mon, 3 Oct 2016 11:42:54 +0200 Subject: [PATCH] Closing queues and improving TTFF report --- src/tests/system-tests/ttff_gps_l1.cc | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/tests/system-tests/ttff_gps_l1.cc b/src/tests/system-tests/ttff_gps_l1.cc index 1c59fd7ce..19b5402f0 100644 --- a/src/tests/system-tests/ttff_gps_l1.cc +++ b/src/tests/system-tests/ttff_gps_l1.cc @@ -30,6 +30,7 @@ * ------------------------------------------------------------------------- */ +#include #include #include #include @@ -251,11 +252,11 @@ void receive_msg() double ttff_msg = 0.0; int msgrcv_size = sizeof(msg.ttff); int msqid; - int msqid_stop; + int msqid_stop = -1; key_t key = 1101; key_t key_stop = 1102; // wait for the queue to be created - while((msqid = msgget(key, 0644)) == -1){} + if((msqid = msgget(key, 0644)) == -1){} if (msgrcv(msqid, &msg, msgrcv_size, 1, 0) != -1) { @@ -265,7 +266,7 @@ void receive_msg() TTFF_v.push_back(ttff_msg / (1000.0 / decimation_factor) ); LOG(INFO) << "Valid Time-To-First-Fix: " << ttff_msg / (1000.0 / decimation_factor ) << "[s]"; // Stop the receiver - while((msqid_stop = msgget(key_stop, 0644)) == -1){} + while((msqid_stop = msgget(key_stop, 0644 | IPC_CREAT))) == -1){} double msgsend_size = sizeof(msg_stop.ttff); msgsnd(msqid_stop, &msg_stop, msgsend_size, IPC_NOWAIT); } @@ -274,6 +275,10 @@ void receive_msg() { receive_msg(); } + else + { + if(msqid_stop != -1) msgctl(msqid_stop, IPC_RMID, NULL); + } } return; } @@ -325,6 +330,15 @@ void TTFF_GPS_L1_CA_Test::print_TTFF_report(const std::vector & ttff_v, std::cout << "TTFF stdev: " << stdev << " [s]" << std::endl; std::cout << "Operating System: " << std::string(HOST_SYSTEM) << std::endl; std::cout << "Navigation mode: " << "3D" << std::endl; + std::string source = config_->property("SignalSource.implementation", ""); + if(source.compare("UHD_Signal_Source")) + { + std::cout << "Source: File" << std::endl; + } + else + { + std::cout << "Source: Live" << std::endl; + } std::cout << "---------------------------" << std::endl; } @@ -501,6 +515,7 @@ int main(int argc, char **argv) msgsend_size = sizeof(msg.ttff); msgsnd(sysv_msqid, &msg, msgsend_size, IPC_NOWAIT); receive_msg_thread.join(); + msgctl(sysv_msqid, IPC_RMID, NULL); google::ShutDownCommandLineFlags(); return res; }