Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
FMC DIO 5ch TTL a
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
6
Issues
6
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
FMC DIO 5ch TTL a
Commits
73914923
Commit
73914923
authored
Oct 09, 2020
by
Miguel Jimenez Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sw: Improve user command line arguments for irq-demo
parent
2dba3f53
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
15 deletions
+37
-15
stats-engine.c
sw/irq-demo/dep/stats-engine.c
+2
-2
stats-engine.h
sw/irq-demo/dep/stats-engine.h
+1
-1
irq-demo-private.h
sw/irq-demo/irq-demo-private.h
+1
-0
irq-demo.c
sw/irq-demo/irq-demo.c
+33
-12
No files found.
sw/irq-demo/dep/stats-engine.c
View file @
73914923
...
...
@@ -80,7 +80,7 @@ int add_usr_timestamp_to_stats_engine(stats_engine engine, struct timespec *ts)
return
0
;
}
int
run_stats_engine
(
stats_engine
engine
)
int
run_stats_engine
(
stats_engine
engine
,
int
verbose
)
{
struct
timespec
ts
;
int
neg
;
...
...
@@ -100,7 +100,7 @@ int run_stats_engine(stats_engine engine)
engine
->
stats
.
ts_per_second
=
count_ts
;
engine
->
stats
.
ts_total
++
;
log_stats_engine
(
engine
,
0
);
log_stats_engine
(
engine
,
verbose
);
update_index_stats_engine
(
&
engine
->
current_ts
);
...
...
sw/irq-demo/dep/stats-engine.h
View file @
73914923
...
...
@@ -27,7 +27,7 @@ int enable_log_for_stats_engine(stats_engine engine);
int
disable_log_for_stats_engine
(
stats_engine
engine
);
int
add_usr_timestamp_to_stats_engine
(
stats_engine
engine
,
struct
timespec
*
ts
);
int
run_stats_engine
(
stats_engine
engine
);
int
run_stats_engine
(
stats_engine
engine
,
int
verbose
);
void
destroy_stats_engine
(
stats_engine
engine
);
#endif
sw/irq-demo/irq-demo-private.h
View file @
73914923
...
...
@@ -22,6 +22,7 @@
struct
_user_args
{
char
*
fmc_dev_path
;
unsigned
int
irq_period
;
int
verbose
;
};
typedef
struct
_user_args
*
user_args
;
...
...
sw/irq-demo/irq-demo.c
View file @
73914923
...
...
@@ -29,6 +29,8 @@
/* Static data for signal handlers */
static
fmc_dio_device
global_fmc_dev
=
NULL
;
/* Global verbose control */
static
int
verbose_mode
=
0
;
/*
* irq-demo /dev/<fmc-device-file> [<irq period>]
...
...
@@ -75,11 +77,13 @@ int main(int argc, char *argv[])
user_arguments
=
create_user_arguments
();
if
(
parse_user_arguments
(
argc
,
argv
,
user_arguments
))
{
/* In case of failure, show the help message and exit */
show_help
();
ret
=
1
;
goto
out_log
;
}
/* Set verbose mode from user command line */
verbose_mode
=
user_arguments
->
verbose
;
/* Create stats engine to compute timestamps metrics (difference, mean, stdev) */
sengine
=
create_stats_engine
();
if
(
check_stats_engine
(
sengine
))
{
...
...
@@ -176,7 +180,7 @@ static void process_timestamps_to_engine(stats_engine engine, struct timespec *t
/* Pass a timestamp to stats engine */
add_usr_timestamp_to_stats_engine
(
engine
,
&
ts
[
i
]);
/* Compute stats taking into consideration all the timestamps inside the engine */
run_stats_engine
(
engine
);
run_stats_engine
(
engine
,
verbose_mode
);
}
/* Finally, free memory for timestamps (reserved by FMC DIO device) */
...
...
@@ -194,15 +198,28 @@ static user_args create_user_arguments(void)
static
int
parse_user_arguments
(
int
argc
,
char
*
argv
[],
user_args
parsed_args
)
{
if
(
argc
!=
2
&&
argc
!=
3
)
return
1
;
parsed_args
->
fmc_dev_path
=
argv
[
1
];
if
(
argc
==
3
)
sscanf
(
argv
[
2
],
"%d"
,
&
parsed_args
->
irq_period
);
else
parsed_args
->
irq_period
=
TEST_FMC_DIO_PERIOD
;
int
opt
;
parsed_args
->
irq_period
=
TEST_FMC_DIO_PERIOD
;
parsed_args
->
verbose
=
0
;
while
((
opt
=
getopt
(
argc
,
argv
,
"hvf:p:"
))
!=
-
1
)
{
switch
(
opt
)
{
case
'f'
:
parsed_args
->
fmc_dev_path
=
optarg
;
break
;
case
'p'
:
sscanf
(
optarg
,
"%d"
,
&
parsed_args
->
irq_period
);
break
;
case
'v'
:
parsed_args
->
verbose
=
1
;
break
;
case
'h'
:
default:
show_help
();
return
1
;
}
}
return
0
;
}
...
...
@@ -216,7 +233,11 @@ static void destroy_user_arguments(user_args args)
static
void
show_help
(
void
)
{
printf
(
"usage: %s <FMC device path> [<irq period (ns)>]
\n
"
,
PROG_NAME
);
printf
(
"%s -f <FMC DIO device path> [options]
\n
"
,
PROG_NAME
);
printf
(
"
\t
-f <path>
\t
Set FMC DIO device path
\n
"
);
printf
(
"
\t
-p <period>
\t
Set IRQ period (in nanoseconds)
\n
"
);
printf
(
"
\t
-v
\t\t
Enable verbose mode
\n
"
);
printf
(
"
\t
-h
\t\t
Show this help message
\n
"
);
}
static
unsigned
int
check_user_stop
(
void
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment