From c142bc9645dd1f1017e51df16bb86f0c9c73b88e Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Mon, 25 Jan 2021 11:58:39 +0100 Subject: [PATCH] fixes during raspberry tests --- lib/graphics.js | 4 ++-- lib/osinfo.js | 5 +++++ lib/system.js | 2 +- lib/util.js | 9 ++++++--- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/lib/graphics.js b/lib/graphics.js index 64a1da5..1f263b4 100644 --- a/lib/graphics.js +++ b/lib/graphics.js @@ -704,12 +704,12 @@ function graphics(callback) { }); } } - if (lines.length > 1 && lines[1].indexOf('gpu=') >= -1) { + if (lines.length > 1 && stdout.toString().indexOf('gpu=') >= -1) { result.controllers.push({ vendor: 'Broadcom', model: 'VideoCore IV', bus: '', - vram: lines[1].replace('gpu=', ''), + vram: util.getValue(lines, 'gpu', '=').replace('M', ''), vramDynamic: true }); } diff --git a/lib/osinfo.js b/lib/osinfo.js index 1e87421..a3334e3 100644 --- a/lib/osinfo.js +++ b/lib/osinfo.js @@ -1023,6 +1023,11 @@ echo -n "hardware: "; cat /sys/class/dmi/id/product_uuid 2> /dev/null; echo;`; const lines = stdout.toString().split('\n'); result.os = util.getValue(lines, 'os').toLowerCase(); result.hardware = util.getValue(lines, 'hardware').toLowerCase(); + if (!result.hardware) { + const lines = fs.readFileSync('/proc/cpuinfo', { encoding: 'utf8' }).toString().split('\n'); + const serial = util.getValue(lines, 'serial'); + result.hardware = serial || ''; + } if (callback) { callback(result); } diff --git a/lib/system.js b/lib/system.js index 67842a1..8d1db6a 100644 --- a/lib/system.js +++ b/lib/system.js @@ -182,7 +182,7 @@ function system(callback) { const model = util.getValue(lines, 'model:', ':', true); // reference values: https://elinux.org/RPi_HardwareHistory // https://www.raspberrypi.org/documentation/hardware/raspberrypi/revision-codes/README.md - if ((result.model === 'BCM2835' || result.model === 'BCM2708' || result.model === 'BCM2709' || result.model === 'BCM2836' || result.model === 'BCM2837') && model.toLowerCase().indexOf('raspberry') >= 0) { + if ((result.model === 'BCM2835' || result.model === 'BCM2708' || result.model === 'BCM2709' || result.model === 'BCM2710' || result.model === 'BCM2711' || result.model === 'BCM2836' || result.model === 'BCM2837') && model.toLowerCase().indexOf('raspberry') >= 0) { const rPIRevision = util.decodePiCpuinfo(lines); result.model = rPIRevision.model; result.version = rPIRevision.revisionCode; diff --git a/lib/util.js b/lib/util.js index 455e40d..a9a8913 100644 --- a/lib/util.js +++ b/lib/util.js @@ -425,12 +425,15 @@ function isRaspberry() { 'BCM2708', 'BCM2709', 'BCM2710', + 'BCM2711', 'BCM2835', + 'BCM2836', + 'BCM2837', 'BCM2837B0' ]; let cpuinfo = []; try { - cpuinfo = fs.readFileSync('/proc/cpuinfo', { encoding: 'utf8' }).split('\n'); + cpuinfo = fs.readFileSync('/proc/cpuinfo', { encoding: 'utf8' }).toString().split('\n'); } catch (e) { return false; } @@ -441,11 +444,11 @@ function isRaspberry() { function isRaspbian() { let osrelease = []; try { - osrelease = fs.readFileSync('/etc/os-release', { encoding: 'utf8' }).split('\n'); + osrelease = fs.readFileSync('/etc/os-release', { encoding: 'utf8' }).toString().split('\n'); } catch (e) { return false; } - const id = getValue(osrelease, 'id'); + const id = getValue(osrelease, 'id', '='); return (id && id.indexOf('raspbian') > -1); }