modbus_connect


 

Function

 

Connects to a Modbus slave device.

 

Format

 

ret = modbus_connect( modbus_t *'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, 0 is returned. If the function fails, -1 is returned.

 

Remarks

 

Connects to a Modbus slave device. Please use this function after making settings related to communication with modbus_new_tcp or modbus_new_rtu.

 

Example

 

Connects to the Modbus slave according to the structure specified by ctx.

 

VB.NET

Dim ret As Integer

Dim ctx As IntPtr

ret = modbus_connect(ctx)

 

C, C++

int ret;

modbus_t *ctx;

ret = modbus_connect(ctx);

 

C#

int ret;

IntPtr ctx;

ret = modbus.Connect(ctx);

 

Python

ret = ctypes.c_int

ctx = ctypes.POINTER(modbus_t)

ret = modbus.modbus_connect(ctx)