NordicSemiconductor / nrf-intel-hex

Yet another parser for "Intel HEX" files.
BSD 3-Clause "New" or "Revised" License
27 stars 8 forks source link

Feature: contains(otherMemMap) method #6

Closed IvanSanchez closed 6 years ago

IvanSanchez commented 6 years ago

Follow-up of #5. Now that we can "slice" the UICR out of a merged set of parsed .hex files, it's time to be able to check if a devkit already has those bytes (and thus know if any updates are needed). In other words, this PR enables doing something like this:

let uicrFromHexFiles = hexMemMap.slice(uicrStartAddr, 256);
if ( devkitMemMap.contains(uicrFromHexFiles) ) { 
  // UICR doesn't have to be updated
} else {
  // UICR needs to be erased
}

Implementing some unit tests for contains() also uncovered a bug (typo in variable name) in slice(). Unit tests moved to the right file, added unit test for the uncovered bug, and for contains().