Coils and discrete inputs (outputs and inputs) show up as output and input objects in Mach. And can be operated on via the mcIo*() API calls.
I should have called the scan denominator a multiplier or "read every n cycles". I have to change that! If your scan time is 100ms, and scan denominator is 4, then the function is performed every 4 cycles (every 400ms) milliseconds. Is is a way to SLOW the function.
All modbus devices implement things differently. Sometimes, you may be reading a version or the like that comes from SLOW NVRAM. If you have to read something like this, it can slow you whole scan! So if you separate the slow read into its' own function, then you can read it less often via the multiplier (what is now called the denominator).
Also, in the later modubs plugins (4458 and up) you can control the plugin via its command register called mbcntl. Look for it in the regfile plugin diag window. You can actually test the commands in that interface.
mcRegSendCommand() will send the command and receive the response and it is a nice robust way to control a plugin that provides such a command register.
Anyway, the commands you write to the register are:
stop
start
restart
By themselves, they will operate on the plugin as a whole. But now you can operate on the device and function levels as well! Do this with the name of the device as seen in the modbus diag window.
start modbus0
stop modbus0
restart modubus0
Next, you can drill down to the function level.
start modbus0/fucntion1
stop modbus0/fucntion1
restart modubus0/function1
Total control now. So for your slow NVRAM read, just create another function and stop it when you don't need to read it anymore.
Here is the example in code:
hReg, rc = mc.mcRegGetHandle(inst, 'mbcntl/command');
response, rc = mc.mcRegSendCommand(hReg, 'stop modbus0') -- response will be OK or FAIL.
response, rc = mc.mcRegSendCommand(hReg, 'start modbus0')
response, rc = mc.mcRegSendCommand(hReg, 'stop modbus0/function1')
response, rc = mc.mcRegSendCommand(hReg, 'start modbus0/function1')
There is an Initial State that is defined at the function level too. So you can control what is started at startup time. In case you need to start a function up late with the command register.
Steve