diff --git a/src/algorithms/channel/adapters/channel.h b/src/algorithms/channel/adapters/channel.h index 834cc5cd7..9160bb490 100644 --- a/src/algorithms/channel/adapters/channel.h +++ b/src/algorithms/channel/adapters/channel.h @@ -95,6 +95,8 @@ public: inline std::shared_ptr tracking() const { return trk_; } inline std::shared_ptr telemetry() const { return nav_; } + inline uint32_t fsm_state() const { return channel_fsm_->state(); } + private: bool glonass_dll_pll_c_aid_tracking_check() const; std::shared_ptr channel_fsm_; diff --git a/src/algorithms/channel/libs/channel_fsm.h b/src/algorithms/channel/libs/channel_fsm.h index 60e248449..92be90c9e 100644 --- a/src/algorithms/channel/libs/channel_fsm.h +++ b/src/algorithms/channel/libs/channel_fsm.h @@ -61,6 +61,8 @@ public: virtual bool Event_failed_acquisition_repeat(); virtual bool Event_failed_acquisition_no_repeat(); + inline uint32_t state() const { return state_; } + private: void start_tracking(); void stop_acquisition(); diff --git a/src/core/receiver/control_thread.cc b/src/core/receiver/control_thread.cc index 9a265254d..a1daaa870 100644 --- a/src/core/receiver/control_thread.cc +++ b/src/core/receiver/control_thread.cc @@ -428,6 +428,7 @@ int ControlThread::run() // start the telecommand listener thread cmd_interface_.set_pvt(flowgraph_->get_pvt()); + cmd_interface_.set_channels(flowgraph_->get_channels()); cmd_interface_thread_ = std::thread(&ControlThread::telecommand_listener, this); #ifdef ENABLE_FPGA diff --git a/src/core/receiver/gnss_flowgraph.h b/src/core/receiver/gnss_flowgraph.h index 2616c8025..bbb48d35a 100644 --- a/src/core/receiver/gnss_flowgraph.h +++ b/src/core/receiver/gnss_flowgraph.h @@ -152,6 +152,14 @@ public: return std::dynamic_pointer_cast(pvt_); } + /*! + * \brief Returns a smart pointer to the Channels object + */ + std::shared_ptr>> get_channels() + { + return std::make_shared>>(channels_); + } + /*! * \brief Priorize visible satellites in the specified vector */ diff --git a/src/core/receiver/tcp_cmd_interface.cc b/src/core/receiver/tcp_cmd_interface.cc index 713c3e726..527578c94 100644 --- a/src/core/receiver/tcp_cmd_interface.cc +++ b/src/core/receiver/tcp_cmd_interface.cc @@ -16,6 +16,7 @@ */ #include "tcp_cmd_interface.h" +#include "channel.h" #include "command_event.h" #include "pvt_interface.h" #include @@ -31,6 +32,7 @@ using b_io_context = boost::asio::io_context; using b_io_context = boost::asio::io_service; #endif + TcpCmdInterface::TcpCmdInterface() : rx_latitude_(0.0), rx_longitude_(0.0), @@ -71,6 +73,12 @@ void TcpCmdInterface::set_pvt(std::shared_ptr PVT_sptr) } +void TcpCmdInterface::set_channels(std::shared_ptr>> channels_sptr) +{ + channels_sptr_ = std::move(channels_sptr); +} + + time_t TcpCmdInterface::get_utc_time() const { return receiver_utc_time_; @@ -120,18 +128,46 @@ std::string TcpCmdInterface::standby(const std::vector &commandLine std::string TcpCmdInterface::status(const std::vector &commandLine __attribute__((unused))) { std::stringstream str_stream; - // todo: implement the receiver status report - // str_stream << "-------------------------------------------------------\n"; - // str_stream << "ch | sys | sig | mode | Tlm | Eph | Doppler | CN0 |\n"; - // str_stream << " | | | | | | [Hz] | [dB - Hz] |\n"; - // str_stream << "-------------------------------------------------------\n"; - // int n_ch = 10; - // for (int n = 0; n < n_ch; n++) - // { - // str_stream << n << "GPS | L1CA | TRK | YES | YES | 23412.4 | 44.3 |\n"; - // } - // str_stream << "--------------------------------------------------------\n"; + str_stream << "-------------------------------------------------------------------------\n"; + str_stream << "| Ch | System | Signal | PRN | Mode | Tlm | Eph | Doppler | CN0 |\n"; + str_stream << "| | | | | | | | [Hz] | [dB-Hz] |\n"; + str_stream << "-------------------------------------------------------------------------\n"; + + int n_ch = static_cast(channels_sptr_->size()); + for (int n = 0; n < n_ch; n++) + { + std::shared_ptr + ch_sptr = std::dynamic_pointer_cast(channels_sptr_->at(n)); + + std::string system = ch_sptr->get_signal().get_satellite().get_system(); + std::string signal = map_signal_pretty_name_.at(ch_sptr->get_signal().get_signal_str()); + uint32_t prn = ch_sptr->get_signal().get_satellite().get_PRN(); + std::string state = map_state_name_.at(ch_sptr->fsm_state()); + + str_stream << std::fixed << std::setprecision(1) + << "| " + << std::right << std::setw(3) << n + << " | " + << std::left << std::setw(7) << system + << " | " + << std::left << std::setw(6) << signal + << " | " + << std::right << std::setw(3) << prn + << " | " + << std::left << std::setw(4) << state + << " | " + << std::left << std::setw(3) << "---" + << " | " + << std::left << std::setw(3) << "---" + << " | " + << std::right << std::setw(9) << 23412.46 + << " | " + << std::right << std::setw(7) << 44.32 + << " |" + << "\n"; + } + str_stream << "-------------------------------------------------------------------------\n"; double longitude_deg; double latitude_deg; diff --git a/src/core/receiver/tcp_cmd_interface.h b/src/core/receiver/tcp_cmd_interface.h index c2f3dda26..c13156245 100644 --- a/src/core/receiver/tcp_cmd_interface.h +++ b/src/core/receiver/tcp_cmd_interface.h @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -37,6 +38,7 @@ class PvtInterface; +class ChannelInterface; class TcpCmdInterface { @@ -57,6 +59,7 @@ public: std::array get_LLH() const; void set_pvt(std::shared_ptr PVT_sptr); + void set_channels(std::shared_ptr>> channels_sptr); private: std::unordered_map &)>> @@ -73,6 +76,25 @@ private: std::shared_ptr> control_queue_; std::shared_ptr PVT_sptr_; + std::shared_ptr>> channels_sptr_; + + const std::map map_signal_pretty_name_{ + {"1C", "L1 C/A"}, + {"1B", "E1"}, + {"1G", "L1 C/A"}, + {"2S", "L2C"}, + {"2G", "L2 C/A"}, + {"5X", "E5a"}, + {"7X", "E5b"}, + {"L5", "L5"}, + {"B1", "B1I"}, + {"B3", "B3I"}}; + + const std::map map_state_name_{ + {0, "STBY"}, + {1, "ACQ"}, + {2, "TRK"}, + {3, "DROP"}}; float rx_latitude_; float rx_longitude_;