Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@connectedyard/node-jlink

Package Overview
Dependencies
Maintainers
12
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@connectedyard/node-jlink - npm Package Compare versions

Comparing version 1.1.4 to 1.1.5

tests/smoke/test.js

16

index.js

@@ -76,3 +76,3 @@ ( function(){

* @param address: must be word aligned (default 0)
* @param numBytes: must be word aligend (default 4)
* @param numBytes: must be word aligned (default 4)
* @return Promise, resolve( Buffer ) or reject( Error )

@@ -86,7 +86,13 @@ */

const memCommand = "mem 0x" + utils.numberToHexString( address, 8) + ", 0x" + utils.numberToHexString( numBytes, 8 );
const memCommand = `mem 0x${utils.numberToHexString( address, 8)}, 0x${utils.numberToHexString( numBytes, 8 )}`;
return jlinkexe.executeJlinkCommands( ["h", memCommand ], { debug: debug } )
.then( function( result ){
return jlinkexe.parseMemoryStringToBuffer( result.stdout, address, numBytes );
});
.then( function( result ){
return jlinkexe.parseMemoryStringToBuffer( result.stdout, address, numBytes );
})
.catch( function(error){
console.error( `Failed to read ${numBytes} bytes from 0x${utils.numberToHexString(address, 8)}`);
console.error( `Command was: "${memCommand}"`);
throw error;
});
};

@@ -93,0 +99,0 @@

@@ -140,25 +140,33 @@ ( function(){

exports.parseMemoryStringToBuffer = function( data, address, numBytes ){
// First find the index of the memory results: "100000A4 = "
const addressStartMarker = utils.numberToHexString( address, 8) + " = ";
const dataIndex = data.indexOf( addressStartMarker );
if( dataIndex === -1 ) throw new Error("_parseMemoryStringToBuffer found no memory data");
if( dataIndex === -1 ) throw new Error("parseMemoryStringToBuffer found no memory data");
// Clip off everything before the marker
data = data.substring( dataIndex );
data = data.split("\n");
const buf = new Buffer( numBytes );
let uint8Value,
bytes,
bufOffset = 0;
let i, j, k;
// Parse line by line until a bytes array
// Example: 100000A4 = 36 0B 7E 3C 54 68 D6 38 F6 FF FF FF 00 50 00 78 6.~.Th.8.....P.x
// => [0x36, 0x0B, 0x7E, 0x3C, 0x54, 0x68, 0xD6, 0x38, 0xF6, 0xFF, 0xFF, 0xFF, 0x00, 0x50, 0x00, 0x78]
const memoryRows = data.split(/[\n\r]+/)
const memoryRegEx = /^([A-F0-9]{8}) = (([A-F0-9]{2}\s{1,2}){1,16})(\s+).{1,16}$/i;
for( i=0; i < data.length; i++ ){
bytes = data[i].trim().split(" ").slice(2);
for( j=0; j < bytes.length; j++ ){
uint8Value = parseInt( bytes[j], 16 );
buf.writeUInt8( uint8Value, bufOffset );
bufOffset++;
}
let bytes = [];
let rowAddress = address;
for( let row of memoryRows){
const matches = memoryRegEx.exec( row );
if( !matches || matches.length < 5) break;
const foundAddress = parseInt(matches[1],16)
if( foundAddress !== rowAddress ) break;
const foundBytes = matches[2].trim().split(/\s+/).map( b => parseInt(b, 16))
bytes.push( ...foundBytes)
rowAddress += foundBytes.length
}
return buf;
if( bytes.length < numBytes ) throw new Error(`Found only ${bytes.length} bytes of requested ${numBytes} bytes`)
// Copy desired bytes into a buffer
return Buffer.from( bytes.slice(0, numBytes) );
};

@@ -165,0 +173,0 @@

{
"name": "@connectedyard/node-jlink",
"version": "1.1.4",
"version": "1.1.5",
"description": "jLinkexe driver for nodejs",

@@ -10,3 +10,3 @@ "main": "index.js",

"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "node_modules/mocha/bin/_mocha -u bdd --timeout 3000 --colors --exit tests/unit --recursive"
},

@@ -31,3 +31,7 @@ "repository": {

"lodash": "^4.17.4"
},
"devDependencies": {
"chai": "^4.2.0",
"mocha": "^8.0.1"
}
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc