Machsupport Forum
Mach Discussion => Mach4 General Discussion => Topic started by: joeaverage on October 14, 2017, 01:03:26 AM
-
Hi All,
more basic questions about Mach/Lua/Life and everything...
How does Machs IO differ from Machs signals?
hIo, rc = mc.mcIoGetHandle(
number mInst,
string path)
seems to indicate if I could provide a path to an IO I should get a valid handle back. As result of another thread I'm trying to work out if its possible
to get a valid handle for 'fwdrevbit', the name of an IO in 'function1' of 'modbus0' I wrote a macro just to see whether it would execute which included:
local handle,retcode=mc.mcIoGetHandle(inst,"modbus0/function1/fwdrevbit")
It didn't seem to return a valid handle. fwdrevbit is a Mach Output according to the Modbus plugin. That is, if I understand the IO fwdrevbit is registered
and owned by Modbus.
Again as part of the other thread I went to Machs Output Signals page and selected Machs Output#0 and was able to assign it to device modbus0 and to the
IO/signal rwdrevbit. I think the OP can run from there, he can use Output#0 or any other output he wants to signal the Modbus device. Given that Machs core
seem to recognise the IO/signal I created should I not be able to address it directly with an IoGetHandle rather than tieing it to a signal and use SignalGetHandle?
Craig
-
I/O is provided by plugin devices. I/O can be "mapped" to Mach signals. In theory, one should be able to bypass mapping an I/O point and just twizzle the I/O without a Mach signal. For like a script that just wants to toggle an output or look at an input that otherwise Mach doesn't need to know about.
You need to provide a complete path to the mcIoGetHandle function. As in add a beginning "/" character to it for "/modbus0/function1/fwdrevbit". That might do it. Otherwise, there may be a bug in the LUA binding for that function as not many have probably used it. MOST of the time, it is just easier to map the I/O to a Mach signal.
Steve
-
Hi smurph,
thanks for that explanation.
To complete the macro we mapped the IO to a signal and it worked fine.
I may go back and experiment some more.
Craig