Added multi-command line in srsenb

master
Xavier Arteaga 4 years ago committed by Xavier Arteaga
parent 676080d6af
commit 4bfe092a24

@ -441,21 +441,10 @@ void parse_args(all_args_t* args, int argc, char* argv[])
static bool do_metrics = false;
static bool do_padding = false;
static void* input_loop(metrics_stdout* metrics, srsenb::enb_command_interface* control)
static void execute_cmd(metrics_stdout* metrics, srsenb::enb_command_interface* control, const string& cmd_line)
{
struct pollfd pfd = {STDIN_FILENO, POLLIN, 0};
string input_line;
while (running) {
int ret = poll(&pfd, 1, 1000); // query stdin with a timeout of 1000ms
if (ret == 1) {
// there is user input to read
getline(cin, input_line);
if (cin.eof() || cin.bad()) {
cout << "Closing stdin thread." << endl;
break;
} else if (not input_line.empty()) {
vector<string> cmd;
srsran::string_parse_list(input_line, ' ', cmd);
srsran::string_parse_list(cmd_line, ' ', cmd);
if (cmd[0] == "t") {
do_metrics = !do_metrics;
if (do_metrics) {
@ -464,6 +453,19 @@ static void* input_loop(metrics_stdout* metrics, srsenb::enb_command_interface*
cout << "Enter t to restart trace." << endl;
}
metrics->toggle_print(do_metrics);
} else if (cmd[0] == "sleep") {
if (cmd.size() != 2) {
cout << "Usage: " << cmd[0] << " [number of seconds]" << endl;
return;
}
int nseconds = srsran::string_cast<int>(cmd[1]);
if (nseconds <= 0) {
return;
}
std::this_thread::sleep_for(std::chrono::seconds(nseconds));
} else if (cmd[0] == "p") {
do_padding = !do_padding;
if (do_padding) {
@ -477,7 +479,7 @@ static void* input_loop(metrics_stdout* metrics, srsenb::enb_command_interface*
} else if (cmd[0] == "cell_gain") {
if (cmd.size() != 3) {
cout << "Usage: " << cmd[0] << " [cell identifier] [gain in dB]" << endl;
continue;
return;
}
// Parse command arguments
@ -495,6 +497,27 @@ static void* input_loop(metrics_stdout* metrics, srsenb::enb_command_interface*
cout << endl;
}
}
static void* input_loop(metrics_stdout* metrics, srsenb::enb_command_interface* control)
{
struct pollfd pfd = {STDIN_FILENO, POLLIN, 0};
string input_line;
while (running) {
int ret = poll(&pfd, 1, 1000); // query stdin with a timeout of 1000ms
if (ret == 1) {
// there is user input to read
getline(cin, input_line);
if (cin.eof() || cin.bad()) {
cout << "Closing stdin thread." << endl;
break;
} else if (not input_line.empty()) {
list<string> cmd_list;
srsran::string_parse_list(input_line, ';', cmd_list);
for (const string& cmd : cmd_list) {
execute_cmd(metrics, control, cmd);
}
}
}
}
return nullptr;

Loading…
Cancel
Save