CN107896234A - The method of transmitting message, Modbus communication networks and equipment in Modbus communication networks - Google Patents

The method of transmitting message, Modbus communication networks and equipment in Modbus communication networks Download PDF

Info

Publication number
CN107896234A
CN107896234A CN201711483731.6A CN201711483731A CN107896234A CN 107896234 A CN107896234 A CN 107896234A CN 201711483731 A CN201711483731 A CN 201711483731A CN 107896234 A CN107896234 A CN 107896234A
Authority
CN
China
Prior art keywords
node device
module
framing
host
message
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201711483731.6A
Other languages
Chinese (zh)
Other versions
CN107896234B (en
Inventor
徐珺
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Kyland Technology Co Ltd
Original Assignee
Kyland Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Kyland Technology Co Ltd filed Critical Kyland Technology Co Ltd
Priority to CN201711483731.6A priority Critical patent/CN107896234B/en
Publication of CN107896234A publication Critical patent/CN107896234A/en
Application granted granted Critical
Publication of CN107896234B publication Critical patent/CN107896234B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/06Notations for structuring of protocol data, e.g. abstract syntax notation one [ASN.1]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/28Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
    • H04L12/40Bus networks
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/18Multiprotocol handlers, e.g. single devices capable of handling multiple protocols
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/22Parsing or analysis of headers
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/28Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
    • H04L12/40Bus networks
    • H04L2012/40208Bus networks characterized by the use of a particular bus standard
    • H04L2012/40228Modbus

Abstract

The embodiment of the invention discloses a kind of method of the transmitting message in Modbus communication networks, Modbus communication networks and equipment.The method of transmitting message in Modbus communication networks of the embodiment of the present invention, including:Agreement framing module and the transport module that the initialization module of host node device determines to enable in host node device according to the configuration information of host node device, and the agreement framing module enabled from the initialization module of node device according to the configuration information determination from node device from node device;When obtaining message to be transmitted, the agreement framing module that host node device enables by transmitting message framing, and by the transport module that host node device enables to from node device send framing after message;After the transport module enabled from node device receives the message after framing, the agreement framing module enabled from node device parses the message after framing according to the analysis mode of this module definition.The embodiment of the present invention reduces the implementation complexity and development difficulty of Modbus protocol stacks.

Description

In Modbus communication networks the method for transmitting message, Modbus communication networks and Equipment
Technical field
The present embodiments relate to the communication technology, more particularly to a kind of side of the transmitting message in Modbus communication networks Method, Modbus communication networks and equipment.
Background technology
Modbus agreements are the bus protocols that first, the whole world is really used for industry spot, are used extensively in industry control industry, Including ModbusRTU, ModbusTCP and ModbusASCII.ModbusASCII messages can pass through serial ports, such as RS232/ RS422/RS485 is transmitted, and can also be transmitted, can also can also be passed by GPRS transmission by ZigBee by Ethernet It is defeated;ModbusRTU can be transmitted by serial ports, such as RS232/RS422/RS485, can also be transmitted by Ethernet, It can also can be transmitted by GPRS transmission by ZigBee;Equally, ModbusTCP can pass through serial ports, such as RS232/ RS422/RS485 is transmitted, and can also be transmitted, can also can also be passed by GPRS transmission by ZigBee by Ethernet It is defeated.
Design Modbus protocol stacks realize that the method for code is at present, for passing through Serial Port Transmission ModbusASCII messages Model Design realize code, code is realized for the Model Design by Serial Port Transmission ModbusRTU messages, for passing through The Model Design of GPRS transmission ModbusRTU messages realizes code, the pattern for transmitting ModbusRTU messages by ZigBee Code is realized in design, is realized code for transmitting ModbusTCP design of EDI messages by Ethernet, by that analogy, that is, is directed to A kind of one section of code of Model Design.
Inventor has found during the present invention is realized:Such design method, not only Code Design repetitive rate is very high, Moreover, also need to be updated the code of equipment, for example, equipment is using by Serial Port Transmission ModbusRTU messages, if It is replaced by by GPRS transmission ModbusRTU messages, then designer, which needs to redesign, passes through GPRS transmission ModbusRTU The design code of message, then equipment reload the design code by GPRS transmission ModbusRTU messages.In addition, with hard The variation of part equipment and the variation of transmission means, it may appear that new transmission means, so change and demand is more and more, need Design fresh code.
The content of the invention
The embodiment of the present invention provide a kind of method of the transmitting message in Modbus communication networks, Modbus communication networks and Equipment, to reduce the implementation complexity of Modbus protocol stacks and development difficulty, the design iterations of code are reduced, improve design effect Rate.
In a first aspect, the embodiments of the invention provide a kind of method of the transmitting message in Modbus communication networks, including:
The initialization module of host node device determines the host node device according to the configuration information of the host node device In the agreement framing module that enables and transport module, and from the initialization module of node device according to described from node device The agreement framing module enabled described in configuration information determination from node device, wherein, each equipment includes multiple agreement framings Module and multiple transport modules, each agreement framing module define a kind of framing mode of Modbus protocol types and each agreement The framing mode that framing module defines is different, and each transport module defines a kind of host-host protocol and each transport module defines Host-host protocol it is different;
When the agreement framing module that the host node device enables obtains message to be transmitted, the host node device The agreement framing module enabled according to the framing mode of this module definition by the transmitting message framing, the message after framing Including purpose from node device address, and the transport module enabled by the host node device is according to this module definition Host-host protocol to it is described from node device send the framing after message;
After the transport module enabled from node device receives the message after the framing, send to it is described from The agreement framing module that node device enables, the agreement framing module enabled from node device is according to this module The analysis mode of definition parses the message after the framing.
Optionally, the host node device initialization module to the host node device carry out initialization and it is described from The initialization module of node device to described after node device initializes, in addition to:
It is described from node device when the agreement framing module enabled from node device obtains message to be transmitted The agreement framing module enabled according to the framing mode of this module definition by the transmitting message framing, the message after framing Including purpose host node device address, and by the transport module enabled from node device according to this module definition Host-host protocol send the framing to the host node device after message;
After the transport module that the host node device enables receives the message after the framing, the master is sent to The agreement framing module that node device enables, the agreement framing module that the host node device enables is according to this module The analysis mode of definition parses the message after the framing.
Optionally, the host node device initialization module to the host node device carry out initialization and it is described from The initialization module of node device to it is described initialized from node device before, in addition to:
The Modbus protocol types supported in each equipment according to the Modbus communication networks create the multiple agreement Framing module, and the host-host protocol supported according to the Modbus communication networks creates the multiple transport module, it is described respectively to set It is standby including the host node device and described from node device.
Optionally, in the framing mode from the agreement framing module that node device enables according to this module definition Before the transmitting message framing, in addition to:
When the transport module enabled from node device listens to the connection request from host node device, institute The transport module establishment enabled from node device and the connection of the host node device and hyphen handle_ID are stated, and The handle_ID is informed into the agreement framing module enabled from node device;
It is described that the message received is distinguished by the handle_ID from the agreement framing module that node device enables From host node device, and by the handle_ID to the message from host node device send feedback message.
Optionally, methods described also includes:
When the transport module enabled from node device determines the Joint failure between host node device, institute The resource that the transport module enabled from node device discharges the connection is stated, will hyphen corresponding with the connection Handle_ID is set to closing, and informs that handle_ID described in the agreement framing module enabled from node device is closed Close.
Optionally, the transport module enabled sends the message after the framing, bag according to the host-host protocol of this module definition Include:
The transport module enabled calls the hardware driving of corresponding hardware according to the host-host protocol of this module definition, to drive The dynamic hardware sends the message after the framing.
Second aspect, the embodiments of the invention provide a kind of Modbus communication networks, including:Host node device and from node Equipment, wherein, each equipment includes multiple agreement framing modules and multiple transport modules, and each agreement framing module definition is a kind of The framing mode that the framing mode of Modbus protocol types and each agreement framing module define is different, each transport module It is different to define the host-host protocol that a kind of host-host protocol and each transport module define;
Wherein, the host node device is used for the agreement framing mould for determining to enable according to configuration information by initialization module Block and transport module;
It is described from node device be used for by initialization module according to configuration information determine the agreement framing module that enables and Transport module;
The host node device is additionally operable to treat when the agreement framing module enabled by the host node device obtains , will according to the framing mode of this module definition by the agreement framing module that the host node device enables during transmitting message The transmitting message framing, the message after framing enable including purpose from node device address, and by the host node device The transport module according to the host-host protocol of this module definition to it is described from node device send framing after message;
It is described to be additionally operable to receive described group by the transport module enabled from node device from node device After message after frame, the agreement framing module enabled from node device is sent to, then by described from node device The agreement framing module enabled parses the message after the framing according to the analysis mode of this module definition.
Optionally, it is described to be additionally operable to from node device when by the agreement framing module enabled from node device When obtaining message to be transmitted, pass through the framing from the agreement framing module that node device enables according to this module definition For mode by the transmitting message framing, the message after framing includes purpose host node device address, and is set by described from node After the standby transport module enabled sends the framing according to the host-host protocol of this module definition to the host node device Message;
The transport module that the host node device is additionally operable to enable by the host node device receives described group After message after frame, the agreement framing module that the host node device enables is sent to, then pass through the host node device The agreement framing module enabled parses the message after the framing according to the analysis mode of this module definition.
Optionally, the Modbus protocol types that each equipment is used to be supported according to the Modbus communication networks create described more Individual agreement framing module, and the host-host protocol supported according to the Modbus communication networks creates the multiple transport module, institute Stating each equipment includes the host node device and described from node device.
Optionally, it is described to be additionally operable to monitor when by the transport module enabled from node device from node device During the connection request of arrival autonomous node equipment, created and the master by the transport module enabled from node device The connection of node device and hyphen handle_ID, and by the handle_ID inform it is described enable from node device described in Agreement framing module;Connect by described distinguished from the agreement framing module that node device enables by the handle_ID The message received from host node device, and by the handle_ID to the message from host node device send out Send feedback message.
Optionally, it is described to be additionally operable to determine when by the transport module enabled from node device from node device During Joint failure between host node device, pass through the transport module enabled from node device and discharge the connection Resource, hyphen handle_ID corresponding with the connection is set to closing, and inform the institute enabled from node device Handle_ID described in stating agreement framing module is closed.
Optionally, each equipment is used for corresponding hard according to the host-host protocol of this module definition calling by the transport module enabled The hardware driving of part, to drive the message after the hardware transmission framing, each equipment includes the host node device With described from node device.
The third aspect, the embodiments of the invention provide a kind of equipment, the equipment includes:
One or more processors;
Storage device, for storing one or more programs;
When one or more of programs are by one or more of computing devices so that one or more of processing Device is realized host node device as described in above-mentioned first aspect is any or passed from node device in Modbus communication networks The method of defeated message.
Fourth aspect, the embodiments of the invention provide a kind of computer-readable recording medium, is stored thereon with computer journey Sequence, realized when the program is executed by processor such as the host node device as described in above-mentioned first aspect is any or from node device The method of transmitting message in Modbus communication networks.
The embodiment of the present invention is defined multiple Modbus agreements and multiple host-host protocols by different code modules respectively, The agreement framing module and transport module enabled during instantiation according to configuration information determination, realize Modbus protocol stacks flexible group Close, solving needs to develop different protocol stacks for different agreements and different transmission means in the prior art, causes generation The problem of code repetitive rate is high, reduce the implementation complexity and development difficulty of Modbus protocol stacks.It is and more with hardware device The variation of sample and transmission means, when the new transmission means of appearance, it is only necessary to increase the code module of new transmission means i.e. Can, reduce the redesign amount of code.
Brief description of the drawings
Fig. 1 is the flow chart of the method for transmitting message in Modbus communication networks that the embodiment of the present invention one provides;
Fig. 2 is the Modbus protocol stack module composition schematic diagrams that the embodiment of the present invention one provides;
Fig. 3 is the structural representation for the Modbus communication networks that the embodiment of the present invention two provides;
Fig. 4 is the structural representation for the equipment that the embodiment of the present invention three provides.
Embodiment
The embodiment of the present invention is described in further detail with reference to the accompanying drawings and examples.It is understood that this The specific embodiment of place description is used only for explaining the embodiment of the present invention, rather than the restriction to the embodiment of the present invention.In addition also It should be noted that for the ease of describing, the part related to the embodiment of the present invention rather than entire infrastructure are illustrate only in accompanying drawing.
Fig. 1 is the flow chart of the method for transmitting message in Modbus communication networks that the embodiment of the present invention one provides, and is had Body comprises the following steps:
Step 101, the initialization module of host node device determine host node device according to the configuration information of host node device In the agreement framing module that enables and transport module, and from the initialization module of node device according to the configuration from node device Information determines the agreement framing module that is enabled from node device, wherein, each equipment include multiple agreement framing modules with it is more Individual transport module, each agreement framing module define a kind of framing mode of Modbus protocol types and each agreement framing module The framing mode of definition is different, and each transport module defines the transmission association that a kind of host-host protocol and each transport module define Discuss different;
Modbus communication networks are an industrial communication systems, pass through public line or local special by controller and computer Formed with connection, can be applied to various data acquisitions and process monitoring.The code of Modbus protocol stacks is except defining data Framing, packing and analysis mode, the relevant information of packet sending and receiving is also defined, for example, for passing through Serial Port Transmission ModbusRTU The Model Design of message realizes code, and code is realized for the Model Design that ModbusRTU messages are transmitted by Ethernet, for Code is realized by the Model Design of Serial Port Transmission ModbusTCP messages, set for transmitting ModbusTCP messages by Ethernet Meter realizes code.
The Modbus protocol types that Modbus communication networks are supported include ModbusRTU, ModbusTCP with ModbusASCII, the host-host protocol of support include Serial Port Transmission, Ethernet transmission, GPRS transmission and ZigBee transmission, Ethernet Transmission is divided into TCP transmission and UDP transmission.Each equipment in the present embodiment (host node device i.e. in Modbus communication networks and from Node device) include multiple agreement framing modules and multiple transport modules, each agreement framing module defines a kind of Modbus The framing mode that the framing mode of protocol type and each agreement framing module define is different, wherein, an agreement framing The module definition framing mode of ModbusRTU agreements, for example, its code includes preparing to need the data sent:Application data And CRC check, the data that packing, framing and parsing receive;Another agreement framing module defines ModbusTCP agreements Framing mode, for example, its code includes preparing to need the data sent:Application data, packing, framing are (according to TCP form groups Frame) and the data that receive of parsing;Also an agreement framing module defines the framing mode of ModbusASCII agreements.Often It is different that individual transport module defines the host-host protocol that a kind of host-host protocol and each transport module define, wherein, a transmission Module definition Serial Port Transmission agreement, for example, its code includes opening serial ports, specify Serial Port Information (baud rate, verification mode, Data bit, stop position), serial ports is sent, and serial ports is received;Another transport module defines Ethernet host-host protocol, for example, its code Including establishing connection (establishing connection according to IP and port), Ethernet is sent, and Ethernet is received;Another defines transport module GPRS transmission agreement, also a transport module define ZigBee host-host protocols.
Configuration information results from the configuration that user is carried out to host node device and from node device in advance, including respectively setting The standby protocol type and host-host protocol enabled, for example, user's selection is by the way of ModbusRTU agreements+Serial Port Transmission, then it is first What is enabled during beginningization in each equipment is exactly transmission mould corresponding to agreement framing module corresponding to ModbusRTU agreements and Serial Port Transmission Block.
Step 102, when agreement framing module that host node device enables obtains message to be transmitted, host node device enables Agreement framing module according to the framing mode of this module definition by transmitting message framing, the message after framing includes purpose from section Point device address, and by the transport module that host node device enables according to the host-host protocol of this module definition to from node device Send the message after framing;
Host node device sends message to from node device, can generate transmitting message by high-rise (for example, application layer), When the agreement framing module that host node device enables gets the transmitting message, the framing by the module according to this module definition Mode is by transmitting message framing, for example, host node device enables agreement framing module corresponding to ModbusRTU agreements, the module Purpose is carried according to the framing mode of ModbusRTU agreements by transmitting message framing, and in the message after framing from node The address of equipment, the transport module that then host node device enables is according to the host-host protocol of this module definition by the report after the framing Text is sent to from node device, for example, host node device enables transport module corresponding to Serial Port Transmission, the module passes according to serial ports Defeated agreement sends message.
After step 103, the transport module enabled from node device receive the message after framing, send to from node device The agreement framing module enabled, the analysis mode parsing group from the agreement framing module that node device enables according to this module definition Message after frame.
The transport module periodic receipt data enabled from node device, after message after framing is received, Ye Shitong Cross caching to do transfer and be transferred to the agreement framing module enabled from node device, the transport module enabled from node device will Message after framing is put into caching, and the agreement framing module enabled from node device calls above-mentioned reading file interface from caching The message after framing is extracted, is then parsed according to the analysis mode of this module definition.
The technical scheme of the present embodiment, in the design code of an equipment, by multiple Modbus agreements and multiple transmission Agreement is defined by different code modules respectively, the agreement framing module and biography enabled in instantiation according to configuration information determination Defeated module, the flexible combination of Modbus protocol stacks is realized, solve needs for different agreement and different in the prior art Transmission means develops different protocol stack, the problem of causing code redundancies high, reduces the implementation complexity of Modbus protocol stacks And development difficulty.And with the variation of hardware device and the variation of transmission means, when there is new transmission means, only need Increase the code module of new transmission means, reduce the design iterations amount of code.
On the basis of above-mentioned technical proposal, Fig. 2 is the Modbus protocol stack modules composition that the embodiment of the present invention one provides Schematic diagram, data transfer is completed between agreement framing module and transport module by calling interface, and this of host node device connects Mouth for example including:
int(*write_file)(struct ClientTransmitInstance*transmit,uint8_t* buffer,int length);
int(*read_file)(struct ClientTransmitInstance*transmit,uint8_t* buffer,int length);
void(*close)(struct ClientTransmitInstance*transmit)。
Wherein, Write is written document function name, and ClientTransmitInstance*transmit is input initial What the change stage created, uint8_t*buffer is the buffer pointers for needing to write, and intlength is write-in length length, Return is actually written into length, if writing failure, returns to -1.
Wherein, to read documentation function name, ClientTransmitInstance*transmit is being initialized read for input The transmit examples that stage creates, uint8_t*buffer are the buffer pointers for needing to read, and int length are reading Length length, actual read-out length is returned to, if reading failure, return to -1.
Wherein, close is release resource function.
In the present embodiment, the agreement framing module that host node device enables is after by transmitting message framing, by calling Write interfaces are stated, the buffer pointers write as needed and write-in length are put into the message after framing in caching buffer, Then the transport module that host node device enables calls above-mentioned read interfaces, and the buffer pointers read as needed and reading are grown Spend in caching buffer and extract the message after framing, the hardware of corresponding hardware is called further according to the host-host protocol of this module definition Driving, to drive the message after the hardware transmission framing, for example, the information of transmission means is com1 in configuration information, Host node device enables transport module corresponding to Serial Port Transmission, and the hardware driving of com1 ports is called according to Serial Port Transmission agreement, To drive com1 ports to realize, serial ports method and serial ports are received.Accordingly, the transport module that host node device enables is according to host-host protocol After calling the hardware driving of com1 ports to receive message, by calling above-mentioned write interfaces that the message of reception is put into caching In, the agreement framing module that then host node device enables is by calling above-mentioned read interfaces to extract the report of reception into caching Text, the message of reception is parsed further according to the analysis mode of this module definition.
On the basis of above-mentioned technical proposal, host node device is initialized in the initialization module of host node device With the initialization module from node device to being initialized from node device after, in addition to:When what is enabled from node device When agreement framing module obtains message to be transmitted, the framing from the agreement framing module that node device enables according to this module definition For mode by transmitting message framing, the message after framing includes purpose host node device address, and by being enabled from node device Transport module framing is sent to host node device according to the host-host protocol of this module definition after message;What host node device enabled After transport module receives the message after framing, the agreement framing module that host node device enables is sent to, host node device opens Agreement framing module parses the message after framing according to the analysis mode of this module definition.
As shown in Fig. 2 the Serial Port Transmission module that host node device enables is calling read interfaces to read framing from caching After message afterwards, the hardware corresponding to serial ports that is configured according to the transmission means of Serial Port Transmission protocol definition and when calling initialization Driving, message is sent to from node device.Equally, the Serial Port Transmission module that host node device enables is according to Serial Port Transmission agreement Hardware driving corresponding to the transmission means of definition and the serial ports configured when calling initialization, receives the report sent from node device Text, then, call write interfaces write-in caching.
As shown in Fig. 2 the GPRS transmission module that host node device enables is calling read interfaces to read framing from caching After message afterwards, corresponding to the GPRS module that is configured according to the transmission means of GPRS transmission protocol definition and when calling initialization Hardware driving, message is sent to from node device.Equally, the GPRS transmission module that host node device enables is according to Serial Port Transmission Hardware driving corresponding to the transmission means of protocol definition and the GPRS module configured when calling initialization, is received from node device The message of transmission, then, call write interfaces write-in caching.The transport module working method of other agreements is similar, no longer superfluous State.
In the present embodiment, the method for message and the method class of above-described embodiment are sent from node device to host node device Seemingly, here is omitted.
On the basis of above-mentioned technical proposal, in the agreement framing module enabled from node device according to this module definition Framing mode by before transmitting message framing, in addition to:Carry out autonomous node when the transport module enabled from node device listens to During the connection request of equipment, the transport module enabled from node device creates connection and hyphen with host node device Handle_ID, and handle_ID is informed to the agreement framing module enabled from node device;The agreement enabled from node device Framing module by handle_ID distinguish the message that receives from host node device, and by handle_ID to message From host node device send feedback message.When the transport module enabled from node device is determined between host node device During Joint failure, the resource of the transport module release connection enabled from node device will hyphen handle_ corresponding with connection ID is set to closing, and informs that the agreement framing module handle_ID enabled from node device is closed.
It can also include in the interface from node device between agreement framing module and transport module:
int(*accpet_connection)(struct ServerTransmitInstance*transmit);
Connection identifier handle_ID is distributed to new connection, inputs transmit examples, exports the handle_ID of distribution, If without new connection, -1 is returned.
void(*close_handle)(struct ServerTransmitInstance*transmit,inthandle_ ID);
Connection identifier handle_ID is set to closing, and input transmit examples are, it is necessary to the handle_ID closed.
Unlike host node device, need to monitor the instruction that multiple host node devices send from node device, when from , it is necessary to create and the host node device when transport module that node device enables listens to the connection request from host node device Connection, and by calling above-mentioned accpet_connection interfaces to create hyphen handle_ID;And work as from node device When the transport module enabled determines the Joint failure between host node device, the transport module release enabled from node device should The resource of connection, and by calling above-mentioned close_handle interfaces that handle_ID corresponding with the connection is set into closing.Phase Answer, the agreement framing module enabled from node device is before above-mentioned write interfaces or read interfaces is called by calling State accpet_connection interfaces and close_handle interfaces determine which current handle_ID is newly created, which is had A little handle_ID can be used and which handle_ID has been closed, the agreement framing mould so enabled from node device Block can is directed to the handle_ID that can be used and writes message into caching or extract message therefrom, due to Modbus nets In network, host node device have it is multiple, from node device respectively with each host node device establish connect, from node device need pass through Connection identifier handle_ID, which knows, to be received the message of main website from which connection and is known by connection identifier handle_ID In which connection response message is sent out to main website.Handle_ID can be multiplexed in the present embodiment, if for example, handle_ID=5 It is closed, then next time, if new connection, then the handle_ID for distributing to the connection may be exactly 5.As for reality Implication, for example, in tcp, it should be the socket of connection, then it is very possible different.Interface should shield this information, protocol groups Frame module should be not felt by this information.
Fig. 3 is the structural representation for the Modbus communication networks that the embodiment of the present invention two provides, including:Host node device 11 With from node device 12, wherein, each equipment includes multiple agreement framing modules and multiple transport modules, each agreement framing mould It is different that block defines the framing mode that a kind of framing mode of Modbus protocol types and each agreement framing module define, often It is different that individual transport module defines the host-host protocol that a kind of host-host protocol and each transport module define;Wherein, the main section Point device 11 is used for agreement framing module and the transport module for determining to enable according to configuration information by initialization module;It is described from Node device 12 is used for agreement framing module and the transport module for determining to enable according to configuration information by initialization module;It is described Host node device 11 is additionally operable to when the agreement framing module enabled by the host node device obtains message to be transmitted, The transmission is reported according to the framing mode of this module definition by the agreement framing module that the host node device enables Literary framing, the message after framing includes purpose from node device address, and the transmission enabled by the host node device Module according to the host-host protocol of this module definition to it is described from node device send framing after message;It is described from node device 12 After being additionally operable to receive the message after the framing from node device by the transport module enabled, send to described The agreement framing module enabled from node device, then pass through the agreement framing module root enabled from node device The message after the framing is parsed according to the analysis mode of this module definition.
It is described to be additionally operable to enable from node device when by described from node device 12 on the basis of above-mentioned technical proposal The agreement framing module obtain message to be transmitted when, pass through the agreement framing module root enabled from node device According to the framing mode of this module definition by the transmitting message framing, the message after framing includes purpose host node device address, And set by described from the transport module that node device enables according to the host-host protocol of this module definition to the host node Preparation send the message after the framing;The host node device 11 is additionally operable to the transmission enabled by the host node device After module receives the message after the framing, the agreement framing module that the host node device enables is sent to, then lead to Cross after the agreement framing module that the host node device enables parses the framing according to the analysis mode of this module definition Message.
On the basis of above-mentioned technical proposal, the Modbus that each equipment is used to be supported according to the Modbus communication networks is assisted Discuss type and create the multiple agreement framing module, and according to the host-host protocol establishment that the Modbus communication networks are supported Multiple transport modules, each equipment include the host node device 11 and described from node device 12.
It is described to be additionally operable to enable from node device when by described from node device 12 on the basis of above-mentioned technical proposal Transport module when listening to the connection request from host node device, pass through the biography enabled from node device The connection of defeated module creation and the host node device and hyphen handle_ID, and by the handle_ID inform it is described from The agreement framing module that node device enables;Institute is passed through by the agreement framing module enabled from node device State handle_ID distinguish the message that receives from host node device, and by the handle_ID to the message come From host node device send feedback message.
It is described to be additionally operable to enable from node device when by described from node device 12 on the basis of above-mentioned technical proposal The transport module determine and host node device between Joint failure when, pass through the biography enabled from node device Defeated module discharges the resource of the connection, and hyphen handle_ID corresponding with the connection is set into closing, and informs described Handle_ID described in the agreement framing module enabled from node device is closed.
On the basis of above-mentioned technical proposal, each equipment is used for the biography according to this module definition by the transport module enabled Defeated agreement calls the hardware driving of corresponding hardware, to drive the message after the hardware transmission framing, each equipment bag Include the host node device 11 and described from node device 12.
The Modbus communication networks that the embodiment of the present invention is provided can perform that any embodiment of the present invention provided The method of transmitting message in Modbus communication networks, possess the corresponding functional module of execution method and beneficial effect.
Fig. 4 is the structural representation for the equipment that the embodiment of the present invention three provides, as shown in figure 4, the equipment can be above-mentioned Host node device or include processor 20, memory 21, input unit 22 and output device from node device, the equipment 23;The quantity of processor 20 can be one or more in equipment, in Fig. 4 by taking a processor 20 as an example;Processing in equipment Device 20, memory 21, input unit 22 can be connected with output device 23 by bus or other modes, with by total in Fig. 4 Exemplified by line connection.
Memory 21 is used as a kind of computer-readable recording medium, and journey is can perform available for storage software program, computer Sequence and module, as corresponding to the method for transmitting message in Modbus communication networks in the embodiment of the present invention programmed instruction/ Module.Processor 20 is stored in software program, instruction and module in memory 21 by operation, so as to perform each of equipment Kind application of function and data processing, that is, the method for realizing the above-mentioned transmitting message in Modbus communication networks.
Memory 21 can mainly include storing program area and storage data field, wherein, storing program area can store operation system Application program needed for system, at least one function;Storage data field can store uses created data etc. according to terminal.This Outside, memory 21 can include high-speed random access memory, can also include nonvolatile memory, for example, at least a magnetic Disk storage device, flush memory device or other non-volatile solid state memory parts.In some instances, memory 21 can be further Including network connection to equipment can be passed through relative to the remotely located memory of processor 20, these remote memories.It is above-mentioned The example of network includes but is not limited to internet, intranet, LAN, mobile radio communication and combinations thereof.
Input unit 22 can be used for the numeral or character information for receiving input, and produce set with the user of equipment and The relevant key signals input of function control.Output device 23 may include the display devices such as display screen.
The embodiment of the present invention four also provides a kind of computer-readable recording medium, and the storage medium may be disposed at above-mentioned main section Point device or from node device, is stored thereon with computer program, is used to perform one kind when the program is executed by processor The method of transmitting message in Modbus communication networks, this method is as described in above-mentioned embodiment of the method, and here is omitted.
Certainly, a kind of computer-readable recording medium that the embodiment of the present invention is provided, its computer executable instructions is not It is limited to method as described above operation, can also carry out that any embodiment of the present invention provided passes in Modbus communication networks Associative operation in the method for defeated message.
By the description above with respect to embodiment, it is apparent to those skilled in the art that, the present invention Embodiment can be realized by software and required common hardware, naturally it is also possible to realized by hardware, but in many cases before Person is more preferably embodiment.Based on such understanding, the technical scheme of the embodiment of the present invention is substantially in other words to existing skill The part that art contributes can be embodied in the form of software product, and the computer software product can be stored in computer In readable storage medium storing program for executing, floppy disk, read-only storage (Read-Only Memory, ROM), random access memory such as computer (Random Access Memory, RAM), flash memory (FLASH), hard disk or CD etc., including some instructions are causing one Computer equipment (can be personal computer, server, or network equipment etc.) performs each embodiment of the embodiment of the present invention Described method.
It is worth noting that, in the embodiment of above-mentioned Modbus communication networks, included unit and module are Divided according to function logic, but be not limited to above-mentioned division, as long as corresponding function can be realized;Separately Outside, the specific name of each functional unit is also only to facilitate mutually differentiation, is not intended to limit the invention the protection of embodiment Scope.
Pay attention to, above are only preferred embodiment and the institute's application technology principle of the embodiment of the present invention.Those skilled in the art It will be appreciated that the embodiment of the present invention is not limited to specific embodiment described here, can carry out for a person skilled in the art each The protection domain that kind significantly changes, readjusts and substituted without departing from the embodiment of the present invention.Therefore, although passing through the above Embodiment is described in further detail to the embodiment of the present invention, but the embodiment of the present invention is not limited only to above implementation Example, in the case where not departing from design of the embodiment of the present invention, other more equivalent embodiments can also be included, and the present invention is implemented The scope of example is determined by scope of the appended claims.

Claims (14)

  1. A kind of 1. method of the transmitting message in Modbus communication networks, it is characterised in that including:
    The initialization module of host node device determines to open in the host node device according to the configuration information of the host node device Agreement framing module and transport module, and from the initialization module of node device according to the configuration from node device The agreement framing module enabled described in information determination from node device, wherein, each equipment includes multiple agreement framing modules With multiple transport modules, each agreement framing module defines a kind of framing mode of Modbus protocol types and each agreement framing The framing mode of module definition is different, and each transport module defines the biography that a kind of host-host protocol and each transport module define Defeated agreement is different;
    When the agreement framing module that the host node device enables obtains message to be transmitted, the host node device enables The agreement framing module according to the framing mode of this module definition by the transmitting message framing, the message after framing includes Purpose is from node device address, and the transmission by the transport module that the host node device enables according to this module definition Agreement to it is described from node device send the framing after message;
    After the transport module enabled from node device receives the message after the framing, send to described from node The agreement framing module that equipment enables, the agreement framing module enabled from node device is according to this module definition Analysis mode parse the message after the framing.
  2. 2. according to the method for claim 1, it is characterised in that the host node device initialization module to the master Node device carries out initialization and the initialization module from node device to described after node device initializes, Also include:
    It is described to be enabled from node device when the agreement framing module enabled from node device obtains message to be transmitted The agreement framing module according to the framing mode of this module definition by the transmitting message framing, the message after framing includes Purpose host node device address, and pass through the transmission from the transport module that node device enables according to this module definition Agreement send the framing to the host node device after message;
    After the transport module that the host node device enables receives the message after the framing, the host node is sent to The agreement framing module that equipment enables, the agreement framing module that the host node device enables is according to this module definition Analysis mode parse the message after the framing.
  3. 3. method according to claim 1 or 2, it is characterised in that the host node device initialization module to institute State host node device carry out initialization and the initialization module from node device initialized to described from node device Before, in addition to:
    The Modbus protocol types supported in each equipment according to the Modbus communication networks create the multiple agreement framing Module, and the host-host protocol supported according to the Modbus communication networks creates the multiple transport module, each equipment bag Include the host node device and described from node device.
  4. 4. according to the method for claim 2, it is characterised in that in the agreement framing mould enabled from node device Root tuber according to the framing mode of this module definition by before the transmitting message framing, in addition to:
    When the transport module enabled from node device listens to the connection request from host node device, it is described from The transport module that node device enables creates the connection and hyphen handle_ID with the host node device, and by institute State handle_ID and inform the agreement framing module enabled from node device;
    The message received from the agreement framing module that node device enables by handle_ID differentiations comes from Host node device, and by the handle_ID to the message from host node device send feedback message.
  5. 5. according to the method for claim 4, it is characterised in that methods described also includes:
    When the transport module that is enabled from node device determines the Joint failure between host node device, it is described from The transport module that node device enables discharges the resource of the connection, will hyphen handle_ corresponding with the connection ID is set to closing, and informs that handle_ID described in the agreement framing module enabled from node device is closed.
  6. 6. method according to claim 1 or 2, it is characterised in that the transport module enabled is according to the biography of this module definition Defeated agreement sends the message after the framing, including:
    The transport module enabled calls the hardware driving of corresponding hardware according to the host-host protocol of this module definition, to drive State hardware and send the message after the framing.
  7. A kind of 7. Modbus communication networks, it is characterised in that including:Host node device and from node device, wherein, in each equipment Including multiple agreement framing modules and multiple transport modules, each agreement framing module defines a kind of group of Modbus protocol types The framing mode that frame mode and each agreement framing module define is different, each transport module define a kind of host-host protocol and The host-host protocol that each transport module defines is different;
    Wherein, the host node device be used for by initialization module according to configuration information determine the agreement framing module that enables and Transport module;
    Agreement framing module and the transmission for being used to determine to enable according to configuration information by initialization module from node device Module;
    The host node device is additionally operable to when the agreement framing module acquisition enabled by the host node device is to be transmitted During message, by the agreement framing module that the host node device enables according to inciting somebody to action the framing mode of this module definition Transmitting message framing, the message after framing includes purpose from node device address, and the institute enabled by the host node device State transport module according to the host-host protocol of this module definition to it is described from node device send framing after message;
    It is described to be additionally operable to from node device after receiving the framing by the transport module enabled from node device Message after, send the agreement framing module enabled from node device to, then enabled from node device by described The agreement framing module message after the framing is parsed according to the analysis mode of this module definition.
  8. 8. Modbus communication networks according to claim 7, it is characterised in that described to be additionally operable to pass through from node device When the agreement framing module that is enabled from node device obtains message to be transmitted, enabled by described from node device For the agreement framing module according to the framing mode of this module definition by the transmitting message framing, the message after framing includes mesh Host node device address, and by it is described from the transport module that node device enables according to the transmission of this module definition assist Discuss the message after sending the framing to the host node device;
    After the transport module that the host node device is additionally operable to enable by the host node device receives the framing Message after, send the agreement framing module that the host node device enables to, then enable by the host node device The agreement framing module message after the framing is parsed according to the analysis mode of this module definition.
  9. 9. the Modbus communication networks according to claim 7 or 8, it is characterised in that each equipment is used for according to The Modbus protocol types that Modbus communication networks are supported create the multiple agreement framing module, and are led to according to the Modbus The host-host protocol that communication network is supported creates the multiple transport module, each equipment include the host node device and it is described from Node device.
  10. 10. Modbus communication networks according to claim 8, it is characterised in that described to be additionally operable to from node device when logical When crossing the transport module enabled from node device and listening to the connection request from host node device, by it is described from The transport module that node device enables creates the connection and hyphen handle_ID with the host node device, and by institute State handle_ID and inform the agreement framing module enabled from node device;Enabled by described from node device The agreement framing module by the handle_ID distinguish the message that receives from host node device, and pass through institute State handle_ID to the message from host node device send feedback message.
  11. 11. Modbus communication networks according to claim 10, it is characterised in that described to be additionally operable to from node device when logical When crossing the transport module that is enabled from node device and determining the Joint failure between host node device, by it is described from The transport module that node device enables discharges the resource of the connection, will hyphen handle_ corresponding with the connection ID is set to closing, and informs that handle_ID described in the agreement framing module enabled from node device is closed.
  12. 12. the Modbus communication networks according to claim 7 or 8, it is characterised in that each equipment is used for the biography by enabling Defeated module calls the hardware driving of corresponding hardware according to the host-host protocol of this module definition, to drive the hardware to send described group Message after frame, each equipment include the host node device and described from node device.
  13. 13. a kind of equipment, it is characterised in that the equipment includes:
    One or more processors;
    Storage device, for storing one or more programs;
    When one or more of programs are by one or more of computing devices so that one or more of processors are real Now the host node device as described in any in claim 1-6 or report is transmitted in Modbus communication networks from node device The method of text.
  14. 14. a kind of computer-readable recording medium, is stored thereon with computer program, it is characterised in that the program is by processor Host node device as described in any in claim 1-6 is realized during execution or from node device in Modbus communication networks The method of middle transmitting message.
CN201711483731.6A 2017-12-29 2017-12-29 Method for transmitting message in Modbus communication network, Modbus communication network system and Modbus communication network equipment Active CN107896234B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201711483731.6A CN107896234B (en) 2017-12-29 2017-12-29 Method for transmitting message in Modbus communication network, Modbus communication network system and Modbus communication network equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201711483731.6A CN107896234B (en) 2017-12-29 2017-12-29 Method for transmitting message in Modbus communication network, Modbus communication network system and Modbus communication network equipment

Publications (2)

Publication Number Publication Date
CN107896234A true CN107896234A (en) 2018-04-10
CN107896234B CN107896234B (en) 2020-06-16

Family

ID=61808869

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201711483731.6A Active CN107896234B (en) 2017-12-29 2017-12-29 Method for transmitting message in Modbus communication network, Modbus communication network system and Modbus communication network equipment

Country Status (1)

Country Link
CN (1) CN107896234B (en)

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102612170A (en) * 2012-03-21 2012-07-25 复旦大学 Internet of Things logistics communication system based on master-slave node mode
US8260872B1 (en) * 2011-03-29 2012-09-04 Data Flow Systems, Inc. Modbus simulation system and associated transfer methods
CN103543721A (en) * 2013-10-18 2014-01-29 国家电网公司 Microgrid hierarchical control system modeling method meeting IEC61850 standard
CN103645714A (en) * 2013-12-11 2014-03-19 东方电气集团东方汽轮机有限公司 Method for realizing MODBUS asynchronous serial communication protocol by using DSP
EP2541846B1 (en) * 2011-06-27 2015-09-23 LSIS Co., Ltd. Communication method of gateway device supporting CAN - and Modbus protocol conversion and gateway device using the same
CN105577482A (en) * 2016-02-04 2016-05-11 北京安控科技股份有限公司 Slave intelligent module network accessing method based on Modbus RTU communication protocol
US20160328352A1 (en) * 2012-05-07 2016-11-10 Bristol, Inc. D/B/A Remote Automation Solutions Methods and apparatus to identify a communication protocol being used in a process control system

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8260872B1 (en) * 2011-03-29 2012-09-04 Data Flow Systems, Inc. Modbus simulation system and associated transfer methods
EP2541846B1 (en) * 2011-06-27 2015-09-23 LSIS Co., Ltd. Communication method of gateway device supporting CAN - and Modbus protocol conversion and gateway device using the same
CN102612170A (en) * 2012-03-21 2012-07-25 复旦大学 Internet of Things logistics communication system based on master-slave node mode
US20160328352A1 (en) * 2012-05-07 2016-11-10 Bristol, Inc. D/B/A Remote Automation Solutions Methods and apparatus to identify a communication protocol being used in a process control system
CN103543721A (en) * 2013-10-18 2014-01-29 国家电网公司 Microgrid hierarchical control system modeling method meeting IEC61850 standard
CN103645714A (en) * 2013-12-11 2014-03-19 东方电气集团东方汽轮机有限公司 Method for realizing MODBUS asynchronous serial communication protocol by using DSP
CN105577482A (en) * 2016-02-04 2016-05-11 北京安控科技股份有限公司 Slave intelligent module network accessing method based on Modbus RTU communication protocol

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
职燕等: "《Modbus通信协议在现场总线控制系统中的应用》", 《兰州大学学报》 *
胡能辉: "《Modbus通信协议自动测试系统的研究与开发》", 《 中国优秀硕士学位论文全文数据库 信息科技辑》 *

Also Published As

Publication number Publication date
CN107896234B (en) 2020-06-16

Similar Documents

Publication Publication Date Title
CN102334112B (en) Method and system for virtual machine networking
CN103178996B (en) Distributed packet-switching chip model verification system and method
US9755963B2 (en) Using headerspace analysis to identify flow entry reachability
CN104967585B (en) A kind of method and apparatus of remote debugging mobile terminal
CN104426680B (en) Data transmission method, device and system
CN109088820B (en) Cross-device link aggregation method and device, computing device and storage medium
US10050859B2 (en) Apparatus for processing network packet using service function chaining and method for controlling the same
CN103004158A (en) Network device with a programmable core
CN109218229A (en) A kind of message processing method, the network equipment and storage medium
CN108306804A (en) A kind of Ethercat main station controllers and its communication means and system
CN107404436A (en) Communication means and device for virtual expansible LAN
WO2022032984A1 (en) Mqtt protocol simulation method and simulation device
CN101257457A (en) Method for network processor to copy packet and network processor
JP2010531602A (en) Method and apparatus for communication of diagnostic data in a real-time communication network
CN104184645B (en) A kind of method, equipment and system for generating operation requests
CN107222458A (en) A kind of data processing method and system of the BACnet protocol stacks of compatible Modbus agreements
CN103501282B (en) Network message sending control method, virtual switch and physical machine
CN105591872B (en) A kind of method and apparatus for realizing multiple data centers interconnection
CN114513404B (en) Method and device for configuring time-sensitive network and computer-readable storage medium
Galal et al. SDN-based gateway architecture for electromagnetic nano-networks
CN109936566A (en) A kind of data transmission method system, device and computer readable storage medium
CN107332793A (en) A kind of message forwarding method, relevant device and system
CN108512737B (en) Data center IP layer interconnection method and SDN controller
CN107896234A (en) The method of transmitting message, Modbus communication networks and equipment in Modbus communication networks
CN105335217B (en) A kind of server silence method and system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
EE01 Entry into force of recordation of patent licensing contract

Application publication date: 20180410

Assignee: Kedong (Guangzhou) Software Technology Co., Ltd

Assignor: Beijing Dongtu Technology Co., Ltd.|Beijing keyin Jingcheng Technology Co., Ltd

Contract record no.: X2020980000255

Denomination of invention: Method for transmitting message in Modbus communication network, Modbus communication network and equipment

License type: Exclusive License

Record date: 20200218

EE01 Entry into force of recordation of patent licensing contract
GR01 Patent grant
GR01 Patent grant