From 39da8ffc5254acec7b9ce51f50b5b0e783dc7b7d Mon Sep 17 00:00:00 2001 From: John Wiseman Date: Thu, 2 Mar 2023 09:33:47 +0000 Subject: 6.0.23.51 --- APRSCode.c | 52 +++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 43 insertions(+), 9 deletions(-) (limited to 'APRSCode.c') diff --git a/APRSCode.c b/APRSCode.c index a54371b..74a17ba 100644 --- a/APRSCode.c +++ b/APRSCode.c @@ -4431,7 +4431,7 @@ static VOID GPSDConnect(void * unused) // Request data - send(TCPSock, "?WATCH={\"enable\":true,\"nmea\":true}", 34, 0); + send(TCPSock, "?WATCH={\"enable\":true,\"nmea\":true}\r\n", 36, 0); } else { @@ -4459,7 +4459,7 @@ static VOID GPSDConnect(void * unused) timeout.tv_usec = 0; // We should get messages more frequently that this ret = select((int)TCPSock + 1, &readfs, NULL, &errorfs, &timeout); - + if (ret == SOCKET_ERROR) { goto Lost; @@ -4472,7 +4472,11 @@ static VOID GPSDConnect(void * unused) { char Buffer[65536]; int len = recv(TCPSock, Buffer, 65500, 0); - + char TCPMsg[8192]; + + char * ptr; + char * Lastptr; + if (len == 0) { closesocket(TCPSock); @@ -4484,15 +4488,45 @@ static VOID GPSDConnect(void * unused) { Buffer[len] = 0; - if (Buffer[0] == '$' && memcmp(&Buffer[3], "RMC", 3) == 0) - if (Check0183CheckSum(Buffer, len)) - DecodeRMC(Buffer, len); + ptr = Lastptr = Buffer; + Buffer[len] = 0; + + while (len > 0) + { + ptr = strchr(Lastptr, 10); + if (ptr) + { + size_t Len = ptr - Lastptr -1; + + if (Len > 8100) + return; + + memcpy(TCPMsg, Lastptr, Len); + TCPMsg[Len++] = 13; + TCPMsg[Len++] = 10; + TCPMsg[Len] = 0; + + if (!Check0183CheckSum(TCPMsg, Len)) + { + Debugprintf("Checksum Error %s", TCPMsg); + } + else + { + if (memcmp(&TCPMsg[3], "RMC", 3) == 0) + DecodeRMC(TCPMsg, Len); + } + Lastptr = ptr + 1; + len -= (int)Len; + } + else + return; + } + } } - } - if (FD_ISSET(TCPSock, &errorfs)) - { + if (FD_ISSET(TCPSock, &errorfs)) + { Lost: #ifdef LINBPQ printf("GPSD Connection lost\n"); -- cgit v1.2.3