@ -19,6 +19,7 @@
*
*
*/
*/
# include <poll.h>
# include <pthread.h>
# include <pthread.h>
# include <signal.h>
# include <signal.h>
# include <stdio.h>
# include <stdio.h>
@ -401,8 +402,12 @@ static bool do_metrics = false;
static void * input_loop ( metrics_stdout * metrics , srsenb : : enb_command_interface * control )
static void * input_loop ( metrics_stdout * metrics , srsenb : : enb_command_interface * control )
{
{
struct pollfd pfd = { STDIN_FILENO , POLLIN , 0 } ;
string input_line ;
string input_line ;
while ( running ) {
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 ) ;
getline ( cin , input_line ) ;
if ( cin . eof ( ) | | cin . bad ( ) ) {
if ( cin . eof ( ) | | cin . bad ( ) ) {
cout < < " Closing stdin thread. " < < endl ;
cout < < " Closing stdin thread. " < < endl ;
@ -441,6 +446,7 @@ static void* input_loop(metrics_stdout* metrics, srsenb::enb_command_interface*
}
}
}
}
}
}
}
return nullptr ;
return nullptr ;
}
}
@ -504,9 +510,8 @@ int main(int argc, char* argv[])
}
}
// create input thread
// create input thread
thread input( & input_loop , & metrics_screen , ( enb_command_interface * ) enb . get ( ) ) ;
std : : thread input( & input_loop , & metrics_screen , ( enb_command_interface * ) enb . get ( ) ) ;
bool signals_pregenerated = false ;
if ( running ) {
if ( running ) {
if ( args . gui . enable ) {
if ( args . gui . enable ) {
enb - > start_plot ( ) ;
enb - > start_plot ( ) ;
@ -521,8 +526,9 @@ int main(int argc, char* argv[])
enb - > print_pool ( ) ;
enb - > print_pool ( ) ;
}
}
}
}
usleep( 10000 ) ;
std: : this_thread : : sleep_for ( std : : chrono : : milliseconds ( 10 ) ) ;
}
}
input . join ( ) ;
metricshub . stop ( ) ;
metricshub . stop ( ) ;
enb - > stop ( ) ;
enb - > stop ( ) ;
cout < < " --- exiting --- " < < endl ;
cout < < " --- exiting --- " < < endl ;