OSTC Companion  3.0
Companion sofftware for H&W dive computers
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | List of all members
HexFile Class Reference

Read .hex file in "Intel HEX" format. More...

#include <HexFile.h>

Public Member Functions

 HexFile ()
 Create an empty object. More...
 
 ~HexFile ()
 
bool allocate (size_t memSize, unsigned char fill=0xFF)
 Allocate initialized space. More...
 
bool sqwiz (size_t newMemSize)
 
void load (const QString &fileName)
 Load the .hex file into the internal buffer. More...
 
const unsigned char * data () const
 Return a pointer to the loaded data. More...
 
unsigned int checksum () const
 Returns the 4 bytes checksum of the loaded data. More...
 
void saveEncrypted (const QString &fileName, unsigned char secretKey[16])
 Save to encrypted HEX file. More...
 
void loadEncrypted (const QString &fileName, unsigned char secretKey[16])
 Reload encrypted HEX file. More...
 

Detailed Description

Read .hex file in "Intel HEX" format.

Note
that OSTC3 firmware is NOT distributed in Intel HEX format, but is first flatened, then encrypted, then written back in a similar looking format.

Constructor & Destructor Documentation

HexFile::HexFile ( )

Create an empty object.

HexFile::~HexFile ( )

Member Function Documentation

bool HexFile::allocate ( size_t  memSize,
unsigned char  fill = 0xFF 
)

Allocate initialized space.

unsigned int HexFile::checksum ( ) const

Returns the 4 bytes checksum of the loaded data.

This is a simple Adler32 checksum: The lower 16bits are the sum of all the bytes (modulo 65536). And the second 16bits are the sum of the running sum itself (also modulo 65536).

const unsigned char * HexFile::data ( ) const

Return a pointer to the loaded data.

void HexFile::load ( const QString &  fileName)

Load the .hex file into the internal buffer.

Returns
TRUE is ok, FAlSE if some error occurs.
void HexFile::loadEncrypted ( const QString &  fileName,
unsigned char  secretKey[16] 
)

Reload encrypted HEX file.

void HexFile::saveEncrypted ( const QString &  fileName,
unsigned char  secretKey[16] 
)

Save to encrypted HEX file.

bool HexFile::sqwiz ( size_t  newMemSize)

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