modbus_set_slave


 

Function

 

Sets the slave ID.

 

Format

 

ret = modbus_set_slave( ctx , slave )

 

Parameters

 

ctx [ VB.NET: IntPtr ] [ C, C++: modbus_t * ] [ C#: IntPtr ] [ Python: ctypes.POINTER(modbus_t) ]

Specify the pointer to the libmodbus structure.

 

slave[ VB.NET: Integer ] [ C, C++: int ] [ C#: int ] [ Python: ctypes.c_int ]

Specify the slave ID.

 

Return values

 

ret [ VB.NET:Integer ] [ C, C++: int ] [ 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.

 

VB.NET

Dim ret As Integer

Dim ctx As IntPtr

ret = modbus_set_slave(ctx, 1)

 

C, C++

int ret;

modbus_t *ctx;

ret = modbus_set_slave(ctx, 1);

 

C#

int ret;

IntPtr ctx;

modbus.SetSlave(ctx , 1);
 

Python

ret = ctypes.c_int

ctx = ctypes.POINTER(modbus_t)

ret = modbus.modbus_set_slave(ctx, 1)