Download Modbus Master Source Code Library

Transcript
Modbus Master C# Source Code Library
Users Manual
Table Of Contents
1.0)
The Modbus Master Stack Source Code Library .................................................................... 3
2.0)
Important Concepts Used in SCL ............................................................................................. 5
3.0)
Pre-requisites ............................................................................................................................. 6
3.1)
Modbus Basics...................................................................................................................... 6
3.1.1)
Modbus Data types ........................................................................................................... 6
3.1.2)
Modbus Device addressing ............................................................................................... 7
3.1.3)
Modbus Data Point addressing ......................................................................................... 7
4.0)
Components of the Modbus Master SCL................................................................................. 8
5.0)
Porting the Source Code Library.............................................................................................. 9
5.1)
5.1.1)
5.2)
Physical Layer Interface Macros and Functions ................................................................. 10
OpenPort ......................................................................................................................... 10
5.2.2)
ClosePort......................................................................................................................... 12
5.2.3)
ReadPort ......................................................................................................................... 12
5.2.4)
WritePort.......................................................................................................................... 13
5.2.5)
Flush................................................................................................................................ 14
5.2.6)
OpenTCP......................................................................................................................... 15
5.2.7)
CloseTCP ........................................................................................................................ 16
5.2.8)
ReadTCP......................................................................................................................... 16
5.2.9)
WriteTCP ......................................................................................................................... 17
Stack Control Macros.......................................................................................................... 19
5.3.1)
DEBUGENABLED ........................................................................................................... 19
5.3.2)
MODBUS_TCP................................................................................................................ 19
5.3.3)
LITTLE_ENDIAN ............................................................................................................. 20
Modbus Error checking and other information..................................................................... 21
6.1)
7.0)
GetTimeInMilliseconds .................................................................................................... 10
5.2.1)
5.3)
6.0)
The User Application Interface Macros and Functions ....................................................... 10
Exception Responses ......................................................................................................... 23
Protocol Entry Functions ........................................................................................................ 24
7.1)
MBDriver_InitSerialDriver ................................................................................................... 25
7.2)
MBDriver_InitTCPDriver ..................................................................................................... 25
7.3)
MBSendRequest ................................................................................................................. 26
7.3.1)
Parameter Values for MBSendRequest .......................................................................... 28
7.3.2)
Response Format............................................................................................................ 31
7.4)
MBDriver_DeInit.................................................................................................................. 35
7.5)
MBGetLastError .................................................................................................................. 35
7.6)
MBGetLastError .................................................................................................................. 36
8.0)
Technical Specifications.......................................................................................................... 37
Sunlux Technologies
Page 2 of 37