⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nmea_apb.c

📁 the example file that can decode the NMEA protocol
💻 C
字号:
#include <stdlib.h>#include <string.h>#include "NMEA_Lib.h"#if (NMEA_INCLUDE_APB == 1)#include "NMEA_APB.h"BOOL NMEA_ParseAPBSentence(CHAR * sentence, struct NMEAObject_t * NMEAObject, UINT32 * flags){    UINT32 sentence_index = 3;    BOOL ret_val = NMEA_FAILURE;    if('A' == sentence[0] && 'P' == sentence[1] && 'B' == sentence[2])    {        sentenceToCHAR(sentence, &NMEAObject->APBObject.StatusBlink, &sentence_index, NMEA_APB_STATUSBLINK, flags);        sentenceToCHAR(sentence, &NMEAObject->APBObject.StatusCycleLockWarning, &sentence_index, NMEA_APB_STATUSCYCLELOCKWARNING, flags);        sentenceToPOINT(sentence, &NMEAObject->APBObject.CrossTrackErrorMagnitude, &sentence_index, NMEA_APB_CROSSTRACKERRORMAGNITUDE, flags);        sentenceToCHAR(sentence, &NMEAObject->APBObject.DirectionToSteer, &sentence_index, NMEA_APB_DIRECTIONTOSTEER, flags);        sentenceToCHAR(sentence, &NMEAObject->APBObject.CrossTrackUnits, &sentence_index, NMEA_APB_CROSSTRACKUNITS, flags);        sentenceToCHAR(sentence, &NMEAObject->APBObject.StatusArrivalCircleEntered, &sentence_index, NMEA_APB_STATUSARRIVALCIRCLEENTERED, flags);        sentenceToCHAR(sentence, &NMEAObject->APBObject.StatusPerpendicularPassedAtWaypoint, &sentence_index, NMEA_APB_STATUSPERPENDICULARPASSEDATWAYPOINT, flags);        sentenceToPOINT(sentence, &NMEAObject->APBObject.BearingOriginToDestination, &sentence_index, NMEA_APB_BEARINGORIGINTODESTINATION, flags);        sentenceToCHAR(sentence, &NMEAObject->APBObject.BODDeclination, &sentence_index, NMEA_APB_BODDECLINATION, flags);        sentenceToWPID(sentence, &NMEAObject->APBObject.DestinationWaypointID, &sentence_index, NMEA_APB_DESTINATIONWAYPOINTID, flags);        sentenceToPOINT(sentence, &NMEAObject->APBObject.BearingPresentPositionToDestination, &sentence_index, NMEA_APB_BEARINGPRESENTPOSITIONTODESTINATION, flags);        sentenceToCHAR(sentence, &NMEAObject->APBObject.Declination, &sentence_index, NMEA_APB_DECLINATION, flags);        sentenceToPOINT(sentence, &NMEAObject->APBObject.HeadingToSteerToDestinationWaypoint, &sentence_index, NMEA_APB_HEADINGTOSTEERTODESTINATIONWAYPOINT, flags);        sentenceToCHAR(sentence, &NMEAObject->APBObject.HTSDWDeclination, &sentence_index, NMEA_APB_HTSDWDECLINATION, flags);    }    return ret_val;}BOOL NMEA_CreateAPBSentence(CHAR * sentence, struct NMEAObject_t * NMEAObject, UINT32 * flags){    UINT32 sentence_index = 3;    BOOL ret_val = NMEA_FAILURE;    sentence[0] = 'A';    sentence[1] = 'P';    sentence[2] = 'B';    sentenceFromCHAR(sentence, &NMEAObject->APBObject.StatusBlink, &sentence_index, NMEA_APB_STATUSBLINK, flags);    sentenceFromCHAR(sentence, &NMEAObject->APBObject.StatusCycleLockWarning, &sentence_index, NMEA_APB_STATUSCYCLELOCKWARNING, flags);    sentenceFromPOINT(sentence, &NMEAObject->APBObject.CrossTrackErrorMagnitude, &sentence_index, NMEA_APB_CROSSTRACKERRORMAGNITUDE, flags);    sentenceFromCHAR(sentence, &NMEAObject->APBObject.DirectionToSteer, &sentence_index, NMEA_APB_DIRECTIONTOSTEER, flags);    sentenceFromCHAR(sentence, &NMEAObject->APBObject.CrossTrackUnits, &sentence_index, NMEA_APB_CROSSTRACKUNITS, flags);    sentenceFromCHAR(sentence, &NMEAObject->APBObject.StatusArrivalCircleEntered, &sentence_index, NMEA_APB_STATUSARRIVALCIRCLEENTERED, flags);    sentenceFromCHAR(sentence, &NMEAObject->APBObject.StatusPerpendicularPassedAtWaypoint, &sentence_index, NMEA_APB_STATUSPERPENDICULARPASSEDATWAYPOINT, flags);    sentenceFromPOINT(sentence, &NMEAObject->APBObject.BearingOriginToDestination, &sentence_index, NMEA_APB_BEARINGORIGINTODESTINATION, flags);    sentenceFromCHAR(sentence, &NMEAObject->APBObject.BODDeclination, &sentence_index, NMEA_APB_BODDECLINATION, flags);    sentenceFromWPID(sentence, &NMEAObject->APBObject.DestinationWaypointID, &sentence_index, NMEA_APB_DESTINATIONWAYPOINTID, flags);    sentenceFromPOINT(sentence, &NMEAObject->APBObject.BearingPresentPositionToDestination, &sentence_index, NMEA_APB_BEARINGPRESENTPOSITIONTODESTINATION, flags);    sentenceFromCHAR(sentence, &NMEAObject->APBObject.Declination, &sentence_index, NMEA_APB_DECLINATION, flags);    sentenceFromPOINT(sentence, &NMEAObject->APBObject.HeadingToSteerToDestinationWaypoint, &sentence_index, NMEA_APB_HEADINGTOSTEERTODESTINATIONWAYPOINT, flags);    sentenceFromCHAR(sentence, &NMEAObject->APBObject.HTSDWDeclination, &sentence_index, NMEA_APB_HTSDWDECLINATION, flags);    return ret_val;}#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -