Hi,
please, can you help me with actual problem? While I can read (0x03) and write (0x06) holding register and I can read (0x01) coil, I cannot write coil (0x05). This is the code, a snippet from signal library definition, with some debug output:
[mc.OSIG_RUNNING_GCODE] = function( state )
local hregTestCoil, rc = mc.mcRegGetHandle( inst, "modbus0/testCoil" ); -- THIS COMMAND IS FAILING
mc.mcCntlSetLastError( inst, "testCoil handle: " .. tostring( hregTestCoil ) .. ", rc: " .. tostring( rc ) );
local hregTestRegister, rc = mc.mcRegGetHandle( inst, "modbus0/testRegister" );
mc.mcCntlSetLastError( inst, "testRegister handle: " .. tostring( hregTestRegister ) .. ", rc: " .. tostring( rc ) );
if( state == 1) then
mc.mcCntlSetLastError( inst, "signal changed to 1" );
mc.mcRegSetValue( hregTestCoil, 1 );
mc.mcRegSetValue( hregTestRegister, 101 );
else
mc.mcCntlSetLastError( inst, "signal changed to 0" );
mc.mcRegSetValue( hregTestCoil, 0 );
mc.mcRegSetValue( hregTestRegister, 100 );
end
end,
Attempt to get handle for testCoil fails with return code of -27 which should mean MERROR_REG_NOT_FOUND. What is wrong?
Thanks.