Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
FMC DEL 1ns 4cha
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
2
Issues
2
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 DEL 1ns 4cha
Commits
25f5c310
Commit
25f5c310
authored
Mar 24, 2014
by
Tomasz Wlostowski
Committed by
Alessandro Rubini
Mar 24, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tools: report output config/status in both human and raw mode, depending on command line switch
parent
a42d06be
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
15 deletions
+60
-15
fmc-fdelay-status.c
tools/fmc-fdelay-status.c
+31
-12
tools-util.c
tools/tools-util.c
+29
-3
No files found.
tools/fmc-fdelay-status.c
View file @
25f5c310
...
...
@@ -13,7 +13,7 @@ void help(char *name)
fprintf
(
stderr
,
"fmc-fdelay-status: reports channel programming
\n
"
);
fprintf
(
stderr
,
"Use:
\"
%s [-i <index>] [-d <dev>] [-r]
\"\n
"
,
name
);
fprintf
(
stderr
,
"
-r: display raw devic
e configuration"
);
fprintf
(
stderr
,
"
-r: display raw hardwar
e configuration"
);
exit
(
1
);
}
...
...
@@ -21,8 +21,7 @@ int main(int argc, char **argv)
{
struct
fdelay_board
*
b
;
struct
fdelay_pulse
p
;
int
nboards
,
ch
,
index
=
-
1
,
dev
=
-
1
;
int
nboards
,
ch
,
index
=
-
1
,
dev
=
-
1
,
raw
=
0
,
opt
;
/* Standard part of the file (repeated code) */
if
(
tools_need_help
(
argc
,
argv
))
...
...
@@ -42,7 +41,34 @@ int main(int argc, char **argv)
if
(
nboards
==
1
)
index
=
0
;
/* so it works with no arguments */
tools_getopt_d_i
(
argc
,
argv
,
&
dev
,
&
index
);
while
((
opt
=
getopt
(
argc
,
argv
,
"i:d:rh"
))
!=
-
1
)
{
char
*
rest
;
switch
(
opt
)
{
case
'i'
:
index
=
strtol
(
optarg
,
&
rest
,
0
);
if
(
rest
&&
*
rest
)
{
fprintf
(
stderr
,
"%s: Not a number
\"
%s
\"\n
"
,
argv
[
0
],
optarg
);
exit
(
1
);
}
break
;
case
'd'
:
dev
=
strtol
(
optarg
,
&
rest
,
0
);
if
(
rest
&&
*
rest
)
{
fprintf
(
stderr
,
"%s: Not a number
\"
%s
\"\n
"
,
argv
[
0
],
optarg
);
exit
(
1
);
}
break
;
case
'r'
:
raw
=
1
;
break
;
case
'h'
:
help
(
argv
[
0
]);
exit
(
0
);
}
}
if
(
index
<
0
&&
dev
<
0
)
{
fprintf
(
stderr
,
"%s: several boards, please pass -i or -d
\n
"
,
...
...
@@ -50,11 +76,6 @@ int main(int argc, char **argv)
exit
(
1
);
}
/* Error if too many arguments */
if
(
optind
!=
argc
)
help
(
argv
[
0
]);
b
=
fdelay_open
(
index
,
dev
);
if
(
!
b
)
{
fprintf
(
stderr
,
"%s: fdelay_open(): %s
\n
"
,
argv
[
0
],
...
...
@@ -70,9 +91,7 @@ int main(int argc, char **argv)
}
/* pass hw number again, as the function is low-level */
report_output_config
(
FDELAY_OUTPUT_USER_TO_HW
(
ch
),
&
p
,
TOOLS_UMODE_USER
);
// tools_report_action(FDELAY_OUTPUT_USER_TO_HW(ch),
// &p, TOOLS_UMODE_RAW);
&
p
,
raw
?
TOOLS_UMODE_RAW
:
TOOLS_UMODE_USER
);
}
fdelay_close
(
b
);
fdelay_exit
();
...
...
tools/tools-util.c
View file @
25f5c310
...
...
@@ -99,6 +99,8 @@ static struct fdelay_time fd_ts_sub(struct fdelay_time a, struct fdelay_time b)
rv
.
utc
=
u
;
rv
.
coarse
=
c
;
rv
.
frac
=
f
;
rv
.
seq_id
=
0
;
rv
.
channel
=
0
;
return
rv
;
}
...
...
@@ -128,7 +130,7 @@ static void report_output_config_human(int channel, struct fdelay_pulse *p)
}
if
(
p
->
mode
&
0x80
)
printf
(
"(triggered) "
);
printf
(
"
(triggered) "
);
tools_report_time
(
m
==
FD_OUT_MODE_DELAY
?
"
\n
delay: "
:
"
\n
start at: "
,
&
p
->
start
,
TOOLS_UMODE_USER
);
...
...
@@ -138,21 +140,45 @@ static void report_output_config_human(int channel, struct fdelay_pulse *p)
if
(
p
->
rep
!=
1
)
{
printf
(
" repeat: "
);
printf
(
" repeat: "
);
if
(
p
->
rep
==
-
1
)
printf
(
"infinite
\n
"
);
else
printf
(
"%d times
\n
"
,
p
->
rep
);
tools_report_time
(
" period: "
,
&
p
->
loop
,
TOOLS_UMODE_USER
);
tools_report_time
(
" period: "
,
&
p
->
loop
,
TOOLS_UMODE_USER
);
}
}
void
report_output_config_raw
(
int
channel
,
struct
fdelay_pulse
*
p
,
int
umode
)
{
char
mode
[
80
];
int
m
=
p
->
mode
&
0x7f
;
if
(
m
==
FD_OUT_MODE_DISABLED
)
strcpy
(
mode
,
"disabled"
);
else
if
(
m
==
FD_OUT_MODE_PULSE
)
strcpy
(
mode
,
"pulse"
);
else
if
(
m
==
FD_OUT_MODE_DELAY
)
strcpy
(
mode
,
"delay"
);
else
sprintf
(
mode
,
"%i (0x%04x)"
,
p
->
mode
,
p
->
mode
);
if
(
p
->
mode
&
0x80
)
strcat
(
mode
,
" (triggered)"
);
printf
(
"Channel %i, mode %s, repeat %i %s
\n
"
,
FDELAY_OUTPUT_HW_TO_USER
(
channel
),
mode
,
p
->
rep
,
p
->
rep
==
-
1
?
"(infinite)"
:
""
);
tools_report_time
(
"start"
,
&
p
->
start
,
umode
);
tools_report_time
(
"end "
,
&
p
->
end
,
umode
);
tools_report_time
(
"loop "
,
&
p
->
loop
,
umode
);
}
void
report_output_config
(
int
channel
,
struct
fdelay_pulse
*
p
,
int
umode
)
{
switch
(
umode
)
{
case
TOOLS_UMODE_USER
:
report_output_config_human
(
channel
,
p
);
break
;
case
TOOLS_UMODE_RAW
:
case
TOOLS_UMODE_FLOAT
:
report_output_config_raw
(
channel
,
p
,
umode
);
default:
break
;
}
...
...
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