IPC@CHIP Modbus library – API Documentation

Header image

Main page

int mbTCP_cl_rd_discr_inputs ( MbHandle  handle,
u8  unitId,
u8  functionCode,
u16  startAddress,
u16  quantity,
u8 input_coilbuf,
u8 exception,
u32  timeoutMs,
int *  errorCode 

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

[in] handle : Handle returned by mbTCP_cl_init()
[in] unitId : Unit identifier
[in] functionCode : Function code 0x01 or 0x02
[in] quantity : Number of inputs/coils to read
[in] startAddress : Address of the first coil/input
[out] input_coilbuf : Buffer provided by the user.
  Required length in bytes: quantity/8 + 1 (for the remainder of quantity mod 8).
  After successful execution input_coilbuf contains the value responded by the server.
  The inputs/coils in the buffer are packed as one input/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.
[out] errorCode : TCP/IP Socket API error code
0 : Execution successful, check *exception for possible exception code.
-1 : Timeout, no reply received
-2 : Received garbage (invalid Modbus frame data)
-4 : Illegal function code
-5 : TCP socket fault, see errorCode

Top of page | Main page

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