MityDSP Documentation Index
tcDspParseIHex

Introduction

The tcDspParseIHex class is a parser that works on Intel HEX files. When the class is constructed (or a ResetParser command is given) an output buffer is created or provided. Data is added to the parser via the AddData method. Data does not have to be aligned in any way. Any unconsumed data is preserved between calls to AddData.

Whenever a file is complete, or an error occurs, a user-provided callback (registered via the RegisterCallback method) is activated. The status and buffer location and maximum offset is provided. Also, a 32-bit checksum is provided for validation. This checksum is the summation of all line-by-line checksums seen in the file.

When an error occurs, the user callback may direct the parser to continue or reset, based upon the boolean returned.

See also:
MityDSP::tcDspParseIHex Class Reference
MityDSP::tcDspParserBase MityDSP Parser Base Class Reference

Example

This is a simple example of tcDspParseIHex creation and usage:

// Really big buffers are probably best set in a block of RAM reserved
// by the linker... otherwise, statically allocate or pull off the heap
const int gnBufAddr = 0x80200000;
const int gnBufLen = 0x00400000;
// obtain this in some application-specific way
// (if the callback will check it)
int myExpectedCksum = 0xABADD00D;
using namespace MityDSP;
bool myParserCallback(int anStatus, void *apBuffer,
int anLength, unsigned int anCksum)
{
if (anStatus == (int)tcDspParserBase::eeParseOK)
{
if (anCksum == myExpectedCksum)
{
// program FLASH
:
}
}
// reset parser after any error or complete message
return(true);
}
:
:
{
:
char inbuf[gnMaxLen];
int bytes;
tcDspParseIHex *myParser;
// create parser and register callback
myParser = new tcDspParseIHex((void *)gnBufferAddr, gnBufferLen);
myParser->RegisterCallback(myParserCallback);
// get data and pump it to the parser
while (true)
{
// get data from somewhere
:
// send to parser
if (myParser->AddData(inbuf, bytes) > 0)
{
// got one (or more)
:
}
else
{
// still working
:
}
:
}
:
}

  
Generated on Mon Apr 22 2013 11:33:02 for MityDSP Core by  Doxygen Version 1.8.1.1
Copyright © 2009, Critical Link LLC, All rights reserved.