return num;
}
-
-static udegree_t nmea_latitude(const char *plat, const char *phem)
+static udegree_t convertToDegree(const char *str)
{
- int ns;
- uint32_t lat;
+ uint32_t dec;
uint32_t deg;
uint32_t min;
- if (*plat == 0)
+ if (*str == 0)
{
return 0;
}
+
+ dec = tokenToInt(str);
+ deg = dec / 1000000;
+ min = dec - deg * 1000000;
+ dec = deg * 1000000 + ((min * 5) + 1) / 3;
+}
+
+static udegree_t nmea_latitude(const char *plat, const char *phem)
+{
+ int ns;
+
if (*phem == 0)
{
return 0;
}
+
/* north lat is +, south lat is - */
if (*phem == 'N')
{
ns = -1;
}
- lat = tokenToInt(plat);
- deg = lat / 1000000;
- min = lat - deg * 1000000;
- lat = deg * 1000000 + ((min * 5) + 1) / 3;
- return ns * lat;
+ return ns * convertToDegree(plat);
}
static udegree_t nmea_longitude(const char *plot, const char *phem)
{
int ew;
- uint32_t lot;
- uint32_t deg;
- uint32_t min;
-
- if (*plot == 0)
- {
- return 0;
- }
- if (*phem == 0)
- {
- return 0;
- }
/* west long is negative, east long is positive */
if (*phem == 'E')
ew = -1;
}
- lot = tokenToInt(plot);
- deg = lot / 1000000;
- min = lot - deg * 1000000;
- lot = deg * 1000000 + ((min * 5) + 1) / 3;
+ if (*phem == 0)
+ {
+ return 0;
+ }
- return ew * lot;
+ return ew * convertToDegree(plot);
}
static uint16_t nmea_altitude(const char *palt, const char *punits)
t.tm_sec = tmr[0] + (ROUND_UP(msec, 1000) / 1000);
t.tm_min = tmr[1];
t.tm_hour = tmr[2];
+ //If we not have refence data, we set as default 1/1/1970.
t.tm_mday = 1;
t.tm_mon = 1;
t.tm_year = 70;
* if the sentence has a callout, call it
*/
if (sentence->callout != 0)
- (*sentence->callout)(context,gsv,context->user_data);
+ (*sentence->callout)(context, gsv, context->user_data);
return NMEA_GPGSV;
}
int c;
while ((c = kfile_getc(channel)) != EOF)
{
- if (nmeap_parse(context, c) == -1)
- break;
+ nmeap_parse(context, c);
}
}