Multi-node addressing method and system
By receiving and comparing virtual addressing frames on the CAN bus, determining the serial number of the node and assigning the real address, the problem of difficulty and frequent changes in address management in multi-node communication in the prior art is solved, and the address and physical location are realized simplified management.
Patent Information
- Application Number
- CN202411554844.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-01
- Publication Date
- 2025-02-11
Smart Images

Figure CN119420596A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of communication technology, and in particular to a multi-node addressing method and system. Background Art
[0002] When implementing multi-node communication, the current Controller Area Network (CAN) bus needs to assign an address to each node in order to distinguish each node. The existing address allocation scheme generally assigns a virtual address to each node. When the node address needs to be reallocated, the virtual address reallocated each time is basically different from the previous address, which increases the difficulty of node management. Summary of the invention
[0003] In view of this, the purpose of the present invention is to overcome the deficiencies in the prior art and provide a multi-node addressing method and system to achieve the correspondence between the addresses of the nodes after addressing and the physical locations, thereby reducing the difficulty of node management.
[0004] In a first aspect, the present application provides a multi-node addressing method, which is applied to a target node, wherein the target node is each to-be-addressed node on a CAN bus, and each of the to-be-addressed nodes has a virtual address, including:
[0005] Receiving virtual address frames sent by other nodes to be addressed through the CAN bus; the virtual address frames are generated according to the virtual addresses of the nodes to be addressed;
[0006] Comparing the received virtual address addressing frame with the target virtual address addressing frame of the target node, and determining whether there is a node to be addressed that is the same as the target node among other nodes to be addressed according to the comparison result;
[0007] If it does not exist, a serial number is determined according to the target virtual address of the target node, and a real address is allocated to the target node according to the serial number.
[0008] In one implementation, determining the sequence number according to the target virtual address of the target node includes:
[0009] Generate a real address addressing frame according to the target virtual address; the source address of the real address addressing frame is the target virtual address;
[0010] The serial number is obtained through the real address addressing frame; the target byte of the real address addressing frame is the serial number.
[0011] In one implementation, allocating a real address to the target node according to the sequence number includes:
[0012] Get the serial numbers of all nodes, sort the serial numbers of all nodes, and get the sorting results;
[0013] Determine the sorting position of the target node in the sorting result;
[0014] The real address is allocated to the target node according to the sorting position.
[0015] In one implementation, determining whether there is a node to be addressed that is the same as the target node according to the comparison result includes:
[0016] Determining whether each of the received virtual address-addressed frames is the same as the target virtual address-addressed frame;
[0017] If at least one of them is the same, it is determined that the same node to be addressed exists;
[0018] If they are all different, it is determined that there is no identical node to be addressed.
[0019] In one embodiment, the method further comprises:
[0020] If there is a node identical to the target node, sending a request virtual address addressing frame to the CAN bus;
[0021] The virtual addresses are reallocated to all the nodes to be addressed according to the request virtual address addressing frame.
[0022] In one embodiment, the method further comprises:
[0023] Obtaining a cumulative number of the virtual address addressing frames that are identical to the target virtual address addressing frame;
[0024] If the accumulated number is greater than or equal to the preset total number of nodes, the virtual addresses of all nodes are set to zero and an abnormal reminder is generated.
[0025] In one embodiment, the method further comprises:
[0026] Sending the target virtual address addressing frame to the CAN bus according to a first preset period;
[0027] Obtaining the number of times the target virtual address addressing frame is sent, and determining whether the number of times the target virtual address is sent is greater than or equal to a preset number;
[0028] If the sending number is less than the preset number, continuing to send the target virtual address addressing frame according to the first preset period;
[0029] If the number of transmissions is greater than or equal to the preset number of times, the target virtual address addressing frame is transmitted to the CAN bus according to a second preset period; the second preset period is greater than the first preset period.
[0030] In one embodiment, the method further comprises:
[0031] If there is no node identical to the target node, obtaining the number of used nodes among all nodes; the used nodes are nodes to which the virtual address has been allocated;
[0032] Determine whether the number of nodes is greater than or equal to a preset total number of nodes;
[0033] If the number of nodes is less than the preset total number of nodes, determining the number of remaining nodes according to the number of nodes and the preset total number of nodes;
[0034] A corresponding remaining virtual address is allocated to each of the remaining nodes, and the remaining virtual address is stored in the used node; the remaining virtual address is different from the virtual address corresponding to the used node.
[0035] In one embodiment, the method further comprises:
[0036] If a frame addressed with a remaining virtual address sent by a new access node is received from the CAN bus, the remaining virtual address is allocated to the new access node.
[0037] In one embodiment, the method further comprises:
[0038] Receiving real address heartbeat frames sent by other nodes to be addressed through the CAN bus;
[0039] According to the real address heartbeat frame, determining whether the target real address of the target node is the same as the real addresses of other nodes to be addressed;
[0040] If there is at least one identical one, a real address addressing request frame is sent to the CAN bus, and the real addresses of all nodes are re-addressed according to the real address addressing request frame.
[0041] In a second aspect, the present application also provides a multi-node addressing system, including:
[0042] A receiving module, used for receiving virtual address frames sent by other nodes to be addressed through the CAN bus; the virtual address frames are generated according to the virtual addresses of the nodes to be addressed;
[0043] A comparison module, used for comparing the received virtual address addressing frame with the target virtual address addressing frame of the target node, and determining whether there is a node to be addressed that is the same as the target node among other nodes to be addressed according to the comparison result;
[0044] The addressing module is used to determine the serial number according to the target virtual address of the target node if it does not exist, and allocate a real address to the target node according to the serial number.
[0045] The embodiments of the present invention have the following beneficial effects:
[0046] The multi-node addressing method and system provided by the embodiments of the present invention, the target node determines whether the virtual address addressing frames of each node to be addressed are the same as the target virtual address addressing frame of the target node by receiving the virtual address addressing frames sent by other nodes to be addressed. If they are not the same, the serial number is determined according to the virtual address, and the real address is allocated to the target node according to the serial number so that the real address corresponds to the serial number. Since device identifiers such as serial numbers correspond to real physical addresses and are easier to obtain, the difficulty of node management is reduced, and the node address will not change due to re-addressing.
[0047] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and understandable, preferred embodiments are given below and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments are briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.
[0049] Figure 1 A flowchart of a multi-node addressing method provided in an embodiment of the present application;
[0050] Figure 2 A schematic diagram of a CAN bus communication structure provided in an embodiment of the present application;
[0051] Figure 3 A flowchart of a method for sending a target virtual address addressed frame provided in an embodiment of the present application;
[0052] Figure 4 A schematic diagram of a flow chart of a method for determining identical nodes provided in an embodiment of the present application;
[0053] Figure 5 A flowchart of a method for obtaining a serial number provided in an embodiment of the present application;
[0054] Figure 6 A flowchart of a real address allocation method provided in an embodiment of the present application;
[0055] Figure 7 A schematic diagram of the framework structure of a multi-node addressing system provided in an embodiment of the present application. DETAILED DESCRIPTION
[0056] Embodiments of the present invention are described in detail below, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and cannot be understood as limiting the present invention.
[0057] The terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of the present invention, the meaning of "plurality" is two or more, unless otherwise clearly and specifically defined.
[0058] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein in the specification of the template are only for the purpose of describing specific embodiments and are not intended to limit the present invention. The term "and / or" used herein includes any and all combinations of one or more of the related listed items.
[0059] Example 1
[0060] See also Figure 1 , Figure 1 A flowchart of a multi-node addressing method provided in this embodiment can reduce the difficulty of managing nodes when multiple nodes communicate. The method is applied to a target node, where the target node is each node to be addressed on a CAN bus, and each of the nodes to be addressed has a virtual address. The method includes:
[0061] S101. Receive virtual address frames sent by other nodes to be addressed via a CAN bus; the virtual address frames are generated according to the virtual addresses of the nodes to be addressed.
[0062] See also Figure 2 , Figure 2 A schematic diagram of a CAN bus communication structure provided in this embodiment.
[0063] Controller Area Network (CAN) is a serial communication protocol bus for real-time applications. It can use twisted pair cables to transmit signals and is one of the most widely used field buses in the world. The CAN protocol is used for communication between various components in the car, replacing expensive and bulky distribution harnesses.
[0064] Since the target node can be each to-be-addressed node on the CAN bus, each to-be-addressed node will be assigned a virtual address after all to-be-addressed nodes are powered on. Similarly, each to-be-addressed node can receive virtual addressing frames sent by other to-be-addressed nodes through the CAN bus.
[0065] For example, if there are 15 nodes to be addressed that have been powered on on the CAN bus, then each node to be addressed can receive the virtual address addressing frames sent by the other 14 nodes to be addressed. Node A among the 15 nodes can receive the virtual address addressing frames of the other 14 nodes to be addressed, and node B can also receive the virtual address addressing frames of the other 14 nodes to be addressed, and the receiving process of node A and node B can be carried out simultaneously, without any order of precedence. When node A is used as the receiving subject, node A can be regarded as the target node, and when node B is used as the receiving subject, node B can be regarded as the target node. This embodiment only uses the perspective of a target node to make the scheme of this embodiment clearer. In fact, each node to be addressed on the CAN bus can execute and needs to execute the scheme of this embodiment in order to address itself.
[0066] The virtual address is an address that is overused in the node addressing process. The default value is 0. The upper limit can be set according to the maximum number of nodes that the CAN bus can accommodate. The virtual address addressing frame is used by nodes on the CAN bus when competing for the virtual address. Its source address is a virtual address and can be regarded as a verification message carrying virtual address information.
[0067] S102: Compare the received virtual address addressing frame with the target virtual address addressing frame of the target node, and determine whether there is a node to be addressed that is the same as the target node among other nodes to be addressed according to the comparison result.
[0068] After receiving the virtual address addressed frames sent by other nodes to be addressed, the target node compares the virtual address addressed frames of other nodes to be addressed with the target virtual address addressed frame of the target node itself.
[0069] For example, after receiving the virtual address addressed frames sent by the other 14 nodes to be addressed, the target node compares these 14 virtual address addressed frames with the target node's own target virtual address addressed frame. The content of the comparison is actually the virtual address carried in the virtual address addressed frame, that is, it determines whether the virtual addresses corresponding to the other 14 nodes to be addressed are the same as the target virtual address corresponding to the target node.
[0070] Since each node to be addressed receives the virtual address addressing frames of other nodes to be addressed, and then determines whether the virtual address addressing frames of other nodes to be addressed are the same as its own virtual address addressing frames, it is equivalent to 15 nodes synchronously executing the steps of receiving virtual address addressing frames and determining whether the virtual address addressing frames are the same.
[0071] S103: If it does not exist, determine the serial number according to the target virtual address of the target node, and allocate a real address to the target node according to the serial number.
[0072] Since each node to be addressed has its virtual address randomly assigned after power-on, there may be cases where the virtual addresses are the same. If the virtual addresses of other nodes to be addressed are different from the address of the target node, it is determined that there are no identical nodes. Since the target node is each node to be addressed on the CAN bus, the fact that there are no identical nodes here means that the virtual addresses of all nodes are different.
[0073] For example, among the 15 nodes, any one of the nodes to be addressed can receive the virtual address frame sent by the other 14 nodes to be addressed. Take three nodes A, B and C as an example. If the virtual addresses of node A and the other 14 nodes to be addressed are different, but the virtual addresses of nodes B and C are the same, then it means that the same node exists. Only when the virtual addresses of any two of the 15 nodes to be addressed are different, can it be said that there are no same nodes.
[0074] When it is determined that there are no identical nodes, it means that the virtual addresses currently used by each node are unique or non-conflicting. At this time, the serial number and real address of the target node can be determined according to the target virtual address of the target node.
[0075] As shown in Table 1, the communication content of CAN communication generally includes an ID field and a DATA field (digital field). The ID field is divided into a 29-bit extended frame and an 11-bit standard frame. The DATA field generally does not exceed 8 bytes. In this embodiment, the CAN data format involved in node addressing can refer to the J1939 CANID encoding format, using an extended frame. The node ID includes the target address and the source address. The corresponding data format can also be selected according to actual needs. The ID field mainly plays a role in determining the priority of the node message, and the DATA field is mainly used to transmit information.
[0076] Table 1
[0077]
[0078] Therefore, after determining that there are no identical nodes, each node will send a message, which is the real address addressed frame in Table 1. The source address of the real address addressed frame is the virtual address, and the first byte of its DATA field is the frame sequence number, and the following 7 bytes are the ASCII code value corresponding to the sequence number. After receiving the real address addressed frames of other nodes to be addressed, the target node will extract the ASCII code value corresponding to the sequence number of each node from the digital field of the real address addressed frame, and then obtain the corresponding sequence number through transcoding and other methods, and then generate the real address of the target node based on the sequence numbers of other nodes to be addressed and the target sequence number of the target node itself.
[0079] The target node of this embodiment receives the virtual address addressing frames sent by other nodes to be addressed, thereby determining whether the virtual address addressing frames of each node to be addressed are the same as the target virtual address addressing frame of the target node. If they are not the same, the sequence number is determined according to the virtual address, and the real address is assigned to the target node according to the sequence number, so that the real address corresponds to the sequence number. Since the device identifier such as the serial number corresponds to the real physical address and is easier to obtain, the difficulty of node management is reduced, and the address of the node will not change due to re-addressing.
[0080] See also Figure 3 , the sending methods of the target virtual address addressing frame include:
[0081] S1001. Sending a target virtual address frame of the CAN bus according to a first preset period.
[0082] S1002: Obtain the number of times the target virtual address addressed frame is sent, and determine whether the number of times is greater than or equal to a preset number.
[0083] S1003: If the number of transmissions is less than the preset number of times, continue to send the target virtual address addressing frame according to the first preset period.
[0084] S1004. If the number of transmissions is greater than or equal to the preset number of times, the target virtual address addressing frame is transmitted to the CAN bus according to a second preset period; the second preset period is greater than the first preset period.
[0085] When the target node on the CAN bus is just powered on, in order to quickly determine whether the virtual address of the target node is legal, the target node can be made to send its own target virtual address addressing frame to the CAN bus according to a first preset period.
[0086] For example, let the target node send target virtual address frames to the CAN bus 20 times within 3 seconds. When the target node sends its own target virtual address frames, it may also receive virtual address frames sent by other nodes to be addressed. In order to avoid conflicts between sending and receiving, an interrupt mechanism can be set.
[0087] For example, the priority of the target node receiving the virtual address frame signal can be higher than the priority of the target node sending the target virtual address frame. Then, when the target node receives the virtual address frame sent by other nodes to be addressed, the target node will stop sending the target virtual address frame and switch to the receiving state to receive the virtual address frame sent by other nodes to be addressed. Alternatively, the priority of sending can be higher than the priority of receiving.
[0088] The target node will record the number of times it sends the target virtual address frame. If the number of times is less than the preset number, it will continue to send the target virtual address frame to the CAN bus according to the first preset period. If the number of times is greater than or equal to the preset number, it will send the target virtual address frame to the CAN bus according to the second preset period. The time interval of the second preset period is greater than the time interval of the first preset period.
[0089] Since the sending process may be interrupted by the receiving process, the target node can determine whether its own sending times have reached 20 times before sending the target virtual address addressed frame next time. If it has not reached 20 times, it will continue to send until the sending times reaches 20 times.
[0090] When the number of transmissions reaches 20, the target node can send the target virtual address addressing frame according to the second preset period, for example, once every 10 minutes. When the number of transmissions of other nodes to be addressed meets the preset number, they also continue to send the virtual address addressing frame according to the second preset period. The virtual address addressing frame sent according to the second period can be regarded as a heartbeat frame, which is used to periodically verify whether the virtual addresses of each node are the same or conflicting during the communication process.
[0091] When the virtual address addressing frame is sent in the second preset period, the sending program of the target node will not be interrupted, so as to avoid affecting the normal operation of the target node. Only when the target node is not in the sending state or is in the idle state, it will receive the virtual address addressing frame sent by other nodes to be addressed in the second preset period, and judge whether the virtual address addressing frame is the same as the target virtual address addressing frame. Therefore, in order to better distinguish whether the virtual address addressing frame is sent in the first preset period or the second preset period, the priority corresponding to different information can be set through the ID field or other identifiers of the virtual address addressing frame to avoid affecting the normal communication of the node.
[0092] This embodiment sets different target virtual address addressing frame sending periods so that the target virtual address addressing frame can meet different requirements of CAN bus communication under different sending periods, thereby improving the efficiency of node management.
[0093] See also Figure 4 , step S102 includes: steps S1021-S1023.
[0094] S1021. Determine whether each of the received virtual address addressed frames is identical to the target virtual address addressed frame, and record the cumulative number of virtual address addressed frames that are identical to the target virtual address addressed frame.
[0095] S1022: If at least one of them is the same, determine that there is the same node to be addressed.
[0096] S1023: If they are all different, determine that there is no identical node to be addressed.
[0097] In order to distinguish different nodes on the CAN bus, the virtual address of each node is different. If the virtual addresses of two nodes are the same, the two nodes can be considered to be the same node, or in other words, there is a conflict between the two nodes.
[0098] After receiving the virtual address frame sent by other nodes to be addressed, the target node can compare its own target virtual address frame with the received virtual address frame. The source address of the virtual address frame is a virtual address. Therefore, the essence of the comparison is to compare whether the virtual address of the target node is the same as the virtual address of other nodes to be addressed. When there is at least one node to be addressed whose virtual address is the same as the target virtual address of the target node, it means that the same node exists, or there are multiple nodes sharing a virtual address.
[0099] This embodiment compares the target virtual address addressing frame of the target node with the virtual address addressing frames of other nodes to be addressed, thereby determining whether there are nodes with the same virtual address, avoiding the problem of different nodes using the same virtual address, which leads to confusion in information exchange and node management, and improving the efficiency of node management.
[0100] In one embodiment, the method further comprises:
[0101] Obtaining a cumulative number of the virtual address addressing frames that are identical to the target virtual address addressing frame;
[0102] If the accumulated number is greater than or equal to the preset total number of nodes, the virtual addresses of all nodes are set to zero and an abnormal reminder is generated.
[0103] For example, there are 15 nodes on the CAN bus. Taking any target node as an example, after receiving the virtual address addressing frame sent by the other 14 nodes, the target node obtains the corresponding virtual address according to the virtual address addressing frame, obtains 14 virtual addresses, and then compares these 14 virtual addresses with the virtual address of the target node itself, and records the cumulative number of the same comparison results. The initial value of the cumulative number is 0. When the virtual address of a node is the same as that of the target node, the cumulative number is increased by one, and so on. If the cumulative number is still zero after the virtual address comparison of the 14 nodes is completed, it means that there is no node identical to the target node. If it is greater than zero, it means that there is at least one node identical to the target node. If there is a node identical to the target node, the virtual address is reallocated to all nodes on the CAN bus.
[0104] Since the number of nodes that a CAN bus can accommodate is usually capped, and this cap is fixed at the beginning. For example, the maximum number of nodes that a CAN bus can accommodate is 20. If the target node determines that the number of nodes with the same virtual address as itself is greater than or equal to 20, and the target node itself also occupies a node number, it means that the number of nodes has exceeded the upper limit of the CAN bus, and there may be illegal node access. At this time, the virtual addresses of all nodes are set to 0 to prevent illegal nodes from receiving or sending information through the CAN bus, and generate corresponding alarm information.
[0105] This embodiment counts the cumulative number of nodes identical to the target node and determines whether the cumulative number exceeds the upper limit of the number of nodes on the CAN bus, thereby determining whether there is illegal node access. If so, the virtual addresses of all nodes are set to 0, thereby ensuring the communication security of the nodes.
[0106] In one embodiment, the method further comprises:
[0107] If there is a node identical to the target node, sending a request virtual address addressing frame to the CAN bus;
[0108] The virtual addresses are reallocated to all the nodes to be addressed according to the request virtual address addressing frame.
[0109] When it is determined that there are nodes with the same virtual address, it means that the current virtual address allocation is unreasonable. At this time, the target node can send a virtual address addressing frame request to the CAN bus. The purpose of the virtual address addressing frame request is to reallocate the virtual addresses of all nodes. After the virtual address is reallocated, the sending and judgment process of the virtual address addressing frame is re-executed until the virtual addresses of all nodes are unique and non-conflicting.
[0110] When this embodiment determines that there are other nodes to be addressed whose virtual addresses are the same as the target node, a virtual address addressing frame requesting the CAN bus is sent, thereby re-addressing the virtual addresses of all nodes, avoiding the communication confusion and management confusion caused by multiple nodes using the same virtual address for communication, and improving the node management efficiency.
[0111] In one embodiment, the method further comprises:
[0112] If there is no node identical to the target node, the number of used nodes among all nodes is obtained; the used nodes are nodes to which the virtual address has been allocated.
[0113] Determine whether the number of nodes is greater than or equal to a preset total number of nodes.
[0114] If the number of nodes is less than the preset total number of nodes, the number of remaining nodes is determined according to the number of nodes and the preset total number of nodes.
[0115] A corresponding remaining virtual address is allocated to each of the remaining nodes, and the remaining virtual address is stored in the used node; the remaining virtual address is different from the virtual address corresponding to the used node.
[0116] There is an upper limit to the number of nodes that the CAN bus can accommodate, but the number of nodes powered on at the beginning may not have reached the upper limit. Therefore, idle nodes and idle virtual addresses corresponding to idle nodes can be allocated and stored first, so that they can be allocated at any time when new nodes are connected later.
[0117] For example, the maximum number of nodes that a CAN bus can accommodate is 20, that is, the total number of preset nodes is 20. If only 15 nodes are powered on at the beginning, then after the virtual addresses are assigned to these 15 nodes, only 15 of the 20 nodes are in use, and the CAN bus still has 5 nodes remaining. The traditional method will reallocate the virtual addresses of all nodes after each new node is connected, which will increase unnecessary allocation time and affect the communication of other nodes to be addressed.
[0118] Therefore, a remaining virtual address can be allocated to each of the five remaining nodes in advance, and the remaining virtual addresses are different from the virtual addresses of the 15 nodes that have been used to avoid virtual address conflicts, and then the five remaining virtual addresses are stored in the target node. If the target node receives a remaining virtual address addressing frame sent by the new access node from the CAN bus, the remaining virtual address is allocated to the new access node.
[0119] This embodiment allocates corresponding remaining virtual addresses to the remaining nodes in advance according to the upper limit of nodes that the CAN bus can accommodate, that is, the preset total number of nodes, so that when new access nodes are subsequently added, they can be directly allocated with remaining virtual addresses without the need for re-addressing. In addition, the virtual addresses of the new access nodes will not conflict with the virtual addresses of other nodes to be addressed, thereby improving the management efficiency of the nodes.
[0120] See also Figure 5 , step S103 includes: steps S1031-S1032.
[0121] S1031. Generate a real address addressing frame according to the target virtual address; the source address of the real address addressing frame is the target virtual address.
[0122] S1032. Obtain the sequence number through the real address addressing frame; the target byte of the real address addressing frame is the sequence number.
[0123] Since the source address of the real address addressing frame is the target virtual address, after determining that the target virtual address of the target node does not conflict with other nodes to be addressed, the real address addressing frame can be generated according to the target virtual address, and then the sequence number is obtained according to the real address addressing frame. As shown in Table 1, the first byte of the DATA field of the real address addressing frame is the frame sequence number, and the following 7 bytes are the ASCII code value of the sequence number. Therefore, the sequence number can be obtained from the DATA field of the real address addressing frame by transcoding or the like.
[0124] See also Figure 6 , step S103 also includes: steps S1033-S1035.
[0125] S1033. Obtain the serial numbers of all nodes, sort the serial numbers of all nodes, and obtain a sorting result.
[0126] S1034: Determine the sorting position of the target node in the sorting result.
[0127] S1035. Allocate the real address to the target node according to the sorting position.
[0128] After obtaining the serial number, the target node will send its serial number to other nodes to be addressed in the form of a real address addressing frame. Correspondingly, other nodes to be addressed will also send their corresponding real address addressing frames through the CAN bus. The target node assigns a real address to itself according to its own serial number and the serial numbers of other nodes to be addressed through the preset allocation rules.
[0129] For example, there are 15 nodes in total. Taking one of the target nodes as an example, after receiving the real address addressing frame sent by the other 14 nodes, the target node can obtain the serial numbers of these 14 nodes from the real address addressing frame, and then combine the target node's own serial number to generate an array, which includes 15 serial numbers, and then determine the real address of the target node based on the position of the target node in these 15 serial numbers.
[0130] For example, after generating an array based on the serial numbers of the above 15 nodes, the 15 serial numbers in the array are sorted, such as from large to small, to obtain the sorting result. The target node determines the node position of its own target serial number in the sorting result based on the sorting result, and then allocates a real address to itself based on the node position.
[0131] For example, the target node ranks third in the sorting result. Since the serial numbers of the products corresponding to the 15 nodes are fixed and the order of the serial numbers is also fixed, the serial numbers can be regarded as the physical addresses of the products. Considering that the serial numbers of general products are marked on the outside of the products in the form of nameplates or stickers, maintenance personnel can determine the location of the CAN node by the size of the product serial number.
[0132] Therefore, if it is determined that the target node is the first node among the 15 nodes, a first real address is assigned to it. If the target node is the second node among the 15 nodes, a second real address is assigned to it. By analogy, the real address of the node and the sequence number of the node are in one-to-one correspondence. The real address of the node is addressed according to the communication requirements and does not really exist. Therefore, it can also be regarded as a kind of virtual address. That is, this embodiment can achieve a one-to-one correspondence between the virtual address and the physical address of the node.
[0133] This embodiment sorts the serial numbers of all nodes to determine the sorting position of the target node in the serial number, and then allocates a real address to the target node according to the sorting position, thereby achieving a one-to-one correspondence between the real address of the node and the serial number. The address of the node will not change due to re-addressing, which greatly improves the node management efficiency.
[0134] In one embodiment, the method further comprises:
[0135] The real address heartbeat frames sent by other nodes to be addressed are received through the CAN bus.
[0136] According to the real address heartbeat frame, it is determined whether the target real address of the target node is the same as the real addresses of other nodes to be addressed.
[0137] If there is at least one identical one, a real address addressing request frame is sent to the CAN bus, and the real addresses of all nodes are re-addressed according to the real address addressing request frame.
[0138] After the real addresses are allocated, each node can generate a real address heartbeat frame based on its own real address, and then periodically send the real address heartbeat frame to other nodes to be addressed through the CAN bus. Each node can also receive the real address heartbeat frames sent by other nodes to determine whether the real address of each node is the same as the real address of other nodes. If there are at least two identical real addresses, a request real address addressing frame can be sent to the CAN bus, and the real addresses of all nodes can be re-addressed according to the request real address addressing frame.
[0139] Similarly, the virtual address can also be verified by means of heartbeat frames. Since the real address is determined based on the virtual address, if the virtual addresses between nodes are the same or there is a conflict, both the virtual address and the real address need to be re-addressed.
[0140] This embodiment implements the periodic detection of the real address of each node by means of heartbeat frames, thereby preventing different nodes from using the same real address, which would lead to confusion in information interaction and node management, and improving the management efficiency of the nodes.
[0141] See also Figure 7 This embodiment further provides a multi-node addressing system 700, including:
[0142] The receiving module 701 is used to receive virtual address frames sent by other nodes to be addressed through the CAN bus; the virtual address frames are generated according to the virtual addresses of the nodes to be addressed;
[0143] The comparison module 702 is used to compare the received virtual address addressing frame with the target virtual address addressing frame of the target node, and determine whether there is a node to be addressed that is the same as the target node among other nodes to be addressed according to the comparison result;
[0144] The addressing module 703 is used to determine the serial number according to the target virtual address of the target node if it does not exist, and allocate a real address to the target node according to the serial number.
[0145] It can be understood that any implementation of the above-mentioned multi-node addressing method is also applicable to the multi-node addressing system provided in this embodiment, and can achieve the same technical effect.
[0146] In all examples shown and described herein, any specific values should be interpreted as merely exemplary and not as limiting, and thus other examples of the exemplary embodiments may have different values.
[0147] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.
[0148] The above-mentioned embodiments only express several implementation methods of the present invention, and the description thereof is relatively specific and detailed, but it cannot be understood as limiting the scope of the present invention. It should be pointed out that for ordinary technicians in this field, several modifications and improvements can be made without departing from the concept of the present invention, which all belong to the protection scope of the present invention.
Claims
1. A multi-node addressing method, characterized in that: Applied to a target node, the target node is each to-be-addressed node on the CAN bus, each of the to-be-addressed nodes having a virtual address, including: Receiving virtual address frames sent by other nodes to be addressed through the CAN bus; the virtual address frames are generated according to the virtual addresses of the nodes to be addressed; Comparing the received virtual address addressing frame with the target virtual address addressing frame of the target node, and determining whether there is a node to be addressed that is the same as the target node among other nodes to be addressed according to the comparison result; If it does not exist, a serial number is determined according to the target virtual address of the target node, and a real address is allocated to the target node according to the serial number.
2. The multi-node addressing method according to claim 1, characterized in that: The determining of the sequence number according to the target virtual address of the target node comprises: Generate a real address addressing frame according to the target virtual address; the source address of the real address addressing frame is the target virtual address; The serial number is obtained through the real address addressing frame; the target byte of the real address addressing frame is the serial number.
3. The multi-node addressing method according to claim 1, characterized in that: The allocating a real address to the target node according to the sequence number comprises: Get the serial numbers of all nodes, sort the serial numbers of all nodes, and get the sorting results; Determine the sorting position of the target node in the sorting result; The real address is allocated to the target node according to the sorting position.
4. The multi-node addressing method according to claim 1, characterized in that: The determining, according to the comparison result, whether there is the to-be-addressed node that is the same as the target node includes: Determining whether each of the received virtual address-addressed frames is the same as the target virtual address-addressed frame; If at least one of them is the same, it is determined that the same node to be addressed exists; If they are all different, it is determined that there is no identical node to be addressed.
5. The multi-node addressing method according to claim 4, characterized in that: The method further comprises: If the node to be addressed that is the same as the target node exists, sending a frame requesting a virtual address addressing to the CAN bus; The virtual addresses are reallocated to all the nodes to be addressed according to the request virtual address addressing frame.
6. The multi-node addressing method according to claim 4, characterized in that: The method further comprises: Obtaining a cumulative number of the virtual address addressing frames that are identical to the target virtual address addressing frame; If the accumulated number is greater than or equal to the preset total number of nodes, the virtual addresses of all nodes are set to zero and an abnormal reminder is generated.
7. The multi-node addressing method according to claim 1, characterized in that: The method further comprises: Sending the target virtual address addressing frame to the CAN bus according to a first preset period; Obtaining the number of times the target virtual address addressing frame is sent, and determining whether the number of times the target virtual address is sent is greater than or equal to a preset number; If the sending number is less than the preset number, continuing to send the target virtual address addressing frame according to the first preset period; If the number of transmissions is greater than or equal to the preset number of times, the target virtual address addressing frame is transmitted to the CAN bus according to a second preset period; the second preset period is greater than the first preset period.
8. The multi-node addressing method according to claim 1, characterized in that: The method further comprises: If there is no node to be addressed that is the same as the target node, obtaining the number of used nodes among all nodes; the used nodes are nodes to which the virtual address has been allocated; Determine whether the number of nodes is greater than or equal to a preset total number of nodes; If the number of nodes is less than the preset total number of nodes, determining the number of remaining nodes according to the number of nodes and the preset total number of nodes; A corresponding remaining virtual address is allocated to each of the remaining nodes, and the remaining virtual address is stored in the used node; the remaining virtual address is different from the virtual address corresponding to the used node.
9. The multi-node addressing method according to claim 8, characterized in that: The method further comprises: If a frame addressed with a remaining virtual address sent by a new access node is received from the CAN bus, the remaining virtual address is allocated to the new access node.
10. The multi-node addressing method according to claim 1, characterized in that: The method further comprises: Receiving real address heartbeat frames sent by other nodes to be addressed through the CAN bus; According to the real address heartbeat frame, determining whether the target real address of the target node is the same as the real addresses of other nodes to be addressed; If there is at least one identical one, a real address addressing request frame is sent to the CAN bus, and the real addresses of all nodes are re-addressed according to the real address addressing request frame.
11. A multi-node addressing system, characterized in that: include: A receiving module, used for receiving virtual addressing frames sent by other nodes to be addressed through the CAN bus; The virtual address addressing frame is generated according to the virtual address of each of the nodes to be addressed; A comparison module, used for comparing the received virtual address addressing frame with the target virtual address addressing frame of the target node, and determining whether there is a node to be addressed that is the same as the target node among other nodes to be addressed according to the comparison result; The addressing module is used to determine the serial number according to the target virtual address of the target node if it does not exist, and allocate a real address to the target node according to the serial number.
Citation Information
Cited By
Adaptive data management method for polymorphic addressing
CN120263802A
Enumeration method for automatically determining an object identifier of a first network node of a can bus having several network nodes
EP4804467A1
Multi-node addressing method and system
WO2026092585A1