gpt4 book ai didi

raspberry-pi - GPS数据解析

转载 作者:太空宇宙 更新时间:2023-11-04 04:17:02 25 4
gpt4 key购买 nike

我得到了 USB DeLORME Earthmate GPA LT-20,我想将它用作移动 GPS 批准单元的一部分,基于 Raspberry Pi。我已经能够访问原始串行数据,但与将数据解析为可用格式的有效方法不一致。目前的计划只是将其以有意义的方式打印在屏幕上。只是看想法。波纹管是数据的样本,我已经改变了 GPS 位置数据以删除特定的测试位置。更喜欢用 C 编写代码

我已阅读以下引用网站:

http://www.gpsinformation.org/dale/nmea.htm

https://en.wikipedia.org/wiki/List_of_GPS_satellites

$GPRMC,050229.000,A,3XX8.647,N,11XX1.282,W,0.1,0.0,140518,11.7,E*4B
$GPGGA,050229.000,3XX8.64662,N,11XX1.28205,W,1,06,1.5,725.48,M,-28.4,M,,*5D
$GPVTG,0.0,T,11.7,M,0.1,N,0.1,K*79
$GPGSV,3,1,09,10,34,240,34,13,24,054,00,15,47,086,26,16,25,292,30*77
$GPGSV,3,2,09,20,79,310,31,21,65,345,37,26,25,260,00,27,11,320,00*78
$GPGSV,3,3,09,29,46,147,34,,,,,,,,,,,,*4C
$PSTMECH,21,7,20,7,15,7,29,7,10,7,00,0,16,7,00,0,00,0,00,0,00,0,00,0*5C

最佳答案

查看此信息:

`"$GPRMC,050229.000,A,3008.647,N,11001.282,W,0.1,0.0,140518,11.7,E*4B"`

使用strtok进行解析:

int main(void)
{
FILE *fp = fopen("test.txt", "r");

char buf[256];
char *array[20];
while(fgets(buf, sizeof(buf), fp))
{
if(strstr(buf, "$GPRMC"))
{
int count = 0;
char *token;
token = strtok(buf, ",");
while(token != NULL)
{
array[count++] = token;
token = strtok(NULL, ",");
if(count == 20)
break;
}

printf("Latitude : %s %s\n", array[3], array[4]);
printf("Longitude : %s %s\n", array[5], array[6]);
}
}

return 0;
}

结果:

Latitude : 3008.647 N
Longitude : 11001.282 W

关于raspberry-pi - GPS数据解析,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50576918/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com