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
fcc4ec48
Commit
fcc4ec48
authored
Dec 09, 2011
by
Aurelio Colosimo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implementation of posix-timer
parent
39ed260c
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
62 additions
and
25 deletions
+62
-25
posix-timer.c
arch-gnu-linux/posix-timer.c
+45
-15
constants.h
include/pproto/constants.h
+1
-1
pproto.h
include/pproto/pproto.h
+15
-8
state-initializing.c
proto-standard/state-initializing.c
+1
-1
No files found.
arch-gnu-linux/posix-timer.c
View file @
fcc4ec48
...
...
@@ -7,43 +7,76 @@
#include <sys/time.h>
#include <unistd.h>
#include <errno.h>
#include <stdlib.h>
#include <pproto/pproto.h>
#include <pproto/diag.h>
#include "posix.h"
extern
int
posix_timer_init
(
struct
pp_timer
*
tm
)
/* FIXME
* In ptpd-2.1.0/src/dep/timer.c the mechanism was different.
* A SIGALARM timer was called once a second, increasing the counter of elapsed
* time.
* I find it easier to check for the timestamp when needed. The granularity of
* this timer is the same as the ptpd solution: 1 second.
* Should be checked if this is enough, but I guess yes.
* Maybe a certain SIGALARM timer solution must be re-introduced, because the
* select in the main loop must exit when a timer elapses. To be checked
*/
extern
int
posix_timer_init
(
struct
pp_instance
*
ppi
)
{
/* TODO */
struct
pp_timer
*
t
;
int
i
;
for
(
i
=
0
;
i
<
PP_TIMER_ARRAY_SIZE
;
i
++
)
{
t
=
calloc
(
1
,
sizeof
(
*
t
));
if
(
!
t
)
return
0
;
}
extern
int
posix_timer_start
(
struct
pp_timer
*
tm
)
{
/* TODO */
ppi
->
timers
[
i
]
=
t
;
}
return
0
;
}
extern
int
posix_timer_stop
(
struct
pp_timer
*
tm
)
extern
int
posix_timer_start
(
uint32_t
interval
,
struct
pp_timer
*
tm
)
{
/* TODO */
pp_get_stamp
(
&
tm
->
start
);
tm
->
interval
=
interval
;
return
0
;
}
extern
int
posix_timer_
update
(
struct
pp_timer
*
tm
)
extern
int
posix_timer_
stop
(
struct
pp_timer
*
tm
)
{
/* TODO */
tm
->
interval
=
0
;
tm
->
start
=
0
;
return
0
;
}
extern
int
posix_timer_expired
(
struct
pp_timer
*
tm
)
{
/* TODO */
uint32_t
now
;
if
(
tm
->
start
==
0
)
{
/* FIXME: print a warning message */
return
0
;
}
pp_get_stamp
(
&
now
);
if
(
tm
->
start
+
tm
->
interval
<
now
)
return
1
;
return
0
;
}
int
pp_timer_init
(
struct
pp_
timer
*
tm
)
int
pp_timer_init
(
struct
pp_
instance
*
ppi
)
__attribute__
((
alias
(
"posix_timer_init"
)));
int
pp_timer_start
(
struct
pp_timer
*
tm
)
...
...
@@ -52,8 +85,5 @@ int pp_timer_start(struct pp_timer *tm)
int
pp_timer_stop
(
struct
pp_timer
*
tm
)
__attribute__
((
alias
(
"posix_timer_stop"
)));
int
pp_timer_update
(
struct
pp_timer
*
tm
)
__attribute__
((
alias
(
"posix_timer_update"
)));
int
pp_timer_expired
(
struct
pp_timer
*
tm
)
__attribute__
((
alias
(
"posix_timer_expired"
)));
include/pproto/constants.h
View file @
fcc4ec48
...
...
@@ -32,12 +32,12 @@
#define PP_DEFAULT_MAX_FOREIGN_RECORDS 5
#define PP_DEFAULT_PARENTS_STATS 0
/* FIXME: check if the following defines are really useful */
#define PP_TIMER_PDELAYREQ_INTERVAL 0
#define PP_TIMER_DELAYREQ_INTERVAL 1
#define PP_TIMER_SYNC_INTERVAL 2
#define PP_TIMER_ANNOUNCE_RECEIPT 3
#define PP_TIMER_ANNOUNCE_INTERVAL 4
#define PP_TIMER_ARRAY_SIZE 5
#define PP_TWO_STEP_FLAG 2
#define PP_VERSION_PTP 2
...
...
include/pproto/pproto.h
View file @
fcc4ec48
...
...
@@ -65,6 +65,17 @@ struct pp_channel {
unsigned
char
peer
[
6
];
/* Our peer's MAC address */
};
/*
* Timer
*/
struct
pp_timer
{
uint32_t
start
;
uint32_t
interval
;
};
/*
* Structure for the standard protocol
*/
...
...
@@ -82,6 +93,7 @@ struct pp_instance {
DSParent
*
parentDS
;
DSPort
*
portDS
;
DSTimeProperties
*
timePropertiesDS
;
struct
pp_timer
*
timers
[
PP_TIMER_ARRAY_SIZE
];
};
...
...
@@ -100,17 +112,12 @@ extern int pp_net_shutdown(struct pp_instance *ppi);
extern
int
pp_recv_packet
(
struct
pp_instance
*
ppi
,
void
*
pkt
,
int
len
);
extern
int
pp_send_packet
(
struct
pp_instance
*
ppi
,
void
*
pkt
,
int
len
);
/* Timer stuff */
struct
pp_timer
{
int
dummy
;
/* FIXME */
};
extern
int
pp_timer_init
(
struct
pp_timer
*
tm
);
extern
int
pp_timer_init
(
struct
pp_instance
*
ppi
);
/* initializes timer common
structure */
extern
int
pp_timer_start
(
struct
pp_timer
*
tm
);
extern
int
pp_timer_stop
(
struct
pp_timer
*
tm
);
extern
int
pp_timer_update
(
struct
pp_timer
*
tm
);
extern
int
pp_timer_expired
(
struct
pp_timer
*
tm
);
extern
int
pp_timer_expired
(
struct
pp_timer
*
tm
);
/* returns 1 when expired */
/* Get a timestamp */
...
...
proto-standard/state-initializing.c
View file @
fcc4ec48
...
...
@@ -47,7 +47,7 @@ int pp_initializing(struct pp_instance *ppi, unsigned char *pkt, int plen)
ppi
->
portDS
->
logMinPdelayReqInterval
=
PP_DEFAULT_PDELAYREQ_INTERVAL
;
ppi
->
portDS
->
versionNumber
=
PP_VERSION_PTP
;
if
(
pp_timer_init
(
0
))
/* FIXME */
if
(
pp_timer_init
(
ppi
))
goto
failure
;
/* TODO Check the following code coming from ptpd.
...
...
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