Colway Solutions
Modbus Member Logo

Using the Data Formatter to map 'C' data types to Modbus

 

MMPL-C provides you an extension to the Modbus specifications by supplying a set of functions in file MMPL_C.c that map the low level Modbus types (bits and words) to high level 'C' data types (floats, integers and strings) with due consideration to the ENDIAN format of your platform.

 

There are two categories of functions:

-       Functions that convert an array of raw data bytes as received via Modbus to an array of higher level 'C' data type. They are usually called in DecodeResponse to interpret the raw Modbus data as per the corresponding higher level 'C' datatype of the user database.

-       Functions that convert an array of some higher level 'C' data type into an array of raw data bytes that can be transmitted via Modbus. They are usually called in ConstrucRequest to provide the library with user data in a Modbus compliant format.

 

Following is a brief description of each function:

Function name

Description

MMPL_PackBits

This method bit-packs the destination buffer with bit status information from the source buffer. The source buffer is expected to contain bit status (i.e a value of 0 or 1) information in one byte per bit. This data is bit-packed as 8-bits per byte in the destination buffer.

MMPL_UnPackBits

This method unpacks the bits from the source buffer (which has data bit-packed as 8-bits per byte) and puts the bit status information (i.e a value of 0 or 1) into the destination buffer (in one byte per bit).

MMPL_ShortIntsToBuffer

This method puts data into the destination buffer in such a way that a pair of bytes of the destination buffer is used to hold the value of one two-byte register (source buffer).

MMPL_BufferToShortInts

This method puts data into the destination buffer in such a way that a pair of bytes of the source buffer is used to form the value of one two-byte register.

 

Back to Index

Privacy Policy Site Map FAQ Contact Us