Still struggling with this one. The value of console.log(laststatus.machine.position.work.a) is red long before the router comes to standstill. How can I change the code so that it waits until the machine comes to the end of the routine? function goZeroRef() { zeroXDrillLocation = zeroXRef + drillDiameter/2 + stockWidth - stepIncrements; zeroYDrillLocation = zeroYRef + drillDiameter/2; zeroZDrillLovation = cutDepth; sendGcode("G01 F3000 Z" + safeZ); sendGcode("G01 F3000 X" + zeroXDrillLocation); sendGcode("G01 F3000 Z" + cutDepth); console.log(laststatus.machine.position.work.a); }
Wait for idle, then read it. Pseudo code Code: setTimeout(function() { var waitingToReadValue = setInterval(function(){ if (laststatus.comms.runStatus == "Idle") { clearInterval(waitingToReadValue ); console.log(laststatus.machine.position.work.a): } }, 100) }, 500)
Appreciated very much. This sync/async javascript thing gives me headaches ... (changed the : to ; to make it work). Thanks a lot !!! setTimeout(function() { var waitingToReadValue = setInterval(function(){ if (laststatus.comms.runStatus == "Idle") { clearInterval(waitingToReadValue ); console.log(laststatus.machine.position.work.a); } }, 100) }, 500)