* see the file COPYING for terms of the licnese
*/
-#include <string.h>
+#include <stdio.h>
#include <stdlib.h>
-#include <cfg/debug.h>
+#include <string.h>
#include <ctype.h>
#include "../inc/nmeap.h"
+#include <cfg/debug.h>
+
#define assert(x) ASSERT(x)
-/*
- * Removed to compile in BeRTOS environment.
- *
- * #include <stdio.h>
- * #include <stdlib.h>
- * #include <string.h>
- * #include <cfg/debug.h>
- * #include <assert.h>
- * #include <ctype.h>
- *
- * #include "nmeap.h"
- *
- */
+#include "cfg/cfg_nmea.h"
+
+#define LOG_LEVEL NMEA_LOG_LEVEL
+#define LOG_FORMAT NMEA_LOG_FORMAT
+#include <cfg/log.h>
+#ifdef _DEBUG
+ #undef NDEBUG
+ #define printf(str,...) LOG_INFO(str, ## __VA_ARGS__)
+#endif
/* this only works if you are sure you have an upper case hex digit */
#define HEXTOBIN(ch) ((ch <= '9') ? ch - '0' : ch - ('A' - 10))
*/
int nmeap_process(nmeap_context_t *context)
{
- int id;
+ int id = 0;
int i;
nmeap_sentence_t *s;
case 1:
/* allow numbers even though it isn't usually done */
/* a proprietary id might have a numeral */
- if (isalnum(ch)) {
+ if (isalnum((unsigned char)ch)) {
/* store name separately */
context->input_name[context->input_count - 2] = ch;
/* checksum */
/* LOOKING FOR FIRST CHECKSUM CHARACTER */
case 3:
/* must be upper case hex digit */
- if (isxdigit(ch) && (ch <= 'F')) {
+ if (isxdigit((unsigned char)ch) && (ch <= 'F')) {
/* got first checksum byte */
context->input_state = 4;
context->icks = HEXTOBIN(ch) << 4;
/* LOOKING FOR SECOND CHECKSUM CHARACTER */
case 4:
/* must be upper case hex digit */
- if (isxdigit(ch) && (ch <= 'F')) {
+ if (isxdigit((unsigned char)ch) && (ch <= 'F')) {
/* got second checksum byte */
context->input_state = 5;
context->icks += HEXTOBIN(ch);