Skip to content

Commit bee5e52

Browse files
Added sysinfo variables for use with supportconfig plan on #377
1 parent 84c1707 commit bee5e52

File tree

3 files changed

+105
-30
lines changed

3 files changed

+105
-30
lines changed

app/js/websocket.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ var grblParams = {}
55
var smoothieParams = {}
66
var nostatusyet = true;
77
var safeToUpdateSliders = false;
8-
var laststatus
8+
var laststatus, lastsysinfo
99
var simstopped = false;
1010
var bellstate = false;
1111
var toast = Metro.toast.create;
@@ -555,6 +555,11 @@ function initSocket() {
555555
}
556556
});
557557

558+
socket.on('sysinfo', function(sysinfo) {
559+
console.log(sysinfo)
560+
lastsysinfo = sysinfo;
561+
});
562+
558563
socket.on('status', function(status) {
559564

560565
if (nostatusyet) {

index.js

Lines changed: 94 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ var lastCommand = false
381381
var gcodeQueue = [];
382382
var queuePointer = 0;
383383
var statusLoop;
384-
var frontEndUpdateLoop
384+
var frontEndUpdateLoop, sysinfoUpdateLoop
385385

386386
var queueCounter;
387387
var listPortsLoop;
@@ -680,47 +680,27 @@ io.on("connection", function(socket) {
680680

681681
debug_log("New IO Connection ");
682682

683+
io.sockets.emit("sysinfo", systemInformation);
683684

684685
iosocket = socket;
685686

686687
if (status.machine.firmware.type == 'grbl') {
687-
688688
debug_log("Is Grbl");
689-
690-
691-
// // handle Grbl RESET external input
692-
// if (status.machine.inputs.length > 0) {
693-
// for (i = 0; i < status.machine.inputs.length; i++) {
694-
// switch (status.machine.inputs[i]) {
695-
// case 'R':
696-
// // debug_log('PIN: SOFTRESET');
697-
// safetosend = true;
698-
// break;
699-
// }
700-
// }
701-
// } else {
702-
// setTimeout(function() {
703689
debug_log("Emit Grbl: 1");
704690
io.sockets.emit('grbl', status.machine.firmware)
705-
// }, 10000);
706-
// }
707-
//
708-
// if (safetosend != undefined && safetosend == true) {
709-
// setTimeout(function() {
710-
// debug_log("Emit Grbl: 2");
711-
// io.sockets.emit('grbl', status.machine.firmware)
712-
// }, 10000);
713-
// }
714-
715691
}
716692

717-
718693
// Global Update loop
719694
clearInterval(frontEndUpdateLoop);
720695
frontEndUpdateLoop = setInterval(function() {
721696
io.sockets.emit("status", status);
722697
}, 100);
723698

699+
clearInterval(sysinfoUpdateLoop);
700+
sysinfoUpdateLoop = setInterval(function() {
701+
io.sockets.emit("sysinfo", systemInformation);
702+
}, 1000 * 60);
703+
724704
socket.on("scannetwork", function(data) {
725705
scanForTelnetDevices(data)
726706
})
@@ -3948,5 +3928,92 @@ function friendlyPort(port) {
39483928

39493929
// End USB Port details
39503930

3931+
// System Info on startup
3932+
3933+
const os = require('os');
3934+
const si = require('systeminformation');
3935+
3936+
var systemInformation;
3937+
3938+
async function getSystemInfo() {
3939+
// Basic OS and hardware details
3940+
const osType = os.type(); // 'Linux', 'Darwin' (Mac), 'Windows_NT'
3941+
const osPlatform = os.platform(); // 'win32', 'linux', 'darwin', etc.
3942+
const osRelease = os.release(); // OS version
3943+
const arch = os.arch(); // 'x64', 'arm', 'arm64', etc.
3944+
const totalMemory = os.totalmem();
3945+
const networkInterfaces = os.networkInterfaces();
3946+
const cpu = os.cpus();
3947+
3948+
// Additional system information using systeminformation
3949+
const [baseboard, graphics, osInfo] = await Promise.all([
3950+
si.baseboard(),
3951+
si.graphics(),
3952+
si.osInfo()
3953+
]);
3954+
3955+
// Prepare systemInformation JSON object
3956+
systemInformation = {
3957+
operatingSystem: {
3958+
type: osType,
3959+
platform: osPlatform,
3960+
release: osRelease,
3961+
arch: arch,
3962+
distro: osInfo.distro || "N/A",
3963+
version: osInfo.release || "N/A",
3964+
codename: osInfo.codename || "N/A",
3965+
},
3966+
hardware: {
3967+
cpu: cpu.map(core => ({
3968+
model: core.model,
3969+
speed: core.speed, // in MHz
3970+
times: core.times
3971+
})),
3972+
motherboard: {
3973+
manufacturer: baseboard.manufacturer,
3974+
model: baseboard.model,
3975+
version: baseboard.version,
3976+
serialNumber: baseboard.serial,
3977+
},
3978+
gpu: graphics.controllers.map(gpu => ({
3979+
model: gpu.model,
3980+
vendor: gpu.vendor,
3981+
vram: gpu.vram, // in MB
3982+
bus: gpu.bus
3983+
})),
3984+
memory: {
3985+
total: (totalMemory / 1024 / 1024 / 1024).toFixed(2) + " GB",
3986+
free: (os.freemem() / 1024 / 1024 / 1024).toFixed(2) + " GB",
3987+
},
3988+
},
3989+
network: Object.keys(networkInterfaces).map(iface => ({
3990+
interface: iface,
3991+
addresses: networkInterfaces[iface].map(addr => ({
3992+
address: addr.address,
3993+
family: addr.family,
3994+
internal: addr.internal,
3995+
})),
3996+
})),
3997+
};
3998+
3999+
// Timer to update free memory every minute
4000+
setInterval(() => {
4001+
systemInformation.hardware.memory.free = (os.freemem() / 1024 / 1024 / 1024).toFixed(2) + " GB";
4002+
}, 60000); // 60,000 ms = 1 minute
4003+
4004+
// Log the initial systemInformation object
4005+
console.log(JSON.stringify(systemInformation, null, 2));
4006+
4007+
// Return the systemInformation object (if needed for further use)
4008+
io.sockets.emit("sysinfo", systemInformation);
4009+
4010+
return systemInformation;
4011+
}
4012+
4013+
// Call the function
4014+
getSystemInfo().catch(err => console.error("Error retrieving system information:", err));
4015+
4016+
4017+
// End system info on startup
39514018

39524019
process.on('exit', () => debug_log('exit'))

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"node-gyp": "^9.3.1",
3232
"serialport": "^12.0.0",
3333
"socket.io": "^4.6.1",
34+
"systeminformation": "^5.23.5",
3435
"xmodem.js": "^0.1.0"
3536
},
3637
"main": "index.js",
@@ -58,7 +59,7 @@
5859
"category": "public.app-category.graphics-design",
5960
"entitlements": "build/entitlements.mac.plist",
6061
"entitlementsInherit": "build/entitlements.mac.plist",
61-
"hardenedRuntime":true,
62+
"hardenedRuntime": true,
6263
"gatekeeperAssess": false,
6364
"notarize": false,
6465
"target": {
@@ -138,7 +139,9 @@
138139
],
139140
"win": {
140141
"sign": "./signWin.js",
141-
"signingHashAlgorithms": ["sha256"],
142+
"signingHashAlgorithms": [
143+
"sha256"
144+
],
142145
"target": [
143146
{
144147
"target": "nsis",

0 commit comments

Comments
 (0)