14 #include <boost/program_options.hpp> 16 namespace po = boost::program_options;
19 int main(
int argc,
char **argv){
20 uhd::set_thread_priority_safe(1.);
23 logging::add_common_attributes();
24 std::cout <<
"\033[40;1;32mUSRP GPU Server v 2.0\033[0m" << std::endl;
25 BOOST_LOG_TRIVIAL(debug) <<
"Server started";
26 bool file_write, net_streaming, sw_loop;
28 int port_async,port_sync;
32 std::string* json_res;
34 po::options_description desc(
"Allowed options");
36 (
"help",
"help message")
39 (
"fw", po::value<bool>(&file_write)->default_value(
false)->implicit_value(
true),
"Enable local file writing")
40 (
"no_net", po::value<bool>(&net_streaming)->default_value(
true)->implicit_value(
false),
"Disable network streaming")
41 (
"sw_loop", po::value<bool>(&sw_loop)->default_value(
false)->implicit_value(
true),
"Bypass USRP interaction")
42 (
"clock", po::value<std::string>(&clock)->default_value(
"internal")->implicit_value(
"external"),
"Clock selector")
43 (
"async", po::value<int>(&port_async)->default_value(22001),
"Define ascynchronous TCP communication port")
44 (
"data", po::value<int>(&port_sync)->default_value(61360),
"Define scynchronous TCP data streaming port")
45 (
"uhd_dbg", po::value<bool>(&uhd_dbg)->default_value(
false),
"Enable UHD degug logging on console.")
46 (
"args", po::value<std::string>(&
device_arguments)->default_value(
"noarg"),
"Device argument to pass (experimental use)")
49 po::store(po::parse_command_line(argc, argv, desc), vm);
52 if (vm.count(
"help")){
53 std::cout <<
"USRP GPU server version 2.0. Consult online documentation on how to use this server." << std::endl;
57 if(uhd_dbg)uhd::log::set_console_level(uhd::log::severity_level::trace);
58 server_settings settings;
60 settings.TCP_streaming = net_streaming;
61 settings.FILE_writing = file_write;
68 TXRX thread_manager(&settings, &usrp,
false);
76 BOOST_LOG_TRIVIAL(info) <<
"Main loop";
77 std::this_thread::sleep_for(std::chrono::milliseconds(50));
79 usrp_param global_parameters;
80 bool res = async.
recv_async(global_parameters);
82 BOOST_LOG_TRIVIAL(info) <<
"Sending response to client application";
83 json_res =
new std::string(res?
server_ack(
"Message received"):
server_nack(
"Cannot convert JSON to params"));
86 BOOST_LOG_TRIVIAL(info) <<
"Implementing parameter configuration";
88 thread_manager.
set(&global_parameters);
89 thread_manager.
start(&global_parameters);
91 std::cout<<
"DAq in progress:" <<std::flush;
93 done = thread_manager.
stop();
95 std::cout<<
"."<<std::flush;
97 std::cout<<
"*Measure complete"<<std::endl;
99 boost::this_thread::sleep_for(boost::chrono::milliseconds{500});
102 json_res =
new std::string(
server_ack(
"EOM: end of measurement"));
103 BOOST_LOG_TRIVIAL(info) <<
"Measure ended";
106 BOOST_LOG_TRIVIAL(warning) <<
"Parameter in the received message cannot be implemented";
std::string device_arguments
void start(usrp_param *global_param)
Start the threads.
void set(usrp_param *global_param)
Launches the setting functions for the required signals, antennas...
std::string server_ack(std::string payload)
bool chk_param(usrp_param *parameter)
std::string server_nack(std::string payload)
void set_this_thread_name(std::string thread_name)
Set the htread name reported in the logging.
void print_params(usrp_param my_parameter)
Print parameters on the terminal in a readable way.
bool recv_async(usrp_param &my_parameter, bool blocking=true)
bool stop(bool force=false)
int main(int argc, char **argv)
Manages the hardware I/O of one usrp unit.
void init_logger()
initialize the logger for the server. Creates or access the folder logs. each time the server starts...
void send_async(std::string *message)