Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
Simple PCIe FMC carrier SPEC - Software
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
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
Simple PCIe FMC carrier SPEC - Software
Commits
0af71323
Commit
0af71323
authored
Sep 20, 2012
by
Alessandro Rubini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tools/wr-dio-cmd.c: pulse time can be fractional
Signed-off-by:
Alessandro Rubini
<
rubini@gnudd.com
>
parent
6534d006
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
7 deletions
+29
-7
wr-dio-cmd.c
tools/wr-dio-cmd.c
+29
-7
No files found.
tools/wr-dio-cmd.c
View file @
0af71323
...
...
@@ -26,7 +26,8 @@ struct wr_dio_cmd *cmd = &_cmd;
static
int
scan_pulse
(
int
argc
,
char
**
argv
)
{
unsigned
long
frac_ns
;
int
n
;
char
*
s
;
int
i
,
n
;
if
(
argc
!=
4
)
{
fprintf
(
stderr
,
"%s: %s: wrong number of arguments
\n
"
,
...
...
@@ -50,9 +51,9 @@ static int scan_pulse(int argc, char **argv)
n
=
9
;
argv
[
2
][
10
]
=
'\0'
;
}
if
(
sscanf
(
argv
[
2
],
".%ld%c"
,
&
frac_ns
,
&
c
)
<
1
)
{
fprintf
(
stderr
,
"%s: %s: not a fraction
\"
%s
\"
\n
"
,
prgname
,
argv
[
0
],
argv
[
2
]);
if
(
sscanf
(
argv
[
2
],
".%ld%c"
,
&
frac_ns
,
&
c
)
!=
1
)
{
fprintf
(
stderr
,
"%s: %s: not a fraction
\"
%s
\"
(please use "
"leading dot)
\n
"
,
prgname
,
argv
[
0
],
argv
[
2
]);
return
-
1
;
}
while
(
n
<
9
)
{
...
...
@@ -63,11 +64,32 @@ static int scan_pulse(int argc, char **argv)
cmd
->
t
[
1
].
tv_nsec
=
frac_ns
;
/* Same problem with the time. But now it's integer only (FIXME) */
sscanf
(
argv
[
3
],
"%ld"
,
&
cmd
->
t
[
0
].
tv_sec
);
if
(
argv
[
3
][
0
]
==
'+'
)
cmd
->
flags
|=
WR_DIO_F_REL
;
frac_ns
=
0
;
if
(
!
strcmp
(
argv
[
3
],
"now"
))
cmd
->
flags
|=
WR_DIO_F_NOW
;
i
=
sscanf
(
argv
[
3
],
"%ld.%ld%c"
,
&
cmd
->
t
[
0
].
tv_sec
,
&
frac_ns
,
&
c
);
if
(
i
!=
1
&&
i
!=
2
&&
!
(
cmd
->
flags
&
WR_DIO_F_NOW
))
{
fprintf
(
stderr
,
"%s: %s: not a time value
\"
%s
\"\n
"
,
prgname
,
argv
[
0
],
argv
[
3
]);
return
-
1
;
}
if
(
i
==
2
)
{
/* FIXME: factorize this scanning of fractions */
s
=
strchr
(
argv
[
3
],
'.'
)
+
1
;
n
=
strlen
(
s
);
if
(
n
>
9
)
{
n
=
9
;
s
[
9
]
=
'\0'
;
}
while
(
n
<
9
)
{
frac_ns
*=
10
;
n
++
;
}
}
cmd
->
t
[
0
].
tv_nsec
=
frac_ns
;
if
(
argv
[
3
][
0
]
==
'+'
)
cmd
->
flags
|=
WR_DIO_F_REL
;
ifr
.
ifr_data
=
(
void
*
)
cmd
;
if
(
ioctl
(
sock
,
PRIV_MEZZANINE_CMD
,
&
ifr
)
<
0
)
{
...
...
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