Function
Uses the function code Read Coils (code 01) to acquire multiple bits information of the Coil area.
Format
ret = modbus_read_bits( ctx , addr , nb , dest )
Parameters
ctx [ C : modbus_t * ] [ Python : ctypes.POINTER(modbus_t) ]
Specify the pointer to the libmodbus structure.
addr [ C : int ] [ Python : ctypes.c_int ]
Specify the start address to read.
nb [ C : int ] [ Python : ctypes.c_int ]
Specify the number of bits to read.
dest [ C : uint8_t * ] [ Python : ctypes.POINTER(ctypes.c_uint8) ]
Specify the pointer of the array that stores the read data.
Return values
ret [ 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 Coils (code 01) to acquire multiple bits information of the Coil area.
Example
Acquires the data for 8 bits from the start address 0.
C |
int ret; modbus_t *ctx; uint8_t dest[8]; ret = modbus_read_bits( 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_bits(ctx, 0, 8, dest)
|