Node device, can communication network system, and processing method

CN122909063APending Publication Date: 2026-10-13SHENZHEN TOPBAND CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611212447.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-11
Publication Date
2026-10-13

AI Technical Summary

Technical Problem

[0011]本申请的主要目的在于提供一种节点设备、CAN通信网络系统及处理方法,旨在解决现有CAN总线组网中终端电阻接入状态无法在线实时监测、依赖人工及外部仪器排查,导致在设备发生物理移除与通信失联时无法有效区分工况并导致终端电阻管理失控的技术问题

Benefits of technology

本申请提供的节点设备,通过设置上游监测线路和上游监测输入模块,使单个节点设备具备对上游邻居节点设备终端电阻接入状态的硬件级实时感知能力。节点设备无需依赖人工现场核查、无需借助万用表或专用CAN分析仪等外部测量仪器,即可通过硬件电平检测的方式,直接获知上游邻居节点设备的终端电阻是否已接入CAN总线,从根本上解决了终端电阻状态不可知、不可感的技术难题。同时,节点设备通过上游监测线路获取的监测状态,可作为原始数据上报至主机,为主机进行全网终端电阻状态的汇总分析和决策提供硬件基础,使得终端电阻管理从开环人工配置升级为闭环自动监测。此外,该节点设备仅需在现有CAN总线设备的基础上增设一根上游监测线路及其对应的输入检测模块,无需额外增加复杂的传感器或测量电路,硬件改动小、成本可控,便于在各类CAN总线设备中推广应用。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122909063A_ABST
    Figure CN122909063A_ABST
Patent Text Reader

Abstract

The application discloses a node device, a CAN communication network system and a processing method, and relates to the technical field of controller area network communication. The node device comprises a CAN transceiver, a terminal resistor, an upstream monitoring circuit and an upstream monitoring input module, and is used for monitoring whether an upstream neighbor node device has connected the terminal resistor to a CAN bus. The system comprises a host computer and a plurality of slave computers. In the processing method, the slave computers report CAN communication states and upstream monitoring states to the host computer, the host computer cross-analyzes the states and distinguishes two working conditions of physical removal and communication disconnection, and dynamically adjusts a terminal resistor connection strategy. The application realizes online automatic monitoring of a terminal resistor connection state, and ensures that the CAN bus always has accurate impedance matching.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of controller area network communication technology, and in particular to node devices, CAN communication network systems and processing methods. Background Technology

[0002] Controller Area Network (CAN) bus is a highly reliable serial communication bus widely used in the automotive industry, elevator control, energy storage systems, industrial automation, rail transportation, and other fields. The CAN bus uses a bus topology and differential signal transmission at the physical layer (CAN_H and CAN_L). A 120Ω terminating resistor must be connected to each end of the bus to suppress signal reflections and ensure impedance matching, thereby ensuring the stability and reliability of high-speed communication.

[0003] In a typical multi-device CAN networking system, each device (node) is connected to CAN_H and CAN_L via a bus transceiver. The management of terminating resistors is a fundamental prerequisite for ensuring the normal operation of the CAN bus. In existing technologies, the configuration methods for terminating resistors mainly include the following categories: (1) Fixed terminating resistor connection scheme: A 120Ω resistor is fixedly soldered onto the internal PCB of the two devices at the physical end of the CAN bus, or the connection of the terminating resistor to the bus is selected by jumper caps or DIP switches. This type of scheme is simple in structure and low in cost, but when the end device is removed, damaged or replaced in the field, the terminating resistor at the end of the bus will disappear along with it, resulting in only one end of the CAN bus or no terminating resistor at all, severe signal reflection, and a sharp drop in communication quality or even complete interruption. In addition, it is difficult for maintenance personnel to intuitively judge the actual connection status of the terminating resistor on the bus, making fault diagnosis difficult.

[0004] (2) Automatic access scheme based on mechanical or electrical plug detection: Some existing technologies use mechanical or electrical methods to determine whether a device is a terminal device by checking the connection plugs between nodes. If it is a terminal device, the terminating resistor is automatically connected via a relay or physical switch. For example, some schemes determine whether a device is a terminal device or an intermediate device by detecting whether plugs are inserted in both sockets. However, these schemes are mainly for automatic configuration during the system installation phase. If cable disconnection or damage to the terminal device occurs during system operation, the original terminal device judgment logic may fail. For example, when the cable between CAN node n-1 and CAN node n is disconnected, the original terminal device n has been disconnected and the terminating resistor is lost. Node n-1 becomes the new terminal node, but since plugs are still inserted in both sockets of node n-1, its terminating resistor cannot be automatically connected.

[0005] (3) Remote control scheme for terminating resistors based on software commands: Some CAN bus devices support remote control of the connection and disconnection of the local terminating resistors via CAN messages or configuration software. Although this type of scheme achieves remote control, it still requires manual intervention from the host computer or main control device to issue commands, and cannot autonomously detect and automatically adjust when the device is offline, communication is abnormal, or it is physically removed.

[0006] (4) Termination resistor diagnostic scheme based on electrical parameter detection: Existing technologies also propose to determine whether the connection circuit of the termination resistor is abnormal by outputting a predetermined current to the CAN bus circuit and collecting the voltage value across the termination resistor. For example, when the voltage value is greater than the first preset threshold, it is determined that the connection circuit of the termination resistor has been broken or the number of termination resistors connected is less than 2; when the voltage value is less than the second preset threshold, it is determined that the connection circuit of the termination resistor has been short-circuited or the number of termination resistors connected is greater than 2. This type of scheme can diagnose the abnormal state of the termination resistor, but it is essentially still a fault detection rather than real-time online monitoring, and it cannot continuously and automatically manage the connection status of the termination resistor during normal system operation.

[0007] In summary, existing technologies have the following technical shortcomings in terminal resistance management: (i) Lack of real-time autonomous monitoring capability for terminating resistor status. Existing technologies generally use fixed soldering, DIP switches, or jumper caps to configure terminating resistors. Whether the terminating resistor is connected and which device is currently connected depends entirely on manual on-site verification or pre-designed drawings. When equipment failure occurs during system operation or the equipment is removed during on-site maintenance, the terminating resistor at the end of the bus may be disconnected from the bus along with the end device. The system cannot autonomously detect this change, leading to CAN bus impedance mismatch, increased signal reflection, higher communication error rate, and even bus paralysis.

[0008] (II) Existing terminal resistance monitoring methods rely on manual operation or external measuring instruments. Current terminal resistance monitoring solutions mainly include manual on-site measurement by maintenance personnel using multimeters or offline data acquisition using dedicated CAN analyzers. These methods are all external intervention-based detection, cannot be integrated into the equipment itself, and cannot achieve online, real-time, and automated monitoring and control. In enclosed or hazardous environments such as energy storage power stations and elevator shafts, manual on-site measurement is inefficient, poses high safety risks, and cannot provide continuous monitoring while the system is running.

[0009] (III) Inability to distinguish between physical removal of equipment and communication failure. In a CAN system with multiple cascaded devices, when communication between a slave device and the master device is interrupted, existing technologies struggle to determine whether the interruption is caused by a power outage or physical removal of the device itself, or by a communication line fault or electromagnetic interference. These two scenarios have completely different impacts on the terminating resistor management strategy: if the device is physically removed, the original terminating device disappears, and a new terminating device needs to take over the terminating resistor; if only communication is lost but the device remains physically online, the terminating resistor of the original terminating device remains valid and does not need to be changed. Existing technologies lack effective hardware-level monitoring methods to distinguish between these two scenarios, often leading to misjudgments. Specifically, during physical removal, the terminating resistor may not be migrated to the new terminating device in a timely manner, or during communication failure, the terminating resistor of a still physically online terminating device may be mistakenly disconnected, resulting in CAN bus impedance mismatch.

[0010] The above content is only used to help understand the technical solution of this application and does not represent an admission that the above content is prior art. Summary of the Invention

[0011] The main purpose of this application is to provide a node device, a CAN communication network system, and a processing method, which aims to solve the technical problem that the connection status of the terminating resistor in the existing CAN bus network cannot be monitored online in real time, and relies on manual and external instruments for troubleshooting. This results in the inability to effectively distinguish the working conditions when the device is physically removed or communication is lost, leading to the loss of control over the management of the terminating resistor.

[0012] To achieve the above objectives, this application proposes a node device, the node device comprising: A CAN transceiver is used to connect to the CAN bus. Terminating resistor; Upstream monitoring lines are used to connect to upstream neighboring node devices; The upstream monitoring input module is used to monitor, through the upstream monitoring line, whether the upstream neighbor node device has connected the terminating resistor to the CAN bus.

[0013] In one embodiment, the node device further includes: A terminating resistor control module is used to control the terminating resistor to connect to the CAN bus; The control circuit of the terminal resistor control module is reused as the upstream monitoring circuit of the downstream neighbor node device, so that the downstream neighbor node device can determine whether the upstream neighbor node device has connected the terminal resistor to the CAN bus by the control signal status in the control circuit.

[0014] Furthermore, to achieve the above objectives, this application also proposes a CAN communication network system, which includes: One host and several slave devices, wherein the slave devices are node devices as described above.

[0015] Furthermore, to achieve the above objectives, this application also proposes a processing method applied to the CAN communication network system described above, the processing method comprising: Each of the slave devices reports its CAN communication status and the upstream monitoring status of its upstream neighbor node devices to the host. The host determines the communication status of each slave device based on the CAN communication status reported by each slave device and the upstream monitoring status.

[0016] In one embodiment, the host determines the communication status of each slave device based on the CAN communication status reported by each slave device and the upstream monitoring status, including: If the CAN communication status of the target slave device is disconnected, and the upstream monitoring status reported by the downstream neighbor node device of the target slave device is not connected, then it is determined that the target slave device is in a communication state that has been physically removed.

[0017] In one embodiment, the host determines the communication status of each slave device based on the CAN communication status reported by each slave device and the upstream monitoring status, further comprising: If the CAN communication status of the target slave device is out of contact, and the upstream monitoring status reported by the downstream neighbor node device of the target slave device is in the access status, then the target slave device is determined to be in a communication state where communication is out of contact but physically online.

[0018] In one embodiment, after each slave device reports its CAN communication status and the upstream monitoring status of its upstream neighbor node device to the host, the method further includes: The host establishes the network topology of the CAN communication network and determines the end slave in the network topology based on the CAN communication status reported by each slave and the upstream monitoring status.

[0019] In one embodiment, after establishing the network topology of the CAN communication network and determining the end slave devices in the network topology, the method further includes: When the host determines that the communication status of the end slave has been physically removed, or when it determines that a new end slave is being added, it controls the new end slave to connect its terminating resistor to the CAN bus.

[0020] In one embodiment, the processing method further includes: During the power-on addressing phase of the node device, the host configures the addressing address of each slave device through the upstream monitoring line of each slave device.

[0021] In one embodiment, configuring the addressing addresses of each of the slave devices includes: The slave device receives the first address of the slave device through the upstream monitoring line, constructs the second address of the downstream neighbor node device based on the first address, and transmits the second address to the downstream neighbor node device through the upstream monitoring line of the downstream neighbor node device.

[0022] In addition, to achieve the above objectives, this application also proposes a storage medium, which is a computer-readable storage medium, on which a computer program is stored, and which, when executed by a processor, implements the steps of the processing method described above.

[0023] In addition, to achieve the above objectives, this application also provides a computer program product, which includes a computer program that, when executed by a processor, implements the steps of the processing method described above.

[0024] One or more technical solutions proposed in this application have at least the following technical effects: The node device provided in this application, by setting up an upstream monitoring line and an upstream monitoring input module, enables a single node device to possess the hardware-level real-time sensing capability of the terminal resistance connection status of upstream neighboring node devices. The node device can directly determine whether the terminal resistance of upstream neighboring node devices has been connected to the CAN bus through hardware level detection without relying on manual on-site verification or external measuring instruments such as multimeters or dedicated CAN analyzers, fundamentally solving the technical problem of unknowable and undetectable terminal resistance status. Simultaneously, the monitoring status obtained by the node device through the upstream monitoring line can be reported to the host as raw data, providing the hardware foundation for the host to summarize, analyze, and make decisions regarding the terminal resistance status of the entire network, thus upgrading terminal resistance management from open-loop manual configuration to closed-loop automatic monitoring. Furthermore, this node device only requires adding one upstream monitoring line and its corresponding input detection module to the existing CAN bus device, without the need for additional complex sensors or measurement circuits. The hardware modification is minimal, the cost is controllable, and it is easy to promote and apply in various CAN bus devices.

[0025] The CAN communication network system provided in this application achieves systematic and real-time monitoring of the entire network's terminating resistor access status through a master-slave system architecture and a chain-like monitoring network formed by upstream monitoring lines between each node device. Based on the node devices, the system aggregates the upstream monitoring status of all slave devices to the master, forming a digital view of the terminating resistor access status covering all nodes in the network. The master can continuously acquire the upstream status information monitored by each slave device during system operation, thereby gaining real-time insight into the distribution of terminating resistor access across the entire network. Simultaneously, the system provides architectural support for centralized decision-making and precise control by the master. The master can acquire the reported status of all slave devices and perform comprehensive analysis based on the CAN communication status of each slave device, providing a complete data aggregation and command issuance channel for subsequent determination of whether a device has been physically removed or communication has been lost, and for deciding which slave device should connect to the terminating resistor. Furthermore, the system only requires a unidirectional chain-like upstream monitoring line connection between devices, without relying on complex ring wiring or additional dedicated measurement buses. When the number of devices increases or decreases, the monitoring link can be extended or truncated accordingly. The system architecture is simple and clear, suitable for modular and scalable CAN networking scenarios.

[0026] The processing method provided in this application operates in the aforementioned CAN communication network system. Through cross-correlation analysis of the CAN communication status reported by each slave device and the upstream monitoring status, the method accurately distinguishes between two fault conditions: physical removal of the device and loss of communication. This method establishes a two-dimensional cross-judgment logic: when the target slave device's CAN communication status is lost and its downstream neighboring node device reports an unconnected upstream monitoring status, the target slave device is determined to have been physically removed; when the target slave device's CAN communication status is lost, but its downstream neighboring node device reports an still connected upstream monitoring status, the target slave device is determined to have only lost communication but is still physically online. Based on accurate condition judgment results, when the end device is physically removed, the method controls the new end slave device to automatically connect to the terminating resistor; when the device only loses communication, the original end device's terminating resistor connection status remains unchanged, ensuring that there are always exactly two terminating resistors normally connected at both ends of the CAN bus. This avoids incorrect configurations of three or only one terminating resistor due to misjudgment, fundamentally eliminating the risk of signal reflection, communication errors, and bus paralysis caused by impedance mismatch. This method enables CAN networks to have intelligent management capabilities of self-sensing, self-discrimination, and self-adjustment. Under complex working conditions such as equipment failure, hot-swapping during on-site maintenance, and online system expansion, it can automatically complete the dynamic adjustment of terminal resistor configuration without manual intervention, significantly shortening fault recovery time and reducing operation and maintenance costs. It is especially suitable for application scenarios with extremely high requirements for communication reliability and maintainability, such as energy storage systems, elevator group control, and automotive electronics. Attached Figure Description

[0027] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0028] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0029] Figure 1 This is a schematic diagram of the structure of the CAN communication network system provided in the embodiments of this application; Figure 2 A flowchart illustrating the processing method provided in an embodiment of this application; Figure 3 A flowchart illustrating the address configuration method provided in this application embodiment; Appendix Figure 4 This is a schematic diagram of the internal circuit structure of a node device in a CAN communication network system provided in an embodiment of this application.

[0030] The purpose, features, and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation

[0031] It should be understood that the specific embodiments described herein are merely illustrative of the technical solutions of this application and are not intended to limit this application.

[0032] To better understand the technical solution of this application, a detailed description will be provided below in conjunction with the accompanying drawings and specific implementation methods.

[0033] This application embodiment provides a node device, the node device comprising: A CAN transceiver is used to connect to the CAN bus. Terminating resistor; Upstream monitoring lines are used to connect to upstream neighboring node devices; The upstream monitoring input module is used to monitor, through the upstream monitoring line, whether the upstream neighbor node device has connected the terminating resistor to the CAN bus.

[0034] This embodiment provides a node device for monitoring and controlling the connection status of terminal resistors in a CAN communication network.

[0035] The node equipment includes a CAN transceiver, terminating resistor, upstream monitoring line, and upstream monitoring input module.

[0036] A CAN transceiver is used to connect to the CAN bus, enabling data transmission and reception between node devices and the CAN bus. CAN transceivers can use CAN transceiver chips such as SN65HVD251 and TJA1050. The CAN_H and CAN_L pins of the CAN transceiver are connected to the CAN_H and CAN_L lines of the CAN bus, respectively.

[0037] The terminating resistor is a 120Ω matching resistor, its value matching the characteristic impedance of the CAN bus according to the ISO 11898-2 standard. One end of the terminating resistor is connected to the CAN_H bus, and the other end is connected to the CAN_L bus via an electronic switch. When the electronic switch is on, the terminating resistor is connected to the CAN bus, suppressing signal reflections and ensuring impedance matching. The value of the terminating resistor can also be adjusted appropriately according to the actual characteristic impedance of the CAN bus.

[0038] The upstream monitoring line is used to connect to upstream neighboring node devices. One end of the upstream monitoring line is connected to the input terminal of the upstream monitoring input module of the current node device, and the other end is connected to the terminal resistor control output terminal of the upstream neighboring node device. The upstream monitoring line can be implemented using single-core shielded wire or ordinary wire.

[0039] The upstream monitoring input module is used to monitor whether upstream neighboring nodes have connected their terminating resistors to the CAN bus via the upstream monitoring line. The upstream monitoring input module includes a level detection circuit that determines the terminating resistor connection status of upstream neighboring nodes by detecting the level signal on the upstream monitoring line. The level detection circuit can be implemented using a comparator, a Schmitt trigger, or a general-purpose input / output port of a microcontroller. A high level is detected, indicating that the upstream neighboring node has not connected its terminating resistor; a low level is detected, indicating that the upstream neighboring node has connected its terminating resistor. The level correspondence can also be reversed according to the actual circuit design.

[0040] The upstream monitoring input module also includes a jitter reduction unit. This unit filters and de-jitters the detected level signal to prevent misjudgments caused by transient interference on the signal line. Jitter reduction can be implemented using a hardware RC filter circuit or through software delay sampling and multiple judgments.

[0041] The node device also includes a microcontroller. The microcontroller is electrically connected to both the CAN transceiver and the upstream monitoring input module. The microcontroller is used to read the monitoring results from the upstream monitoring input module. The microcontroller can be a microcontroller chip with a GPIO interface.

[0042] The node device also includes a communication reporting module. This module reports the upstream monitoring status of the node to the host via a CAN transceiver. The communication reporting module can be integrated into a microcontroller, which runs the corresponding communication protocol stack.

[0043] The working principle of the node device is as follows: In a multi-device cascaded network, the upstream monitoring input of each node device is connected to the terminating resistor control output of its upstream neighboring node device. When the terminating resistor of the upstream neighboring node device is connected to the CAN bus, its terminating resistor control output outputs a corresponding control level (e.g., low level). The upstream monitoring input module of the current node device detects this low-level signal through the upstream monitoring line, thus determining that the terminating resistor of the upstream neighboring node device is connected. When the terminating resistor of the upstream neighboring node device is not connected, its terminating resistor control output outputs the opposite control level (e.g., high level). The current node device detects the high-level signal, thus determining that the terminating resistor of the upstream neighboring node device is not connected.

[0044] The upstream monitoring input module converts the detected level signal into a digital monitoring status signal and transmits it to the microcontroller. The microcontroller, through the communication reporting module, reports its upstream monitoring status to the host via a CAN transceiver. After the host summarizes the upstream monitoring statuses reported by all slave devices, it can grasp the terminal resistor connection status of all node devices in the entire network.

[0045] Through the above technical solution, node devices can directly determine whether the terminating resistors of upstream neighboring nodes have been connected to the CAN bus through hardware level detection without relying on manual on-site verification or external measuring instruments such as multimeters or dedicated CAN analyzers. This achieves local autonomous sensing of the terminating resistor connection status. Simultaneously, the monitoring status acquired by the node devices can be reported as raw data to the host, providing a hardware foundation for the host to summarize, analyze, and make decisions regarding the terminating resistor status across the entire network.

[0046] In a typical application scenario of this embodiment, the node device is used as a battery management unit in an energy storage system. Multiple battery management units are cascaded and networked via a CAN bus, and each battery management unit uses the node device described in this embodiment. When a battery management unit is removed from the field due to a fault, its downstream neighboring node device detects a change in the terminating resistor control level (from low to high) through the upstream monitoring line, thus sensing that the terminating resistor of the upstream device has been disconnected from the bus. This monitoring status is reported to the host via the CAN bus, providing a basis for the host to dynamically adjust the terminating resistor.

[0047] In another typical application scenario of this embodiment, the node device is used in the modular controller of the elevator control system. Multiple elevator controllers are cascaded and networked via a CAN bus, and each elevator controller uses the node device described in this embodiment. When the system needs to expand with a new elevator controller, the new device automatically establishes a monitoring line connection with the upstream device after being connected. The existing terminal devices automatically adjust the connection strategy of the terminal resistor by detecting the connection status of the new downstream device, thereby realizing the online expansion of the system.

[0048] In one feasible implementation, the node device further includes: A terminating resistor control module is used to control the terminating resistor to connect to the CAN bus; The control circuit of the terminal resistor control module is reused as the upstream monitoring circuit of the downstream neighbor node device, so that the downstream neighbor node device can determine whether the upstream neighbor node device has connected the terminal resistor to the CAN bus by the control signal status in the control circuit.

[0049] In this embodiment, the node device further includes a terminating resistor control module. The terminating resistor control module controls the connection of the terminating resistor to the CAN bus. Specifically, the terminating resistor control module outputs a control level to control the on / off state of the electronic switch, thereby controlling whether the terminating resistor is connected to the CAN bus. The control level is either high or low. When the control level is valid (e.g., high), the electronic switch is on, and the terminating resistor is connected to the CAN bus; when the control level is invalid (e.g., low), the electronic switch is off, and the terminating resistor is disconnected from the CAN bus. The validity definition of the level can be configured according to the type of electronic switch actually used.

[0050] The terminating resistor control module can be implemented using a microcontroller's general purpose input / output (GPIO) ports in conjunction with a driver circuit. The microcontroller outputs a control level via the GPIO, which is amplified by the driver circuit to drive the electronic switch on and off. The driver circuit can include a transistor amplifier circuit or a MOSFET driver circuit to provide sufficient drive current.

[0051] In this embodiment, the control line of the terminating resistor control module is multiplexed as the upstream monitoring line of the downstream neighboring node device. Specifically, the control output terminal of the terminating resistor control module of the current node device is not only connected to the local electronic switch to control the connection and disconnection of the terminating resistor, but also connected to the upstream monitoring input terminal of the downstream neighboring node device through a physical line. In this way, the downstream neighboring node device can determine whether the current node device (i.e., its upstream neighboring node device) has connected the terminating resistor to the CAN bus by the control signal status in this control line.

[0052] The control line is multiplexed as an upstream monitoring line as follows: The control level signal output by the terminating resistor control module of the current node device is applied to the control terminal of the electronic switch to control the on / off state of the terminating resistor; simultaneously, it is directly transmitted to the upstream monitoring input module of the downstream neighboring node device through this control line. The upstream monitoring input module of the downstream neighboring node device detects the level signal on this control line and determines the connection status of the terminating resistor of the upstream neighboring node device based on the level. When a valid control level is detected, it is determined that the terminating resistor of the upstream neighboring node device is connected; when an invalid control level is detected, it is determined that the terminating resistor of the upstream neighboring node device is not connected.

[0053] This multiplexing design eliminates the need for additional dedicated monitoring signal lines. Simply connecting the terminating resistor control output to the upstream monitoring input of the downstream device simultaneously enables both local control of the terminating resistor and status transmission to the downstream device. Specifically, the terminating resistor control module of the current node device, while controlling the connection of its own terminating resistor, naturally indicates whether the terminating resistor is connected through the level of its control output. The downstream device directly reads this level to obtain the connection information of the upstream device's terminating resistor. Thus, the control circuit simultaneously performs the dual functions of local terminating resistor control and upstream connection status transmission.

[0054] The advantages of this multiplexing structure are as follows: First, it reduces the number of independent monitoring signal lines, thereby lowering the cost of wiring harnesses and the number of connector pins, resulting in a significant cumulative effect in multi-device cascading networks. Second, it simplifies the connection between devices, requiring only the connection between the control output of the upstream device and the monitoring input of the downstream device, without the need for additional configuration of monitoring signal routing. Third, the monitoring information and control information originate from the same source, and the monitored level status truly reflects the actual status of the control output, eliminating the problem of information inconsistency and ensuring the accuracy of the monitoring results.

[0055] To ensure the reliability of signal transmission after the control line is multiplexed as a monitoring line, the driving end of the control line should have sufficient driving capability to drive the upstream monitoring input module of downstream equipment. Specifically, the output stage of the terminating resistor control module should be able to provide sufficient current and voltage to ensure that the signal level does not shift due to line loss or load effects during transmission. When an optocoupler is used as an electronic switch, the input end (LED side) of the optocoupler is driven by the control level, and the level state of its control output end corresponds to the on / off state of the optocoupler. Downstream equipment can determine the connection status of the upstream terminating resistor by detecting the level of the optocoupler output end.

[0056] The control output of the terminating resistor control module should be configured as either push-pull or open-drain output. When using open-drain output, an external pull-up resistor is required to ensure a defined voltage level during downstream device monitoring.

[0057] In practical applications, the transmission distance of control lines should be kept within a reasonable range. For most industrial field applications, the cascade distance between devices is usually within a few meters, and the transmission delay and attenuation of level signals on the control lines can be ignored. For long-distance transmission applications, level buffers or drive enhancement circuits can be added to the control lines to ensure signal quality.

[0058] The electronic switch preferably uses the LTV-172A type optocoupler.

[0059] In this embodiment, when the node device is operating normally, if it needs to connect a terminating resistor, the terminating resistor control module outputs a valid control level. This activates the device's electronic switch, connecting the terminating resistor to the CAN bus. Simultaneously, this valid level is transmitted to downstream neighboring node devices via control lines, allowing the downstream devices to detect that the terminating resistor is connected. If the device does not need to connect a terminating resistor, the terminating resistor control module outputs an invalid control level. This activates the device's electronic switch, disconnecting the terminating resistor from the CAN bus. Furthermore, this invalid level is transmitted to downstream neighboring node devices, allowing the downstream devices to detect that the terminating resistor is not connected.

[0060] In this way, each device can not only autonomously control the connection status of its terminating resistor, but also transmit this status to downstream devices in real time, forming a chain-like status transmission channel from the beginning to the end. By aggregating the upstream monitoring status reported by each slave device, the host can grasp the terminating resistor connection status of all node devices in the entire network.

[0061] This application provides a CAN communication network system, the CAN communication network system comprising: One host and several slave devices, wherein the slave devices are node devices as described above.

[0062] This embodiment provides a CAN communication network system.

[0063] The CAN communication network system includes one master unit and several slave units, where the slave units are the node devices described in the preceding embodiments. The master unit and slave units constitute the nodes in the CAN communication network, and the nodes are connected for communication via the CAN bus.

[0064] The master device is located at the physical beginning of the CAN bus. During normal system operation, the master's terminating resistor is always connected to the CAN bus to ensure impedance matching at the bus beginning. The master device does not need an upstream monitoring input module, as it is the beginning device and there are no other upstream devices requiring monitoring. The master's terminating resistor control module always outputs a valid control level, keeping the master's terminating resistor connected.

[0065] Slave devices are node devices other than the master device. Each slave device includes a CAN transceiver, terminating resistor, upstream monitoring line, upstream monitoring input module, and terminating resistor control module. Each slave device is connected to the terminating resistor control output of its upstream neighbor node device via its upstream monitoring line, thereby enabling it to monitor the terminating resistor connection status of the upstream neighbor node device. The terminating resistor control output of each slave device is connected to the upstream monitoring input of its downstream neighbor node device, thereby transmitting its own terminating resistor connection status information to the downstream neighbor node device.

[0066] The devices form a chain monitoring structure via upstream monitoring lines. Specifically, starting from the first master unit, the master unit's terminating resistor control output is connected to the upstream monitoring input of the first slave unit; the first slave unit's terminating resistor control output is connected to the upstream monitoring input of the second slave unit; the second slave unit's terminating resistor control output is connected to the upstream monitoring input of the third slave unit; and so on, until the last slave unit. The terminating resistor control output of the last slave unit is left floating and not connected to any downstream devices.

[0067] In this chain-like monitoring structure, each device can sense the terminating resistor connection status of its upstream neighboring nodes. Specifically, device k detects the level of the terminating resistor control output of device k-1 (the upstream neighbor) through its upstream monitoring line, thereby determining whether the terminating resistor of device k-1 is connected to the CAN bus. Device k's own terminating resistor connection status is then transmitted to device k+1 (the downstream neighbor) through its terminating resistor control output. Thus, in the entire network, except for the head host, the terminating resistor connection status of each device is sensed by its downstream neighboring devices.

[0068] Each slave device also includes a communication reporting module, which reports its upstream monitoring status to the master device via a CAN transceiver. Specifically, each slave device sends a reporting message to the master device via the CAN bus at a predetermined period, for example, every 100 milliseconds. The reporting message includes at least the slave device's upstream monitoring status, that is, the connection status of the terminating resistor of the upstream neighbor node device detected by the slave device through the upstream monitoring line. The reporting message may also include the slave device's terminating resistor control status, that is, whether the slave device's own terminating resistor is currently connected or disconnected.

[0069] The host system includes a receiving and summarizing module and a decision control module. The receiving and summarizing module receives upstream monitoring status reports from all slave devices via the CAN bus. After receiving the reports from each slave device, the receiving and summarizing module stores the upstream monitoring status of each slave device in the host's cache, forming a status table of the terminal resistor access status of all nodes in the network. Because each slave device reports periodically, the status table in the host's cache is updated in real time with each report, enabling the host to monitor the access status of all terminal resistors in the network in real time.

[0070] The decision control module is used to perform comprehensive analysis and decide on the network-wide terminal resistor control strategy based on the upstream monitoring status of each slave device summarized by the receiving and summarizing module. The decision control module is also used to send control commands to the target slave device via the CAN bus when it is necessary to change the terminal resistor connection status, controlling the target slave device to connect or disconnect its terminal resistor.

[0071] Specifically, by analyzing the upstream monitoring status of each slave device, the host can determine whether each node in the network is online and the terminating resistor connection status of each node. For example, if the upstream monitoring status of a slave device is "connected," it means that the terminating resistor of its upstream neighbor node device has been connected to the CAN bus; if it is "not connected," it means that the terminating resistor of its upstream neighbor node device has not been connected. The host establishes a complete view of the terminating resistor connection status of the entire network by summarizing the upstream monitoring status of all slave devices.

[0072] By analyzing the CAN communication status of each slave device (i.e. whether the host can receive the reported messages from each slave device normally) and combining the upstream monitoring status of each slave device, the host can accurately distinguish whether each slave device is online normally, has lost communication, or has been physically removed.

[0073] Specifically, the host maintains communication status records for each slave device. If the host does not receive a report from a slave device for a predetermined period of time (e.g., 500 milliseconds), it determines that the slave device's CAN communication status is lost. At this time, the host further combines the upstream monitoring status reported by the downstream neighboring node device of the slave device to make a judgment: if the upstream monitoring status reported by the downstream neighboring node device is "not connected," it means that the slave device's terminating resistor control signal has disappeared, indicating that the slave device has been physically removed; if the upstream monitoring status reported by the downstream neighboring node device is "connected," it means that the slave device's terminating resistor control signal still exists, indicating that the slave device is only communicationally lost but is still physically online.

[0074] After the host determines that a slave device has been physically removed, the decision control module further determines whether the slave device is the end slave device in the current network. If the slave device is the end slave device, the host sends a control command to the new end slave device (i.e., the direct upstream neighbor of the removed device) to control its connection to the terminating resistor, so as to take over the function of the terminating resistor of the removed device and ensure that there is still a terminating resistor connected at the end of the CAN bus.

[0075] When the host detects that a new slave device has been added to the system (i.e., a new slave device has been added after the end slave device), the host senses the topology change by receiving reports from each slave device. The newly connected slave device automatically establishes a monitoring line connection with the upstream device after power-on and reports its upstream monitoring status to the host. After identifying the new device based on the reported information, the host controls the original end slave device to disconnect its terminating resistor, and the new end slave device connects to the terminating resistor.

[0076] Through the above system architecture, the host can continuously acquire upstream status information monitored by each slave device during system operation, and monitor the connection distribution of the entire network's terminating resistors in real time. Simultaneously, the host can make centralized decisions based on the aggregated information and send control commands to each slave device via the CAN bus, achieving unified management and dynamic control of the entire network's terminating resistors.

[0077] In this embodiment, the CAN communication network system can have two or more devices. When the system contains only one master and one slave, the slave is the end slave, and its terminating resistor is connected to the CAN bus, forming the matching resistors at both ends of the CAN bus together with the master's terminating resistor. When the system contains multiple slaves, only the terminating resistor of the end slave is connected, while the terminating resistors of the other slaves are disconnected, ensuring that there are exactly two terminating resistors at both ends of the CAN bus.

[0078] The chain-like monitoring structure of this system offers excellent scalability. When a new slave device needs to be added, it simply needs to be connected downstream of the original slave device, and its upstream monitoring input connected to the terminating resistor control output of the original slave device. Upon power-up, the new device automatically reports its upstream monitoring status to the host. The host then automatically updates the network topology based on the reported information and controls the original slave device to disconnect its terminating resistor and the new slave device to connect its terminating resistor. The entire process requires no manual configuration, enabling plug-and-play functionality and online expansion.

[0079] Similarly, when the system needs to remove a slave device, it simply needs to unplug the device from the network. Its downstream neighboring nodes detect the disappearance of the upstream control signal (becoming high level) through the upstream monitoring line and report this status to the host. The host automatically identifies the device removal event based on the reported information and controls the new end slave device to connect to the terminating resistor. The entire process requires no manual intervention, achieving hot-swapping support for the system.

[0080] Figure 1 This is a schematic diagram of the CAN communication network system provided in an embodiment of this application. Figure 1As shown, the CAN communication network system includes one master device (device 1) and multiple slave devices (devices 2 to n). These devices are cascaded sequentially via the CAN bus (including CAN_H and CAN_L lines) to form a bus-type network topology. Device 1 is located at the physical head of the entire CAN communication network, acting as the master device. Device 1's terminating resistor is always connected to the CAN bus to ensure impedance matching at the bus head. Device 1 does not have an upstream monitoring input because, as the head device, there are no other upstream devices to monitor. Devices 2, 3, 4...n are slave devices, cascaded sequentially after the master device. Device n is located at the physical tail of the entire CAN communication network, acting as the tail slave. Its terminating resistor is connected to the CAN bus to ensure impedance matching at the bus tail. The tail slave's terminating resistor control output is left floating and not connected to any downstream devices. The slave devices form a chain monitoring structure through upstream monitoring lines. Each slave's upstream monitoring input is connected to the terminating resistor control output of its upstream neighboring node device, thus enabling monitoring of the terminating resistor connection status of the upstream neighboring node device. Each slave device periodically reports its upstream monitoring status to the master device, which then uses the aggregated information to monitor the distribution of terminal resistors across the entire network in real time.

[0081] A typical application scenario for this system is the networking of battery management units in an energy storage system. In large-scale energy storage power stations, battery clusters are composed of multiple cascaded battery management units, each acting as a CAN node. As the capacity of the energy storage system expands, the number of battery management units needs to be dynamically increased or decreased. Using the CAN communication network system of this embodiment, the various battery management units form a chain monitoring structure through upstream monitoring lines. The host (usually the battery cluster management unit) can monitor the online status and terminating resistor connection status of each battery management unit in real time, and automatically adjust the terminating resistor configuration when battery management units are added or removed, ensuring the reliability of CAN communication.

[0082] Another typical application scenario for this system is the modular controller networking of elevator control systems. In elevator control systems, multiple floor controllers are cascaded via a CAN bus, with each floor controller acting as a CAN node. Using the CAN communication network system of this embodiment, the floor controllers form a chain monitoring structure through upstream monitoring lines. The host can monitor the status of each floor controller in real time and automatically adjust the terminal resistor configuration when a floor controller malfunctions or is replaced, ensuring the stable operation of the elevator control network.

[0083] Compared with existing technologies such as fixed terminating resistor configuration schemes, plug-based automatic access schemes, and software command-based remote control schemes, this system has the following advantages: It achieves real-time, online, and automatic monitoring of the entire network's terminating resistor status through a chain-like monitoring structure, eliminating the need for manual intervention; it enables dynamic adaptive adjustment of terminating resistors through centralized decision-making by the host, handling various complex operating conditions such as equipment additions / removals, fault removal, and communication failures; and it reduces system cost and wiring complexity by reusing the terminating resistor control lines as monitoring lines, achieving monitoring functionality without adding extra cables.

[0084] This application provides a processing method, referring to... Figure 2 , Figure 2 This is a flowchart illustrating the first embodiment of the processing method of this application.

[0085] In this embodiment, the processing method is applied to the CAN communication network system described above, and the processing method includes steps S10~S20: Step S10: Each slave device reports its CAN communication status and the upstream monitoring status of its upstream neighbor node device to the host. Step S20: The host determines the communication status of each slave device based on the CAN communication status and the upstream monitoring status reported by each slave device.

[0086] In a CAN communication network system, each slave device sends a report message to the master device at a predetermined period. The report messages are transmitted via the CAN bus, sent from the slave device's CAN transceiver to the master. The report period can be set according to actual application requirements, for example, reporting once every 100 milliseconds or once every 200 milliseconds. The report period should not be too long to ensure the master can obtain the status information of each slave device in a timely manner; the report period should also not be too short to avoid consuming excessive CAN bus bandwidth.

[0087] The CAN communication status reported by each slave device refers to whether the CAN communication connection between the slave device and the master device has been successfully established. Specifically, when a slave device is working normally, its CAN communication status is "established," indicating that the slave device can communicate normally with the master device through the CAN bus. If a slave device cannot communicate with the master device due to its own fault, power failure, CAN transceiver damage, or CAN bus line interruption, its CAN communication status is "disconnected." Each slave device carries its own CAN communication status identifier in its report message.

[0088] The upstream monitoring status reported by each slave device refers to the connection status of the terminating resistor of the upstream neighboring node device detected by that slave device through its upstream monitoring line. Specifically, the slave device detects the level signal on the upstream monitoring line through its upstream monitoring input module. If a level indicating that the terminating resistor is connected (e.g., low level) is detected, the upstream monitoring status is connected; if a level indicating that the terminating resistor is not connected (e.g., high level) is detected, the upstream monitoring status is not connected. When sending a reporting message, each slave device carries the upstream monitoring status identifier detected by itself in its reporting message.

[0089] The reporting message can use either the standard CAN frame or extended frame format. The identifier (ID) of the reporting message can include the slave device address information so that the master can identify the source device of the reporting message. The data field of the reporting message can contain multiple status fields; for example, one byte can indicate the CAN communication status, and another byte can indicate the upstream monitoring status.

[0090] After receiving the reports from each slave device, the host identifies the source of the report based on the device address information in the report and stores the CAN communication status and upstream monitoring status in the host's cache. The host maintains a corresponding status record for each slave device, including the slave device's CAN communication status and the upstream monitoring status reported by the slave device. Since each slave device reports periodically, the status records in the host's cache are refreshed in real time as the reports are updated.

[0091] After receiving the reports from each slave device and updating the status records in the cache, the host performs a comprehensive analysis of the status of each slave device. By reading the CAN communication status of each slave device stored in the cache, the host can determine the current CAN communication connection status of each slave device. For a slave device with a CAN communication status of "established," it indicates that the CAN communication between the slave device and the host is currently normal, and the slave device is in a normal online state.

[0092] For a slave device whose CAN communication status is "out of contact," meaning the master has not received a report from the slave device within a predetermined time, it indicates that CAN communication between the slave and the master has been interrupted. In this case, the master further reads the upstream monitoring status reported by the slave device. It should be noted that this upstream monitoring status is either the status value last reported by the slave device before the communication interruption and stored in the master's cache, or the terminating resistor connection status reported by the slave device's downstream neighboring node.

[0093] The host computer combines the CAN communication status of each slave device with the upstream monitoring status to determine the actual communication status of each slave device. Specifically, the host computer performs correlation analysis between the CAN communication status of each slave device and the upstream monitoring status of that slave device to determine whether each slave device is online normally, has lost communication, or has been physically removed.

[0094] For example, for a slave device k, if its CAN communication status is established, it indicates that the slave device is online normally, and its communication status is normal. If its CAN communication status is lost, it indicates that the slave device has lost CAN communication with the master, and its communication status is abnormal. Furthermore, by combining the upstream monitoring status of the slave device, the master can preliminarily determine whether the slave device has lost communication or has been physically removed, but the specific judgment logic belongs to subsequent steps.

[0095] After the host completes the judgment of the communication status of each slave device, it stores the judgment result in the host cache as the basis for subsequent terminal resistor control decisions. The host can also display the communication status of each slave device through a human-machine interface, so that maintenance personnel can understand the operating status of each node device in the network in real time.

[0096] In practical implementation, the host can use timers or counters to determine communication timeouts. For example, the host sets a timer for each slave device, resetting the timer whenever it receives a report message from that slave. If the timer exceeds a preset timeout threshold (e.g., 500 milliseconds or 1 second) without receiving a report message from the slave, the slave's CAN communication status is determined to be "lost". The timeout threshold should be set according to the system's actual communication cycle and real-time requirements.

[0097] It should be noted that in this embodiment, steps S10 and S20 are executed continuously in a loop. Each slave device continuously reports status information to the master device according to a predetermined period, and the master device continuously receives and analyzes this information, thereby realizing real-time monitoring of the communication status of all slave devices in the network.

[0098] Using the above method, the host can obtain the CAN communication status and upstream monitoring status of all slave devices in the network in real time, and make judgments on the communication status of each slave device, providing a data basis for subsequent terminal resistor control decisions.

[0099] In one feasible implementation, step S20 includes: If the CAN communication status of the target slave device is disconnected, and the upstream monitoring status reported by the downstream neighbor node device of the target slave device is not connected, then it is determined that the target slave device is in a communication state that has been physically removed.

[0100] In this embodiment, the host determines the communication status of each slave device based on the CAN communication status reported by each slave device and the upstream monitoring status.

[0101] If the target slave device's CAN communication status is out of contact, and the upstream monitoring status reported by the downstream neighbor node device of the target slave device is not connected, then the host determines that the target slave device is in a communication state that has been physically removed.

[0102] Specifically, after receiving the report messages from each slave device, the host analyzes the status of each slave device one by one. For a target slave device (e.g., device k), the host first checks the CAN communication status of that target slave device. The CAN communication status of the target slave device is recorded in the host's buffer, and this status is determined by the host based on whether it receives a report message from the target slave device within the timeout period. If the host does not receive a report message from the target slave device within the preset timeout period, the CAN communication status of the target slave device is marked as disconnected.

[0103] After confirming that the target slave's CAN communication status is lost, the host further acquires the upstream monitoring status reported by the target slave's downstream neighbor node device (i.e., device k+1). This upstream monitoring status is the level signal detected by the downstream neighbor node device through its upstream monitoring line, and this level signal directly reflects the level status of the target slave's terminating resistor control output. The downstream neighbor node device reports this upstream monitoring status to the host at a predetermined period, and the host stores it in its cache.

[0104] If the host reads from the cache that the upstream monitoring status reported by the downstream neighbor node device is "not connected," it indicates that the terminating resistor control output of the target slave device is in an invalid level state, meaning that the terminating resistor of the target slave device is not connected to the CAN bus. If the target slave device was originally a terminal slave device or its terminating resistor was originally in the connected state, this "not connected" state indicates that the terminating resistor control signal of the target slave device has disappeared.

[0105] The host makes a comprehensive judgment based on two conditions: the target slave's CAN communication being interrupted and the upstream monitoring status reported by the target slave's downstream neighbors as "not connected." When both conditions are met simultaneously, the host determines that the target slave has not only lost communication but also its terminal resistor control signal has disappeared, indicating that the target slave has been physically removed from the network.

[0106] The principle behind this embodiment is as follows: When a device is physically removed, its physical connection to the CAN bus is severed, and its CAN transceiver can no longer send or receive CAN messages. Therefore, the host will detect that the device's CAN communication status has become disconnected. Simultaneously, the device's terminal resistor control output will no longer output a valid control level signal. The downstream neighboring node devices will detect a change in their communication level from indicating connection to indicating disconnection through the upstream monitoring line, and will report this change to the host. Therefore, the simultaneous fulfillment of both communication disconnection and downstream monitoring indicating disconnection is a sufficient condition for the physical removal of the device.

[0107] Let's take the scenario of a slave device being physically removed as an example. Assume the system includes devices 1 (master) to n (slave devices), where the terminating resistor of device n is connected to the CAN bus, and its downstream monitoring line is floating. When device n is physically removed: on the one hand, the physical connection between device n and the CAN bus is severed, its CAN transceiver no longer responds to the master's communication requests, and the master detects that device n's CAN communication status has changed to disconnected; on the other hand, the terminating resistor control signal of device n disappears along with device n, but since device n is a slave device, no downstream neighboring node can report changes in its terminating resistor connection status. At this time, the master can only determine the situation based on device n's CAN communication status being disconnected, and cannot directly determine that it has been physically removed.

[0108] However, the situation becomes clearer when the penultimate device (device n-1) is physically removed. After device n-1 is removed, the host detects that its CAN communication status is down. Simultaneously, device n, as a downstream neighbor node of device n-1, had its upstream monitoring line originally connected to the terminating resistor control output of device n-1. After device n-1 is removed, the signal at its terminating resistor control output disappears, and the level detected by device n through the upstream monitoring line changes from connected to disconnected, which device n reports to the host. Upon receiving the reported disconnected upstream monitoring status from device n, and combining this with the downed CAN communication status of device n-1, the host determines that device n-1 has been physically removed.

[0109] It should be noted that when the end slave device is physically removed, since no downstream neighboring node can report its terminating resistor connection status, the host will make a comprehensive judgment based on the communication status of device n-1 (the second to last device) and the upstream monitoring status of device n. Specifically, if device n's CAN communication status is disconnected, and device n-1's CAN communication status is established (i.e., device n-1 is still online), and device n-1's terminating resistor was not originally connected (because the end device is device n), then the host can determine that device n has been physically removed. In this case, device n's terminating resistor has disappeared, and device n-1 needs to take over connecting the terminating resistor.

[0110] In one specific implementation of this embodiment, after determining that the target slave device has been physically removed, the host also generates a corresponding removal event record. The removal event record includes the target slave device's device address, removal time, and network status information at the time of removal. The host can store the removal event record in a local log or display an alarm through a human-machine interface to notify maintenance personnel that a device has been removed.

[0111] In another specific embodiment of this example, after determining that the target slave device has been physically removed, the host further determines whether the target slave device is an end slave device in the current network. If so, the host automatically controls the new end slave device to connect to its terminating resistor; the specific control method is described in subsequent embodiments.

[0112] The determination method in this embodiment effectively avoids misjudging communication loss as physical removal. In existing technologies, when a device experiences communication interruption due to CAN communication line failure, electromagnetic interference, or software malfunction, the system often cannot distinguish whether the device has been physically removed or is merely experiencing a communication failure, potentially leading to incorrect terminal resistance management decisions. This embodiment, however, introduces the upstream monitoring status reported by downstream neighboring nodes—an independent hardware-level monitoring information—enabling the host to accurately differentiate between the two operating conditions and make the correct control decisions.

[0113] In one feasible implementation, step S20 further includes: If the CAN communication status of the target slave device is out of contact, and the upstream monitoring status reported by the downstream neighbor node device of the target slave device is in the access status, then the target slave device is determined to be in a communication state where communication is out of contact but physically online.

[0114] In this embodiment, the host determines the communication status of each slave device based on the CAN communication status reported by each slave device and the upstream monitoring status.

[0115] If the target slave device's CAN communication status is out of contact, and the upstream monitoring status reported by the downstream neighbor node device of the target slave device is in the access status, then the host determines that the target slave device is in a communication state where communication is out of contact but physically online.

[0116] Specifically, after receiving the report messages from each slave device, the host analyzes the status of each slave device one by one. For a target slave device (e.g., device k), the host first checks the CAN communication status of that target slave device. The CAN communication status of the target slave device is recorded in the host's buffer, and this status is determined by the host based on whether it receives a report message from the target slave device within the timeout period. If the host does not receive a report message from the target slave device within the preset timeout period, the CAN communication status of the target slave device is marked as disconnected.

[0117] After confirming that the target slave's CAN communication status is lost, the host further acquires the upstream monitoring status reported by the target slave's downstream neighbor node device (i.e., device k+1). This upstream monitoring status is the level signal detected by the downstream neighbor node device through its upstream monitoring line, and this level signal directly reflects the level status of the target slave's terminating resistor control output. The downstream neighbor node device reports this upstream monitoring status to the host at a predetermined period, and the host stores it in its cache.

[0118] If the host reads from the cache that the upstream monitoring status reported by the downstream neighbor node device is "accessed," it indicates that the terminating resistor control output of the target slave device is still in a valid state, meaning that the terminating resistor of the target slave device is still connected to the CAN bus. This access status indicates that the terminating resistor control signal of the target slave device still exists, the target slave device is still physically connected to the network, and its terminating resistor is still valid.

[0119] The host makes a comprehensive judgment based on two conditions: the target slave's CAN communication being out of service and the upstream monitoring status reported by the target slave's downstream neighbors being "connected". When both conditions are met, the host determines that the target slave is in a communication state of being out of service but physically online, meaning that the target slave itself is still connected to the CAN bus and its terminating resistor is still connected, but the CAN communication between the target slave and the host is interrupted for some reason.

[0120] The principle behind this embodiment is as follows: When a device experiences only a communication loss but remains physically online, its physical connection to the CAN bus is not broken, and its terminating resistor control module continues to operate normally, continuously outputting a control level signal to maintain the terminating resistor's connection. This control level signal is transmitted through the control line to the upstream monitoring input of the downstream neighboring node device. The downstream neighboring node device detects this level signal through the upstream monitoring line, determines that the upstream neighboring node device's terminating resistor is in the connected state, and reports this state to the host. Therefore, the simultaneous fulfillment of both communication loss and downstream monitoring connection conditions is a sufficient condition for a device to be communicationally lost but physically online.

[0121] The following example illustrates a scenario where a slave device loses communication but remains physically online. Assume the system comprises devices 1 (master) to n (slave devices), where the terminating resistor of device n is connected to the CAN bus. When CAN communication of device n is interrupted due to electromagnetic interference, CAN transceiver failure, or software anomaly, but device n's power supply, microcontroller, and terminating resistor control module are still functioning normally: On one hand, the master device does not receive a report from device n within the timeout period, detecting that device n's CAN communication status has become disconnected; on the other hand, device n's terminating resistor control module still outputs a valid control level, and its terminating resistor remains connected to the CAN bus. Since no downstream neighboring node of device n can report its terminating resistor connection status, the master device cannot directly confirm the terminating resistor status of device n through downstream monitoring. However, the fact that the terminating resistor control signal of device n still exists can be indirectly known through the monitoring status of the upstream device (device n-1), or confirmed through device n's last reported status (its terminating resistor was connected before the communication interruption).

[0122] The determination method in this embodiment is particularly effective for scenarios where communication between non-end-device slave devices is lost but they are physically online. Let's take device n-1 (the penultimate device) as an example of communication loss but physical online status. Device n-1's CAN communication with the host is interrupted for some reason (e.g., CAN transceiver failure or software malfunction), but device n-1 itself remains powered on, its terminating resistor control module is still functioning normally, and the terminating resistor remains disconnected (because device n-1 is not an end-device). At this time, the host detects that device n-1's CAN communication status is lost. Simultaneously, device n, as a downstream neighbor node of device n-1, has its upstream monitoring line connected to the terminating resistor control output of device n-1. Device n detects through this line that the terminating resistor control output signal of device n-1 is still valid (indicating that the terminating resistor is not connected) and reports this upstream monitoring status (not connected) to the host. After receiving the upstream monitoring status reported by device n as not connected, the host, combined with the CAN communication status of device n-1 being lost, determines that device n-1 is in a communication state of communication loss but physical online status.

[0123] It is important to note that in this embodiment, the terminating resistors of non-end slave devices are normally not connected (only the terminating resistors of end slave devices and the head host are connected). Therefore, when a non-end slave device loses communication but is physically online, its downstream neighboring node device reports an upstream monitoring status of "not connected" (because the terminating resistor of the non-end slave device was not connected to begin with). At this time, both the conditions of communication loss and downstream monitoring being "not connected" are met simultaneously, but this combination does not indicate that the device has been physically removed; rather, it indicates that the device has lost communication and its terminating resistor is normally disconnected. The head host needs to make an accurate judgment based on whether the device is an end device and other contextual information.

[0124] For the end slave device itself, its terminating resistance is connected. When the end slave device loses communication but remains physically online, since no downstream neighboring node device can report its terminating resistance status, the host cannot directly determine whether the end slave device is physically removed or has lost communication through downstream monitoring. In this case, the host can make a comprehensive judgment by combining the last reported status of the end slave device and the monitoring status of the penultimate device. If the last reported terminating resistance status of the end slave device before the communication interruption was "connected," and the communication status of the penultimate device is normal, then it can be determined that the end slave device may be in a state of communication loss but physical online, and its terminating resistance connected status should be kept unchanged.

[0125] In one specific implementation of this embodiment, after determining that the target slave device is in a communication outage but physically online state, the host generates a corresponding communication outage event record. The communication outage event record includes the target slave device's device address, the time of the outage, and the network status information at the time of the outage. The host can store this communication outage event record in a local log or display an alarm through a human-machine interface to notify maintenance personnel that a device has experienced a communication outage but remains physically online, requiring investigation.

[0126] In another specific implementation of this embodiment, after determining that the target slave device is in a communication state of communication failure but physical online status, the host will not change the terminating resistor connection status of the target slave device and its downstream devices. This is because although the target slave device is communication failure, it is still physically online, and its terminating resistor (if it is an end device) remains valid. If the terminating resistor is mistakenly moved to another device at this time, it will result in three terminating resistors on the CAN bus, causing impedance mismatch. Therefore, the host maintains the original terminating resistor configuration unchanged and only records the communication failure event for subsequent processing by maintenance personnel.

[0127] This embodiment, together with the aforementioned embodiment (method for determining physical removal), constitutes a complete operating condition discrimination system. By cross-correlation analysis of the CAN communication status and upstream monitoring status, the host can accurately distinguish three operating conditions of the device: normal online, physically removed, and communication lost but physically online. For the end slave device (without downstream neighboring nodes), the upstream monitoring status reported by its downstream neighbor is unavailable. In this case, the host can make an auxiliary judgment based on the last reported status of the end slave device and the monitoring status of its upstream neighboring device. If the end slave device is communication lost, and the communication status of its upstream neighboring device (device n-1) is normal, and the upstream monitoring status of device n-1 is not connected (indicating that the terminating resistor of device n-2 is not connected), then it can be comprehensively determined that the end slave device may be in a state of communication lost but physically online or physically removed, which needs to be further confirmed by combining other information.

[0128] The determination method in this embodiment effectively avoids the loss of control over terminating resistor management caused by misjudging "disconnection" as physical removal. In the prior art, when a device communication is abnormal, the system often simply treats it as offline and triggers the terminating resistor migration logic, resulting in the terminating resistor of the still physically online end device being incorrectly disconnected. The CAN bus changes from two terminating resistors to only one, severely degrading communication quality. However, this embodiment introduces the upstream monitoring status reported by downstream neighboring node devices. This independent hardware-level monitoring information enables the host to accurately identify the condition of communication disconnection but physical online status, maintaining the original terminating resistor configuration unchanged, thereby ensuring that the CAN bus always has correct impedance matching.

[0129] In one feasible implementation, after step S10, the method further includes: The host establishes the network topology of the CAN communication network and determines the end slave in the network topology based on the CAN communication status reported by each slave and the upstream monitoring status.

[0130] In other words, the host establishes the network topology of the CAN communication network and determines the end slaves in the network topology based on the CAN communication status reported by each slave and the upstream monitoring status.

[0131] Specifically, after continuously receiving messages reported by each slave device, the host stores the CAN communication status of each slave device and the upstream monitoring status detected by each slave device in its buffer. The host uses this information to build a complete network topology from the head end to the tail end step by step.

[0132] The basic principle of establishing a network topology by the host is as follows. In a multi-device cascaded network, the upstream monitoring lines between each slave device form a unidirectional chain connection from the head end to the tail end. The upstream monitoring status of each slave device reflects the level status of the terminating resistor control output of its upstream neighboring node device. When the upstream neighboring node device is online normally, its terminating resistor control output will output a definite level signal, which is detected and reported by the downstream slave device. Therefore, by checking the upstream monitoring status reported by each slave device, the host can infer whether the connection between each slave device and its upstream neighboring node device has been established normally.

[0133] Specifically, for slave device k (device k), if the upstream monitoring status reported by slave k to the master device is "connected" or "not connected" (i.e., a valid level signal is detected, rather than floating or unknown), it indicates that the upstream monitoring line connection between slave k and its upstream neighboring node device (device k-1) is normal, device k-1 is online, and its terminal resistor control module is working normally. If the upstream monitoring status reported by slave k remains invalid or the master device does not receive the report message from slave k, it indicates that the connection between slave k and its upstream neighboring node device may be interrupted, or slave k itself is offline.

[0134] The host constructs the network topology hierarchically, starting from the first end. The host first confirms the existence of device 1 (the first host), whose terminating resistor is always connected. Then, the host checks whether device 2 (the first slave) is reporting its status and the status of its upstream monitoring. If device 2 reports normally, it indicates that device 2 is online, the upstream monitoring line between device 2 and device 1 is connected normally, and the terminating resistor control signal of device 1 is successfully detected by device 2. The host then confirms the connection relationship between device 1 and device 2.

[0135] Next, the host checks whether device 3 is reporting normally and its upstream monitoring status. If device 3 reports normally, it means that device 3 is online and the upstream monitoring line connection between device 3 and device 2 is normal. The host confirms the connection relationship between device 2 and device 3 accordingly. The host continues in this manner, checking the reporting status and upstream monitoring status of each slave device step by step, until a slave device fails to report normally or its upstream monitoring status is abnormal.

[0136] The host establishes a complete connection link from device 1 to device n through the above step-by-step checks. In the network topology, each node represents a device, and the edges between nodes represent the connection relationships of upstream monitoring lines. The network topology established by the host reflects the connection sequence and cascading relationship of all online devices in the current system.

[0137] After establishing the network topology, the host determines the end slave device in the current network based on the topology information. The criteria for determining the end slave device are as follows: The end slave device is the device located at the end of the link in the network topology, and no other devices are connected after it. Physically, the end slave device's terminating resistor is connected to the CAN bus, and its terminating resistor control output is left floating, not outputting control signals to any downstream devices. In terms of monitoring characteristics, no neighboring node device downstream of the end slave device can detect its terminating resistor connection status.

[0138] The host determines the end slave device in the following way: Starting from device 1, the host traverses downstream along the established network topology until it finds the last slave device that can report normally and has a complete connection. This slave device is the end slave device of the current network. Specifically, the host checks the reporting status of each slave device. If slave device k reports normally, while slave device k+1 cannot report normally or does not exist, then slave device k is the end slave device. If slave device k reports normally, and the upstream monitoring status of slave device k indicates that its upstream neighbors are normal, but the host does not find any downstream devices of slave device k reporting, then slave device k is the end slave device.

[0139] In another implementation, the host can also determine the end slave by analyzing the upstream monitoring status of each slave. In a series of cascaded links, the end slave is characterized by the fact that the terminating resistor of its upstream neighbor node is not connected (because only the terminating resistors at the beginning and end are connected), and there are no other devices downstream of it. Therefore, the host can determine the end slave by finding a slave whose upstream monitoring status is connected and whose downstream status is empty.

[0140] After identifying the end slave device, the host records the device address of the end slave device in the host's cache and marks it as the end device of the current network. The host also marks the end slave device's terminating resistor connection status as connected to ensure impedance matching at the end of the CAN bus.

[0141] In one specific implementation of this embodiment, after establishing the network topology, the host outputs the network topology information in a visual manner. The visual output may include the connection sequence of each device, the online status of each device, and the connection status of the terminal resistors for each device. Maintenance personnel can intuitively understand the overall structure of the current CAN communication network and the working status of each node by viewing the network topology information.

[0142] In another specific embodiment of this example, the host periodically re-establishes the network topology. Because changes may occur during system operation, such as the addition or removal of devices, device failures, or communication anomalies, the network topology may dynamically change. By periodically re-establishing the network topology, the host ensures that the topology information it maintains is always consistent with the actual network state. The periodic rebuilding cycle can be set according to the dynamic nature of the system.

[0143] In a typical application scenario of this embodiment, the system includes one master and five slaves. All slaves are online and reporting normally. The master checks each level to determine that devices 2, 3, 4, 5, and 6 are online in sequence, and that all upstream monitoring lines are connected normally. The master identifies device 6 as the end slave. When device 6 is physically removed, device 5 continues to report normally, but device 6 stops reporting. The master re-establishes the network topology and identifies device 5 as the new end slave.

[0144] In another typical application scenario of this embodiment, the system includes one master and three slaves. Device 3 is a terminal slave with its terminating resistor connected. When communication of device 3 is lost due to interference but it is still physically online, the master detects that the CAN communication status of device 3 is lost, but the upstream neighbor device of device 3 (device 2) detects that the terminating resistor control signal of device 3 is still present (this can be indirectly confirmed by the upstream monitoring status of device 2 being connected). When establishing the network topology, the master confirms that device 2 is still online and that the connection between device 2 and device 3 still exists. Therefore, device 3 is still marked as a terminal slave, and its terminating resistor connected status remains unchanged.

[0145] The network topology establishment and end-device determination method in this embodiment provides a foundation for the host to perform dynamic management of the network-wide terminating resistance. Only when the host accurately grasps the current network topology and end-device locations can it make correct terminating resistance control decisions when devices are added, removed, or fail.

[0146] In one feasible implementation, after establishing the network topology of the CAN communication network and determining the end slave devices in the network topology, the method further includes: When the host determines that the communication status of the end slave has been physically removed, or when it determines that a new end slave is being added, it controls the new end slave to connect its terminating resistor to the CAN bus.

[0147] In other words, when the master determines that the communication status of the end slave has been physically removed, or when it determines that a new end slave has been added, it controls the new end slave to connect its terminating resistor to the CAN bus.

[0148] Specifically, after establishing the network topology and identifying the current end slave device, the host continuously monitors changes in the network status. When a device is removed or added, the host needs to make corresponding terminating resistor control decisions to ensure that there are always exactly two terminating resistors properly connected at both ends of the CAN bus.

[0149] The first scenario: The end slave device is physically removed.

[0150] During operation, the host continuously receives reports from each slave device and monitors the CAN communication status and upstream monitoring status of each slave device. When the host determines that the end slave device has been physically removed according to the method of the aforementioned embodiment, the host triggers the terminating resistor migration process.

[0151] Specifically, assume the current end slave device is device n, whose terminating resistor is connected to the CAN bus. When device n is physically removed, the host detects that device n's CAN communication status has changed to disconnected. Since device n is an end slave device, no downstream neighboring node device can report its terminating resistor status change. The host will make a comprehensive judgment based on the communication status of device n-1 (the second to last device) and the upstream monitoring status of device n-1. If device n-1's CAN communication status is established, and device n-1's upstream monitoring status is disconnected, while device n's CAN communication status is disconnected, then the host determines that device n has been physically removed.

[0152] After determining that the end slave device n has been physically removed, the host identifies the new end slave device as n-1. The host sends a terminating resistor connection control command to n-1 via the CAN bus, instructing n-1 to connect its terminating resistor to the CAN bus. Upon receiving the control command from the host, n-1's terminating resistor control module outputs a valid control level, driving the electronic switch to turn on and connecting its own 120Ω terminating resistor to the CAN bus. After connecting the terminating resistor, n-1 takes over the terminating resistor function of the removed device n, becoming the new end slave device.

[0153] After sending a control command to device n-1, the host further confirms the execution result of the control command. Specifically, within a predetermined time after sending the control command, the host verifies whether the terminating resistor has been successfully connected by checking the upstream monitoring status reported by device n-1. If the downstream neighbor node device of device n-1 (i.e., device n, but device n no longer exists at this time) does not exist, the host can confirm this by checking the terminating resistor control status reported by device n-1 itself. After connecting the terminating resistor, device n-1 includes its own terminating resistor control status as connected in its subsequent reporting messages. Upon receiving this report, the host confirms that the terminating resistor migration was successful.

[0154] After confirming that the new end slave device has successfully connected to the terminating resistor, the host updates the network topology information and terminating resistor connection status information in the host cache. The host marks device n-1 as the new end slave device, marks its terminating resistor connection status as connected, and removes the original end slave device n from the network topology.

[0155] The second scenario: The system expands to include new end slave devices.

[0156] When a new slave device needs to be added to the system, maintenance personnel connect the new device (device n+1) downstream of the original end slave device (device n). Specifically, the CAN bus interface of device n+1 is connected to the CAN bus, and the upstream monitoring input of device n+1 is connected to the terminating resistor control output of device n. After power-on, device n+1 automatically enters the addressing process (see subsequent embodiments for details), receiving the addressing signal from device n through the upstream monitoring line to obtain its own device address.

[0157] After the new device is powered on and addresses are completed, it begins sending reporting messages to the host according to a predetermined period. The reporting message contains the CAN communication status (establishment) of device n+1 and its upstream monitoring status. The upstream monitoring input of device n+1 is connected to the terminating resistor control output of device n, so the upstream monitoring status reported by device n+1 reflects the level status of the terminating resistor control output of device n.

[0158] After receiving the report message from device n+1, the host recognizes the existence of the new device. The host compares the reported information of device n+1 with the currently stored network topology information and finds that device n+1 is not in the original topology, and its upstream monitoring status is "accessed" (indicating that the terminal resistor control signal of device n is present). Therefore, the host determines that the system has undergone device expansion, and device n+1 is a newly added slave device.

[0159] After the system determines that a new end slave device has been added, the host triggers the terminating resistor migration process. The host first sends a terminating resistor disconnect control command to the original end slave device n, controlling device n to disconnect its terminating resistor. After receiving the control command from the host, device n's terminating resistor control module outputs an invalid control level, driving the electronic switch to turn off and disconnecting its own 120Ω terminating resistor from the CAN bus.

[0160] Subsequently, the host sends a terminating resistor access control command to the new end slave device n+1, controlling device n+1 to connect its terminating resistor. After receiving the control command from the host, device n+1's terminating resistor control module outputs a valid control level, driving the electronic switch to turn on and connecting its own 120Ω terminating resistor to the CAN bus.

[0161] After sending the control command, the host further confirms the execution result of the control command. The host confirms that the terminating resistor of device n is disconnected and the terminating resistor of device n+1 is connected by receiving reports from device n and device n+1, respectively. Specifically, the host checks whether the local terminating resistor control status reported by device n is "not connected" and whether the local terminating resistor control status reported by device n+1 is "connected". When both conditions are met, the host confirms that the terminating resistor migration was successful.

[0162] After confirming successful terminating resistor migration, the host updates the network topology information and terminating resistor access status information in its cache. The host removes device n from the end slave role and marks its terminating resistor access status as unconnected; it marks device n+1 as the new end slave and marks its terminating resistor access status as connected.

[0163] In a special case, if device n is unable to receive the host's disconnect control command due to communication loss, the host can adopt a backup strategy. Specifically, after device n+1 detects that its upstream monitoring status is "connected," it can actively determine whether device n is still online through hardware detection. If device n+1 detects an "connected" status through the upstream monitoring line, it indicates that the terminating resistor control signal of device n is still present, but device n may have lost communication. In this case, the host can forcibly connect device n+1 to the terminating resistor and record the communication loss event of device n, coordinating the process again after device n resumes communication.

[0164] In one specific implementation of this embodiment, after the host controls a new slave device to connect to the terminating resistor, it also broadcasts a notification of the terminating resistor status change to the entire network via the CAN bus. Upon receiving this notification, other slave devices update their locally cached network status information to maintain a network view consistent with the host.

[0165] In another specific embodiment of this example, if the host does not receive an acknowledgment response after sending a control command to a slave device during the terminal resistor migration process, the command will be retransmitted. The number of retransmissions and the interval between retransmissions can be set according to the system's communication reliability requirements. If no acknowledgment response is received after multiple retransmissions, the host records the control failure event and issues an alarm, prompting maintenance personnel to intervene manually.

[0166] The end-slave dynamic control method in this embodiment enables the CAN network to possess self-sensing, self-configuration, and self-healing capabilities. When an end-slave is physically removed, the master device can automatically recognize the removal event and migrate the terminating resistor to the new end-slave; when the system expands by adding a new slave device, the master device can automatically recognize the new event and migrate the terminating resistor from the original end to the new end. The entire process requires no manual re-switching or on-site hardware adjustments, supporting hot-swapping of devices and online dynamic expansion.

[0167] The technical effects of this embodiment are illustrated below through specific working condition examples.

[0168] Under normal operating conditions, the system consists of devices 1 (master) to n (slave devices). Device 1's terminating resistor is connected, device n's terminating resistor is connected, and the terminating resistors of devices 2 to n-1 are all disconnected. Devices 2 to n report their upstream monitoring status to the master. Device 2's upstream monitoring status is "connected" (device 1's terminating resistor is detected as connected), device 3's upstream monitoring status is "not connected" (device 2's terminating resistor is not connected), device 4's upstream monitoring status is "not connected," and so on, with device n's upstream monitoring status also being "not connected."

[0169] When the end slave device n is physically removed, its CAN communication status becomes disconnected. The host, combining the communication status of device n-1 and the upstream monitoring status of device n-1, determines that device n has been physically removed. Subsequently, the host controls device n-1 to connect a terminating resistor. After the migration is complete, the terminating resistors of device 1 and device n-1 are connected, while the terminating resistors of the remaining devices are disconnected. Only two terminating resistors remain at both ends of the CAN bus.

[0170] When device n loses communication but remains physically online, the host determines that device n is in a state of communication loss but physical online, and keeps the terminating resistor of device n connected. At this time, the terminating resistor of device 1 is connected, the terminating resistor of device n is connected, and the terminating resistors of the other devices are disconnected. There are still exactly two terminating resistors at both ends of the CAN bus.

[0171] When device n-1 (the second-to-last device) is physically removed, the host detects that device n-1's CAN communication status is lost, and simultaneously, the upstream monitoring status reported by device n changes to "not connected." The host determines that device n-1 has been physically removed. At this time, device n is still the end slave, its terminating resistor is still connected, and device n's CAN communication status is "established." Therefore, the host does not need to perform terminating resistor migration, and there are still only two terminating resistors at both ends of the CAN bus (device 1 and device n).

[0172] When device n-1 loses communication but remains physically online, the host determines that device n-1 is in a state of communication loss but physical online status. At this time, device n's CAN communication is established, and device n's terminating resistor remains connected, while device n-1's terminating resistor remains disconnected. There are still only two terminating resistors at both ends of the CAN bus (device 1 and device n), and the host does not need to perform any terminating resistor changes.

[0173] For devices 2 through n-2, whether these devices are physically removed or lose communication, the connection status of the terminating resistors at the end of the CAN bus will not be affected. This is because the terminating resistors of these devices are normally open, and their removal or loss of connection will not cause the already connected terminating resistors to disappear. Terminating resistor migration is only required when the end slave device is removed.

[0174] As can be seen from the above working condition analysis, the end slave dynamic control method of this embodiment can ensure that there are always only two terminating resistors properly connected at both ends of the CAN bus under various complex working conditions, effectively avoiding communication quality degradation or bus paralysis caused by incorrect terminating resistor configuration.

[0175] In one feasible implementation, the processing method further includes: During the power-on addressing phase of the node device, the host configures the addressing address of each slave device through the upstream monitoring line of each slave device.

[0176] In this embodiment, the processing method further includes: during the power-on addressing stage of the node device, the host configures the addressing address of each slave device through the upstream monitoring line of each slave device.

[0177] Specifically, after power-on, the node devices automatically enter the addressing phase. During the addressing phase, each device uses the terminating resistor to control the transmission of modulated square wave signals, encoding the address information into the square wave waveform, and transmitting it downstream from the first host to achieve automatic address allocation for all devices in the network.

[0178] The specific steps of the addressing process are as follows.

[0179] The first step is to start waiting.

[0180] After the node device powers on, it first performs initialization operations, including microcontroller clock initialization, GPIO port initialization, and timer initialization. After initialization, the device enters a startup wait state. In the startup wait state, the device continuously checks whether the addressing startup conditions are met. The addressing startup conditions include: the device is powered on, and the device is currently not addressed or the addressing enable flag is true. "Currently not addressed" means that the device's address has not yet been assigned, and its stored address is a default value or an invalid value; "addressing enable flag is true" means that the device is allowed to enter the addressing process. When all the above conditions are met, the device exits the startup wait state and proceeds to the next step.

[0181] The second step is to connect the terminating resistor.

[0182] Once the addressing start conditions are met, the device's terminating resistor control module outputs a high-level control signal, driving the electronic switch to turn on and connecting the device's 120Ω terminating resistor to the CAN bus. The purpose of connecting the terminating resistor at this point is to provide stable impedance matching for the CAN bus during the addressing process, ensuring the reliability of addressing signal transmission. It should be noted that all devices initially have their terminating resistors connected; subsequent adjustments will be made based on the device's position in the network (start, intermediate node, or end).

[0183] The third step is to determine the relationship between the first and second devices.

[0184] After the device is connected to the terminating resistor, it detects the upstream connection monitoring status through its upstream monitoring input module. The device detects whether the level signal on the upstream monitoring line remains high and delays for a preset time (e.g., 100 milliseconds). This delay is used to filter out instantaneous jitter in the signal, ensuring the reliability of the detection results.

[0185] If the upstream monitoring status is detected to be high and remains high for a period exceeding a preset time, it indicates that no other devices are connected upstream of this device, or that the upstream device is not outputting a valid control level signal. In this case, the device determines itself as the first-end host and enters the first-end host addressing process.

[0186] If the upstream monitoring status is detected to be not high (i.e., low), it indicates that another device is connected upstream of this device, and the upstream device has output a valid control level signal. At this time, the device determines itself to be a slave device and enters the slave addressing process.

[0187] The fourth step is the slave addressing process.

[0188] The addressing process for a device identified as a slave device is as follows.

[0189] First, the slave device outputs a low level to control its terminating resistor, disconnecting its own terminating resistor. Since the slave device is not the network endpoint, its terminating resistor does not need to be connected to the CAN bus; therefore, disconnecting it avoids having three terminating resistors on the bus.

[0190] Then, the slave device enters the receiving and parsing process. The slave device continuously attempts to receive the modulated square wave signal from the upstream device through its upstream monitoring input module. This modulated square wave signal is generated by the upstream device by controlling the high and low levels of its output terminal through a control terminating resistor, and the signal encodes address information. The address information may include an address value and a checksum, which is used to verify the integrity of the address data.

[0191] The slave device decodes the received modulated square wave signal. The decoding process includes: detecting the edges of the square wave signal, measuring the duration of the high and low levels, and parsing the address value and checksum according to the pulse width modulation coding rules. If decoding fails (e.g., no valid square wave signal is detected, checksum mismatch, or signal is not received within a timeout), it returns to continue receiving and waits for the upstream device to retransmit.

[0192] If decoding is successful, the slave device will use the parsed address value as its own address, store it in its non-volatile memory, and mark the current device as addressed.

[0193] After the slave device completes its local address setting, it checks whether the local address equals the preset total number of devices. The total number of devices is a pre-configured parameter of the system, representing the number of all devices in the current CAN communication network.

[0194] If the local address is not equal to the total number of devices, it means that the local device is not a terminal slave and needs to transmit the addressing address downstream. In this case, the slave device adds 1 to its local address to obtain the addressing address (i.e., the second addressing address) of the downstream neighboring node. Then, the slave device sends a modulated square wave signal containing this addressing address information (which may include a checksum) to the downstream neighboring node by controlling the high and low levels of its terminating resistor output. After transmission, the slave device checks whether the number of transmissions exceeds the preset maximum number of transmissions (NumMax). If it does not exceed the limit, it retransmits; if it does exceed the limit, the transmission process ends.

[0195] If the local address equals the total number of devices, it indicates that the local device is a slave device. In this case, the slave device outputs a high level to control its terminating resistor, connects the terminating resistor, and then ends the addressing process. After the slave device connects the terminating resistor, impedance matching at the end of the CAN bus is established.

[0196] Step 5: Header host addressing process.

[0197] The addressing process for the device identified as the first host is as follows.

[0198] First, the host computer maintains its terminating resistor control level output high, keeping the terminating resistor connected. The terminating resistor of the host computer must always be connected to ensure impedance matching at the beginning of the CAN bus.

[0199] Then, the first host sets its local address to the default starting address (e.g., 1) and marks the current device as addressed.

[0200] Next, the first-end host adds 1 to its local address to obtain the address of the first downstream slave device (i.e., the first address). The first-end host sends a modulated square wave signal containing the address information (which may include a checksum) to the downstream neighboring node device by controlling the high and low levels of its terminating resistor output.

[0201] After transmission is complete, the first-end host checks whether the number of transmissions exceeds the preset maximum number of transmissions (NumMax). If it does not exceed the maximum number, it retransmits; otherwise, it terminates the transmission process.

[0202] In this embodiment, the encoding method for the modulated square wave signal can be pulse width modulation (PWM). Specifically, different combinations of high-level and low-level durations at the output terminal are controlled by controlling the terminating resistor to represent different binary data. For example, a narrower high-level pulse can represent binary 0, and a wider high-level pulse can represent binary 1; or different values ​​can be represented by the duty cycle of the high and low levels. The address information can include multiple bytes, each byte is encoded in the above manner, and a check byte is appended after the address byte to ensure the reliability of data transmission.

[0203] After receiving the modulated square wave signal, the downstream device measures the duration of the high and low levels in the square wave signal, restores the original address value and check code according to the decoding rules corresponding to the encoding method, and performs verification.

[0204] In one specific embodiment of this example, the address is represented by 8 bits, with a value range of 1 to 254. Address 1 is reserved for the first-end host, and slave addresses are assigned sequentially starting from 2. The total number of devices is preset according to the system configuration, and the address of the last-end slave is equal to the total number of devices.

[0205] In another specific implementation of this embodiment, the addressing process supports a timeout retransmission mechanism. After a device sends an address to a downstream device, if it does not receive an acknowledgment response from the downstream device within a predetermined time (this acknowledgment response can be implicitly represented by the level change after the downstream device connects to the terminating resistor, or it can be explicitly represented by an acknowledgment message on the CAN bus), the sending device will repeatedly send the address until the transmission is successful or the maximum number of transmissions is reached.

[0206] In another specific embodiment of this example, the addressing process supports resuming interrupted transmissions. When a device fails to receive the address for any reason, it remains in a waiting state, and its upstream device will continuously retransmit the address until the device successfully receives it. This ensures that even if there is brief signal interference or device response delay during the addressing process, the entire addressing process can still be completed smoothly.

[0207] The address configuration method described above physically decouples the addressing channel from the CAN communication channel. After power-on, the device can complete the chained address transfer from start to finish via hardware-level pulse-width modulation signals without waiting for the CAN bus communication to be established. Even if the terminating resistor is not fully configured during initial power-on, or the CAN bus is temporarily unstable due to electromagnetic interference, address allocation between devices can still be reliably completed.

[0208] This method effectively avoids the startup deadlock problem in traditional CAN message negotiation-based automatic address allocation schemes, which leads to "incorrectly configured terminating resistor → unstable CAN communication → address negotiation failure → inability to recover." Furthermore, this method eliminates the need for DIP switches or pre-programmed firmware; device addresses are automatically allocated upon each power-on, supporting plug-and-play functionality and in-system expansion.

[0209] In one feasible implementation, configuring the addressing addresses of each of the slave devices includes: The slave device receives the first address of the slave device through the upstream monitoring line, constructs the second address of the downstream neighbor node device based on the first address, and transmits the second address to the downstream neighbor node device through the upstream monitoring line of the downstream neighbor node device.

[0210] In this embodiment, configuring the address of each slave device specifically includes: the slave device receives the first address of the slave device through the upstream monitoring line, constructs the second address of the downstream neighbor node device based on the first address, and transmits the second address to the downstream neighbor node device through the upstream monitoring line of the downstream neighbor node device.

[0211] Specifically, during the addressing phase, the address allocation of the entire network adopts a unidirectional chain-like transmission method from the head end to the tail end. After receiving the address from the upstream device, each device performs an increment operation on the address to generate the next address for use by the downstream device, and then passes it downstream.

[0212] The complete process of address passing in chained addressing is as follows.

[0213] The master node, acting as the initiating node of the entire addressing process, sets its own address as the default starting address. In this embodiment, the default starting address is 1. The master node adds 1 to the starting address 1, obtaining 2, which is used as the addressing address of the first slave device. The master node controls the high and low level changes of its output terminal by controlling the terminating resistor, and sends out a modulated square wave signal containing the addressing address 2. This signal is transmitted to the upstream monitoring input terminal of the first slave device through the upstream monitoring line.

[0214] The first slave device receives the modulated square wave signal from the master device via its upstream monitoring input module, decodes the signal, and obtains address 2. The first slave device sets address 2 as its own device address and stores it in its local non-volatile memory. At this point, the first slave device has completed the reception and setting of its own address, which is the first address as described in claim 10.

[0215] After completing its own address settings, the first slave device checks if its local address equals the total number of devices. If its local address does not equal the total number of devices (i.e., it is not a terminal slave device), the first slave device needs to pass the addressing address downstream. Specifically, the first slave device adds 1 to its own address 2, resulting in 3, which is used as the addressing address of the downstream neighboring node device (i.e., the second slave device). This address 3 is the second addressing address described in claim 10.

[0216] The first slave device controls the output level of its terminating resistor to transmit a modulated square wave signal containing address 3. This signal is then transmitted to the second slave device via the connection line between the first slave device's terminating resistor control output and the upstream monitoring input of the second slave device.

[0217] The second slave device receives the modulated square wave signal from the first slave device through its upstream monitoring input module, decodes the signal, and obtains address 3. The second slave device sets address 3 as its own device address. Then, the second slave device checks whether its local address is equal to the total number of devices. If not, the second slave device adds 1 to its own address 3, obtaining 4, which is used as the address of the downstream neighbor node device (i.e., the third slave device), and sends it downstream.

[0218] The above process follows the same logic, with each slave device operating according to the same rules: receiving the first address from upstream, setting it as its own address, then adding 1 to that address to construct the second address, and passing it downstream. The entire address is passed step by step along the cascaded link from the head end to the tail end, until it reaches the tail slave device.

[0219] After receiving the addressing address via its upstream monitoring line, the end slave device sets it as its own address. Then, the end slave device determines that its own address equals the total number of devices, and therefore does not pass the addressing address downstream. The end slave device connects a terminating resistor, ending the addressing process.

[0220] Taking a system with 5 devices as an example, the host (device 1) has an address of 1. The host sends address 2. Device 2 receives address 2, sets it as its own address, and then sends address 3. Device 3 receives address 3, sets it as its own address, and then sends address 4. Device 4 receives address 4, sets it as its own address, and then sends address 5. Device 5 receives address 5, sets it as its own address, determines that its local address equals the total number of devices (5), and stops sending addresses downstream, connecting a terminating resistor. At this point, address allocation for all devices is complete.

[0221] In this embodiment, the modulation square wave signal can be encoded using pulse width modulation (PWM). Specifically, different combinations of high and low level durations at the output terminal are controlled by controlling the terminating resistor to represent different binary data. The address information can include multiple bytes, each encoded using PWM, with a check byte appended after the address byte.

[0222] During address transmission, the transmitting device encodes the address into a modulated square wave signal and then transmits the signal by controlling the level change at the output terminal through its terminating resistor. This signal is transmitted along the upstream monitoring line to the upstream monitoring input terminal of the receiving device. The upstream monitoring input module of the receiving device detects the level changes on the line in real time, converts them into digital signals, and decodes them according to the same encoding rules as the transmitting end to restore the address value and checksum. The checksum is then verified to ensure the integrity of the address data.

[0223] In one specific embodiment of this example, after each slave device receives the first address and successfully sets its own address, it sends an address setting completion confirmation message to the master device before sending the second address downstream. This confirmation message is sent via the CAN bus, informing the master device that the address setting has been completed. Upon receiving this confirmation message, the master device records the address setting status of the device in its cache.

[0224] In another specific embodiment of this example, to ensure the reliability of address transmission, the transmitting device waits for an acknowledgment response from the receiving device after sending the second address downstream. The acknowledgment response can be an acknowledgment message sent by the receiving device via the CAN bus, or an implicit acknowledgment signal represented by the receiving device changing the level of its terminating resistor control output. If the transmitting device does not receive an acknowledgment response within a predetermined time, it retransmits the address.

[0225] In another specific embodiment of this example, the address is transmitted by incrementing by 1 at each level. This method ensures that the device address directly corresponds to the physical location of the device in the cascaded link; that is, device 2 has an address of 2, device 3 has an address of 3, and so on. Maintenance personnel can intuitively determine the device's position in the network using its address, facilitating system debugging and maintenance.

[0226] In another specific embodiment of this invention, the device address can also adopt other progressive methods. For example, a fixed step value (such as 2, 5, or 10) can be added to the first address to construct the second address, or mapping can be performed according to a predetermined address allocation table. Regardless of the address construction method used, it falls within the protection scope of this application.

[0227] The chain-addressing address transfer method in this embodiment physically decouples the addressing channel from the CAN communication channel. After the device powers on, it can complete the chain-address transfer via the upstream monitoring line without waiting for the CAN bus communication to be established normally. Even if the terminating resistor is not fully configured when the system is first powered on, or the CAN bus is temporarily unstable due to electromagnetic interference, address allocation between devices can still be reliably completed. This effectively avoids the inherent defect of traditional automatic address allocation schemes based on CAN message negotiation that cannot start when the bus is idle or impedance mismatched.

[0228] Furthermore, this method eliminates the need for DIP switches or pre-programmed firmware, and device addresses are automatically assigned each time the device is powered on. When a new device is added to the system, after it connects to the cascaded link, it only needs to obtain the address from its upstream device, increment it by 1, and continue to pass it downstream to complete the address assignment. The entire process requires no manual intervention and supports plug-and-play functionality and online expansion of devices.

[0229] Figure 3 This is a flowchart illustrating the address configuration method provided in an embodiment of this application. Figure 3 As shown, the address configuration method includes the following steps.

[0230] After powering on, the device first enters a startup waiting state. The device cyclically checks whether the addressing startup conditions are met: the device is powered on and is not currently addressed, or the addressing enable flag is true. When this condition is met, the device exits the waiting state.

[0231] The device outputs a high-level control signal to the terminating resistor and connects it. Then, the device checks whether the upstream access monitoring status remains high and delays for a preset time (x milliseconds). This detection is used to determine whether the current device is the network initiator.

[0232] If the upstream access monitoring status is high and remains high for a delay of x milliseconds, the current device is determined to be the first-end host. The first-end host changes its local address to the default starting address 1, marks the current device as addressed, and sends the address to the downstream device. The address is the local address plus 1, i.e., address 2. The first-end host sends a modulated square wave signal containing the address information to the downstream device by controlling the high and low levels of the terminating resistor output. After sending, it checks whether the number of transmissions exceeds the maximum number of transmissions NumMax. If it does not exceed the maximum number of transmissions NumMax, it continues sending; otherwise, it terminates the addressing process.

[0233] If the upstream access monitoring status is not high, the current device is determined to be a slave, not a master. The slave first restores its default state, outputs a low level to the terminating resistor enable control level, and disconnects the terminating resistor (i.e., it is not connected). Then, the slave enters the receive parsing process, continuously attempting to receive the modulated square wave signal from the upstream. This signal contains the address information and may contain a checksum. If the receive parsing fails, it returns to continue receiving; if the receive parsing succeeds, the slave changes its local address to the received address and marks the current device as addressed.

[0234] After the slave device completes the address setting, it further checks whether its local address equals the total number of devices to determine if it is the final slave device. If the local address equals the total number of devices, the current device is determined to be the final slave device. The final slave device outputs a high level to enable its terminating resistor, connects to the terminating resistor, and then ends the addressing process. If the local address does not equal the total number of devices, the current device is determined not to be the final slave device. This device needs to transmit the address downstream, i.e., add 1 to the local address to obtain the address of the downstream device. By controlling the high and low levels of the terminating resistor output, a modulated square wave signal containing the address information (which may include a checksum) is sent to the downstream device. After transmission, it checks whether the number of transmissions exceeds the maximum number of transmissions NumMax. If it does not exceed the maximum number of transmissions NumMax, it continues to transmit; otherwise, it ends the addressing process.

[0235] Appendix Figure 4 This is a schematic diagram of the internal circuit structure of a node device in a CAN communication network system provided in this application embodiment. The following is in conjunction with... Figure 4 The circuit implementation of the node device in this application is described in detail.

[0236] like Figure 4 As shown, devices 1, 2, and n are cascaded sequentially to form a CAN communication network system. Taking device 2 as an example, the internal circuit structure of each node device is the same, including components such as a microcontroller (MCU), a CAN level conversion circuit, a terminating resistor R1, optocouplers D1 and D2, a transistor Q3, and a capacitor CB1.

[0237] The microcontroller (MCU), as the core control unit of the node device, is used to perform logic functions such as terminating resistor connection control, upstream monitoring status detection, and addressing signal modulation and demodulation. The MCU outputs control signals through general purpose input / output (GPIO) ports to control the connection and disconnection of the terminating resistor; at the same time, it receives detection signals from the upstream monitoring line through another GPIO port to determine the terminating resistor connection status of the upstream neighboring node device.

[0238] One end of the CAN level conversion circuit is connected to the MCU's CAN controller interface (TXD and RXD pins), and the other end is connected to the CAN bus (CAN_H and CAN_L). The CAN level conversion circuit is used to realize bidirectional conversion between the MCU's logic level signals and the differential signals of the CAN bus, enabling node devices to communicate with other node devices via the CAN bus.

[0239] The terminating resistor R1 is a 120Ω matching resistor, with one end connected to the CAN_H bus and the other end connected to the CAN_L bus via optocoupler D1. The resistance value of the terminating resistor R1 is matched to the characteristic impedance of the CAN bus according to the ISO 11898-2 standard.

[0240] Optocoupler D1, acting as an electronic switch, is connected in series in the circuit of terminating resistor R1 to control whether R1 is connected to the CAN bus. The input side (LED side) of optocoupler D1 is controlled by the MCU via transistor Q3. When the MCU outputs a high-level control signal, transistor Q3 conducts, current flows through the LED side of optocoupler D1, and optocoupler D1 conducts. Its output transistor then saturates and conducts, connecting terminating resistor R1 to the CAN bus. When the MCU outputs a low-level control signal, transistor Q3 is cut off, optocoupler D1 is cut off, and terminating resistor R1 is disconnected from the CAN bus.

[0241] Optocoupler D2 and its peripheral circuitry constitute the upstream monitoring input module. The input side (LED side) of optocoupler D2 is connected to the upstream monitoring line, which originates from the terminating resistor control output of the upstream neighboring node device (i.e., the output side of optocoupler D1). When the terminating resistor of the upstream neighboring node device is connected, optocoupler D1 conducts, and its output is at a low level. This low-level signal is transmitted through the upstream monitoring line to the input side of optocoupler D2 in the current device, causing optocoupler D2 to conduct. The output side of optocoupler D2 generates a low-level signal, which is sent to the GPIO port of the MCU via the terminating resistor connection status output. Upon detecting this low level, the MCU determines that the terminating resistor of the upstream neighboring node device is connected. When the terminating resistor of the upstream neighboring node device is disconnected, optocoupler D1 is cut off, and its output is at a high level (determined by the pull-up resistor or floating state). Optocoupler D2 is cut off, and its output generates a high-level signal. Upon detecting this high level, the MCU determines that the terminating resistor of the upstream neighboring node device is not connected.

[0242] The output terminal for the terminating resistor connection status is the signal terminal output by the local unit to the upstream monitoring line. Specifically, the local MCU controls the connection and disconnection of the terminating resistor R1 by controlling the on / off state of transistor Q3 and optocoupler D1; simultaneously, the level state on the output side of optocoupler D1 (i.e., the level of the terminating resistor connection status output terminal) is transmitted to the input side of optocoupler D2 of the downstream neighboring node device through the upstream monitoring line, enabling the downstream device to sense the local terminating resistor connection status. Therefore, the terminating resistor control line is multiplexed as the upstream monitoring line, simultaneously undertaking the dual functions of local terminating resistor control and transmitting the status to the upstream monitoring line.

[0243] The signal ground serves as a common reference ground for all node devices, and the electrical reference potential is unified among all devices through the signal ground wire.

[0244] Capacitor CB1 is a decoupling capacitor connected in parallel between the power supply and signal ground. It is used to filter out high-frequency noise on the power line and ensure the stability of the power supply to the optocoupler and MCU.

[0245] D2 is a diode connected between the upstream monitoring line and the signal ground. It is used for clamping protection to prevent transient overvoltages on the upstream monitoring line that are higher than the power supply voltage or lower than the ground potential from damaging the input LED of the optocoupler D2.

[0246] Figure 4 In this diagram, device 1 is the master device, and its terminating resistor R1 is always connected to the CAN bus to ensure impedance matching at the beginning of the bus. Device n is the slave device, and its terminating resistor R1 is connected to the CAN bus to ensure impedance matching at the end of the bus. Devices 2 to n-1 are intermediate slave devices, and their terminating resistor R1 is disconnected and they are not connected to the CAN bus. All devices are connected via upstream monitoring lines (represented by the "terminating resistor connection status output" signal line in the diagram) to form a unidirectional chain monitoring structure from the beginning to the end. The upstream monitoring input of each device is connected to the terminating resistor connection status output of its upstream neighboring node device, thus enabling real-time monitoring of the terminating resistor connection status of the upstream neighboring node device.

[0247] It should be noted that, Figure 4 The upstream direction shown is from device n to device 1, and the downstream direction is from device 1 to device n, which is consistent with the "upstream" and "downstream" directions marked in the figure.

[0248] Through the above circuit structure, each node device can autonomously complete the hardware-level real-time monitoring and control of the terminal resistor connection status without manual intervention or external measuring instruments, providing a reliable hardware foundation for the dynamic management of the terminal resistors of the entire network.

[0249] It should be noted that the above examples are only for understanding this application and do not constitute a limitation on the processing method of this application. Any simple modifications based on this technical concept are within the protection scope of this application.

[0250] This application provides a computer-readable storage medium having computer-readable program instructions (i.e., a computer program) stored thereon, the computer-readable program instructions being used to perform the processing methods in the above embodiments.

[0251] The computer-readable storage medium provided in this application may be, for example, a USB flash drive, but is not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems or devices, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections having one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system or device. The program code contained on the computer-readable storage medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination thereof.

[0252] The aforementioned computer-readable storage medium may be included in the node device; or it may exist independently and not assembled into the node device.

[0253] Computer program code for performing the operations of this application can be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, and C++, and conventional procedural programming languages ​​such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a Local Area Network (LAN) or a Wide Area Network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0254] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0255] The modules described in the embodiments of this application can be implemented in software or hardware. The names of the modules do not necessarily limit the functionality of the unit itself.

[0256] The readable storage medium provided in this application is a computer-readable storage medium that stores computer-readable program instructions (i.e., a computer program) for executing the above-described processing method. This solves the technical problem in existing CAN bus networks where the connection status of the terminating resistor cannot be monitored online in real time, relying on manual labor and external instruments for troubleshooting. This leads to an inability to effectively distinguish operating conditions and cause uncontrolled terminating resistor management when equipment is physically removed or communication is lost. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in this application are the same as those of the processing method provided in the above embodiments, and will not be repeated here.

[0257] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the processing method described above.

[0258] The computer program product provided in this application can solve the technical problem that the connection status of terminating resistors in existing CAN bus networks cannot be monitored online in real time, relying on manual and external instruments for troubleshooting. This leads to an inability to effectively distinguish operating conditions when equipment is physically removed or communication is lost, resulting in uncontrolled terminating resistor management. Compared with the prior art, the beneficial effects of the computer program product provided in this application are the same as those of the processing methods provided in the above embodiments, and will not be repeated here.

[0259] The above description is only a part of the embodiments of this application and does not limit the patent scope of this application. All equivalent structural transformations made under the technical concept of this application and using the contents of the specification and drawings of this application, or direct / indirect applications in other related technical fields, are included in the patent protection scope of this application.

Claims

1. A node device, characterized in that, The node device includes: A CAN transceiver is used to connect to the CAN bus. Terminating resistor; Upstream monitoring lines are used to connect to upstream neighboring node devices; The upstream monitoring input module is used to monitor, through the upstream monitoring line, whether the upstream neighbor node device has connected the terminating resistor to the CAN bus.

2. The node device as described in claim 1, characterized in that, The node device also includes: A terminating resistor control module is used to control the terminating resistor to connect to the CAN bus; The control circuit of the terminal resistor control module is reused as the upstream monitoring circuit of the downstream neighbor node device, so that the downstream neighbor node device can determine whether the upstream neighbor node device has connected the terminal resistor to the CAN bus by the control signal status in the control circuit.

3. A CAN communication network system, characterized in that, The CAN communication network system includes: One host and several slave devices, wherein the slave devices are node devices as described in claim 1 or 2.

4. A processing method, characterized in that, The processing method is applied to the CAN communication network system as described in claim 3, and the processing method includes: Each of the slave devices reports its CAN communication status and the upstream monitoring status of its upstream neighbor node devices to the host. The host determines the communication status of each slave device based on the CAN communication status reported by each slave device and the upstream monitoring status.

5. The processing method as described in claim 4, characterized in that, The host determines the communication status of each slave device based on the CAN communication status reported by each slave device and the upstream monitoring status, including: If the CAN communication status of the target slave device is disconnected, and the upstream monitoring status reported by the downstream neighbor node device of the target slave device is not connected, then it is determined that the target slave device is in a communication state that has been physically removed.

6. The processing method as described in claim 4, characterized in that, The host determines the communication status of each slave device based on the CAN communication status reported by each slave device and the upstream monitoring status, and further includes: If the CAN communication status of the target slave device is out of contact, and the upstream monitoring status reported by the downstream neighbor node device of the target slave device is in the access status, then the target slave device is determined to be in a communication state where communication is out of contact but physically online.

7. The processing method as described in claim 4, characterized in that, After each slave device reports its CAN communication status and the upstream monitoring status of its upstream neighbor node to the host, the system further includes: The host establishes the network topology of the CAN communication network and determines the end slave in the network topology based on the CAN communication status reported by each slave and the upstream monitoring status.

8. The processing method as described in claim 7, characterized in that, After establishing the network topology of the CAN communication network and determining the end slave devices in the network topology, the process also includes: When the host determines that the communication status of the end slave has been physically removed, or when it determines that a new end slave is being added, it controls the new end slave to connect its terminating resistor to the CAN bus.

9. The processing method as described in claim 4, characterized in that, The processing method further includes: During the power-on addressing phase of the node device, the host configures the addressing address of each slave device through the upstream monitoring line of each slave device.

10. The processing method as described in claim 9, characterized in that, The configuration of the addressing addresses of each of the slave devices includes: The slave device receives the first address of the slave device through the upstream monitoring line, constructs the second address of the downstream neighbor node device based on the first address, and transmits the second address to the downstream neighbor node device through the upstream monitoring line of the downstream neighbor node device.