CN115834543A - Address setting method and device, storage medium and electronic device - Google Patents

Address setting method and device, storage medium and electronic device Download PDF

Info

Publication number
CN115834543A
CN115834543A CN202211447346.7A CN202211447346A CN115834543A CN 115834543 A CN115834543 A CN 115834543A CN 202211447346 A CN202211447346 A CN 202211447346A CN 115834543 A CN115834543 A CN 115834543A
Authority
CN
China
Prior art keywords
node
target
address
nodes
group
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.)
Pending
Application number
CN202211447346.7A
Other languages
Chinese (zh)
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.)
Zhejiang Dahua Technology Co Ltd
Original Assignee
Zhejiang Dahua 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 Zhejiang Dahua Technology Co Ltd filed Critical Zhejiang Dahua Technology Co Ltd
Priority to CN202211447346.7A priority Critical patent/CN115834543A/en
Publication of CN115834543A publication Critical patent/CN115834543A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Small-Scale Networks (AREA)

Abstract

The embodiment of the invention provides an address setting method, an address setting device, a storage medium and an electronic device, wherein the method comprises the following steps: under the condition that a group of nodes in a normal connection state with a target gateway is determined, sending a first detection instruction to the group of nodes, wherein the first detection instruction is used for determining whether a target address to be allocated contained in the first detection instruction is occupied or not; acquiring a first detection result of a group of nodes responding to a first detection instruction; and under the condition that the first detection result shows that the target address is not occupied, determining a target node of the address to be allocated from a first list, and setting the target address as the node address of the target node, wherein the first list records node information of a group of nodes, and the group of nodes comprises the target node. The embodiment of the invention solves the problem of low address setting efficiency in the related technology and achieves the effect of improving the address setting efficiency.

Description

