#include <stdlib.h>
#include <string.h>
#include "NMEA_Lib.h"
void sentenceToWPID(char * sentence, UINT32 * uint32_ptr, WPID * sentence_index, UINT32 position, UINT32 * flags)
{
UINT8 i = 0;
CHAR sub_str[15];
UINT32 subsentence_index = 0;
if(',' == sentence[*sentence_index] && ',' != sentence[*sentence_index+1])
{
(*sentence_index)++;
while(',' != sentence[*sentence_index])
{
sub_str[subsentence_index++] = sentence[(*sentence_index)++];
}
*uint32_ptr = atoi(sub_str);
}
else
{
(*sentence_index)++;
*uint32_ptr = 0;
}
return;
}
void sentenceToUTC(char * sentence, UINT32 * uint32_ptr, UTC * sentence_index, UINT32 position, UINT32 * flags)
{
UINT8 i = 0;
CHAR sub_str[15];
UINT32 subsentence_index = 0;
if(',' == sentence[*sentence_index] && ',' != sentence[*sentence_index+1])
{
(*sentence_index)++;
while(',' != sentence[*sentence_index])
{
sub_str[subsentence_index++] = sentence[(*sentence_index)++];
}
*uint32_ptr = atoi(sub_str);
}
else
{
(*sentence_index)++;
*uint32_ptr = 0;
}
return;
}
void sentenceToPOINT(char * sentence, POINTPTR point_ptr, UINT32 * sentence_index, UINT32 position, UINT32 * flags)
{
UINT8 i = 0;
CHAR sub_str[15];
if(',' == sentence[*sentence_index] && ',' != sentence[*sentence_index+1])
{
(*sentence_index)++;
while('.' != sentence[*sentence_index])
{
sub_str[i] = sentence[(*sentence_index)];
(*sentence_index)++;
i++;
}
sub_str[i] = '\0';
point_ptr->x = atoi(sub_str);
i = 0;
(*sentence_index)++;
while(',' != sentence[*sentence_index])
{
sub_str[i] = sentence[*sentence_index];
(*sentence_index)++;
i++;
}
sub_str[i] = '\0';
point_ptr->y = atoi(sub_str);
}
else
{
(*sentence_index)++;
point_ptr->x = 0;
point_ptr->y = 0;
}
return;
}
void sentenceToUINT32(char * sentence, UINT32 * uint32_ptr, UINT32 * sentence_index, UINT32 position, UINT32 * flags)
{
UINT8 i = 0;
CHAR sub_str[15];
UINT32 subsentence_index = 0;
if(',' == sentence[*sentence_index] && ',' != sentence[*sentence_index+1])
{
(*sentence_index)++;
while(',' != sentence[*sentence_index])
{
sub_str[subsentence_index++] = sentence[(*sentence_index)++];
}
*uint32_ptr = atoi(sub_str);
}
else
{
(*sentence_index)++;
*uint32_ptr = 0;
}
return;
}
void sentenceToUINT16(char * sentence, UINT16 * uint16_ptr, UINT32 * sentence_index, UINT32 position, UINT32 * flags)
{
UINT8 i = 0;
CHAR sub_str[15];
UINT32 subsentence_index = 0;
if(',' == sentence[*sentence_index] && ',' != sentence[*sentence_index+1])
{
(*sentence_index)++;
while(',' != sentence[*sentence_index])
{
sub_str[subsentence_index++] = sentence[(*sentence_index)++];
}
*uint16_ptr = atoi(sub_str);
}
else
{
(*sentence_index)++;
*uint16_ptr = 0;
}
return;
}
void sentenceToUINT8(char * sentence, UINT8 * uint8_ptr, UINT32 * sentence_index, UINT32 position, UINT32 * flags)
{
UINT8 i = 0;
CHAR sub_str[15];
UINT32 subsentence_index = 0;
if(',' == sentence[*sentence_index] && ',' != sentence[*sentence_index+1])
{
(*sentence_index)++;
while(',' != sentence[*sentence_index])
{
sub_str[subsentence_index++] = sentence[(*sentence_index)++];
}
*uint8_ptr = atoi(sub_str);
}
else
{
(*sentence_index)++;
*uint8_ptr = 0;
}
return;
}
void sentenceToCHAR(CHAR * sentence, CHAR * char_ptr, UINT32 * sentence_index, UINT32 position, UINT32 * flags)
{
UINT8 i = 0;
CHAR sub_str[15];
UINT32 subsentence_index = 0;
if(',' == sentence[*sentence_index] && ',' != sentence[*sentence_index+1])
{
(*sentence_index)++;
*char_ptr = sentence[(*sentence_index)++];
}
else
{
(*sentence_index)++;
}
return;
}
void sentenceToWAYPOINT(CHAR * sentence, CHAR * waypoint_ptr, UINT32 * sentence_index, UINT32 position, UINT32 * flags)
{
UINT8 i = 0;
CHAR sub_str[15];
UINT32 subsentence_index = 0;
if(',' == sentence[*sentence_index] && ',' != sentence[*sentence_index+1])
{
(*sentence_index)++;
strncpy(waypoint_ptr, sentence+(*sentence_index), 4)[4] = '\0';
*sentence_index += 5;
}
else
{
(*sentence_index)++;
waypoint_ptr[0] = '\0';
}
return;
}
void sentenceToDATE(CHAR * sentence, DATE * date_ptr, UINT32 * sentence_index, UINT32 position, UINT32 * flags)
{
if(',' == sentence[*sentence_index] && ',' != sentence[*sentence_index+1])
{
(*sentence_index)++;
strncpy(date_ptr, sentence+(*sentence_index), 6)[6] = '\0';
*sentence_index += 6;
}
else
{
(*sentence_index)++;
date_ptr[0] = '\0';
}
return;
}
void sentenceToTIME(CHAR * sentence, CHAR * time_ptr, UINT32 * sentence_index, UINT32 position, UINT32 * flags)
{
UINT32 str_index = 0;
if(',' == sentence[*sentence_index] && ',' != sentence[*sentence_index+1])
{
/*assert(isdigit(sentence[4]));*/
(*sentence_index)++;
while(',' != sentence[*sentence_index])
{
time_ptr[str_index] = sentence[*sentence_index];
(*sentence_index)++;
str_index++;
}
time_ptr[str_index] = '\0';
}
else
{
(*sentence_index)++;
time_ptr[0] = '\0';
}
return;
}
void sentenceToBOOL(char * sentence, BOOL * char_ptr, UINT32 * sentence_index, UINT32 position, UINT32 * flags)
{
UINT8 i = 0;
CHAR sub_str[15];
UINT32 subsentence_index = 0;
if(',' == sentence[*sentence_index] && ',' != sentence[*sentence_index+1])
{
(*sentence_index)++;
*char_ptr = sentence[(*sentence_index)++];
}
else
{
(*sentence_index)++;
}
return;
}
void sentenceFromBOOL(char * sentence, BOOL * char_ptr, UINT32 * sentence_index, UINT32 position, UINT32 * flags)
{
UINT8 i = 0;
CHAR sub_str[15];
UINT32 subsentence_index = 0;
if(',' == sentence[*sentence_index] && ',' != sentence[*sentence_index+1])
{
(*sentence_index)++;
*char_ptr = sentence[(*sentence_index)++];
}
else
{
(*sentence_index)++;
}
return;
}
void sentenceFromWPID(char * sentence, WPID * uint32_ptr, UINT32 * sentence_index, UINT32 position, UINT32 * flags)
{
UINT8 i = 0;
CHAR sub_str[15];
UINT32 subsentence_index = 0;
if(',' == sentence[*sentence_index] && ',' != sentence[*sentence_index+1])
{
(*sentence_index)++;
while(',' != sentence[*sentence_index])
{
sub_str[subsentence_index++] = sentence[(*sentence_index)++];
}
*uint32_ptr = atoi(sub_str);
}
else
{
(*sentence_index)++;
*uint32_ptr = 0;
}
return;
}
void sentenceFromUTC(char * sentence, UTC * uint32_ptr, UINT32 * sentence_index, UINT32 position, UINT32 * flags)
{
UINT8 i = 0;
CHAR sub_str[15];
UINT32 subsentence_index = 0;
if(',' == sentence[*sentence_index] && ',' != sentence[*sentence_index+1])
{
(*sentence_index)++;
while(',' != sentence[*sentence_index])
{
sub_str[subsentence_index++] = sentence[(*sentence_index)++];
}
*uint32_ptr = atoi(sub_str);
}
else
{
(*sentence_index)++;
*uint32_ptr = 0;
}
return;
}
void sentenceFromPOINT(char * sentence, POINTPTR point_ptr, UINT32 * sentence_index, UINT32 posit
评论0