Multi-node addressing method and system
By receiving and comparing virtual address addressing frames on the CAN bus, determining the serial number and assigning the real address, the problem of node management difficulty is solved, the correspondence between the real address and the serial number is realized, and node management efficiency and communication security are improved.
Patent Information
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- SUNWODA ENERGY TECHNOLOGY CO LTD
- Filing Date
- 2025-10-30
- Publication Date
- 2026-05-07
AI Technical Summary
In the existing technology, the address allocation scheme of CAN bus nodes increases the difficulty of node management because the virtual address is usually different each time it is reassigned, and there is a lack of correspondence with the physical location.
By receiving virtual address addressing frames sent by other nodes, comparing them, determining whether there are identical nodes, determining the sequence number based on the target virtual address, allocating a real address, and realizing the correspondence between the real address and the sequence number.
It reduces the difficulty of node management, avoids address changes caused by re-addressing, and improves node management efficiency and communication security.
Smart Images

Figure CN2025131247_07052026_PF_FP_ABST
Abstract
Description
A multi-node addressing method and system
[0001] This application claims priority to Chinese Patent Application No. 202411554844.0, filed on November 1, 2024, entitled "A Multi-Node Addressing Method and System", the entire contents of which are incorporated herein by reference. Technical Field
[0002] This invention relates to the field of communication technology, and in particular to a multi-node addressing method and system. Background Technology
[0003] Currently, Controller Area Network (CAN) buses require assigning an address to each node to distinguish them when implementing multi-node communication. Existing address allocation schemes typically assign virtual addresses to each node. When a node's address needs to be reassigned, the reassigned virtual address is almost always different from the previous address, increasing the complexity of node management. Summary of the Invention
[0004] In view of this, the purpose of the present invention is to overcome the shortcomings of the prior art and provide a multi-node addressing method and system to realize the correspondence between the address of the node after addressing and the physical location, thereby reducing the management difficulty of the node.
[0005] Firstly, this application provides a multi-node addressing method applied to a target node, wherein the target node is each addressable node on a CAN bus, and each addressable node has a virtual address, including:
[0006] The system receives virtual addressing frames sent by other nodes to be addressed via the CAN bus; the virtual addressing frames are generated based on the virtual addresses of each node to be addressed.
[0007] The received virtual address addressing frame is compared with the target virtual address addressing frame of the target node, and the comparison result is used to determine whether there is a target node among other nodes to be addressed that is the same as the target node.
[0008] If it does not exist, then determine the sequence number based on the target virtual address of the target node, and assign a real address to the target node based on the sequence number.
[0009] In one implementation, determining the sequence number based on the target virtual address of the target node includes:
[0010] A real address addressing frame is generated based on the target virtual address; the source address of the real address addressing frame is the target virtual address.
[0011] The sequence number is obtained through the real address addressing frame; the target byte of the real address addressing frame is the sequence number.
[0012] In one implementation, assigning a real address to the target node based on the sequence number includes:
[0013] Obtain the sequence number of all nodes, sort the sequence numbers of all nodes, and obtain the sorting result;
[0014] Determine the sorting position of the target node in the sorting result;
[0015] The real address is assigned to the target node according to the sorting position.
[0016] In one implementation, determining whether there exists a node to be addressed that is identical to the target node based on the comparison result includes:
[0017] Determine whether each received virtual address addressing frame is the same as the target virtual address addressing frame;
[0018] If at least one is the same, then it is determined that there are identical nodes to be addressed;
[0019] If all are different, then it is determined that there are no identical nodes to be addressed.
[0020] In one embodiment, the method further includes:
[0021] If a node identical to the target node exists, a request virtual address addressing frame is sent to the CAN bus;
[0022] The virtual address is reassigned to all the nodes to be addressed according to the requested virtual address addressing frame.
[0023] In one embodiment, the method further includes:
[0024] Obtain the cumulative number of virtual addressing frames that are identical to the target virtual addressing frame;
[0025] If the cumulative number is greater than or equal to the preset total number of nodes, then the virtual addresses of all nodes are set to zero, and an error alert is generated.
[0026] In one embodiment, the method further includes:
[0027] The target virtual address addressing frame is sent to the CAN bus according to the first preset cycle;
[0028] Obtain the number of times the target virtual address addressing frame has been sent, and determine whether the number of times it has been sent is greater than or equal to a preset number;
[0029] If the number of transmissions is less than the preset number, then the target virtual address addressing frame will continue to be transmitted according to the first preset period;
[0030] If the number of transmissions is greater than or equal to the preset number of transmissions, the target virtual address addressing frame is transmitted to the CAN bus according to the second preset period; the second preset period is greater than the first preset period.
[0031] In one embodiment, the method further includes:
[0032] If no node is identical to the target node, then obtain the number of used nodes among all nodes; the used nodes are those nodes that have been allocated the virtual address.
[0033] Determine whether the number of nodes is greater than or equal to the preset total number of nodes;
[0034] If the number of nodes is less than the preset total number of nodes, then the number of remaining nodes is determined based on the number of nodes and the preset total number of nodes;
[0035] Each remaining node is assigned a corresponding remaining virtual address, 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.
[0036] In one embodiment, the method further includes:
[0037] If a remaining virtual address addressing frame is received from a new access node on the CAN bus, the remaining virtual address is assigned to the new access node.
[0038] In one embodiment, the method further includes:
[0039] Receive real address heartbeat frames sent by other nodes to be addressed via the CAN bus;
[0040] Based on the real address heartbeat frame, determine whether the target real address of the target node is the same as the real address of other nodes to be addressed;
[0041] If at least one is identical, a request real address addressing frame is sent to the CAN bus, and the real addresses of all nodes are re-addressed according to the request real address addressing frame.
[0042] Secondly, this application also provides a multi-node addressing system, including:
[0043] The receiving module is used to receive virtual address addressing frames sent by other nodes to be addressed via the CAN bus; the virtual address addressing frames are generated based on the virtual addresses of each node to be addressed.
[0044] The comparison module 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 target node among other nodes to be addressed that is the same as the target node based on the comparison result;
[0045] The addressing module is used to determine a sequence number based on the target virtual address of the target node if the target node does not exist, and to assign a real address to the target node based on the sequence number.
[0046] The embodiments of the present invention have the following beneficial effects:
[0047] The multi-node addressing method and system provided in the embodiments of the present invention allow a target node to receive virtual addressing frames sent by other nodes to be addressed, thereby determining whether the virtual addressing frames of each node to be addressed are the same as the target virtual addressing frame of the target node. If they are not the same, a sequence number is determined based on the virtual address, and a real address is assigned to the target node based on the sequence number, so that the real address corresponds to the sequence number. Since the device identifiers such as the sequence number correspond to the real physical address and are easier to obtain, the management difficulty of the node is reduced, and the node's address will not change due to re-addressing.
[0048] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description
[0049] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation on the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0050] Figure 1 is a flowchart illustrating a multi-node addressing method provided in an embodiment of this application;
[0051] Figure 2 is a schematic diagram of a CAN bus communication structure provided in an embodiment of this application;
[0052] Figure 3 is a flowchart illustrating a method for sending a target virtual address addressing frame according to an embodiment of this application;
[0053] Figure 4 is a flowchart illustrating a method for determining identical nodes provided in an embodiment of this application;
[0054] Figure 5 is a flowchart illustrating a serial number acquisition method provided in an embodiment of this application;
[0055] Figure 6 is a flowchart illustrating a real address allocation method provided in an embodiment of this application;
[0056] Figure 7 is a schematic diagram of the framework structure of a multi-node addressing system provided in an embodiment of this application. Detailed Implementation
[0057] Embodiments of the present invention are described in detail below. Examples of these embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and should not be construed as limiting the present invention.
[0058] The terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of this invention, "a plurality of" means two or more, unless otherwise explicitly specified.
[0059] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein in the template description is for the purpose of describing particular embodiments only and is not intended to limit the invention. The term "and / or" as used herein includes any and all combinations of one or more of the associated listed items.
[0060] Example 1
[0061] Referring to Figure 1, which is a flowchart illustrating a multi-node addressing method provided in this embodiment, this method can reduce the management difficulty of nodes during multi-node communication. The method is applied to target nodes, which are each addressable node on the CAN bus. Each addressable node has a virtual address. The method includes:
[0062] S101. Receive virtual address addressing frames sent by other nodes to be addressed via the CAN bus; the virtual address addressing frames are generated based on the virtual addresses of each node to be addressed.
[0063] Referring to Figure 2, which is a schematic diagram of a CAN bus communication structure provided in this embodiment.
[0064] Controller Area Network (CAN) is a serial communication protocol bus used for real-time applications. It uses twisted-pair cables to transmit signals and is one of the most widely used fieldbuses in the world. The CAN protocol is used for communication between various components in automobiles, replacing expensive and bulky wiring harnesses.
[0065] Since the target node can be any addressable node on the CAN bus, each addressable node will be assigned a virtual address after all addressable nodes are powered on. Similarly, each addressable node can receive virtual address frames sent by other addressable nodes via the CAN bus.
[0066] For example, if there are 15 nodes on the CAN bus that are powered on and awaiting addressing, then each node can receive virtual address frames sent by the other 14 nodes. Node A can receive virtual address frames from the other 14 nodes, and node B can also receive virtual address frames from the other 14 nodes. Furthermore, the receiving processes of nodes A and B can occur simultaneously, without any specific order. When node A is the receiving entity, it can be considered the target node; when node B is the receiving entity, it can also be considered the target node. This embodiment only uses the perspective of a target node to make the scheme clearer. In reality, every node on the CAN bus that awaits addressing can and needs to execute the scheme of this embodiment in order to address itself.
[0067] Virtual addresses are addresses that are overused during node addressing. The default value is 0, and the maximum number of virtual addresses can be set according to the maximum number of nodes that the CAN bus can accommodate. Virtual address addressing frames are used by nodes on the CAN bus when competing for virtual addresses. Their source address is a virtual address, and they can be regarded as a verification message carrying virtual address information.
[0068] S102. The received virtual address addressing frame is compared with the target virtual address addressing frame of the target node, and the comparison result is used to determine whether there is a target node among the other nodes to be addressed that is the same as the target node.
[0069] After receiving virtual address addressing frames sent by other nodes to be addressed, the target node compares the virtual address addressing frames of the other nodes to be addressed with its own target virtual address addressing frame.
[0070] For example, after receiving virtual address addressing frames sent by 14 other nodes to be addressed, the target node compares these 14 virtual address addressing frames with its own target virtual address addressing frame. The comparison is actually the virtual address carried in the virtual address addressing frame. That is, it determines whether the virtual address corresponding to each of the other 14 nodes to be addressed is the same as the target virtual address corresponding to the target node.
[0071] Since each node to be addressed receives virtual addressing frames from other nodes to be addressed and then determines whether the virtual addressing frames of other nodes to be addressed are the same as its own virtual addressing frames, it is equivalent to 15 nodes synchronously performing the steps of receiving virtual addressing frames and determining whether the virtual addressing frames are the same.
[0072] S103. If it does not exist, then determine the sequence number based on the target virtual address of the target node, and assign a real address to the target node based on the sequence number.
[0073] Since each node to be addressed has its virtual address randomly assigned after power-on, there may be cases where 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 every node to be addressed on the CAN bus, the statement that there are no identical nodes here means that the virtual addresses of all nodes are different.
[0074] For example, among 15 nodes, any one of the nodes to be addressed can receive virtual addressing frames sent by the other 14 nodes. Taking three nodes A, B, and C as an example, if node A has a different virtual address than the other 14 nodes, but nodes B and C have the same virtual address, then there are duplicate nodes. Only when any two of the 15 nodes have different virtual addresses can it be concluded that there are no duplicate nodes.
[0075] When it is determined that no duplicate nodes exist, it means that the virtual address currently used by each node is unique or non-conflicting. At this point, the sequence number and physical address of the target node can be determined based on the target virtual address of the target node.
[0076] As shown in Table 1, 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 destination address and the source address. Alternatively, the corresponding data format can be selected according to actual needs. The ID field mainly serves to determine the priority of node messages, while the DATA field is mainly used for transmitting information.
[0077] Table 1
[0078] Therefore, after determining that no duplicate nodes exist, each node will send a message, which is the real address addressing frame in Table 1. The source address of the real address addressing frame is a virtual address. 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 addressing 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 numeric field of the real address addressing frame, and then obtain the corresponding sequence number through transcoding and other methods. Then, based on the sequence numbers of other nodes to be addressed and the target node's own target sequence number, it will generate the real address of the target node.
[0079] In this embodiment, the target node receives virtual addressing frames sent by other nodes to be addressed, thereby determining whether the virtual addressing frames of each node to be addressed are the same as the target virtual addressing frame of the target node. If they are different, a sequence number is determined based on the virtual address, and a real address is assigned to the target node based on the sequence number, so that the real address corresponds to the sequence number. Since device identifiers such as the sequence number correspond to the real physical address and are easier to obtain, the management difficulty of the node is reduced, and the node's address will not change due to readdressing.
[0080] Referring to Figure 3, the transmission methods of the target virtual address addressing frame include:
[0081] S1001. Send its own target virtual address addressing frame to the CAN bus according to the first preset cycle.
[0082] S1002. Obtain the number of times the target virtual address addressing frame has been sent, and determine whether the number of times it has been sent is greater than or equal to a preset number.
[0083] S1003. If the number of transmissions is less than the preset number of transmissions, then continue to transmit 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 transmissions, then the target virtual address addressing frame is transmitted to the CAN bus according to the second preset period; the second preset period is greater than the first preset period.
[0085] When the target node on the CAN bus is powered on, in order to determine as soon as possible whether the virtual address of the target node is valid, the target node can be instructed to send its own target virtual address addressing frame to the CAN bus according to the first preset cycle.
[0086] For example, if the target node is instructed to send 20 target virtual address addressing frames to the CAN bus within 3 seconds, while the target node is sending its own target virtual address addressing frame, it may also receive virtual address addressing frames sent by other nodes to be addressed. In order to avoid conflicts caused by sending and receiving, an interrupt mechanism can be set up.
[0087] For example, the priority of receiving virtual address addressing frame signals can be set higher than the priority of sending target virtual address addressing frames. Then, when the target node receives virtual address addressing frames from other nodes awaiting addressing, it will interrupt its own transmission and switch to a receiving state to receive virtual address addressing frames from those other nodes. Alternatively, the priority of transmission can be set higher than the priority of reception.
[0088] The target node records the number of times it sends the target virtual address addressing frame. If the number of transmissions is less than a preset number, it continues to send the target virtual address addressing frame to the CAN bus according to the first preset period. If the number of transmissions is greater than or equal to the preset number, it sends the target virtual address addressing 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 during the receiving process, the target node can determine whether it has reached 20 transmissions before sending the target virtual address address frame again. If it has not reached 20 transmissions, it will continue to send until the transmission count reaches 20.
[0090] After 20 transmissions, the target node can send a target virtual address encoding frame according to a second preset period, such as once every 10 minutes. Other nodes waiting to be addressed will also continue to send virtual address encoding frames according to the second preset period after the preset number of transmissions has been met. The virtual address encoding frames sent according to the second period can be regarded as a heartbeat frame, used to periodically verify whether the virtual addresses of each node are the same or conflict during communication.
[0091] When a virtual address addressing frame is sent with the second preset period, the target node's sending procedure will not be interrupted, thus avoiding affecting the normal operation of the target node. Only when the target node is not in a sending state or is in an idle state will it receive virtual address addressing frames sent by other nodes to be addressed with the second preset period, and determine whether the virtual address addressing frame is the same as the target virtual address addressing frame. Therefore, in order to better distinguish whether a virtual address addressing frame is sent with the first or second preset period, the priority of 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 nodes.
[0092] This embodiment sets different transmission cycles for the target virtual address addressing frame, enabling the target virtual address addressing frame to meet different needs of CAN bus communication under different transmission cycles, thereby improving the efficiency of node management.
[0093] Referring to Figure 4, step S102 includes steps S1021-S1023.
[0094] S1021. Determine whether each received virtual address addressing frame is the same as the target virtual address addressing frame, and record the cumulative number of virtual address addressing frames that are the same as the target virtual address addressing frame.
[0095] S1022. If at least one is the same, then it is determined that there are identical nodes to be addressed.
[0096] S1023. If all are different, then it is determined that there are no identical nodes to be addressed.
[0097] To distinguish different nodes on the CAN bus, each node has a different virtual address. If two nodes have the same virtual address, they can be considered to be the same node, or in other words, they are in conflict.
[0098] After receiving virtual address addressing frames from other nodes to be addressed, the target node can compare its own target virtual address addressing frame with the received frame. Since the source address of the virtual address addressing frame is a virtual address, the comparison essentially involves checking if the target node's virtual address is the same as the virtual addresses of other nodes to be addressed. If at least one node to be addressed has the same virtual address as the target node's target virtual address, it indicates that there are identical nodes, or multiple nodes sharing the same 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. This avoids the problem of different nodes using the same virtual address, which leads to chaotic information exchange and node management, and improves the efficiency of node management.
[0100] In one embodiment, the method further includes:
[0101] Obtain the cumulative number of virtual addressing frames that are identical to the target virtual addressing frame;
[0102] If the cumulative number is greater than or equal to the preset total number of nodes, then the virtual addresses of all nodes are set to zero, and an error alert is generated.
[0103] For example, if there are 15 nodes on a CAN bus, taking any one of them as a target node, after receiving virtual address encoding frames from the other 14 nodes, the target node obtains the corresponding virtual address based on the virtual address encoding frame, resulting in 14 virtual addresses. These 14 virtual addresses are then compared with the target node's own virtual address, and the cumulative number of comparisons showing the same result is recorded. The initial value of the cumulative count is 0. When a node's virtual address matches the target node's, the cumulative count is incremented by one, and so on. If the cumulative count is still zero after comparing the virtual addresses of the 14 nodes, it means there is no node identical to the target node. If it is greater than zero, it means at least one node identical to the target node exists. If a node identical to the target node exists, the virtual addresses are reassigned to all nodes on the CAN bus.
[0104] Since the number of nodes a CAN bus can accommodate is typically capped, and this cap is fixed from the beginning. For example, if the maximum number of nodes a CAN bus can accommodate is 20, and 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 one node slot, it means that the number of nodes has exceeded the CAN bus's limit, potentially indicating unauthorized node access. In this case, the virtual addresses of all nodes are set to 0 to prevent unauthorized nodes from receiving or sending information through the CAN bus, and corresponding alarm information is generated.
[0105] This embodiment determines whether there are any unauthorized nodes by counting the cumulative number of nodes that are the same as the target node and judging whether the cumulative number exceeds the maximum number of nodes on the CAN bus. If so, the virtual address of all nodes is set to 0, thus ensuring the communication security of the nodes.
[0106] In one embodiment, the method further includes:
[0107] If a node identical to the target node exists, a request virtual address addressing frame is sent to the CAN bus;
[0108] The virtual address is reassigned to all the nodes to be addressed according to the requested virtual address addressing frame.
[0109] Once it is determined that there are nodes with the same virtual address, it indicates that the current virtual address allocation is unreasonable. At this time, the target node can send a virtual address reassignment frame to the CAN bus. The purpose of the virtual address reassignment frame is to re-address the virtual addresses of all nodes. After the virtual addresses are reassigned, the virtual address reassignment frame sending and judgment process is repeated until the virtual addresses of all nodes are unique and do not conflict.
[0110] In this embodiment, when it is determined that there are other nodes to be addressed that have the same virtual address as the target node, a request virtual address addressing frame is sent to the CAN bus, thereby re-addressing the virtual addresses of all nodes. This avoids communication chaos and management chaos caused by multiple nodes using the same virtual address for communication, and improves the management efficiency of nodes.
[0111] In one embodiment, the method further includes:
[0112] If no node is identical to the target node, then obtain the number of used nodes among all nodes; the used nodes are those nodes that have been assigned the virtual address.
[0113] Determine whether the number of nodes is greater than or equal to the preset total number of nodes.
[0114] If the number of nodes is less than the preset total number of nodes, then the number of remaining nodes is determined based on the number of nodes and the preset total number of nodes.
[0115] Each remaining node is assigned a corresponding remaining virtual address, 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] The number of nodes that a CAN bus can accommodate is limited. However, the number of nodes initially powered on may not reach the limit. Therefore, idle nodes and their corresponding idle virtual addresses can be allocated and stored first, so that they can be allocated to new nodes at any time.
[0117] For example, a CAN bus can accommodate a maximum of 20 nodes. If only 15 nodes are initially powered on, after assigning virtual addresses to these 15 nodes, only 15 of the 20 nodes will be in use, leaving 5 nodes unused on the CAN bus. Traditional methods reallocate virtual addresses to all nodes each time a new node is added, increasing allocation time and impacting communication with other nodes awaiting addressing.
[0118] Therefore, a remaining virtual address can be pre-assigned to each of the five remaining nodes. These remaining virtual addresses are different from the virtual addresses of the 15 already used nodes to avoid virtual address conflicts. These five remaining virtual addresses are then stored in the target node. If the target node receives a remaining virtual address addressing frame from the newly accessed node via the CAN bus, it allocates the remaining virtual address to the new accessed node.
[0119] This embodiment pre-allocates the remaining virtual addresses to the remaining nodes based on the maximum number of nodes that the CAN bus can accommodate, i.e., the preset total number of nodes. This allows new nodes to be directly assigned the remaining virtual addresses without needing to be re-addressed. It also ensures that the virtual addresses of new nodes do not conflict with the virtual addresses of other nodes to be addressed, thus improving node management efficiency.
[0120] Referring to Figure 5, step S103 includes: steps S1031-S1032.
[0121] S1031. Generate a real address addressing frame based on 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, a real address addressing frame can be generated based on the target virtual address, and then the sequence number can be obtained from 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 through methods such as encoding conversion.
[0124] Referring to Figure 6, step S103 also includes steps S1033-S1035.
[0125] S1033. Obtain the sequence number of all nodes, sort the sequence numbers of all nodes, and obtain the sorting result.
[0126] S1034. Determine the sorting position of the target node in the sorting result.
[0127] S1035. Assign the real address to the target node according to the sorting position.
[0128] After acquiring the serial number, the target node sends it to other nodes awaiting addressing in the form of a real address addressing frame. Correspondingly, the other nodes also send their corresponding real address addressing frames via the CAN bus. Based on its own serial number and the serial numbers of the other nodes awaiting addressing, the target node assigns itself a real address according to a preset allocation rule.
[0129] For example, if there are 15 nodes, taking one target node as an example, after receiving the real address addressing frames sent by the other 14 nodes, the target node can obtain the sequence numbers of these 14 nodes from the real address addressing frames, and then combine them with its own sequence number to generate an array containing 15 sequence numbers. Then, based on the position of the target node in these 15 sequence numbers, the real address of the target node can be determined.
[0130] For example, after generating an array based on the sequence numbers of the 15 nodes mentioned above, the 15 sequence numbers in the array are sorted, such as from largest to smallest, to obtain the sorting result. The target node determines its target sequence number's position in the sorting result based on the sorting result, and then assigns itself a real address based on the node position.
[0131] For example, if the target node is ranked third in the sorting results, since the serial numbers of the 15 nodes corresponding to the products are fixed, and the order of the serial numbers is also fixed, the serial number can be regarded as the physical address of the product. Considering that products usually mark their serial numbers on the outside of the product 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 the target node is determined to be the first node among the 15 nodes, it is assigned a first-ranked physical address. If the target node is the second-ranked node among the 15 nodes, it is assigned a second-ranked physical address, and so on. This ensures a one-to-one correspondence between the node's physical address and its sequence number. The node's physical address is assigned based on communication requirements and does not actually exist; therefore, it can be considered a type of virtual address. In other words, this embodiment achieves a one-to-one correspondence between the node's virtual address and its physical address.
[0133] This embodiment sorts the sequence numbers of all nodes to determine the target node's position in the sequence numbers, and then assigns a real address to the target node according to the sort position. This achieves a one-to-one correspondence between the node's real address and the sequence number, preventing the node's address from changing due to re-addressing, and greatly improving the node management efficiency.
[0134] In one embodiment, the method further includes:
[0135] The system receives real address heartbeat frames sent by other nodes to be addressed via the CAN bus.
[0136] Based on the real address heartbeat frame, determine whether the target real address of the target node is the same as the real address of other nodes to be addressed.
[0137] If at least one is identical, a request real address addressing frame is sent to the CAN bus, and the real addresses of all nodes are re-addressed according to the request real address addressing frame.
[0138] After the real addresses are assigned, 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 via the CAN bus. Each node can also receive real address heartbeat frames sent by other nodes, thereby determining 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, virtual addresses can also be verified using heartbeat frames. Since the real address is determined based on the virtual address, if the virtual addresses of different nodes are the same or conflict, both the virtual and real addresses need to be re-addressed.
[0140] This embodiment uses heartbeat frames to periodically detect the real addresses of each node, avoiding the use of the same real address by different nodes, which would lead to chaotic information exchange and node management, and thus improve the efficiency of node management.
[0141] Referring to Figure 7, this embodiment also provides a multi-node addressing system 700, including:
[0142] The receiving module 701 is used to receive virtual address addressing frames sent by other nodes to be addressed via the CAN bus; the virtual address addressing frames are generated based on the virtual addresses of each node 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 target node among other nodes to be addressed that is the same as the target node based on the comparison result;
[0144] Addressing module 703 is used to determine a sequence number based on the target virtual address of the target node if the target node does not exist, and to assign a real address to the target node based on the sequence number.
[0145] It is understood that any of the above-described multi-node addressing methods are 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 limitations; therefore, other examples of exemplary embodiments may have different values.
[0147] It should be noted that similar labels and letters in the following figures indicate similar items. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures.
[0148] The above-described embodiments are merely illustrative of several implementations of the present invention, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of the invention. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of the present invention, and these modifications and improvements all fall within the scope of protection of the present invention.
Claims
1. A multi-node addressing method, characterized in that, Applied to target nodes, where each target node is an addressable node on the CAN bus, and each addressable node has a virtual address, including: The system receives virtual addressing frames sent by other nodes to be addressed via the CAN bus; the virtual addressing frames are generated based on the virtual addresses of each node to be addressed. The received virtual address addressing frame is compared with the target virtual address addressing frame of the target node, and the comparison result is used to determine whether there is a target node among other nodes to be addressed that is the same as the target node. If it does not exist, then determine the sequence number based on the target virtual address of the target node, and assign a real address to the target node based on the sequence number.
2. The multi-node addressing method according to claim 1, characterized in that, Determining the sequence number based on the target virtual address of the target node includes: A real address addressing frame is generated based on the target virtual address; the source address of the real address addressing frame is the target virtual address. The sequence number is obtained through the real address addressing frame; the target byte of the real address addressing frame is the sequence number.
3. The multi-node addressing method according to claim 1, characterized in that, The step of assigning a real address to the target node according to the sequence number includes: Obtain the sequence number of all nodes, sort the sequence numbers of all nodes, and obtain the sorting result; Determine the sorting position of the target node in the sorting result; The real address is assigned to the target node according to the sorting position.
4. The multi-node addressing method according to claim 1, characterized in that, The step of determining whether there exists a node to be addressed that is identical to the target node based on the comparison results includes: Determine whether each received virtual address addressing frame is the same as the target virtual address addressing frame; If at least one is the same, then it is determined that there are identical nodes to be addressed; If all are different, then it is determined that there are no identical nodes to be addressed.
5. The multi-node addressing method according to claim 4, characterized in that, The method further includes: If a node to be addressed exists that is identical to the target node, a request virtual address addressing frame is sent to the CAN bus; The virtual address is reassigned to all the nodes to be addressed according to the requested virtual address addressing frame.
6. The multi-node addressing method according to claim 4, characterized in that, The method further includes: Obtain the cumulative number of virtual addressing frames that are identical to the target virtual addressing frame; If the cumulative number is greater than or equal to the preset total number of nodes, then the virtual addresses of all nodes are set to zero, and an error alert is generated.
7. The multi-node addressing method according to claim 1, characterized in that, The method further includes: The target virtual address addressing frame is sent to the CAN bus according to the first preset cycle; Obtain the number of times the target virtual address addressing frame has been sent, and determine whether the number of times it has been sent is greater than or equal to a preset number; If the number of transmissions is less than the preset number, then the target virtual address addressing frame will continue to be transmitted according to the first preset period; If the number of transmissions is greater than or equal to the preset number of transmissions, the target virtual address addressing frame is transmitted to the CAN bus according to the 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 includes: If no addressable node is found that is identical to the target node, then the number of used nodes among all nodes is obtained; the used nodes are those that have been assigned the virtual address. Determine whether the number of nodes is greater than or equal to the preset total number of nodes; If the number of nodes is less than the preset total number of nodes, then the number of remaining nodes is determined based on the number of nodes and the preset total number of nodes; Each remaining node is assigned a corresponding remaining virtual address, 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 includes: If a remaining virtual address addressing frame is received from a new access node on the CAN bus, the remaining virtual address is assigned to the new access node.
10. The multi-node addressing method according to claim 1, characterized in that, The method further includes: Receive real address heartbeat frames sent by other nodes to be addressed via the CAN bus; Based on the real address heartbeat frame, determine whether the target real address of the target node is the same as the real address of other nodes to be addressed; If at least one is identical, a request real address addressing frame is sent to the CAN bus, and the real addresses of all nodes are re-addressed according to the request real address addressing frame.
11. A multi-node addressing system, characterized in that, include: The receiving module is used to receive virtual addressing frames sent by other nodes to be addressed via the CAN bus; The virtual addressing frame is generated based on the virtual address of each of the nodes to be addressed; The comparison module 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 target node among other nodes to be addressed that is the same as the target node based on the comparison result; The addressing module is used to determine a sequence number based on the target virtual address of the target node if the target node does not exist, and to assign a real address to the target node based on the sequence number.
Citation Information
Patent Citations
Automatic addressing method and system of CAN bus
CN106547223A
Intelligent addressing method and device for bus component and computer equipment
CN110035137A
Node addressing system, method and device
CN110474993A
Node address allocation method and device based on CAN communication
CN118101622A
Multi-node addressing method and system
CN119420596A