mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2025-01-12 02:10:34 +00:00
Improve queue management gnss-sdr and in TTFF tests.
Always destroy queues when exiting
This commit is contained in:
parent
047ced2b20
commit
08f0a36075
@ -213,7 +213,9 @@ galileo_e1_pvt_cc::galileo_e1_pvt_cc(unsigned int nchannels, bool dump, std::str
|
|||||||
|
|
||||||
|
|
||||||
galileo_e1_pvt_cc::~galileo_e1_pvt_cc()
|
galileo_e1_pvt_cc::~galileo_e1_pvt_cc()
|
||||||
{}
|
{
|
||||||
|
msgctl(sysv_msqid, IPC_RMID, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -313,7 +313,9 @@ gps_l1_ca_pvt_cc::gps_l1_ca_pvt_cc(unsigned int nchannels,
|
|||||||
|
|
||||||
|
|
||||||
gps_l1_ca_pvt_cc::~gps_l1_ca_pvt_cc()
|
gps_l1_ca_pvt_cc::~gps_l1_ca_pvt_cc()
|
||||||
{}
|
{
|
||||||
|
msgctl(sysv_msqid, IPC_RMID, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool pseudoranges_pairCompare_min(const std::pair<int,Gnss_Synchro>& a, const std::pair<int,Gnss_Synchro>& b)
|
bool pseudoranges_pairCompare_min(const std::pair<int,Gnss_Synchro>& a, const std::pair<int,Gnss_Synchro>& b)
|
||||||
|
@ -290,7 +290,9 @@ hybrid_pvt_cc::hybrid_pvt_cc(unsigned int nchannels, bool dump, std::string dump
|
|||||||
|
|
||||||
|
|
||||||
hybrid_pvt_cc::~hybrid_pvt_cc()
|
hybrid_pvt_cc::~hybrid_pvt_cc()
|
||||||
{}
|
{
|
||||||
|
msgctl(sysv_msqid, IPC_RMID, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -90,6 +90,7 @@ ControlThread::~ControlThread()
|
|||||||
{
|
{
|
||||||
// save navigation data to files
|
// save navigation data to files
|
||||||
// if (save_assistance_to_XML() == true) {}
|
// if (save_assistance_to_XML() == true) {}
|
||||||
|
if(msgiq != -1) msgctl(msqid, IPC_RMID, NULL);;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -431,6 +432,7 @@ void ControlThread::init()
|
|||||||
supl_mns = 0;
|
supl_mns = 0;
|
||||||
supl_lac = 0;
|
supl_lac = 0;
|
||||||
supl_ci = 0;
|
supl_ci = 0;
|
||||||
|
msqid = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -528,7 +530,7 @@ void ControlThread::sysv_queue_listener()
|
|||||||
ttff_msgbuf msg;
|
ttff_msgbuf msg;
|
||||||
double ttff_msg = 0.0;
|
double ttff_msg = 0.0;
|
||||||
int msgrcv_size = sizeof(msg.ttff);
|
int msgrcv_size = sizeof(msg.ttff);
|
||||||
int msqid;
|
|
||||||
key_t key = 1102;
|
key_t key = 1102;
|
||||||
|
|
||||||
if((msqid = msgget(key, 0644 | IPC_CREAT )) == -1)
|
if((msqid = msgget(key, 0644 | IPC_CREAT )) == -1)
|
||||||
@ -552,9 +554,7 @@ void ControlThread::sysv_queue_listener()
|
|||||||
read_queue = false;
|
read_queue = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
usleep(1000000);
|
|
||||||
}
|
}
|
||||||
msgctl(msqid, IPC_RMID, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -143,7 +143,6 @@ private:
|
|||||||
*/
|
*/
|
||||||
void assist_GNSS();
|
void assist_GNSS();
|
||||||
|
|
||||||
|
|
||||||
void apply_action(unsigned int what);
|
void apply_action(unsigned int what);
|
||||||
std::shared_ptr<GNSSFlowgraph> flowgraph_;
|
std::shared_ptr<GNSSFlowgraph> flowgraph_;
|
||||||
std::shared_ptr<ConfigurationInterface> configuration_;
|
std::shared_ptr<ConfigurationInterface> configuration_;
|
||||||
@ -160,6 +159,7 @@ private:
|
|||||||
|
|
||||||
void keyboard_listener();
|
void keyboard_listener();
|
||||||
void sysv_queue_listener();
|
void sysv_queue_listener();
|
||||||
|
int msqid;
|
||||||
|
|
||||||
// default filename for assistance data
|
// default filename for assistance data
|
||||||
const std::string eph_default_xml_filename = "./gps_ephemeris.xml";
|
const std::string eph_default_xml_filename = "./gps_ephemeris.xml";
|
||||||
|
@ -255,8 +255,12 @@ void receive_msg()
|
|||||||
int msqid_stop = -1;
|
int msqid_stop = -1;
|
||||||
key_t key = 1101;
|
key_t key = 1101;
|
||||||
key_t key_stop = 1102;
|
key_t key_stop = 1102;
|
||||||
|
bool leave = false;
|
||||||
|
|
||||||
|
while(!leave)
|
||||||
|
{
|
||||||
// wait for the queue to be created
|
// wait for the queue to be created
|
||||||
if((msqid = msgget(key, 0644)) == -1){}
|
while((msqid = msgget(key, 0644)) == -1){}
|
||||||
|
|
||||||
if (msgrcv(msqid, &msg, msgrcv_size, 1, 0) != -1)
|
if (msgrcv(msqid, &msg, msgrcv_size, 1, 0) != -1)
|
||||||
{
|
{
|
||||||
@ -266,15 +270,15 @@ void receive_msg()
|
|||||||
TTFF_v.push_back(ttff_msg / (1000.0 / decimation_factor) );
|
TTFF_v.push_back(ttff_msg / (1000.0 / decimation_factor) );
|
||||||
LOG(INFO) << "Valid Time-To-First-Fix: " << ttff_msg / (1000.0 / decimation_factor ) << "[s]";
|
LOG(INFO) << "Valid Time-To-First-Fix: " << ttff_msg / (1000.0 / decimation_factor ) << "[s]";
|
||||||
// Stop the receiver
|
// Stop the receiver
|
||||||
//while(((msqid_stop = msgget(key_stop, 0644 | IPC_CREAT))) == -1){}
|
|
||||||
while(((msqid_stop = msgget(key_stop, 0644))) == -1){}
|
while(((msqid_stop = msgget(key_stop, 0644))) == -1){}
|
||||||
double msgsend_size = sizeof(msg_stop.ttff);
|
double msgsend_size = sizeof(msg_stop.ttff);
|
||||||
msgsnd(msqid_stop, &msg_stop, msgsend_size, IPC_NOWAIT);
|
msgsnd(msqid_stop, &msg_stop, msgsend_size, IPC_NOWAIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ttff_msg != -1)
|
if(ttff_msg == -1)
|
||||||
{
|
{
|
||||||
receive_msg();
|
leave = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -586,17 +590,6 @@ int main(int argc, char **argv)
|
|||||||
google::ParseCommandLineFlags(&argc, &argv, true);
|
google::ParseCommandLineFlags(&argc, &argv, true);
|
||||||
google::InitGoogleLogging(argv[0]);
|
google::InitGoogleLogging(argv[0]);
|
||||||
|
|
||||||
// Create SysV message queue to read TFFF measurements
|
|
||||||
key_t sysv_msg_key;
|
|
||||||
int sysv_msqid;
|
|
||||||
sysv_msg_key = 1101;
|
|
||||||
int msgflg = IPC_CREAT | 0666;
|
|
||||||
if ((sysv_msqid = msgget(sysv_msg_key, msgflg )) == -1)
|
|
||||||
{
|
|
||||||
std::cout<<"GNSS-SDR can not create message queues!" << std::endl;
|
|
||||||
throw new std::exception();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Start queue thread
|
// Start queue thread
|
||||||
std::thread receive_msg_thread(receive_msg);
|
std::thread receive_msg_thread(receive_msg);
|
||||||
|
|
||||||
@ -611,6 +604,15 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Terminate the queue thread
|
// Terminate the queue thread
|
||||||
|
key_t sysv_msg_key;
|
||||||
|
int sysv_msqid;
|
||||||
|
sysv_msg_key = 1101;
|
||||||
|
int msgflg = IPC_CREAT | 0666;
|
||||||
|
if ((sysv_msqid = msgget(sysv_msg_key, msgflg )) == -1)
|
||||||
|
{
|
||||||
|
std::cout<<"GNSS-SDR can not create message queues!" << std::endl;
|
||||||
|
throw new std::exception();
|
||||||
|
}
|
||||||
ttff_msgbuf msg;
|
ttff_msgbuf msg;
|
||||||
msg.mtype = 1;
|
msg.mtype = 1;
|
||||||
msg.ttff = -1;
|
msg.ttff = -1;
|
||||||
@ -619,6 +621,7 @@ int main(int argc, char **argv)
|
|||||||
msgsnd(sysv_msqid, &msg, msgsend_size, IPC_NOWAIT);
|
msgsnd(sysv_msqid, &msg, msgsend_size, IPC_NOWAIT);
|
||||||
receive_msg_thread.join();
|
receive_msg_thread.join();
|
||||||
msgctl(sysv_msqid, IPC_RMID, NULL);
|
msgctl(sysv_msqid, IPC_RMID, NULL);
|
||||||
|
|
||||||
google::ShutDownCommandLineFlags();
|
google::ShutDownCommandLineFlags();
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user