#include "mb.h"
This module defines the interface for the application. It contains the basic functions and types required to use the Modbus Master protocol stack. A typical application will want to call eMBMasterInit() first. If the device is ready to answer network requests it must then call eMBEnable() to activate the protocol stack. In the main loop the function eMBMasterPoll() must be called periodically. The time interval between pooling depends on the configured Modbus timeout. If an RTOS is available a separate task should be created and the task should always call the function eMBMasterPoll().
// Initialize protocol stack in RTU mode for a Master
eMBMasterInit( MB_RTU, 38400, MB_PAR_EVEN );
// Enable the Modbus Protocol Stack.
eMBMasterEnable( );
for( ;; )
{
// Call the main polling loop of the Modbus Master protocol stack.
eMBMasterPoll( );
...
}
Use the default Modbus Master TCP port (502)