Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
White Rabbit Switch - Software
Manage
Activity
Members
Labels
Plan
Issues
99
Issue boards
Milestones
Wiki
Code
Merge requests
4
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Projects
White Rabbit Switch - Software
Commits
de9072dd
Commit
de9072dd
authored
3 months ago
by
Adam Wujek
Browse files
Options
Downloads
Patches
Plain Diff
userspace/tools/wr_date: add parameter offset_us
Signed-off-by:
Adam Wujek
<
dev_public@wujek.eu
>
parent
a0278400
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
userspace/tools/wr_date.c
+21
-1
21 additions, 1 deletion
userspace/tools/wr_date.c
with
21 additions
and
1 deletion
userspace/tools/wr_date.c
+
21
−
1
View file @
de9072dd
...
...
@@ -50,6 +50,7 @@ static struct wr_nmea nmea;
static
struct
wr_irig
wr_irig
;
static
char
*
opt_cfgfile
=
WRDATE_CFG_FILE
;
static
char
*
prgname
;
static
long
opt_offset_us
=
0
;
void
help
(
void
)
{
...
...
@@ -66,6 +67,9 @@ void help(void)
" baudrate for NMEA (default %d)
\n
"
" -m <GPZDA|GPRMC>
\n
"
" format for NMEA (default %s)
\n
"
" -o <offset_us>
\n
"
" for tohost cmd, add an extra offset in us;
\n
"
" possitive offset means linux time is greater than e.g., WR time
\n
"
" Supported <source> of Time Of Day:
\n
"
" irigb use IRIG-B (NOTE: remember to enable it!)
\n
"
" nmea use NMEA
\n
"
...
...
@@ -254,6 +258,19 @@ int wrdate_get(volatile struct PPSG_WB *pps, int tohost)
hw
.
tv_usec
=
nsec
/
1000
;
}
/* Apply provided offset as parameter */
while
(
hw
.
tv_usec
+
opt_offset_us
>
1000000
)
{
opt_offset_us
-=
1000000
;
hw
.
tv_sec
++
;
}
while
(
hw
.
tv_usec
+
opt_offset_us
<
0
)
{
opt_offset_us
+=
1000000
;
hw
.
tv_sec
--
;
}
hw
.
tv_usec
+=
opt_offset_us
;
if
(
settimeofday
(
&
hw
,
NULL
))
fprintf
(
stderr
,
"wr_date: settimeofday(): %s
\n
"
,
strerror
(
errno
));
...
...
@@ -710,7 +727,7 @@ int main(int argc, char **argv)
prgname
=
argv
[
0
];
while
(
(
c
=
getopt
(
argc
,
argv
,
"fc:b:m:vn"
))
!=
-
1
)
{
while
(
(
c
=
getopt
(
argc
,
argv
,
"fc:b:m:vn
o:
"
))
!=
-
1
)
{
switch
(
c
)
{
case
'f'
:
opt_force
=
1
;
...
...
@@ -727,6 +744,9 @@ int main(int argc, char **argv)
case
'v'
:
opt_verbose
=
1
;
break
;
case
'o'
:
opt_offset_us
=
atol
(
optarg
);
break
;
case
'n'
:
opt_not
=
1
;
printf
(
"Dry run mode: No action will be performed
\n
"
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment