From 192fa69f68a6e84f75a9b50860cdfbe97426363f Mon Sep 17 00:00:00 2001 From: Wolfgang Hottgenroth Date: Sun, 28 Feb 2021 22:01:06 +0100 Subject: [PATCH] xmt --- cube/User/Src/networkAbstractionLayer_lan.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cube/User/Src/networkAbstractionLayer_lan.c b/cube/User/Src/networkAbstractionLayer_lan.c index 6021c01..fc1ff8e 100644 --- a/cube/User/Src/networkAbstractionLayer_lan.c +++ b/cube/User/Src/networkAbstractionLayer_lan.c @@ -108,10 +108,11 @@ void networkSntpEngine(void *handle) { memset(&(localHandle->ntpMsg), 0, sizeof(localHandle->ntpMsg)); uint8_t srcAddr[4]; uint16_t srcPort; - /* + recvfrom(SNTP_SOCK, (uint8_t*)(&(localHandle->ntpMsg)), sizeof(localHandle->ntpMsg), srcAddr, &srcPort); - */ + + /* uint8_t buf[90]; memset(buf, 0, sizeof(buf)); recvfrom(SNTP_SOCK, buf, sizeof(buf), srcAddr, &srcPort); @@ -131,13 +132,13 @@ void networkSntpEngine(void *handle) { coloredMsg(LOG_BLUE, "%02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x", buf[x+0], buf[x+1], buf[x+2], buf[x+3], buf[x+4], buf[x+5], buf[x+6], buf[x+7], buf[x+8], buf[x+9], buf[x+10], buf[x+11], buf[x+12], buf[x+13], buf[x+14], buf[x+15]); - + */ close(SNTP_SOCK); coloredMsg(LOG_BLUE, "nes, msg received from %d.%d.%d.%d:%d", srcAddr[0], srcAddr[1], srcAddr[2], srcAddr[3], srcPort); coloredMsg(LOG_BLUE, "nes, received in the %d. cycles", localHandle->retryCount); - localHandle->seconds = localHandle->ntpMsg.rec - UNIX_NTP_EPOCH_DIFF; + localHandle->seconds = ((localHandle->ntpMsg.xmt >> 32) & 0x0ffffffff) - UNIX_NTP_EPOCH_DIFF; coloredMsg(LOG_BLUE, "nes, seconds: %lu", localHandle->seconds); localHandle->sntpState = SNTP_STATE_DONE; } else {