Skip to content

Commit

Permalink
Merge b6ab38e into abc6c7a
Browse files Browse the repository at this point in the history
  • Loading branch information
monkbroc committed Jan 31, 2020
2 parents abc6c7a + b6ab38e commit ce3d9c3
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/cmd/binary.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ const Parser = require('binary-version-reader').HalModuleParser;
const utilities = require('../lib/utilities');
const ensureError = utilities.ensureError;

const INVALID_SUFFIX_SIZE = 65535;
const DEFAULT_PRODUCT_ID = 65535;
const DEFAULT_PRODUCT_VERSION = 65535;

class BinaryCommand {
inspectBinary(binaryFile){
Expand All @@ -48,7 +51,7 @@ class BinaryCommand {
throw new VError(ensureError(err), `Could not parse ${binaryFile}`);
})
.then(fileInfo => {
if (fileInfo.suffixInfo.suffixSize === 65535){
if (fileInfo.suffixInfo.suffixSize === INVALID_SUFFIX_SIZE){
throw new VError(`${binaryFile} does not contain inspection information`);
}

Expand Down Expand Up @@ -111,6 +114,14 @@ class BinaryCommand {
+ ' at version '
+ chalk.bold(fileInfo.prefixInfo.moduleVersion.toString()));

if (fileInfo.suffixInfo.productId !== DEFAULT_PRODUCT_ID &&
fileInfo.suffixInfo.productVersion !== DEFAULT_PRODUCT_VERSION) {
console.log(' It is firmware for '
+ chalk.bold('product id ' + fileInfo.suffixInfo.productId)
+ ' at version '
+ chalk.bold(fileInfo.suffixInfo.productVersion));
}

if (fileInfo.prefixInfo.depModuleFunction){
console.log(' It depends on '
+ chalk.bold(functions[fileInfo.prefixInfo.depModuleFunction])
Expand Down
Binary file added test/__fixtures__/binaries/product_firmware.bin
Binary file not shown.
11 changes: 11 additions & 0 deletions test/e2e/binary.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,17 @@ describe('Binary Commands', () => {
' This is an application module number 1 at version 6',
' It depends on a system module number 1 at version 1213'
]
},
{
file: 'product_firmware.bin',
contents: [
'product_firmware.bin',
' CRC is ok (e309c618)',
' Compiled for electron',
' This is an application module number 1 at version 6',
' It is firmware for product id 8178 at version 13',
' It depends on a system module number 2 at version 1201'
]
}
];

Expand Down

0 comments on commit ce3d9c3

Please sign in to comment.