cpuTemperature() fixed raspberry pi sensors issue
This commit is contained in:
parent
a792db68d4
commit
1b78e9fec1
@ -30,6 +30,7 @@ For major (breaking) changes - version 3 and 2 see end of page.
|
||||
|
||||
| Version | Date | Comment |
|
||||
| -------------- | -------------- | -------- |
|
||||
| 4.26.7 | 2020-05-06 | `cpuTemperature()` fixed raspberry pi sensors issue |
|
||||
| 4.26.6 | 2020-06-03 | `diskLayout()` fixed issue linux |
|
||||
| 4.26.5 | 2020-05-27 | `cpuTemperature()` optimizes scanning AMD linux sensors |
|
||||
| 4.26.4 | 2020-05-21 | `cpuTemperature()` fix (BSD), code cleanup |
|
||||
|
||||
@ -83,6 +83,11 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th scope="row">4.26.7</th>
|
||||
<td>2020-06-06</td>
|
||||
<td><span class="code">cpuTemperature()</span> fixed raspberry pi sensors issue</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">4.26.6</th>
|
||||
<td>2020-06-03</td>
|
||||
|
||||
@ -207,7 +207,7 @@
|
||||
<div class="title">Downloads last month</div>
|
||||
</div>
|
||||
<div class="col-xl-4 col-lg-4 col-md-4 col-12">
|
||||
<div class="numbers">280</div>
|
||||
<div class="numbers">283</div>
|
||||
<div class="title">Dependends</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
61
lib/cpu.js
61
lib/cpu.js
@ -816,37 +816,38 @@ function cpuTemperature(callback) {
|
||||
result.max = tdieTemp;
|
||||
}
|
||||
}
|
||||
if (callback) { callback(result); }
|
||||
resolve(result);
|
||||
} else {
|
||||
fs.stat('/sys/class/thermal/thermal_zone0/temp', function (err) {
|
||||
if (err === null) {
|
||||
fs.readFile('/sys/class/thermal/thermal_zone0/temp', function (error, stdout) {
|
||||
if (!error) {
|
||||
let lines = stdout.toString().split('\n');
|
||||
if (lines.length > 0) {
|
||||
result.main = parseFloat(lines[0]) / 1000.0;
|
||||
result.max = result.main;
|
||||
}
|
||||
}
|
||||
if (callback) { callback(result); }
|
||||
resolve(result);
|
||||
});
|
||||
} else {
|
||||
exec('/opt/vc/bin/vcgencmd measure_temp', function (error, stdout) {
|
||||
if (!error) {
|
||||
let lines = stdout.toString().split('\n');
|
||||
if (lines.length > 0 && lines[0].indexOf('=')) {
|
||||
result.main = parseFloat(lines[0].split('=')[1]);
|
||||
result.max = result.main;
|
||||
}
|
||||
}
|
||||
if (callback) { callback(result); }
|
||||
resolve(result);
|
||||
});
|
||||
}
|
||||
});
|
||||
if (result.main !== -1.0 || result.max !== -1.0) {
|
||||
if (callback) { callback(result); }
|
||||
resolve(result);
|
||||
}
|
||||
}
|
||||
fs.stat('/sys/class/thermal/thermal_zone0/temp', function (err) {
|
||||
if (err === null) {
|
||||
fs.readFile('/sys/class/thermal/thermal_zone0/temp', function (error, stdout) {
|
||||
if (!error) {
|
||||
let lines = stdout.toString().split('\n');
|
||||
if (lines.length > 0) {
|
||||
result.main = parseFloat(lines[0]) / 1000.0;
|
||||
result.max = result.main;
|
||||
}
|
||||
}
|
||||
if (callback) { callback(result); }
|
||||
resolve(result);
|
||||
});
|
||||
} else {
|
||||
exec('/opt/vc/bin/vcgencmd measure_temp', function (error, stdout) {
|
||||
if (!error) {
|
||||
let lines = stdout.toString().split('\n');
|
||||
if (lines.length > 0 && lines[0].indexOf('=')) {
|
||||
result.main = parseFloat(lines[0].split('=')[1]);
|
||||
result.max = result.main;
|
||||
}
|
||||
}
|
||||
if (callback) { callback(result); }
|
||||
resolve(result);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user