modbus_get_slave


 

Function

 

Retrieves the slave ID that has been set.

 

Format

 

ret = modbus_get_slave( ctx )

 

Parameters

 

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

Specify the pointer to the libmodbus structure.

 

Return values

 

ret [ 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.

 

C

int ret;

modbus_t *ctx;

ret = modbus_get_slave(ctx);

 

Python

ret = ctypes.c_int

ctx = ctypes.POINTER(modbus_t)

ret = modbus.modbus_get_slave(ctx)