IPC@CHIP Modbus library – API Documentation

Header image

Main page

int mbRTU_mst_rd_discr_inputs ( MbHandle  handle,
u8  slaveAddr,
u8  functionCode,
u16  startAddress,
u16  quantity,
u8 inputCoilBuf,
u8 exception,
u32  timeoutMs 

Send a "read discrete input" (02) or "read coil status" (01) request and receive reply from the slave.


[in] handle : Handle returned by mbRTU_mst_init()
[in] slaveAddr : Slave address
[in] functionCode : Function code 0x01 or 0x02
[in] startAddress : Address of the first register
[in] quantity : Number of coils to read
[out] inputCoilBuf : Buffer provided by the user
  Required length in bytes: quantity/8 + 1 (for the remainder of quantity mod 8).
  After successful execution, inputCoilBuf contains the values responded by the slave.
  The inputs/coils in the buffer are packed as one coil per bit of the buffer field.
  Value/Status is indicated as 1= ON and 0= OFF.
  Buffer content is only valid if *exception==0 !
[out] exception : Exception code (see ModbusExceptionCodes).
[in] timeoutMs : Wait max. timeout in [ms] for a reply from the slave.

0 : Execution successful, check *exception for possible exception code.
-1 : Communication timeout receive
-2 : Received garbage (CRC error)
-3 : Unable to send request
-8 : Illegal parameter

Top of page | Main page

Copyright © 2017 Beck IPC GmbH
Generated on Thu Mar 9 18:00:33 2017 by Doxygen 1.6.1