modbus_set_slave


 

Function

 

Sets the slave ID.

 

Format

 

ret = modbus_set_slave( ctx , slave )

 

Parameters

 

ctx [ C : modbus_t * ] [ Python : ctypes.POINTER(modbus_t) ]

Specify the pointer to the libmodbus structure.

 

slave [ C : int ] [ Python : ctypes.c_int ]

Specify the slave ID.

 

Return values

 

ret [ C : int ] [ Python : ctypes.c_int ]

If the function succeeds, 0 is returned. If the function fails, -1 is returned, and the following error is stored in errno.

 

Definition

Description

EINVAL

Slave ID is invalid.

 

Remarks

 

Sets the slave ID for the specified Modbus structure.

 

Example

 

Sets slave ID 1.

 

C

int ret;

modbus_t *ctx;

ret = modbus_set_slave(ctx, 1);

 

Python

ret = ctypes.c_int

ctx = ctypes.POINTER(modbus_t)

ret = modbus.modbus_set_slave(ctx, 1)