modbus_set_byte_timeout


 

Function

 

Sets the timeout period between bytes in Modbus communication.

 

Format

 

ret = modbus_set_byte_timeout( ctx , to_sec , to_usec )

 

Parameters

 

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

Specify the pointer to the libmodbus structure.

 

to_sec [ VB.NET: Uinteger ] [ C, C++: uint32_t * ] [ C#:uint ] [ Python: ctypes.POINTER(ctypes.c_uint32) ]

Specify the part of the timeout period that is more than 1 second (in unit of sec).

 

to_usec [ VB.NET:Uinteger ] [ C, C++: uint32_t * ] [ C#:out uint ] [ Python: ctypes.POINTER(ctypes.c_uint32) ]

Specify the part of the timeout period that is less than 1 second (in unit of usec).

Range of values : 0-999999

 

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 errno is set.

 

Definition

Description

EINVAL

CTX is invalid. Or to_usec is more than 1000000. Or both to_sec and to_usec are set to 0.

 

 

Remarks

 

The timeout setting between bytes in the same message in Modbus communication can be set.

 

Example

 

Sets the timeout period to 1.234 seconds.

 

VB.NET

Dim ret As Integer

Dim ctx As IntPtr

ret = modbus_set_byte_timeout(ctx,1, 234000)

 

C, C++

int ret;

modbus_t *ctx;

ret = modbus_set_byte_timeout(ctx, 1, 234000);

 

C#

int ret;

IntPtr ctx;

ret = modbus_set_byte_timeout(ctx, 1, 234000);

 

Python

ret = ctypes.c_int

ctx = ctypes.POINTER(modbus_t)

ret = modbus.modbus_set_byte_timeout(ctx, 1, 234000)