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.
I found when testing that
wait_complete()
in thegcode()
function does not wait for a move. I had to implement polling of the interpreter state, like is done inocode()
. Here is my full gcode function:I'm curious if this was not implemented in
gcode()
but only inocode()
can we add it togcode()
as well? If so, I'm happy to make a PR.