modbus_read_input_registers


 

Function

 

Uses the function code Read Input Registers (code 04) to acquire multiple registers information of the input register area.

 

Format

 

ret = modbus_read_input_registers( 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 registers to read.

 

dest [ C : uint16_t * ] [ Python : ctypes.POINTER(ctypes.c_uint16) ]

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 registers 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 Input Registers (code 04) to acquire multiple registers information of the input register area.

 

Example

 

Acquires the data for 8 registers from the start address 0.

 

C

int ret;

modbus_t *ctx;

uint16_t dest[8];

ret = modbus_read_input_registers( ctx, 0, 8 , dest );

 

Python

ret = ctypes.c_int

ctx = ctypes.POINTER(modbus_t)

uint16_buff_type = ctypes.c_uint16 * 8

dest = uint16_buff_type()

ret = modbus.modbus_read_input_registers(ctx, 0, 8, dest)