mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2024-11-19 00:04:58 +00:00
Merge branch 'next' of https://github.com/gnss-sdr/gnss-sdr into next
This commit is contained in:
commit
15ed9d1a08
@ -507,7 +507,7 @@ rtklib_pvt_cc::~rtklib_pvt_cc()
|
||||
|
||||
// Save Galileo UTC model parameters
|
||||
file_name = "gal_utc_model.xml";
|
||||
if (d_ls_pvt->galileo_utc_model.A0_6 != 0.0)
|
||||
if (d_ls_pvt->galileo_utc_model.Delta_tLS_6 != 0.0)
|
||||
{
|
||||
std::ofstream ofs;
|
||||
try
|
||||
|
@ -24,6 +24,7 @@ set(GNSS_RECEIVER_SOURCES
|
||||
gnss_block_factory.cc
|
||||
gnss_flowgraph.cc
|
||||
in_memory_configuration.cc
|
||||
tcp_cmd_interface.cc
|
||||
)
|
||||
|
||||
set(GNSS_RECEIVER_HEADERS
|
||||
|
@ -100,6 +100,12 @@ ControlThread::~ControlThread()
|
||||
}
|
||||
|
||||
|
||||
void ControlThread::telecommand_listener()
|
||||
{
|
||||
int tcp_cmd_port = configuration_->property("Channel.telecontrol_tcp_port", 3333);
|
||||
cmd_interface_.run_cmd_server(tcp_cmd_port);
|
||||
}
|
||||
|
||||
/*
|
||||
* Runs the control thread that manages the receiver control plane
|
||||
*
|
||||
@ -148,8 +154,11 @@ void ControlThread::run()
|
||||
keyboard_thread_ = boost::thread(&ControlThread::keyboard_listener, this);
|
||||
sysv_queue_thread_ = boost::thread(&ControlThread::sysv_queue_listener, this);
|
||||
|
||||
bool enable_FPGA = configuration_->property("Channel.enable_FPGA", false);
|
||||
//start the telecommand listener thread
|
||||
cmd_interface_thread_ = boost::thread(&ControlThread::telecommand_listener, this);
|
||||
|
||||
|
||||
bool enable_FPGA = configuration_->property("Channel.enable_FPGA", false);
|
||||
if (enable_FPGA == true)
|
||||
{
|
||||
flowgraph_->start_acquisition_helper();
|
||||
@ -171,10 +180,12 @@ void ControlThread::run()
|
||||
#ifdef OLD_BOOST
|
||||
keyboard_thread_.timed_join(boost::posix_time::seconds(1));
|
||||
sysv_queue_thread_.timed_join(boost::posix_time::seconds(1));
|
||||
cmd_interface_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));
|
||||
cmd_interface_thread_.try_join_until(boost::chrono::steady_clock::now() + boost::chrono::milliseconds(1000));
|
||||
#endif
|
||||
|
||||
LOG(INFO) << "Flowgraph stopped";
|
||||
@ -201,32 +212,32 @@ bool ControlThread::read_assistance_from_XML()
|
||||
bool ret = false;
|
||||
// getting names from the config file, if available
|
||||
std::string eph_xml_filename = configuration_->property("GNSS-SDR.SUPL_gps_ephemeris_xml", eph_default_xml_filename);
|
||||
std::string utc_xml_filename = configuration_->property("GNSS-SDR.SUPL_gps_utc_model.xml", utc_default_xml_filename);
|
||||
std::string utc_xml_filename = configuration_->property("GNSS-SDR.SUPL_gps_utc_model_xml", utc_default_xml_filename);
|
||||
std::string iono_xml_filename = configuration_->property("GNSS-SDR.SUPL_gps_iono_xml", iono_default_xml_filename);
|
||||
std::string gal_iono_xml_filename = configuration_->property("GNSS-SDR.SUPL_gal_iono_xml", gal_iono_default_xml_filename);
|
||||
std::string ref_time_xml_filename = configuration_->property("GNSS-SDR.SUPL_gps_ref_time_xml", ref_time_default_xml_filename);
|
||||
std::string ref_location_xml_filename = configuration_->property("GNSS-SDR.SUPL_gps_ref_location_xml", ref_location_default_xml_filename);
|
||||
std::string eph_gal_xml_filename = configuration_->property("GNSS-SDR.SUPL_gal_ephemeris_xml", eph_gal_default_xml_filename);
|
||||
std::string eph_cnav_xml_filename = configuration_->property("GNSS-SDR.SUPL_gps_cnav_ephemeris_xml", eph_cnav_default_xml_filename);
|
||||
std::string gal_utc_xml_filename = configuration_->property("GNSS-SDR.SUPL_gal_utc_model.xml", gal_utc_default_xml_filename);
|
||||
std::string cnav_utc_xml_filename = configuration_->property("GNSS-SDR.SUPL_cnav_utc_model.xml", cnav_utc_default_xml_filename);
|
||||
std::string gal_utc_xml_filename = configuration_->property("GNSS-SDR.SUPL_gal_utc_model_xml", gal_utc_default_xml_filename);
|
||||
std::string cnav_utc_xml_filename = configuration_->property("GNSS-SDR.SUPL_cnav_utc_model_xml", cnav_utc_default_xml_filename);
|
||||
std::string eph_glo_xml_filename = configuration_->property("GNSS-SDR.SUPL_glo_ephemeris_xml", eph_glo_gnav_default_xml_filename);
|
||||
std::string glo_utc_xml_filename = configuration_->property("GNSS-SDR.SUPL_glo_utc_model.xml", glo_utc_default_xml_filename);
|
||||
std::string glo_utc_xml_filename = configuration_->property("GNSS-SDR.SUPL_glo_utc_model_xml", glo_utc_default_xml_filename);
|
||||
|
||||
if (configuration_->property("GNSS-SDR.AGNSS_XML_enabled", false) == true)
|
||||
{
|
||||
eph_xml_filename = configuration_->property("GNSS-SDR.AGNSS_gps_ephemeris_xml", eph_default_xml_filename);
|
||||
utc_xml_filename = configuration_->property("GNSS-SDR.AGNSS_gps_utc_model.xml", utc_default_xml_filename);
|
||||
utc_xml_filename = configuration_->property("GNSS-SDR.AGNSS_gps_utc_model_xml", utc_default_xml_filename);
|
||||
iono_xml_filename = configuration_->property("GNSS-SDR.AGNSS_gps_iono_xml", iono_default_xml_filename);
|
||||
gal_iono_xml_filename = configuration_->property("GNSS-SDR.AGNSS_gal_iono_xml", gal_iono_default_xml_filename);
|
||||
ref_time_xml_filename = configuration_->property("GNSS-SDR.AGNSS_gps_ref_time_xml", ref_time_default_xml_filename);
|
||||
ref_location_xml_filename = configuration_->property("GNSS-SDR.AGNSS_gps_ref_location_xml", ref_location_default_xml_filename);
|
||||
eph_gal_xml_filename = configuration_->property("GNSS-SDR.AGNSS_gal_ephemeris_xml", eph_gal_default_xml_filename);
|
||||
eph_cnav_xml_filename = configuration_->property("GNSS-SDR.AGNSS_gps_cnav_ephemeris_xml", eph_cnav_default_xml_filename);
|
||||
gal_utc_xml_filename = configuration_->property("GNSS-SDR.AGNSS_gal_utc_model.xml", gal_utc_default_xml_filename);
|
||||
cnav_utc_xml_filename = configuration_->property("GNSS-SDR.AGNSS_cnav_utc_model.xml", cnav_utc_default_xml_filename);
|
||||
gal_utc_xml_filename = configuration_->property("GNSS-SDR.AGNSS_gal_utc_model_xml", gal_utc_default_xml_filename);
|
||||
cnav_utc_xml_filename = configuration_->property("GNSS-SDR.AGNSS_cnav_utc_model_xml", cnav_utc_default_xml_filename);
|
||||
eph_glo_xml_filename = configuration_->property("GNSS-SDR.AGNSS_glo_ephemeris_xml", eph_glo_gnav_default_xml_filename);
|
||||
glo_utc_xml_filename = configuration_->property("GNSS-SDR.AGNSS_glo_utc_model.xml", glo_utc_default_xml_filename);
|
||||
glo_utc_xml_filename = configuration_->property("GNSS-SDR.AGNSS_glo_utc_model_xml", glo_utc_default_xml_filename);
|
||||
}
|
||||
|
||||
std::cout << "Trying to read GNSS ephemeris from XML file(s)..." << std::endl;
|
||||
@ -511,7 +522,7 @@ void ControlThread::assist_GNSS()
|
||||
{
|
||||
std::cout << "SUPL: Failed to create Iono data file" << std::endl;
|
||||
}
|
||||
std::string utc_xml_filename = configuration_->property("GNSS-SDR.SUPL_gps_utc_model.xml", utc_default_xml_filename);
|
||||
std::string utc_xml_filename = configuration_->property("GNSS-SDR.SUPL_gps_utc_model_xml", utc_default_xml_filename);
|
||||
if (supl_client_ephemeris_.save_utc_xml(utc_xml_filename, supl_client_ephemeris_.gps_utc) == true)
|
||||
{
|
||||
std::cout << "SUPL: UTC model data file created" << std::endl;
|
||||
|
@ -37,6 +37,7 @@
|
||||
|
||||
#include "control_message_factory.h"
|
||||
#include "gnss_sdr_supl_client.h"
|
||||
#include "tcp_cmd_interface.h"
|
||||
#include <boost/thread.hpp>
|
||||
#include <gnuradio/msg_queue.h>
|
||||
#include <memory>
|
||||
@ -113,6 +114,10 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
//Telecommand TCP interface
|
||||
TcpCmdInterface cmd_interface_;
|
||||
void telecommand_listener();
|
||||
boost::thread cmd_interface_thread_;
|
||||
//SUPL assistance classes
|
||||
gnss_sdr_supl_client supl_client_acquisition_;
|
||||
gnss_sdr_supl_client supl_client_ephemeris_;
|
||||
|
187
src/core/receiver/tcp_cmd_interface.cc
Normal file
187
src/core/receiver/tcp_cmd_interface.cc
Normal file
@ -0,0 +1,187 @@
|
||||
/*!
|
||||
* \file tcp_cmd_interface.cc
|
||||
*
|
||||
* \brief Class that implements a TCP telecontrol command line interface
|
||||
* for GNSS-SDR
|
||||
* \author Javier Arribas jarribas (at) cttc.es
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors)
|
||||
*
|
||||
* GNSS-SDR is a software defined Global Navigation
|
||||
* Satellite Systems receiver
|
||||
*
|
||||
* This file is part of GNSS-SDR.
|
||||
*
|
||||
* GNSS-SDR is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GNSS-SDR is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GNSS-SDR. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include "tcp_cmd_interface.h"
|
||||
|
||||
|
||||
std::string TcpCmdInterface::stop(const std::vector<std::string> &commandLine)
|
||||
{
|
||||
std::string response;
|
||||
response = "Not implemented\n";
|
||||
return response;
|
||||
}
|
||||
|
||||
std::string TcpCmdInterface::status(const std::vector<std::string> &commandLine)
|
||||
{
|
||||
std::string response;
|
||||
response = "Not implemented\n";
|
||||
return response;
|
||||
}
|
||||
|
||||
std::string TcpCmdInterface::assistedstart(const std::vector<std::string> &commandLine)
|
||||
{
|
||||
std::string response;
|
||||
response = "Not implemented\n";
|
||||
return response;
|
||||
}
|
||||
|
||||
std::string TcpCmdInterface::warmstart(const std::vector<std::string> &commandLine)
|
||||
{
|
||||
std::string response;
|
||||
response = "Not implemented\n";
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
std::string TcpCmdInterface::coldstart(const std::vector<std::string> &commandLine)
|
||||
{
|
||||
std::string response;
|
||||
response = "Not implemented\n";
|
||||
return response;
|
||||
}
|
||||
|
||||
std::string TcpCmdInterface::set_ch_satellite(const std::vector<std::string> &commandLine)
|
||||
{
|
||||
std::string response;
|
||||
response = "Not implemented\n";
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
void TcpCmdInterface::register_functions()
|
||||
{
|
||||
functions["status"] = status;
|
||||
functions["stop"] = stop;
|
||||
functions["assistedstart"] = assistedstart;
|
||||
functions["warmstart"] = warmstart;
|
||||
functions["coldstart"] = coldstart;
|
||||
functions["set_ch_satellite"] = set_ch_satellite;
|
||||
}
|
||||
|
||||
|
||||
TcpCmdInterface::TcpCmdInterface()
|
||||
{
|
||||
register_functions();
|
||||
}
|
||||
|
||||
|
||||
void TcpCmdInterface::run_cmd_server(int tcp_port)
|
||||
{
|
||||
// Get the port from the parameters
|
||||
uint16_t port = tcp_port;
|
||||
|
||||
// Error to not throw exception
|
||||
boost::system::error_code not_throw;
|
||||
|
||||
// Socket and acceptor
|
||||
boost::asio::io_service service;
|
||||
boost::asio::ip::tcp::acceptor acceptor(service, boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), port));
|
||||
|
||||
bool keep_running = true;
|
||||
while (keep_running)
|
||||
{
|
||||
try
|
||||
{
|
||||
std::cout << "Telecommand TCP interface listening on port " << tcp_port << std::endl;
|
||||
boost::asio::ip::tcp::socket socket(service);
|
||||
acceptor.accept(socket, not_throw);
|
||||
if (not_throw)
|
||||
{
|
||||
std::cerr << "Error when binding the port in the socket" << std::endl;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Read a message
|
||||
boost::system::error_code error = boost::asio::error::eof;
|
||||
do
|
||||
{
|
||||
std::string response;
|
||||
boost::asio::streambuf b;
|
||||
boost::asio::read_until(socket, b, '\n');
|
||||
std::istream is(&b);
|
||||
std::string line;
|
||||
std::getline(is, line);
|
||||
std::cout << "received command: " << line << std::endl;
|
||||
|
||||
std::istringstream iss(line);
|
||||
std::vector<std::string> cmd_vector(std::istream_iterator<std::string>{iss},
|
||||
std::istream_iterator<std::string>());
|
||||
|
||||
if (cmd_vector.size() > 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
response = functions[cmd_vector.at(0)](cmd_vector);
|
||||
}
|
||||
catch (const std::exception &ex)
|
||||
{
|
||||
response = "ERROR: command execution error: " + std::string(ex.what()) + "\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
response = "ERROR: empty command\n";
|
||||
}
|
||||
|
||||
//send cmd response
|
||||
socket.write_some(boost::asio::buffer(response), not_throw);
|
||||
if (not_throw)
|
||||
{
|
||||
std::cerr << "Error sending(" << not_throw.value() << "): " << not_throw.message() << std::endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (error > 0); // && error != boost::asio::error::eof);
|
||||
|
||||
if (error == boost::asio::error::eof)
|
||||
{
|
||||
std::cout << "EOF detected\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "error: " << error << std::endl;
|
||||
}
|
||||
|
||||
// Close socket
|
||||
socket.close();
|
||||
}
|
||||
catch (const std::exception &ex)
|
||||
{
|
||||
std::cout << "Exception " << ex.what() << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TcpCmdInterface::~TcpCmdInterface()
|
||||
{
|
||||
// TODO Auto-generated destructor stub
|
||||
}
|
64
src/core/receiver/tcp_cmd_interface.h
Normal file
64
src/core/receiver/tcp_cmd_interface.h
Normal file
@ -0,0 +1,64 @@
|
||||
/*!
|
||||
* \file tcp_cmd_interface.h
|
||||
*
|
||||
* \brief Class that implements a TCP telecontrol command line interface
|
||||
* for GNSS-SDR
|
||||
* \author Javier Arribas jarribas (at) cttc.es
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors)
|
||||
*
|
||||
* GNSS-SDR is a software defined Global Navigation
|
||||
* Satellite Systems receiver
|
||||
*
|
||||
* This file is part of GNSS-SDR.
|
||||
*
|
||||
* GNSS-SDR is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GNSS-SDR is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GNSS-SDR. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef TCPCMDINTERFACE_H_
|
||||
#define TCPCMDINTERFACE_H_
|
||||
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
#include <algorithm>
|
||||
#include <boost/asio.hpp>
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
class TcpCmdInterface
|
||||
{
|
||||
public:
|
||||
TcpCmdInterface();
|
||||
virtual ~TcpCmdInterface();
|
||||
void run_cmd_server(int tcp_port);
|
||||
|
||||
private:
|
||||
std::unordered_map<std::string, std::function<std::string(const std::vector<std::string> &)>>
|
||||
functions;
|
||||
static std::string status(const std::vector<std::string> &commandLine);
|
||||
static std::string stop(const std::vector<std::string> &commandLine);
|
||||
static std::string assistedstart(const std::vector<std::string> &commandLine);
|
||||
static std::string warmstart(const std::vector<std::string> &commandLine);
|
||||
static std::string coldstart(const std::vector<std::string> &commandLine);
|
||||
static std::string set_ch_satellite(const std::vector<std::string> &commandLine);
|
||||
|
||||
void register_functions();
|
||||
};
|
||||
|
||||
#endif /* TCPCMDINTERFACE_H_ */
|
Loading…
Reference in New Issue
Block a user