[go: up one dir, main page]

CN100493079C - Method for main node supporting different agreement type secondary unit apparatus on secondary node - Google Patents

Method for main node supporting different agreement type secondary unit apparatus on secondary node Download PDF

Info

Publication number
CN100493079C
CN100493079C CNB2004100001744A CN200410000174A CN100493079C CN 100493079 C CN100493079 C CN 100493079C CN B2004100001744 A CNB2004100001744 A CN B2004100001744A CN 200410000174 A CN200410000174 A CN 200410000174A CN 100493079 C CN100493079 C CN 100493079C
Authority
CN
China
Prior art keywords
message content
message
node
content key
mask
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.)
Expired - Fee Related
Application number
CNB2004100001744A
Other languages
Chinese (zh)
Other versions
CN1642167A (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.)
Huawei Technologies Co Ltd
Original Assignee
Huawei Technologies 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 Huawei Technologies Co Ltd filed Critical Huawei Technologies Co Ltd
Priority to CNB2004100001744A priority Critical patent/CN100493079C/en
Publication of CN1642167A publication Critical patent/CN1642167A/en
Application granted granted Critical
Publication of CN100493079C publication Critical patent/CN100493079C/en
Anticipated expiration legal-status Critical
Expired - Fee Related legal-status Critical Current

Links

Images

Landscapes

  • Small-Scale Networks (AREA)

Abstract

本发明公开了主节点支持从节点上不同协议类型从单元设备的方法,在主从通信协议中,预先设定各个协议类型从单元设备的报文内容键值和报文内容掩码,并建立同一协议类型从单元设备的报文内容掩码、报文内容键值与上层应用程序的对应关系,该方法包括以下步骤:主节点接收到从节点发来的报文后,逐一选取未选用过的一个协议类型的报文内容掩码,并通过选取的报文内容掩码获得报文内容键值;将获得的报文内容键值与所述协议类型的报文内容键值进行比较,若相同,则选取所述协议类型的报文内容键值对应的上层应用程序,若不相同,则将从节点报文丢弃。本发明方法实现了对不同协议类型从单元设备的支持,并且能够灵活适应从节点上不同协议类型从单元设备的改变和增减。

Figure 200410000174

The invention discloses a method for a master node to support slave unit devices of different protocol types on a slave node. In the master-slave communication protocol, the message content key value and message content mask of each protocol type slave unit device are preset, and the The corresponding relationship between the message content mask of the slave unit device of the same protocol type, the key value of the message content and the upper layer application program, the method includes the following steps: After the master node receives the message sent from the slave node, it selects the unselected A message content mask of a protocol type, and obtain the message content key value by the selected message content mask; compare the obtained message content key value with the message content key value of the protocol type, if If they are the same, then select the upper-layer application program corresponding to the message content key value of the protocol type, and if not, discard the slave node message. The method of the invention realizes the support to the slave unit devices of different protocol types, and can flexibly adapt to the change and increase or decrease of the slave unit devices of different protocol types on the slave node.

Figure 200410000174

Description

主节点支持从节点上不同协议类型从单元设备的方法 The master node supports the method of slave unit devices of different protocol types on the slave node

技术领域 technical field

本发明涉及一种通信协议技术,特别是涉及主节点支持从节点上不同协议类型从单元设备的方法。The invention relates to a communication protocol technology, in particular to a method for a master node to support slave unit devices of different protocol types on the slave node.

背景技术 Background technique

完成特定功能的系统一般由多个具有相对独立功能的子系统单元组合构成,这些子系统单元在系统中的地位是不同的,一般有一个居于主要地位的主单元和多个居于从属地位的从单元。主单元是系统中居于控制地位的子系统,完成系统的主要功能,并控制其它子系统;从单元是系统中居于被控制地位的子系统,完成系统的辅助功能,并接受主单元的控制。A system that completes a specific function is generally composed of a plurality of subsystem units with relatively independent functions. unit. The master unit is the subsystem in the control position in the system, which completes the main functions of the system and controls other subsystems; the slave unit is the subsystem in the controlled position in the system, completes the auxiliary functions of the system, and accepts the control of the master unit.

图1是主、从节点的关系示意图。参见图1,一般系统中有一个主节点和一个或者多个从节点,主节点和从节点之间通过通信通道相互联系,并通过主从通信协议进行通信,通信通道时分复用。Figure 1 is a schematic diagram of the relationship between master and slave nodes. Referring to Figure 1, a general system has a master node and one or more slave nodes. The master node and the slave nodes communicate with each other through a communication channel, and communicate through a master-slave communication protocol, and the communication channel is time-division multiplexed.

主从通信协议是系统中主单元设备和从单元设备相互通信时遵从的通信协议。在主从通信协议中,主单元对应主节点概念,从单元对应从节点概念,节点是逻辑概念,而单元是物理概念,是指完成特定功能的子系统。The master-slave communication protocol is the communication protocol that the master unit device and the slave unit device in the system follow when they communicate with each other. In the master-slave communication protocol, the master unit corresponds to the concept of the master node, the slave unit corresponds to the concept of the slave node, the node is a logical concept, and the unit is a physical concept, which refers to a subsystem that completes a specific function.

系统中存在不同类型的从单元设备,从单元设备类型不同不是指从单元设备的功能不同,而是指从单元设备和主单元设备进行报文交互时所遵从的协议类型不同,以及和这些协议相对应的不同的上层应用程序。There are different types of slave unit devices in the system. The different types of slave unit devices do not mean that the functions of the slave unit devices are different, but that the protocol types that the slave unit devices and the master unit devices follow when exchanging messages are different, and that they are different from these protocols. Corresponding to different upper-level applications.

在现有的主从通信协议中,主节点通过从节点标识来识别遵从不同协议类型的从单元设备,进而找到从节点上从单元设备的上层应用程序,完成对从单元设备的支持。In the existing master-slave communication protocol, the master node identifies slave unit devices that comply with different protocol types through the slave node identifier, and then finds the upper layer application program of the slave unit device on the slave node to complete the support for the slave unit device.

现有技术实现主节点支持从节点上不同协议类型从单元设备的方法为:The existing technology realizes that the master node supports slave unit devices of different protocol types on the slave node as follows:

方法一:设定从节点号与协议类型的对应关系,主节点通过从节点号识别遵从不同协议类型的从单元设备。设备的从节点号由硬件决定,每个设备上都有拨码开关,通过拨码开关设定设备的从节点号。例如有遵从不同协议类型的从单元设备A与从单元设备B,设定设备A遵从的协议类型一对应的从节点号为1,那么在安装设备A的时候,将设备A的拨码开关拨到1的位置,当设备A所在的从节点1向主节点发送报文后,主节点通过报文中的从节点号1识别设备A,并找到设备A的上层应用程序,完成对设备A的支持。Method 1: Set the corresponding relationship between the slave node number and the protocol type, and the master node identifies the slave unit devices that comply with different protocol types through the slave node number. The slave node number of the device is determined by the hardware, each device has a dial switch, and the slave node number of the device is set through the dial switch. For example, if there are slave unit device A and slave unit device B that comply with different protocol types, set the slave node number corresponding to the protocol type that device A complies with to 1, then when installing device A, dial the DIP switch of device A To the position of 1, when the slave node 1 where device A is located sends a message to the master node, the master node identifies device A through the slave node number 1 in the message, and finds the upper layer application program of device A, and completes the device A support.

如果设备A的拨码开关没有拨到1的位置,即设备A的从节点号与设备A遵从的协议类型一不存在对应关系,那么设备A不会被支持;如果将遵从协议类型二的设备B的拨码开关拨到1的位置,因为设备B遵从的协议类型二与从节点号1不存在对应关系,那么设备B不会被支持。可见,在这种方法中,从节点号和协议类型的对应关系是固定的,所以,当设备所拨的从节点号与该设备所遵从协议对应的从节点号不存在对应关系时,该设备不会被支持。If the DIP switch of device A is not dialed to the 1 position, that is, there is no corresponding relationship between the slave node number of device A and the protocol type 1 that device A complies with, then device A will not be supported; if the device that complies with protocol type 2 The DIP switch of B is turned to the 1 position, because there is no corresponding relationship between the protocol type 2 complied with by the device B and the slave node number 1, then the device B will not be supported. It can be seen that in this method, the corresponding relationship between the slave node number and the protocol type is fixed, so when there is no corresponding relationship between the slave node number dialed by the device and the slave node number corresponding to the protocol that the device complies with, the device will not be supported.

方法二:设定从节点波特率与协议类型的对应关系,主节点通过从节点波特率识别遵从不同协议类型的从单元设备。例如有遵从不同协议类型的从单元设备A与设备B,设定设备A遵从的协议类型一对应的从节点波特率为15000,当设备A所在的从节点向主节点发送报文后,主节点通过该从节点的波特率15000识别出设备A,并找到设备A的上层应用程序,完成对设备A的支持。Method 2: Set the corresponding relationship between the baud rate of the slave node and the protocol type, and the master node identifies slave unit devices that comply with different protocol types through the baud rate of the slave node. For example, there are slave unit device A and device B that comply with different protocol types. Set the baud rate of the slave node corresponding to the protocol type that device A complies with to 15000. When the slave node where device A is located sends a message to the master node, the master node The node recognizes device A through the slave node's baud rate of 15000, and finds the upper layer application program of device A to complete the support for device A.

如果在实际传输时,设备A的波特率为9600,即设备A的从节点波特率与设备A遵从的协议类型一不存在对应关系,那么设备A不会被支持;如果遵从协议类型二的设备B的传输波特率为15000,因为设备B遵从的协议类型二与从节点波特率15000之间不存在对应关系,那么设备B不会被支持。可见,在这种方法中,从节点波特率与协议类型的对应关系是固定的,所以,当某设备的实际传输波特率与该设备所遵从协议对应的从节点波特率不存在对应关系时,该设备不会被支持。可见,在现有的主从通信协议中,主节点通过从节点标识实现对不同协议类型从单元设备的支持。但是,由于从节点标识与协议类型的对应关系是固定的,所以当从节点的实际标识与协议类型不存在对应关系时,主节点不能支持从节点上的从单元设备,从而导致主节点对从单元设备的支持率低,无法适应从单元设备的改变和扩展。If in actual transmission, the baud rate of device A is 9600, that is, there is no correspondence between the baud rate of device A’s slave node and the protocol type 1 that device A complies with, then device A will not be supported; if it complies with protocol type 2 The transmission baud rate of device B is 15000, because there is no corresponding relationship between the protocol type 2 complied with by device B and the slave node baud rate of 15000, then device B will not be supported. It can be seen that in this method, the corresponding relationship between the slave node baud rate and the protocol type is fixed, so when the actual transmission baud rate of a certain device does not correspond to the slave node baud rate corresponding to the protocol complied with by the device relationship, the device will not be supported. It can be seen that in the existing master-slave communication protocol, the master node implements support for slave unit devices of different protocol types through the slave node identifier. However, since the corresponding relationship between the slave node ID and the protocol type is fixed, when there is no corresponding relationship between the actual ID of the slave node and the protocol type, the master node cannot support the slave unit device on the slave node, which causes the master node to The support rate of the unit device is low, and it cannot adapt to the change and expansion of the unit device.

可见,在现有技术中,即使从单元设备所遵从的协议类型没有改变,但只要从节点标识改变,就会导致主节点无法支持从节点上从单元设备。It can be seen that in the prior art, even if the protocol type complied with by the slave unit device does not change, as long as the slave node identifier changes, the master node cannot support the slave unit device on the slave node.

并且,在主从通信协议中,主节点与从节点进行报文交互的过程分作主节点侧和从节点侧两个部分,主节点侧和从节点侧分别维护着一个状态机,通过状态机完成报文的发送和接收。Moreover, in the master-slave communication protocol, the process of message interaction between the master node and the slave node is divided into two parts: the master node side and the slave node side. The master node side and the slave node side maintain a state machine respectively. Through the state machine Complete message sending and receiving.

图2是主节点的主从通信状态机示意图。参见图2,现有的主从通信协议中,主节点状态机共有五个状态,其中,空闲状态201是数据发送和接收流程公用的状态;等待查询应答状态202和等待接收数据状态203用于数据接收流程;等待传输应答状态204和等待接收应答状态205用于数据发送流程。主节点状态机的普通状态为空闲状态201,空闲状态201具有周期属性,该周期属性有两个值:查询周期和传输周期。Fig. 2 is a schematic diagram of a master-slave communication state machine of a master node. Referring to Fig. 2, in the existing master-slave communication protocol, the master node state machine has five states in total, wherein, the idle state 201 is a state common to the data sending and receiving process; the waiting query response state 202 and the waiting data receiving state 203 are used for Data receiving process; waiting for transmission response state 204 and waiting for receiving response state 205 are used for data sending process. The common state of the state machine of the master node is the idle state 201, and the idle state 201 has a cycle attribute, and the cycle attribute has two values: query cycle and transmission cycle.

在现有的主节点报文接收流程中,主节点在空闲状态201的查询周期向从节点发送查询命令;在等待查询应答状态202接收从节点发回的查询应答;在等待接收数据状态203中接收从节点发来的数据报文。In the existing master node message receiving process, the master node sends a query command to the slave node in the query cycle of the idle state 201; in the waiting query response state 202, it receives the query response sent back from the slave node; in the waiting to receive data state 203 Receive data packets sent from the node.

在现有的主节点报文发送流程中,主节点在空闲状态201的传输周期向从节点发送传输命令;在等待传输应答状态204中向从节点发送数据报文;在等待接收应答状态205中接收从节点发来的接收报文应答。In the existing master node message sending process, the master node sends a transmission command to the slave node in the transmission cycle of the idle state 201; sends a data message to the slave node in the waiting transmission response state 204; Receive the received message response from the slave node.

图3是从节点的主从通信状态机示意图。参见图3,现有的主从通信协议中,从节点状态机共有四个状态,其中,等待命令状态301是数据发送和接收流程公用的状态;等待接收命令状态302和等待接收应答状态303用于数据发送流程;等待接收数据状态304用于数据接收流程。从节点状态机的普通状态为等待命令状态301,等待命令状态301具有周期属性,其周期属性与主节点状态机的空闲状态201的周期属性相反。Fig. 3 is a schematic diagram of a master-slave communication state machine of a slave node. Referring to Fig. 3, in the existing master-slave communication protocol, the slave node state machine has four states in total, wherein, the waiting command state 301 is the common state of data sending and receiving flow; the waiting receiving command state 302 and waiting receiving response state 303 are used in the data sending process; the waiting to receive data state 304 is used in the data receiving process. The general state of the slave node state machine is the waiting command state 301, and the waiting command state 301 has a periodic attribute, which is opposite to that of the idle state 201 of the master node state machine.

在现有的从节点报文发送流程中,从节点在等待命令状态301向主节点发送查询应答;在等待接收命令状态302中向主节点发送数据报文;在等待接收应答状态303中接收主节点发来的接收报文应答。In the existing slave node message sending process, the slave node sends a query response to the master node in the waiting command state 301; sends a data message to the master node in the waiting to receive command state 302; Response to received message from the node.

在现有的从节点报文接收中,从节点在等待命令状态301接收到主节点的传输命令;在等待接收数据状态304中接收主节点发来的数据报文。In the existing message reception of the slave node, the slave node receives the transmission command of the master node in the waiting command state 301 ; and receives the data message sent by the master node in the waiting data receiving state 304 .

发明内容 Contents of the invention

有鉴于此,本发明的目的在于提供主节点支持从节点上不同协议类型从单元设备的方法,通过从单元设备所遵从的协议类型,使主节点查找到从单元设备的上层应用程序。In view of this, the object of the present invention is to provide a method for the master node to support slave unit devices of different protocol types on the slave node, so that the master node can find the upper layer application program of the slave unit device through the protocol type that the slave unit device complies with.

为了达到上述目的,本发明的技术方案是这样实现的:In order to achieve the above object, the technical solution of the present invention is achieved in that:

主节点支持从节点上不同协议类型从单元设备的方法,预先在主从通信协议中设定各协议类型从单元设备的报文内容键值和报文内容掩码,并建立同一协议类型从单元设备的报文内容掩码、报文内容键值和上层应用程序三者之间的对应关系,该方法包括以下步骤:The master node supports the method of slave unit devices of different protocol types on the slave node, pre-set the message content key value and message content mask of each protocol type slave unit device in the master-slave communication protocol, and establish the same protocol type slave unit The corresponding relationship between the message content mask of the device, the key value of the message content and the upper layer application program, the method includes the following steps:

A、主节点接收从节点发来的报文;A. The master node receives the message sent by the slave node;

B、选取未选用过的一个协议类型的报文内容掩码,并通过选取的报文内容掩码获得报文中的报文内容键值;B. Select the message content mask of a protocol type that has not been selected, and obtain the message content key value in the message by the selected message content mask;

