Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
FMC DEL 1ns 4cha - Software
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
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 - Software
Commits
97a11be1
Commit
97a11be1
authored
May 02, 2012
by
Alessandro Rubini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tools: added fd-raw-settime
parent
d68573e4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
98 additions
and
1 deletion
+98
-1
.gitignore
tools/.gitignore
+1
-0
Makefile
tools/Makefile
+2
-1
fd-raw-settime.c
tools/fd-raw-settime.c
+80
-0
fdelay-raw.h
tools/fdelay-raw.h
+15
-0
No files found.
tools/.gitignore
View file @
97a11be1
fd-raw-input
parport-burst
fd-raw-gettime
fd-raw-settime
tools/Makefile
View file @
97a11be1
...
...
@@ -6,6 +6,7 @@ HOSTCC ?= gcc
hostprogs-y
:=
fd-raw-input
hostprogs-y
+=
fd-raw-gettime
hostprogs-y
+=
fd-raw-settime
hostprogs-y
+=
parport-burst
# we are not in the kernel, so we need to piggy-back on "make modules"
...
...
@@ -19,4 +20,4 @@ module_install:
# we need this as we are out of the kernel
%
:
%.c
$(HOSTCC)
$(HOST_EXTRACFLAGS)
-Wall
$^
-o
$@
$(HOSTCC)
$(HOST_EXTRACFLAGS)
-
O2
-
Wall
$^
-o
$@
tools/fd-raw-settime.c
0 → 100644
View file @
97a11be1
/*
* a tool to set the fdelay time through sysfs
*
* Copyright (C) 2012 CERN (www.cern.ch)
* Author: Alessandro Rubini <rubini@gnudd.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* version 2 as published by the Free Software Foundation or, at your
* option, any later version.
*/
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <unistd.h>
#include <glob.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/select.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <linux/zio.h>
#include <linux/zio-user.h>
#include <fine-delay.h>
#include "fdelay-raw.h"
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
struct
time_word
{
uint32_t
val
;
char
*
name
;
};
struct
time_word
words
[]
=
{
{
0
,
"coarse"
},
{
0
,
"utc-l"
},
{
0
,
"utc-h"
},
/* This must be last, as this forces hardware access */
};
int
main
(
int
argc
,
char
**
argv
)
{
char
*
sysnames
[
10
];
char
path
[
80
];
int
i
,
err
;
if
(
argc
<
2
||
argc
>
3
)
{
fprintf
(
stderr
,
"%s: Use
\"
%s <sec> [<nsec>]
\"\n
"
,
argv
[
0
],
argv
[
0
]);
exit
(
1
);
}
i
=
fdelay_get_sysnames
(
sysnames
);
if
(
!
i
)
{
fprintf
(
stderr
,
"%s: no fine-delay devices
\n
"
,
argv
[
0
]);
exit
(
1
);
}
if
(
i
>
1
)
{
fprintf
(
stderr
,
"%s: several fine-delay devices, using %s
\n
"
,
argv
[
0
],
sysnames
[
0
]);
}
words
[
0
].
val
=
0
;
words
[
1
].
val
=
atoi
(
argv
[
1
]);
/* FIXME: error check */
words
[
2
].
val
=
0
;
if
(
argc
==
3
)
words
[
0
].
val
=
atoi
(
argv
[
2
])
/
8
;
/* FIXME: error check */
for
(
i
=
0
,
err
=
0
;
i
<
ARRAY_SIZE
(
words
);
i
++
)
{
sprintf
(
path
,
"%s/%s"
,
sysnames
[
0
],
words
[
i
].
name
);
if
(
fdelay_sysfs_set
(
path
,
&
words
[
i
].
val
)
!=
0
)
err
++
;
}
if
(
err
)
{
fprintf
(
stderr
,
"%s: got %i errors writing %i attributes
\n
"
,
argv
[
0
],
err
,
ARRAY_SIZE
(
words
));
}
return
0
;
}
tools/fdelay-raw.h
View file @
97a11be1
...
...
@@ -29,3 +29,18 @@ static inline int fdelay_sysfs_get(char *path, uint32_t *resp)
fclose
(
f
);
return
0
;
}
static
inline
int
fdelay_sysfs_set
(
char
*
path
,
uint32_t
*
value
)
{
FILE
*
f
=
fopen
(
path
,
"w"
);
if
(
!
f
)
return
-
1
;
if
(
fprintf
(
f
,
"%i
\n
"
,
*
value
)
<
2
)
{
fclose
(
f
);
errno
=
EINVAL
;
return
-
1
;
}
fclose
(
f
);
return
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