Skip to content

Commit e88b483

Browse files
committed
Better NTP debug
1 parent 687b9f3 commit e88b483

File tree

1 file changed

+31
-14
lines changed

1 file changed

+31
-14
lines changed

Firmware/RTK_Everywhere/NTP.ino

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,23 @@ bool ntpProcessOneRequest(bool process, const timeval *recTv, const timeval *syn
520520

521521
ntpServer->read((char *)&packet.packet, NTPpacket::NTPpacketSize); // Copy the NTP data into our packet
522522

523+
/*
524+
// Add the incoming packet to the diagnostics
525+
if (ntpDiag != nullptr)
526+
{
527+
char tmpbuf[128];
528+
snprintf(tmpbuf, sizeof(tmpbuf), "Packet <-- : ");
529+
strlcat(ntpDiag, tmpbuf, ntpDiagSize);
530+
for (int i = 0; i < NTPpacket::NTPpacketSize; i++)
531+
{
532+
snprintf(tmpbuf, sizeof(tmpbuf), "%02X ", packet.packet[i]);
533+
strlcat(ntpDiag, tmpbuf, ntpDiagSize);
534+
}
535+
snprintf(tmpbuf, sizeof(tmpbuf), "\r\n");
536+
strlcat(ntpDiag, tmpbuf, ntpDiagSize);
537+
}
538+
*/
539+
523540
// If process is false, return now
524541
if (!process)
525542
{
@@ -635,26 +652,26 @@ bool ntpProcessOneRequest(bool process, const timeval *recTv, const timeval *syn
635652
// Add the socketSendUDP result to the diagnostics
636653
if (ntpDiag != nullptr)
637654
{
638-
char tmpbuf[128];
639-
snprintf(tmpbuf, sizeof(tmpbuf), "socketSendUDP result: %d\r\n", result);
640-
strlcat(ntpDiag, tmpbuf, ntpDiagSize);
655+
char tmpbuf[128];
656+
snprintf(tmpbuf, sizeof(tmpbuf), "socketSendUDP result: %d\r\n", result);
657+
strlcat(ntpDiag, tmpbuf, ntpDiagSize);
641658
}
642659
*/
643660

644661
/*
645-
// Add the packet to the diagnostics
662+
// Add the outgoing packet to the diagnostics
646663
if (ntpDiag != nullptr)
647664
{
648-
char tmpbuf[128];
649-
snprintf(tmpbuf, sizeof(tmpbuf), "Packet: ");
650-
strlcat(ntpDiag, tmpbuf, ntpDiagSize);
651-
for (int i = 0; i < NTPpacket::NTPpacketSize; i++)
652-
{
653-
snprintf(tmpbuf, sizeof(tmpbuf), "%02X ", packet.packet[i]);
665+
char tmpbuf[128];
666+
snprintf(tmpbuf, sizeof(tmpbuf), "Packet --> : ");
667+
strlcat(ntpDiag, tmpbuf, ntpDiagSize);
668+
for (int i = 0; i < NTPpacket::NTPpacketSize; i++)
669+
{
670+
snprintf(tmpbuf, sizeof(tmpbuf), "%02X ", packet.packet[i]);
671+
strlcat(ntpDiag, tmpbuf, ntpDiagSize);
672+
}
673+
snprintf(tmpbuf, sizeof(tmpbuf), "\r\n");
654674
strlcat(ntpDiag, tmpbuf, ntpDiagSize);
655-
}
656-
snprintf(tmpbuf, sizeof(tmpbuf), "\r\n");
657-
strlcat(ntpDiag, tmpbuf, ntpDiagSize);
658675
}
659676
*/
660677
}
@@ -818,7 +835,7 @@ void ntpServerStop()
818835
// Update the NTP server state
819836
void ntpServerUpdate()
820837
{
821-
char ntpDiag[512]; // Char array to hold diagnostic messages
838+
char ntpDiag[768]; // Char array to hold diagnostic messages
822839

823840
if (present.ethernet_ws5500 == false)
824841
return;

0 commit comments

Comments
 (0)