C、将获得的报文内容键值与步骤B所述协议类型的报文内容键值进行比较,如果获得的报文内容键值与步骤B所述协议类型的报文内容键值相同,则执行步骤E,如果获得的报文内容键值与步骤B所述协议类型的报文内容键值不同,且存在未被选用过的报文内容掩码,则返回步骤B,如果获得的报文内容键值与步骤B所述协议类型的报文内容键值不同,且所有协议类型的报文内容掩码均被选用过,则执行步骤D;C. Comparing the obtained message content key value with the message content key value of the protocol type described in step B, if the obtained message content key value is the same as the message content key value of the protocol type described in step B, then Execute step E, if the obtained message content key value is different from the message content key value of the protocol type described in step B, and there is a message content mask that has not been selected, return to step B, if the obtained message The content key value is different from the message content key value of the protocol type described in step B, and the message content masks of all protocol types have been selected, then step D is performed;

D、主节点将报文丢弃,提示告警信息,并结束本流程;D. The master node discards the message, prompts an alarm message, and ends the process;

E、选取步骤B所述协议类型的报文内容键值对应的上层应用程序为从节点上从单元设备的上层应用程序。E. Select the upper-layer application program corresponding to the message content key value of the protocol type described in step B as the upper-layer application program of the slave unit device on the slave node.

所述设定报文内容键值的步骤包括:设定报文中能够唯一标识从单元设备与主单元设备通信时所遵从协议类型的报文内容为该协议类型的报文内容键值。The step of setting the message content key includes: setting the message content in the message that can uniquely identify the protocol type that the slave unit device complies with when communicating with the master unit device as the message content key value of the protocol type.

所述设定报文内容掩码的步骤包括:设定报文内容掩码由地址偏移量和掩码值组成,并根据报文内容键值设定报文内容掩码的地址偏移量和掩码值。The step of setting the message content mask includes: setting the message content mask to be composed of an address offset and a mask value, and setting the address offset of the message content mask according to the message content key value and mask values.

所述根据报文内容键值设定报文内容掩码的地址偏移量的步骤包括:设定报文内容掩码的地址偏移量为报文内容键值在报文中所处的字节位减一。The step of setting the address offset of the message content mask according to the message content key value includes: setting the address offset of the message content mask as the word where the message content key value is located in the message Node minus one.

所述根据报文内容键值设定报文内容掩码的掩码值的步骤包括:设定掩码值的字节数为报文内容键值的字节数,并设定掩码值的各个字节位为十六进制的全一值。The step of setting the mask value of the message content mask according to the message content key value includes: setting the number of bytes of the mask value as the number of bytes of the message content key value, and setting the number of bytes of the mask value Each byte bit is an all-ones value in hexadecimal.

步骤B所述通过选取的报文内容掩码获得报文中的报文内容键值的步骤包括:将用于确定报文内容键值的指针进行偏移,指针的偏移量为报文内容掩码中地址偏移量的值,然后选取指针所指字节位为当前报文中报文内容键值的起始位,并选取报文内容掩码中掩码值的字节位数为当前报文中报文内容键值的字节位数,然后将选取的报文内容键值与报文内容掩码的掩码值相与,获得报文中的报文内容键值。The step of obtaining the message content key value in the message by the message content mask described in step B includes: offsetting the pointer for determining the message content key value, and the offset of the pointer is the message content The value of the address offset in the mask, and then select the byte pointed by the pointer as the start bit of the message content key value in the current message, and select the byte number of the mask value in the message content mask as The number of bytes of the message content key value in the current message, and the selected message content key value and the mask value of the message content mask to obtain the message content key value in the message.

该方法进一步包括:主节点在所述步骤A接收到从节点发来的报文后,先查找报文中的从节点号,并判断是否有该从节点号的保存记录,如果没有该从节点号的保存记录,则将该报文作为首报文,并保存该首报文中的从节点号,再进行所述步骤B至步骤E,然后建立保存的首报文从节点号与所述步骤E选取的上层应用程序的对应关系,如果有该从节点号的保存记录,则不进行所述步骤B至步骤E,直接选取与该从节点号对应的上层应用程序。The method further includes: after the master node receives the message from the slave node in the step A, it first searches for the slave node number in the message, and judges whether there is a record of the slave node number, if there is no record of the slave node number, then use the message as the first message, and save the slave node number in the first message, then carry out the steps B to E, and then set up the saved first message slave node number and the If there is a record of the slave node number corresponding to the upper-layer application program selected in step E, the upper-layer application program corresponding to the slave node number is directly selected without performing steps B to E.

所述步骤A包括以下步骤:Described step A comprises the following steps:

a、主节点在空闲状态的查询周期中向从节点发送查询命令,然后迁移到等待查询应答状态;a. The master node sends a query command to the slave node during the query period of the idle state, and then migrates to the state of waiting for the query response;

b、从节点在等待命令状态接收到主节点发来的查询命令,并且有数据报文,则向主节点发送该数据报文,然后迁移到等待接收应答状态;b. The slave node receives the query command from the master node in the state of waiting for commands, and if there is a data message, it sends the data message to the master node, and then transitions to the state of waiting to receive a response;

c、主节点在等待查询应答状态中,如果接收到错误的数据报文,则向从节点发出发送错误应答,并保持在等待查询应答状态,如果主节点接收到正确的数据报文,则向从节点发出发送成功应答;c. In the state of waiting for the query response, if the master node receives the wrong data message, it will send an error response to the slave node and keep waiting for the query response state. If the master node receives the correct data message, it will send an error response to the slave node. Send a successful response from the node;

d、从节点在等待接收应答状态中,如果等待应答超时或接收到发送错误应答,则重发数据报文,并保持在等待接收应答状态,如果从节点接收到发送成功应答,则迁移到等待命令状态。d. The slave node is in the state of waiting to receive a response. If the waiting response times out or receives a sending error response, it will resend the data message and remain in the state of waiting to receive a response. If the slave node receives a successful sending response, it will migrate to waiting command status.

步骤d所述从节点重发数据报文,并保持在等待接收应答状态的步骤进一步包括:从节点重发数据报文的次数达到上限,则迁移到等待命令状态。The step of resending the data message from the slave node in step d and keeping it in the state of waiting to receive a response further includes: when the number of times the slave node resends the data message reaches the upper limit, then transition to the state of waiting for a command.

