Skip to content

Commit

Permalink
memLayout() improved parsing memory bank (windows)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebhildebrandt committed Mar 15, 2024
1 parent b6e84be commit 356bb7a
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 21 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Expand Up @@ -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) |
Expand Down
5 changes: 5 additions & 0 deletions docs/history.html
Expand Up @@ -57,6 +57,11 @@ <h3>Full version history</h3>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">5.22.3</th>
<td>2024-03-15</td>
<td><span class="code">memLayout()</span> improved parsing memory bank (windows)</td>
</tr>
<tr>
<th scope="row">5.22.2</th>
<td>2024-03-14</td>
Expand Down
2 changes: 1 addition & 1 deletion docs/index.html
Expand Up @@ -170,7 +170,7 @@
<img class="logo" src="assets/logo.png" alt="logo">
<div class="title">systeminformation</div>
<div class="subtitle"><span id="typed"></span>&nbsp;</div>
<div class="version">New Version: <span id="version">5.22.2</span></div>
<div class="version">New Version: <span id="version">5.22.3</span></div>
<button class="btn btn-light" onclick="location.href='https://github.com/sebhildebrandt/systeminformation'">View on Github <i class=" fab fa-github"></i></button>
</div>
<div class="down">
Expand Down
6 changes: 4 additions & 2 deletions lib/memory.js
Expand Up @@ -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();
Expand All @@ -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,
Expand Down
19 changes: 2 additions & 17 deletions lib/system.js
Expand Up @@ -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];
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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];
Expand Down
15 changes: 15 additions & 0 deletions lib/util.js
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 356bb7a

Please sign in to comment.