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
50
Issues
50
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
c8fd61ad
Commit
c8fd61ad
authored
Apr 20, 2015
by
Alessandro Rubini
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'wrs-4.1.2-fixes-rebased'
parents
0250bb3b
4179fcdc
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
16 deletions
+46
-16
wr-servo.c
proto-ext-whiterabbit/wr-servo.c
+2
-1
common-fun.h
proto-standard/common-fun.h
+2
-0
state-master.c
proto-standard/state-master.c
+7
-5
wrs-socket.c
time-wrs/wrs-socket.c
+35
-10
No files found.
proto-ext-whiterabbit/wr-servo.c
View file @
c8fd61ad
...
...
@@ -268,6 +268,8 @@ int wr_servo_update(struct pp_instance *ppi)
got_sync
=
0
;
s
->
mu
=
ts_sub
(
ts_sub
(
s
->
t4
,
s
->
t1
),
ts_sub
(
s
->
t3
,
s
->
t2
));
if
(
__PP_DIAG_ALLOW
(
ppi
,
pp_dt_servo
,
1
))
{
dump_timestamp
(
ppi
,
"servo:t1"
,
s
->
t1
);
dump_timestamp
(
ppi
,
"servo:t2"
,
s
->
t2
);
...
...
@@ -276,7 +278,6 @@ int wr_servo_update(struct pp_instance *ppi)
dump_timestamp
(
ppi
,
"->mdelay"
,
s
->
mu
);
}
s
->
mu
=
ts_sub
(
ts_sub
(
s
->
t4
,
s
->
t1
),
ts_sub
(
s
->
t3
,
s
->
t2
));
s
->
picos_mu
=
ts_to_picos
(
s
->
mu
);
big_delta_fix
=
s
->
delta_tx_m
+
s
->
delta_tx_s
+
s
->
delta_rx_m
+
s
->
delta_rx_s
;
...
...
proto-standard/common-fun.h
View file @
c8fd61ad
...
...
@@ -49,6 +49,8 @@ static inline int __send_and_log(struct pp_instance *ppi, int msglen,
(
int
)(
ppi
->
last_snt_time
.
seconds
),
(
int
)(
ppi
->
last_snt_time
.
nanoseconds
),
pp_msg_names
[
msgtype
]);
if
(
ppi
->
last_snt_time
.
correct
==
0
)
return
-
1
;
return
0
;
}
...
...
proto-standard/state-master.c
View file @
c8fd61ad
...
...
@@ -25,20 +25,22 @@ int pp_master(struct pp_instance *ppi, unsigned char *pkt, int plen)
}
if
(
pp_timeout_z
(
ppi
,
PP_TO_SYNC
))
{
/* Restart the timeout for next time */
pp_timeout_rand
(
ppi
,
PP_TO_SYNC
,
DSPOR
(
ppi
)
->
logSyncInterval
);
if
((
e
=
msg_issue_sync_followup
(
ppi
)
<
0
))
goto
out
;
/* Restart the timeout for next time */
pp_timeout_rand
(
ppi
,
PP_TO_SYNC
,
DSPOR
(
ppi
)
->
logSyncInterval
);
}
if
(
pp_timeout_z
(
ppi
,
PP_TO_ANN_INTERVAL
))
{
if
((
e
=
msg_issue_announce
(
ppi
)
<
0
))
goto
out
;
/* Restart the timeout for next time */
pp_timeout_rand
(
ppi
,
PP_TO_ANN_INTERVAL
,
DSPOR
(
ppi
)
->
logAnnounceInterval
);
if
((
e
=
msg_issue_announce
(
ppi
)
<
0
))
goto
out
;
}
if
(
plen
==
0
)
...
...
time-wrs/wrs-socket.c
View file @
c8fd61ad
...
...
@@ -11,6 +11,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <poll.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
...
...
@@ -274,11 +275,10 @@ int wrs_net_recv(struct pp_instance *ppi, void *pkt, int len,
}
/* Waits for the transmission timestamp and stores it in t (if not null). */
static
void
poll_tx_timestamp
(
struct
pp_instance
*
ppi
,
static
void
poll_tx_timestamp
(
struct
pp_instance
*
ppi
,
void
*
pkt
,
int
len
,
struct
wrs_socket
*
s
,
int
fd
,
TimeInternal
*
t
)
{
char
data
[
16384
];
struct
msghdr
msg
;
struct
iovec
entry
;
struct
sockaddr_ll
from_addr
;
...
...
@@ -287,7 +287,8 @@ static void poll_tx_timestamp(struct pp_instance *ppi,
char
control
[
1024
];
}
control
;
struct
cmsghdr
*
cmsg
;
int
res
;
struct
pollfd
pfd
;
int
res
,
retry
=
0
;;
struct
sock_extended_err
*
serr
=
NULL
;
struct
scm_timestamping
*
sts
=
NULL
;
...
...
@@ -302,12 +303,36 @@ static void poll_tx_timestamp(struct pp_instance *ppi,
msg
.
msg_control
=
&
control
;
msg
.
msg_controllen
=
sizeof
(
control
);
res
=
recvmsg
(
fd
,
&
msg
,
MSG_ERRQUEUE
);
if
(
t
)
t
->
correct
=
0
;
if
(
t
)
/* poison the stamp */
t
->
seconds
=
t
->
correct
=
0
;
pfd
.
fd
=
fd
;
pfd
.
events
=
POLLIN
;
while
(
1
)
{
/* Not forever: we break after a few runs */
errno
=
0
;
res
=
poll
(
&
pfd
,
1
,
20
/* ms */
);
if
(
res
!=
1
)
{
pp_diag
(
ppi
,
time
,
1
,
"%s: poll() = %i (%s)
\n
"
,
__func__
,
res
,
strerror
(
errno
));
return
;
}
if
(
res
<=
0
||
!
t
)
res
=
recvmsg
(
fd
,
&
msg
,
MSG_ERRQUEUE
);
if
(
res
<=
0
)
{
pp_diag
(
ppi
,
time
,
1
,
"%s: recvmsg() = %i (%s)
\n
"
,
__func__
,
res
,
strerror
(
errno
));
return
;
}
/* Now, check if this frame is our frame. If not, retry */
if
(
!
memcmp
(
data
,
pkt
,
len
))
break
;
pp_diag
(
ppi
,
time
,
1
,
"%s: recvmsg(): not our frame
\n
"
,
__func__
);
/* We won't pop out wrong stamps forever... */
if
(
retry
++
>
5
)
return
;
}
if
(
!
t
)
/* maybe caller is not interested, though we popped it out */
return
;
/*
...
...
@@ -373,7 +398,7 @@ int wrs_net_send(struct pp_instance *ppi, void *pkt, int len,
ppi
->
t_ops
->
get
(
ppi
,
t
);
ret
=
send
(
fd
,
hdr
,
len
,
0
);
poll_tx_timestamp
(
ppi
,
s
,
fd
,
t
);
poll_tx_timestamp
(
ppi
,
pkt
,
len
,
s
,
fd
,
t
);
if
(
drop
)
/* avoid messaging about stamps that are not used */
goto
drop_msg
;
...
...
@@ -395,7 +420,7 @@ int wrs_net_send(struct pp_instance *ppi, void *pkt, int len,
addr
.
sin_port
=
3200
;
ret
=
sendto
(
fd
,
pkt
,
len
,
0
,
(
struct
sockaddr
*
)
&
addr
,
sizeof
(
struct
sockaddr_in
));
poll_tx_timestamp
(
ppi
,
s
,
fd
,
t
);
poll_tx_timestamp
(
ppi
,
pkt
,
len
,
s
,
fd
,
t
);
if
(
drop
)
/* like above: skil messages about timestamps */
goto
drop_msg
;
...
...
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