数据报文的重发次数根据报文的重要性预先设定。The retransmission times of the data message are preset according to the importance of the message.

可见,本发明方法通过对主节点报文接收流程和从节点报文发送流程进行简化,省去从节点返回查询应答与主节点发送数据接收命令的命令交互过程,提高了主节点与从节点之间的通信速率,并减少了通信时的出错概率。本发明方法通过建立同一协议类型从单元设备的报文内容掩码、报文内容键值和上层应用程序三者之间的一一对应关系,实现主节点对不同协议类型从单元设备的支持,避免了从节点标识改变而导致主节点不支持从节点上的从单元设备的缺点。根据本发明提出的方法,通过对主从通信控制块中从单元设备的报文内容掩码、报文内容键值和上层应用程序及其对应关系进行相应的增加或更改操作,还可及时适应从节点上从单元设备的增加和改变。It can be seen that the method of the present invention simplifies the message receiving process of the master node and the message sending process of the slave node, saves the command interaction process of returning the query response from the node and sending the data receiving command of the master node, and improves the relationship between the master node and the slave node. Inter-communication rate, and reduce the error probability of communication. The method of the present invention realizes the support of the master node to the slave unit devices of different protocol types by establishing a one-to-one correspondence between the message content mask of the same protocol type slave unit device, the message content key value and the upper layer application program, The disadvantage that the master node does not support the slave unit device on the slave node due to the change of the slave node ID is avoided. According to the method proposed by the present invention, by performing corresponding increase or change operations on the message content mask, message content key value, upper-layer application program and corresponding relationship of the slave unit device in the master-slave communication control block, it can also be adapted in time. Addition and change of slave unit devices on slave nodes.

附图说明 Description of drawings

图1是主、从节点的关系示意图;Figure 1 is a schematic diagram of the relationship between master and slave nodes;

图2是现有技术中主节点的主从通信状态机示意图;Fig. 2 is a schematic diagram of a master-slave communication state machine of a master node in the prior art;

图3是现有技术中从节点的主从通信状态机示意图;Fig. 3 is a schematic diagram of a master-slave communication state machine of a slave node in the prior art;

图4是本发明方法的流程图;Fig. 4 is the flowchart of the inventive method;

图5是本发明方法中主节点的主从通信状态机示意图;Fig. 5 is the schematic diagram of the master-slave communication state machine of master node in the method of the present invention;

图6是本发明方法中从节点的主从通信状态机示意图。Fig. 6 is a schematic diagram of the master-slave communication state machine of the slave node in the method of the present invention.

具体实施方式 Detailed ways

为了使本发明的目的、技术方案和优点更加清楚,下面结合附图及实施例对本发明作进一步地详细描述。In order to make the purpose, technical solution and advantages of the present invention clearer, the present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments.

预先设定各个协议类型从单元设备的报文内容键值和报文内容掩码,并建立同一协议类型从单元设备的报文内容掩码、报文内容键值和上层应用程序三者之间的对应关系,其中,报文内容键值为唯一标识从单元设备与主单元设备进行报文交互时所遵从协议类型的报文内容;报文内容掩码由地址偏移量和掩码值组成,设定报文内容掩码的地址偏移量为与该报文内容掩码对应的报文内容键值在报文中所处的字节位减一,设定报文内容掩码的掩码值的字节数为与该报文内容掩码对应的报文内容键值的字节数,且掩码值的各个字节位为十六进制的全一值。Pre-set the message content key value and message content mask of each protocol type slave unit device, and establish the relationship between the message content mask, message content key value and upper-layer application program of the same protocol type slave unit device Corresponding relationship, in which, the key value of the message content uniquely identifies the message content of the protocol type that the slave unit device and the master unit device follow when interacting with the message; the message content mask is composed of an address offset and a mask value , set the address offset of the message content mask to be the byte of the message content key value corresponding to the message content mask minus one, and set the mask of the message content mask The number of bytes of the code value is the number of bytes of the key value of the message content corresponding to the message content mask, and each byte of the mask value is a value of all ones in hexadecimal.

在主从通信协议中规定通过报文内容掩码获得从节点报文的报文内容键值,在主从通信控制块中查找与获得的报文内容键值相同的报文内容键值及与查找到的报文内容键值对应的从节点上的从单元设备的上层应用程序。In the master-slave communication protocol, it is stipulated that the message content key value of the slave node message is obtained through the message content mask, and the message content key value and the same message content key value as the obtained message content key value are searched in the master-slave communication control block. The upper layer application program of the slave unit device on the slave node corresponding to the found message content key value.

因为握手字符可唯一标识协议类型,所以在本实施例中将握手字符设定为报文内容键值。Because the handshake character can uniquely identify the protocol type, the handshake character is set as the message content key value in this embodiment.

例如,有遵从协议类型①的从单元设备C,协议类型①的握手字符为“HD”,将握手字符“HD”设定为协议类型①的报文内容键值。握手字符“HD”在报文中位于第3个字节位,那么根据该握手字符“HD”设定协议类型①的报文内容掩码,将握手字符“HD”在报文中所处的字节位减一,得到报文内容掩码的地址偏移量2,握手字符“HD”的字节数为2,所以报文内容掩码的掩码值为字节数为2的十六进制的全一值,即0xFFFF。For example, there is a slave unit device C that complies with the protocol type ①, the handshake character of the protocol type ① is “HD”, and the handshake character “HD” is set as the message content key value of the protocol type ①. The handshake character "HD" is located in the third byte of the message, then set the message content mask of the protocol type ① according to the handshake character "HD", and the handshake character "HD" is located in the message The byte bit is subtracted by one to get the address offset 2 of the message content mask, and the byte number of the handshake character "HD" is 2, so the mask value of the message content mask is 16 bytes with a byte number of 2 The value of all ones in base, that is, 0xFFFF.

