Colway Solutions
Modbus Member Logo

User Manual - Modbus Master Protocol Library - ‘C’ Source Code

1   Architecture. 4

1.1   MMPL Block Schematic. 4

1.2   Directory Structure. 5

1.3   Files. 5

1.4   Hooks and Macros. 6

2   Porting. 6

2.1   Add source code to your project. 7

2.2    Set Endian Architecture. 7

2.2.1   More about Endianness. 8

2.3   Select Modbus framing type (RTU or TCP). 9

2.4   Glue MMPL to device interface. 9

2.5   Glue MMPL-C to application and database. 11

2.5.1   Glue library to Application. 11

2.5.2   Glue library to simulated Database. 11

2.5.3   Using the Data Formatter to map ‘C’ data types to Modbus. 12

2.6   Configure diagnostics. 13

2.6.1   Step-1: Select debugger level 14

2.6.2   Step-2: Include or exclude Formatted I/O support. 14

2.6.3   Step-3: Implement the debug “sink”. 15

2.7   Optimise MMPL-C. 15

2.7.1   Set optimal buffer sizes. 16

2.7.2   Include only the function you require. 17

2.7.3   Reduce Code Memory size by configuring CRC macros (Modbus RTU only). 18

2.7.4   Reduce Data Memory (RAM) size by configuring CRC macros. 18

3   Making calls into MMPL-C APIs. 21

3.1   Flowchart for MMPL-C API invocation. 22

4   MMPL-C Reference. 27

4.1   MMPL-C Data Types. 27

4.2   MMPL-C Function Reference. 28

4.2.1   MMPL_OpenPort. 28

4.2.2   MMPL_ClosePort. 29

4.2.3   MMPL_ReadPort. 32

4.2.4   MMPL_WritePort. 33

4.2.5   MMPL_DebugPrint. 33

4.2.6   MMPL_SendRequest. 35

4.2.7   MMPL_RecvAndProcessResp. 35

4.2.8   DoModbusTransaction. 35

4.2.9   Status codes returned by function DoModbusTransaction, MMPL_SendRequest and MMPL_RecvAndProcessResp . 35

4.3   Macro Reference. 38

4.3.1   MODBUS_MODE. 38

4.3.2   ENDIAN_STYLE. 38

4.3.3   RD_BLK_SIZE_BITINFO.. 39

4.3.4   RD_BLK_SIZE_REGINFO.. 39

4.3.5   WR_BLK_SIZE_BITINFO.. 39

4.3.6   WR_BLK_SIZE_REGINFO.. 40

4.3.7   RX_BUFFER_SIZE and TX_BUFFER_SIZE. 40

4.3.8   STDIO_SUPPORTED.. 40

4.3.9   DEBUG_LEVEL. 41

4.3.10   CRC_TABLE_LOCATION.. 42

4.3.11   CRC_TABLE_LOC_MODIFIER. 42

4.3.12   xdata... 43

Privacy Policy Site Map FAQ Contact Us