Colway Solutions
Modbus Member Logo

Glue MSPL to Device Interface

 

A communication channel has to be set up between physical device and the Modbus library in order to receive Modbus request packets and transmit response packets.

The Modbus standard provides allows users to choose their own communication channel. Modbus compliant software is therefore unaware of the characteristics of particular communication channels.

Therefore the library provides a set of unimplemented (i.e. empty) hook functions that can be glued to the real interface functions of your communication channel.

The hook functions cover the four communication operations.

 

S.No.

Channel Operation

Hook Function

Porting Notes

1

Open Port

MSPL_OpenPort

   i. Use this function to open and configure communication channel

   ii. User application must call this function once for every channel supported by the device

   iii. A unique channel identification number is passed as an argument to this function.

   iv. Device driver API usually returns a path identifier or handle to the channel being opened. This is required in subsequent operations: read, write and close. Please ensure that your program stores this identifier. See Win32 port implementation as an example.

2

Read from channel

MSPL_ReadPort

   i. Library calls this function to read data from communication channel

   ii. Function typically calls device driver's "Read" API

   iii. A unique channel number is passed as an argument to identify the channel.

   iv. Caution: Blocking calls to device driver API's in this function will block execution of MSPL-C as well as the application code that is calling the library.

3.

Write to channel

MSPL_WritePort

   i. Library calls this function to transmit data on communication channel

   ii. Function typically calls device driver's "Write" API

   iii. A unique channel number is passed as an argument to identify the channel.

   iv. Caution: Blocking calls to device driver API's in this function will block execution of MSPL-C as well as the application code that is calling the library.

4.

Close Port

MSPL_ClosePort

   i. Use this function to close communication channel

   ii. User application calls this function when no Modbus communication is required

   iii. A unique channel number is passed as an argument to identify the channel.

 

Back to Index

Privacy Policy Site Map FAQ Contact Us