Hi all, I am trying to use the socket.io-client npm package to receive websocket events from the control software. I have seen a few other threads with some troubleshooting info but still can't get it to work. The code is simply: io = require('socket.io-client'); var socket = io('http://127.0.0.1:3000/'); socket.on('status', function(status) { console.log(status) }); My understanding is this should print out a status every 400ms or so. However I am not receiving any events. I have tried listening to many other events that should be emitting according to the code on github, but nothing's coming through. I did notice that as soon as I run the script, the Log / Serial console of the control software goes nuts, similar to if I open http://127.0.0.1:3000 in a browser tab, so it seems like it is detecting a new connection. However it just keeps printing and doesn't stop, and the controller status keeps toggling from "Running" to "Idle" and back until I kill the script, then it stops. Any help appreciated, Nick
Its 100ms : OpenBuilds-CONTROL/index.js at master ยท OpenBuilds/OpenBuilds-CONTROL Peter can answer this better than I, but is there a reason you can't run it from a javascript macro from within control? If you can, then you can use this Code: socket.on('status', function(status) { console.log(status) }); And you can use this something like this (obviously swap out laststatus.comms with whatever you want to get) Code: setInterval(function() { console.log(laststatus.comms) }, 100); This will also give you the ability to control the polling interval.
No, running from within control won't work for my application. I am looking to communicate with the blackbox from a separate application to do things like homing, getting positions, sending gcode commands. Is my approach of using sockets through control convoluted, maybe there is a more direct way?