<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2600.0" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=000101808-23042004><FONT face=Arial color=#0000ff
size=2>Hello,</FONT></SPAN></DIV>
<DIV><SPAN class=000101808-23042004><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=000101808-23042004><FONT face=Arial color=#0000ff size=2>on the
first look, I would say, that you forgat to allocate heap space for *data.
</FONT></SPAN></DIV>
<DIV><SPAN class=000101808-23042004><FONT face=Arial color=#0000ff size=2>Please
add a line, like this: data =
NutHeapAllocClear(sizeof(*data))</FONT></SPAN></DIV>
<DIV><SPAN class=000101808-23042004><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=000101808-23042004><FONT face=Arial color=#0000ff size=2>Since
Nut/OS release 3.4.1, there are some time related functions available, among
them also a (working) sntp client in /pro/sntp.c.</FONT></SPAN></DIV>
<DIV><SPAN class=000101808-23042004><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=000101808-23042004><FONT face=Arial color=#0000ff
size=2>Cheers,</FONT></SPAN></DIV>
<DIV><SPAN class=000101808-23042004><FONT face=Arial color=#0000ff
size=2>Oliver.</FONT></SPAN></DIV>
<BLOCKQUOTE
style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px solid">
<DIV class=OutlookMessageHeader dir=ltr align=left><FONT face=Tahoma><BR><FONT
size=2><SPAN class=000101808-23042004><FONT face=Arial
color=#0000ff> </FONT></SPAN>-----Ursprüngliche
Nachricht-----<BR><B>Von:</B> en-nut-discussion-bounces@egnite.de
[mailto:en-nut-discussion-bounces@egnite.de]<B>Im Auftrag von </B>tomek
w<BR><B>Gesendet:</B> Freitag, 23. April 2004 02:36<BR><B>An:</B>
en-nut-discussion@egnite.de<BR><B>Betreff:</B> [En-Nut-Discussion] SNTP
problems<BR><BR></FONT></FONT></DIV>
<DIV>Hi everyone.<BR>I am working on some project now and i need to
synchronise Ethernut board using SNTP.<BR>I cut a little source code of
Lars H. Andersson's SNTP implementation but it doesn't work, neither the
non-modified code.</DIV>
<DIV>What could be the problem? What i am doing wrong?</DIV>
<DIV> </DIV>
<DIV>Here is part of my sorce code:</DIV>
<DIV> </DIV>
<DIV>typedef struct _sntpframe sntpframe;<BR>struct _sntpframe
{<BR> u_char mode;<BR> u_char
stratum;<BR> u_char poll;<BR> u_char
precision;<BR> u_long root_delay;<BR>
u_long root_dispersion;<BR> u_long
reference_identifier;<BR> u_long
reference_ts_sec;<BR> u_long
reference_ts_frac;<BR> u_long
originate_ts_sec;<BR> u_long
originate_ts_frac;<BR> u_long
receive_ts_sec;<BR> u_long
receive_ts_frac;<BR> u_long
transmit_ts_sec;<BR> u_long transmit_ts_frac;<BR>};</DIV>
<DIV><BR>sntpframe *data; <BR>u_long
server_addr;<BR>server_addr=inet_addr("150.254.183.15");<BR>u_short
NTPort = 123;<BR>int len;<BR>UDPSOCKET *sock = NULL;
<BR>u_long rec_addr = 0;<BR>u_short port; <BR>u_short bufsize = 256;</DIV>
<DIV>sock = NutUdpCreateSocket(0);<BR>data->mode =
0x1B;<BR>NutUdpSetSockOpt(sock, SO_RCVBUF, &bufsize,
sizeof(bufsize));</DIV>
<DIV>NutUdpSendTo(sock, server_addr,NTPort, data, sizeof(*data));<BR>len =
NutUdpReceiveFrom(sock, &rec_addr, &port, data, sizeof(*data),
5000);<BR>NutUdpDestroySocket(sock); <BR><BR>It returns sth not equal to
0 for createsocket, 0 for udpsend and 0 for udpreceive.</DIV>
<DIV>I checked the server adress with windows ntp client and it works all the
time.</DIV>
<DIV>Thanks for any help.</DIV>
<P>
<HR SIZE=1>
<FONT face=arial size=-1>Do you Yahoo!?<BR>Yahoo! Photos: <A
href="http://pa.yahoo.com/*http://us.rd.yahoo.com/evt=23765/*http://photos.yahoo.com/ph/print_splash">High-quality
4x6 digital prints for 25¢</A></FONT></BLOCKQUOTE></BODY></HTML>