图4是本发明方法的流程图。参见图4,实现主节点支持协议类型①的从单元设备C的方法具体包括以下步骤:Fig. 4 is a flowchart of the method of the present invention. Referring to Fig. 4, the method for realizing the slave unit device C of the master node supporting the protocol type ① specifically includes the following steps:

步骤401:从节点接收到主节点发来的查询命令后,向主节点发送报文。Step 401: After receiving the query command from the master node, the slave node sends a message to the master node.

步骤402:主节点接收到从节点发来的报文。Step 402: the master node receives the message sent by the slave node.

步骤403:主节点查找到报文中的从节点号,并判断该从节点号是否有保存记录,如果有保存记录,则执行步骤404,如果没有保存记录,则执行步骤405。Step 403: The master node finds the slave node number in the message, and judges whether the slave node number has a saved record. If there is a saved record, execute step 404. If there is no saved record, execute step 405.

步骤404:主节点则根据从节点号查找到与该从节点号对应的从单元设备的上层应用程序,并结束本流程。Step 404: The master node searches for the upper-layer application program of the slave unit device corresponding to the slave node number according to the slave node number, and ends this process.

步骤405:主节点将接收到的报文作为首报文,并保存该首报文中的从节点号。Step 405: the master node takes the received message as the first message, and saves the slave node number in the first message.

步骤406:在主从通信控制块中,选取未选用过的一个协议类型的报文内容掩码,并根据选取的报文内容掩码获得首报文中的报文内容键值,例如选取到协议类型①的报文内容掩码,该报文内容掩码的地址偏移量为2,将用于确定报文中报文内容键值的指针进行偏移,指针的偏移量为报文内容掩码中地址偏移量的值2,然后选取指针所指的第3个字节位为该首报文中报文内容键值的起始位,因为报文内容掩码中掩码值0xFFFF的字节位数为2,则设定该报文中报文内容键值的字节位数为2,然后将选取的报文内容键值与报文内容掩码的掩码值0xFFFF相与,获得该首报文的报文内容键值。Step 406: In the master-slave communication control block, select a message content mask of a protocol type that has not been selected, and obtain the message content key value in the first message according to the selected message content mask, for example, select The message content mask of protocol type ①, the address offset of the message content mask is 2, and the pointer used to determine the key value of the message content in the message is offset, and the offset of the pointer is the message The value of the address offset in the content mask is 2, and then the third byte pointed by the pointer is selected as the start bit of the message content key value in the first message, because the mask value in the message content mask If the number of bytes of 0xFFFF is 2, set the number of bytes of the message content key value in the message to 2, and then compare the selected message content key value with the mask value 0xFFFF of the message content mask. and to obtain the packet content key value of the first packet.

步骤407:将首报文的报文内容键值与协议类型①的报文内容键值“HD”进行比较,并判断该首报文的报文内容键值与协议类型①的报文内容键值“HD”是否相同,如果不相同,则执行步骤408,如果相同,则执行步骤410。Step 407: Compare the message content key value of the first message with the message content key value "HD" of the protocol type ①, and judge the message content key value of the first message and the message content key of the protocol type ① Whether the value "HD" is the same, if not, go to step 408, and if they are the same, go to step 410.

步骤408:判断主从通信控制块中是否存在未被选用过协议类型的报文内容掩码,如果存在,则返回步骤406,如果不存在,则执行步骤409。Step 408: Determine whether there is a message content mask of the protocol type not selected in the master-slave communication control block, if yes, return to step 406, if not, execute step 409.

步骤409:主节点将从节点报文丢弃,并提示告警信息,然后结束本流程。Step 409: the master node discards the message from the slave node, prompts an alarm message, and ends the process.

步骤410:选取与协议类型①的报文内容键值对应的上层应用程序为从节点上的从单元设备C的上层应用程序,并建立首报文中的从节点号与选取的从节点上的从单元设备C的上层应用程序之间的对应关系。Step 410: Select the upper-layer application program corresponding to the message content key value of the protocol type ① as the upper-layer application program of the slave unit device C on the slave node, and establish the slave node number in the first message and the selected slave node. Correspondence between the upper layer applications of the slave unit device C.

为了提高主节点与从节点之间的通信速率,并减少了通信时的出错概率,一个较佳实施例是:将步骤401中主节点向从节点发送查询命令,从节点接收到查询命令后,向主节点发送报文的过程进行简化,即把主节点报文接收流程和从节点报文发送流程进行简化,省去主节点与从节点的二次命令交互过程。In order to increase the communication rate between the master node and the slave node, and reduce the error probability during communication, a preferred embodiment is: in step 401, the master node sends a query command to the slave node, and after the slave node receives the query command, The process of sending messages to the master node is simplified, that is, the message receiving process of the master node and the message sending process of the slave node are simplified, and the secondary command interaction process between the master node and the slave node is omitted.

图5是本发明方法中主节点的主从通信状态机示意图,图6是本发明方法中从节点的主从通信状态机示意图,下面结合图5和图6介绍简化后的主节点报文接收流程和从节点报文发送流程。Fig. 5 is the schematic diagram of master-slave communication state machine of master node in the method of the present invention, Fig. 6 is the schematic diagram of master-slave communication state machine of slave node in the method of the present invention, below in conjunction with Fig. 5 and Fig. 6 introduction simplified master node message reception Process and slave node message sending process.

在主节点报文接收流程中,去掉主节点状态机的等待接收数据状态203,同时取消主节点向从节点发送的数据接收命令。In the message receiving process of the master node, the waiting data receiving state 203 of the state machine of the master node is removed, and at the same time, the data receiving command sent by the master node to the slave node is cancelled.

