Colway Solutions
Modbus Member Logo

Glue MSPL-C to application and database

Glue library to Application

The library handles the task of framing and de-framing Modbus messages. The data within the messages are supplied by respective application programs. The library encapsulates this data as per Modbus framing rules and transmits it to the recipient.

 

Using the functions Read Coil and Write Coil to illustrate.

  • Read Coil: In response to the Read Coil command, the application program running on the slave will supply data to the library. The library will frame the data in accordance to Modbus framing rules and send it to the master, completing the transaction.
  • Write Coil: The application running on the master supplies the data to the library. The library encapsulates the data in the right frames and forwards the framed message to the slave program, which executes the command.

  •  

    Two functions in the MSPL_UserIf.c file facilitate the interface between the library and your application and database.

  • MSPL_ReadUserData: Called by MSPL-C when it receives a "read" type of Modbus request.
  • MSPL_WriteUserData: Called by MSPL-C when it receives a "write" type of Modbus request.
  •  

    User is responsible for implementing these interface functions.

     

    These two functions present a well defined interface that is fully documented in this manual. The library supplied to you contains dummy implementations of these functions with no code within.

     

    Please refer to sample Win32 port for a complete reference.

     

    Glue library to Simulated Database

    A simulated database forms part of the library supplied. It has a few variables of all the data types supported by the library.

    Use this database as a first step to get the library working on your platform. This exercise will assist in integrating the library with the application's database.

     

    The database is created at the beginning of the MSPL_UserIf.c file and contains the following data elements:


    S.No.

    Data Element

    Associated Modbus Data Type

    Number of Arrays

    Memory Address

    1

    CSPL_U8 (single byte)

    Coils, Discrete Inputs

    2

    0000 to 0015 (16 items)

     

    2

    CSPL_U16 (two byte)

    Holding and Input Registers

    2

    0000 to 0010 (10 items)

    3

    Demonstrate mapping register to long integer

    Float

    1

    0020 to 0029 (5 floats using 10 registers)

    4

    Demonstrate mapping register to long integer

    Long Integer - 4 bytes

    1

    0040 to 0049 (5 long integers using 10 registers)

    5

    Demonstrate mapping register to string

    Strings

    1

    0060 to 0063 (8 characters that can hold a 'C' string of max length 7 using 4 registers)

     

    The interface functions in the MSPL_UserIf.c file operate upon this simulated database.

    After testing with this database, you may replace it with your own.  Modify the interface functions to operate on your database.

     

    Back to Index

    Privacy Policy Site Map FAQ Contact Us