Commit 6819b27a authored by Miguel Jimenez Lopez's avatar Miguel Jimenez Lopez

irq-demo: Fix user stop mechanism

parent d83d33ac
......@@ -55,7 +55,6 @@ int main(int argc, char *argv[])
user_args user_arguments;
log_device logs[2];
unsigned int n_logs = 2;
unsigned int user_stop = 0;
stats_engine sengine;
int ret = 0;
......@@ -128,12 +127,7 @@ int main(int argc, char *argv[])
global_fmc_dev = dev;
/* Main loop of IRQ demo (until user requests to exit) */
while(!user_stop) {
/* Main logic funtion (get timestamps and process them in the stats engine) */
demo_irq_process_loop(dev, sengine);
/* Check if user has requested to exit */
user_stop = check_user_stop();
}
demo_irq_process_loop(dev, sengine);
/* Exit sequence */
......@@ -161,18 +155,21 @@ static void demo_irq_process_loop(fmc_dio_device fmc_dev, stats_engine engine)
{
struct usr_timestamp *ts;
unsigned int nts;
int user_stop = 0;
int ret;
/* Process loop:
* - Get timestamps from FMC DIO device (specific channel under testing)
* - Pass them to the stats engine and generate the statistics
* - Sleep for a while to avoid excesive CPU consumption
* - Check if user has requested to stop the DEMO
*/
do {
ret = get_utc_ts_from_fmc_dio_device(fmc_dev, TEST_FMC_DIO_CH, &ts, &nts);
process_timestamps_to_engine(engine, ts, nts);
usleep(PROCESS_SLEEP_US);
} while(!ret || ret == -EAGAIN);
user_stop = check_user_stop();
} while(!user_stop);
}
static void process_timestamps_to_engine(stats_engine engine, struct usr_timestamp *ts,
......@@ -245,7 +242,7 @@ static void show_help(void)
printf("\t -p <period> \tSet IRQ period (in nanoseconds)\n");
printf("\t -v \t\tEnable verbose mode\n");
printf("\t -h \t\tShow this help message\n");
printf("Please, press 'q' key or CNTRL+C to exit from the demo tool\n");
printf("Please, press 'q' key + ENTER or CNTRL+C to exit from the demo tool\n");
}
static unsigned int check_user_stop(void)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment