Instances of this class may be used to parse an Intel HEX file into an application-provided buffer. More...
#include <core/DspParseIHex.h>
Public Member Functions | |
tcDspParseIHex (void *apOutBuf=NULL, int anOutBufLen=4096) | |
This constructor is used to create an instance of an Intel HEX record parser. | |
~tcDspParseIHex () | |
This destructor is used to close up and free the resources tied to the associated parser. | |
bool | ResetParser (void *apOutBuf=NULL, int anOutBufLen=0) |
This routine is used to reset a parser to an initialized state. | |
int | AddData (void *apData, int anLength) |
This routine is used to add data to the parser. | |
void | DisableOutput (bool abDisable) |
This method allows writing to the output buffer to be disabled (for instance, when performing only a validation of a file). | |
void | ResetOutputBuffer (char anBlank) |
This method clears the output buffer using the provided character. | |
Public Member Functions inherited from MityDSP::tcDspParserBase | |
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 void | RegisterCallback (tfParserCallback afCallback, void *apUser=NULL) |
Registers the specified callback for the parser. |
Additional Inherited Members | |
Public Types inherited from MityDSP::tcDspParserBase | |
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 Attributes inherited from MityDSP::tcDspParserBase | |
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 inherited from MityDSP::tcDspParserBase | |
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 inherited from MityDSP::tcDspParserBase | |
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. |
Instances of this class may be used to parse an Intel HEX file into an application-provided buffer.
tcDspParseIHex::tcDspParseIHex | ( | void * | apOutBuf = NULL , |
int | anOutBufLen = 4096 |
||
) |
This constructor is used to create an instance of an Intel HEX record 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 | - Lngth of output buffer (default: 4K) |
tcDspParseIHex::~tcDspParseIHex | ( | ) |
This destructor is used to close up and free the resources tied to the associated parser.
|
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 from MityDSP::tcDspParserBase.
|
virtual |
This routine is used to add data to the parser.
In this class, the parse finds a start record, and then decodes data records, until an end record is reached. At this point the registered callback is activated with a status of eeParseOK.
Errors are generated if the start record is not found when expected, if any of the decoded data falls outside the provided output buffer, or if any of the individual record checksums are incorrect.
A running 32-bit checksum is maintained for the entire file, and is passed to the callback upon completion.
[in] | apData | - Pointer to new data |
[in] | anLength | - Length of new data |
Reimplemented from MityDSP::tcDspParserBase.
void tcDspParseIHex::DisableOutput | ( | bool | abDisable | ) |
This method allows writing to the output buffer to be disabled (for instance, when performing only a validation of a file).
[in] | abDisable | True to disable writing to the output buffer. |
void tcDspParseIHex::ResetOutputBuffer | ( | char | anBlank | ) |
This method clears the output buffer using the provided character.
[in] | anBlank | The character to use to clear the buffer. |