From 4b620c59318825de09a4feea1a6958ddbca14d1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Cebri=C3=A1n=20Juan?= Date: Wed, 22 Aug 2018 15:42:38 +0200 Subject: [PATCH] Add an IP address parser to enable specifying multiple clients in the Monitor block configuration --- src/core/receiver/gnss_flowgraph.cc | 21 +++++++++++++++++---- src/core/receiver/gnss_flowgraph.h | 1 + 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/core/receiver/gnss_flowgraph.cc b/src/core/receiver/gnss_flowgraph.cc index a88ace37a..72a7a013b 100644 --- a/src/core/receiver/gnss_flowgraph.cc +++ b/src/core/receiver/gnss_flowgraph.cc @@ -1157,11 +1157,10 @@ void GNSSFlowgraph::init() */ enable_monitor_ = configuration_->property("Monitor.enable_monitor", false); - std::vector udp_addr_vec; - std::string address_string = configuration_->property("Monitor.client_addresses", std::string("127.0.0.1")); - //todo: split the string in substrings using the separator and fill the address vector. - udp_addr_vec.push_back(address_string); + std::vector udp_addr_vec = split_string(address_string, '_'); + std::sort(udp_addr_vec.begin(), udp_addr_vec.end()); + udp_addr_vec.erase(std::unique(udp_addr_vec.begin(), udp_addr_vec.end()), udp_addr_vec.end()); if (enable_monitor_) { @@ -1599,3 +1598,17 @@ Gnss_Signal GNSSFlowgraph::search_next_signal(std::string searched_signal, bool } return result; } + +std::vector GNSSFlowgraph::split_string(const std::string &s, char delim) +{ + std::vector v; + std::stringstream ss(s); + std::string item; + + while (std::getline(ss, item, delim)) + { + *(std::back_inserter(v)++) = item; + } + + return v; +} diff --git a/src/core/receiver/gnss_flowgraph.h b/src/core/receiver/gnss_flowgraph.h index 49b25eef4..1f1d07ada 100644 --- a/src/core/receiver/gnss_flowgraph.h +++ b/src/core/receiver/gnss_flowgraph.h @@ -186,6 +186,7 @@ private: bool enable_monitor_; gr::basic_block_sptr GnssSynchroMonitor_; + std::vector split_string(const std::string &s, char delim); }; #endif /*GNSS_SDR_GNSS_FLOWGRAPH_H_*/