A method and device for detecting the baud rate of a vehicle OBD interface CAN communication
Patent Information
- Application Number
- CN202610942879.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-26
- Publication Date
- 2026-10-16
AI Technical Summary
[0003]然而,实践发现,传统的检测方式针对每种车型车辆均是固定通过全引脚和全波特率来进行检测,检测引脚和波特率的范围较大,容易导致波特率的检测效率低,且获取波特率时造码的风险较大
本发明实施例中,根据车辆的车辆类型,生成车辆的通信配置文件,通信配置文件至少包括通信检测节点配置信息,通信检测节点配置信息包括至少一个通信检测节点、每一通信检测节点的逻辑通道集合、每一通信检测节点的第一波特率集合的至少一种;从通信配置文件中读取当前待检测的目标通信检测节点以及目标通信检测节点所需的目标逻辑通道;根据目标通信检测节点的目标逻辑通道和目标通信检测节点的第一波特率集合,判断目标通信检测节点的当前条件是否满足第一预设通信条件,得到第一判断结果,第一预设通信条件用于表示CAN控制器的通信模式为静默模式时上位机、下位机及OBD接口之间实现通信的条件;当第一判断结果为是时,确定目标通信检测节点检测完成,并重新执行从通信配置文件中确定出当前待检测的目标通信检测节点以及目标通信检测节点所需的目标逻辑通道的操作,直至所有通信检测节点均被检测完毕。可见,实施本发明能够根据车辆类型自动生成车辆的通信配置文件,并根据通信配置文件,有针对性地选择当前待检测的目标通信检测节点及其所需的目标逻辑通道,再根据目标通信检测节点的目标逻辑通道和目标通信检测节点的第一波特率集合,判断目标通信检测节点的当前条件是否满足第一预设通信条件,当判断出满足第一预设通信条件时,确定目标通信检测节点检测完成,重复确定目标通信检测节点及其所需的目标逻辑通道的过程,如此循环,直至所有通信检测节点均被检测完毕,能够基于车辆类型提高待检测的通信检测节点及其逻辑通道的选择效率和选择准确性从而能够提高通信检测节点的检测效率和检测准确性,还有利于减少获取波特率时造码的风险,进而有利于提升检测安全性。
Smart Images

