@@ -623,26 +623,45 @@ void processUart1Message(SEMP_PARSE_STATE *parse, uint16_t type)
623
623
}
624
624
}
625
625
626
- // Save GGA / RMC / GST for the authentication coprocessor
626
+ // Save GGA / RMC / GST for the Apple device
627
+ // We should optimse this with a Lee table... TODO
627
628
if ((online.authenticationCoPro ) && (type == RTK_NMEA_PARSER_INDEX))
628
629
{
629
630
if (strstr (sempNmeaGetSentenceName (parse), " GGA" ) != nullptr )
630
631
{
631
- strncpy (latestGPGGA, (const char *)parse->buffer , sizeof (latestGPGGA));
632
- if ((strlen (latestGPGGA) > 10 ) && (latestGPGGA[strlen (latestGPGGA) - 2 ] == ' \r ' ))
633
- latestGPGGA[strlen (latestGPGGA) - 2 ] = 0 ; // Truncate the \r\n
632
+ if (parse->length < latestNmeaMaxLen)
633
+ {
634
+ memcpy (latestGPGGA, parse->buffer , parse->length );
635
+ latestGPGGA[parse->length ] = 0 ; // NULL terminate
636
+ if ((strlen (latestGPGGA) > 10 ) && (latestGPGGA[strlen (latestGPGGA) - 2 ] == ' \r ' ))
637
+ latestGPGGA[strlen (latestGPGGA) - 2 ] = 0 ; // Truncate the \r\n
638
+ }
639
+ else
640
+ systemPrintf (" Increase latestNmeaMaxLen to > %d\r\n " , parse->length );
634
641
}
635
642
else if (strstr (sempNmeaGetSentenceName (parse), " RMC" ) != nullptr )
636
643
{
637
- strncpy (latestGPRMC, (const char *)parse->buffer , sizeof (latestGPRMC));
638
- if ((strlen (latestGPRMC) > 10 ) && (latestGPRMC[strlen (latestGPRMC) - 2 ] == ' \r ' ))
639
- latestGPRMC[strlen (latestGPRMC) - 2 ] = 0 ; // Truncate the \r\n
644
+ if (parse->length < latestNmeaMaxLen)
645
+ {
646
+ memcpy (latestGPRMC, parse->buffer , parse->length );
647
+ latestGPRMC[parse->length ] = 0 ; // NULL terminate
648
+ if ((strlen (latestGPRMC) > 10 ) && (latestGPRMC[strlen (latestGPRMC) - 2 ] == ' \r ' ))
649
+ latestGPRMC[strlen (latestGPRMC) - 2 ] = 0 ; // Truncate the \r\n
650
+ }
651
+ else
652
+ systemPrintf (" Increase latestNmeaMaxLen to > %d\r\n " , parse->length );
640
653
}
641
654
else if (strstr (sempNmeaGetSentenceName (parse), " GST" ) != nullptr )
642
655
{
643
- strncpy (latestGPGST, (const char *)parse->buffer , sizeof (latestGPGST));
644
- if ((strlen (latestGPGST) > 10 ) && (latestGPGST[strlen (latestGPGST) - 2 ] == ' \r ' ))
645
- latestGPGST[strlen (latestGPGST) - 2 ] = 0 ; // Truncate the \r\n
656
+ if (parse->length < latestNmeaMaxLen)
657
+ {
658
+ memcpy (latestGPGST, parse->buffer , parse->length );
659
+ latestGPGST[parse->length ] = 0 ; // NULL terminate
660
+ if ((strlen (latestGPGST) > 10 ) && (latestGPGST[strlen (latestGPGST) - 2 ] == ' \r ' ))
661
+ latestGPGST[strlen (latestGPGST) - 2 ] = 0 ; // Truncate the \r\n
662
+ }
663
+ else
664
+ systemPrintf (" Increase latestNmeaMaxLen to > %d\r\n " , parse->length );
646
665
}
647
666
}
648
667
0 commit comments