@connectedyard/node-intelhex
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -63,14 +63,13 @@ ( function() { | ||
var encodeUInt32 = ( littleEndian ) ? buffer.readUInt32LE : buffer.readUInt32BE; | ||
var words = []; | ||
const words = []; | ||
for( var offset = 0; offset < buffer.length; offset+=4 ){ | ||
words.push( encodeUInt32( offset )); | ||
const uint32 = ( littleEndian ) ? buffer.readUInt32LE( offset ) : buffer.readUInt32BE( offset ); | ||
words.push( uint32 ); | ||
} | ||
this.appendWords( words, false ); | ||
this.appendWords( words, littleEndian ); | ||
}; | ||
IntelHexFileOut.prototype.appendWords = function( words, littleEndian ){ | ||
if( !words || words.length === 0 || words.length * 4 > SEGMENT_LENGTH_BYTES ){ | ||
if( !words || words.length === 0 ){ // || words.length * 4 > SEGMENT_LENGTH_BYTES ){ | ||
throw new Error("invalid number of words [" + words.length + "]"); | ||
@@ -77,0 +76,0 @@ } |
{ | ||
"name": "@connectedyard/node-intelhex", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Building and converting between intel-hex and binary data", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -8,3 +8,3 @@ # node-intelhex | ||
``` | ||
var intelhex = require('node-intelhex'); | ||
var intelhex = require('@connectedyard/node-intelhex'); | ||
@@ -83,2 +83,2 @@ intelhex.binaryFileToIntelHexFile( "binaryFile.bin", "intelHex.hex" ); | ||
The default hex line terminator is `\n`, which can be changed by setting `processor.lineTerminator`. | ||
The default hex line terminator is `\n`, which can be changed by setting `processor.lineTerminator`. |
@@ -13,4 +13,2 @@ ( function(){ | ||
it( 'converts a binary file to hex', function(){ | ||
var intelHexFileData = ":020000040003F7\n:10F400006262643433373035376262663263366243\n:10F41000376435343433613035643631393336301E\n:00000001FF\n"; | ||
@@ -25,3 +23,2 @@ | ||
expect( binaryResults ).toEqual( binaryFileData ); | ||
}); | ||
@@ -28,0 +25,0 @@ }); |
@@ -321,2 +321,42 @@ ( function(){ | ||
describe('Append Buffer', function(){ | ||
it('builds a file from a small buffer', function(){ | ||
var buffer = new Buffer(16).fill(0); | ||
var fileData = ":1000000000000000000000000000000000000000F0\n:00000001FF\n"; | ||
var file = new IntelFile(0); | ||
file.appendBuffer( buffer ); | ||
file.close(); | ||
expect( file.contents).toBe( fileData ); | ||
}); | ||
it('builds a file from a huge buffer', function(){ | ||
var largeSize = 128*1024; | ||
var buffer = new Buffer(128*1024).fill(0); | ||
var file = new IntelFile(0); | ||
file.appendBuffer( buffer ); | ||
file.close(); | ||
var expectedLineCount = largeSize/16 + 2; | ||
var lines = file.contents.trim().split('\n'); | ||
expect( lines.length ).toBe( expectedLineCount ); | ||
var line; | ||
var match; | ||
for( var i = 0; i < lines.length - 1; i++ ){ | ||
line = lines[i]; | ||
if( i === 4096 ){ | ||
match = line.match( "^:02000004[0-9A-F]{4}[0-9A-F]{2}"); // address line every 65536 bytes | ||
} else { | ||
match = line.match( "^:10[0-9A-F]{4}000{32}[0-9A-F]{2}" ); // data line for 16 zeroes | ||
} | ||
expect( match.length ).toBe( 1 ); | ||
} | ||
}); | ||
}) | ||
})(); | ||
@@ -323,0 +363,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
629
83
46680
24