NMEAParser
NMEA Parser Library - Monte Variakojis @VisualGPS
Public Member Functions | Protected Member Functions | Private Types | Private Attributes | List of all members
CNMEAParserPacket Class Referenceabstract

This class will parse NMEA data packet and call its virtual processor methods. More...

#include <NMEAParserPacket.h>

Inheritance diagram for CNMEAParserPacket:
CNMEAParser

Public Member Functions

 CNMEAParserPacket ()
 
 ~CNMEAParserPacket ()
 
CNMEAParserData::ERROR_E ProcessNMEABuffer (char *pData, size_t nBufferSize)
 Parses pData for NMEA data. More...
 
void Reset (void)
 Reset the parser. More...
 
virtual void OnError (CNMEAParserData::ERROR_E nError, char *pCmd)
 This method is called whenever there is a parsing error. More...
 

Protected Member Functions

virtual CNMEAParserData::ERROR_E ProcessRxCommand (char *pCmd, char *pData)=0
 Redefine this method to process valid NMEA commands. Make sure that you honer the parameters below. More...
 
virtual void TimeTag (void)
 This method is called when receiving the start of message of the NMEA packet. More...
 

Private Types

enum  PARSE_STATE {
  PARSE_STATE_SOM = 0, PARSE_STATE_CMD, PARSE_STATE_DATA, PARSE_STATE_CHECKSUM_1,
  PARSE_STATE_CHECKSUM_2
}
 

Private Attributes

PARSE_STATE m_nState
 Current NMEA parse state. More...
 
uint8_t m_u8Checksum
 Calculated NMEA sentence checksum. More...
 
uint8_t m_u8ReceivedChecksum
 Received NMEA sentence checksum (if exists) More...
 
uint16_t m_nIndex
 Index used for command and data. More...
 
char m_pCommand [CNMEAParserData::c_uMaxCmdLen]
 NMEA command. More...
 
char m_pData [CNMEAParserData::c_uMaxDataLen]
 NMEA data. More...
 

Detailed Description

This class will parse NMEA data packet and call its virtual processor methods.

Below describes the ProcessNMEABuffer() methods state machine. It's whole goal is to connect data, build a command and call ProcessRxCommand robustly.

dot_inline_dotgraph_1.png
Receive Packet State Machine

Definition at line 66 of file NMEAParserPacket.h.

Member Enumeration Documentation

◆ PARSE_STATE

Enumerator
PARSE_STATE_SOM 

Search for start of message.

PARSE_STATE_CMD 

Get command.

PARSE_STATE_DATA 

Get data.

PARSE_STATE_CHECKSUM_1 

Get first checksum character.

PARSE_STATE_CHECKSUM_2 

get second checksum character

Definition at line 70 of file NMEAParserPacket.h.

Constructor & Destructor Documentation

◆ CNMEAParserPacket()

CNMEAParserPacket::CNMEAParserPacket ( )

Definition at line 28 of file NMEAParserPacket.cpp.

◆ ~CNMEAParserPacket()

CNMEAParserPacket::~CNMEAParserPacket ( )

Definition at line 37 of file NMEAParserPacket.cpp.

Member Function Documentation

◆ OnError()

virtual void CNMEAParserPacket::OnError ( CNMEAParserData::ERROR_E  nError,
char *  pCmd 
)
inlinevirtual

This method is called whenever there is a parsing error.

Redefine this method to capture errors.

Parameters
pCmdPointer to NMEA command that caused the error. Please note that this parameter may be NULL of not completely defined. Use with caution.

Definition at line 116 of file NMEAParserPacket.h.

◆ ProcessNMEABuffer()

CNMEAParserData::ERROR_E CNMEAParserPacket::ProcessNMEABuffer ( char *  pData,
size_t  nBufferSize 
)

Parses pData for NMEA data.

This method will parse pData for NMEA data.

Parameters
pDataPointer to buffer to parse
nBufferSizeNumber of bytes in pData to process.
Returns
CNMEAParserData::ERROR_E, if successful, ERROR_OK is returned.

Definition at line 41 of file NMEAParserPacket.cpp.

◆ ProcessRxCommand()

virtual CNMEAParserData::ERROR_E CNMEAParserPacket::ProcessRxCommand ( char *  pCmd,
char *  pData 
)
protectedpure virtual

Redefine this method to process valid NMEA commands. Make sure that you honer the parameters below.

Parameters
pCmdPointer to the NMEA command string
pDataComma separated data that belongs to the command
Returns
Returns CNMEAParserData::ERROR_OK If successful

Implemented in CNMEAParser.

◆ Reset()

void CNMEAParserPacket::Reset ( void  )

Reset the parser.

A reset will restart the parser to start to look for the start of message.

Definition at line 170 of file NMEAParserPacket.cpp.

◆ TimeTag()

virtual void CNMEAParserPacket::TimeTag ( void  )
inlineprotectedvirtual

This method is called when receiving the start of message of the NMEA packet.

If you need to time tag your NMEA sentences, redefine this method to allow you to capture when the SOM was received. You can then use the ProcessRxCommand() method to capture the NMEA command that this time-tag belongs to.

Definition at line 137 of file NMEAParserPacket.h.

Member Data Documentation

◆ m_nIndex

uint16_t CNMEAParserPacket::m_nIndex
private

Index used for command and data.

Definition at line 83 of file NMEAParserPacket.h.

◆ m_nState

PARSE_STATE CNMEAParserPacket::m_nState
private

Current NMEA parse state.

Definition at line 80 of file NMEAParserPacket.h.

◆ m_pCommand

char CNMEAParserPacket::m_pCommand[CNMEAParserData::c_uMaxCmdLen]
private

NMEA command.

Definition at line 84 of file NMEAParserPacket.h.

◆ m_pData

char CNMEAParserPacket::m_pData[CNMEAParserData::c_uMaxDataLen]
private

NMEA data.

Definition at line 85 of file NMEAParserPacket.h.

◆ m_u8Checksum

uint8_t CNMEAParserPacket::m_u8Checksum
private

Calculated NMEA sentence checksum.

Definition at line 81 of file NMEAParserPacket.h.

◆ m_u8ReceivedChecksum

uint8_t CNMEAParserPacket::m_u8ReceivedChecksum
private

Received NMEA sentence checksum (if exists)

Definition at line 82 of file NMEAParserPacket.h.


The documentation for this class was generated from the following files: