This class provides a base class from which various MityDSP parsers may be derived. More...
#include <core/DspParserBase.h>
Public Types | |
enum | teDspParseStatus { eeParseOK = 0, eeParseChecksumErr = -1, eeParseSyncErr = -2, eeParseBustedMsg = -3, eeParseTooBigErr = -4, eeBaseLast = -5 } |
possible return status' More... | |
typedef bool(* | tfParserCallback )(int, void *, int, unsigned int, void *) |
Prototype for message complete callbacks. | |
Public Member Functions | |
tcDspParserBase (void *apOutBuf=NULL, int anOutBufLen=4096) | |
This constructor is used to create an instance of a parser. | |
virtual | ~tcDspParserBase () |
This destructor is used to close up and free the resources tied to the associated parser. | |
virtual bool | ResetParser (void *apOutBuf=NULL, int anOutBufLen=0) |
This routine is used to reset a parser to an initialized state. | |
virtual int | AddData (void *apData, int anLength) |
This routine is used to add data to the parser. | |
virtual void | RegisterCallback (tfParserCallback afCallback, void *apUser=NULL) |
Registers the specified callback for the parser. | |
Public Attributes | |
unsigned int | mnBytesRead |
Bytes passed to parser. | |
unsigned int | mnBytesWritten |
Bytes written to buffer. | |
unsigned int | mnGoodMsgs |
Count of valid messages decoded. | |
unsigned int | mnBadMsgs |
Count of bad messages. | |
unsigned int | mnSyncErrs |
Number of synchronization errors. | |
unsigned int | mnChecksumErrs |
Number of checksum errors. | |
Protected Member Functions | |
int | AssembleLine (void *apInput, int anLength, bool &arLineComplete) |
Utility routine to assemble a line of data (delimited by a <CR> or <LF>) into the local line buffer. | |
char | AsciiHexDigitVal (char anHexdigit) |
This routine converts a hex character (0-9, a-f, or A-F) to it's corresponding numeric value. | |
Protected Attributes | |
tfParserCallback | mfCallback |
Storage for parser callback. | |
C_SECT | mhMutex |
Semaphore to serialize access. | |
bool | mbStorageCreated |
Indicates whether out buf created. | |
void * | mpOutBuf |
Pointer to output storage. | |
int | mnOutBufLen |
Current bytes written to output. | |
unsigned int | mnChecksum |
Storage to accumulate checksum. | |
char * | maLineBuffer |
Storage to acculate complete lines (or other entities) to parse. | |
int | mnLineBufLen |
Length of line buffer. | |
int | mnLinePos |
Working position in the line buffer. | |
void * | mpUserParameter |
User-provided parameter to callback. |
This class provides a base class from which various MityDSP parsers may be derived.
typedef bool(* MityDSP::tcDspParserBase::tfParserCallback)(int, void *, int, unsigned int, void *) |
Prototype for message complete callbacks.
[in] | anStatus | Cast of teDspParseStatus to an integer |
[in] | apData | Pointer to the buffer containing parse results |
[in] | anLength | Length of parse results |
[in] | anInfo | Other buffer info (usually a checksum) |
[in] | apUser | User parameter (provided at registration) |
tcDspParserBase::tcDspParserBase | ( | void * | apOutBuf = NULL , |
|
int | anOutBufLen = 4096 | |||
) |
This constructor is used to create an instance of a parser.
Storage for parser output, and the maximum size of the output, may be optionally provided. If no buffer is provided, the class attempts to create one.
[in] | apOutBuf | Address of parser output buffer (default: NULL) |
[in] | anOutBufLen | Length of output buffer (default: 4K) |
tcDspParserBase::~tcDspParserBase | ( | ) | [virtual] |
This destructor is used to close up and free the resources tied to the associated parser.
bool tcDspParserBase::ResetParser | ( | void * | apOutBuf = NULL , |
|
int | anOutBufLen = 0 | |||
) | [virtual] |
This routine is used to reset a parser to an initialized state.
A new output buffer may optionally be provided.
[in] | apOutBuf | Address of new parser output buffer (default: NULL) |
[in] | anOutBufLen | Length of new output buffer (default: 0) |
Reimplemented in MityDSP::tcDspParseIHex.
int tcDspParserBase::AddData | ( | void * | apData, | |
int | anLength | |||
) | [virtual] |
This routine is used to add data to the parser.
In the base class, this is simply a "passthrough"... the input data is taken as a complete message and is passed to the callback. If the input fits in the output, the status is eeParseOK, otherwise eeParseTooBigErr.
[in] | apData | Pointer to new data |
[in] | anLength | Length of new data |
Reimplemented in MityDSP::tcDspParseIHex.
void tcDspParserBase::RegisterCallback | ( | tfParserCallback | afCallback, | |
void * | apUser = NULL | |||
) | [virtual] |
Registers the specified callback for the parser.
[in] | afCallback | The application callback to associate with the parser (or NULL for none). |
[in] | apUser | An argument to be supplied with the callback. |
int tcDspParserBase::AssembleLine | ( | void * | apInput, | |
int | anLength, | |||
bool & | arLineComplete | |||
) | [protected] |
Utility routine to assemble a line of data (delimited by a <CR> or <LF>) into the local line buffer.
[in] | apInput | Pointer to the raw input data. |
[in] | anLength | Length of available raw data. |
[out] | arLineComplete | Set to true if a completed line is available. |
char tcDspParserBase::AsciiHexDigitVal | ( | char | anHexdigit | ) | [protected] |
This routine converts a hex character (0-9, a-f, or A-F) to it's corresponding numeric value.
[in] | anHexdigit | The ASCII character to convert |
unsigned int MityDSP::tcDspParserBase::mnBytesRead |
Bytes passed to parser.
unsigned int MityDSP::tcDspParserBase::mnBytesWritten |
Bytes written to buffer.
unsigned int MityDSP::tcDspParserBase::mnGoodMsgs |
Count of valid messages decoded.
unsigned int MityDSP::tcDspParserBase::mnBadMsgs |
Count of bad messages.
unsigned int MityDSP::tcDspParserBase::mnSyncErrs |
Number of synchronization errors.
unsigned int MityDSP::tcDspParserBase::mnChecksumErrs |
Number of checksum errors.
tfParserCallback MityDSP::tcDspParserBase::mfCallback [protected] |
Storage for parser callback.
C_SECT MityDSP::tcDspParserBase::mhMutex [protected] |
Semaphore to serialize access.
bool MityDSP::tcDspParserBase::mbStorageCreated [protected] |
Indicates whether out buf created.
void* MityDSP::tcDspParserBase::mpOutBuf [protected] |
Pointer to output storage.
int MityDSP::tcDspParserBase::mnOutBufLen [protected] |
Current bytes written to output.
unsigned int MityDSP::tcDspParserBase::mnChecksum [protected] |
Storage to accumulate checksum.
char* MityDSP::tcDspParserBase::maLineBuffer [protected] |
Storage to acculate complete lines (or other entities) to parse.
int MityDSP::tcDspParserBase::mnLineBufLen [protected] |
Length of line buffer.
int MityDSP::tcDspParserBase::mnLinePos [protected] |
Working position in the line buffer.
void* MityDSP::tcDspParserBase::mpUserParameter [protected] |
User-provided parameter to callback.