From e11e5545c80f0336e9336c0aad9e38a858058819 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Fri, 6 May 2016 14:00:13 +0200 Subject: [PATCH] TCP port and RTCM Station ID config can be done now by the Rtcm_Printer --- src/core/system_parameters/rtcm.cc | 35 +++++++++++++++++------------- src/core/system_parameters/rtcm.h | 3 +++ 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/src/core/system_parameters/rtcm.cc b/src/core/system_parameters/rtcm.cc index e29fce6a1..72b8a9834 100644 --- a/src/core/system_parameters/rtcm.cc +++ b/src/core/system_parameters/rtcm.cc @@ -39,25 +39,30 @@ #include #include #include -#include #include #include "Galileo_E1.h" - using google::LogMessage; -DEFINE_int32(RTCM_Ref_Station_ID, 1234, "Reference Station ID in RTCM messages"); -DEFINE_int32(RTCM_Port, 2101 , "TCP port of the RTCM message server"); -// 2101 is the standard RTCM port according to the Internet Assigned Numbers Authority (IANA) -// https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xml - Rtcm::Rtcm() { + // 2101 is the standard RTCM port according to the Internet Assigned Numbers Authority (IANA) + // https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xml + unsigned short _default_port = 2101; + unsigned short _default_station_id = 1234; + Rtcm::Rtcm(_default_port, _default_station_id); +} + + +Rtcm::Rtcm(unsigned short port, unsigned short station_id) +{ + RTCM_port = port; + RTCM_Station_ID = station_id; preamble = std::bitset<8>("11010011"); reserved_field = std::bitset<6>("000000"); rtcm_message_queue = std::make_shared< concurrent_queue >(); - boost::asio::ip::tcp::endpoint endpoint(boost::asio::ip::tcp::v4(), FLAGS_RTCM_Port); + boost::asio::ip::tcp::endpoint endpoint(boost::asio::ip::tcp::v4(), RTCM_port); servers.emplace_back(io_service, endpoint); server_is_running = false; } @@ -80,10 +85,10 @@ Rtcm::~Rtcm() // ***************************************************************************************************** void Rtcm::run_server() { - std::cout << "Starting a TCP Server on port " << FLAGS_RTCM_Port << std::endl; + std::cout << "Starting a TCP Server on port " << RTCM_port << std::endl; try { - std::thread tq([&]{ std::make_shared(io_service, rtcm_message_queue, FLAGS_RTCM_Port)->do_read_queue(); }); + std::thread tq([&]{ std::make_shared(io_service, rtcm_message_queue, RTCM_port)->do_read_queue(); }); tq.detach(); std::thread t([&]{ io_service.run(); }); @@ -105,7 +110,7 @@ void Rtcm::stop_service() void Rtcm::stop_server() { - std::cout << "Stopping TCP Server on port " << FLAGS_RTCM_Port << std::endl; + std::cout << "Stopping TCP Server on port " << RTCM_port << std::endl; rtcm_message_queue->push("Goodbye"); // this terminates tq Rtcm::stop_service(); servers.front().close_server(); @@ -448,7 +453,7 @@ std::bitset<58> Rtcm::get_MT1001_sat_content(const Gps_Ephemeris & eph, double o std::string Rtcm::print_MT1001(const Gps_Ephemeris & gps_eph, double obs_time, const std::map & pseudoranges) { - unsigned int ref_id = static_cast(FLAGS_RTCM_Ref_Station_ID); + unsigned int ref_id = static_cast(RTCM_Station_ID); unsigned int smooth_int = 0; bool sync_flag = false; bool divergence_free = false; @@ -498,7 +503,7 @@ std::string Rtcm::print_MT1001(const Gps_Ephemeris & gps_eph, double obs_time, c std::string Rtcm::print_MT1002(const Gps_Ephemeris & gps_eph, double obs_time, const std::map & pseudoranges) { - unsigned int ref_id = static_cast(FLAGS_RTCM_Ref_Station_ID); + unsigned int ref_id = static_cast(RTCM_Station_ID); unsigned int smooth_int = 0; bool sync_flag = false; bool divergence_free = false; @@ -570,7 +575,7 @@ std::bitset<74> Rtcm::get_MT1002_sat_content(const Gps_Ephemeris & eph, double o std::string Rtcm::print_MT1003(const Gps_Ephemeris & ephL1, const Gps_CNAV_Ephemeris & ephL2, double obs_time, const std::map & pseudoranges) { - unsigned int ref_id = static_cast(FLAGS_RTCM_Ref_Station_ID); + unsigned int ref_id = static_cast(RTCM_Station_ID); unsigned int smooth_int = 0; bool sync_flag = false; bool divergence_free = false; @@ -680,7 +685,7 @@ std::bitset<101> Rtcm::get_MT1003_sat_content(const Gps_Ephemeris & ephL1, const std::string Rtcm::print_MT1004(const Gps_Ephemeris & ephL1, const Gps_CNAV_Ephemeris & ephL2, double obs_time, const std::map & pseudoranges) { - unsigned int ref_id = static_cast(FLAGS_RTCM_Ref_Station_ID); + unsigned int ref_id = static_cast(RTCM_Station_ID); unsigned int smooth_int = 0; bool sync_flag = false; bool divergence_free = false; diff --git a/src/core/system_parameters/rtcm.h b/src/core/system_parameters/rtcm.h index 3931583e7..8c2b57688 100644 --- a/src/core/system_parameters/rtcm.h +++ b/src/core/system_parameters/rtcm.h @@ -84,6 +84,7 @@ class Rtcm { public: Rtcm(); //