diff --git a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_cc.cc b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_cc.cc index 52b972576..d1d031ec0 100644 --- a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_cc.cc +++ b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_cc.cc @@ -324,6 +324,8 @@ rtklib_pvt_cc::rtklib_pvt_cc(unsigned int nchannels, bool dump, std::string dump std::cout << "GNSS-SDR can not create message queues!" << std::endl; throw new std::exception(); } + gettimeofday(&tv, NULL); + begin = tv.tv_sec * 1000000 + tv.tv_usec; } @@ -557,7 +559,9 @@ int rtklib_pvt_cc::work (int noutput_items, gr_vector_const_void_star &input_ite << " [deg], Height= " << d_ls_pvt->d_height_m << " [m]" << std::endl; ttff_msgbuf ttff; ttff.mtype = 1; - ttff.ttff = 0; //d_sample_counter; + gettimeofday(&tv, NULL); + long long int end = tv.tv_sec * 1000000 + tv.tv_usec; + ttff.ttff = static_cast(end - begin) / 1000000.0; send_sys_v_ttff_msg(ttff); first_fix = false; } diff --git a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_cc.h b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_cc.h index 370b7c25e..f6bda20bb 100644 --- a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_cc.h +++ b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_cc.h @@ -31,6 +31,7 @@ #ifndef GNSS_SDR_RTKLIB_PVT_CC_H #define GNSS_SDR_RTKLIB_PVT_CC_H +#include #include #include #include @@ -142,6 +143,8 @@ private: double ttff; } ttff_msgbuf; bool send_sys_v_ttff_msg(ttff_msgbuf ttff); + struct timeval tv; + long long int begin; public: rtklib_pvt_cc(unsigned int nchannels, diff --git a/src/tests/system-tests/ttff_gps_l1.cc b/src/tests/system-tests/ttff_gps_l1.cc index e30d79bd3..1c57fdb85 100644 --- a/src/tests/system-tests/ttff_gps_l1.cc +++ b/src/tests/system-tests/ttff_gps_l1.cc @@ -279,8 +279,8 @@ void receive_msg() ttff_msg = msg.ttff; if( (ttff_msg != 0) && (ttff_msg != -1)) { - TTFF_v.push_back(ttff_msg / (1000.0 / decimation_factor) ); - LOG(INFO) << "Valid Time-To-First-Fix: " << ttff_msg / (1000.0 / decimation_factor ) << "[s]"; + TTFF_v.push_back(ttff_msg); + LOG(INFO) << "Valid Time-To-First-Fix: " << ttff_msg << "[s]"; // Stop the receiver while(((msqid_stop = msgget(key_stop, 0644))) == -1){} double msgsend_size = sizeof(msg_stop.ttff);