The application appl/goal_mb/01_simple_io demonstrates the usage of the GOAL Modbus Stack. It defines data regions for specific data types, opens up a Modbus instance and creates objects.
It also initializes Device Detection to access CM Variables to set Interface Configuration like IP Address.
Footprint
The application uses with enabled logging at the platform STM32F429_nucleo about 52 kB of RAM and 240 kB of FLASH.
Data Regions
The application uses the function goal_mbCfgDataRegionDefine
to define accessable regions for specific data types.
Data Type | Region |
---|---|
GOAL_MB_DATA_COIL | 1000 to |
GOAL_MB_DATA_HOLD_REG | 3000 to |
This function only restricts regions used by Coils and Holding Registers. Other Data Types must be handled by the application itself.
Data Objects
The application creates objects as following:
Data Type | Name(s) | Address(es) |
---|---|---|
Coil | APPL_COIL_1 | 1000 |
Coil | APPL_COIL_2 | 1001 |
Discrete Input | APPL_DISC_INPUT_1 to | 2000 to |
Holding Register | APPL_HOLD_REG_1 | 3000 |
Holding Register | APPL_HOLD_REG_2 | 3001 |
Input Register | APPL_INPUT_REG_1 to | 3050 to |
Application Logic
The application provides a generic callback handler, which handles events like received read-requests or write-requests and connection-related events. Handles callback IDs are the following:
GOAL_MB_CB_ID_APPL_READY
GOAL_MB_CB_ID_DATA_READ
the called function
appl_readRequestProcess
provides the discrete inputs, input- and holding registers and returns random values and LED states to the requested objects.
GOAL_MB_CB_ID_DATA_WRITE
the called function
appl_writeRequestProcess
handles write requests for a holding register, setting the written value to target specific LED registers.
GOAL_MB_CB_ID_CONNECT_REQUEST
GOAL_MB_CB_ID_CONNECT_RELEASE
GOAL_MB_CB_ID_LED_CHANGED
Available Callback IDs are listed here.
There is also an application loop implemented, which mirrors application coils every 100 ms.