【发布时间】:2023-03-12 12:30:01
【问题描述】:
我是 arduino 的新手,并尝试使用 arduino 的 neo 6m 模块提取 gps 坐标,但循环一直运行到无穷大。你能帮我解释一下为什么它没有坏吗?
void gpsEvent()
{
gpsString = "";
while (1)
{
while (gps.available() > 0) //Serial incoming data from GPS
{
char inChar = (char)gps.read();
gpsString += inChar;//store incoming data from GPS to temparary string str[]
i++;
// Serial.print(inChar);
if (i < 7)
{
if (gpsString[i-1] != test[i-1]) //check for right string
{
i = 0;
gpsString = "";
}
}
if (inChar == '\r')
{
if (i > 60)
{
gps_status = 1;
break;
}
else
{
i = 0;
}
}
}
if (gps_status)
break;
}
}
void get_gps()
{
gps_status = 0;
int x = 0;
while (gps_status == 0)
{
gpsEvent();
int str_lenth = i;
coordinate2dec();
i = 0;
x = 0;
str_lenth = 0;
}
}
我在 void setup() 循环中调用了get_gps(); 来初始化系统,但是用于从数据中提取正确字符串的 gpsEvent 函数正在运行直到无限,请您帮忙。代码参考来自https://circuitdigest.com/microcontroller-projects/arduino-based-accident-alert-system-using-gps-gsm-accelerometer
但我自己做了一些改动,但在 gps 模块的编程中没有。
【问题讨论】:
标签: arduino gps iot android-gps