Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
P
PPSi
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
47
Issues
47
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
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
PPSi
Commits
55ef8b55
Commit
55ef8b55
authored
Dec 03, 2016
by
Alessandro Rubini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: the heuristics for wrs no-wr slave were not ok
Signed-off-by:
Alessandro Rubini
<
rubini@gnudd.com
>
parent
289371e7
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
11 deletions
+23
-11
wrs-time.c
time-wrs/wrs-time.c
+23
-11
No files found.
time-wrs/wrs-time.c
View file @
55ef8b55
...
...
@@ -217,9 +217,10 @@ static int wrs_time_get(struct pp_instance *ppi, TimeInternal *t)
static
int
wrs_time_set
(
struct
pp_instance
*
ppi
,
TimeInternal
*
t
)
{
TimeInternal
diff
;
TimeInternal
diff
,
now
;
struct
timex
tx
;
int
tai_offset
=
0
;
int
msec
;
/*
* This is almost unused in ppsi, only proto-standard/servo.c
...
...
@@ -232,29 +233,40 @@ static int wrs_time_set(struct pp_instance *ppi, TimeInternal *t)
/*
* We say "weird" because we are not expected to set time here;
* rather, time setting goes usually from the WR servo, straight
* to the HAL process, where a difference is injected into the fpga
;
*
rather then "setting" an absolute time, which we can't do
*
and thus T3 is referenced below, to get some approximate value..
.
* to the HAL process, where a difference is injected into the fpga
.
*
We are only asked to set a time when slave of non-wr (and
*
normal servo drives us). So get time to calc a rough difference
.
*/
pp_diag
(
ppi
,
time
,
1
,
"%s: (weird) %9li.%09li
\n
"
,
__func__
,
(
long
)
t
->
seconds
,
(
long
)
t
->
nanoseconds
);
/* We have no way to get the WR time, currently. So use our T3 */
sub_TimeInternal
(
&
diff
,
t
,
&
ppi
->
t3
);
wrdate_get
(
&
now
);
sub_TimeInternal
(
&
diff
,
t
,
&
now
);
pp_diag
(
ppi
,
time
,
1
,
"%s: (weird) %9li.%09li - delta %9li.%09li
\n
"
,
__func__
,
(
long
)
t
->
seconds
,
(
long
)
t
->
nanoseconds
,
(
long
)
diff
.
seconds
,
(
long
)
diff
.
nanoseconds
);
/*
* We can adjust nanoseconds or seconds, but not both at the
* same time. When an adjustment is in progress we can't do
* the other. So make nanoseconds first if >
1
0ms, and the
* the other. So make nanoseconds first if >
2
0ms, and the
* servo will call us again later for the seconds part.
* Thus, we fall near, and can then trim frequency (hopefully).
*/
if
(
abs
(
diff
.
nanoseconds
)
>
10
*
1000
*
1000
)
{
msec
=
diff
.
nanoseconds
/
1000
/
1000
;;
#define THRESHOLD_MS 20
if
((
msec
>
THRESHOLD_MS
&&
msec
<
(
1000
-
THRESHOLD_MS
))
||
(
msec
<
-
THRESHOLD_MS
&&
msec
>
(
-
1000
+
THRESHOLD_MS
)))
{
pp_diag
(
ppi
,
time
,
1
,
"%s: adjusting nanoseconds: %li
\n
"
,
__func__
,
(
long
)
diff
.
nanoseconds
);
diff
.
seconds
=
0
;
}
else
{
diff
.
nanoseconds
=
0
;
if
(
msec
>
500
)
diff
.
seconds
++
;
if
(
msec
<
-
500
)
diff
.
seconds
--
;
pp_diag
(
ppi
,
time
,
1
,
"%s: adjusting seconds: %li
\n
"
,
__func__
,
(
long
)
diff
.
seconds
);
diff
.
nanoseconds
=
0
;
}
wrs_adjust_counters
(
diff
.
seconds
,
diff
.
nanoseconds
);
...
...
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