[En-Nut-Discussion] SNTP problems
tomek w
twojcikpl at yahoo.com
Fri Apr 23 02:36:06 CEST 2004
Hi everyone.
I am working on some project now and i need to synchronise Ethernut board using SNTP.
I cut a little source code of Lars H. Andersson's SNTP implementation but it doesn't work, neither the non-modified code.
What could be the problem? What i am doing wrong?
Here is part of my sorce code:
typedef struct _sntpframe sntpframe;
struct _sntpframe {
u_char mode;
u_char stratum;
u_char poll;
u_char precision;
u_long root_delay;
u_long root_dispersion;
u_long reference_identifier;
u_long reference_ts_sec;
u_long reference_ts_frac;
u_long originate_ts_sec;
u_long originate_ts_frac;
u_long receive_ts_sec;
u_long receive_ts_frac;
u_long transmit_ts_sec;
u_long transmit_ts_frac;
};
sntpframe *data;
u_long server_addr;
server_addr=inet_addr("150.254.183.15");
u_short NTPort = 123;
int len;
UDPSOCKET *sock = NULL;
u_long rec_addr = 0;
u_short port;
u_short bufsize = 256;
sock = NutUdpCreateSocket(0);
data->mode = 0x1B;
NutUdpSetSockOpt(sock, SO_RCVBUF, &bufsize, sizeof(bufsize));
NutUdpSendTo(sock, server_addr,NTPort, data, sizeof(*data));
len = NutUdpReceiveFrom(sock, &rec_addr, &port, data, sizeof(*data), 5000);
NutUdpDestroySocket(sock);
It returns sth not equal to 0 for createsocket, 0 for udpsend and 0 for udpreceive.
I checked the server adress with windows ntp client and it works all the time.
Thanks for any help.
---------------------------------
Do you Yahoo!?
Yahoo! Photos: High-quality 4x6 digital prints for 25¢
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.egnite.de/pipermail/en-nut-discussion/attachments/20040422/3c4dd2b5/attachment-0001.html>
More information about the En-Nut-Discussion
mailing list