Figure CN122933490A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of communication technology, and in particular to a method and apparatus for detecting the baud rate of CAN communication via a vehicle OBD interface. Background Technology
[0002] Currently, vehicle baud rate detection typically involves polling and listening to all pins (all possible pins) and all baud rates (all possible baud rates). When the vehicle's OBD interface does not broadcast CAN, it usually attempts to send common or general commands sequentially for detection.
[0003] However, in practice, it has been found that traditional detection methods use a fixed full-pin and full-baud-rate approach for each vehicle model. This results in a wide range of pins and baud rates, which easily leads to low baud-rate detection efficiency and a high risk of code manipulation when acquiring the baud rate. Therefore, proposing a technical solution to improve baud-rate detection efficiency is particularly important. Summary of the Invention
[0004] This invention provides a method and apparatus for detecting the baud rate of CAN communication in a vehicle OBD interface, which can improve the detection efficiency of baud rate and help reduce the risk of code forgery when obtaining the baud rate.
[0005] To address the aforementioned technical problems, the first aspect of this invention discloses a method for detecting the baud rate of a vehicle's OBD interface CAN communication. The method is applied to a CAN bus, which is used to detect the required baud rate of the vehicle's OBD interface through a communication mode between a host computer and a slave computer based on a CAN controller. The communication module includes a silent mode or a normal mode. The method includes: Based on the vehicle type, a communication configuration file for the vehicle is generated. The communication configuration file includes at least communication detection node configuration information, which includes at least one of the following: at least one communication detection node, a logical channel set for each communication detection node, and a first baud rate set for each communication detection node. Read the target communication detection node to be detected and the target logical channel required by the target communication detection node from the communication configuration file; Based on the target logical channel of the target communication detection node and the first baud rate set of the target communication detection node, it is determined whether the current condition of the target communication detection node meets the first preset communication condition, and a first judgment result is obtained. The first preset communication condition is used to indicate the conditions for communication between the host computer, the slave computer and the OBD interface when the communication mode of the CAN controller is the silent mode. When the first judgment result is yes, it is determined that the detection of the target communication detection node is complete.
[0006] As an optional implementation, in a first aspect of the present invention, the step of determining whether the current conditions of the target communication detection node satisfy a first preset communication condition based on the target logical channel of the target communication detection node and the first baud rate set of the target communication detection node, and obtaining a first determination result, includes: The logical channel of the target communication detection node is set as the target logical channel, and the communication mode of the CAN controller is set to the silent mode to create the first communication link of the CAN controller. The first communication link is used to test whether the host computer can receive the CAN frame data sent by the OBD interface through the slave computer. Based on the first baud rate set of the target communication detection node, determine whether the first baud rate set of the target communication detection node contains the communication baud rate of the first communication link; When it is determined that the first baud rate set of the target communication detection node contains the communication baud rate of the first communication link, the first determination result is determined to be that the current condition of the target communication detection node satisfies the first preset communication condition. When it is determined that the first baud rate set of the target communication detection node does not contain the communication baud rate of the first communication link, the first determination result is that the current condition of the target communication detection node does not meet the first preset communication condition.
[0007] As an optional implementation, in the first aspect of the present invention, determining whether the first baud rate set of the target communication detection node contains the communication baud rate of the first communication link, based on the first baud rate set of the target communication detection node, includes: Based on the first preset detection order, one of the first baud rates from the first set of the target communication detection nodes is determined as the first current baud rate to be detected, so as to determine whether the first current baud rate meets the first preset detection condition. The first preset detection condition is used to represent the condition for the host computer to receive vehicle broadcast data transmitted through the first communication link within a first preset time period. When it is determined that the first current baud rate meets the first preset detection condition, the first current baud rate that meets the first preset detection condition is determined as the communication baud rate of the first communication link; When it is determined that the first current baud rate does not meet the first preset detection condition, the operation of selecting one of the first baud rates from the first baud rate set of the target communication detection node based on the first preset detection order is re-executed as the first current baud rate to determine whether the first current baud rate meets the first preset detection condition. When all the determined first current baud rates do not meet the first preset detection conditions, it is determined that the first baud rate set of the target communication detection node does not contain the communication baud rate of the first communication link.
[0008] As an optional implementation, in the first aspect of the present invention, the communication configuration file further includes a second baud rate set for the detection activation node of each of the communication detection nodes; Furthermore, the method further includes: When the first judgment result is negative, the detection activation node of the target communication detection node is read; Based on the target logical channel of the target communication detection node and the second baud rate set of the detection activation node, it is determined whether the current condition of the detection activation node meets the second preset communication condition, and a second judgment result is obtained. The second preset communication condition is used to indicate the conditions for communication between the host computer, the slave computer and the OBD interface when the communication mode of the CAN controller is the normal mode. When the second judgment result is yes, it is determined that the detection of the target communication detection node is complete.
[0009] As an optional implementation, in the first aspect of the present invention, the step of determining whether the current condition of the detection activation node satisfies the second preset communication condition based on the target logical channel of the target communication detection node and the second baud rate set of the detection activation node, and obtaining the second determination result, includes: The logical channel of the detection activation node is set as the target logical channel of the target communication detection node, and the communication mode of the CAN controller is set to the normal mode to create a second communication link of the CAN controller. The second communication link is used to test whether the host computer can receive the reply data corresponding to the preset command sent by the OBD interface through the lower computer after the host computer sends a preset command to the OBD interface through the lower computer. Based on the second baud rate set of the detected active nodes, determine whether the second baud rate set of the detected active nodes contains the communication baud rate of the second communication link; When it is determined that the second baud rate set of the detection activation node contains the communication baud rate of the second communication link, the second determination result is determined to be that the current condition of the detection activation node meets the second preset communication condition; When it is determined that the second baud rate set of the detection activation node does not contain the communication baud rate of the second communication link, the second determination result is determined to be that the current condition of the detection activation node does not meet the second preset communication condition.
[0010] As an optional implementation, in the first aspect of the present invention, determining whether the second baud rate set of the detected active node contains the communication baud rate of the second communication link, based on the second baud rate set of the detected active node, includes: Based on the second preset detection order, one of the second baud rates from the set of the second baud rates of the detection activation node is selected as the second current baud rate to be detected, so as to determine whether the second current baud rate meets the second preset detection condition. The second preset detection condition is used to represent the condition for the host computer to receive the vehicle response data transmitted through the second communication link within a second preset time period. When it is determined that the second current baud rate meets the second preset detection condition, the second current baud rate that meets the second preset detection condition is determined as the communication baud rate of the second communication link; When it is determined that the second current baud rate does not meet the second preset detection condition, the operation of selecting one of the second baud rates from the set of second baud rates of the detection activation node based on the second preset detection order is re-executed as the second current baud rate to be detected, so as to determine whether the second current baud rate meets the second preset detection condition. When all the determined second current baud rates do not meet the second preset detection conditions, it is determined that the second baud rate set of the detection activation node does not contain the communication baud rate of the second communication link.
[0011] As an optional implementation, in the first aspect of the present invention, the method further includes: Determine whether the CAN communication parameters corresponding to the vehicle model and determined by the personnel in the communication configuration file exist. When it is determined that the CAN communication parameters exist in the communication configuration file, the CAN controller is configured according to the CAN communication parameters to realize communication between the host computer, the slave computer and the OBD interface; When it is determined that the CAN communication parameters are not present in the communication configuration file, the baud rate detection process of the vehicle's OBD interface is initiated.
[0012] A second aspect of this invention discloses a device for detecting the baud rate of a vehicle's OBD interface CAN communication. The device is applied to a CAN bus, which is used to detect the required baud rate of the vehicle's OBD interface via a communication mode between a host computer and a slave computer based on a CAN controller. The communication module includes a silent mode or a normal mode. The device includes: A generation module is used to generate a communication configuration file for the vehicle based on the vehicle type. The communication configuration file includes at least communication detection node configuration information, which includes at least one of the following: at least one communication detection node, a logical channel set for each communication detection node, and a first baud rate set for each communication detection node. The reading module is used to read the target communication detection node to be detected and the target logical channel required by the target communication detection node from the communication configuration file; The judgment module is used to determine whether the current condition of the target communication detection node meets the first preset communication condition based on the target logical channel of the target communication detection node and the first baud rate set of the target communication detection node, and to obtain a first judgment result. The first preset communication condition is used to indicate the conditions for communication between the host computer, the slave computer and the OBD interface when the communication mode of the CAN controller is the silent mode. The determination module is used to determine that the detection of the target communication detection node is complete when the first judgment result is yes.
[0013] As an optional implementation, in a second aspect of the present invention, the specific method by which the judgment module determines whether the current conditions of the target communication detection node meet the first preset communication conditions based on the target logical channel of the target communication detection node and the first baud rate set of the target communication detection node, and obtains the first judgment result, includes: The logical channel of the target communication detection node is set as the target logical channel, and the communication mode of the CAN controller is set to the silent mode to create the first communication link of the CAN controller. The first communication link is used to test whether the host computer can receive the CAN frame data sent by the OBD interface through the slave computer. Based on the first baud rate set of the target communication detection node, determine whether the first baud rate set of the target communication detection node contains the communication baud rate of the first communication link; When it is determined that the first baud rate set of the target communication detection node contains the communication baud rate of the first communication link, the first determination result is determined to be that the current condition of the target communication detection node satisfies the first preset communication condition. When it is determined that the first baud rate set of the target communication detection node does not contain the communication baud rate of the first communication link, the first determination result is that the current condition of the target communication detection node does not meet the first preset communication condition.
[0014] As an optional implementation, in a second aspect of the present invention, the specific method by which the determining module determines whether the first baud rate set of the target communication detection node contains the communication baud rate of the first communication link includes: Based on the first preset detection order, one of the first baud rates from the first set of the target communication detection nodes is determined as the first current baud rate to be detected, so as to determine whether the first current baud rate meets the first preset detection condition. The first preset detection condition is used to represent the condition for the host computer to receive vehicle broadcast data transmitted through the first communication link within a first preset time period. When it is determined that the first current baud rate meets the first preset detection condition, the first current baud rate that meets the first preset detection condition is determined as the communication baud rate of the first communication link; When it is determined that the first current baud rate does not meet the first preset detection condition, the operation of selecting one of the first baud rates from the first baud rate set of the target communication detection node based on the first preset detection order is re-executed as the first current baud rate to determine whether the first current baud rate meets the first preset detection condition. When all the determined first current baud rates do not meet the first preset detection conditions, it is determined that the first baud rate set of the target communication detection node does not contain the communication baud rate of the first communication link.
[0015] As an optional implementation, in a second aspect of the invention, the communication configuration file further includes a second baud rate set for the detection activation nodes of each of the communication detection nodes; Furthermore, the reading module is also configured to read the detection activation node of the target communication detection node when the first judgment result is negative; The judgment module is further configured to determine whether the current condition of the detection activation node meets the second preset communication condition based on the target logical channel of the target communication detection node and the second baud rate set of the detection activation node, and obtain a second judgment result. The second preset communication condition is used to indicate the conditions for communication between the host computer, the slave computer and the OBD interface when the communication mode of the CAN controller is the normal mode. The determining module is further configured to determine that the target communication detection node detection is complete when the second judgment result is yes.
[0016] As an optional implementation, in a second aspect of the present invention, the specific method by which the judgment module determines whether the current condition of the detection activation node satisfies the second preset communication condition based on the target logical channel of the target communication detection node and the second baud rate set of the detection activation node, and obtains the second judgment result, includes: The logical channel of the detection activation node is set as the target logical channel of the target communication detection node, and the communication mode of the CAN controller is set to the normal mode to create a second communication link of the CAN controller. The second communication link is used to test whether the host computer can receive the reply data corresponding to the preset command sent by the OBD interface through the lower computer after the host computer sends a preset command to the OBD interface through the lower computer. Based on the second baud rate set of the detected active nodes, determine whether the second baud rate set of the detected active nodes contains the communication baud rate of the second communication link; When it is determined that the second baud rate set of the detection activation node contains the communication baud rate of the second communication link, the second determination result is determined to be that the current condition of the detection activation node meets the second preset communication condition; When it is determined that the second baud rate set of the detection activation node does not contain the communication baud rate of the second communication link, the second determination result is determined to be that the current condition of the detection activation node does not meet the second preset communication condition.
[0017] As an optional implementation, in a second aspect of the present invention, the specific method by which the determining module determines whether the second baud rate set of the detected active node contains the communication baud rate of the second communication link includes: Based on the second preset detection order, one of the second baud rates from the set of the second baud rates of the detection activation node is selected as the second current baud rate to be detected, so as to determine whether the second current baud rate meets the second preset detection condition. The second preset detection condition is used to represent the condition for the host computer to receive the vehicle response data transmitted through the second communication link within a second preset time period. When it is determined that the second current baud rate meets the second preset detection condition, the second current baud rate that meets the second preset detection condition is determined as the communication baud rate of the second communication link; When it is determined that the second current baud rate does not meet the second preset detection condition, the operation of selecting one of the second baud rates from the set of second baud rates of the detection activation node based on the second preset detection order is re-executed as the second current baud rate to be detected, so as to determine whether the second current baud rate meets the second preset detection condition. When all the determined second current baud rates do not meet the second preset detection conditions, it is determined that the second baud rate set of the detection activation node does not contain the communication baud rate of the second communication link.
[0018] As an optional implementation, in a second aspect of the present invention, the determining module is further configured to determine whether the communication configuration file contains CAN communication parameters determined by the personnel of the vehicle model corresponding to the vehicle. The device also includes: A communication module is used to set parameters for the CAN controller according to the CAN communication parameters when the judgment module determines that the CAN communication parameters exist in the communication configuration file, so as to realize communication between the host computer, the slave computer and the OBD interface; The startup module is used to initiate the baud rate detection process of the vehicle's OBD interface when the judgment module determines that the CAN communication parameters are not present in the communication configuration file.
[0019] A third aspect of the present invention discloses another device for detecting the baud rate of CAN communication in a vehicle OBD interface, the device comprising: Memory containing executable program code; A processor coupled to the memory; The processor calls the executable program code stored in the memory to execute the method for detecting the baud rate of vehicle OBD interface CAN communication disclosed in the first aspect of the present invention.
[0020] The fourth aspect of the present invention discloses a computer storage medium storing computer instructions, which, when invoked, are used to execute the method for detecting the baud rate of the vehicle OBD interface CAN communication disclosed in the first aspect of the present invention.
[0021] Compared with the prior art, the embodiments of the present invention have the following beneficial effects: In this embodiment of the invention, a communication configuration file for the vehicle is generated according to the vehicle type. The communication configuration file includes at least one of the following: communication detection node configuration information, which includes at least one communication detection node, a set of logical channels for each communication detection node, and a set of first baud rates for each communication detection node. The target communication detection node to be detected and the target logical channels required by the target communication detection node are read from the communication configuration file. Based on the target logical channels and the first baud rate set of the target communication detection node, it is determined whether the current conditions of the target communication detection node meet the first preset communication conditions, and a first judgment result is obtained. The first preset communication conditions are used to indicate the conditions for communication between the host computer, the slave computer, and the OBD interface when the communication mode of the CAN controller is in silent mode. When the first judgment result is yes, it is determined that the detection of the target communication detection node is completed, and the operation of determining the target communication detection node to be detected and the target logical channels required by the target communication detection node from the communication configuration file is repeated until all communication detection nodes are detected. As can be seen, implementing this invention can automatically generate a vehicle communication configuration file based on the vehicle type, and selectively choose the target communication detection node to be detected and its required target logical channel based on the communication configuration file. Then, based on the target logical channel of the target communication detection node and the first baud rate set of the target communication detection node, it is determined whether the current condition of the target communication detection node meets the first preset communication condition. When it is determined that the first preset communication condition is met, it is determined that the target communication detection node detection is completed. The process of determining the target communication detection node and its required target logical channel is repeated until all communication detection nodes have been detected. This can improve the selection efficiency and accuracy of the communication detection node and its logical channel based on the vehicle type, thereby improving the detection efficiency and accuracy of the communication detection node. It also helps to reduce the risk of code forgery when obtaining the baud rate, thus improving the detection security. Attached Figure Description
[0022] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0023] Figure 1 This is a flowchart illustrating a method for detecting the baud rate of a vehicle OBD interface CAN communication according to an embodiment of the present invention. Figure 2 This is a flowchart illustrating another method for detecting the baud rate of CAN communication via a vehicle OBD interface, as disclosed in an embodiment of the present invention. Figure 3 This is a schematic diagram illustrating the applicable scenario for the method for detecting the baud rate of a vehicle OBD interface CAN communication disclosed in an embodiment of the present invention. Figure 4 This is a schematic diagram of a process for determining a vehicle's communication configuration file based on the vehicle type, as disclosed in an embodiment of the present invention. Figure 5 This is a schematic diagram of a rule format for baud rate detection in a communication configuration file disclosed in an embodiment of the present invention; Figure 6 This is a flowchart illustrating another method for detecting the baud rate of CAN communication via a vehicle OBD interface, as disclosed in an embodiment of the present invention. Figure 7 This is a schematic diagram of the structure of a device for detecting the baud rate of CAN communication in a vehicle OBD interface, as disclosed in an embodiment of the present invention. Figure 8 This is a schematic diagram of another device for detecting the baud rate of vehicle OBD interface CAN communication disclosed in an embodiment of the present invention; Figure 9 This is a schematic diagram of the structure of another vehicle OBD interface CAN communication baud rate detection device disclosed in an embodiment of the present invention. Detailed Implementation
[0024] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0025] The terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this invention are used to distinguish different objects, not to describe a specific order. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, apparatus, product, or end that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, products, or ends.
[0026] In this document, the term "embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of the invention. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.
[0027] This invention discloses a method and apparatus for detecting the baud rate of CAN communication in a vehicle's OBD interface. It can automatically generate a vehicle communication configuration file based on the vehicle type, and selectively choose the target communication detection node and its required target logical channel based on the configuration file. Then, based on the target logical channel and the first baud rate set of the target communication detection node, it determines whether the current condition of the target communication detection node meets a first preset communication condition. When the first preset communication condition is met, the detection of the target communication detection node is considered complete. This process of determining the target communication detection node and its required target logical channel is repeated until all communication detection nodes have been detected. This method improves the selection efficiency and accuracy of the communication detection node and its logical channel based on the vehicle type, thereby improving the detection efficiency and accuracy. It also helps reduce the risk of code forgery when obtaining the baud rate, thus improving detection security. Detailed descriptions follow.
[0028] Example 1 Please see Figure 1 , Figure 1 This is a flowchart illustrating a method for detecting the baud rate of a vehicle OBD interface CAN communication according to an embodiment of the present invention. Figure 1 The described method for detecting the baud rate of the vehicle's OBD interface CAN communication can be applied to the CAN bus. The CAN bus is used to detect the required baud rate of the vehicle's OBD interface through a communication mode between the host computer and the slave computer based on the CAN controller. The communication module 305 includes a silent mode or a normal mode. Figure 1 As shown, the method for detecting the baud rate of the vehicle's OBD interface CAN communication may include the following operations: 101. Generate the vehicle's communication configuration file based on the vehicle type.
[0029] In this embodiment of the invention, the vehicle type can be determined through user selection. Specifically, the user selects the MMY elements of the vehicle through the host computer interface. The MMY elements include at least one of brand, model, and year. Furthermore, based on the vehicle's MMY elements, a type that matches the MMY elements is determined from a variety of pre-determined types and used as the vehicle type.
[0030] In this embodiment of the invention, optionally, the communication configuration file includes at least communication detection node configuration information. The communication detection node configuration information includes at least one of the following: at least one communication detection node, a logical channel set for each communication detection node, and a first baud rate set for each communication detection node. The logical channel set includes at least one logical channel, and the first baud rate set includes at least one first baud rate. Further optionally, the communication configuration file also includes a second baud rate set for the detection activation node of each communication detection node. The second baud rate set includes at least one second baud rate. This aspect of the embodiment is not limited.
[0031] 102. Read the target communication detection node to be detected and the target logical channel required by the target communication detection node from the communication configuration file.
[0032] It should be noted that the target logic channel required by the target communication detection node refers to the logic channel that needs to be detected among all the logic channels of the target communication detection node, and the logic channel refers to the CAN pin.
[0033] In this embodiment of the invention, optionally, the communication configuration file may also include the detection order of each communication detection node. Specifically, the target communication detection node to be detected is read from the communication configuration file according to the detection order of each communication detection node. Further optionally, the logical channel set of each communication detection node included in the communication configuration file may include the target logical channels required by that communication detection node. For example, assuming the communication detection nodes include CheckBus1 node and CheckBus2 node, the CAN pins required by CheckBus1 node are denoted as <6,14> in the communication configuration file, and the CAN pins required by CheckBus2 node are denoted as <3,11> in the communication configuration file.
[0034] 103. Based on the target logical channel of the target communication detection node and the first baud rate set of the target communication detection node, determine whether the current conditions of the target communication detection node meet the first preset communication conditions, and obtain the first judgment result.
[0035] In this embodiment of the invention, the first preset communication condition is used to indicate the conditions under which communication is achieved between the host computer, the slave computer, and the OBD interface when the communication mode of the CAN controller is silent mode. The silent mode indicates a mode in which the host computer does not actively send data but can receive CAN frame data sent by the vehicle through the OBD interface via the slave computer.
[0036] In this embodiment of the invention, optionally, when the first judgment result is yes, step 104 is triggered; when the first judgment result is no, the operation of determining the target communication detection node to be detected and the target logical channel required by the target communication detection node from the communication configuration file in step 102 can be re-executed; or, the detection activation node of the target communication detection node can be further judged, which is not limited in this embodiment of the invention.
[0037] 104. The target communication detection node detection is complete.
[0038] In this embodiment of the invention, after executing step 104, the operation of determining the target communication detection node to be detected and the target logical channel required by the target communication detection node from the communication configuration file in step 102 can be re-executed until all communication detection nodes have been detected.
[0039] It is evident that implementation Figure 1 The described method for detecting the baud rate of CAN communication in a vehicle's OBD interface can automatically generate a communication configuration file for the vehicle based on its type. Based on this configuration file, it selectively chooses the target communication detection node and its required target logical channel. Then, based on the target logical channel and the first baud rate set of the target communication detection node, it determines whether the current conditions of the target communication detection node meet a first preset communication condition. When the first preset communication condition is met, the detection of the target communication detection node is considered complete. This process of determining the target communication detection node and its required target logical channel is repeated until all communication detection nodes have been detected. This method improves the selection efficiency and accuracy of the communication detection node and its logical channel based on the vehicle type, thereby increasing the detection efficiency and accuracy. It also helps reduce the risk of code forgery when acquiring the baud rate, thus improving detection security.
[0040] In an optional embodiment, step 103 above, which involves determining whether the current conditions of the target communication detection node meet the first preset communication conditions based on the target logical channel of the target communication detection node and the first baud rate set of the target communication detection node, and obtaining a first determination result, includes: Set the target communication detection node's logical channel to the target logical channel and set the CAN controller's communication mode to silent mode to create the CAN controller's first communication link; Based on the first baud rate set of the target communication detection node, determine whether the first baud rate set of the target communication detection node contains the communication baud rate of the first communication link; When it is determined that the first baud rate set of the target communication detection node contains the communication baud rate of the first communication link, the first determination result is determined to be that the current condition of the target communication detection node meets the first preset communication condition. When it is determined that the first baud rate set of the target communication detection node does not contain the communication baud rate of the first communication link, the first determination result is that the current condition of the target communication detection node does not meet the first preset communication condition.
[0041] In this embodiment of the invention, the first communication link is used to test whether the host computer can receive CAN frame data sent by the OBD interface through the slave computer, such as vehicle broadcast data.
[0042] Specifically, based on the first baud rate set of the target communication detection node, it is determined whether the first baud rate set of the detection activation node contains the communication baud rate of the first communication link; when it is determined that the first baud rate set of the target communication detection node contains the communication baud rate of the first communication link, it is determined that the target communication detection node can communicate successfully, and the detection of the target communication detection node is completed; when it is determined that the first baud rate set of the target communication detection node does not contain the communication baud rate of the first communication link, it is determined that the target communication detection node cannot communicate successfully.
[0043] As can be seen, this optional embodiment can set the logical channel of the target communication detection node as the target logical channel and set the communication mode of the CAN controller to silent mode to create a first communication link of the CAN controller. Based on the first baud rate set of the target communication detection node, it determines whether the first baud rate set of the target communication detection node contains the communication baud rate of the first communication link. When it is determined that the first baud rate set of the target communication detection node contains the communication baud rate of the first communication link, the first determination result is that the current condition of the target communication detection node meets the first preset communication condition. When it is determined that the first baud rate set of the target communication detection node does not contain the communication baud rate of the first communication link, the first determination result is that the current condition of the target communication detection node does not meet the first preset communication condition. This can improve the accuracy and reliability of creating the first communication link based on silent mode, thereby improving the accuracy and reliability of determining whether the target communication detection node contains the communication baud rate, which is beneficial to improving the detection accuracy and reliability of the target communication detection node.
[0044] In this optional embodiment, as an optional implementation, determining whether the first baud rate set of the target communication detection node contains the communication baud rate of the first communication link, based on the first baud rate set of the target communication detection node, includes: Based on the first preset detection order, one of the first baud rates from the first set of target communication detection nodes is determined as the first current baud rate to be detected, so as to determine whether the first current baud rate meets the first preset detection conditions. When it is determined that the first current baud rate meets the first preset detection condition, the first current baud rate that meets the first preset detection condition is determined as the communication baud rate of the first communication link; When it is determined that the first current baud rate does not meet the first preset detection condition, the operation of selecting one of the first baud rates from the first baud rate set of the target communication detection node as the first current baud rate is re-executed based on the first preset detection order to determine whether the first current baud rate meets the first preset detection condition. When none of the determined first current baud rates meet the first preset detection conditions, it is determined that the first baud rate set of the target communication detection node does not contain the communication baud rate of the first communication link.
[0045] In this embodiment of the invention, optionally, the first preset detection order can be pre-configured in the communication configuration file or defined by the user during the actual detection process; this embodiment of the invention does not impose any limitations.
[0046] In this embodiment of the invention, the first preset detection condition is used to represent the condition under which the host computer receives vehicle broadcast data transmitted through the first communication link within a first preset time period. Specifically, for the first communication link of the target communication detection node, each first baud rate in the first baud rate set of the target communication detection node is detected sequentially to determine whether the host computer receives vehicle broadcast data transmitted through the first communication link within the first preset time period. If it is determined that the host computer receives vehicle broadcast data, then the first baud rate that enables the host computer to receive vehicle broadcast data is determined as the communication baud rate of the first communication link, that is, the first baud rate set of the target communication detection node contains the communication baud rate of the first communication link. If it is determined that the host computer does not receive vehicle broadcast data, then it is determined that the first baud rate set of the target communication detection node does not contain the communication baud rate of the first communication link.
[0047] Specifically, the working principle of detecting each first baud rate in the first baud rate set of the target communication detection node is as follows: The baud rate of the first communication link of the target communication detection node is set sequentially according to the first baud rate set of the target communication detection node; The system detects whether the host computer can receive the vehicle broadcast data sent from the vehicle's OBD interface to the slave computer via the first communication link and then sent from the slave computer to the host computer within a first preset time period.
[0048] As can be seen, this optional implementation can determine one of the first baud rates from the first baud rate set of the target communication detection node as the first current baud rate to be detected based on the first preset detection order, so as to determine whether the first current baud rate meets the first preset detection condition. When it is determined that the first current baud rate meets the first preset detection condition, the first current baud rate that meets the first preset detection condition is determined as the communication baud rate of the first communication link. When it is determined that the first current baud rate does not meet the first preset detection condition, the operation of selecting one of the first baud rates from the first baud rate set of the target communication detection node as the first current baud rate based on the first preset detection order is re-executed to determine whether the first current baud rate meets the first preset detection condition. When all the determined first current baud rates do not meet the first preset detection condition, it is determined that the first baud rate set of the target communication detection node does not contain the communication baud rate of the first communication link. By detecting the first communication link of the target communication detection node sequentially according to each baud rate in the first baud rate set, the accuracy and reliability of communication detection of the first communication link can be improved, thereby improving the detection accuracy and reliability of the target communication detection node.
[0049] Example 2 Please see Figure 2 , Figure 2 This is a flowchart illustrating a method for detecting the baud rate of a vehicle OBD interface CAN communication according to an embodiment of the present invention. Figure 2 The described method for detecting the baud rate of the vehicle's OBD interface CAN communication can be applied to the CAN bus. The CAN bus is used to detect the required baud rate of the vehicle's OBD interface through a communication mode between the host computer and the slave computer based on the CAN controller. The communication module 305 includes a silent mode or a normal mode. Figure 2 As shown, the method for detecting the baud rate of the vehicle's OBD interface CAN communication may include the following operations: 201. Generate the vehicle's communication configuration file based on the vehicle type.
[0050] 202. Read the target communication detection node to be detected and the target logical channel required by the target communication detection node from the communication configuration file.
[0051] 203. Based on the target logical channel of the target communication detection node and the first baud rate set of the target communication detection node, determine whether the current conditions of the target communication detection node meet the first preset communication conditions, and obtain the first judgment result.
[0052] In this embodiment of the invention, when the first judgment result is yes, step 203 is triggered; when the first judgment result is no, step 205 is triggered.
[0053] 204. The detection of the target communication detection node has been completed.
[0054] In this embodiment of the invention, after executing step 204, the operation of determining the target communication detection node to be detected and the target logical channel required by the target communication detection node from the communication configuration file in step 202 can be re-executed until all communication detection nodes have been detected.
[0055] In this embodiment of the invention, for other descriptions of steps 201-204, please refer to the detailed description of steps 101-104 in Embodiment 1. These descriptions will not be repeated in this embodiment of the invention.
[0056] 205. Read the target communication detection node's detection activation node.
[0057] 206. Based on the target logical channel of the target communication detection node and the second baud rate set of the detection activation node, determine whether the current condition of the detection activation node meets the second preset communication condition, and obtain the second judgment result.
[0058] In this embodiment of the invention, the second preset communication condition is used to indicate the conditions for communication between the host computer, the slave computer, and the OBD interface when the communication mode of the CAN controller is in normal mode.
[0059] In this embodiment of the invention, when the second judgment result is yes, step 207 is triggered; when the second judgment result is no, the detection process of the node can be terminated; or, the communication failure reason of the target communication detection node can be detected. If the communication failure reason is found to be less related to the CAN bus, the detection process of the target communication detection node can be re-executed. This embodiment of the invention does not impose any limitations.
[0060] 207. The detection of the target communication detection node has been completed.
[0061] In this embodiment of the invention, after executing step 207, the operation of determining the target communication detection node to be detected and the target logical channel required by the target communication detection node from the communication configuration file in step 202 can be re-executed until all communication detection nodes have been detected.
[0062] It is evident that implementation Figure 2The described method for detecting the baud rate of CAN communication in a vehicle's OBD interface can automatically generate a communication configuration file for the vehicle based on its type. Based on this configuration file, it selectively chooses the target communication detection node and its required target logical channel. Then, based on the target logical channel and the first baud rate set of the target communication detection node, it determines whether the current conditions of the target communication detection node meet a first preset communication condition. When the first preset communication condition is met, the detection of the target communication detection node is considered complete. This process of determining the target communication detection node and its required target logical channel is repeated until all communication detection nodes have been detected. This method improves the selection efficiency and accuracy of the communication detection node and its logical channel based on the vehicle type, thereby increasing the detection efficiency and accuracy. It also helps reduce the risk of code forgery when acquiring the baud rate, thus improving detection security. Furthermore, when it is determined that the first preset communication condition is not met, the detection activation node of the target communication detection node can be read, and based on the target logical channel of the target communication detection node and the second baud rate set of the detection activation node, it can be determined whether the current condition of the detection activation node meets the second preset communication condition. When it is determined that the second preset communication condition is met, the detection of the target communication detection node is determined to be completed. It can detect whether the detection activation node of the target communication detection node meets the normal mode communication condition only when the target communication detection node does not meet the silent mode communication condition. It can improve the detection diversity, flexibility and accuracy of target communication detection conditions based on the communication conditions of multiple communication modes.
[0063] In an optional embodiment, step 206 above, which determines whether the current condition of the detection activation node meets the second preset communication condition based on the target logical channel of the target communication detection node and the second baud rate set of the detection activation node, and obtains the second determination result, includes: Set the logical channel of the detection activation node as the target logical channel of the target communication detection node, and set the communication mode of the CAN controller to normal mode to create a second communication link for the CAN controller. Based on the second baud rate set of the detected active node, determine whether the second baud rate set of the detected active node contains the communication baud rate of the second communication link; When it is determined that the second baud rate set of the detection activation node contains the communication baud rate of the second communication link, the second determination result is determined to be that the current condition of the detection activation node meets the second preset communication condition. When it is determined that the second baud rate set of the detection activation node does not contain the communication baud rate of the second communication link, the second determination result is determined to be that the current condition of the detection activation node does not meet the second preset communication condition.
[0064] In this embodiment of the invention, the second communication link is used to test whether the host computer can receive the reply data corresponding to the preset command sent by the OBD interface through the slave computer after the host computer sends a preset command to the OBD interface through the slave computer.
[0065] Specifically, based on the second baud rate set of the detection activation node, it is determined whether the second baud rate set of the detection activation node contains the communication baud rate of the second communication link; when it is determined that the second baud rate set of the detection activation node contains the communication baud rate of the second communication link, it is determined that the target communication detection node to which the detection activation node belongs can successfully communicate, and the detection of the target communication detection node is completed; when it is determined that the second baud rate set of the detection activation node does not contain the communication baud rate of the second communication link, it is determined that the target communication detection node to which the detection activation node belongs cannot successfully communicate.
[0066] As can be seen, this optional embodiment can set the logical channel of the detection activation node as the target logical channel of the target communication detection node, and set the communication mode of the CAN controller to normal mode to create a second communication link of the CAN controller. Based on the second baud rate set of the detection activation node, it can determine whether the second baud rate set of the detection activation node contains the communication baud rate of the second communication link. When it is determined that the second baud rate set of the detection activation node contains the communication baud rate of the second communication link, the second determination result is determined to be that the current condition of the detection activation node meets the second preset communication condition. When it is determined that the second baud rate set of the detection activation node does not contain the communication baud rate of the second communication link, the second determination result is determined to be that the current condition of the detection activation node does not meet the second preset communication condition. This can improve the accuracy and reliability of creating the second communication link based on normal mode, thereby improving the accuracy and reliability of determining whether the detection activation node contains the communication baud rate, and thus improving the detection accuracy and reliability of the target communication detection node to which the detection activation node belongs.
[0067] In this optional embodiment, as an optional implementation, determining whether the second baud rate set of the detected active node contains the communication baud rate of the second communication link, based on the second baud rate set of the detected active node, includes: Based on the second preset detection order, one of the second baud rates from the set of second baud rates of the detected active nodes is selected as the second current baud rate to be detected, so as to determine whether the second current baud rate meets the second preset detection conditions; When it is determined that the second current baud rate meets the second preset detection condition, the second current baud rate that meets the second preset detection condition is determined as the communication baud rate of the second communication link; When it is determined that the second current baud rate does not meet the second preset detection condition, the operation of selecting one of the second baud rates from the set of second baud rates of the detection activation node based on the second preset detection order is re-executed as the second current baud rate to be detected, so as to determine whether the second current baud rate meets the second preset detection condition. When none of the determined second current baud rates meet the second preset detection conditions, it is determined that the set of second baud rates of the detection activation node does not contain the communication baud rate of the second communication link.
[0068] In this embodiment of the invention, optionally, the second preset detection order can be pre-configured in the communication configuration file or defined by the user during the actual detection process; this embodiment of the invention does not impose any limitations.
[0069] In this embodiment of the invention, the second preset detection condition represents the condition under which the host computer receives vehicle response data transmitted via the second communication link within a second preset duration. The second preset duration and the first preset duration may be unequal or equal, such as both being 200 milliseconds. Specifically, for the second communication link of the detection activation node, each second baud rate in the second baud rate set of the detection activation node is detected sequentially to determine whether the host computer can receive vehicle response data transmitted via the second communication link within the second preset duration. If it is determined that the host computer receives vehicle response data, the second baud rate that enables the host computer to receive vehicle response data is determined as the communication baud rate of the second communication link, that is, the second baud rate set of the detection activation node contains the communication baud rate of the second communication link. If it is determined that the host computer does not receive vehicle response data, the second baud rate of the detection activation node does not contain the communication baud rate of the second communication link.
[0070] Specifically, the working principle of detecting each second baud rate in the set of second baud rates for detecting active nodes is as follows: The baud rate of the second communication link of the detection and activation node is set sequentially according to the second baud rate set of the detection and activation node; The host computer sends a preset command to the slave computer through the second communication link, and the slave computer sends the preset command to the vehicle's OBD interface through the second communication link. If the lower-level device successfully sends data to the vehicle's OBD interface, it will send corresponding response data to the upper-level device. If the lower-level device fails to send data, it will not send response data to the upper-level device. In this way, by detecting whether the upper-level device receives the response data, the baud rate of the active detection node can be detected.
[0071] As can be seen, this optional implementation can select one of the second baud rates from the set of second baud rates of the detection activation node as the second current baud rate to be detected based on the second preset detection order, in order to determine whether the second current baud rate meets the second preset detection conditions. When it is determined that the second current baud rate meets the second preset detection conditions, the second current baud rate that meets the second preset detection conditions is determined as the communication baud rate of the second communication link. When it is determined that the second current baud rate does not meet the second preset detection conditions, the operation of selecting one of the second baud rates from the set of second baud rates of the detection activation node as the second current baud rate to be detected based on the second preset detection order is re-executed to determine whether the second current baud rate meets the second preset detection conditions. When all the determined second current baud rates do not meet the second preset detection conditions, it is determined that the set of second baud rates of the detection activation node does not contain the communication baud rate of the second communication link. By detecting the second communication link of the detection activation node in sequence according to each baud rate in the set of second baud rates, the accuracy and reliability of communication detection of the second communication link can be improved, thereby improving the detection accuracy and reliability of the target communication detection node.
[0072] In another alternative embodiment, the method further includes: Determine if the CAN communication parameters corresponding to the vehicle model and determined by the personnel in the communication configuration file exist; When it is determined that there are CAN communication parameters in the communication configuration file, the parameters of the CAN controller are set according to the CAN communication parameters to realize communication between the host computer, the slave computer and the OBD interface. When it is determined that there are no CAN communication parameters in the communication configuration file, the baud rate detection process of the vehicle's OBD interface is initiated.
[0073] In this embodiment of the invention, specifically, when the vehicle type personnel can clearly know the specific communication detection node, CAN pin, and baud rate of the vehicle type, they can use the communication detection node, CAN pin, and baud rate without going through the automatic baud rate detection process.
[0074] In this embodiment of the invention, optionally, the baud rate detection process of the vehicle's OBD interface may include steps 102-104 of Embodiment 1, or steps 202-207 of Embodiment 2. Specifically, when it is determined that there are no CAN communication parameters in the communication configuration file, steps 102-104 of Embodiment 1 are initiated, or steps 202-207 of Embodiment 2 are initiated.
[0075] As can be seen, this optional embodiment can determine whether the CAN communication parameters corresponding to the vehicle model and determined by the personnel exist in the communication configuration file. When it is determined that the CAN communication parameters exist in the communication configuration file, the parameters of the CAN controller are set directly according to the CAN communication parameters to realize the communication between the host computer, the slave computer and the OBD interface, which can improve the communication efficiency and communication speed of the vehicle's OBD interface. When it is determined that the CAN communication parameters do not exist in the communication configuration file, the baud rate detection process of the vehicle's OBD interface is started, which can improve the timeliness, accuracy and automation level of the start of the baud rate detection process of the OBD interface.
[0076] For example, such as Figure 3 As shown, Figure 3 This is a schematic diagram illustrating a scenario applicable to the method for detecting the CAN communication baud rate of a vehicle OBD interface disclosed in an embodiment of the present invention. The scenario includes a host computer, a slave computer, and a vehicle. The communication connection between the host computer and the slave computer is a USB wired connection, and the communication connection between the slave computer and the vehicle is an OBD wired connection. Furthermore, the scenario may also include a vehicle model cloud platform on the Internet, wherein the vehicle model cloud platform communicates with the host computer via a network, and the vehicle model cloud platform can be used to determine the vehicle's communication configuration file based on the vehicle type.
[0077] For example, such as Figure 4 As shown, Figure 4 This is a schematic diagram of a process for determining a vehicle's communication configuration file based on its vehicle type, as disclosed in an embodiment of the present invention. Figure 4 Taking an XML configuration file as an example, the communication configuration file for a vehicle is determined based on the vehicle type. The specific steps are as follows: Users select the vehicle's MMY (brand, model, and year) through the host computer interface. The host computer uses these three input elements to request the corresponding vehicle model's XML configuration file from the vehicle model cloud platform; The cloud platform pre-converts the Excel files of various car brands (which contain detailed information about the vehicle's electronic control units, such as pins, baud rate, and other parameters) into library files with the .db extension using the SQLite Studio tool. Use the SQL statement: "select * from Ford where model AND year" to query the database; Analyze the query results to determine the maximum number of CAN channels, the possible baud rate sets, and information on each electronic control unit node, and generate an XML configuration file accordingly. The cloud platform returns the final XML file to the host computer.
[0078] For example, such as Figure 5 As shown, Figure 5 This is a schematic diagram illustrating the rule format for baud rate detection in a communication configuration file disclosed in an embodiment of the present invention. Specifically, it reads the CheckBuses node and EnsureCanBuses node from the XML configuration file. For example, there are two CheckBuses nodes, also called CheckBus1 node and CheckBus2 node. The CAN pins that CheckBus1 node needs to detect are <6,14>, and the CAN pins that CheckBus2 node needs to detect are <3,11>. In the silent mode of the CAN controller, the baud rate BusBaudRate to be switched to be monitored comes from the CheckBuses node. When no communicable baud rate is detected in the silent mode, it switches to the normal command sending and receiving mode. At this time, the baud rate list used for communication and the actively sent commands both come from the Active child node. When the vehicle personnel can clearly know the specific CAN pins and baud rates of the vehicle model, the EnsureCanBuses node is used directly without going through the automatic baud rate detection process.
[0079] For example, such as Figure 6 As shown, Figure 6 This is a flowchart illustrating another method for detecting the baud rate of a vehicle OBD interface CAN communication according to an embodiment of the present invention. The method for detecting the baud rate of a vehicle OBD interface CAN communication may include the following steps: 1. The host computer checks if the XML configuration file contains an EnsureCanBuses node; 2. If applicable, directly use the CAN communication parameters (pins, baud rate) specified in EnsureCanBuses to communicate with the vehicle; 3. If nothing is said, proceed to the baud rate detection process; 4. The host computer sequentially reads the child nodes CheckBus in the CheckBuses node; 5. The host computer creates a CAN communication link, selects the BusPin pin in CheckBus, and sets the CAN controller to silent mode; 6. The BusBaudRate sub-node in the CheckBus node has multiple baud rate lists. Select one baud rate in turn to set the baud rate of CAN. 7. If the baud rate list has not been completely selected and tried, wait 200ms to see if CAN frame data has been received; 8. If no vehicle broadcast data is received within the timeout period, proceed to step 6 to continue the attempt at the next baud rate; 9. If vehicle broadcast data is received within the timeout period, it means that the baud rate for communication on this CAN route has been found, and then the CAN link created in step 5 is closed; 10. Determine whether all child nodes (CheckBus) in the sequentially read CheckBuses nodes have been tested; 11. Once all tests are completed, this testing process is finished and you can exit. 12. If there are still CheckBus nodes that have not been tested, proceed to step 4; 13. In step 7, if the baud rate list has been exhausted, it means that the vehicle broadcast cannot be heard. Then, close the CAN link created in step 5. Enter the active command sending mode to detect. 14. The host computer obtains the Active child node of the CheckBus child node. A CAN communication link is created, the pins in the CheckBus are selected, and the CAN controller is set to normal mode. 15. The host computer obtains the baud rate list from the Active child node in the XML file, and selects one in sequence to set the baud rate of the CAN controller; In the 16.xml file, the Order sub-node of the Active node is a list of CAN frame commands actively sent by the host computer. The host computer selects one command in sequence, calls the send API to send it to the slave computer, and the slave computer sends it to the vehicle through the CAN bus. 17. If the data is successfully sent to the vehicle's CAN bus, the lower-level machine will reply with an ACK command to the upper-level machine; if the data transmission fails, there will be no reply; the upper-level machine will determine whether it has received an ACK reply by checking the 200ms timeout. 18. If the host computer receives an ACK reply within the timeout period, it means that the baud rate for this CAN communication has been found. Close the CAN link created in step 5, and then jump to step 10. 19. If the host computer does not receive an ACK reply within the timeout period, the host computer will determine whether the command list of the Order node in the Active child node has been selected and sent in sequence; 20. If the Order node command list has not been completely selected and sent, proceed to step 16; 21. If the command list of the Order node has not yet been selected and sent, the host computer will determine whether the baud rate list in the Active child node has been selected. 22. If the baud rate list has not been completely selected, proceed to step 15; if the baud rate list has been completely selected, it means that no baud rate can be used for communication. Then close the CAN link created in step 5 and proceed to step 10.
[0080] Example 3 Please see Figure 7 , Figure 7 This is a schematic diagram of a device for detecting the baud rate of a vehicle OBD interface CAN communication, as disclosed in an embodiment of the present invention. Figure 7 The described device for detecting the baud rate of the vehicle OBD interface CAN communication can be applied to the CAN bus. The CAN bus is used to detect the baud rate required by the vehicle's OBD interface through a communication mode between the host computer and the slave computer based on the CAN controller. The communication module 305 includes a silent mode or a normal mode. Figure 7 As shown, the device for detecting the baud rate of the vehicle's OBD interface CAN communication may include: The generation module is used to generate a communication configuration file for a vehicle based on the vehicle type. The communication configuration file includes at least one of the following: communication detection node configuration information, which includes at least one communication detection node, a logical channel set for each communication detection node, and a first baud rate set for each communication detection node.
[0081] The reading module 302 is used to read the target communication detection node to be detected and the target logical channel required by the target communication detection node from the communication configuration file.
[0082] The judgment module 303 is used to determine whether the current condition of the target communication detection node meets the first preset communication condition based on the target logical channel of the target communication detection node and the first baud rate set of the target communication detection node, and to obtain the first judgment result. The first preset communication condition is used to indicate the conditions for communication between the host computer, the slave computer and the OBD interface when the communication mode of the CAN controller is silent mode.
[0083] The determination module 304 is used to determine that the target communication detection node detection is complete when the first judgment result is yes.
[0084] It is evident that implementation Figure 7The described vehicle OBD interface CAN communication baud rate detection device can automatically generate a vehicle communication configuration file based on the vehicle type. Based on this configuration file, it selectively chooses the target communication detection node and its required target logical channel. Then, based on the target logical channel and the first baud rate set of the target communication detection node, it determines whether the current condition of the target communication detection node meets a first preset communication condition. When the first preset communication condition is met, the detection of the target communication detection node is considered complete. This process of determining the target communication detection node and its required target logical channel is repeated until all communication detection nodes have been detected. This device improves the selection efficiency and accuracy of the communication detection node and its logical channel based on the vehicle type, thereby increasing the detection efficiency and accuracy. It also helps reduce the risk of code forgery when acquiring the baud rate, thus improving detection security.
[0085] In an optional embodiment, the judgment module 303 determines whether the current conditions of the target communication detection node meet the first preset communication conditions based on the target logical channel of the target communication detection node and the first baud rate set of the target communication detection node, and obtains the first judgment result in the following specific ways: Set the logical channel of the target communication detection node to the target logical channel, and set the communication mode of the CAN controller to silent mode to create the first communication link of the CAN controller. The first communication link is used to test whether the host computer can receive CAN frame data sent by the OBD interface through the slave computer. Based on the first baud rate set of the target communication detection node, determine whether the first baud rate set of the target communication detection node contains the communication baud rate of the first communication link; When it is determined that the first baud rate set of the target communication detection node contains the communication baud rate of the first communication link, the first determination result is determined to be that the current condition of the target communication detection node meets the first preset communication condition. When it is determined that the first baud rate set of the target communication detection node does not contain the communication baud rate of the first communication link, the first determination result is that the current condition of the target communication detection node does not meet the first preset communication condition.
[0086] As can be seen, this optional embodiment can set the logical channel of the target communication detection node as the target logical channel and set the communication mode of the CAN controller to silent mode to create a first communication link of the CAN controller. Based on the first baud rate set of the target communication detection node, it determines whether the first baud rate set of the target communication detection node contains the communication baud rate of the first communication link. When it is determined that the first baud rate set of the target communication detection node contains the communication baud rate of the first communication link, the first determination result is that the current condition of the target communication detection node meets the first preset communication condition. When it is determined that the first baud rate set of the target communication detection node does not contain the communication baud rate of the first communication link, the first determination result is that the current condition of the target communication detection node does not meet the first preset communication condition. This can improve the accuracy and reliability of creating the first communication link based on silent mode, thereby improving the accuracy and reliability of determining whether the target communication detection node contains the communication baud rate, which is beneficial to improving the detection accuracy and reliability of the target communication detection node.
[0087] In this optional embodiment, as an optional implementation method, the specific way in which the determining module 303 determines whether the first baud rate set of the target communication detection node contains the communication baud rate of the first communication link includes: Based on the first preset detection order, one of the first baud rates from the first set of target communication detection nodes is determined as the first current baud rate to be detected, so as to determine whether the first current baud rate meets the first preset detection condition. The first preset detection condition is used to represent the condition for the host computer to receive vehicle broadcast data transmitted through the first communication link within a first preset time period. When it is determined that the first current baud rate meets the first preset detection condition, the first current baud rate that meets the first preset detection condition is determined as the communication baud rate of the first communication link; When it is determined that the first current baud rate does not meet the first preset detection condition, the operation of selecting one of the first baud rates from the first baud rate set of the target communication detection node as the first current baud rate is re-executed based on the first preset detection order to determine whether the first current baud rate meets the first preset detection condition. When none of the determined first current baud rates meet the first preset detection conditions, it is determined that the first baud rate set of the target communication detection node does not contain the communication baud rate of the first communication link.
[0088] As can be seen, this optional implementation can determine one of the first baud rates from the first baud rate set of the target communication detection node as the first current baud rate to be detected based on the first preset detection order, so as to determine whether the first current baud rate meets the first preset detection condition. When it is determined that the first current baud rate meets the first preset detection condition, the first current baud rate that meets the first preset detection condition is determined as the communication baud rate of the first communication link. When it is determined that the first current baud rate does not meet the first preset detection condition, the operation of selecting one of the first baud rates from the first baud rate set of the target communication detection node as the first current baud rate based on the first preset detection order is re-executed to determine whether the first current baud rate meets the first preset detection condition. When all the determined first current baud rates do not meet the first preset detection condition, it is determined that the first baud rate set of the target communication detection node does not contain the communication baud rate of the first communication link. By detecting the first communication link of the target communication detection node sequentially according to each baud rate in the first baud rate set, the accuracy and reliability of communication detection of the first communication link can be improved, thereby improving the detection accuracy and reliability of the target communication detection node.
[0089] In another optional embodiment, the communication configuration file further includes a second baud rate set of the detection activation nodes for each communication detection node. Additionally, the reading module 302 is further configured to read the detection activation nodes of the target communication detection node when the first determination result is negative. The judgment module 303 is also used to determine whether the current condition of the detection activation node meets the second preset communication condition based on the target logical channel of the target communication detection node and the second baud rate set of the detection activation node, and to obtain the second judgment result. The second preset communication condition is used to indicate the conditions for communication between the host computer, the slave computer and the OBD interface when the communication mode of the CAN controller is normal mode. The determination module 304 is also used to determine that the target communication detection node detection is complete when the second judgment result is yes.
[0090] As can be seen, this optional embodiment can read the detection activation node of the target communication detection node when it is determined that the first preset communication condition is not met, and determine whether the current condition of the detection activation node meets the second preset communication condition based on the target logical channel of the target communication detection node and the second baud rate set of the detection activation node. When it is determined that the second preset communication condition is met, it is determined that the detection of the target communication detection node is completed. It can detect whether the detection activation node of the target communication detection node meets the normal mode communication condition only when the target communication detection node does not meet the silent mode communication condition. It can improve the detection diversity, flexibility and accuracy of the target communication detection condition based on the communication conditions of multiple communication modes.
[0091] In this optional embodiment, as an optional implementation method, the judgment module 303 determines whether the current condition of the detection activation node meets the second preset communication condition based on the target logical channel of the target communication detection node and the second baud rate set of the detection activation node, and obtains the second judgment result in the following specific ways: Set the logic channel of the detection activation node as the target logic channel of the target communication detection node, and set the communication mode of the CAN controller to normal mode to create a second communication link for the CAN controller. The second communication link is used to test whether the host computer can receive the reply data corresponding to the preset command sent by the OBD interface through the lower computer after the upper computer sends the preset command to the OBD interface through the lower computer. Based on the second baud rate set of the detected active node, determine whether the second baud rate set of the detected active node contains the communication baud rate of the second communication link; When it is determined that the second baud rate set of the detection activation node contains the communication baud rate of the second communication link, the second determination result is determined to be that the current condition of the detection activation node meets the second preset communication condition. When it is determined that the second baud rate set of the detection activation node does not contain the communication baud rate of the second communication link, the second determination result is determined to be that the current condition of the detection activation node does not meet the second preset communication condition.
[0092] As can be seen, this optional implementation can set the logical channel of the detection activation node as the target logical channel of the target communication detection node, and set the communication mode of the CAN controller to normal mode to create a second communication link for the CAN controller. Based on the second baud rate set of the detection activation node, it can determine whether the second baud rate set of the detection activation node contains the communication baud rate of the second communication link. When it is determined that the second baud rate set of the detection activation node contains the communication baud rate of the second communication link, the second determination result is determined to be that the current condition of the detection activation node meets the second preset communication condition. When it is determined that the second baud rate set of the detection activation node does not contain the communication baud rate of the second communication link, the second determination result is determined to be that the current condition of the detection activation node does not meet the second preset communication condition. This can improve the accuracy and reliability of creating the second communication link based on normal mode, thereby improving the accuracy and reliability of determining whether the detection activation node contains the communication baud rate, and thus improving the detection accuracy and reliability of the target communication detection node to which the detection activation node belongs.
[0093] In this optional implementation, the specific method by which the determining module 303 determines whether the second baud rate set of the detected active node contains the communication baud rate of the second communication link includes: Based on the second preset detection order, one of the second baud rates from the set of second baud rates of the detection activation node is selected as the second current baud rate to be detected, so as to determine whether the second current baud rate meets the second preset detection condition. The second preset detection condition is used to represent the condition for the host computer to receive the vehicle response data transmitted through the second communication link within the second preset time period. When it is determined that the second current baud rate meets the second preset detection condition, the second current baud rate that meets the second preset detection condition is determined as the communication baud rate of the second communication link; When it is determined that the second current baud rate does not meet the second preset detection condition, the operation of selecting one of the second baud rates from the set of second baud rates of the detection activation node based on the second preset detection order is re-executed as the second current baud rate to be detected, so as to determine whether the second current baud rate meets the second preset detection condition. When none of the determined second current baud rates meet the second preset detection conditions, it is determined that the set of second baud rates of the detection activation node does not contain the communication baud rate of the second communication link.
[0094] As can be seen, this optional implementation can also select one of the second baud rates from the set of second baud rates of the detection activation node as the second current baud rate to be detected based on the second preset detection order, so as to determine whether the second current baud rate meets the second preset detection condition. When it is determined that the second current baud rate meets the second preset detection condition, the second current baud rate that meets the second preset detection condition is determined as the communication baud rate of the second communication link. When it is determined that the second current baud rate does not meet the second preset detection condition, the operation of selecting one of the second baud rates from the set of second baud rates of the detection activation node as the second current baud rate to be detected based on the second preset detection order is re-executed to determine whether the second current baud rate meets the second preset detection condition. When all the determined second current baud rates do not meet the second preset detection condition, it is determined that the set of second baud rates of the detection activation node does not contain the communication baud rate of the second communication link. By detecting the second communication link of the detection activation node in sequence according to each baud rate in the set of second baud rates, the accuracy and reliability of communication detection of the second communication link can be improved, thereby improving the detection accuracy and reliability of the target communication detection node.
[0095] In another optional embodiment, the determination module 303 is further configured to determine whether the CAN communication parameters corresponding to the vehicle model and determined by the personnel in the communication configuration file exist. And, as... Figure 8 As shown, Figure 8 This is a schematic diagram of another device for detecting the baud rate of a vehicle OBD interface CAN communication disclosed in an embodiment of the present invention, wherein, as shown... Figure 8 As shown, the device may further include: The communication module 305 is used to set parameters of the CAN controller according to the CAN communication parameters when the judgment module 303 determines that there are CAN communication parameters in the communication configuration file, so as to realize communication between the host computer, the slave computer and the OBD interface.
[0096] The startup module 306 is used to start the baud rate detection process of the vehicle's OBD interface when the judgment module 303 determines that there are no CAN communication parameters in the communication configuration file.
[0097] As can be seen, this optional embodiment can determine whether the CAN communication parameters corresponding to the vehicle model and determined by the personnel exist in the communication configuration file. When it is determined that the CAN communication parameters exist in the communication configuration file, the parameters of the CAN controller are set directly according to the CAN communication parameters to realize the communication between the host computer, the slave computer and the OBD interface, which can improve the communication efficiency and communication speed of the vehicle's OBD interface. When it is determined that the CAN communication parameters do not exist in the communication configuration file, the baud rate detection process of the vehicle's OBD interface is started, which can improve the timeliness, accuracy and automation level of the start of the baud rate detection process of the OBD interface.
[0098] Example 4 Please see Figure 9 , Figure 9 This is a schematic diagram of another device for detecting the baud rate of CAN communication in a vehicle OBD interface, as disclosed in an embodiment of the present invention. Figure 9 As shown, the device for detecting the baud rate of the vehicle's OBD interface CAN communication may include: Memory 401 storing executable program code; Processor 402 coupled to memory 401; The processor 402 calls the executable program code stored in the memory 401 to execute the steps in the method for detecting the baud rate of vehicle OBD interface CAN communication as described in Embodiment 1 or Embodiment 2 of the present invention.
[0099] Example 5 This invention discloses a computer storage medium storing computer instructions. When these computer instructions are invoked, they are used to execute the steps in the method for detecting the baud rate of the vehicle OBD interface CAN communication described in Embodiment 1 or Embodiment 2 of this invention.
[0100] Example 6 This invention discloses a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program, and the computer program is operable to cause a computer to perform the steps in the method for detecting the baud rate of vehicle OBD interface CAN communication described in Embodiment 1 or Embodiment 2.
[0101] The device embodiments described above are merely illustrative. The modules described as separate components may or may not be physically separate. The components shown as modules may or may not be physical modules; that is, they may be located in one place or distributed across multiple network modules. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0102] Through the detailed description of the above embodiments, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, including read-only memory (ROM), random access memory (RAM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), one-time programmable read-only memory (OTPROM), electrically-Erasable Programmable Read-Only Memory (EEPROM), compact disc read-only memory (CD-ROM) or other optical disc storage, disk storage, magnetic tape storage, or any other computer-readable medium that can be used to carry or store data.
[0103] Finally, it should be noted that the method and apparatus for detecting the baud rate of CAN communication in a vehicle OBD interface disclosed in the embodiments of the present invention are merely preferred embodiments of the present invention and are only used to illustrate the technical solutions of the present invention, not to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for detecting the baud rate of CAN communication via a vehicle OBD interface, characterized in that, The method is applied to a CAN bus, which is used to detect the baud rate required by the vehicle's OBD interface through a communication mode between a host computer and a slave computer based on a CAN controller. The communication module includes a silent mode or a normal mode. The method includes: Based on the vehicle type, a communication configuration file for the vehicle is generated. The communication configuration file includes at least communication detection node configuration information, which includes at least one of the following: at least one communication detection node, a logical channel set for each communication detection node, and a first baud rate set for each communication detection node. Read the target communication detection node to be detected and the target logical channel required by the target communication detection node from the communication configuration file; Based on the target logical channel of the target communication detection node and the first baud rate set of the target communication detection node, it is determined whether the current condition of the target communication detection node meets the first preset communication condition, and a first judgment result is obtained. The first preset communication condition is used to indicate the conditions for communication between the host computer, the slave computer and the OBD interface when the communication mode of the CAN controller is the silent mode. When the first judgment result is yes, it is determined that the detection of the target communication detection node is complete.
2. The method for detecting the baud rate of CAN communication in a vehicle OBD interface according to claim 1, characterized in that, The step of determining whether the current conditions of the target communication detection node meet the first preset communication conditions based on the target logical channel of the target communication detection node and the first baud rate set of the target communication detection node, and obtaining the first determination result, includes: The logical channel of the target communication detection node is set as the target logical channel, and the communication mode of the CAN controller is set to the silent mode to create the first communication link of the CAN controller. The first communication link is used to test whether the host computer can receive the CAN frame data sent by the OBD interface through the slave computer. Based on the first baud rate set of the target communication detection node, determine whether the first baud rate set of the target communication detection node contains the communication baud rate of the first communication link; When it is determined that the first baud rate set of the target communication detection node contains the communication baud rate of the first communication link, the first determination result is determined to be that the current condition of the target communication detection node satisfies the first preset communication condition. When it is determined that the first baud rate set of the target communication detection node does not contain the communication baud rate of the first communication link, the first determination result is that the current condition of the target communication detection node does not meet the first preset communication condition.
3. The method for detecting the baud rate of CAN communication in a vehicle OBD interface according to claim 2, characterized in that, The step of determining whether the first baud rate set of the target communication detection node contains the communication baud rate of the first communication link, based on the first baud rate set of the target communication detection node, includes: Based on the first preset detection order, one of the first baud rates from the first set of the target communication detection nodes is determined as the first current baud rate to be detected, so as to determine whether the first current baud rate meets the first preset detection condition. The first preset detection condition is used to represent the condition for the host computer to receive vehicle broadcast data transmitted through the first communication link within a first preset time period. When it is determined that the first current baud rate meets the first preset detection condition, the first current baud rate that meets the first preset detection condition is determined as the communication baud rate of the first communication link; When it is determined that the first current baud rate does not meet the first preset detection condition, the operation of selecting one of the first baud rates from the first baud rate set of the target communication detection node based on the first preset detection order is re-executed as the first current baud rate to determine whether the first current baud rate meets the first preset detection condition. When all the determined first current baud rates do not meet the first preset detection conditions, it is determined that the first baud rate set of the target communication detection node does not contain the communication baud rate of the first communication link.
4. The method for detecting the baud rate of CAN communication in a vehicle OBD interface according to any one of claims 1-3, characterized in that, The communication configuration file also includes a second baud rate set for the detection activation nodes of each of the communication detection nodes; Furthermore, the method further includes: When the first judgment result is negative, the detection activation node of the target communication detection node is read; Based on the target logical channel of the target communication detection node and the second baud rate set of the detection activation node, it is determined whether the current condition of the detection activation node meets the second preset communication condition, and a second judgment result is obtained. The second preset communication condition is used to indicate the conditions for communication between the host computer, the slave computer and the OBD interface when the communication mode of the CAN controller is the normal mode. When the second judgment result is yes, it is determined that the detection of the target communication detection node is complete.
5. The method for detecting the baud rate of CAN communication in a vehicle OBD interface according to claim 4, characterized in that, The step of determining whether the current condition of the detection activation node meets the second preset communication condition based on the target logical channel of the target communication detection node and the second baud rate set of the detection activation node, and obtaining the second determination result, includes: The logical channel of the detection activation node is set as the target logical channel of the target communication detection node, and the communication mode of the CAN controller is set to the normal mode to create a second communication link of the CAN controller. The second communication link is used to test whether the host computer can receive the reply data corresponding to the preset command sent by the OBD interface through the lower computer after the host computer sends a preset command to the OBD interface through the lower computer. Based on the second baud rate set of the detected active nodes, determine whether the second baud rate set of the detected active nodes contains the communication baud rate of the second communication link; When it is determined that the second baud rate set of the detection activation node contains the communication baud rate of the second communication link, the second determination result is determined to be that the current condition of the detection activation node meets the second preset communication condition; When it is determined that the second baud rate set of the detection activation node does not contain the communication baud rate of the second communication link, the second determination result is determined to be that the current condition of the detection activation node does not meet the second preset communication condition.
6. The method for detecting the baud rate of CAN communication in a vehicle OBD interface according to claim 5, characterized in that, The step of determining whether the second baud rate set of the detected active nodes contains the communication baud rate of the second communication link includes: Based on the second preset detection order, one of the second baud rates from the set of the second baud rates of the detection activation node is selected as the second current baud rate to be detected, so as to determine whether the second current baud rate meets the second preset detection condition. The second preset detection condition is used to represent the condition for the host computer to receive the vehicle response data transmitted through the second communication link within a second preset time period. When it is determined that the second current baud rate meets the second preset detection condition, the second current baud rate that meets the second preset detection condition is determined as the communication baud rate of the second communication link; When it is determined that the second current baud rate does not meet the second preset detection condition, the operation of selecting one of the second baud rates from the set of second baud rates of the detection activation node based on the second preset detection order is re-executed as the second current baud rate to be detected, so as to determine whether the second current baud rate meets the second preset detection condition. When all the determined second current baud rates do not meet the second preset detection conditions, it is determined that the second baud rate set of the detection activation node does not contain the communication baud rate of the second communication link.
7. The method for detecting the baud rate of CAN communication in a vehicle OBD interface according to any one of claims 1, 2, 3, 5, and 6, characterized in that, The method further includes: Determine whether the CAN communication parameters corresponding to the vehicle model and determined by the personnel in the communication configuration file exist. When it is determined that the CAN communication parameters exist in the communication configuration file, the CAN controller is configured according to the CAN communication parameters to realize communication between the host computer, the slave computer and the OBD interface; When it is determined that the CAN communication parameters are not present in the communication configuration file, the baud rate detection process of the vehicle's OBD interface is initiated.
8. A device for detecting the baud rate of CAN communication in a vehicle OBD interface, characterized in that, The device is applied to a CAN bus, which is used to detect the baud rate required by the vehicle's OBD interface through a communication mode between a host computer and a slave computer based on a CAN controller. The communication module includes a silent mode or a normal mode. The device includes: A generation module is used to generate a communication configuration file for the vehicle based on the vehicle type. The communication configuration file includes at least communication detection node configuration information, which includes at least one of the following: at least one communication detection node, a logical channel set for each communication detection node, and a first baud rate set for each communication detection node. The reading module is used to read the target communication detection node to be detected and the target logical channel required by the target communication detection node from the communication configuration file; The judgment module is used to determine whether the current condition of the target communication detection node meets the first preset communication condition based on the target logical channel of the target communication detection node and the first baud rate set of the target communication detection node, and to obtain a first judgment result. The first preset communication condition is used to indicate the conditions for communication between the host computer, the slave computer and the OBD interface when the communication mode of the CAN controller is the silent mode. The determination module is used to determine that the detection of the target communication detection node is complete when the first judgment result is yes.
9. A device for detecting the baud rate of CAN communication in a vehicle OBD interface, characterized in that, The device includes: Memory containing executable program code; A processor coupled to the memory; The processor calls the executable program code stored in the memory to execute the method for detecting the baud rate of the vehicle OBD interface CAN communication as described in any one of claims 1-7.
10. A computer storage medium, characterized in that, The computer storage medium stores computer instructions, which, when invoked, are used to execute the method for detecting the baud rate of the vehicle OBD interface CAN communication as described in any one of claims 1-7.