View previous topic :: View next topic |
Author |
Message |
nicofer
Joined: 01 May 2013 Posts: 90 Location: GRJ
|
Posted: Mon Nov 04, 2013 10:40 am Post subject: SNTP Problem |
|
|
Hi
I use an old wiznet module in 12c mode - all working 100 % in TCP / IP as web server on LAN and from " outside " the router .
Now I want to use the SNTP function to get the time and I only get a 0 value ??
What am I missing
I use all the standard setup and configs .
Config Tcpip = Int7 , Mac = 00.02.33.34.56.78 , Ip = 192.168.0.241 , Submask = 255.255.255.0 , Gateway = 192.168.0.1 , Localport = 1000 , Tx = &B11 , Rx = &B11 , Twi = 254 , Clock = 400000 , Chip = W3100a
'
'
'
'
'
Do
Tempw = Socketstat(i , 0) ' get status
Select Case Tempw
Case Sock_established
' Ppmw1 = 15
Print #2 , " sock_est" ' delete it when it sends to much data to the terminal
'
'
'
'
'
' Print #2 , "Listening on socket : " ; I
Cls
Lcd "Ready to connect"
End Select
'
And then the sntp code
Ntp:
Print #2 , " NTP "
Tcp_tempb = Getsocket(0 , Sock_dgram , 1000 , 0) ' get socket for UDP mode, specify port 5000
Print #2 , " ntp socket status " ; Tcp_tempb
'IP URA 193.67.79.202
ip_snmp = Maketcp(128.138.140.44)
Ura_snmp = Sntp(0 , Ip_snmp) ' get time from SNTP server
Print #2 , "Ura_snmp " ; Ura_snmp
Closesocket 0
Return
I tried both the NTP server adres above with NTPTool and i get a reply on my pc , all 100 % working.
How long does the sntp( ) function wait for a reply ?
Any help please.
Cheers |
|
Back to top |
|
|
bzijlstra
Joined: 30 Dec 2004 Posts: 1179 Location: Tilburg - Netherlands
|
|
Back to top |
|
|
nicofer
Joined: 01 May 2013 Posts: 90 Location: GRJ
|
Posted: Fri Nov 08, 2013 7:34 am Post subject: |
|
|
Hi Ben
Yes I tried your code also - same problem
If I use Tera Term pro and send a " x" to one of the NPT ip's I get a 4 byte reply.
If I do it with easy tcp I get a 3 byte reply from the NTP server.
I am still wondering how long does the function wait for a reply . can it be that the link is a it slow and for that reason the function return 0 ?
Your code is more a low level of the SNTP function but I have the same problem .
I use the wiznet with only one channel but I make sure it is not busy when I start the UDP - NTP request.
Thanks for the help anyway.
Any idea where I can still find some of the IIN 7000 Wiznet modules ? I mod the unit to work in I2c mode .
Cheers |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Fri Nov 08, 2013 10:18 am Post subject: |
|
|
the w5x00 libs check for received data and wait few ms a number of times till an answer is received.
the w3100 lib only checks a fixed amount of time.
if you send an email to support i can send a mod which you can test. _________________ Mark |
|
Back to top |
|
|
nicofer
Joined: 01 May 2013 Posts: 90 Location: GRJ
|
Posted: Fri Nov 08, 2013 10:36 am Post subject: |
|
|
Hi
Thanks - will do .
oops - the 3 bytes is not the return bytes but the nr of bytes sent - the rx byte count is 0
Tcp_tempb = Getsocket(0 , 2 , 5000 , 0) ' get socket for UDP mode, specify port 5000
Print #2 , " ntp socket status " ; Tcp_tempb ' I get a " 0" reply here
Result = Udpwritestr(192.168.0.207 , 37 , 0 , Sstr , 255) ' ntp0.nl.net port 37
Print #2 , "UDP geskryf " ; Result ' I get a " 3 " here
Result = Socketstat(0 , 2) ' get number of bytes waiting
Print #2 , "UDP bytes ontvang " ; Result ' get a " 0 " reply here
If Result > 0 Then
Temp = Udpread(0 , Sa(1) , Result) ' read the result
Print #2 , Sa(1) , Sa(2) , Sa(3) , Sa(4)
End If
Must say the Easy TCP/IP (i2c) + Bascom is VERY powerful. - keep up the good work !
Cheers
Nico |
|
Back to top |
|
|
nicofer
Joined: 01 May 2013 Posts: 90 Location: GRJ
|
Posted: Fri Nov 08, 2013 10:50 am Post subject: |
|
|
Hi
Here is a screenshot with the time delay - from South Africa - so with a lot of stops and delays .
It is on a 4MB dsl line .
Best might be to make the delay at least double that .
Cheers |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
|
|