Address setting method and device, storage medium and electronic device
Technical Field
The embodiment of the invention relates to the technical field of communication, in particular to an address setting method, an address setting device, a storage medium and an electronic device.
Background
Generally, a large number of child nodes need to be accessed under a serial port of the gateway, and usually addresses need to be set for the child nodes, for example, a 485 gateway is taken as an example, and 485 addresses need to be set for the child nodes accessing the gateway. The common method is to set the child node address by a key way, if there are many child nodes, a large amount of manpower and material resources are needed to configure the child node address, and the requirement on constructors is high. When a child node is newly added, a professional is required to operate on site. Namely, the method for setting the address of the child node of the gateway in the related art has the problem of low efficiency.
Aiming at the problem of low efficiency of setting addresses in the related art, no effective solution is provided at present.
Disclosure of Invention
Embodiments of the present invention provide an address setting method and apparatus, a storage medium, and an electronic apparatus, so as to at least solve the problem of low efficiency in setting an address in the related art.
According to an embodiment of the present invention, there is provided an address setting method including: under the condition that a group of nodes in a normal connection state with a target gateway is determined, sending a first detection instruction to the group of nodes, wherein the first detection instruction is used for determining whether a target address to be allocated contained in the first detection instruction is occupied or not; acquiring a first detection result of the group of nodes responding to the first detection instruction; and under the condition that the first detection result indicates that the target address is not occupied, determining a target node of an address to be allocated from a first list, and setting the target address as the node address of the target node, wherein the first list records node information of the group of nodes, and the group of nodes comprises the target node.
In an exemplary embodiment, the obtaining the first probing result of the group of nodes in response to the first probing instruction includes: determining that the first detection result indicates that the target address is occupied when first response information sent by one node in the group of nodes is received, wherein the first response information indicates that the node address of the one node in the group of nodes is the target address; and under the condition that the first response information sent by any node in the group of nodes is not received within a preset time, determining that the first detection result represents that the target address is not occupied.
In an exemplary embodiment, the sending the first probing instruction to the group of nodes includes: continuously sending the first probe instruction to the group of nodes N times, wherein N is a positive integer greater than or equal to 2; the obtaining a first probing result of the set of nodes in response to the first probing instruction comprises: determining that the first probe result indicates that the target address is occupied in case of receiving first acknowledgement information sent by one node in the group of nodes N times continuously, wherein the first acknowledgement information indicates that the node address of the one node in the group of nodes is the target address.
In one exemplary embodiment, before sending the first probing instruction to the set of nodes, the method further comprises: sending a second probe instruction to a target node set associated with the target gateway in case of receiving a target configuration instruction, wherein the second probe instruction is used for determining the group of nodes in the target node set; determining the set of nodes in the target node set according to a second probing result of the target node set in response to the second probing instruction.
In an exemplary embodiment, the sending a second probing instruction to a set of target nodes associated with the target gateway, determining the set of nodes in the set of target nodes according to a second probing result of the set of target nodes in response to the second probing instruction, includes: acquiring a target list, wherein the target list records node identifiers of all nodes in the target node set and node serial numbers of all the nodes; for each node sequence number included in the target list, performing the following operations, wherein the each node sequence number is a current sequence number when the following operations are performed: sending the second probing instruction to each node in the target node set, wherein the second probing instruction includes the current sequence number; under the condition that second response information sent by one node in the target node set is received, adding the node identification of the one node in the target node set into the first list, wherein the second response information indicates that the node serial number of the one node in the target node set is the current serial number; determining a node identified by a node identification included in the first list as the group of nodes, wherein the node information includes the node identification.
In one exemplary embodiment, the method further comprises: under the condition that the second response information sent by any node in the target node set is not received, adding a node identifier corresponding to the current serial number into a second list; and sending prompt information, wherein the prompt information is used for indicating that the node identified by the node identifier included in the second list has abnormality.
In one exemplary embodiment, the method further comprises: in the event that it is determined that the target address is already occupied, performing the following on an address in a target address range: determining an address in the target address range that is different from the target address, wherein the address in the target address range is an address allowed to be assigned to the group of nodes for communicating with the target gateway; sending a third probing instruction to the group of nodes, wherein the third probing instruction is used to determine whether the one address included in the third probing instruction is occupied; obtaining a second detection result of the group of nodes responding to the third detection instruction; and determining the target node from the first list and setting the address as the node address of the target node when the second detection result indicates that the address is unoccupied.
In an exemplary embodiment, the determining a target node to which an address is to be allocated from the first list includes: determining the target node with an address conflict from the first list, wherein the node address of the target node is the same as the node address of at least one node in the set of nodes; or determining the target node to which no node address has been allocated from the first list.
According to another embodiment of the present invention, there is also provided an address setting apparatus including: a first sending module, configured to send a first probe instruction to a group of nodes in a normal connection state with a target gateway when the group of nodes is determined, where the first probe instruction is used to determine whether a target address to be allocated included in the first probe instruction is occupied; an obtaining module, configured to obtain a first probing result of the group of nodes in response to the first probing instruction; a setting module, configured to determine, when the first detection result indicates that the target address is not occupied, a target node to which an address is to be allocated from a first list, and set the target address as a node address of the target node, where node information of the group of nodes is recorded in the first list, and the group of nodes includes the target node.
According to a further embodiment of the present invention, there is also provided a computer-readable storage medium having a computer program stored thereon, wherein the computer program is arranged to perform the steps of any of the above method embodiments when executed.
According to yet another embodiment of the present invention, there is also provided an electronic device, comprising a memory in which a computer program is stored and a processor configured to run the computer program to perform the steps of any of the method embodiments described above.
According to the invention, a first detection instruction is sent to a group of nodes in a normal connection state with a target gateway, wherein the first detection instruction comprises a target address to be allocated, the first detection instruction is used for determining whether the target address is occupied or not, a first detection result of the group of nodes responding to the first detection instruction is obtained, and when the first detection result shows that the target address is not occupied, the target node of the address to be allocated is determined from a first list, and the target address is set as the node address of the target node. The method and the device achieve the purpose of automatically allocating the target address to the target node of the address to be allocated under the condition that the target address is determined to be unoccupied, and avoid the problem that a large amount of manpower and material resources are needed to be consumed to allocate the node address of each node in the related technology, therefore, the problem that the efficiency of setting the address is low in the related technology is solved, and the effect of improving the efficiency of setting the address is achieved.
Drawings
Fig. 1 is a block diagram of a hardware configuration of a mobile terminal of an address setting method according to an embodiment of the present invention;
fig. 2 is a flowchart of a setting method of an address according to an embodiment of the present invention;
FIG. 3 is an exemplary diagram of an application scenario in accordance with an embodiment of the present invention;
FIG. 4 is an overall interaction flow diagram of address assignment, according to a specific embodiment of the present invention;
FIG. 5 is a schematic flow chart of a probing node according to an embodiment of the present invention;
FIG. 6 is a flowchart illustrating automatic node address setting according to an embodiment of the present invention;
fig. 7 is a block diagram of a configuration of an address setting apparatus according to an embodiment of the present invention.
Detailed Description
Embodiments of the present invention will be described in detail below with reference to the accompanying drawings in conjunction with embodiments.
It should be noted that the terms "first," "second," and the like in the description and claims of the present invention and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order.
The method embodiments provided in the embodiments of the present application may be executed in a mobile terminal, a computer terminal, or a similar computing device. Taking the example of the operation on the mobile terminal, fig. 1 is a hardware structure block diagram of the mobile terminal of the address setting method according to the embodiment of the present invention. As shown in fig. 1, the mobile terminal may include one or more (only one shown in fig. 1) processors 102 (the processor 102 may include, but is not limited to, a processing device such as a microprocessor MCU or a programmable logic device FPGA), and a memory 104 for storing data, wherein the mobile terminal may further include a transmission device 106 for communication functions and an input-output device 108. It will be understood by those skilled in the art that the structure shown in fig. 1 is only an illustration, and does not limit the structure of the mobile terminal. For example, the mobile terminal may also include more or fewer components than shown in FIG. 1, or have a different configuration than shown in FIG. 1.
The memory 104 may be used to store computer programs, for example, software programs and modules of application software, such as computer programs corresponding to the address setting method in the embodiment of the present invention, and the processor 102 executes various functional applications and data processing by running the computer programs stored in the memory 104, so as to implement the above-mentioned method. The memory 104 may include high speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include memory located remotely from the processor 102, which may be connected to the mobile terminal over a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The transmission device 106 is used for receiving or transmitting data via a network. Specific examples of the network described above may include a wireless network provided by a communication provider of the mobile terminal. In one example, the transmission device 106 includes a Network adapter (NIC), which can be connected to other Network devices through a base station so as to communicate with the internet. In one example, the transmission device 106 may be a Radio Frequency (RF) module, which is used for communicating with the internet in a wireless manner.
In the present embodiment, a method for setting an address is provided, and fig. 2 is a flowchart of a method for setting an address according to an embodiment of the present invention, as shown in fig. 2, the flowchart includes the following steps:
step S202, under the condition that a group of nodes in a normal connection state with a target gateway is determined, sending a first detection instruction to the group of nodes, wherein the first detection instruction is used for determining whether a target address to be allocated contained in the first detection instruction is occupied or not;
step S204, acquiring a first detection result of the group of nodes responding to the first detection instruction;
step S206, when the first detection result indicates that the target address is not occupied, determining a target node to which an address is to be allocated from a first list, and setting the target address as a node address of the target node, where node information of the group of nodes is recorded in the first list, and the group of nodes includes the target node.
Through the steps, a first detection instruction is sent to a group of nodes in a normal connection state with a target gateway, wherein the first detection instruction comprises a target address to be allocated, the first detection instruction is used for determining whether the target address is occupied or not, a first detection result of the group of nodes responding to the first detection instruction is obtained, when the first detection result shows that the target address is not occupied, the target node of the address to be allocated is determined from a first list, and the target address is set as the node address of the target node. The method and the device achieve the purpose of automatically allocating the target address to the target node of the address to be allocated under the condition that the target address is determined to be unoccupied, and avoid the problem that a large amount of manpower and material resources are needed to be consumed to allocate the node address of each node in the related technology, therefore, the problem that the efficiency of setting the address is low in the related technology is solved, and the effect of improving the efficiency of setting the address is achieved.
The executing agent of the above steps may be a gateway device, such as the above target gateway, or a controller, or a processor with human-computer interaction capability configured on a storage device, or a processing device or a processing unit with similar processing capability, but is not limited thereto.
In the foregoing embodiment, when a group of nodes in a normal connection state with a target gateway is determined, a first probe instruction is sent to the group of nodes, where the first probe instruction is used to determine whether a target address to be allocated included in the first probe instruction is occupied, taking a 485 gateway (corresponding to the target gateway) as an example, in practical applications, a large number of nodes (or node devices, or 485 devices) may be generally accessed under a serial port of the 485 gateway, but there may be some nodes that are not normally connected with the 485 gateway, for example, lines of some nodes may be connected to some nodesThe method comprises the steps that a fault can exist to cause the normal connection with a 485 gateway, when a group of nodes which are normally connected with a target gateway are determined, a first detection instruction is sent to the group of nodes, wherein the first detection instruction comprises a target address to be distributed, whether the target address is occupied or not is determined by sending the first detection instruction, in practical application, the gateway can send a broadcast instruction to all the nodes to determine whether a certain node is under a gateway serial port or not, for example, the broadcast instruction comprises a target node serial number SN x When some node A returns response information to the target gateway based on the broadcast instruction, the response information comprises the serial number information of the node A and the serial number SN of the target node x If the node A is consistent with the target gateway serial port, the node A is considered to be under the target gateway serial port, namely the node A and the target gateway are in a normal connection state, and by analogy, all nodes connected with the target gateway can be determined, namely the nodes correspond to the group of nodes; in practical application, in order to reduce the occurrence of possible misjudgment caused by the influence of other factors, the target gateway can adopt a mode of continuously sending three instructions, when the gateway receives three responses of a certain node, the target address can be considered to be occupied, and the first detection result can be determined according to the response condition of a group of nodes (for example, the condition of node response or no node response); determining a target node to be allocated with an address from a first list and setting the target address as the node address of the target node when the first detection result indicates that the target address is unoccupied, wherein the first list records node information of a group of nodes, the group of nodes comprises the target node, the first list records node information of a group of nodes, the first list can include the node information of the unallocated address, or the node information of the address needing to be reallocated, or an address conflict existsNode information and the like, where the node information may be an identifier of a node, for example, a serial number of the node, and when it is determined that the target address is not occupied, a target node to be assigned an address may be selected from the first list, and the target address is assigned to the target node; optionally, one of the plurality of node information included in the first list, where an address conflict exists, may be preferentially selected as a target node, and the target address may be assigned to the target node. The method and the device achieve the purpose of automatically allocating the target address to the target node of the address to be allocated under the condition that the target address is determined to be unoccupied, and avoid the problem that a large amount of manpower and material resources are needed to be consumed to allocate the node address of each node in the related technology, so that the problem that the efficiency of setting the address is low in the related technology is solved, and the effect of improving the efficiency of setting the address is achieved.
In an optional embodiment, the obtaining a first probing result of the group of nodes in response to the first probing instruction comprises: determining that the first detection result indicates that the target address is occupied in a case of receiving first response information sent by one node in the group of nodes, wherein the first response information indicates that the node address of the one node in the group of nodes is the target address; and under the condition that the first response message sent by any node in the group of nodes is not received within a preset time length, determining that the first detection result represents that the target address is not occupied. In this embodiment, when first response information sent by one node (e.g., node a) in a group of nodes is received, the first response information indicates that a node address of the node (e.g., node a) is a target address, at this time, it may be determined that a first probing result indicates that the target address is occupied, in practical applications, when a target gateway sends a first probing instruction, the first probing instruction includes the target address, that is, the target gateway sends instruction information to the target address, if the first response information of the node (e.g., node a) can be received, it indicates that the target address is occupied, that is, the node address of node a can be considered as the target address, if no response information of any node is received within a predetermined time period, it indicates that the target address is not occupied at present, and so on, it may be determined whether all addresses in an address range assignable by the target gateway are occupied. Through the embodiment, the purpose of determining whether the target address is occupied by sending the first detection instruction is achieved.
In an optional embodiment, the sending the first probe instruction to the group of nodes includes: continuously sending the first probe instruction to the group of nodes N times, wherein N is a positive integer greater than or equal to 2; the obtaining a first probing result of the set of nodes in response to the first probing instruction comprises: determining that the first probe result indicates that the target address is occupied in a case where first response information is received, the first response information being transmitted by one node in the group of nodes N consecutive times, wherein the first response information indicates that the node address of the one node in the group of nodes is the target address. In this embodiment, in order to improve the accuracy of determining whether the target address is occupied, the target gateway may repeatedly send the first probe instruction N times (e.g., 3 times, 4 times, or other times), and when the target gateway can normally receive the first response information returned by a certain node (e.g., node a) in a group of nodes within N times, it may be determined that the target address is occupied, that is, occupied by the device corresponding to node a. By the embodiment, the effect of improving the accuracy of determining whether the target address is occupied is achieved.
In an optional embodiment, before sending the first probing instruction to the set of nodes, the method further comprises: sending a second probe instruction to a target node set associated with the target gateway in case of receiving a target configuration instruction, wherein the second probe instruction is used for determining the group of nodes in the target node set; determining the set of nodes in the target node set according to a second probing result of the target node set in response to the second probing instruction. In this embodiment, a second probing instruction may be sent to a node in a set of target nodes associated with a target gateway before sending the first probing instruction, where the target nodeThe set comprises the group of nodes, and a group of nodes is determined in the target node set according to a second detection result of the nodes in the target node set in response to a second detection instruction, for example, the nodes in the target node set are all nodes associated with the target gateway, and a part of the nodes which are not normally connected with the target gateway may be included in the node set, for example, a line of the part of the nodes may have a fault and fail to be normally connected with the target gateway, and the second detection instruction is sent to determine which nodes in the target node set are normally connected with the target gateway, for example, the second detection instruction may be a broadcast instruction sent by the target gateway to all the nodes, and the broadcast instruction includes a certain node serial number (e.g., SN) x ) When some node A returns response information to the target gateway based on the broadcast instruction, the SN of the serial number can be considered x The corresponding node (e.g., node a) is under the serial port of the target gateway, that is, the node a and the target gateway are normally connected, and so on, it can be respectively determined whether the node corresponding to the serial number of the other node is normally connected with the target gateway, so that a group of nodes in the target node set which are in a normal connection state with the target gateway can be determined. Through the embodiment, the purpose of determining the group of nodes in the normal connection state with the target gateway by sending the second detection instruction is achieved.
In an optional embodiment, the sending a second probe instruction to a target node set associated with the target gateway, and determining the group of nodes in the target node set according to a second probe result of the target node set in response to the second probe instruction, includes: acquiring a target list, wherein the target list records node identifiers of all nodes in the target node set and node serial numbers of all nodes; for each node sequence number included in the target list, performing the following operations, wherein the each node sequence number is a current sequence number when the following operations are performed: sending the second probing instruction to each node in the target node set, wherein the second probing instruction includes the current sequence number; under the condition that second response information sent by one node in the target node set is received, adding the node identification of the one node in the target node set into the first list, wherein the second response information indicates that the node serial number of the one node in the target node set is the current serial number; determining a node identified by a node identification included in the first list as the group of nodes, wherein the node information includes the node identification. In this embodiment, a group of nodes may be determined from the target node set by, for example, obtaining a target list in which node identifiers of nodes in the target node set and node serial numbers of the nodes are recorded, then, for each node serial number (e.g., current serial number) in the target list, sending a second probe instruction including the current serial number to each node in the target node combination, and when receiving a second response message sent by one node (e.g., node a), considering that one node (e.g., node a) corresponding to the current serial number is already in a normal connection state with the target gateway, at this time, adding the node identifier of the one node (i.e., node a) to the first list, where the target list may be a list prepared in advance and in which all node information associated with the target gateway is recorded, and so on, according to the above method, all node identifiers (or node serial numbers) that are in a normal connection state with the target gateway may be determined from the target node set, thereby obtaining the first list; in practical application, the node identifier that is not normally connected to the target gateway may also be stored in another list, such as a second list, so that the corresponding node in the second list may be inspected or repaired. By the embodiment, the purpose of determining a group of nodes normally connected with the target gateway from the target node set is achieved.
In an optional embodiment, the method further comprises: under the condition that the second response information sent by any node in the target node set is not received, adding a node identifier corresponding to the current serial number into a second list; and sending prompt information, wherein the prompt information is used for indicating that the node identified by the node identifier included in the second list has abnormality. In this embodiment, after the target gateway sends the second probe instruction to each node in the target node set, where the second probe instruction includes the current serial number, if the second response message sent by any node in the target node set is not received, it is considered that the node corresponding to the current serial number is not normally connected to the target gateway, at this time, the node identifier corresponding to the current serial number may be added to the second list, and further, a prompt message may be sent to prompt that the node corresponding to the node identifier included in the second list is abnormal. By the embodiment, the purpose of determining the abnormal node from the target node set and sending the prompt message is achieved.
In an optional embodiment, the method further comprises: in the event that it is determined that the target address is already occupied, performing the following on an address in a target address range: determining an address in the target address range that is different from the target address, wherein the address in the target address range is an address allowed to be assigned to the group of nodes for communicating with the target gateway; sending a third probing instruction to the group of nodes, wherein the third probing instruction is used to determine whether the one address included in the third probing instruction is occupied; obtaining a third detection result of the group of nodes responding to the third detection instruction; and determining the target node from the first list and setting the address as the node address of the target node when the third detection result indicates that the address is unoccupied. The above operation may be referred to as a determination operation for determining whether a target address is occupied, for example, a node address allocation of a 485 gateway, assuming that a target address range that can be set by the gateway is 1-254, an address 1 (or other addresses) may be used as the target address, when it is determined that the address (e.g., address 1) is occupied, an address (e.g., address 2 or other addresses) different from the target address is selected from the target address range, then a third probe instruction is sent to a group of nodes by the same method as in the foregoing embodiment, and a third probe result of a group of nodes in response to the third probe instruction is obtained, so as to determine whether the address 2 is occupied, for example, if a response message sent by one node (e.g., node B) in the group of nodes indicates that the node address of the node B is the same as the address 2, the address 2 is considered to be occupied, and if no node sends a response message, the address 2 is not occupied; in practical application, the above-mentioned judging operation may be executed from address 1, and then the address is automatically incremented by 1, and the above-mentioned judging operation is repeatedly executed. By the embodiment, the purposes of automatically determining whether each address in the target address range is occupied or not and automatically allocating the unoccupied address to the node to which the address is to be allocated are achieved.
In an optional embodiment, the determining, from the first list, a target node to which an address is to be allocated includes: determining the target node with an address conflict from the first list, wherein the node address of the target node is the same as the node address of at least one node in the set of nodes; or determining the target node from the first list to which no node address has been allocated. In this embodiment, it may be determined from the first list that there is a target node with an address conflict, for example, addresses of 2 or more node devices are the same, and one of the nodes may be selected for address allocation; optionally, a target node to which a node address is not allocated may be selected from the first list, and a node whose address is a factory default address may be selected from the first list as the target node to perform address allocation; optionally, in the node information recorded in the first list, if some nodes identify that the corresponding nodes have already been assigned addresses and do not have address conflicts with other nodes, the original node addresses may be reserved for such nodes, and addresses may be reassigned. By the embodiment, the purpose of selecting the target node for address allocation from the first list is achieved.
It is to be understood that the above-described embodiments are only a few, but not all, embodiments of the present invention. The present invention will be described in detail with reference to examples.
Fig. 3 is an exemplary diagram of an application scenario according to an embodiment of the present invention, where a 485 gateway (corresponding to the target gateway) is connected to a large quantum node under a serial port, such as 485 nodes 1 to 485 node N in fig. 3, and the 485 gateway communicates with each node through an AB line.
In the related art, most 485 equipment adopts a key mode, so that higher operation requirements are met for technical personnel on the project site, the operation process of the technical personnel is simplified, and the construction period is shortened. The embodiment of the application provides a method for automatically setting 485 gateway child node addresses. The method comprises the following steps:
1. and acquiring the serial number information of the sub-node according to the two-dimension code information on the surface of the intelligent sub-node (corresponding to the node or the node equipment).
2. Child node sequence number information is assembled into an xls table, where each child node may be aliased and tagged.
3. And importing the xls table through a gateway web, analyzing the xls serial number information through a JavaWeb library, and transmitting the information to gateway equipment through http.
4. And after receiving the serial number list, the gateway judges whether a serial number node exists, whether a 485 address needs to be set and the like.
FIG. 4 is a flowchart of the overall interaction of address assignment, according to a specific embodiment of the present invention, including:
s402, importing a serial number list;
s404, broadcasting the transmission sequence number, for example, the gateway transmits the current sequence number information to all the child nodes (corresponding to the target node set) by broadcasting (corresponding to the aforementioned transmission second probing instruction), optionally, the current sequence number information may be repeatedly transmitted three times;
s406, comparing whether the serial numbers are consistent, namely comparing the current serial number with the self serial number after the child node receives the current serial number information;
s408, if the serial numbers are consistent, answering, and if the serial numbers of the subnodes are consistent with the current serial number sent by broadcasting, considering that the subnodes are under the current gateway serial port;
s410, adding the node into a 485 address queue to be distributed (corresponding to the first list);
s412, starting from address 1, sending probe information (corresponding to the first probe command) to all nodes;
s414, normal response or messy codes exist;
s416, the address is considered to be occupied;
s418, increasing the address by 1, and continuing to detect;
s420, the child node does not respond, for example, the gateway does not receive response information returned by any child node within a preset time length;
s422, the address is considered to be unoccupied;
s424, selecting a node of an address to be distributed (corresponding to the target node of the address to be distributed determined from the first list), and setting a 485 address;
s426, address setting is successful;
s428, the node is added to the gateway configuration.
Fig. 5 is a schematic flowchart of a probe node according to a specific embodiment of the present invention, that is, a process for determining whether a sequence number of a child node matches a sequence number sent by a gateway is as follows:
s502, a sequence number list (corresponding to the aforementioned target list) is imported.
S504, send a sequence number broadcast instruction to the child node, for example, the gateway sends the current sequence number information to all child nodes by broadcasting, and repeatedly sends the current sequence number information three times.
S506, judging whether the child node has a response;
in the step, all the child nodes receive the serial numbers sent by broadcasting, and the child nodes compare the serial numbers with the self serial numbers after receiving the serial number information; if the serial number of the child node is consistent with the serial number sent by broadcasting, the node is considered to be under the current gateway serial port;
the child node initiates a response to the gateway, and the response content comprises the current 485 address, the serial number information and other contents.
S508, if the determination result in step S506 is negative, that is, the gateway does not receive the response from the child node, adding the serial number to the "serial number does not exist" list (corresponding to the second list).
And S510, if the judgment result in the step S506 is yes, namely the gateway receives the response of the child node, adding the serial number into the 485 address queue to be allocated, and waiting for the 485 address to be allocated again.
Steps S502-S510 are repeated until all sequence numbers are traversed.
And S512, ending.
Optionally, a "non-existent sequence number list" may be derived subsequently, the line connection may be checked, or whether the node is a child node of another gateway may be confirmed.
Fig. 6 is a schematic flow chart of automatic node address setting according to an embodiment of the present invention, which includes:
assume that the sub-node 485 address is set to 1-254 (corresponding to the aforementioned target address range), and 255 is a broadcast address.
S602, initializing the 485 address to be allocated to 1 (or other addresses);
s604, determining whether the 485 address to be currently allocated is within an address range allowed to be allocated, for example, determining whether 1< =485 address < =254 is satisfied;
s606, if the determination result in the step S604 is yes, transmitting instruction information (corresponding to the first probe instruction) to the address 1 child node;
if the determination result in the step S604 is negative, the process can be ended;
s608, judging whether a child node responds after the address in the step S606 is used for sending the instruction information;
s610, if the determination result in the step S608 is yes, it is determined that the 485 address already exists, that is, the node of the 485 address already exists, and the process proceeds to step S612;
s612, automatically increasing 1 to the 485 address to be distributed currently, and returning to the step S604;
s614, if the judgment result in the step S608 is negative, the 485 address is considered to be unoccupied; at this time, a node sequence number is selected from the list to be allocated (corresponding to the aforementioned first list);
in the above steps S602-S614, the gateway sequentially sends the instruction information to the designated address starting from address 1, and waits for the response of the child node, optionally, the gateway may repeatedly send the instruction information three times;
if the gateway can normally receive the response of the child node within three times, the address is considered to be occupied;
in practical application, if the gateway receives a child node response within three times but does not complete the command packet, the address is considered to be occupied and a conflict address exists;
then, the address of the gateway child node is increased by 1, and the steps S604-S612 are repeated until no child node responds, so that the 485 address is proved to be unused.
S616, setting a 485 address to the specified serial number;
after finding out the 485 addresses of the unoccupied child nodes, the gateway sets a new 485 address to the appointed child node (such as the node N) through a broadcast instruction;
s618, determining whether the child node (e.g., the node N) has a response, for example, after the gateway sets a new 485 address to the designated child node, the gateway sends instruction information to the new 485 address, and if there is a child node returning response information, it is determined that the 485 address is successfully set;
s620, when the gateway receives the response information sent by the child node (such as the node N), the new 485 address is considered to be successfully set;
s622, storing the information of the node (such as the node N) into gateway configuration; that is, the information of the sub-node serial number (namely the serial number of the node N), 485 address and the like is stored in the gateway configuration;
s624, starting to inquire child node information at regular time; after the information such as the serial number and 485 address of the child node is stored in the gateway configuration in step S622, the gateway can send an event to the platform to prompt that the child node is on line, so that the child node data can be queried;
and S626, ending.
In the above embodiment, the 485 address is automatically configured for the 485 gateway child node by importing the serial number list, and the 485 child node is automatically added to the gateway host by importing the serial number of the child node, so that the effect of one-key deployment can be achieved.
In the related art, there is a method for acquiring 485 addresses of all current nodes of a bus by generating response delay time through the id of the node itself, and there are some approaches of id values, which result in insufficient delay and failure to receive information of all nodes of the bus in time, and compared with the related art, the embodiment of the present application has the following advantages: 1) And scanning the 485 gateway sub-node two-dimensional code through a code scanning gun to obtain a sub-node serial number. Executing before project deployment; 2) The serial number is led into the gateway through 485 gateway web, technicians in subsequent projects do not need to be concerned about the problem of sub-node configuration, and the gateway automatically sets addresses of sub-nodes according to the idle-open serial number to avoid conflict and automatically reduces the configuration work of the technicians on line.
Through the above description of the embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but the former is a better implementation mode in many cases. Based on such understanding, the technical solutions of the present invention or portions thereof contributing to the prior art may be embodied in the form of a software product, which is stored in a storage medium (such as ROM/RAM, magnetic disk, optical disk) and includes instructions for enabling a terminal device (which may be a mobile phone, a computer, a server, or a network device) to execute the method according to the embodiments of the present invention.
There is also provided an address setting apparatus in this embodiment, and fig. 7 is a block diagram of a configuration of the address setting apparatus according to an embodiment of the present invention, as shown in fig. 7, the apparatus includes:
a first sending module 702, configured to send a first probe instruction to a group of nodes in a normal connection state with a target gateway when the group of nodes is determined, where the first probe instruction is used to determine whether a target address to be allocated included in the first probe instruction is occupied;
an obtaining module 704, configured to obtain a first probing result of the group of nodes in response to the first probing instruction;
a setting module 706, configured to determine, when the first detection result indicates that the target address is not occupied, a target node to which an address is to be allocated from a first list, and set the target address as a node address of the target node, where node information of the group of nodes is recorded in the first list, and the group of nodes includes the target node.
In an alternative embodiment, the obtaining module 704 includes: a first determination unit configured to determine that the first probe result indicates that the target address is occupied when first response information sent by one node in the group of nodes is received, wherein the first response information indicates that the node address of the one node in the group of nodes is the target address; a second determining unit, configured to determine that the first detection result indicates that the target address is unoccupied when the first response information sent by any node in the group of nodes is not received within a predetermined time period.
In an optional embodiment, the first sending module 702 includes: a sending unit, configured to send the first probe instruction to the group of nodes N times continuously, where N is a positive integer greater than or equal to 2; the acquiring module 704 includes: a third determining unit, configured to determine that the first detection result indicates that the target address is occupied when receiving first response information that is continuously transmitted by one node in the group of nodes N times, where the first response information indicates that the node address of the one node in the group of nodes is the target address.
In an optional embodiment, the apparatus further comprises: a second sending module, configured to send, before sending the first probe instruction to the group of nodes, a second probe instruction to a target node set associated with the target gateway in a case that a target configuration instruction is received, where the second probe instruction is used to determine the group of nodes in the target node set; a first determining module, configured to determine the group of nodes in the target node set according to a second probing result of the target node set in response to the second probing instruction.
In an alternative embodiment, the apparatus is configured to determine the set of nodes by: acquiring a target list, wherein the target list records node identifiers of all nodes in the target node set and node serial numbers of all nodes; for each node sequence number included in the target list, performing the following operations, wherein the each node sequence number is a current sequence number when the following operations are performed: sending the second probe instruction to each node in the target node set, wherein the second probe instruction includes the current serial number; under the condition that second response information sent by one node in the target node set is received, adding the node identification of the one node in the target node set into the first list, wherein the second response information indicates that the node serial number of the one node in the target node set is the current serial number; determining a node identified by a node identification included in the first list as the group of nodes, wherein the node information includes the node identification.
In an optional embodiment, the apparatus further comprises: an adding module, configured to add a node identifier corresponding to the current sequence number to a second list when the second response information sent by any node in the target node set is not received; and the prompt information is used for indicating that the node identified by the node identifier included in the second list has abnormity.
In an optional embodiment, the apparatus further comprises: an execution module, configured to, if it is determined that the target address is occupied, perform the following on an address in a target address range: determining an address in the target address range that is different from the target address, wherein the address in the target address range is an address allowed to be assigned to the group of nodes for communicating with the target gateway; sending a third probing instruction to the group of nodes, wherein the third probing instruction is used to determine whether the one address included in the third probing instruction is occupied; obtaining a second detection result of the group of nodes responding to the third detection instruction; and determining the target node from the first list and setting the address as the node address of the target node when the second detection result indicates that the address is unoccupied.
In an optional embodiment, the setting module 706 includes: a fourth determining unit, configured to determine, from the first list, the target node with an address conflict, where a node address of the target node is the same as a node address of at least one node in the group of nodes; or a fifth determining unit configured to determine the target node to which a node address has not been allocated from the first list.
It should be noted that, the above modules may be implemented by software or hardware, and for the latter, the following may be implemented, but not limited to: the modules are all positioned in the same processor; alternatively, the modules are respectively located in different processors in any combination.
Embodiments of the present invention also provide a computer-readable storage medium having a computer program stored thereon, wherein the computer program is arranged to perform the steps of any of the above-mentioned method embodiments when executed.
In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to: various media capable of storing computer programs, such as a usb disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a removable hard disk, a magnetic disk, or an optical disk.
Embodiments of the present invention also provide an electronic device comprising a memory having a computer program stored therein and a processor arranged to run the computer program to perform the steps of any of the above method embodiments.
In an exemplary embodiment, the electronic apparatus may further include a transmission device and an input/output device, wherein the transmission device is connected to the processor, and the input/output device is connected to the processor.
For specific examples in this embodiment, reference may be made to the examples described in the above embodiments and exemplary embodiments, and details of this embodiment are not repeated herein.
It will be apparent to those skilled in the art that the various modules or steps of the invention described above may be implemented using a general purpose computing device, they may be centralized on a single computing device or distributed across a network of computing devices, and they may be implemented using program code executable by the computing devices, such that they may be stored in a memory device and executed by the computing device, and in some cases, the steps shown or described may be performed in an order different than that described herein, or they may be separately fabricated into various integrated circuit modules, or multiple ones of them may be fabricated into a single integrated circuit module. Thus, the present invention is not limited to any specific combination of hardware and software.
The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention, and various modifications and changes may be made by those skilled in the art. Any modification, equivalent replacement, or improvement made within the principle of the present invention should be included in the protection scope of the present invention.

