modbus_get_slave


 

Function

 

Retrieves the slave ID that has been set.

 

Format

 

ret = modbus_get_slave( ctx )

 

Parameters

 

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

Specify the pointer to the libmodbus structure.

 

Return values

 

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

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

 

Definition

Description

EINVAL

CTX is invalid.

 

Remarks

 

Retrieves the slave ID that has been set in the specified Modbus structure.

 

Example

 

Retrieves the slave ID.

 

VB.NET

Dim ret As Integer

Dim ctx As IntPtr

ret = modbus_get_slave(ctx)

 

C, C++

int ret;

modbus_t *ctx;

ret = modbus_get_slave(ctx);

 

C#

int ret;

IntPtr ctx;

ret = modbus.GetSlave(ctx);
 

Python

ret = ctypes.c_int

ctx = ctypes.POINTER(modbus_t)

ret = modbus.modbus_get_slave(ctx)