lib/HalModuleParser.js
function(fileBuffer) {
		// last 4 bytes of the file are the crc
		// 2 bytes before that is suffix payload size

		//lets read the suffix backwards.

		var idx = fileBuffer.length - 4;
		var crcBlock = fileBuffer.slice(idx, idx + 4).toString('hex');

		idx -= 2;
		var suffixSize = fileBuffer.readUInt16LE(idx);

		idx -= 32;
		var fwUniqueId = fileBuffer.slice(idx, idx + 32).toString('hex');

		idx -= 2;
		var reserved = fileBuffer.readUInt16LE(idx);

		idx -= 2;
		var productVersion = fileBuffer.readUInt16LE(idx);

		idx -= 2;
		var productId = fileBuffer.readUInt16LE(idx);


		if (reserved === 0) {
			//cool!
		}

		if (suffixSize < 40) {
			productId = -1;
			productVersion = -1;
		}

		return {
			productId: productId,
			productVersion: productVersion,
			fwUniqueId: fwUniqueId,
			reserved: reserved,
			suffixSize: suffixSize,
			crcBlock: crcBlock
		};
	}
function(fileBuffer) {
		// last 4 bytes of the file are the crc
		// 2 bytes before that is suffix payload size

		//lets read the suffix backwards.

		var idx = fileBuffer.length - 4;
		var crcBlock = fileBuffer.slice(idx, idx + 4).toString('hex');

		idx -= 2;
		var suffixSize = fileBuffer.readUInt16LE(idx);

		idx -= 32;
		var fwUniqueId = fileBuffer.slice(idx, idx + 32).toString('hex');

		idx -= 2;
		var reserved = fileBuffer.readUInt16LE(idx);

		idx -= 2;
		var productVersion = fileBuffer.readUInt16LE(idx);

		idx -= 2;
		var productId = fileBuffer.readUInt16LE(idx);


		if (reserved === 0) {
			//cool!
		}

		if (suffixSize < 40) {
			productId = -1;
			productVersion = -1;
		}

		return {
			productId: productId,
			productVersion: productVersion,
			fwUniqueId: fwUniqueId,
			reserved: reserved,
			suffixSize: suffixSize,
			crcBlock: crcBlock
		};
	}
function ( fileBuffer ) { // last 4 bytes of the file are the crc // 2 bytes before that is suffix payload size //lets read the suffix backwards. var idx = fileBuffer . length - 4 ; var crcBlock = fileBuffer . slice ( idx , idx + 4 ) . toString ( 'hex' ) ; idx -= 2 ; var suffixSize = fileBuffer . readUInt16LE ( idx ) ; idx -= 32 ; var fwUniqueId = fileBuffer . slice ( idx , idx + 32 ) . toString ( 'hex' ) ; idx -= 2 ; var reserved = fileBuffer . readUInt16LE ( idx ) ; idx -= 2 ; var productVersion = fileBuffer . readUInt16LE ( idx ) ; idx -= 2 ; var productId = fileBuffer . readUInt16LE ( idx ) ; if ( reserved === 0 ) { //cool! } if ( suffixSize < 40 ) { productId = - 1 ; productVersion = - 1 ; } return { productId : productId , productVersion : productVersion , fwUniqueId : fwUniqueId , reserved : reserved , suffixSize : suffixSize , crcBlock : crcBlock } ; }
/*
parses out the suffix area of the binary, only reads back
into the file as far
as is provided by the 'suffixSize' value. Returns:
{
productId: (*|Number),
productVersion: (*|Number),
fwUniqueId: (*|String),
reserved: (*|Number),
suffixSize: (*|Number),
crcBlock: (*|String)
}

@param fileBuffer
@returns Object
@private
/ * parses out the suffix area of the binary only reads back into the file as far as is provided by the suffixSize value . Returns : { productId : ( * |Number ) productVersion : ( * |Number ) fwUniqueId : ( * |String ) reserved : ( * |Number ) suffixSize : ( * |Number ) crcBlock : ( * |String ) }