NMEA 0183是美国国家海洋电子协会(National Marine Electronics Association )为海用电子设备制定的标准格式。目前业已成了GPS导航设备统一的RTCM(Radio Technical Commission for Maritime services)标准协议。
以下面的数据为例:
$GPGGA,022206.00,3905.87672799,N,11704.89762467,E,4,32,0.5,39.2934,M,-7.5829,M,02,0000*41
$GNGST,022207.00,0.00,0.02,0.01,161.8102,0.02,0.01,0.05*74
$GPGSV,2,1,07,10,30,308,43,15,50,054,50,20,59,312,47,21,49,229,47*7F
$GPGSV,2,2,07,24,71,118,51,27,02,300,37,32,08,258,41*41
$GLGSV,2,1,07,66,46,058,48,82,29,260,44,76,43,059,47,77,38,150,43*66
$GLGSV,2,2,07,81,09,213,40,67,48,329,48,68,06,291,39*57
$GAGSV,2,1,06,04,69,007,48,09,33,287,43,11,35,240,41,12,10,190,37*65
$GAGSV,2,2,06,19,25,078,32,01,38,114,43*66
$BDGSV,3,1,10,01,37,146,43,02,34,226,38,03,43,190,42,06,72,343,47*6C
$BDGSV,3,2,10,08,26,191,41,09,57,287,44,13,39,210,42,16,70,329,49*66
$BDGSV,3,3,10,04,26,124,38,05,16,249,36*6D
每一行末尾的“星号”后面都有两位校验,是本行字符串中将“美元符号”和“星号”之间的每一个字符从左至右依次进行异或等于运算而得到的。(试了好几次,特殊符号不能正常显示,以后再来研究。)
下面以计算一条GPGGA的校验和为例,放出C语言计算代码:
#include
int main()
{
char str[] = "$GPGGA,022206.00,3905.87672799,N,11704.89762467,E,4,32,0.5,39.2934,M,-7.5829,M,02,0000*41";
int i = 0;
int result = str[1];
for(i = 2; str[i] != '*'; i++)
{
result ^= str[i];
}
printf("result=%x\n", result);
return 0;
}
计算结果:
result=41
计算结果与GPGGA中的校验和一致。