Hi all:
I'm working on getting my toolchanger integrated and I'm having an issue with the mcSignalWait command:
I have a much larger body of code, but this is the minimal chunk that shows the issue. I am trying to wait on an input signal that originates from a modbus coil. All of the UI elements tied to the coil operate just fine (led status). The mcSignalWait API call does not work, yet the mcSignalGetState does.
To test the script, I have a UI button linked to the following script that sends
local inst = mc.mcGetInstance()
-- Check to make sure that TC is ready (req complete)
--rc = mc.mcSignalWait(inst, mc.ISIG_INPUT43, mc.WAIT_MODE_HIGH, 5) --Wait 5 seconds for req complete to become active
rc = mc.mcSignalGetState(inst, mc.ISIG_INPUT43)
if (rc~= 0) then --Check our return call
mc.mcCntlSetLastError(inst, "rc = 0 There was an error: Request Complete Timeout")
else
mc.mcCntlSetLastError(inst, "rc = 1 Request Complete")
local hTcOutCMD, rc -- Command Out
hTcOutCMD, rc = mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT92) -- Get handle for output 92: outgoing command
rc = mc.mcSignalSetState(hTcOutCMD, 1) -- Outgoing Command
if (rc~= 0) then --Check our return call
mc.mcCntlSetLastError(inst, "There was an error: Set Outgoing Command")
end
end
The script runs just fine, reports "request complete" and triggers the output coil when I use "mc.mcSignalGetState(inst, mc.ISIG_INPUT43)", but when I try "mc.mcSignalWait(inst, mc.ISIG_INPUT43, mc.WAIT_MODE_HIGH, 5)" it only gives me the "mc.mcCntlSetLastError(inst, "rc = 0 There was an error: Request Complete Timeout")" error.
I have tried many permutations of this command, all to the same effect:
mc.mcSignalWait(inst, mc.ISIG_INPUT43, WAIT_MODE_HIGH, 5)
mc.mcSignalWait(inst, mc.ISIG_INPUT43, 1, 5)
I have also tried the mcSignalHandleWait command, but it also behaves the same.
Am I missing something?
Ultimately, the final code will go into an m6 macro, so if there is a workaround that could work there instead (G-code?) I'm open to suggestions.
FWIW, I'm running M4 ver 4.2.0.5255