Hi Charles,
Exactly, with SNTP "time began" at 1/1-1900.
I see your code uses LONGS which I'm trying to avoid but I'll digest it and see what might come out, thanks for sharing, I appreciate it!
/Henrik.
Hi Charles,
Exactly, with SNTP "time began" at 1/1-1900.
I see your code uses LONGS which I'm trying to avoid but I'll digest it and see what might come out, thanks for sharing, I appreciate it!
/Henrik.
I guess that I left out some stuff in the code above.
It is designed for use with a Lantronix XPort. It logs on to port 123 of timeservers and comes back with network time.
And, yes, you ***MUST*** use 18F chips!
The stuff that goes before it is -
Code:THEADER[0] = $2 ' STX THEADER[1] = TSIP1 ' DESTINATION IP THEADER[2] = TSIP2 THEADER[3] = TSIP3 THEADER[4] = TSIP4 THEADER[5] = 0 ; DESTINATION PORT HIGHBYTE THEADER[6] = 123 ; DESTINATION PORT LOWBYTE LRC1 = 0 LRC2 = 0 For X = 1 to 6 LRC1 = LRC1 ^ THeader[x] next X THEADER[7] = LRC1 THEADER[8] = 0 THEADER[9] = 48 'Data Length lowbyte ;Send the header For X = 0 to 9 HSEROUT2 [THeader[X]] Next X LRC2 = LRC2 ^ THeader[8] LRC2 = LRC2 ^ THeader[9] ;Send the data HSEROUT2 [$1B] LRC2 = LRC2 ^ $1B For X = 0 To 46 HSEROUT2 [0] LRC2 = LRC2 ^ 0 NEXT X ;Send the Checksum (LRC) HSEROUT2 [LRC2] getresponse: HSERIN2 1000,NoResponse,[Wait($2)] hserin2 200,NoResponse,[SKIP 41,TimeNow.Byte3,TimeNow.Byte2,TimeNow.Byte1,TimeNow.Byte0]
Charles Linquist
Thanks Charles,
I'm using the 18LF46K22 and W5100 ethernet chip, the SNTP stuff are done and I get the seconds count from the server, no issues there. It's the conversion from seconds to true time that's bugging me and the reason I'm trying to avoid longs is that it adds a lot of overhead to the program even in sections not actually using longs.
I'm on my way to convert your convert-routine to use 16 bit variables but it does get a bit messy...
Thanks again for sharing!
/Henrik.
It shouldn't be too bad - breaking it into 16 bit 'chunks' , you will just have an offset that is not just hours, but hours, minutes and seconds.
Charles Linquist
Bookmarks