Commit 63201f33 authored by Miguel Jimenez Lopez's avatar Miguel Jimenez Lopez

irq-demo: Use blocking mode for the ioctl() syscall and remove sleep

parent b7887f05
......@@ -261,12 +261,12 @@ static int get_hw_ts_from_fmc_dio_device(fmc_dio_device dev, int ch,
int ret;
c->command = WR_DIO_CMD_STAMP;
c->flags = 0;
c->flags = WR_DIO_F_WAIT;
c->channel = ch;
ret = ioctl(dev->fd, PRIV_MEZZANINE_CMD, (unsigned long) c);
if(ret < 0) {
return -EFAULT;
return ret;
}
if(c->nstamp <= 0) {
......
......@@ -19,19 +19,16 @@
#define TEST_FMC_DIO_COUNT -1
#define TEST_FMC_DIO_PERIOD 100000000
#define STATS_LOG_PATH "./.irq-demo.log"
#define PROCESS_SLEEP_US 100000
#define MAX_FMC_DIO_PATH 100
struct _user_args {
char fmc_dev_path[MAX_FMC_DIO_PATH];
unsigned int irq_period;
unsigned int sleep_period_us;
int verbose;
};
typedef struct _user_args * user_args;
static void demo_irq_process_loop(fmc_dio_device fmc_dev, stats_engine engine,
unsigned int sleep_us);
static void demo_irq_process_loop(fmc_dio_device fmc_dev, stats_engine engine);
static void process_timestamps_to_engine(stats_engine engine, struct usr_timestamp *ts,
unsigned int nts, int last_only);
......
......@@ -127,7 +127,7 @@ int main(int argc, char *argv[])
global_fmc_dev = dev;
/* Main loop of IRQ demo (until user requests to exit) */
demo_irq_process_loop(dev, sengine, user_arguments->sleep_period_us);
demo_irq_process_loop(dev, sengine);
/* Exit sequence */
......@@ -151,8 +151,7 @@ out_log:
return ret;
}
static void demo_irq_process_loop(fmc_dio_device fmc_dev, stats_engine engine,
unsigned int sleep_us)
static void demo_irq_process_loop(fmc_dio_device fmc_dev, stats_engine engine)
{
struct usr_timestamp *ts;
unsigned int nts;
......@@ -160,9 +159,8 @@ static void demo_irq_process_loop(fmc_dio_device fmc_dev, stats_engine engine,
int ret;
/* Process loop:
* - Get timestamps from FMC DIO device (specific channel under testing)
* - Blocking: 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 {
......@@ -171,7 +169,6 @@ static void demo_irq_process_loop(fmc_dio_device fmc_dev, stats_engine engine,
// Use only the last TS for stats
process_timestamps_to_engine(engine, ts, nts, 1);
}
usleep(sleep_us);
user_stop = check_user_stop();
} while(!user_stop);
}
......@@ -212,7 +209,6 @@ static int parse_user_arguments(int argc, char *argv[], user_args parsed_args)
int opt;
parsed_args->irq_period = TEST_FMC_DIO_PERIOD;
parsed_args->sleep_period_us = PROCESS_SLEEP_US;
parsed_args->verbose = 0;
if(argc == 1) {
......@@ -220,7 +216,7 @@ static int parse_user_arguments(int argc, char *argv[], user_args parsed_args)
return 1;
}
while((opt = getopt(argc, argv, "hvf:p:s:")) != -1) {
while((opt = getopt(argc, argv, "hvf:p:")) != -1) {
switch(opt) {
case 'f':
strncpy(parsed_args->fmc_dev_path, optarg, MAX_FMC_DIO_PATH-1);
......@@ -228,9 +224,6 @@ static int parse_user_arguments(int argc, char *argv[], user_args parsed_args)
case 'p':
sscanf(optarg, "%d", &parsed_args->irq_period);
break;
case 's':
sscanf(optarg, "%d", &parsed_args->sleep_period_us);
break;
case 'v':
parsed_args->verbose = 1;
break;
......@@ -261,7 +254,6 @@ static void show_help(void)
printf("%s -f <FMC DIO device path> [options]\n", PROG_NAME);
printf("\t -f <path> \tSet FMC DIO device path\n");
printf("\t -p <period> \tSet IRQ period (in nanoseconds)\n");
printf("\t -s <sleep us> \tSet Sleep period in microseconds\n");
printf("\t -v \t\tEnable verbose mode\n");
printf("\t -h \t\tShow this help message\n");
printf("Please, press 'q' key + ENTER or CNTRL+C to exit from the demo tool\n");
......
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