NMEAParser
NMEAParser copied to clipboard
[Suggestion of minor evolution] Removing verbose
Hello,
(First of all, thank you for sharing this code!)
The function CNMEAParser::ProcessRxCommand has a printf that can be annoying when used in an application that already has a certain level of verbosity.
Since this function can be overloaded by child classes as described in the documentation, could it be removed from the parent class and be placed in the example's child class instead? Something like :
Parent CNMEAParser class:
CNMEAParserData::ERROR_E CNMEAParser::ProcessRxCommand(char * pCmd, char * pData)
{
/* REMOVE FROM HERE ....
//
// Grab the talker ID
//
uint16_t u16TalkerID = (uint16_t)((uint8_t)pCmd[0]) << 8;
u16TalkerID |= (uint16_t)((uint8_t)pCmd[1]);
//
// Get the sentence ID, --XXX where XXX is the sentence ID
//
char *lpszSentenceID = &pCmd[2];
printf("Cmd: %s, TalkerID:%c%c, Sentence ID: %s\n", pCmd, (u16TalkerID >> 8) & 0xFF, (u16TalkerID) & 0xFF, lpszSentenceID);
... UNTIL HERE */
//-----------------------------------------------------------------------------
// ...
Child example class:
///
/// \brief This method is redefined from CNMEAParserPacket::ProcessRxCommand(char *pCmd, char *pData)
///
/// \param pCmd Pointer to the NMEA command string
/// \param pData Comma separated data that belongs to the command
/// \return Returns CNMEAParserData::ERROR_OK If successful
///
virtual CNMEAParserData::ERROR_E ProcessRxCommand(char *pCmd, char *pData) {
// Grab the talker ID
uint16_t u16TalkerID = (uint16_t)((uint8_t)pCmd[0]) << 8;
u16TalkerID |= (uint16_t)((uint8_t)pCmd[1]);
// Get the sentence ID, --XXX where XXX is the sentence ID
char *lpszSentenceID = &pCmd[2];
// Debug verbosity
printf("Cmd: %s, TalkerID:%c%c, Sentence ID: %s\n", pCmd, (u16TalkerID >> 8) & 0xFF, (u16TalkerID) & 0xFF, lpszSentenceID);
// Call base class to process the command
CNMEAParser::ProcessRxCommand(pCmd, pData);
return CNMEAParserData::ERROR_OK;
}
(Or the verbosity could be embedded in a #define so it could be turned ON/OFF.)
This way, the example in the documentation would have the very same behavior but the user would be free not to have any verbosity.