Function used for opening a Modbus/TCP client-type communication.
The function creates a Modbus client that remains alive as long as the current task is running. If the task is restarted, the client is deleted. Therefore, for proper functioning, it is recommended to run the function each time the task is restarted (see restarted variable).
Syntax |
i32 mbc_init (string strIp, i32 nPort, real timeout, real expTime, i32 buffDim [, i32 initCode<0]) |
||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
strIp |
String with target IP address |
||||||||||
nPort |
Target port number |
||||||||||
timeout |
Timeout in seconds on command execution |
||||||||||
expTime |
Minimum guaranteed time, in seconds, that the response remains in the buffer before being discarded to make place for new messages if the Modbus message handling buffer is full |
||||||||||
buffDim |
Size of the Modbus message management buffer. Represents the maximum number of commands (Modbus read/write functions) that can be used simultaneously |
||||||||||
initCode |
Indicates the initial index of units: •<0, the sys_cfg.5 bit is used to determine the initial index of units •0, the initial index of units is 0 (nonstandard value) regardless of the status of sys_cfg.5 •>0, the initial index of units is 1 (standard value) regardless of the state of sys_cfg.5 (optional, default <0) |
||||||||||
Result |
Returns the communication management handle that uniquely identifies the communication. It is used in all other Modbus management functions.
|
||||||||||
Validity |
Task |
||||||||||
Note |
The function is blocking. It exits only when the operation is completed |
Since RTE 34.30.0, a new management has been introduced. The Modbus client is created, but not connected, the management of the connection will then be manageable through the mbc_connect() and mbc_shutdown() commands. Automatic reconnection to the server is not available for these types of clients.
Syntax |
i32 mbc_init (real timeout, real expTime, i32 buffDim) |
||||||||
---|---|---|---|---|---|---|---|---|---|
timeout |
Timeout in seconds on command execution |
||||||||
expTime |
Minimum guaranteed time, in seconds, that the response remains in the buffer before being discarded to make room for new messages if the Modbus message handler buffer is full |
||||||||
buffDim |
Size of the Modbus message handling buffer. Represents the maximum number of commands (Modbus read/write functions) that can be used simultaneously |
||||||||
result |
Returns the communication management handle that uniquely identifies the communication. It is used in all other Modbus management functions.
|
||||||||
Validity |
Task |
||||||||
System Requirements |
From RTE 34.30.0 |
||||||||
Note |
Example of use: |