From 356bb7a505b92ac66f4d0c8045cb8c25015190a0 Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Fri, 15 Mar 2024 16:24:18 +0100 Subject: [PATCH] memLayout() improved parsing memory bank (windows) --- CHANGELOG.md | 3 ++- docs/history.html | 5 +++++ docs/index.html | 2 +- lib/memory.js | 6 ++++-- lib/system.js | 19 ++----------------- lib/util.js | 15 +++++++++++++++ 6 files changed, 29 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 96751530..35a68105 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -83,7 +83,8 @@ For major (breaking) changes - **version 4, 3 and 2** - see end of page. | Version | Date | Comment | | ------- | ---------- | --------------------------------------------------------------------------------------------------- | -| 5.22.1 | 2024-03-14 | `chassis()` type, assetTag, sku improved parsing (macOS) | +| 5.22.3 | 2024-03-15 | `chassis()` improved parsing memory bank (windows) | +| 5.22.2 | 2024-03-14 | `chassis()` type, assetTag, sku improved parsing (macOS) | | 5.22.1 | 2024-03-12 | `wifiConnections()` patch for mac OS Sonome 14.4 (macOS) | | 5.22.0 | 2024-02-18 | `wifiConnections()` added signal quality attribute | | 5.21.25 | 2024-02-17 | `wifiConnections()` fixed signal strength (windows) | diff --git a/docs/history.html b/docs/history.html index 7a5f5d92..1764cfc7 100644 --- a/docs/history.html +++ b/docs/history.html @@ -57,6 +57,11 @@

Full version history

+ + 5.22.3 + 2024-03-15 + memLayout() improved parsing memory bank (windows) + 5.22.2 2024-03-14 diff --git a/docs/index.html b/docs/index.html index 35fe5dcd..e2210e4d 100644 --- a/docs/index.html +++ b/docs/index.html @@ -170,7 +170,7 @@
systeminformation
 
-
New Version: 5.22.2
+
New Version: 5.22.3
diff --git a/lib/memory.js b/lib/memory.js index b5a84f15..88735312 100644 --- a/lib/memory.js +++ b/lib/memory.js @@ -530,7 +530,7 @@ function memLayout(callback) { const FormFactors = 'Unknown|Other|SIP|DIP|ZIP|SOJ|Proprietary|SIMM|DIMM|TSOP|PGA|RIMM|SODIMM|SRIMM|SMD|SSMP|QFP|TQFP|SOIC|LCC|PLCC|BGA|FPBGA|LGA'.split('|'); try { - util.powerShell('Get-CimInstance Win32_PhysicalMemory | select DataWidth,TotalWidth,Capacity,BankLabel,MemoryType,SMBIOSMemoryType,ConfiguredClockSpeed,FormFactor,Manufacturer,PartNumber,SerialNumber,ConfiguredVoltage,MinVoltage,MaxVoltage | fl').then((stdout, error) => { + util.powerShell('Get-CimInstance Win32_PhysicalMemory | select DataWidth,TotalWidth,Capacity,BankLabel,MemoryType,SMBIOSMemoryType,ConfiguredClockSpeed,FormFactor,Manufacturer,PartNumber,SerialNumber,ConfiguredVoltage,MinVoltage,MaxVoltage,Tag | fl').then((stdout, error) => { if (!error) { let devices = stdout.toString().split(/\n\s*\n/); devices.shift(); @@ -539,10 +539,12 @@ function memLayout(callback) { const dataWidth = util.toInt(util.getValue(lines, 'DataWidth', ':')); const totalWidth = util.toInt(util.getValue(lines, 'TotalWidth', ':')); const size = parseInt(util.getValue(lines, 'Capacity', ':'), 10) || 0; + const tag = util.getValue(lines, 'Tag', ':'); + const tagInt = util.splitByNumber(tag); if (size) { result.push({ size, - bank: util.getValue(lines, 'BankLabel', ':'), // BankLabel + bank: util.getValue(lines, 'BankLabel', ':') + tagInt[1] ? ' / ' + tagInt[1] : '', // BankLabel type: memoryTypes[parseInt(util.getValue(lines, 'MemoryType', ':'), 10) || parseInt(util.getValue(lines, 'SMBIOSMemoryType', ':'), 10)], ecc: dataWidth && totalWidth ? totalWidth > dataWidth : false, clockSpeed: parseInt(util.getValue(lines, 'ConfiguredClockSpeed', ':'), 10) || parseInt(util.getValue(lines, 'Speed', ':'), 10) || 0, diff --git a/lib/system.js b/lib/system.js index 5390c0c4..6448b053 100644 --- a/lib/system.js +++ b/lib/system.js @@ -215,7 +215,7 @@ function system(callback) { exec('ioreg -c IOPlatformExpertDevice -d 2', function (error, stdout) { if (!error) { let lines = stdout.toString().replace(/[<>"]/g, '').split('\n'); - const model = splitByNumber(util.getValue(lines, 'model', '=', true)); + const model = util.splitByNumber(util.getValue(lines, 'model', '=', true)); const version = util.getValue(lines, 'version', '=', true); result.manufacturer = util.getValue(lines, 'manufacturer', '=', true); result.model = version ? util.getValue(lines, 'model', '=', true) : model[0]; @@ -616,21 +616,6 @@ function macOsChassisType(model) { return 'Other'; } -function splitByNumber(str) { - let numberStarted = false; - let num = ''; - let cpart = ''; - for (const c of str) { - if ((c >= '0' && c <= '9') || numberStarted) { - numberStarted = true; - num += c; - } else { - cpart += c; - } - } - return [cpart, num]; -} - function chassis(callback) { const chassisTypes = ['Other', 'Unknown', @@ -710,7 +695,7 @@ function chassis(callback) { if (!error) { let lines = stdout.toString().replace(/[<>"]/g, '').split('\n'); const model = util.getValue(lines, 'model', '=', true); - const modelParts = splitByNumber(model); + const modelParts = util.splitByNumber(model); const version = util.getValue(lines, 'version', '=', true); result.manufacturer = util.getValue(lines, 'manufacturer', '=', true); result.model = version ? util.getValue(lines, 'model', '=', true) : modelParts[0]; diff --git a/lib/util.js b/lib/util.js index 3051065b..67015405 100644 --- a/lib/util.js +++ b/lib/util.js @@ -63,6 +63,20 @@ function toInt(value) { return result; } +function splitByNumber(str) { + let numberStarted = false; + let num = ''; + let cpart = ''; + for (const c of str) { + if ((c >= '0' && c <= '9') || numberStarted) { + numberStarted = true; + num += c; + } else { + cpart += c; + } + } + return [cpart, num]; +} const stringReplace = new String().replace; const stringToLower = new String().toLowerCase; @@ -1302,6 +1316,7 @@ function semverCompare(v1, v2) { function noop() { } exports.toInt = toInt; +exports.splitByNumber = splitByNumber; exports.execOptsWin = execOptsWin; exports.getCodepage = getCodepage; exports.execWin = execWin;