memLayout() raspberry PI support

This commit is contained in:
Sebastian Hildebrandt 2020-02-17 21:35:21 +01:00
parent 3fee3ae45b
commit 8c251354b0
5 changed files with 68 additions and 1 deletions

View File

@ -30,6 +30,7 @@ For major (breaking) changes - version 3 and 2 see end of page.
| Version | Date | Comment |
| -------------- | -------------- | -------- |
| 4.22.1 | 2020-02-17 | `memLayout()` raspberry PI support |
| 4.22.0 | 2020-02-17 | `services()` added pids (windows) |
| 4.21.3 | 2020-02-16 | `versions()` fixed mysql version (macOS) |
| 4.21.2 | 2020-02-11 | `networkConnections()` fixed linux (debian) issue |

View File

@ -83,6 +83,11 @@
</tr>
</thead>
<tbody>
<tr>
<th scope="row">4.22.1</th>
<td>2020-02-17</td>
<td><span class="code">memLayout()</span> raspberry PI support</td>
</tr>
<tr>
<th scope="row">4.22.0</th>
<td>2020-02-17</td>

View File

@ -168,7 +168,7 @@
<img class="logo" src="assets/logo.png">
<div class="title">systeminformation</div>
<div class="subtitle"><span id="typed"></span></div>
<div class="version">Current Version: <span id="version">4.22.0</span></div>
<div class="version">Current Version: <span id="version">4.22.1</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">

View File

@ -15,6 +15,7 @@
const os = require('os');
const exec = require('child_process').exec;
const execSync = require('child_process').execSync;
const util = require('./util');
let _platform = process.platform;
@ -314,6 +315,62 @@ function memLayout(callback) {
}
});
}
if (!result.length) {
result.push({
size: os.totalmem(),
bank: '',
type: '',
clockSpeed: 0,
formFactor: '',
partNum: '',
serialNum: '',
voltageConfigured: -1,
voltageMin: -1,
voltageMax: -1,
});
// Try Raspberry PI
try {
let stdout = execSync('cat /proc/cpuinfo 2>/dev/null');
let lines = stdout.toString().split('\n');
let model = util.getValue(lines, 'hardware', ':', true).toUpperCase();
let version = util.getValue(lines, 'revision', ':', true).toLowerCase();
if (model === 'BCM2835' || model === 'BCM2708' || model === 'BCM2709' || model === 'BCM2835' || model === 'BCM2837') {
const clockSpeed = {
'0': 400,
'1': 450,
'2': 450,
'3': 3200
};
result[0].clockSpeed = version && version[2] && clockSpeed[version[2]] || 400;
result[0].clockSpeed = version && version[4] && version[4] === 'd' ? '500' : result[0].clockSpeed;
result[0].type = 'LPDDR2';
result[0].type = version && version[2] && version[2] === '3' ? 'LPDDR4' : result[0].type;
result[0].formFactor = 'SoC';
stdout = execSync('vcgencmd get_config sdram_freq 2>/dev/null');
lines = stdout.toString().split('\n');
let freq = parseInt(util.getValue(lines, 'sdram_freq', '=', true), 10) || 0;
if (freq) {
result.clockSpeed = freq;
}
stdout = execSync('vcgencmd measure_volts sdram_p 2>/dev/null');
lines = stdout.toString().split('\n');
let voltage = parseInt(util.getValue(lines, 'sdram_freq', '=', true), 10) || 0;
if (voltage) {
result.voltageConfigured = voltage;
result.voltageMin = voltage;
result.voltageMax = voltage;
}
}
} catch (e) {
util.noop();
}
}
if (callback) { callback(result); }
resolve(result);
});

View File

@ -100,6 +100,10 @@ function system(callback) {
if (result.model === 'BCM2835' || result.model === 'BCM2708' || result.model === 'BCM2709' || result.model === 'BCM2835' || result.model === 'BCM2837') {
// Pi 4
if (['c03112'].indexOf(result.version) >= 0) {
result.model = result.model + ' - Pi 4 Model B';
result.version = result.version + ' - Rev. 1.2';
}
if (['a03111', 'b03111', 'c03111'].indexOf(result.version) >= 0) {
result.model = result.model + ' - Pi 4 Model B';
result.version = result.version + ' - Rev. 1.1';