9 std::string comp_string;
10 comp_string =
"UNINIT";
13 comp_string =
"TONES";
16 comp_string =
"CHIRP";
19 comp_string =
"NOISE";
25 comp_string =
"NODSP";
28 comp_string =
"SWONLY";
31 comp_string =
"DIRECT";
39 if(input_string.compare(
"NODSP") == 0)conv = NODSP;
41 if(input_string.compare(
"CHIRP") == 0)conv = CHIRP;
43 if(input_string.compare(
"NOISE") == 0)conv = NOISE;
45 if(input_string.compare(
"TONES") == 0)conv = TONES;
47 if(input_string.compare(
"SWONLY") == 0)conv = SWONLY;
49 if(input_string.compare(
"DIRECT") == 0)conv = DIRECT;
56 std::vector<w_type> res(string_vector.size());
57 for(
size_t i = 0; i <string_vector.size(); i++ ){
64 std::string comp_string;
65 comp_string =
"UNINIT";
81 if (not str.compare(
"OFF"))
return (ant_mode)OFF;
82 if (not str.compare(
"RX"))
return (ant_mode)RX;
83 if (not str.compare(
"TX"))
return (ant_mode)TX;
84 print_warning(
"ant_mode from parametern conversion has not been recognised. Setting to OFF");
91 int param::get_output_buffer_size(){
93 return std::ceil((
float)buffer_len/(
float)decim)*wave_type.size();
97 bool param::dynamic_buffer(){
99 for(
size_t i = 0; i< wave_type.size(); i++)
if(wave_type[i]!=TONES)dynamic =
true;
104 int usrp_param::get_number(ant_mode T){
106 if(A_TXRX.mode == T)num++;
107 if(A_RX2.mode == T)num++;
108 if(B_TXRX.mode == T)num++;
109 if(B_RX2.mode == T)num++;
113 bool usrp_param::is_A_active(){
114 return (A_TXRX.mode != OFF or A_RX2.mode != OFF);
117 bool usrp_param::is_B_active(){
118 return (B_TXRX.mode != OFF or B_RX2.mode != OFF);
121 void server_settings::validate(){
122 if(clock_reference.compare(
"internal") != 0 and clock_reference.compare(
"external") != 0){
123 std::stringstream ss;
124 ss<<
"Clock selection mode \""<<clock_reference<<
"\" is not valid for the usrp X300. Setting mode to \"internal\".";
126 clock_reference =
"internal";
129 cudaGetDeviceCount(&num_gpus);
131 print_error(
"No GPU found in the system. This version of the USRP server needs at least one GPU to work.");
134 if(GPU_device_index>num_gpus){
135 std::stringstream ss;
136 ss<<
"GPU device index ("<< GPU_device_index <<
") has been selected. However on the system only (" << num_gpus<<
") GPUs have been detected. Setting GPU index to "<< 0;
138 GPU_device_index = 0;
140 if(default_rx_buffer_len < MIN_USEFULL_BUFFER or default_rx_buffer_len > MAX_USEFULL_BUFFER){
141 print_warning(
"RX default buffer length selected may give troubles");
143 if(default_tx_buffer_len < MIN_USEFULL_BUFFER or default_tx_buffer_len > MAX_USEFULL_BUFFER){
144 print_warning(
"TX default buffer length selected may give troubles");
146 if((not TCP_streaming) and (not FILE_writing)){
151 void server_settings::autoset(){
152 TCP_streaming =
false;
154 clock_reference =
"internal";
155 GPU_device_index = 0;
156 default_rx_buffer_len = 1000000;
157 default_tx_buffer_len = 1000000;
177 #if defined(__APPLE__) 179 #include <mach/mach.h> 180 #include <mach/mach_time.h> 186 #if not defined(__APPLE__) 187 int SYSTEM_CORES = 7;
190 struct sched_param scheme;
192 pthread_t thread_ID = (pthread_t)Thread.native_handle();
194 scheme.sched_priority = priority;
197 retcode = pthread_setschedparam(thread_ID, policy, &scheme);
198 if(retcode != 0)
print_warning(
"Cannot set thread scheduling policy");
201 print_debug(
"Setting affinity to ", affinity%SYSTEM_CORES);
203 CPU_SET(affinity%SYSTEM_CORES, &cpuset);
204 int rc = pthread_setaffinity_np(Thread.native_handle(),
sizeof(cpu_set_t), &cpuset);
206 std::stringstream ss;
207 ss <<
"Error calling pthread_setaffinity_np: there may be some instability. Result: " << rc;
212 #if defined(__APPLE__) 219 auto handle = thread->native_handle();
220 pthread_setname_np(handle,threadName);
std::string device_arguments
std::string ant_mode_to_str(ant_mode enumerator)
std::string get_front_end_name(char code)
void SetThreadName(boost::thread *thread, const char *threadName)
std::string w_type_to_str(w_type enumerator)
void print_error(std::string text)
void Thread_Prioriry(boost::thread &Thread, int priority, int affinity)
ant_mode ant_mode_from_string(std::string str)
w_type string_to_w_type(std::string input_string)
std::vector< w_type > string_to_w_type_vector(std::vector< std::string > string_vector)
void print_debug(std::string text, double value)
void print_warning(std::string text)