@@ -381,7 +381,7 @@ var lastCommand = false
381381var gcodeQueue = [ ] ;
382382var queuePointer = 0 ;
383383var statusLoop ;
384- var frontEndUpdateLoop
384+ var frontEndUpdateLoop , sysinfoUpdateLoop
385385
386386var queueCounter ;
387387var 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
39524019process . on ( 'exit' , ( ) => debug_log ( 'exit' ) )
0 commit comments