verser-git / probe_screen_v2.8

CNC probe macros on one screen for LinuxCNC v2.8
https://vers.ge
11 stars 1 forks source link

Gmocappy 2.8.4 gcode doesn't wait for moves #2

Open nathantsoi opened 1 week ago

nathantsoi commented 1 week ago

I found when testing that wait_complete() in the gcode() function does not wait for a move. I had to implement polling of the interpreter state, like is done in ocode(). Here is my full gcode function:

    @restore_task_mode
    def gcode(self, s, distance=None, data=None):
        self.command.mode(linuxcnc.MODE_MDI)
        self.timed_wait_complete()
        for l in s.split("\n"):
            # Search for G1 followed by a space, otherwise we'll catch G10 too.
            if "G1 " in l:
                l += " F#<_ini[TOOLSENSOR]RAPID_SPEED>"
            time_in = 5
            if distance is not None:
                # set a non-default wait limit for wait_complete()
                time_in = 1 + (distance / self.ps_rapid_speed ) * 60
            #print("probe_screen time_in=", time_in)
            #print("probe_screen:\n", l)
            self.command.mdi(l)
            self.timed_wait_complete()
            if self.error_poll() == -1:
                return -1

            self.stat.poll()
            # wait for the interpreter to return to idle state
            while self.stat.interp_state != linuxcnc.INTERP_IDLE:
                #print("probe_screen: interp_state=", self.stat.interp_state)
                if self.error_poll() == -1:
                    return -1
                self.command.wait_complete()
                self.stat.poll()
            self.command.wait_complete()
            if self.error_poll() == -1:
                return -1
        return 0

I'm curious if this was not implemented in gcode() but only in ocode() can we add it to gcode() as well? If so, I'm happy to make a PR.