Hello Guest it is October 15, 2019, 05:21:46 AM

Author Topic: Signal vs IO and Aliases  (Read 704 times)

0 Members and 1 Guest are viewing this topic.

Signal vs IO and Aliases
« 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?

Code: [Select]
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?

My wife left with my best friend...
     and I miss him!

Offline smurph

  • *
  •  1,138 1,138
  • "That there... that's an RV."
    • View Profile
Re: Signal vs IO and Aliases
« Reply #1 on: November 02, 2017, 01:41:03 PM »
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. 

Re: Signal vs IO and Aliases
« Reply #2 on: November 02, 2017, 01:47:52 PM »
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.

My wife left with my best friend...
     and I miss him!