Colway Solutions
Modbus Member Logo

Making Calls into MMPL-C APIs

 

Once you have ported the library to your platform, it is time to make calls into its API's. The following table shows a list of API's that may be called by the user's application:

 

API

When to call

Mandatory?

Remarks

DoModbusTransaction

Periodically for every channel, when there is need to send request/response to/from the Modbus Slave .

Yes

->   This is the main entry point into the library, also called as the trigger function.

->   DoModbusTransaction is a blocking call and does not return until a response is received or a timeout occurs..

->   If DoModbusTransaction is used, then MMPL_ReadPort function in MMPL_UserIf.c must implement a timeout logic

MMPL_SendRequest/
MMPL_RecvAndProcessResp

(These functions do what DoModbusTransaction single handedly does)

Periodically for every channel, when there is need to send request/response to/from the Modbus Slave .

Yes

->   MMPL_SendRequest function constructs and sends Modbus request

->   MMPL_RecvAndProcessResp function receives and processes slave response

->   Unlike DoModbusTransastion, the call does not get blocked waiting for slave to respond

->   MMPL_SendRequest( );
DoAnyOtherAppTass()/* Call any other application tasks*/
if(ResponseReceived){
MMPL_RecvAndProcessResp( );
}

MMPL_OpenPort

On program start up, once for every communication channel to be opened and initialised.

No (optional)

->   The user is free to perform channel initialisation outside of the library in which case this function need not be implemented and/or called.

MMPL_ClosePort

Once per channel when Modbus communication is no longer required on that channel.

No (optional)

->   In applications where Modbus communication is expected to be active until the device is switched OFF, this function need not be called at all.

->   As for MMPL_OpenPort, user may choose to implement channel de-initialisation code outside the library in which case this function need not be implemented or called.


Back to Index


Privacy Policy Site Map FAQ Contact Us