MB_GetState block
Short summary
Name |
MB_GetState |
→POU type |
|
Category |
more system blocks, blocks for Modbus, block with internal error diagnostic |
Graphical interface |
|
Available since |
|
Functionality
The block determines the state of a given →Modbus connection.
It is imperative that you are using MB_GetState in order to determine the state of a Modbus connection within each cycle of the application. Make sure that the application contains the required steps depending on the return code of MB_GetState. Do not use internal variables within the application for determining the state of a connection. – Please also observe the note on the usage as it is specified for the MB_InitTCP block.
Inputs, return value
|
Identifier |
Description |
|
Inputs: |
MBHandle |
DINT |
the handle for an existing connection (with initial value -1) |
Return value: |
– |
SINT |
returns the current state of the given connection handle:
|
Input EN and output ENO are available when →calling
the block. See "Execution control: EN, ENO" for information on input EN and output ENO.
Internal error diagnostic for block
The block checks the following error cases: The LibModbus system service has not been loaded and/or you have no permissions to use Modbus (no enabled feature in the license for
the →runtime system
).
In such an error case, the output ENO of the block is set to value FALSE (or an equivalent).
Example for usage within ST-editor
Best practice in order to get to know the usage of the Modbus blocks: Create a new project based on the project template Moving Light with Modbus Access and study this sample project. This project contains a usage of this block.