Critical Link MityCam SoC Firmware  1.0
Critical Link MityCam SoC Firmware
SocCamera::tcDspParserBase Class Reference

#include "core/DspParserBase.h"

Inheritance diagram for SocCamera::tcDspParserBase:
Collaboration diagram for SocCamera::tcDspParserBase:

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 *)
 

Public Member Functions

 tcDspParserBase (char *apOutBuf=NULL, int anOutBufLen=4096)
 
virtual ~tcDspParserBase ()
 
virtual bool ResetParser (char *apOutBuf=NULL, int anOutBufLen=0)
 
virtual int AddData (void *apData, int anLength)
 
virtual void RegisterCallback (tfParserCallback afCallback, void *apUser=NULL)
 

Public Attributes

unsigned int mnBytesRead
 Bytes passed to parser. More...
 
unsigned int mnBytesWritten
 Bytes written to buffer. More...
 
unsigned int mnGoodMsgs
 Count of valid messages decoded. More...
 
unsigned int mnBadMsgs
 Count of bad messages. More...
 
unsigned int mnSyncErrs
 Number of synchronization errors. More...
 
unsigned int mnChecksumErrs
 Number of checksum errors. More...
 

Protected Member Functions

int AssembleLine (void *apInput, int anLength, bool &arLineComplete)
 
char AsciiHexDigitVal (char anHexdigit)
 

Protected Attributes

tfParserCallback mfCallback
 Storage for parser callback. More...
 
C_SECT mhMutex
 Semaphore to serialize access. More...
 
bool mbStorageCreated
 Indicates whether out buf created. More...
 
char * mpOutBuf
 Pointer to output storage. More...
 
int mnOutBufLen
 Current bytes written to output. More...
 
unsigned int mnChecksum
 Storage to accumulate checksum. More...
 
char * maLineBuffer
 (or other entities) to parse. More...
 
int mnLineBufLen
 Length of line buffer. More...
 
int mnLinePos
 Working position in the line buffer. More...
 
void * mpUserParameter
 User-provided parameter to callback. More...
 

Detailed Description

This class provides a base class from which various MityDSP parsers may be derived.

See also
tcDspParserBase Page

Member Typedef Documentation

◆ tfParserCallback

typedef bool(* SocCamera::tcDspParserBase::tfParserCallback) (int, void *, int, unsigned int, void *)

Prototype for message complete callbacks.

Parameters
[in]anStatusCast of teDspParseStatus to an integer
[in]apDataPointer to the buffer containing parse results
[in]anLengthLength of parse results
[in]anInfoOther buffer info (usually a checksum)
[in]apUserUser parameter (provided at registration)
Returns
True to continue parsing, if possible False to restart parser on next message

Member Enumeration Documentation

◆ teDspParseStatus

possible return status'

Enumerator
eeParseOK 

success

eeParseChecksumErr 

checksum failure

eeParseSyncErr 

data sync error

eeParseBustedMsg 

broken message (missing data)

eeParseTooBigErr 

result too big for output buffer

eeBaseLast 

base class

errors beyond this are outside

Constructor & Destructor Documentation

◆ tcDspParserBase()

tcDspParserBase::tcDspParserBase ( char *  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.

Parameters
[in]apOutBufAddress of parser output buffer (default: NULL)
[in]anOutBufLenLength of output buffer (default: 4K)
Returns
None.
See also
DspParserBase.h

◆ ~tcDspParserBase()

tcDspParserBase::~tcDspParserBase ( )
virtual

This destructor is used to close up and free the resources tied to the associated parser.

Returns
None.
See also
DspParserBase.h

Member Function Documentation

◆ AddData()

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.

Parameters
[in]apDataPointer to new data
[in]anLengthLength of new data
Returns
Integer number of messages completed this call.
See also
DspParserBase.h

Reimplemented in tcCamParser.

◆ AsciiHexDigitVal()

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.

Parameters
[in]anHexdigitThe ASCII character to convert
Returns
The resulting numeric value
See also
DspParserBase.h

◆ AssembleLine()

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.

Parameters
[in]apInputPointer to the raw input data.
[in]anLengthLength of available raw data.
[out]arLineCompleteSet to true if a completed line is available.
Returns
Number of bytes consumed from the input buffer.
See also
DspParserBase.h

◆ RegisterCallback()

void tcDspParserBase::RegisterCallback ( tfParserCallback  afCallback,
void *  apUser = NULL 
)
virtual

Registers the specified callback for the parser.

Parameters
[in]afCallbackThe application callback to associate with the parser (or NULL for none).
[in]apUserAn argument to be supplied with the callback.
Returns
None.
See also
DspParserBase.h

◆ ResetParser()

bool tcDspParserBase::ResetParser ( char *  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.

Parameters
[in]apOutBufAddress of new parser output buffer (default: NULL)
[in]anOutBufLenLength of new output buffer (default: 0)
Returns
True, if successful.
See also
DspParserBase.h

Reimplemented in tcCamParser.

Member Data Documentation

◆ maLineBuffer

char* SocCamera::tcDspParserBase::maLineBuffer
protected

(or other entities) to parse.

Storage to acculate complete lines

◆ mbStorageCreated

bool SocCamera::tcDspParserBase::mbStorageCreated
protected

Indicates whether out buf created.

◆ mfCallback

tfParserCallback SocCamera::tcDspParserBase::mfCallback
protected

Storage for parser callback.

◆ mhMutex

C_SECT SocCamera::tcDspParserBase::mhMutex
protected

Semaphore to serialize access.

◆ mnBadMsgs

unsigned int SocCamera::tcDspParserBase::mnBadMsgs

Count of bad messages.

◆ mnBytesRead

unsigned int SocCamera::tcDspParserBase::mnBytesRead

Bytes passed to parser.

◆ mnBytesWritten

unsigned int SocCamera::tcDspParserBase::mnBytesWritten

Bytes written to buffer.

◆ mnChecksum

unsigned int SocCamera::tcDspParserBase::mnChecksum
protected

Storage to accumulate checksum.

◆ mnChecksumErrs

unsigned int SocCamera::tcDspParserBase::mnChecksumErrs

Number of checksum errors.

◆ mnGoodMsgs

unsigned int SocCamera::tcDspParserBase::mnGoodMsgs

Count of valid messages decoded.

◆ mnLineBufLen

int SocCamera::tcDspParserBase::mnLineBufLen
protected

Length of line buffer.

◆ mnLinePos

int SocCamera::tcDspParserBase::mnLinePos
protected

Working position in the line buffer.

◆ mnOutBufLen

int SocCamera::tcDspParserBase::mnOutBufLen
protected

Current bytes written to output.

◆ mnSyncErrs

unsigned int SocCamera::tcDspParserBase::mnSyncErrs

Number of synchronization errors.

◆ mpOutBuf

char* SocCamera::tcDspParserBase::mpOutBuf
protected

Pointer to output storage.

◆ mpUserParameter

void* SocCamera::tcDspParserBase::mpUserParameter
protected

User-provided parameter to callback.


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