主节点报文接收流程为:主节点在空闲状态201的查询周期中向从节点发送查询命令,然后迁移到等待查询应答状态202,等待自从节点发回的应答;在等待查询应答状态202中,如果主节点等待应答超时或者自从节点发回的应答是表明没有数据要发送的无事应答,那么主节点迁移到空闲状态201,且周期属性迁移到传输周期,如果主节点接收到错误的数据报文,则向从节点发出发送错误应答,同时,主节点保持在等待查询应答状态202,等待从节点重发数据报文,如果主节点接收到正确的数据报文,则向从节点发出发送成功应答,然后主节点迁移到空闲状态201,且周期属性迁移到传输周期。The message receiving process of the master node is: the master node sends a query command to the slave node in the query period of the idle state 201, then migrates to the waiting query response state 202, and waits for the response sent back from the slave node; in the waiting query response state 202, If the master node waits for the response timeout or the response sent back from the slave node is a no-thing response indicating that there is no data to send, then the master node migrates to the idle state 201, and the period attribute migrates to the transmission period, if the master node receives the wrong datagram If the master node receives the correct data message, it will send a successful message to the slave node. Acknowledgment, then the master node transitions to the idle state 201, and the period attribute transitions to the transmission period.

相应地,在从节点报文发送流程中,去掉从节点状态机的等待接收命令状态302,取消从节点向主节点发送的有事应答。Correspondingly, in the message sending process of the slave node, the state machine of the slave node waiting to receive the command 302 is removed, and the busy response sent from the slave node to the master node is cancelled.

从节点报文发送流程为:从节点在等待命令状态301接收到主节点发来的查询命令,如果从节点没有数据报文要发送到主节点,则向主节点发送无事应答,同时,从节点保持在等待命令状态301,如果从节点有数据报文要发送到主节点,则向主节点发送该数据报文,然后从节点迁移到等待接收应答状态303;在等待接收应答状态303中,如果从节点等待应答超时或者接收到发送错误应答,则重发数据报文,数据报文的重发次数可预先设定,同时,从节点保持在等待接收应答状态303,如果从节点接收到发送成功应答或者数据报文的重发次数超过上限,那么从节点迁移到等待命令状态301。The message sending process of the slave node is: the slave node receives the query command from the master node in the waiting command state 301, if the slave node has no data message to send to the master node, it sends a no-thing response to the master node, and at the same time, the slave node Node remains in waiting command state 301, if slave node has data message to send to master node, then send this data message to master node, then transfers to waiting to receive response state 303 from node; In waiting to receive response state 303, If the slave node waits for the response timeout or receives an error response to send, then resend the data message, the number of retransmissions of the data message can be preset, and at the same time, the slave node remains in the state of waiting to receive the response 303, if the slave node receives the send If the response is successful or the number of retransmissions of the data message exceeds the upper limit, then the slave node will migrate to the waiting command state 301 .

总之,以上所述,仅为本发明的较佳实施例而已,并非用于限定本发明的保护范围。凡在本发明的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本发明的保护范围之内。In a word, the above descriptions are only preferred embodiments of the present invention, and are not intended to limit the protection scope of the present invention. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present invention shall be included within the protection scope of the present invention.

Claims (10)