Claims (11)

1. A method for setting an address, comprising:
under the condition that a group of nodes in a normal connection state with a target gateway is determined, sending a first detection instruction to the group of nodes, wherein the first detection instruction is used for determining whether a target address to be allocated contained in the first detection instruction is occupied or not;
acquiring a first detection result of the group of nodes responding to the first detection instruction;
and when the first detection result indicates that the target address is unoccupied, determining a target node of an address to be allocated from a first list, and setting the target address as a node address of the target node, wherein the first list records node information of the group of nodes, and the group of nodes includes the target node.
2. The method of claim 1, wherein obtaining the first probing result of the set of nodes in response to the first probing instruction comprises:
determining that the first detection result indicates that the target address is occupied in a case of receiving first response information sent by one node in the group of nodes, wherein the first response information indicates that the node address of the one node in the group of nodes is the target address;
and under the condition that the first response information sent by any node in the group of nodes is not received within a preset time, determining that the first detection result represents that the target address is not occupied.
3. The method of claim 1,
the sending the first probing instruction to the set of nodes comprises: continuously sending the first probe instruction to the group of nodes N times, wherein N is a positive integer greater than or equal to 2;
the obtaining a first probing result of the set of nodes in response to the first probing instruction comprises: determining that the first probe result indicates that the target address is occupied in case of receiving first acknowledgement information sent by one node in the group of nodes N times continuously, wherein the first acknowledgement information indicates that the node address of the one node in the group of nodes is the target address.
4. The method of claim 1, wherein prior to sending the first probing instruction to the set of nodes, the method further comprises:
sending a second probe instruction to a target node set associated with the target gateway in case of receiving a target configuration instruction, wherein the second probe instruction is used for determining the group of nodes in the target node set;
determining the set of nodes in the target node set according to a second probing result of the target node set in response to the second probing instruction.
5. The method of claim 4, wherein sending a second probing instruction to a set of target nodes associated with the target gateway, and wherein determining the set of nodes in the set of target nodes according to a second probing result of the set of target nodes in response to the second probing instruction comprises:
acquiring a target list, wherein the target list records node identifiers of all nodes in the target node set and node serial numbers of all nodes;
for each node sequence number included in the target list, performing the following operations, wherein the each node sequence number is a current sequence number when the following operations are performed: sending the second probing instruction to each node in the target node set, wherein the second probing instruction includes the current sequence number; adding a node identifier of one node in the target node set to the first list under the condition of receiving second response information sent by the one node in the target node set, wherein the second response information indicates that the node serial number of the one node in the target node set is the current serial number;
determining a node identified by a node identification included in the first list as the group of nodes, wherein the node information includes the node identification.
6. The method of claim 5, further comprising:
under the condition that the second response information sent by any node in the target node set is not received, adding a node identifier corresponding to the current serial number into a second list;
and sending prompt information, wherein the prompt information is used for indicating that the node identified by the node identifier included in the second list has abnormality.
7. The method of claim 1, further comprising:
in the event that it is determined that the target address is already occupied, performing the following on an address in a target address range:
determining an address in the target address range that is different from the target address, wherein the address in the target address range is an address allowed to be assigned to the group of nodes for communicating with the target gateway;
sending a third probing instruction to the group of nodes, wherein the third probing instruction is used to determine whether the one address included in the third probing instruction is occupied;
obtaining a third detection result of the group of nodes responding to the third detection instruction;
and determining the target node from the first list and setting the address as the node address of the target node when the third detection result indicates that the address is unoccupied.
8. The method of claim 1, wherein determining the target node to which the address is to be assigned from the first list comprises:
determining the target node with an address conflict from the first list, wherein the node address of the target node is the same as the node address of at least one node in the set of nodes; or
Determining the target node from the first list to which a node address has not been assigned.
9. An address setting apparatus, comprising:
a first sending module, configured to send a first probe instruction to a group of nodes in a normal connection state with a target gateway when the group of nodes is determined, where the first probe instruction is used to determine whether a target address to be allocated included in the first probe instruction is occupied;
an obtaining module, configured to obtain a first probing result of the group of nodes in response to the first probing instruction;
a setting module, configured to determine, when the first detection result indicates that the target address is not occupied, a target node to which an address is to be allocated from a first list, and set the target address as a node address of the target node, where node information of the group of nodes is recorded in the first list, and the group of nodes includes the target node.
10. A computer-readable storage medium, in which a computer program is stored, which computer program, when being executed by a processor, carries out the steps of the method according to any one of claims 1 to 8.
11. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the steps of the method as claimed in any of claims 1 to 8 are implemented when the computer program is executed by the processor.
CN202211447346.7A 2022-11-18 2022-11-18 Address setting method and device, storage medium and electronic device Pending CN115834543A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211447346.7A CN115834543A (en) 2022-11-18 2022-11-18 Address setting method and device, storage medium and electronic device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211447346.7A CN115834543A (en) 2022-11-18 2022-11-18 Address setting method and device, storage medium and electronic device

