Hi,
every Mach API function has a return code. When programming you should get into the habit of testing the return
codes to trap errors. Aside from anything else it will help you identify the offending function call.
LUA Syntax:
rc = mc.mcSignalWait(
number mInst,
number sigId,
number waitMode,
number timeoutSecs);
Description:
Wait on a signal to change state.
Parameters: Parameter Description
mInst The controller instance.
sigId A valid signal ID. (NOT a signal handle)
waitMode An integer specifying whether to wait on the signal to go high (WAIT_MODE_HIGH) or low (WAIT_MODE_LOW).
timeoutSecs A double specifying a timeout period.
Returns: Return Code Description
MERROR_NOERROR No Error.
MERROR_INVALID_INSTANCE The mInst parameter was out of range.
MERROR_INVALID_ARG sigId or wiatMode is out of range or timeoutSecs is negative.
MERROR_NOT_ENABLED The control is not enabled.
MERROR_TIMED_OUT The timeout period was reached without a change of state.
Note the syntax:
rc=mc.mcSignalWait(.........)
rc is a numeric value, with each number meaning a different thing.
And note the possible return code enumerations:
MERROR_NOERROR
MERROR_INVALID_INSTANCE
MERROR_INVALID_ARG
MERROR_NOT_ENABLED
MERROR_TIMED_OUT
Of these MERROR_INVALID_ARG and MERROR_TIMED_OUT are likely to give you most grief.
The return codes are a number, MERROR_NOERROR is equivalent to 0 whereas MERROR_TIMED_OUT is
equivalent to -40. A full set of return codes and their numeric equivalents are here:
https://www.machsupport.com/forum/index.php?topic=40051.0To test a return code do something like this:
local rc=mc.mcSignalWait(inst,mc.ISIG_INPUT7 ,1,0)
if rc==0 then --No error
end
if rc== -2 then
wx.wxMessageBox('Function failed-invalid arg')
return
end
if rc== -40 then
wx.wxMessageBoox('Function failed-timed out')
return
end
Craig