1, the host node support from the node the different agreement type from the method for unit, it is characterized in that, in the master-slave communication agreement, set message content key assignments and the message content mask of each protocol type in advance from unit, and set up same protocol type from the corresponding relation between message content mask, message content key assignments and the upper level applications three of unit, this method may further comprise the steps:
A, host node receive the message of sending from node;
B, choose the message content mask of a protocol type of not selecting for use, and obtain message content key assignments in the message by the message content mask of choosing;
C, the message content key assignments of acquisition and the message content key assignments of the described protocol type of step B are compared, if the message content key assignments that obtains is identical with the message content key assignments of the described protocol type of step B, execution in step E then, if the message content key assignments that obtains is different with the message content key assignments of the described protocol type of step B, and there is the not message content mask of selected mistake, then return step B, if the message content key assignments that obtains is different with the message content key assignments of the described protocol type of step B, and all selected mistake of the message content mask of all protocol types, then execution in step D;
D, host node be packet loss, prompt alarm information, and process ends;
E, choose upper level applications that the message content key-value pair of the described protocol type of step B answers for from node from the upper level applications of unit.
2, method according to claim 1, it is characterized in that the step of described setting message content key assignments comprises: set in the message can unique identification during from unit and master unit devices communicating the message content of the protocol type of deferring to be the message content key assignments of this protocol type.
3, method according to claim 1, it is characterized in that, the step of described setting message content mask comprises: set the message content mask and be made up of address offset amount and mask value, and set the address offset amount and the mask value of message content mask according to the message content key assignments.
4, method according to claim 3, it is characterized in that the described step of setting the address offset amount of message content mask according to the message content key assignments comprises: the address offset amount of setting the message content mask is that message content key assignments residing byte position in message subtracts one.
5, according to claim 3 or 4 described methods, it is characterized in that, the described step of setting the mask value of message content mask according to the message content key assignments comprises: the byte number of setting mask value is the byte number of message content key assignments, and each byte position of setting mask value is a hexadecimal full value.
6, method according to claim 5, it is characterized in that, the described step by the message content key assignments in the message content mask acquisition message of choosing of step B comprises: will be used for determining that the pointer of message content key assignments is offset, the side-play amount of pointer is the value of address offset amount in the message content mask, choosing pointer indication byte position then is the start bit of message content key assignments in the current message, and the byte figure place of choosing mask value in the message content mask is the byte figure place of message content key assignments in the current message, then with the mask value of the message content key assignments chosen and message content mask with, obtain the message content key assignments in the message.
7, method according to claim 1, it is characterized in that, this method further comprises: after host node receives the message of sending from node in described steps A, search earlier in the message from node number, and judge whether this keeping records from node number, if there is not this keeping records from node number, then with this message as the literary composition of reporting for the first time, and preserve in this literary composition of reporting for the first time from node number, carry out described step B again to step e, the corresponding relation of the upper level applications that the literary composition of set up preserving then of reporting for the first time is chosen from node number and described step e, if this keeping records from node number is arranged, then do not carry out described step B to step e, directly choose and be somebody's turn to do from node number corresponding upper application program.
8, method according to claim 1 is characterized in that, described steps A may further comprise the steps:
A, host node to sending querying command from node, are moved to the inquiry response state of waiting for then in the polling cycle of idle condition;
B, receive the querying command that host node is sent at the wait command state, and data message is arranged, then send this data message, move to then and wait for and receive response status to host node from node;
C, host node are in waiting for the inquiry response state, if receive wrong data message,, and remain on the inquiry response state of waiting for then to sending the transmission wrong responses from node, if host node receives correct data message, then to send the transmission successful respond from node;
D, from node during wait for receiving response status, if wait acknowledge is overtime or receive the transmission wrong responses, retransmission data message then, and remain on and wait for and receive response status if receive the transmission successful respond from node, is then moved to the wait command state.
9, method according to claim 8, it is characterized in that, steps d is described from node retransmission data message, and remains on the step that wait for to receive response status and further comprise: reach the upper limit from the number of times of node retransmission data message, then move to the wait command state.
10, method according to claim 9 is characterized in that, the repeating transmission number of times of data message preestablishes according to the importance of message.
CNB2004100001744A 2004-01-08 2004-01-08 Method for main node supporting different agreement type secondary unit apparatus on secondary node Expired - Fee Related CN100493079C (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CNB2004100001744A CN100493079C (en) 2004-01-08 2004-01-08 Method for main node supporting different agreement type secondary unit apparatus on secondary node

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CNB2004100001744A CN100493079C (en) 2004-01-08 2004-01-08 Method for main node supporting different agreement type secondary unit apparatus on secondary node

Publications (2)

Publication Number Publication Date
CN1642167A CN1642167A (en) 2005-07-20
CN100493079C true CN100493079C (en) 2009-05-27

Family

ID=34866659

Family Applications (1)

Application Number Title Priority Date Filing Date
CNB2004100001744A Expired - Fee Related CN100493079C (en) 2004-01-08 2004-01-08 Method for main node supporting different agreement type secondary unit apparatus on secondary node

Country Status (1)

Country Link
CN (1) CN100493079C (en)

Families Citing this family (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101159656B (en) 2007-11-12 2011-05-11 华为技术有限公司 Packet sampling method, system and equipment
CN105634690A (en) * 2015-06-24 2016-06-01 东莞市芯谷电子科技有限公司 A method for enhancing the reliability of the serial port communication of the pattern machine
CN106878098A (en) * 2015-12-10 2017-06-20 深圳市中兴微电子技术有限公司 Method and device for identifying and processing data messages
CN105635802A (en) * 2015-12-31 2016-06-01 浙江大华技术股份有限公司 Transmission method of digital media data and device
CN106155586B (en) * 2016-05-31 2019-03-08 华为技术有限公司 A storage method, server and storage controller
CN107273158B (en) * 2017-06-08 2021-10-26 广东美的暖通设备有限公司 Program upgrading method and device, host, slave and multi-split air conditioning system
CN107567065B (en) * 2017-08-16 2020-11-10 南京天溯自动化控制系统有限公司 Transparent data transmission method and system based on wireless self-organizing network
CN110955170B (en) * 2018-09-27 2023-10-17 中车株洲电力机车研究所有限公司 End-to-end self-adaptive synchronization method and plug-and-play traction control device
CN113746647B (en) * 2020-05-27 2023-12-19 中国联合网络通信集团有限公司 Data transmission method, node, electronic device and readable storage medium
CN113609518B (en) * 2021-06-18 2023-12-12 天津津航计算技术研究所 Message protocol timeout retransmission method and system based on association container map
CN114884852B (en) * 2022-05-07 2024-04-23 武汉思普崚技术有限公司 Node interaction and protocol identification method, device, equipment and computer medium

Also Published As

Publication number Publication date
CN1642167A (en) 2005-07-20

Similar Documents

Publication Publication Date Title
US6901580B2 (en) Configuration parameter sequencing and sequencer
JP3461850B2 (en) Data exchange method and data communication device in data processing device
US7437479B2 (en) Position identifier management apparatus and method, mobile computer, and position identifier processing method
CN112995133B (en) Analysis method, device and system based on modbus protocol
CN100493079C (en) Method for main node supporting different agreement type secondary unit apparatus on secondary node
JPH0344464B2 (en)
JP4257238B2 (en) Automatic IP address assignment method / program / recording medium / device / system, chassis management device, control card
CN101834778B (en) Method for processing neighbor discovery protocol item and three-layer switching equipment
CN114422288A (en) Communication System Based on Modbus Protocol
KR20210111839A (en) Data retransmission method, apparatus, recording medium and electronic device
CN102938715B (en) Based on off-line checking method and the equipment of MAC address authentication
CN106293673A (en) Operational order processing method and processing device
WO2016131404A1 (en) New type can frame based communication method, device and system
WO2019223065A1 (en) Data collection method, data sending method, data collection device, and network device
CN113194494B (en) Air interface resource control method, device, network side equipment and terminal
CN113645008B (en) Message protocol timeout retransmission method and system based on linked list
CN103217956A (en) Industrial control system as well as control method and control device thereof
CN110581803A (en) SDN-based message forwarding method and device
CN113132468B (en) Communication method, communication device, communication system and storage medium based on ModbusTCP protocol
CN113949628B (en) Automatic equipment adding method and system
JPH0591108A (en) Message communication control method and communication system
CN112953835B (en) Data transmission method, device and system
CN1172503C (en) Method for automatic identification of local management interface type by data terminal equipment
CN107360037A (en) A kind of error message acquisition methods and network management device
CN115941128B (en) QCache-based message protocol timeout retransmission management method

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20090527

Termination date: 20170108

CF01 Termination of patent right due to non-payment of annual fee