A GPS disciplined clock
Dependencies: net lpc1768 crypto clock web log
Diff: web-this/home/web-home-ajax.c
- Revision:
- 60:7cab896b0fd4
- Parent:
- 59:d2d25c2265f8
- Child:
- 87:5052e316994a
--- a/web-this/home/web-home-ajax.c Wed May 01 10:14:26 2019 +0000 +++ b/web-this/home/web-home-ajax.c Wed May 01 14:08:56 2019 +0000 @@ -15,26 +15,20 @@ HttpOk("text/plain; charset=UTF-8", "no-cache", NULL, NULL); clktime now = ClkNowTai(); - int32_t fraction = now & ((1UL << CLK_TIME_ONE_SECOND_SHIFT) - 1); //fraction is 30 bit so fits into 32 bits - int32_t ms = (fraction * 1000LL) >> CLK_TIME_ONE_SECOND_SHIFT; //fraction time in ms needs 40 bits so use 1000LL to promote to 64bit - HttpAddInt16AsHex(ms); //0, 1, 2, 3 - - char nibble; - nibble = 0; - if (RtcIsSet() ) nibble |= 1; //4 - if (ClkTimeIsSet() ) nibble |= 2; //4 - if (PpsIsStable() ) nibble |= 4; //4 - if (NmeaTimeIsStable() ) nibble |= 8; //4 - HttpAddNibbleAsHex(nibble); - - nibble = 0; - if (ClkGovRateIsSynced ) nibble |= 1; //5 - if (ClkGovTimeIsSynced ) nibble |= 2; //5 - if (ClkUtcGetNextLeapEnable() ) nibble |= 4; //5 - if (ClkUtcGetNextLeapForward()) nibble |= 8; //5 - HttpAddNibbleAsHex(nibble); - - HttpAddInt12AsHex(ClkUtcGetNextEpochMonth1970()); //6, 7, 8 - HttpAddInt16AsHex(ClkUtcGetEpochOffset()); //9, 10, 11, 12 + clktime fraction = now & ((1UL << CLK_TIME_ONE_SECOND_SHIFT) - 1); + clktime ms = (fraction * 1000) >> CLK_TIME_ONE_SECOND_SHIFT; + HttpAddInt16AsHex(ms ); HttpAddChar('\n'); + char byte = 0; + if (RtcIsSet() ) byte |= 0x01; + if (ClkTimeIsSet() ) byte |= 0x02; + if (PpsIsStable() ) byte |= 0x04; + if (NmeaTimeIsStable() ) byte |= 0x08; + if (ClkGovRateIsSynced ) byte |= 0x10; + if (ClkGovTimeIsSynced ) byte |= 0x20; + if (ClkUtcGetNextLeapEnable() ) byte |= 0x40; + if (ClkUtcGetNextLeapForward()) byte |= 0x80; + HttpAddByteAsHex (byte ); HttpAddChar('\n'); + HttpAddInt12AsHex(ClkUtcGetNextEpochMonth1970()); HttpAddChar('\n'); + HttpAddInt16AsHex(ClkUtcGetEpochOffset() ); HttpAddChar('\n'); }