Machsupport Forum
		Mach Discussion => Mach4 General Discussion => Topic started by: KMX on October 19, 2016, 04:53:11 PM
		
			
			- 
				Hello!
I am trying to do tool length probing button script, but have some problems with mcCntlGcodeExecuteWait function. The function executes, but in the mean time Mach4 freezes and position DROs are not updating.
How to solve it?
Regards, Denis
			 
			
			- 
				Post the code to check, but does sound like you have an infinite  loop somewhere
DazTheGas
			 
			
			- 
				Hello!
This is the code (very simple):
--Measure
inst = mc.mcGetInstance()
local rc
function GCodeExecute(GCode)
    local rc = mc.mcCntlGcodeExecuteWait(inst, GCode)
    if rc ~= mc.MERROR_NOERROR then
        return 'Error', false
    else
        return 'OK', true
    end
end
local a, b
a, b = GCodeExecute('G0 G53 Z0 X-200 Y-300')   
  
if b == true then
    mc.mcCntlSetLastError(inst, 'test move.')
else
    mc.mcCntlSetLastError(inst, a)
end  
At this time I'm using simulation device for motion tests. The code is executed on button "LeftUp"  event.
Denis
			 
			
			- 
				I have just tried to do it as Macro script and there is no problem with freezing...
Denis
			 
			
			- 
				Hello Denis,
i also had this problems. It looks like there is a problem ore a new behavior of the mcCntlGcodeExecuteWait() function.
Try to use mcCntlGcodeExecute() instead of mcCntlGcodeExecuteWait() when ever possible.
I used the whole day yesterday  to debug an fix most of problems after update to newest mach4 version.
Now it works so far.