W
-----------------------------------------------------------
Got questions? Get answers over the phone at Keen.com.
Up to 100 minutes free!
http://www.keen.com
struct timespec tm;
/* Make sure we have a default route set */
routeAdd ("0", DEFAULT_GATEWAY);
/* Set the time */
for (i=0; i < NUM_RETRIES; i++)
{
if (sntpcTimeGet (TIME_SERVER, sysClkRateGet() * 5, &tm) == OK)
{
break;
}
}
That gets you a timespec structure from the server. After that you'll
need to cope with time zones etc to get the VxWorks clock set correctly.
HTH,
John...
In article <311c2be6...@usw-ex0106-045.remarq.com>,
Sent via Deja.com http://www.deja.com/
Before you buy.
I think if you started from the NTP v3 sources, you'd be OK. If you
want v4 (current release) then either go at it yourself, or wait till
I'm done. I'm trying to port v4 now. If you want to go at it
yourself, you can start with the vxworks port information in the NTP
distribution, but there are a significant number of small changes that
have to be made. Additionally, code has to be added to the kernel to
support NTP; specifically a PLL/FLL as shown in the kernel and
nanokernel tar files on UDel.
For more information, try comp.protocols.time.ntp,
http://www.eecis.udel.edu/~ntp/, and/or the 'hackers' and 'bugs' mail
lists at majo...@ntp.org
If you're serious about starting immediately, then I'll send you a
list of changes to make from the 4.0.99j distribution but it's still a
work-in-progress.
Bryan
"Warren.Brown" wrote:
>
> Hello
> Has anyone added the NTP (Network Time Protocol) client
> services to a VxWorks embedded target ?
> Any hints as to the right steps to take ?
>
> W
>
> -----------------------------------------------------------
>
> Got questions? Get answers over the phone at Keen.com.
> Up to 100 minutes free!
> http://www.keen.com
--
Bryan D. Lee Phone: 603/885-7025
Software Engineer & ELDP Fax : 603/885-3016
Sanders-A Lockheed Martin Company Pager: 603/423-5565
PO Box 868, PTP1-2361, Nashua, NH 03061 Email: bryan...@lmco.com
>If you want v4 (current release) then either go at it yourself, or wait till
>I'm done. I'm trying to port v4 now.
I also am interested in having an NTP-client under VxWorks. From your posting,
I'm assuming that you will be making the results of your efforts public. I'll
be looking forward to it. I suspect many others will, too.
When do you think that you will have a version to release? How will you
announce its availability, and where will you be posting it?
Thank you.
--
Todd Litwin
Jet Propulsion Laboratory
(818) 354-5028
Todd.E...@jpl.nasa.gov
I'll post info here when I'm done and the changes will be submitted to
the main NTP CVS tree on UDel.
At the moment, the Phase Locked Loop and Freq Locked Loop for slaving
the time within the kernel is driving me up a wall, so it'll be a
while on that score. And you/I would need this for PPS
synchronization or to discipline the clock to a tighter tolerance. It
touches on the stuff I've already modified, hence why I haven't
released the stuff I've done so far.
Bryan
--
Bryan
john_...@my-deja.com wrote:
>
> Add the INCLUDE_SNTPC component to the kernel, then do something like
> this in your application:
>
> struct timespec tm;
>
> /* Make sure we have a default route set */
>
> routeAdd ("0", DEFAULT_GATEWAY);
>
> /* Set the time */
>
> for (i=0; i < NUM_RETRIES; i++)
> {
> if (sntpcTimeGet (TIME_SERVER, sysClkRateGet() * 5, &tm) == OK)
> {
> break;
> }
> }
>
> That gets you a timespec structure from the server. After that you'll
> need to cope with time zones etc to get the VxWorks clock set correctly.
>
> HTH,
>
> John...
>
> In article <311c2be6...@usw-ex0106-045.remarq.com>,
> Warren.Brown <wbrownN...@foxboro.com.invalid> wrote:
> > Hello
> > Has anyone added the NTP (Network Time Protocol) client
> > services to a VxWorks embedded target ?
> > Any hints as to the right steps to take ?
> >
> > W
> >
> > -----------------------------------------------------------
> >
> > Got questions? Get answers over the phone at Keen.com.
> > Up to 100 minutes free!
> > http://www.keen.com
> >
> >
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
--
Bryan,
Tornado 2.0 (vxWorks 5.4) includes a Simple NTP Client, but it only seems
to provide one-shot "what time is it now" or "come back when you next see
an NTP broadcast" functionality and AFAIK doesn't try to correct for
network delays or interface to the vxWorks clock. It sounds like the
solution you're working in is a lot more comprehensive.
Wasn't there a port of xntp available for vxWorks several years ago
though?
- Andrew
--
Sharks kill 10 people each year. People kill 60,000,000 sharks each year.
It looked from the code fragment that it was a one-shot deal. And
what I'm working on now ought to allow continuous fine adjustments
with or without a 1-PPS signal as if the board is another computer NTP
client/server. Besides we didn't have any intention of upgrading to
v5.4 any time soon and this ought to work on earlier vxworks
versions. I'm not doing anything Tornado specific.
And yes there was/is an xntpd port from v3 sources, I believe.
For better or worse I started from the v4 sources.
Bryan
--
: Wasn't there a port of xntp available for vxWorks several years ago
: though?
There is a file called xntp-3.4y.tar.Z available on
ftp://ftp.atd.ucar.edu/pub/vxworks/vx/
Groeten,
Johan
--
o o o o o o o . . . ___________________________________
o _____ || Johan Borkhuis |
.][__n_n_|DD[ ====_____ | jo...@borksoft.xs4all.nl |
>(________|__|_[_________]_|________________________________|
_/oo OOOOO oo` ooo ooo 'o!o!o o!o!o`
=== VxWorks FAQ: http://www.xs4all.nl/~borkhuis/vxworks/vxworks.html ===
Here you go. Sync("18.72.0.3");
struct {
unsigned char livnmode, stratum, poll, prec;
unsigned long delay, disp, refid;
unsigned long reftime[2], origtime[2], rcvtime[2], txtime[2];
} pkt;
#define PORT 123
#define MY_OFFSET 2208988800L
/* Sync the time */
int
Sync(char *hostname)
{
int i, fd = -1, len, n, zonemin;
struct sockaddr_in saddr, myaddr;
struct hostent *hp;
char answer[2000];
unsigned long myt;
long offset;
fd_set readfds;
struct timeval tv;
/* Get server name */
n = strlen(hostname);
if (n <= 0) {
perror("hostname");
return 0;
}
sprintf(answer, "Connecting to %s\n", hostname);
printf(answer);
/* Resolve server name */
bzero((char *)&saddr, sizeof saddr);
saddr.sin_family = AF_INET;
saddr.sin_port = htons(PORT);
if ((saddr.sin_addr.s_addr = inet_addr(hostname)) == ERROR) {
perror("unknown server");
return 0;
}
sprintf(answer, "Hostname resolved, getting the socket\n");
printf(answer);
/* Get a socket */
if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
perror("socket");
return 0;
}
sprintf(answer, "Got socket, bind to port\n");
printf(answer);
/* Bind it to some port */
bzero((char *)&myaddr, sizeof myaddr);
myaddr.sin_family = AF_INET;
myaddr.sin_port = htons(3030);
myaddr.sin_addr.s_addr = INADDR_ANY;
if (bind(fd, (struct sockaddr *) &myaddr, sizeof myaddr) < 0) {
perror("bind error");
close(fd);
return 0;
}
/* Fill in the request packet */
bzero((char *)&pkt, sizeof pkt);
pkt.livnmode = 0x0b; /* version 1, mode 3 (client) */
sprintf(answer, "Send packet\n");
printf(answer);
/* Send packet to server */
if ((n = sendto(fd,
(char *)&pkt, sizeof pkt, 0,
(struct sockaddr *) &saddr,
sizeof saddr)) != sizeof pkt) {
sprintf(answer, "sendto %d err %d", n, errno);
perror(answer);
close(fd);
return 0;
}
sprintf(answer, "Wait for reply\n");
printf(answer);
/* Read reply packet from server */
len = sizeof pkt;
FD_SET(fd, &readfds);
tv.tv_sec = 5;
tv.tv_usec = 0;
if(select(fd+1, &readfds, NULL, NULL, &tv)){
if ((n = recvfrom(fd,
(char *)&pkt, sizeof pkt, 0,
(struct sockaddr *) &saddr,
&len)) != sizeof pkt) {
sprintf(answer, "recvfrom %d err %d", n, errno);
perror(answer);
close(fd);
return 0;
}
}
else {
perror("Timeout");
close(fd);
return 0;
}
sprintf(answer, "Sanitu check\n");
printf(answer);
/* Sanity checks */
if ((pkt.livnmode & 0xc0) == 0xc0 || !pkt.stratum || !pkt.txtime[0]) {
perror("server not synchronized");
close(fd);
return 0;
}
/*
* NTP timestamps are represented as a 64-bit unsigned fixed-
* point number, in seconds relative to 0h on 1 January 1900. The integer
* part is in the first 32 bits and the fraction part in the last 32 bits.
*/
myt = ntohl(pkt.txtime[0]) - MY_OFFSET;
offset = myt - time(NULL);
sprintf(answer, "Time: %s\nstratum %d offset %ld\n",
ctime(&myt), (int) pkt.stratum, offset);
if (fd >= 0)
close(fd);
printf(answer);
return 1;
}
Andy
--
-------------------------------------------------------------------
)\._.,--....,'``. Andrej Cedilnik (ace...@cs.umbc.edu)
/, _.. \ _\ (`._ ,. URL: http://www.cs.umbc.edu/~acedil1
`._.-(,_..'--(,_..'`-.;.' TEL: (301)725-5724 ICQ: 27889915
-------------------------------------------------------------------