Function
Uses the function code Read Discrete Inputs (code 02) to acquire multiple bits information of the Input Status area.
Format
ret = modbus_read_input_bits( ctx , addr , nb , dest )
Parameters
ctx [ VB.NET: IntPtr ] [ C, C++: modbus_t * ] [ C#: IntPtr ] [ Python: ctypes.POINTER(modbus_t) ]
Specify the pointer to the libmodbus structure.
addr [ VB.NET: Integer ] [ C, C++: int ] [ C#: int ] [ Python: ctypes.c_int ]
Specify the start address to read.
nb [ VB.NET: Integer ] [ C, C++: int ] [ C#: int ] [ Python: ctypes.c_int ]
Specify the number of bits to read.
dest [ VB.NET: Byte() ] [ C, C++: uint8_t * ] [ C#: byte[] ] [ Python: ctypes.POINTER(ctypes.c_uint8) ]
Specify the pointer of the array that stores the read data.
Return values
ret [ VB.NET:Integer ] [ C, C++: int ] [ C#: int ] [ Python: ctypes.c_int ]
If the function succeeds, the number of bits that were successfully read is returned.
If the function fails, -1 is returned, and the following errno is set.
Definition |
Description |
EMBMDATA |
The number of request data is too large. |
Remarks
Uses the function code Read Discrete Inputs (code 02) to acquire multiple bits information of the Input Status area.
Example
Acquires the data for 8 bits from the start address 0.
VB.NET |
Dim ret As Integer Dim ctx As IntPtr Dim dest(8) As Byte ret = modbus_read_input_bits(ctx, 0, 8, dest)
|
C, C++ |
int ret; modbus_t *ctx; uint8_t dest[8]; ret = modbus_read_input_bits( ctx, 0, 8 , dest );
|
C# |
int ret; IntPtr ctx; byte[] dest = new byte[8]; ret = modbus.ReadInputBits(ctx, 0, 8, dest);
|
Python |
ret = ctypes.c_int ctx = ctypes.POINTER(modbus_t) uint8_buff_type = ctypes.c_uint8 * 8 dest = uint8_buff_type() ret = modbus.modbus_read_input_bits(ctx, 0, 8, dest)
|