Here are a couple of general utility functions. Methods may of course also call C runtime-library functions and Windows API functions.
General Utility Functions
|
Function Name |
Purpose |
|
GetNextByteBoundary |
Adjusts an offset to the next byte boundary |
|
GetLongField |
Extracts data with optional byte reordering |
|
GetRawFrame |
Extracts the raw data for an entire frame and returns true if successful |
int GetNextByteBoundary(int ibitOffset) takes a number representing a bit offset and returns a byte offset. If the bit offset points to a byte boundary then the byte offset of that byte is returned. Otherwise the byte offset of the next byte is returned. Use of this function is exemplified by the StartBit Method called NextByteBoundary.
START_BIT
METHOD NextByteBoundary
/* Moves the pointer to the beginning of the next byte.
If the pointer is already at a byte boundary, it doesn't move. */
CODE
iOutput = MTH::GetNextByteBoundary(iofsbitCurrentPosition) * 8;
ENDCODE
void GetLongField(Abyte& abResults, const BYTE* pabFrame, int iCurrentBit, int iSize, bool bHostDataOrder)extracts iSize bits starting at bit offset iCurrentBit from the byte array pabFrame and stores them into abResults. If bHostDataOrder is true then the byte ordering is reversed. This function is most commonly used to extract data from abytLayer.
bool GetRawFrame(pCaptBuff, evn, abData) extracts the raw data from an entire frame and returns true if successful.
int64 evn; // This is the frame number. It must come from the
// evnFrameNumber parameter. If you want
// to retrieve a different frame, you must save that
// frame's evnFrameNumber in inter-frame data to
// retrieve it now.
Abyte abData; // The array to receive the data.
if (MTH::fxnGetRawFrame(pCaptBuff, evn, abData)) // get the frame
{
for (int i = 0; i < abData.GetSize(); i++)
{
// abData[i] is one byte of the returned frame.
}
}
else
{
// error case - we didn't get the frame.
}