memLayout() added ECC flag

This commit is contained in:
Sebastian Hildebrandt
2021-02-07 15:44:54 +01:00
parent 412d9573c3
commit 00faa546e8
7 changed files with 35 additions and 4 deletions
+1
View File
@@ -123,6 +123,7 @@ export namespace Systeminformation {
size: number;
bank: string;
type: string;
ecc?: boolean;
clockSpeed: number;
formFactor: string;
partNum: string;
+16 -2
View File
@@ -317,10 +317,13 @@ function memLayout(callback) {
const sizeString = util.getValue(lines, 'Size');
const size = sizeString.indexOf('GB') >= 0 ? parseInt(sizeString, 10) * 1024 * 1024 * 1024 : parseInt(sizeString, 10) * 1024 * 1024;
if (parseInt(util.getValue(lines, 'Size'), 10) > 0) {
const totalWidth = util.toInt(util.getValue(lines, 'Total Width'));
const dataWidth = util.toInt(util.getValue(lines, 'Data Width'));
result.push({
size,
bank: util.getValue(lines, 'Bank Locator'),
type: util.getValue(lines, 'Type:'),
ecc: dataWidth && totalWidth ? totalWidth > dataWidth : false,
clockSpeed: (util.getValue(lines, 'Configured Clock Speed:') ? parseInt(util.getValue(lines, 'Configured Clock Speed:'), 10) : (util.getValue(lines, 'Speed:') ? parseInt(util.getValue(lines, 'Speed:'), 10) : null)),
formFactor: util.getValue(lines, 'Form Factor:'),
manufacturer: getManufacturerLinux(util.getValue(lines, 'Manufacturer:')),
@@ -335,6 +338,7 @@ function memLayout(callback) {
size: 0,
bank: util.getValue(lines, 'Bank Locator'),
type: 'Empty',
ecc: null,
clockSpeed: 0,
formFactor: util.getValue(lines, 'Form Factor:'),
partNum: '',
@@ -351,6 +355,7 @@ function memLayout(callback) {
size: os.totalmem(),
bank: '',
type: '',
ecc: null,
clockSpeed: 0,
formFactor: '',
partNum: '',
@@ -375,10 +380,11 @@ function memLayout(callback) {
'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].ecc = false;
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].formFactor = 'SoC';
stdout = execSync('vcgencmd get_config sdram_freq 2>/dev/null');
@@ -410,6 +416,8 @@ function memLayout(callback) {
if (_darwin) {
exec('system_profiler SPMemoryDataType', function (error, stdout) {
if (!error) {
const allLines = stdout.toString().split('\n');
const eccStatus = util.getValue(allLines, 'ecc', ':', true).toLowerCase();
let devices = stdout.toString().split(' BANK ');
let hasBank = true;
if (devices.length === 1) {
@@ -426,6 +434,7 @@ function memLayout(callback) {
size: size * 1024 * 1024 * 1024,
bank: bank,
type: util.getValue(lines, ' Type:'),
ecc: eccStatus ? eccStatus === 'enabled' : null,
clockSpeed: parseInt(util.getValue(lines, ' Speed:'), 10),
formFactor: '',
manufacturer: getManufacturerDarwin(util.getValue(lines, ' Manufacturer:')),
@@ -440,6 +449,7 @@ function memLayout(callback) {
size: 0,
bank: bank,
type: 'Empty',
ecc: null,
clockSpeed: 0,
formFactor: '',
manufacturer: '',
@@ -461,6 +471,7 @@ function memLayout(callback) {
size: size * 1024 * 1024 * 1024,
bank: 0,
type,
ecc: false,
clockSpeed: 0,
formFactor: '',
manufacturer: 'Apple',
@@ -492,10 +503,13 @@ function memLayout(callback) {
devices.shift();
devices.forEach(function (device) {
let lines = device.split('\r\n');
const dataWidth = util.toInt(util.getValue(lines, 'DataWidth', '='));
const totalWidth = util.toInt(util.getValue(lines, 'TotalWidth', '='));
result.push({
size: parseInt(util.getValue(lines, 'Capacity', '='), 10) || 0,
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,
formFactor: FormFactors[parseInt(util.getValue(lines, 'FormFactor', '='), 10) || 0],
manufacturer: util.getValue(lines, 'Manufacturer', '='),