From 0b12a29d8203975571f9296c693a9f2e902ac103 Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Tue, 8 Jun 2021 23:01:24 +0200 Subject: [PATCH 1/4] memLayout() improved clock speed detection (windows) --- CHANGELOG.md | 5 +++-- docs/changes.html | 4 ++-- docs/history.html | 7 ++++++- docs/index.html | 4 ++-- lib/memory.js | 2 +- 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b0d4153..22ddba4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -53,8 +53,8 @@ We had to make **several interface changes** to keep systeminformation as consis - `getData()`: support for passing parameters and filters (see section General / getData) - `graphics()`: extended nvidia-smi parsing - `networkInterfaces()`: type detection improved (win - wireless) -- `memoryLayout()`: extended manufacturer list (decoding) -- `memoryLayout()`: added ECC flag +- `memLayout()`: extended manufacturer list (decoding) +- `memLayout()`: added ECC flag - `osInfo()`: better fqdn (win) - `osinfo()`: added hypervizor if hyper-v is enabled (win only) - `osInfo()`: added remoteSession (win only) @@ -77,6 +77,7 @@ For major (breaking) changes - **version 4, 3 and 2** - see end of page. | Version | Date | Comment | | -------------- | -------------- | -------- | +| 5.7.5 | 2021-06-08 | `memLayout()` improved clock speed detection (windows) | | 5.7.4 | 2021-05-27 | `osInfo()`, `cpu()` improved hypervisor, virtualization detection (windows) | | 5.7.3 | 2021-05-26 | `osInfo()` improved UEFI detection (windows) | | 5.7.2 | 2021-05-24 | `system()` virtual detection improvement | diff --git a/docs/changes.html b/docs/changes.html index d913931..71200a0 100644 --- a/docs/changes.html +++ b/docs/changes.html @@ -179,8 +179,8 @@
  • getData(): support for passing parameters and filters (see section General / getData)
  • graphics(): extended nvidia-smi parsing
  • networkInterfaces(): type detection improved (win - wireless)
  • -
  • memoryLayout(): extended manufacturer list (decoding)
  • -
  • memoryLayout(): added ECC flag
  • +
  • memLayout(): extended manufacturer list (decoding)
  • +
  • memLayout(): added ECC flag
  • osInfo(): better fqdn (win)
  • osinfo(): added hypervizor if hyper-v is enabled (win only)
  • system(): better Raspberry PI detection
  • diff --git a/docs/history.html b/docs/history.html index 8666a71..b5fea79 100644 --- a/docs/history.html +++ b/docs/history.html @@ -56,6 +56,11 @@ + + 5.7.5 + 2021-06-08 + memLayout() improved clock speed detection (windows) + 5.7.4 2021-05-27 @@ -329,7 +334,7 @@ 5.0.4 2021-01-27 - memoryLayout() improved manufacturer decoding (linux) + memLayout() improved manufacturer decoding (linux) 5.0.3 diff --git a/docs/index.html b/docs/index.html index 36875fd..87c1199 100644 --- a/docs/index.html +++ b/docs/index.html @@ -170,7 +170,7 @@
    systeminformation
     
    -
    New Version: 5.7.4
    +
    New Version: 5.7.5
    @@ -211,7 +211,7 @@
    Downloads last month
    -
    414
    +
    420
    Dependents
    diff --git a/lib/memory.js b/lib/memory.js index 90bfc1c..e1aa80a 100644 --- a/lib/memory.js +++ b/lib/memory.js @@ -510,7 +510,7 @@ function memLayout(callback) { bank: util.getValue(lines, 'abel', '='), // BankLabel type: memoryTypes[parseInt(util.getValue(lines, 'MemoryType', '='), 10)], ecc: dataWidth && totalWidth ? totalWidth > dataWidth : false, - clockSpeed: parseInt(util.getValue(lines, 'ConfiguredClockSpeed', '='), 10) || 0, + clockSpeed: parseInt(util.getValue(lines, 'ConfiguredClockSpeed', '='), 10) || parseInt(util.getValue(lines, 'Speed', '='), 10) || 0, formFactor: FormFactors[parseInt(util.getValue(lines, 'FormFactor', '='), 10) || 0], manufacturer: util.getValue(lines, 'Manufacturer', '='), partNum: util.getValue(lines, 'PartNumber', '='), From b120e27c7298af6a336bdc02c8e33de6b67dd157 Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Tue, 8 Jun 2021 23:01:38 +0200 Subject: [PATCH 2/4] 5.7.5 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2c60340..8b5a351 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "systeminformation", - "version": "5.7.4", + "version": "5.7.5", "description": "Simple system and OS information library", "license": "MIT", "author": "Sebastian Hildebrandt (https://plus-innovations.com)", From ac828716f70ebd3fd1da85d29848105f2429a2aa Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Wed, 9 Jun 2021 11:41:51 +0200 Subject: [PATCH 3/4] battery() improved detection (additional batteries windows) --- CHANGELOG.md | 1 + docs/battery.html | 10 ++++++++++ docs/history.html | 5 +++++ docs/index.html | 2 +- lib/battery.js | 23 +++++++++++++++++------ lib/index.d.ts | 1 + 6 files changed, 35 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 22ddba4..145131f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -77,6 +77,7 @@ For major (breaking) changes - **version 4, 3 and 2** - see end of page. | Version | Date | Comment | | -------------- | -------------- | -------- | +| 5.7.6 | 2021-06-09 | `battery()` improved detection (additional batteries windows) | | 5.7.5 | 2021-06-08 | `memLayout()` improved clock speed detection (windows) | | 5.7.4 | 2021-05-27 | `osInfo()`, `cpu()` improved hypervisor, virtualization detection (windows) | | 5.7.3 | 2021-05-26 | `osInfo()` improved UEFI detection (windows) | diff --git a/docs/battery.html b/docs/battery.html index 9ebed0b..d912070 100644 --- a/docs/battery.html +++ b/docs/battery.html @@ -226,6 +226,16 @@ battery serial + + + additionalBatteries[] + + + + X + + array of additional batteries + diff --git a/docs/history.html b/docs/history.html index b5fea79..fa11c5f 100644 --- a/docs/history.html +++ b/docs/history.html @@ -56,6 +56,11 @@ + + 5.7.6 + 2021-06-09 + battery() improved detection (additional batteries windows) + 5.7.5 2021-06-08 diff --git a/docs/index.html b/docs/index.html index 87c1199..7d3caf6 100644 --- a/docs/index.html +++ b/docs/index.html @@ -170,7 +170,7 @@
    systeminformation
     
    -
    New Version: 5.7.5
    +
    New Version: 5.7.6
    diff --git a/lib/battery.js b/lib/battery.js index c01eb00..7c049e8 100644 --- a/lib/battery.js +++ b/lib/battery.js @@ -41,7 +41,7 @@ function parseWinBatteryPart(lines, designCapacity, fullChargeCapacity) { // 9 = "Charging Critical" // 10 = "Undefined" // 11 = "Partially Charged" - if (lines.join('').toLowerCase().indexOf('BatteryStatus') >= 0) { + if (status >= 0) { const statusValue = status ? parseInt(status) : 0; result.status = statusValue; result.hasBattery = true; @@ -50,7 +50,7 @@ function parseWinBatteryPart(lines, designCapacity, fullChargeCapacity) { result.voltage = parseInt(util.getValue(lines, 'DesignVoltage', '=') || 0) / 1000.0; result.capacityUnit = 'mWh'; result.percent = parseInt(util.getValue(lines, 'EstimatedChargeRemaining', '=') || 0); - result.currentCapacity = parseInt(result.maxcapacity * result.percent / 100); + result.currentCapacity = parseInt(result.maxCapacity * result.percent / 100); result.isCharging = (statusValue >= 6 && statusValue <= 9) || statusValue === 11 || (!(statusValue === 3) && !(statusValue === 1) && result.percent < 100); result.acConnected = result.ischarging || statusValue === 2; result.model = util.getValue(lines, 'DeviceID', '='); @@ -217,14 +217,25 @@ module.exports = function (callback) { workload ).then(data => { if (data) { - let parts = data.results[0].split(/\n\s*\n/); + // let parts = data.results[0].split(/\n\s*\n/); + let parts = data.results[0].split('\r\n'); + let batteries = []; + for (let i = 0; i < parts.length; i++) { + const hasValue = value => /\S/.test(value); + if (hasValue(parts[i]) && (!batteries.length || !hasValue(parts[i - 1]))) { + batteries.push([]); + } + if (hasValue(parts[i])) { + batteries[batteries.length - 1].push(parts[i]); + } + } let designCapacities = data.results[1].split('\r\n'); let fullChargeCapacities = data.results[2].split('\r\n'); - if (parts && parts.length) { + if (batteries && batteries.length) { let first = false; let additionalBatteries = []; - for (let i = 0; i < parts.length; i++) { - let lines = parts[i].split('\r\n'); + for (let i = 0; i < batteries.length; i++) { + let lines = batteries[i]; const designCapacity = designCapacities && designCapacities.length >= (i + 1) && designCapacities[i] ? util.toInt(designCapacities[i]) : 0; const fullChargeCapacity = fullChargeCapacities && fullChargeCapacities.length >= (i + 1) && fullChargeCapacities[i] ? util.toInt(fullChargeCapacities[i]) : 0; const parsed = parseWinBatteryPart(lines, designCapacity, fullChargeCapacity); diff --git a/lib/index.d.ts b/lib/index.d.ts index e72dc39..eeb620b 100644 --- a/lib/index.d.ts +++ b/lib/index.d.ts @@ -284,6 +284,7 @@ export namespace Systeminformation { model: string; manufacturer: string; serial: string; + additionalBatteries?: BatteryData[]; } interface GraphicsData { From 5fe92ca01a428225efcaefc5a802aba848adb41d Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Wed, 9 Jun 2021 11:41:57 +0200 Subject: [PATCH 4/4] 5.7.6 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8b5a351..bf3ae91 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "systeminformation", - "version": "5.7.5", + "version": "5.7.6", "description": "Simple system and OS information library", "license": "MIT", "author": "Sebastian Hildebrandt (https://plus-innovations.com)",