Publications (1)

Publication Number Publication Date
CN115834543A true CN115834543A (en) 2023-03-21

Family

ID=85529126

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211447346.7A Pending CN115834543A (en) 2022-11-18 2022-11-18 Address setting method and device, storage medium and electronic device

Country Status (1)

Country Link
CN (1) CN115834543A (en)

Similar Documents

Publication Publication Date Title
CN108737590B (en) Automatic address allocation method and system, Modbus master station and Modbus slave station
CN112272243B (en) Address allocation method
EP3422655B1 (en) Method for managing address of meter device, and acquisition terminal and meter device
CN112583677A (en) Method, device, storage medium and system for allocating addresses to slave devices
CN115242752B (en) Address allocation method, device, equipment and medium of battery management system
CN110708400B (en) Network address allocation method, device, node equipment and storage medium
EP3901766A1 (en) Offline configuration method and apparatus for smart device
CN114401250A (en) Address allocation method and device
CN105357267A (en) Method, device and system for obtaining server information
US20240107647A1 (en) Control method, control device and lighting system
CN108834130B (en) Identification distribution method, device, terminal and computer readable storage medium
CN109787688B (en) Communication device, pluggable optical module, communication system, communication method, and storage medium
CN115834543A (en) Address setting method and device, storage medium and electronic device
CN115334041A (en) Method for automatically allocating addresses to communication equipment of master station and slave station, master station, slave station and system
CN113347287B (en) Host discovery and addition method, device, equipment and medium in data center
CN106028303B (en) Intelligent device discovery method and device
CN108141480B (en) Method and apparatus for addressing in a system of interconnected cells
CN110661655B (en) Cluster deployment method and system, electronic device and storage medium
CN113395366A (en) Network address allocation method and device
CN106559439A (en) A kind of method for processing business and equipment
CN111464395A (en) Method and device for creating block chain and readable storage medium
CN111064599B (en) Method and system for monitoring plug-in migration
CN111541795B (en) Address allocation method, device, equipment and computer readable storage medium
CN112596893B (en) Monitoring method and system for multi-node edge computing device
CN117544596B (en) Automatic address allocation method for telemetry system, telemetry system and storage medium

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