Welcome to Our Community

Some features disabled for guests. Register Today.

How to read values after a job is completed?

Discussion in 'CAM' started by Erik HENDRIX 0X, Jan 29, 2022.

  1. Erik HENDRIX 0X

    Builder

    Joined:
    Jan 22, 2022
    Messages:
    7
    Likes Received:
    3
    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);
    }
     
  2. sharmstr

    sharmstr OpenBuilds Team
    Staff Member Moderator Builder Resident Builder

    Joined:
    Mar 23, 2018
    Messages:
    2,035
    Likes Received:
    1,431
    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)  
     
  3. Erik HENDRIX 0X

    Builder

    Joined:
    Jan 22, 2022
    Messages:
    7
    Likes Received:
    3
    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)
     
    sharmstr and Peter Van Der Walt like this.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice