A method and apparatus for detecting a can bus error frame
Patent Information
- Application Number
- CN202610849291.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-12
- Publication Date
- 2026-09-11
AI Technical Summary
[0002]在现有汽车电子系统中,CAN总线的错误识别完全由底层CAN控制器处理,错误信息直接反映在总线上,但上层应用层无法感知这些错误细节
本方法通过在CAN控制单元层面,以固定且小于一帧CAN报文总位数的采样周期,连续读取接收错误计数值和/或发送错误计数值,并基于这些计数值的变化来识别CAN总线的错误帧,这种自动化的探测机制避免了现有技术中耗时的人工排查过程,提高了故障诊断的效率。
Smart Images

Figure CN122741402A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of error frame detection technology, and in particular to a method and apparatus for detecting CAN bus error frames. Background Technology
[0002] In existing automotive electronic systems, CAN bus error identification is entirely handled by the underlying CAN controller, and error information is directly reflected on the bus, but the upper application layer cannot perceive these error details.
[0003] When erroneous frames occur on the vehicle's CAN bus, the diagnostic process heavily relies on manual on-site troubleshooting. Engineers must manually remove and reinsert each ECU fuse on the actual vehicle to isolate the fault source. This operation is not only time-consuming and cumbersome but also requires extensive preparatory work, including familiarity with the precise location of the corresponding fuse for each ECU, the specific layout of the fuse box, and the removal procedures for related obstructing components. In the complex electronic architecture of modern vehicles, this manual troubleshooting method is inefficient, significantly extending maintenance cycles and increasing operational difficulty, especially in scenarios where multiple ECUs work together. Therefore, there is an urgent need for a technical solution that can automatically and in real-time detect CAN bus erroneous frames to reduce reliance on manual intervention and improve diagnostic efficiency. Summary of the Invention
[0004] To achieve the above objectives, a first aspect of this disclosure provides a CAN bus error frame detection method for a CAN control unit, the method comprising: Multiple receive error counts and / or multiple transmit error counts are read from the CAN bus interface at a fixed sampling period; the sampling period is less than the total number of bits in a CAN message frame. The erroneous frames of the CAN bus are identified based on the plurality of receive error counts and / or the plurality of transmit error counts.
[0005] The first aspect of this application provides a CAN bus error frame detection method, which has at least the following beneficial effects: This method continuously reads the receive error count and / or transmit error count at the CAN control unit level with a sampling period of fixed value and less than the total number of bits in a CAN message frame, and identifies erroneous frames on the CAN bus based on changes in these counts. This automated detection mechanism avoids the time-consuming manual troubleshooting process in existing technologies and improves the efficiency of fault diagnosis.
[0006] To achieve the above objectives, a second aspect of this disclosure provides a CAN bus error frame detection device, the device comprising: The data reading module is used to read multiple receive error counts and / or multiple transmit error counts from the CAN bus interface according to a fixed sampling period; the sampling period is less than the total number of bits in a CAN message frame; An error frame identification module is used to identify error frames of the CAN bus based on the plurality of receive error count values and / or the plurality of transmit error count values.
[0007] To achieve the above objectives, a third aspect of this disclosure provides an electronic device including at least one controller and a memory for communicatively connecting to the controller; the memory stores instructions executable by the at least one controller, which, when executed by the at least one controller, cause the at least one controller to perform: a CAN bus error frame detection method as described in any of the embodiments of the first aspect.
[0008] To achieve the above objectives, a fourth aspect of the present disclosure provides a computer-readable storage medium storing computer-executable instructions for causing a computer to perform: a CAN bus error frame detection method as described in any of the embodiments of the first aspect.
[0009] It is understood that the beneficial effects of the second to fourth aspects compared with the related technologies are the same as the beneficial effects of the first aspect compared with the related technologies. Please refer to the relevant description in the first aspect above, which will not be repeated here. Attached Figure Description
[0010] To more clearly illustrate the technical solutions in the embodiments of this application, the drawings used in the description of the embodiments or related technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0011] Figure 1 This is a schematic diagram of a CAN bus error frame detection method provided in one embodiment of this application; Figure 2 This is a schematic diagram illustrating the error count value variation conditions provided in one embodiment of this application; Figure 3 This is a schematic diagram of a CAN bus error frame detection device according to an embodiment of this application; Figure 4 This is a schematic diagram of an electronic device provided in one embodiment of this application. Detailed Implementation
[0012] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0013] It should be noted that although functional modules are divided in the device schematic diagram and a logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than the module division in the device or the order in the flowchart. The terms "first," "second," etc., in the specification, claims, and the aforementioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence.
[0014] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of this application only and is not intended to limit this application. Reference Figure 1 One embodiment of this application provides a CAN bus error frame detection method for a CAN control unit, the method comprising: Step S110: Read multiple receive error counts and / or multiple transmit error counts from the CAN bus interface according to a fixed sampling period; the sampling period is less than the total number of bits in a CAN message frame. Step S120: Identify the erroneous frames of the CAN bus based on multiple receive error counts and / or multiple transmit error counts.
[0015] For ease of understanding, the following explains some key terms in this embodiment: CAN bus, or Controller Area Network, is a serial communication network used in automotive electronics, industrial automation, and other fields. The bus is designed for data exchange between microcontrollers in distributed control systems, achieving high efficiency and reliability in data exchange, and is particularly suitable for applications with real-time requirements.
[0016] The CAN control unit (ECU) is a hardware or software module that implements the CAN protocol. Its main functions include sending and receiving CAN messages, as well as error detection and handling. The control unit is responsible for managing the communication status on the CAN bus and generating and responding to error frames according to the protocol specifications.
[0017] The Receive Error Count (REC) is a counter maintained internally by the CAN controller to record error events that occur during the CAN control unit's reception of CAN messages.
[0018] The Transmission Error Count (TEC) is another counter maintained internally by the CAN controller to record error events that occur during the transmission of CAN messages by the CAN control unit.
[0019] The sampling period refers to the time interval between reading the received error count and / or transmitted error count from the CAN bus interface. The period is set to a fixed value to ensure continuous and regular monitoring of error states.
[0020] The total number of bits in a CAN message refers to all the bits occupied by a CAN message frame on the bus, including the arbitration field, data field, CRC field, ACK field, and control bits such as start and end of frame.
[0021] An error frame is a frame sent in CAN bus communication when a node detects a bus error, in order to notify other nodes and force all nodes into error handling mode. Sending an error frame causes the currently transmitting message to be aborted and triggers the error counter of the relevant node to increment.
[0022] This embodiment provides a CAN bus error frame detection method. The method identifies CAN bus error frames by periodically monitoring and analyzing the error count value of the CAN control unit.
[0023] First, the method involves reading multiple receive error counts and / or multiple transmit error counts from the CAN bus interface at a fixed sampling period. The sampling period is less than the total number of bits in a CAN message frame. The CAN control unit can be configured with an internal timer that triggers data reading operations at a preset frequency. Alternatively, the CAN control unit can utilize its built-in DMA (Direct Memory Access) controller to automatically transfer error counts from registers to a designated memory area during each fixed sampling period, thereby reducing the CPU load and ensuring real-time data reading.
[0024] Secondly, after obtaining a continuous sequence of error counts, these data can be analyzed to determine whether there are error frames. For example, the received error count or transmitted error count read in two adjacent sampling periods can be compared. Because the monitoring interval is shorter than the length of a message frame, REC or TEC will only increase the count when an error or error flag is detected. If the count value is found to increase in a short period of time, it can be preliminarily determined that there may be error frames on the CAN bus. This increase in the count value can reflect the cumulative trend of the error count value.
[0025] In existing technologies, the identification of CAN bus error frames mainly relies on the underlying CAN controller. Its error status is usually directly reflected on the bus, while upper-layer applications often cannot directly perceive it. When a vehicle CAN bus has an error frame problem, manual on-site troubleshooting is usually required, such as unplugging and plugging ECU fuses one by one. This operation is time-consuming and requires prior preparation.
[0026] In contrast, this embodiment, at the CAN control unit level, continuously reads the receive error count and / or transmit error count at a fixed sampling period less than the total number of bits in a CAN message frame, and identifies erroneous frames on the CAN bus based on changes in these counts. This automated detection mechanism avoids the time-consuming manual troubleshooting process in existing technologies, improving the efficiency of fault diagnosis. Furthermore, the error frame identification results can be provided to upper-layer applications, enabling upper-layer software to respond to bus errors promptly, such as recording fault codes, switching to alternative communication paths, or notifying the driver, thereby improving reliability and maintainability.
[0027] In some embodiments of this application, identifying erroneous frames on the CAN bus based on multiple receive error counts and / or multiple transmit error counts includes: Read the first and second reception error count values collected in two adjacent sampling periods in sequence; The range of the first received error count value is If the second receive error count is greater than the first receive error count, it is determined that there is an error frame on the CAN bus. The range of the first received error count value is If the difference between the second receive error count and the first receive error count is 1, it is determined that there is no error frame on the CAN bus.
[0028] In some embodiments of this application, identifying erroneous frames of the CAN bus based on multiple receive error counts and / or multiple transmit error counts further includes: The range of the first received error count value is If the second receive error count is equal to the first receive error count, then read the third receive error count, the third transmit error count, and the second transmit error count; wherein the third receive error count and the second receive error count are receive error counts collected in two adjacent sampling periods, and the second receive error count was collected before the third receive error count; the third transmit error count is collected at the same timestamp as the third receive error count, and the second transmit error count is collected at the same timestamp as the second receive error count; If the third receive error count is equal to the second receive error count, and the third transmit error count is equal to the second transmit error count, then an error frame is determined to exist on the CAN bus. If the difference between the third receive error count and the second receive error count is 1, or if the difference between the third transmit error count and the second transmit error count is 1, it is determined that there is no error frame on the CAN bus.
[0029] In some embodiments of this application, identifying erroneous frames of the CAN bus based on multiple receive error counts and / or multiple transmit error counts further includes: If the first receive error count is greater than 127 and the first receive error count is equal to the second receive error count, it is determined that there is no error frame on the CAN bus.
[0030] In some embodiments of this application, identifying CAN bus error frame acquisition based on multiple receive error counts and / or multiple transmit error counts further includes: If the first receive error count is greater than 127 and the second receive error count is greater than the first receive error count, it is determined that there is an error frame on the CAN bus. If the first receive error count is greater than 127 and the second receive error count is equal to 127, it is determined that there is no error frame on the CAN bus.
[0031] In some embodiments of this application, identifying erroneous frames on the CAN bus based on multiple receive error counts and / or multiple transmit error counts includes: Read the first and second transmission error count values collected in two adjacent sampling periods in sequence; If the first transmission error count is less than or equal to 255, and the difference between the second transmission error count and the first transmission error count is 7, or a multiple of 8, then an error frame is determined to exist on the CAN bus.
[0032] In some embodiments of this application, identifying erroneous frames of the CAN bus based on multiple receive error counts and / or multiple transmit error counts further includes: If the first transmission error count is less than or equal to 255 and the second transmission error count is less than the first transmission error count, it is determined that there is no error frame on the CAN bus.
[0033] In some embodiments of this application, identifying erroneous frames of the CAN bus based on multiple receive error counts and / or multiple transmit error counts further includes: If either the first or second transmission error count is greater than 255, the CAN bus is determined to be off.
[0034] For ease of understanding, please refer to Figure 2 This application provides the following embodiments: A standard CAN frame message consists of 108-132 bits (including bit padding, so the length is variable). The CAN control unit uses 98 times the bit time interval to call the underlying CAN_GETControllerRXErrorCounter and CAN_GETControllerTXErrorCounter interfaces to obtain the REC and TEC count values once.
[0035] The TEC count value detected at time T1 is recorded as TEC1, and the REC count value detected at time T1 is recorded as REC1; The TEC count value detected at time T2 is denoted as TEC2, and the REC count value detected at time T2 is denoted as REC2; The TEC count values detected at subsequent time points such as T3 and T4 are recorded as TEC3, TEC4, etc., and the REC count values detected at subsequent time points such as T3 and T4 are recorded as REC3, REC4, etc.
[0036] When the CAN control unit is a receiving node; (1) If REC1=REC2=0, it is determined that the bus is normal and there is no error frame; This is because when the receiving unit finishes receiving data normally (i.e., when the CRC (Cyclic Redundancy Check) does not detect any errors and returns the ACK (Acknowledge) bit normally), REC is ±0 when REC=0. Since the monitoring interval is shorter than the length of a frame, the count retrieval time T1 is after the start of a certain frame (SOF) and T2 is before the ACK. At this time, a frame is being transmitted normally on the bus, so it is reasonable for the REC or TEC count to remain unchanged.
[0037] (2) If 0 < REC1 ≤ 127 and REC2 = REC1, there are two possible cases: If REC3=REC2-1 or TEC3=TEC2-1, it is determined that the bus is normal and there is no error frame. If REC3=REC2 and TEC3=TEC2, it is determined that the bus condition is abnormal and there is an error frame. Since the sampling interval is shorter than the length of a message frame, the counting retrieval time T1 is after the SOF of a certain message frame and T2 is before the ACK bit. At this time, a message frame is being transmitted normally on the bus, so REC2=REC1.
[0038] When the counter retrieves time T3, if the bus is normal, that is, the control unit sends or receives a frame message normally, REC3=REC2-1 or TEC3=TEC2-1 will appear; otherwise, it is judged that there is an error frame on the bus.
[0039] (3) If 0 < REC1 ≤ 127 and REC2 = REC1 - 1, it is determined that the bus is normal and there is no error frame. This is because the monitoring interval is shorter than the length of a message frame. The count retrieval time T1 is before the EOF (End Of Frame) segment of a certain message frame, and T2 is after the SOF of the next frame. At this time, it is considered that one message is received normally.
[0040] (4) If 0 < REC1 ≤ 127 and REC2 > REC1, it is determined that the bus condition is abnormal and there is an error frame; Because REC only increments its count when it detects an error or an error flag, there must be an error frame on the bus during this call.
[0041] (5) If REC1 > 127 and REC2 = 127, it is determined that the bus is normal, there is no error frame, and the message is successfully received.
[0042] (6) If REC1 > 127 and REC2 > REC1, it is determined that the bus condition is abnormal and there is an error frame; This means that REC only increments the count when it detects an error or an error flag. In this case, there must be an error frame on the bus.
[0043] When the CAN control unit is a transmitting node; (1) If TEC1 > 255, it is determined that the bus is in the off state; (2) If TEC1≤255 and the difference between TEC2-TEC1 is an integer multiple of 8, it is judged that: the bus condition is abnormal and there is an error frame; This is because TEC only increments the counter when it detects an error or an error flag; in this case, there will definitely be an error frame on the bus. Figure 2 It can be seen that TEC increases by 8 each time, and the count is decremented by 1 when a message is successfully sent. The interval between two count retrievals is less than one frame of transmission time, meaning that the value retrieved at time T2 can only decrease by a maximum of 1.
[0044] In the above scenario, when the difference between two count retrievals is a multiple of 8, it indicates that the ECU continuously detected errors during the count retrieval period and failed to successfully send a complete message. In the next case, the count retrieval difference is 7, indicating that the ECU received an ACK response during the count retrieval period and that an error frame existed on the bus after the EOF of that frame, or that the ECU actively detected an error.
[0045] (3) If TEC1≤255 and the difference between TEC2-TEC1=7, it is judged that the bus condition is abnormal and there is an error frame; Because REC only increments its count when it detects an error or an error flag, there must be an error frame on the bus during this call.
[0046] (4) If TEC1≤255 and TEC1>TEC2, it is determined that the bus is normal, there is no erroneous frame, and the message was successfully sent once; Due to the limitation of the counting retrieval interval (less than the transmission time of one frame of message), if there is an error on the bus during this period, the difference will be at least 7. In the current case, the TEC decreases, which proves that the bus is normal and a message has been successfully sent once.
[0047] Figure 3 One embodiment of this application provides a CAN bus error frame detection device, the device comprising: The data reading module 1001 is used to read multiple receive error counts and / or multiple transmit error counts from the CAN bus interface according to a fixed sampling period; the sampling period is less than the total number of bits in a CAN message frame; The error frame identification module 1002 is used to identify error frames of the CAN bus based on multiple receive error counts and / or multiple transmit error counts.
[0048] It should be noted that the CAN bus error frame detection device in this application embodiment is based on the same inventive concept as the aforementioned CAN bus error frame detection method. Therefore, the CAN bus error frame detection device in this application embodiment corresponds to the aforementioned CAN bus error frame detection method. For the specific implementation process, please refer to the aforementioned generative intelligent question answering method, which will not be repeated here.
[0049] One embodiment of this application also provides an electronic device, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the aforementioned CAN bus error frame detection method. The electronic device includes (e.g.) Figure 4 ): At least one battery; At least one memory; At least one processor; At least one program; The program is stored in memory, and the processor executes at least one program to implement the CAN bus error frame detection method described above in this disclosure.
[0050] This electronic device can be any smart terminal, including mobile phones, tablets, personal digital assistants (PDAs), and in-vehicle computers.
[0051] The electronic devices according to embodiments of this application will now be described in detail.
[0052] The processor 1600 can be implemented using a general-purpose central processing unit (CPU), microprocessor, application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of this disclosure. The memory 1700 can be implemented as a read-only memory (ROM), static storage device, dynamic storage device, or random access memory (RAM). The memory 1700 can store the operating system and other application programs. When the technical solutions provided in the embodiments of this specification are implemented through software or firmware, the relevant program code is stored in the memory 1700 and is called and executed by the processor 1600 to execute a CAN bus error frame detection method according to an embodiment of this disclosure.
[0053] The input / output interface 1800 is used to implement information input and output. The communication interface 1900 is used to enable communication and interaction between this device and other devices. Communication can be achieved through wired means (such as USB, Ethernet cable, etc.) or wireless means (such as mobile network, WIFI, Bluetooth, etc.). Bus 2000 transmits information between various components of the device (e.g., processor 1600, memory 1700, input / output interface 1800, and communication interface 1900); The processor 1600, memory 1700, input / output interface 1800 and communication interface 1900 are connected to each other within the device via bus 2000.
[0054] This disclosure also provides a storage medium, which is a computer-readable storage medium storing computer-executable instructions for causing a computer to execute the aforementioned CAN bus error frame detection method.
[0055] Memory, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs and non-transitory computer-executable programs. Furthermore, memory may include high-speed random access memory, and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some embodiments, memory may optionally include memory remotely located relative to the processor, and these remote memories can be connected to the processor via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
[0056] The embodiments described in this disclosure are for the purpose of more clearly illustrating the technical solutions of this disclosure and do not constitute a limitation on the technical solutions provided by this disclosure. As those skilled in the art will know, with the evolution of technology and the emergence of new application scenarios, the technical solutions provided by this disclosure are also applicable to similar technical problems.
[0057] Those skilled in the art will understand that the technical solutions shown in the figures do not constitute a limitation on the embodiments of this disclosure, and may include more or fewer steps than shown, or combine certain steps, or different steps.
[0058] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.
[0059] Those skilled in the art will understand that all or some of the steps in the methods disclosed above, as well as the functional modules / units in the systems and devices, can be implemented as software, firmware, hardware, or suitable combinations thereof.
[0060] The terms “first,” “second,” “third,” “fourth,” etc. (if present) in the specification and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms “comprising” and “having,” and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0061] It should be understood that in this application, "at least one (item)" means one or more, and "more than" means two or more. "And / or" is used to describe the relationship between related objects, indicating that three relationships can exist. For example, "A and / or B" can represent three cases: only A exists, only B exists, and both A and B exist simultaneously, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one (item) of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one (item) of a, b, or c can represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, and c can be single or multiple.
[0062] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0063] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0064] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0065] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes multiple instructions to cause an electronic device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing programs, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0066] The above is a detailed description of the preferred embodiments of this application. However, the embodiments of this application are not limited to the above-described implementation methods. Those skilled in the art can make various equivalent modifications or substitutions without departing from the spirit of the embodiments of this application. All such equivalent modifications or substitutions are included within the scope defined by the claims of the embodiments of this application.
Claims
1. A method for detecting CAN bus error frames, characterized in that, For a CAN control unit, the method includes: Multiple receive error counts and / or multiple transmit error counts are read from the CAN bus interface at a fixed sampling period; the sampling period is less than the total number of bits in a CAN message frame. The erroneous frames of the CAN bus are identified based on the plurality of receive error counts and / or the plurality of transmit error counts.
2. The CAN bus error frame detection method according to claim 1, characterized in that, The step of identifying erroneous frames on the CAN bus based on the plurality of receive error counts and / or the plurality of transmit error counts includes: Read the first and second reception error count values collected in two adjacent sampling periods in sequence; Within the range of the first reception error count value If the second receive error count value is greater than the first receive error count value, it is determined that there is an error frame in the CAN bus; Within the range of the first reception error count value If the difference between the second receive error count value and the first receive error count value is 1, it is determined that there is no error frame on the CAN bus.
3. The CAN bus error frame detection method according to claim 2, characterized in that, The step of identifying error frames on the CAN bus based on the plurality of receive error counts and / or the plurality of transmit error counts further includes: Within the range of the first reception error count value If the second receive error count is equal to the first receive error count, then read the third receive error count, the third transmit error count, and the second transmit error count; wherein the third receive error count and the second receive error count are receive error counts collected in two adjacent sampling periods, and the second receive error count was collected before the third receive error count; the third transmit error count is collected at the same timestamp as the third receive error count, and the second transmit error count is collected at the same timestamp as the second receive error count; If the third receive error count is equal to the second receive error count, and the third transmit error count is equal to the second transmit error count, then it is determined that there is an error frame in the CAN bus. If the difference between the third receive error count and the second receive error count is 1, or if the difference between the third transmit error count and the second transmit error count is 1, it is determined that there is no error frame on the CAN bus.
4. The CAN bus error frame detection method according to claim 2, characterized in that, The step of identifying error frames on the CAN bus based on the plurality of receive error counts and / or the plurality of transmit error counts further includes: If the first receive error count is greater than 127, and the first receive error count and the second receive error count are equal, it is determined that there are no error frames on the CAN bus.
5. A CAN bus error frame detection method according to claim 2, characterized in that, The step of identifying the error frame acquisition of the CAN bus based on the plurality of receive error count values and / or the plurality of transmit error count values further includes: If the first receive error count is greater than 127 and the second receive error count is greater than the first receive error count, it is determined that there is an error frame on the CAN bus. If the first receive error count is greater than 127 and the second receive error count is equal to 127, it is determined that there are no error frames on the CAN bus.
6. The CAN bus error frame detection method according to claim 1, characterized in that, The step of identifying erroneous frames on the CAN bus based on the plurality of receive error counts and / or the plurality of transmit error counts includes: Read the first and second transmission error count values collected in two adjacent sampling periods in sequence; If the first transmission error count is less than or equal to 255, and the difference between the second transmission error count and the first transmission error count is 7, or a multiple of 8, then the CAN bus is determined to have an error frame.
7. A CAN bus error frame detection method according to claim 6, characterized in that, The step of identifying error frames on the CAN bus based on the plurality of receive error counts and / or the plurality of transmit error counts further includes: If the first transmission error count is less than or equal to 255 and the second transmission error count is less than the first transmission error count, it is determined that there is no error frame on the CAN bus.
8. A CAN bus error frame detection method according to claim 6, characterized in that, The step of identifying error frames on the CAN bus based on the plurality of receive error counts and / or the plurality of transmit error counts further includes: If either the first transmission error count or the second transmission error count is greater than 255, the CAN bus is determined to be off.
9. A CAN bus error frame detection device, characterized in that, The device includes: The data reading module is used to read multiple receive error counts and / or multiple transmit error counts from the CAN bus interface according to a fixed sampling period; the sampling period is less than the total number of bits in a CAN message frame; An error frame identification module is used to identify error frames of the CAN bus based on the plurality of receive error count values and / or the plurality of transmit error count values.
10. An electronic device, characterized in that, It includes at least one controller and a memory for communicatively connecting with the controller; the memory stores instructions executable by the at least one controller, which, when executed by the at least one controller, causes the at least one controller to perform a CAN bus error frame detection method as described in any one of claims 1 to 8.