Modbus Messaging Implementation Guide v1 · PDF file3.1 PROTOCOL DESCRIPTION ... MODBUS MESSAGING IMPLEMENTATION GUIDE 1.0 8-May-02 Modbus Messaging Implementation Guide v1.doc 49

  • Upload
    lydan

  • View
    228

  • Download
    2

Embed Size (px)

Citation preview

  • A Community for MODBUS Users by MODBUS Users

    MODBUS MESSAGING ON TCP/IP

    IMPLEMENTATION GUIDE

    Rev 1.0 8May02

  • MODBUS MESSAGING IMPLEMENTATION GUIDE 1.0 8-May-02

    www.modbus.org Modbus Messaging Implementation Guide v1.docpage 2/49

    Key words :

    (5-10 words)

    Summary :

    (3-5 lines)

    Document modificationsRN Month-Year Author Modifications

  • MODBUS MESSAGING IMPLEMENTATION GUIDE 1.0 8-May-02

    www.modbus.org Modbus Messaging Implementation Guide v1.docpage 3/49

    Table of Contents

    1. INTRODUCTION................................ ................................ ........................ 61.1 OBJECTIVES................................ ................................ ................................ .6

    1.2 CLIENT / SERVER MODEL ................................ ................................ ........... 6

    1.3 REFERENCE DOCUMENTS................................ ................................ .......... 8

    2. ABBREVIATIONS ................................ ................................ ..................... 8

    3. CONTEXT................................ ................................ ................................ ..83.1 PROTOCOL DESCRIPTION................................ ................................ .......... 8

    3.1.1 General communication architecture ................................ ................................ ................ 83.1.2 MODBUS On TCP/IP Application Data Unit ................................ ................................ ......93.1.3 MBAP Header description................................ ................................ ................................ 10

    3.2 MODBUS FUNCTIONS CODES DESCRIPTION................................ ......... 11

    4. FUNCTIONAL DESCRIPTION................................ ................................ 124.1 MODBUS COMPONENT ARCHITECTURE MODEL................................ ...12

    4.2 TCP CONNECTION MANAGEMENT................................ ........................... 154.2.1 Connections management Module ................................ ................................ ................. 154.2.1.1 General description .......................................................................................................154.2.1.2 Connection management description ............................................................................174.2.2 Impact of Operating Modes on the TCP Connection ................................ ..................... 184.2.2.1 Communication break between two operational end points:...........................................184.2.2.2 Crash and Reboot of the Server end point.....................................................................184.2.2.3 Crash and Reboot of the Client .....................................................................................184.2.3 Access Control Module................................ ................................ ................................ ....19

    4.3 USE of TCP\IP STACK................................ ................................ ................ 194.3.1 Use of BSD Socket interface................................ ................................ ............................ 204.3.2 TCP layer parameterization ................................ ................................ ............................ 224.3.3 IP layer parameterization ................................ ................................ ................................ .234.3.3.1 IP Parameters...............................................................................................................23

    4.4 COMMUNICATION APPLICATION LAYER................................ ................. 244.4.1 MODBUS Client ................................ ................................ ................................ ................ 244.4.1.1 MODBUS client design .................................................................................................244.4.1.2 Build a MODBUS Request ............................................................................................254.4.1.3 Process MODBUS Confirmation ...................................................................................274.4.1.4 Time-out managing .......................................................................................................294.4.2 MODBUS Server ................................ ................................ ................................ ............... 304.4.2.1 MODBUS Server Design...............................................................................................304.4.2.2 MODBUS PDU Checking ..............................................................................................324.4.2.3 MODBUS service processing ........................................................................................334.4.2.4 User Application Interface (Backend Interface)..............................................................344.4.2.5 MODBUS Response building ........................................................................................34

    5. IMPLEMENTATION GUIDELINE................................ ............................ 355.1 OBJECT MODEL DIAGRAM ................................ ................................ ....... 36

  • MODBUS MESSAGING IMPLEMENTATION GUIDE 1.0 8-May-02

    www.modbus.org Modbus Messaging Implementation Guide v1.docpage 4/49

    5.1.1 TCP management package ................................ ................................ .............................. 375.1.2 Configuration layer package ................................ ................................ ........................... 385.1.3 Communication layer package ................................ ................................ ........................ 395.1.4 Interface classes................................ ................................ ................................ ............... 40

    5.2 IMPLEMENTATION CLASS DIAGRAM................................ ....................... 40

    5.3 SEQUENCE DIAGRAMS................................ ................................ .............. 42

    5.4 CLASSES AND METHODS DESCRIPTION................................ ................ 455.4.1 MODBUS server class ................................ ................................ ................................ ......45Class CMODBUSServer ................................ ................................ ................................ ............. 455.4.2 MODBUS Client Class ................................ ................................ ................................ ......46Class CMODBUSClient ................................ ................................ ................................ .............. 465.4.3 Interface Classes ................................ ................................ ................................ .............. 475.4.3.1 Interface Indication class...............................................................................................47Class CInterfaceIndicationMsg ................................ ................................ ................................ .475.4.3.2 Interface Response Class..............................................................................................47Class CInterfaceResponseMsg ................................ ................................ ................................ .475.4.4 Connexion Management class ................................ ................................ ........................ 48Class CConnexionMngt................................ ................................ ................................ ............. 48

  • MODBUS MESSAGING IMPLEMENTATION GUIDE 1.0 8-May-02

    www.modbus.org Modbus Messaging Implementation Guide v1.docpage 5/49

    List of Figures

    Figure 1: MODBUS TCP/IP communication architecture ................................ ............... 9

    Figure 2: General MODBUS frame................................ ................................ .................... 9

    Figure 3: MODBUS request/response over TCP/IP................................ ......................... 9

    Figure 4: MODBUS Messaging Service Conceptual Architecture ............................... 12

    Figure 5 MODBUS Data Model with separate blocks................................ .................... 13

    Figure 6 MODBUS Data Model with only 1 block ................................ .......................... 13

    Figure 7: TCP connection management activity diagram ................................ ............ 16

    Figure 8: MODBUS TCP connection establishment ................................ ..................... 17

    Figure 9: MODBUS Exchanges................................ ................................ ....................... 21

    Figure 10: MODBUS Client unit ................................ ................................ ...................... 24

    Figure 11: MODBUS Client Activity Diagram ................................ ................................ .25

    Figure 12: Request building activity diagram ................................ ............................... 26

    Figure 13: Process MODBUS Confirmation activity diagram ................................ ...... 29

    Figure 14: MODBUS Server unit ................................ ................................ ..................... 30

    Figure 15: Process MODBUS Indication activity diagram................................ ............ 31

    Figure 16: MODBUS PDU Checking activity diagram................................ ................... 32

    Figure 17: MODBUS service processing activity diagram ................................ ........... 33

    Figure 18: MODBUS Messaging Service Object Mod