Vehicle fault detection method and detection device
By initializing the fault code variable and fault global variable in the vehicle gateway, receiving the fault diagnosis response message and judging the fault status, the problem of inability to distinguish fault types in the existing technology is solved, and the efficiency and flexibility of fault detection are improved, and simplified. The fault management process was completed.
Patent Information
- Application Number
- CN202411338113.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-25
- Publication Date
- 2024-12-24
- Estimated Expiration
- 2044-09-25
AI Technical Summary
The prior art cannot distinguish whether a vehicle failure is a new addition or a historical failure, and the fault detection method is not flexible enough, especially when replacing the entire vehicle and hardware equipment, software updates are time-consuming and labor-intensive.
Initialize the vehicle fault code variable and fault global variable in the vehicle gateway, receive the fault diagnosis response message and register the fault code, start the preset fault detection timer to traverse the fault code, call the fault detection callback function to judge the fault status, and save the status in the fault code variable.
It realizes the diagnosis of faults of various domain controllers of the vehicle in the vehicle gateway, distinguishes historical faults from new faults, facilitates user management, improves the efficiency and flexibility of fault detection, and reduces the time and workload of software updates.
Smart Images

Figure CN118859911B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of smart vehicle technology, and in particular to a vehicle fault detection method and detection device. Background Art
[0002] After the vehicle chassis control systems realize domain control, the fault diagnosis of chassis domain controllers is different from that of traditional distributed controllers. Especially with the large-scale popularization of new energy vehicles, car computers (TBOX) have become standard, and big data analysis and vehicle status confirmation have become the norm. Fault diagnosis has become an important part of domain control.
[0003] However, the current fault detection cannot tell whether the fault is a new one or a historical one. In addition, the fault is closely related to the actual vehicle electronic control unit (ECU). The current fault reporting mechanism requires software updates after the vehicle scene and hardware equipment are replaced, which is time-consuming and labor-intensive. Summary of the invention
[0004] In view of this, an embodiment of the present application provides a vehicle fault detection method and a detection device to solve the problem in the prior art that historical faults and new faults cannot be distinguished during fault detection and the detection method is not flexible enough.
[0005] According to a first aspect of an embodiment of the present application, a vehicle fault detection method is provided. The method is executed by a vehicle gateway and includes:
[0006] When the vehicle gateway is powered on, the vehicle fault code variable and the fault global variable are initialized. The vehicle fault code variable includes at least the fault codes of all faults of the vehicle and the fault detection callback function corresponding to each fault code. The fault global variable includes the fault detection information of at least some fault codes in the vehicle fault code variable.
[0007] Receive the fault diagnosis response message, register the vehicle fault code variable according to the fault information carried in the fault diagnosis response message, and obtain the registered fault code;
[0008] In response to receiving a message for starting a fault detection timer, a preset fault detection timer is started, and for each registered fault code, a vehicle fault code variable is traversed to obtain a matching target fault code;
[0009] Call the fault detection callback function of the target fault code to determine whether a fault exists, and generate the fault status of the registered fault code corresponding to the target fault code;
[0010] The fault status of the target fault code is saved in the vehicle fault code variable.
[0011] A second aspect of an embodiment of the present application provides a vehicle fault detection device, comprising:
[0012] An initialization module is configured to initialize the vehicle fault code variable and the fault global variable when the vehicle gateway is powered on. The vehicle fault code variable includes at least the fault codes of all faults of the vehicle and the fault detection callback function corresponding to each fault code. The fault global variable includes the fault detection information of at least some fault codes in the vehicle fault code variable.
[0013] A registration module is configured to receive a fault diagnosis response message, register a vehicle fault code variable according to the fault information carried in the fault diagnosis response message, and obtain a registered fault code;
[0014] A detection module is configured to start a preset fault detection timer in response to receiving a message to start a fault detection timer, and traverse the vehicle fault code variables for each registered fault code to obtain a matching target fault code;
[0015] A judgment module is configured to call a fault detection callback function of a target fault code to determine whether a fault exists, and generate a fault state of a registered fault code corresponding to the target fault code;
[0016] The saving module is configured to save the fault status of the target fault code in the vehicle fault code variable.
[0017] Compared with the prior art, the embodiments of the present application have the following beneficial effects: the embodiments of the present application configure the vehicle fault code variable and the fault global variable in the vehicle gateway, receive the fault diagnosis response message and register the vehicle fault code variable based on the fault information carried in the fault diagnosis response message to obtain the registered fault code, and then when the preset fault detection timer is started, the vehicle fault code variable is traversed for each registered fault code, and the matching target fault code is obtained in the vehicle fault code variable, and the fault detection callback function of the target fault code is called to determine whether there is a fault, and the fault state of the registered fault code corresponding to the target fault code is generated, and finally the fault state is saved in the vehicle fault code variable, so that the faults of the domain controllers of the whole vehicle can be diagnosed in the vehicle gateway, and the fault information of all faults can be recorded through the vehicle fault code variable, which is convenient for the user system to manage the whole vehicle fault. At the same time, the fault state of each fault code detected is also recorded in the vehicle fault code variable, and the user can quickly and easily distinguish between historical faults and new faults, providing support for subsequent fault processing.
[0018] Furthermore, the embodiment of the present application also configures node timeout global variables and fault global variables in the vehicle gateway, respectively, for storing motor node loss faults and other motor faults, respectively. By parsing the received fault diagnosis response message, or receiving the fault diagnosis response message and calling the fault detection callback function to determine the relevant information in the configuration motor node loss fault, and then obtaining the fault status of each fault code in the vehicle fault code variable according to the determined relevant information, the efficiency of fault detection is improved and the user experience is enhanced.
[0019] Furthermore, the embodiments of the present application also use configuration words to set the faults and motor nodes that need to be detected, so that when the vehicle's ECU or fault diagnosis application scenario changes, fault detection can be achieved by modifying the configuration words, or the configuration words and the fault code values in the fault configuration table can be modified, fault conditions can be generated, and fault conditions can be eliminated without modifying the fault diagnosis code as a whole, thereby improving the flexibility of fault detection. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0021] Figure 1 It is a flow chart of a vehicle fault detection method provided in an embodiment of the present application.
[0022] Figure 2 It is a flowchart of a method provided in an embodiment of the present application for calling a fault detection callback function of a target fault code to determine whether a fault exists, and generating a fault status of a registered fault code corresponding to the target fault code.
[0023] Figure 3 It is a flowchart of a method provided in an embodiment of the present application for calling a fault detection callback function to determine whether a target fault code satisfies a target fault generation condition, and determining a fault state corresponding to the target fault code according to the determination result.
[0024] Figure 4 It is a flowchart of a method provided in an embodiment of the present application for calling a fault detection callback function to determine whether a target fault code satisfies a target fault removal condition, and determining a fault state corresponding to the target fault code according to the determination result.
[0025] Figure 5It is a flowchart of a method provided in an embodiment of the present application for calling a fault detection callback function to determine whether a target fault code satisfies a fault generation condition or a fault elimination condition, and determining a fault state corresponding to the target fault code according to the judgment result.
[0026] Figure 6 It is a flowchart of the fault detection method provided in an embodiment of the present application.
[0027] Figure 7 It is a flow chart of another vehicle fault detection method provided in an embodiment of the present application.
[0028] Figure 8 It is a flowchart of a method for determining the timeout status of each node provided in an embodiment of the present application.
[0029] Fig. 9 It is a flow chart of the method for node loss fault detection provided in an embodiment of the present application.
[0030] Fig.10 It is a flowchart of the method for node loss fault recovery provided in an embodiment of the present application.
[0031] Fig.11 It is a flow chart of another vehicle fault detection method provided in an embodiment of the present application.
[0032] Fig.12 It is a flow chart of another vehicle fault detection method provided in an embodiment of the present application.
[0033] Fig.13 It is a schematic diagram of a vehicle fault detection device provided in an embodiment of the present application.
[0034] Fig.14 It is a schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0035] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0036] A vehicle fault detection method and device according to an embodiment of the present application will be described in detail below with reference to the accompanying drawings.
[0037] As mentioned above, the current fault detection cannot tell whether the fault is a new one or a historical fault. In addition, the fault is closely related to the actual vehicle ECU. The current fault reporting mechanism requires software to be updated after the vehicle scene and hardware equipment are replaced, which is time-consuming and labor-intensive. At the same time, the current fault uses the Controller Area Network (CAN) communication protocol, which has a high overhead.
[0038] In view of this, the embodiment of the present application provides a vehicle fault detection method, which configures the vehicle fault code variable and the fault global variable in the vehicle gateway, receives the fault diagnosis response message and registers the vehicle fault code variable based on the fault information carried by the fault diagnosis response message to obtain the registered fault code, and then when the preset fault detection timer is started, the vehicle fault code variable is traversed for each registered fault code, and the matching target fault code is obtained in the vehicle fault code variable, and the fault detection callback function of the target fault code is called to determine whether there is a fault, and the fault state of the registered fault code corresponding to the target fault code is generated, and finally the fault state is saved in the vehicle fault code variable, so that the fault of each domain controller of the vehicle can be diagnosed in the vehicle gateway, and the fault information of all faults can be recorded through the vehicle fault code variable, which is convenient for the user system to manage the vehicle fault. At the same time, the fault state of each fault code detected is also recorded in the vehicle fault code variable, and the user can easily and quickly check the historical faults and new faults, which provides support for subsequent fault processing.
[0039] Figure 1 FIG. 1 is a flow chart of a vehicle fault detection method provided in an embodiment of the present application. Figure 1 As shown, the method comprises the following steps:
[0040] In step S101, when the vehicle gateway is powered on, the vehicle fault code variables and fault global variables are initialized.
[0041] Among them, the vehicle fault code variable includes at least the fault codes of all vehicle faults and the fault detection callback function corresponding to each fault code, and the fault global variable includes the fault detection information of at least some fault codes in the vehicle fault code variable.
[0042] In step S102, a fault diagnosis response message is received, and a vehicle fault code variable is registered according to the fault information carried in the fault diagnosis response message to obtain a registered fault code.
[0043] In step S103, in response to receiving a message for starting a fault detection timer, a preset fault detection timer is started, and the vehicle fault code variables are traversed for each registered fault code to obtain a matching target fault code.
[0044] In step S104, the fault detection callback function of the target fault code is called to determine whether a fault exists, and the fault status of the registered fault code corresponding to the target fault code is generated.
[0045] In step S105, the fault status of the target fault code is saved in the vehicle fault code variable.
[0046] In an embodiment of the present application, the vehicle fault detection method can be executed by a vehicle gateway.
[0047] In an embodiment of the present application, a vehicle fault code variable and a fault global variable can be configured in the vehicle gateway, and the vehicle fault code variable and the fault global variable are initialized when the vehicle gateway is powered on. Among them, the vehicle fault code variable includes at least the fault codes of all faults of the vehicle, and the fault detection callback function corresponding to each fault code. The fault global variable includes the fault detection information of at least part of the fault codes in the vehicle fault code variable. For example, if it is necessary to detect a vehicle motor fault, the fault global variable can be configured as the fault detection information of all motor fault codes.
[0048] In an example, the vehicle fault code variable can be named s_dem_regtbl, and its structure is:
[0049] typedef struct
[0050] {
[0051] uint32_t code; / * 3 bytes fault code * /
[0052] uint8_t level; / * fault level * /
[0053] uint8_t status; / * fault status * /
[0054] uint8_t occucnt; / * fault occurrence count * /
[0055] uint8_t resetcnt; / * Resume counting * /
[0056] boolean (*function)(uint32_t code); / * Fault detection callback function* /
[0057] } dtc_regtbl_t;
[0058] Among them, dtc_regtbl_t is the structure name of the vehicle fault code variable s_dem_regtbl, and typedefstruct is the defined structure.
[0059] The fault code, fault level and fault detection callback function in the vehicle fault code variable s_dem_regtbl can be initialized and configured when the vehicle gateway is powered on. During power-on initialization, the fault status can be set to no fault, and the fault occurrence count and recovery count can be set to 0. That is, when the vehicle gateway is powered on and initialized, in s_dem_regtbl, set the fault status status = FASLE, the fault occurrence count occucnt = 0, and the recovery count resetctnt = 0.
[0060] Furthermore, the fault code can be updated according to the information obtained by parsing the fault diagnosis response message, and the registered fault code corresponding to the fault information carried in the fault diagnosis response message can be obtained. The fault state, fault occurrence count and recovery count can be updated according to the information obtained by parsing the fault diagnosis response message during fault detection, and can also be updated according to the return value of the fault detection callback function of each fault code.
[0061] In another example, the fault global variable can be named s_lin_elc_err, and its structure is:
[0062] typedef struct {
[0063] lin_errcode_elc_t code[LIN_ELC_ERR_MAX];
[0064] uint8_t id_num;
[0065] } lin_elc_err_t;
[0066] Among them, lin_elc_err_t is the structure name of the fault global variable s_lin_elc_err, which includes parameters code[LIN_ELC_ERR_MAX] and id_num. The parameter code[LIN_ELC_ERR_MAX] indicates the maximum number of faults, and its type is the structure lin_errcode_elc_t. The parameter id_num indicates the number of faults.
[0067] The fault data structure used to register into s_lin_elc_err is:
[0068] / * Number of faults * /
[0069] #define LIN_ELC_ERR_MAX40
[0070] / / Fault detection parameter structure
[0071] typedef struct {
[0072] uint32_t errcode; / / fault code value
[0073] uint8_t linid; / / LINID value
[0074] uint8_t peroid; / / period value
[0075] uint8_t peroid_cnt; / / cycle count
[0076] boolean state; / / fault status
[0077] uint8_t cnt; / / fault count
[0078] uint8_t cnt_occ; / / Generate fault count
[0079] uint8_t cnt_disocc; / / Remove fault count
[0080] uint8_t chn; / / channel number
[0081] uint8_t signnum; / / signal number
[0082] uint8_t occur; / / Generate fault status
[0083] uint8_t disoccur; / / Relieve fault status
[0084] uint8_t level; / / fault level
[0085] uint8_t elc_num; / / device number#
[0086] uint8_t signnum_bitnum; / / bit receiving flag corresponding to the signal number
[0087] } lin_errcode_elc_t;
[0088] / * Fault detection parameters * /
[0089] typedef struct {
[0090] lin_errcode_elc_t code[LIN_ELC_ERR_MAX];
[0091] uint8_t id_num;
[0092] } lin_elc_err_t;
[0093] In the fault global variable s_lin_elc_err, the fault code value and other information can be initialized and configured when the vehicle gateway is powered on. The fault status, fault count, fault generation count and fault clearance count can be obtained by parsing the fault diagnosis response message.
[0094] That is to say, the vehicle gateway can receive the fault diagnosis instruction, send the fault diagnosis instruction to each ECU, and receive the fault diagnosis response message returned by each ECU. Furthermore, the vehicle gateway can register the fault global variable according to the fault information carried in the fault diagnosis response message. After receiving the fault diagnosis response message, the vehicle gateway can parse the fault diagnosis response message and use the parsed information to update the fault status, fault count, fault generation count and fault release count corresponding to each fault code value in the fault global variable.
[0095] In an embodiment of the present application, a fault detection timer can be set in the vehicle gateway. When a message to start the fault detection timer is received, the fault detection timer is started. For each registered fault code in the vehicle fault code variable, all fault codes in the vehicle fault code variable are traversed to obtain the target fault code in the fault global variable that matches it. Then, the fault detection callback function of the target fault code is called to determine whether there is a fault, and then the fault state of the registered fault code corresponding to the target fault code is generated. Among them, the period of the fault detection timer can be set according to actual needs, for example, 50 milliseconds (ms).
[0096] It is understandable that if a registered fault code traverses all fault codes in the vehicle fault code variable and does not obtain a matching target fault code, it can be considered that the registered fault code does not have a fault. At this time, the fault state of the registered fault code can be directly set to no fault in the vehicle fault code variable.
[0097] In an embodiment of the present application, the generated fault code status can be saved in the vehicle fault code variable and the fault code status parameter of the registered fault code corresponding to the target fault code, thereby realizing unified diagnosis of vehicle faults in the vehicle gateway. At the same time, the diagnosis result includes the fault code status, so that the user can quickly obtain the fault detection result by querying the vehicle fault code variable and effectively distinguish between historical faults and new faults.
[0098] According to the technical solution provided by the embodiment of the present application, by configuring the vehicle fault code variable and the fault global variable in the vehicle gateway, receiving the fault diagnosis response message and registering the vehicle fault code variable based on the fault information carried by the fault diagnosis response message, the registered fault code is obtained, and then when the preset fault detection timer is started, the vehicle fault code variable is traversed for each registered fault code, and the matching target fault code is obtained in the vehicle fault code variable, and the fault detection callback function of the target fault code is called to determine whether there is a fault, and the fault state of the registered fault code corresponding to the target fault code is generated, and finally the fault state is saved in the vehicle fault code variable, so that the fault of each domain controller of the vehicle can be diagnosed in the vehicle gateway, and the fault information of all faults can be recorded through the vehicle fault code variable, which is convenient for the user system to manage the vehicle fault. At the same time, the fault state of each fault code detected is also recorded in the vehicle fault code variable, and the user can easily and quickly check the historical faults and new faults, which provides support for subsequent fault processing.
[0099] In the embodiment of the present application, after the vehicle gateway is powered on, the vehicle gateway may also receive a configuration word sent by the diagnostic device and convert the configuration word into a configuration variable. The configuration variable is used to identify whether each fault needs to be detected.
[0100] In an embodiment of the present application, the configuration word may be sent to the vehicle gateway by the fault diagnosis device through the 2E service of the UDS protocol, and is used to specify which ECUs need to perform which fault detections. Among them, the fault diagnosis device can be connected to the vehicle gateway and send diagnostic instructions to the vehicle gateway, so that the corresponding on-board unit can perform the corresponding test operation after receiving the diagnostic instructions forwarded by the vehicle gateway, and receive the test results forwarded by the vehicle gateway. In one example, the configuration word can be 32 bytes, such as 2EF011XX. When the ECU does not exist, there is no need to change the code. It is only necessary to send 2E F0 11 XX (32-byte configuration word) to the gateway through the UDS diagnostic protocol 2E after power-on, for example, 2EF01 1A00007B95FD0D1306A703412401220000000000000000000000000000000000000000. Table 1 is the code definition of the configuration word.
[0101] Table 1 Configuration word code definition
[0102] The code definition of the configuration word can be defined according to actual needs. The code definition of the configuration word is converted into a bit table, and the expression form is shown in Table 2.
[0103] Table 2 Configuration word code definition bit table
[0104]
[0105] By splitting the configuration word into a bit table, we can get Table 3.
[0106] Table 3 Configuration word split into bits
[0107]
[0108] It can be seen that they are arranged in bits and bytes, because the configuration word has 32 bytes. Generally speaking, each bit represents a fault. When the configuration is 1, a fault code is reported, that is, the gateway needs to detect the fault.
[0109] After receiving the configuration word, the vehicle gateway can convert it into a 64-bit configuration variable, which is a global variable, for example, it can be named DTClist. It should be noted that the capacity of the configuration variable can be determined according to actual needs, but it does not exceed the capacity of the configuration word, that is, 32 bytes. Further, you can set
[0110] static uint64_t s_lin_dtclist = 0x0000000000000000UL; / * Not installed by default, set to 1 if installation is detected* /
[0111] / * Store data * /
[0112] s_lin_dtclist |= (uint64_t)((pdata[0]&0x20)>>5); / / 1# General electrical fault of motor
[0113] s_lin_dtclist |= (uint64_t)((pdata[0]&0x02)>>1)<<1; / / 1# Permanent electrical fault of the motor
[0114] s_lin_dtclist |= (uint64_t)((pdata[4]&0x10)>>4)<<2; / / 1# Motor communication error fault
[0115] s_lin_dtclist |= (uint64_t)((pdata[3]&0x02)>>1)<<3; / / 1# Motor node lost fault
[0116] s_lin_dtclist |= (uint64_t)((pdata[5]&0x04)>>2)<<4; / / 1# Motor overheat fault
[0117] s_lin_dtclist |= (uint64_t)((pdata[4]&0x40)>>6)<<5; / / 2# General electrical fault of motor
[0118] s_lin_dtclist |= (uint64_t)((pdata[0]&0x04)>>2)<<6; / / 2# Permanent electrical fault of the motor
[0119] s_lin_dtclist |= (uint64_t)((pdata[5]&0x01)>>0)<<7; / / 2# Motor communication error fault
[0120] s_lin_dtclist |= (uint64_t)((pdata[8]&0x02)>>1)<<8; / / 2# Motor node lost fault
[0121] s_lin_dtclist |= (uint64_t)((pdata[6]&0x01)>>0)<<9; / / 2# Motor overheat fault
[0122] s_lin_dtclist |= (uint64_t)((pdata
[12] &0x04)>>2)<<10; / / 3# General electrical fault of motor
[0123] Among them, UL stands for Unsigned Long, which means an unsigned long integer, and |= is a bit or assignment symbol. Furthermore, pdata is the written configuration word, and the bit corresponding to the motor fault is taken out, and the value of the bit is assigned to s_lin_dtclist, that is, DTClist. For example, the 1# motor communication error fault is a motor fault, and the bit corresponding to its configuration word is the first byte, the fifth bit, then the bit is moved to the lowest bit, and then assigned to the 0th bit of s_lin_dtclist. And so on, fill each fault from the lowest bit to the highest bit of s_lin_dtclis, and assign the newly obtained value to the 1st bit, the 2nd bit..., until the last bit of s_lin_dtclist in sequence. In this way, by querying the values of different bits in the configuration variable, it can be determined whether a certain fault of the ECU corresponding to the bit needs to be detected.
[0124] Furthermore, calling the fault detection callback function of the target fault code to determine whether a fault exists can be to determine whether the target fault corresponding to the target fault code is identified in the configuration variable as requiring detection; in response to determining that the target fault corresponding to the target fault code is identified in the configuration variable as requiring detection, calling the fault detection callback function of the target fault code to determine whether a fault exists.
[0125] That is to say, when traversing the fault code variables of the whole vehicle, for any fault code variable traversed, the corresponding value in the configuration variable can be used to determine whether the fault code needs to be detected. If so, continue to execute the step of detecting the fault code, otherwise do not detect the fault code. In this way, when the fault detection application scenario changes, for example, when different faults need to be detected, the configuration word can be directly modified to achieve it without modifying the fault diagnosis code.
[0126] In an embodiment of the present application, initializing the fault global variable may be, obtaining a fault configuration table; using the fault configuration table to initialize the fault code value, fault generation conditions and fault clearance conditions in the fault global variable; initializing the fault state in the fault global variable to no fault, and initializing the fault generation count and fault clearance count in the fault global variable to 0.
[0127] As before, the fault code value, fault generating condition and fault clearing condition in the fault global variable can be configured during initialization. Further, the vehicle gateway can obtain the fault configuration table and use the information in the fault configuration table to initialize the fault global variable.
[0128] In an example, if the fault to be detected is a motor fault, the fault configuration table can be named a global array s_lin_elc_errcode, and its structure is:
[0129] / **************Motor failure*************** /
[0130] 0x20, / / Number of IDs of motor faults
[0131] / **************** Vent1 ******************* /
[0132] LIN_9, / / Channel number
[0133] 0x18, / / ID value
[0134] 0x10, / / minimum frame period value (2 bytes) 160ms
[0135] 0x01,0x80,0x93,0x00, / / Fault code value (4 bytes) / / 1# Motor general electrical fault
[0136] LINID02, / / Signal number
[0137] 0x00, / / Relieve motor fault condition
[0138] 0x01, / / Generate motor fault condition
[0139] 0x01, / / Fault level
[0140] 0x00, / / Motor number # - 1
[0141] 0x00, / / bit corresponding to the signal number: bit0
[0142] / **************** Vent1 ******************* /
[0143] LIN_9, / / Channel number
[0144] 0x18, / / ID value
[0145] 0x10, / / minimum frame period value (2 bytes) 160
[0146] 0x09,0x80,0x93,0x00, / / Fault code value (4 bytes) / / 1# Motor permanent electrical fault
[0147] LINID02, / / Signal number
[0148] 0x00, / / Relieve motor fault condition
[0149] 0x02, / / Generate motor fault condition
[0150] 0x01, / / Fault level
[0151] 0x00, / / Motor number # - 1
[0152] 0x01, / / bit corresponding to the signal number: bit1
[0153] Among them, the motor fault condition and the motor fault condition can be queried from the motor fault diagnostic trouble code (DTC) table. Table 4 is a motor fault DTC table provided in an embodiment of the present application:
[0154] Table 4 Motor Fault DTC
[0155]
[0156] Table 4 continued from Table 1
[0157]
[0158] Table 4 continued from Table 2
[0159]
[0160] The vehicle gateway registers the fault configuration table, that is, the information in the global array s_lin_elc_errcode, into the fault global variable s_lin_elc_err for subsequent query during fault detection.
[0161] On the other hand, the vehicle gateway can update the fault status in the fault global variable, generate fault counts, and release fault counts according to the fault information carried in the fault diagnosis response message. The format of the fault diagnosis response message is shown in Table 5:
[0162] Table 5 Fault diagnosis response message
[0163]
[0164] Table 5 continued from Table 1
[0165]
[0166] Table 5 continued from Table 2
[0167]
[0168] Table 5 continued from Table 3
[0169]
[0170] After receiving the fault diagnosis response message, the vehicle gateway parses and extracts the information therein, and then uses the information to update the fault status in the fault global variable, generate fault counts, and release fault counts.
[0171] Figure 2 1 is a flow chart of a method for calling a fault detection callback function of a target fault code to determine whether a fault exists, and generating a fault status of a registered fault code corresponding to the target fault code, provided by an embodiment of the present application. Figure 2 As shown, the method comprises the following steps:
[0172] In step S201, the fault detection callback function of the target fault code is called to determine whether the target fault code satisfies the target fault generation condition or the target fault elimination condition.
[0173] In step S202, the fault state corresponding to the target fault code is determined according to the judgment result.
[0174] Among them, the target fault generation condition is the fault generation condition corresponding to the target fault code value in the fault global variable, and the target fault removal condition is the fault removal condition corresponding to the target fault code value in the fault global variable.
[0175] In the embodiment of the present application, when the fault detection timer is turned on to traverse the vehicle fault code variable, the target fault code traversed, that is, the target fault code value in the fault global variable that matches the registered fault code traversed this time, can be determined as the fault code that needs to be detected this time. Therefore, the fault detection callback function of the target fault code can be called to determine whether the target fault code meets the target fault generation condition or the target fault removal condition, and the fault state corresponding to the target fault code is determined according to the judgment result.
[0176] Among them, the fault generation conditions and fault clearance conditions of the fault code refer to the description in Table 4 above, and the fault generation conditions and fault clearance conditions of each fault code are written into the fault global variable when the vehicle gateway is powered on and initialized. At the same time, the fault detection callback function of each fault code is also written into the vehicle fault code variable when the vehicle gateway is powered on and initialized. For the target fault code in the vehicle fault code variable, its fault detection callback function is called in the vehicle fault code variable, and the fault generation conditions and fault clearance conditions of the fault value matching the target fault code are obtained from the fault global variable, and the fault state of the target fault code can be determined. Furthermore, the current state of the target fault code in the vehicle fault code variable can also be combined when making a judgment. For specific judgment methods, please refer to the detailed description below.
[0177] Figure 3 1 is a flow chart of a method for calling a fault detection callback function to determine whether a target fault code satisfies a target fault condition, and determining a fault state corresponding to the target fault code according to the determination result, provided in an embodiment of the present application. Figure 3 As shown, the method comprises the following steps:
[0178] In step S301 , in response to determining that the target fault code satisfies the target fault generation condition, the clear fault count of the target fault code value in the fault global variable is set to 0, and the generate fault count of the target fault code value in the fault global variable is incremented by 1.
[0179] In step S302, in response to determining that the fault count generated after the plus 1 operation is greater than or equal to the first preset threshold, the fault state corresponding to the target fault code in the vehicle fault code variable is set to the presence of a new fault.
[0180] In step S303, in response to determining that the fault count after the plus 1 operation is less than the first preset threshold, the fault state corresponding to the target fault code is set to no fault in the vehicle fault code variable.
[0181] In an embodiment of the present application, when calling the fault detection callback function to determine whether the target fault code meets the target fault generation condition, the clear fault count of the target fault code value in the fault global variable can be set to 0, and the generation fault count of the target fault code value in the fault global variable can be increased by 1.
[0182] In an embodiment of the present application, if it is determined that the fault count generated after the plus 1 operation is greater than or equal to the first preset threshold, the fault state corresponding to the target fault code can be set to the existence of a fault in the vehicle fault code variable.
[0183] In an embodiment of the present application, if it is determined that the fault count generated after the plus 1 operation is greater than or equal to the first preset threshold, the fault state corresponding to the target fault code in the vehicle fault code variable can be set to the presence of a new fault, for example, represented by s_dem_regtbl.status=0x09.
[0184] In an embodiment of the present application, if it is determined that the fault count generated after the plus 1 operation is less than the first preset threshold, the fault state corresponding to the target fault code can be set to no fault in the vehicle fault code variable, for example, represented by s_dem_regtbl.status=0x00.
[0185] The first preset threshold can be set according to actual needs, for example, 3.
[0186] Figure 4 1 is a flow chart of a method for calling a fault detection callback function to determine whether a target fault code satisfies a target fault removal condition and determining a fault state corresponding to the target fault code according to the determination result provided by an embodiment of the present application. Figure 4 As shown, the method comprises the following steps:
[0187] In step S401 , in response to determining that the target fault code satisfies the target fault removal condition, the clear fault count of the target fault code value in the fault global variable is incremented by 1, and the generate fault count of the target fault code value in the fault global variable is set to 0.
[0188] In step S402, in response to determining that the cleared fault count after the plus 1 operation is greater than or equal to the second preset threshold, the fault state corresponding to the target fault code is set to fault recovery in the vehicle fault code variable.
[0189] In step S403, in response to determining that the cleared fault count after the plus 1 operation is less than the second preset threshold, the fault state corresponding to the target fault code is set to fault existence in the vehicle fault code variable.
[0190] In an embodiment of the present application, when the fault detection callback function is called to determine that the target fault code meets the target fault clearance condition, the clear fault count of the target fault code value in the fault global variable can be increased by 1, and the generated fault count of the target fault code value in the fault global variable can be set to 0.
[0191] In an embodiment of the present application, if it is determined that the cleared fault count after the plus 1 operation is greater than or equal to the first preset threshold, the fault state corresponding to the target fault code can be set to fault recovery in the vehicle fault code variable, for example, represented by s_dem_regtbl.status=0x08.
[0192] In an embodiment of the present application, if it is determined that the cleared fault count after the plus 1 operation is less than the second preset threshold, the fault state corresponding to the target fault code can be set to a fault in the vehicle fault code variable, for example, represented by s_dem_regtbl.status=0x09.
[0193] The second preset threshold can be set according to actual needs, for example, 3.
[0194] Figure 5 The present invention provides a method for calling a fault detection callback function to determine whether a target fault code satisfies a fault generation condition or a fault elimination condition, and determining a fault state corresponding to the target fault code according to the judgment result. Figure 5 As shown, the method comprises the following steps:
[0195] In step S501, in response to determining that the target fault code satisfies neither the fault generation condition nor the fault removal condition, the fault generation count of the target fault code value in the fault global variable is set to 0, and the fault clearance count of the target fault code value in the fault global variable is set to 0.
[0196] In step S502, in the vehicle fault code variable, the fault state corresponding to the target fault code is set to no fault.
[0197] In the embodiment of the present application, when it is determined that the target fault code satisfies neither the fault generation condition nor the fault removal condition, the fault generation count of the target fault code value in the fault global variable is set to 0, and the fault removal count of the target fault code value in the fault global variable is set to 0. Furthermore, the fault state corresponding to the target fault code can be set to no fault in the vehicle fault code variable.
[0198] Figure 6 FIG. 1 is a flow chart of a fault detection method provided in an embodiment of the present application. Figure 6As shown, when the fault detection timer is turned on, you can first confirm whether the fault detection function is turned on. If not, return to end the detection process. If it is confirmed that the fault detection function is turned on, determine whether the vehicle gateway is powered on for the first time. If so, read the fault data and initialize the vehicle fault code variable and the fault global variable. Among them, the fault data can be stored in the flash memory of the vehicle gateway. After reading the fault data, or after determining that the vehicle gateway is not powered on for the first time, you can traverse all registered fault codes and return to end the process after the traversal is completed.
[0199] During the traversal process, for each registered fault code, the fault detection callback function that the fault code depends on can be executed to determine whether there is a fault. If there is no fault, determine whether it is a recovery after a fault. If it is determined not to be a recovery after a fault, that is, the fault has never occurred, s_dem_regtbl.status is set to 0x00. If it is determined to be a recovery after a fault, s_dem_regtbl.status is set to 0x08. On the other hand, if there is a fault, s_dem_regtbl.status is set to 0x09, indicating that there is currently a fault. The value of the determined fault code fault status s_dem_regtbl.status is stored in the flash, and then the remaining registered fault codes are traversed again until the traversal of all registered fault codes is completed.
[0200] In the embodiment of the present application, when performing fault detection, the node loss fault can be detected separately as a specific fault. That is to say, in the embodiment of the present application, a node timeout global variable can also be configured in the vehicle gateway, and when the vehicle gateway is powered on and initialized, the node timeout global variable is initialized using the fault configuration table, and after receiving the fault diagnosis response message, the node timeout global variable is registered using the fault information carried in the fault diagnosis response message.
[0201] Figure 7 is a flow chart of another vehicle fault detection method provided in an embodiment of the present application. Figure 7 Steps S702 to S705 in the embodiment shown are similar to Figure 1 Steps S102 to S105 in the illustrated embodiment are substantially the same and will not be described in detail herein. Figure 7 As shown, the method also includes the following steps:
[0202] In step S701, when the vehicle gateway is powered on, a fault configuration table is obtained, the vehicle fault code variables are initialized, and the fault configuration table is used to initialize the fault global variables and the node timeout global variables.
[0203] Among them, the vehicle fault code variable includes at least the fault codes of all vehicle faults and the fault detection callback function corresponding to each fault code, and the fault global variable includes the fault detection information of at least some fault codes in the vehicle fault code variable.
[0204] In step S706, the timeout count of the node timeout global variable is initialized to 0, and the timeout state of the node timeout global variable is initialized to the node not lost state.
[0205] In step S707, in response to receiving the message for starting the node loss timer, the preset node loss timer is started, all nodes in the node timeout global variable are traversed, and the timeout status of each node is determined.
[0206] In the embodiment of the present application, the fault configuration table is obtained when the vehicle gateway is powered on, and the node timeout global variable is initialized using the fault configuration table. The node timeout global variable can be named s_lin_timeout, and its structure is:
[0207] / / Frame timeout detection parameter structure
[0208] typedef struct {
[0209] uint32_terrcode; / / fault code value
[0210] uint16_tlinid; / / LIINID value
[0211] uint16_tperoid; / / period value
[0212] booleanstate; / / timeout status
[0213] uint16_tcnt; / / timeout count
[0214] uint8_tchn; / / channel number
[0215] uint8_tlevel; / / fault level
[0216] } lin_errcode_t;
[0217] / * Minimum number of frame periods * /
[0218] #define LIN_TIMEOUT_MAX20
[0219] / * Frame timeout detection parameters* /
[0220] typedef struct {
[0221] lin_errcode_t code[LIN_TIMEOUT_MAX];
[0222] uint8_t id_num;
[0223] } lin_timeout_t;
[0224] During initialization, the information in s_lin_elc_errcode can be extracted into s_lin_timeout, where the timeout state can be initialized to the node not being lost, that is, state = FALSE, and the timeout count can be initialized to 0, that is, cnt = 0.
[0225] The array contents for node loss are as follows (global array: s_lin_errcode):
[0226] / **************Frame timeout configuration table*************** /
[0227] 0x08, / / Number of IDs for frame timeout
[0228] / **************** Vent1 ******************* /
[0229] LIN_9, / / Channel number
[0230] 0x18, / / ID value
[0231] 0x38,0x00, / / Minimum frame period value (2 bytes)
[0232] 0x87,0x80,0x93,0x00, / / Fault code value (4 bytes)
[0233] 0x01, / / Fault level A1: A2: B3: C4: D
[0234] / **************** Vent2 ******************* /
[0235] LIN_9, / / Channel number
[0236] 0x19, / / ID value
[0237] 0x38,0x00, / / Minimum frame period value (2 bytes)
[0238] 0x87,0x81,0x93,0x00, / / Fault code value (4 bytes)
[0239] 0x01, / / Fault level A1: A2: B3: C4: D
[0240] The contents in the fault configuration table can be used to set the number of frame timeout IDs, the Lin channel number of the Lin message, the ID value of the Lin message, the message sending cycle, the fault code, and the fault level.
[0241] In the embodiment of the present application, the initialization and update method of the node timeout global variable is basically the same as the initialization and update method of the fault global variable, and will not be repeated here.
[0242] In an embodiment of the present application, a node loss timer can be set in the vehicle gateway for detecting node loss failures separately. When the vehicle gateway receives a message to start the node loss timer, the preset node loss timer is started, and all nodes in the node timeout global variable are traversed to determine the timeout status of each node. Among them, the period of the node loss timer can be set according to actual needs, for example, 10ms.
[0243] Figure 8 FIG. 1 is a flow chart of a method for determining the timeout status of each node provided in an embodiment of the present application. Figure 8 As shown, the method comprises the following steps:
[0244] In step S801, in response to determining in the configuration variable that the node loss fault bit corresponding to the target node is set to require detection, and there is no fault diagnosis response message of the target node in the node timeout global variable, the timeout count of the target node in the node timeout global variable is increased by 1.
[0245] The target node is any node among all nodes in the node timeout global variable.
[0246] In step S802, in response to determining that the timeout count of the target node after the plus 1 operation is performed is greater than or equal to a third preset threshold, it is determined that a node loss failure occurs in the target node.
[0247] In step S803, the timeout state of the target node is set to the node loss state, and the timeout count of the target node is set to 0.
[0248] In an embodiment of the present application, when traversing each node, if it is determined in the configuration variable that the node loss fault bit corresponding to the target node is set to require detection, and the timeout state in the node timeout global variable is the node loss state, the timeout count of the target node in the node timeout global variable is added by 1.
[0249] Next, if it is determined that the timeout count of the target node after the plus 1 operation is greater than or equal to the third preset threshold, it can be determined that a node loss failure has occurred in the target node. At this time, the timeout state of the target node can be set to the node loss state, and the timeout count of the target node can be set to 0.
[0250] The value of the third threshold can be set according to actual needs, for example, 10.
[0251] Fig. 9 FIG. 1 is a flow chart of a method for detecting node loss failure provided in an embodiment of the present application. Fig. 9 As shown, when the node loss timer is turned on, all nodes in the node timeout global variable can be traversed first. If the traversal is completed, return to end the process. If the traversal is not completed, for each traversed node, first determine whether its configuration word is 1, that is, determine whether the node needs to perform node loss fault detection. If it is not 1, continue to traverse the next node. If it is 1, continue to determine whether the node timeout global variable has the current fault diagnosis response message of the target node. If so, it can be determined that the target node is not lost, and the timeout state of the target node is set to the node non-lost state in the node timeout global variable, that is, set s_lin_timeout.code[cnt].state = FALSE. If not, the timeout count of the target node in the node timeout global variable can be increased by 1. Next, determine whether the timeout count of the target node after the plus 1 operation is greater than or equal to the third preset threshold. If so, it is determined that a node loss failure has occurred at the target node. At this time, the timeout state of the target node can be set to the node loss state, that is, set s_lin_timeout.code[cnt].state = TRUE, and the timeout count of the target node is set to 0, that is, set s_lin_timeout.code[cnt].cnt = 0.
[0252] Among them, the standard prerequisites for the node loss fault can be determined from the motor fault DTC table shown in Table 4, for example, including:
[0253] 1) ECU is powered on and the ignition switch is in the ON position for a delay of 2 seconds;
[0254] 2) After the diagnostic function is restored for 500ms;
[0255] 3) Non-busoff state;
[0256] 4) Within normal voltage range.
[0257] Furthermore, by querying Table 4, it can be learned that the fault condition is: the message is lost 10 times continuously.
[0258] Furthermore, Figure 8 The method of the illustrated embodiment may also include:
[0259] In step S804, in response to determining that the node timeout global variable includes the current fault diagnosis response message of the target node, the timeout state of the target node is set to a node non-lost state, and the timeout count of the target node is set to 0.
[0260] In an embodiment of the present application, when traversing each node, if it is determined that the node timeout global variable includes the current fault diagnosis response message of the target node, indicating that the current message is not lost, then the timeout state of the target node can be set to the node not lost state, and the timeout count of the target node can be set to 0, thereby completing the recovery of the node loss fault.
[0261] Fig.10 FIG. 1 is a flow chart of a method for recovering from node loss failure provided by an embodiment of the present application. Fig.10 As shown in the figure, when the message reception is interrupted, that is, after the current round of message reception is completed, all nodes in the node timeout global variable can be traversed to determine whether the received message exists in the node timeout global variable. If it exists, it means that the message is received successfully this time. At this time, it can be considered that the node loss fault has been restored. Therefore, the timeout state of the target node can be set to the node non-loss state, that is, set s_lin_timeout.code[cnt].state = FALSE, and the timeout count of the target node can be set to 0, that is, set s_lin_timeout.code[cnt].cnt = 0.
[0262] In the embodiment of the present application, the node loss fault can be detected by detecting the state bit of s_lin_timeout.code. If s_lin_timeout.code[cnt].state = FALSE, it indicates that there is no node loss fault at present, and if s_lin_timeout.code[cnt].state = TRUE, it indicates that a node loss fault has occurred at present. Wherein, cnt is the index of the registered node loss message.
[0263] After a node loss failure occurs, the status position of s_dem_regtbl[i].status can be set to 0x90. When the failure is detected again and it is found that the failure has been recovered, the status position of s_dem_regtbl[i].status is set to 0x80.
[0264] In the embodiment of the present application, the vehicle fault code variable at least includes a fault code, a fault state, a fault count and a fault detection callback function. Among them, the fault code and the fault detection callback function are configured in the initialization stage, the fault code can be registered in the stage of registering the vehicle fault code variable according to the fault information carried in the fault diagnosis response message to obtain the registered fault code, and the fault state and the fault count are configured and updated in the stage of registering the vehicle fault code variable according to the fault information carried in the fault diagnosis response message.
[0265] Furthermore, in the stage of registering the vehicle fault code variable with the fault information carried in the fault diagnosis response message, the configuration of updating the fault status and fault count can be to parse the fault information carried in the fault diagnosis response message to obtain the fault status and fault count of the fault code corresponding to the message. Alternatively, the fault information carried in the fault diagnosis response message is parsed, and the parsed information is input into the fault detection callback function of the fault code corresponding to the message; the fault status and fault count are determined according to the return value of the fault detection callback function of the fault code corresponding to the message.
[0266] In an embodiment of the present application, the fault state of the target fault code is saved in the vehicle fault code variable. In response to determining that the target fault code does not have a fault and is not recovered after a fault, the fault state of the target fault code in the vehicle fault code variable is set to the first state, that is, s_dem_regtbl.status=0x00. In response to determining that the target fault code does not have a fault and is recovered after a fault, the fault state of the target fault code in the vehicle fault code variable is set to the second state, that is, s_dem_regtbl.status=0x08. In response to determining that the target fault code has a fault, the fault state of the target fault code in the vehicle fault code variable is set to the third state, that is, s_dem_regtbl.status=0x09. Among them, the target fault code is any fault code in the vehicle fault code variable.
[0267] Fig.11 FIG. 1 is a flow chart of another vehicle fault detection method provided in an embodiment of the present application. Fig.11 As shown, when performing vehicle fault detection, the vehicle gateway can be powered on first, and the node timeout global variable, fault global variable and vehicle fault code variable are registered in the vehicle gateway when powered on. Then the configuration word is written through the 2E service. After the fault occurs, the vehicle gateway receives the fault diagnosis response message reported by the vehicle ECU, and detects the message according to the registered node timeout global variable, fault global variable and vehicle fault code variable to obtain the fault detection result.
[0268] Fig.12 FIG. 1 is a flow chart of another vehicle fault detection method provided in an embodiment of the present application. Fig.12As shown, first start the 50ms fault detection timer, receive the Lin message and parse the fault code information, and register the fault code information to the vehicle fault code variable. For each fault code in the registered vehicle fault code variable, traverse the fault codes in the vehicle fault code variable to determine whether there is a registered fault code in the fault global variable that matches the fault code in the vehicle fault code variable.
[0269] Determine whether all fault codes in the fault global variable have been traversed. If so, determine that there is no fault and exit. If not, take out a fault and determine whether the fault code matches the fault code value in the fault global variable. If not, continue to traverse the next fault code. If it matches, continue to execute the detection process.
[0270] Determine whether the node to which the fault currently removed belongs is lost. If lost, determine that a node loss fault has occurred and exit; if not lost, continue to execute the detection process.
[0271] Determine whether the fault generation condition is met, that is, whether the corresponding signal in the received Lin message meets the fault generation condition. If it meets the condition, the fault clearing count is cleared to zero, the fault generation count is accumulated by 1, and then determine whether the fault generation count is >= 3. If so, the fault generation count is assigned to 3, and the fault status is set to FALSE, that is, the fault is generated, it is judged as a fault and exits. Otherwise, if the fault generation count is <3, it is determined that there is no fault and exits.
[0272] If the fault generation condition is not met, then continue to determine whether the fault clearing condition is met, that is, whether the corresponding signal in the received Lin message meets the fault clearing condition. If yes, the fault clearing count is accumulated by 1, the fault generation count is cleared, and then determine whether the fault clearing count is >= 3, that is, 3 signals that meet the fault clearing condition are received in succession. If yes, the fault clearing count is assigned to 3, and the motor fault status is set to TRUE, that is, the fault is recovered, and it is determined that there is no fault and exit. On the contrary, if the fault clearing count is <3, it is determined that there is a fault and exit.
[0273] On the contrary, if it is determined that the fault clearing condition is not met, that is, a signal that is neither a fault generating signal nor a fault clearing signal is received at this time, the fault generating count is cleared to zero, the fault clearing count is also cleared to zero, and it is determined that there is no fault and exits.
[0274] Taking the detection of vehicle motor fault as an example, the 50ms fault detection timer will detect the registered fault code s_dem_regtbl, traverse each fault code, and call the fault detection callback function corresponding to the fault code.
[0275] For motor node loss, determine whether the fault status of s_lin_timeout is TRUE. If it is TRUE, a node loss fault has occurred, but the fault status of s_dem_regtbl is FASLE, which means it is the first fault. Then change the fault status of s_dem_regtbl to 0x09.
[0276] For motor faults other than motor node loss fault, determine whether the fault status of s_lin_elc_err is FALSE. If it is FALSE, a motor fault has occurred, but the fault status of s_dem_regtbl is FASLE, which means that the fault has occurred for the first time. Then change the fault status of s_dem_regtbl to 0x09.
[0277] When the timer is entered next time, if the fault is restored, the fault status of s_dem_regtbl is changed to 0x08. It can be known that it is a historical fault. When a node loss fault occurs during the next fault detection, the fault status of s_dem_regtbl is changed to 0x09, and it can be known that it is a current fault. In this way, fault detection is achieved.
[0278] In the embodiment of the present application, when it is determined that the electronic control unit in the vehicle has changed, or when it is determined that the fault diagnosis scenario has changed, an updated configuration word sent by the diagnostic device can be received, and the updated configuration word can be converted into an updated configuration variable. If it is determined that the target fault corresponding to the target fault code is marked as requiring detection in the updated configuration variable, the fault detection callback function of the target fault code is called to determine whether there is a fault.
[0279] In an embodiment of the present application, when it is determined that an electronic control unit in a vehicle has changed, or when it is determined that a fault diagnosis scenario has changed, an updated configuration word sent by a diagnostic device can be received, and the updated configuration word can be converted into an updated configuration variable. Then, the vehicle gateway obtains an updated fault configuration table, and the updated fault configuration table includes at least an updated fault code value, an updated fault generation condition, and an updated fault clearance condition. Finally, if it is determined that the target fault corresponding to the target fault code is marked as requiring detection in the updated configuration variable, the fault detection callback function of the target fault code is called, and the updated fault code value, the updated fault generation condition, and the updated fault clearance condition are used to determine whether a fault exists.
[0280] That is to say, when the vehicle hardware, such as the ECU, changes, or when the vehicle fault diagnosis application scenario changes, the technical solution provided in the embodiment of the present application can be used to update the fault detection solution by modifying the configuration word without modifying the entire fault diagnosis code.
[0281] In the embodiment of the present application, after the fault status of all target fault codes is saved in the vehicle fault code variable, if a fault query instruction is received, the fault information is queried from the vehicle fault code variable. Alternatively, after the fault status of all target fault codes is saved in the vehicle fault code variable, if a fault clear instruction is received, the fault information in the vehicle fault code variable is cleared.
[0282] That is to say, after receiving the fault query instruction, the 19th routine control of the UDS diagnostic service can be used to query. Among them, the fault query instruction is shown in Table 6:
[0283] Table 6 Fault query instruction table
[0284]
[0285] In one example, the number of all registered fault codes can be queried through 1901, and the fault information of all currently registered fault codes can be queried through 1902, including the fault code and status.
[0286] When receiving the fault clearing instruction, the 14th routine control of the UDS diagnostic service can be used to clear all fault records. Among them, the fault clearing instruction is shown in Table 7:
[0287] Table 7 Fault Clearing Instructions
[0288]
[0289] In the embodiment of the present application, the vehicle gateway communicates with the electronic control unit in the vehicle using the local interconnect network LIN communication protocol. The fault diagnosis response message is a LIN message, which is sent by the electronic control unit to the vehicle gateway.
[0290] The technical solution provided by the embodiment of the present application provides a method for externalizing the fault diagnosis results of the domain controller. By performing diagnostic processing on the gateway, the motor fault can be reported to the remote server in real time, and all faults under the domain controller can be obtained at the same time, which is conducive to systematic fault handling. At the same time, by using the function of the configuration word, the detection of motor faults can be achieved without changing the software after changing the hardware scene. The lightweight UDS diagnostic service provided by the embodiment of the present application can realize the query and clearing of faults, and supports the recording and query of historical faults and current faults.
[0291] All the above optional technical solutions can be arbitrarily combined to form optional embodiments of the present application, which will not be described one by one here.
[0292] The following is an embodiment of the device of the present application, which can be used to execute the embodiment of the method of the present application. For details not disclosed in the embodiment of the device of the present application, please refer to the embodiment of the method of the present application.
[0293] Fig.13 Schematic diagram of a vehicle fault detection device provided in an embodiment of the present application. Fig.13 As shown, the device comprises:
[0294] The initialization module 1301 is configured to initialize the vehicle fault code variable and the fault global variable when the vehicle gateway is powered on. The vehicle fault code variable includes at least the fault codes of all vehicle faults and the fault detection callback function corresponding to each fault code. The fault global variable includes the fault detection information of at least some of the fault codes in the vehicle fault code variable.
[0295] The registration module 1302 is configured to receive a fault diagnosis response message, register a vehicle fault code variable according to the fault information carried in the fault diagnosis response message, and obtain a registered fault code.
[0296] The detection module 1303 is configured to start a preset fault detection timer in response to receiving a message for starting a fault detection timer, and traverse the vehicle fault code variables for each registered fault code to obtain a matching target fault code.
[0297] The determination module 1304 is configured to call the fault detection callback function of the target fault code to determine whether a fault exists, and generate a fault status of the registered fault code corresponding to the target fault code.
[0298] The saving module 1305 is configured to save the fault status of the target fault code in the vehicle fault code variable.
[0299] According to the technical solution provided by the embodiment of the present application, by configuring the vehicle fault code variable and the fault global variable in the vehicle gateway, receiving the fault diagnosis response message and registering the vehicle fault code variable based on the fault information carried by the fault diagnosis response message, the registered fault code is obtained, and then when the preset fault detection timer is started, the vehicle fault code variable is traversed for each registered fault code, and the matching target fault code is obtained in the vehicle fault code variable, and the fault detection callback function of the target fault code is called to determine whether there is a fault, and the fault state of the registered fault code corresponding to the target fault code is generated, and finally the fault state is saved in the vehicle fault code variable, so that the fault of each domain controller of the vehicle can be diagnosed in the vehicle gateway, and the fault information of all faults can be recorded through the vehicle fault code variable, which is convenient for the user system to manage the vehicle fault. At the same time, the fault state of each fault code detected is also recorded in the vehicle fault code variable, and the user can easily and quickly check the historical faults and new faults, which provides support for subsequent fault processing.
[0300] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0301] Fig.14 Schematic diagram of an electronic device provided in an embodiment of the present application. Fig.14 As shown, the electronic device 14 of this embodiment includes: a processor 1401, a memory 1402, and a computer program 1403 stored in the memory 1402 and executable on the processor 1401. When the processor 1401 executes the computer program 1403, the steps in the above-mentioned method embodiments are implemented. Alternatively, when the processor 1401 executes the computer program 1403, the functions of the modules / units in the above-mentioned device embodiments are implemented.
[0302] The electronic device 14 may be a desktop computer, a notebook, a PDA, a cloud server, or other electronic device. The electronic device 14 may include, but is not limited to, a processor 1401 and a memory 1402. Those skilled in the art will appreciate that Fig.14 The electronic device 14 is merely an example and does not limit the electronic device 14 , and may include more or less components than those shown in the figure, or different components.
[0303] The processor 1401 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
[0304] The memory 1402 may be an internal storage unit of the electronic device 14, for example, a hard disk or memory of the electronic device 14. The memory 1402 may also be an external storage device of the electronic device 14, for example, a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card (FlashCard), etc. equipped on the electronic device 14. The memory 1402 may also include both an internal storage unit of the electronic device 14 and an external storage device. The memory 1402 is used to store computer programs and other programs and data required by the electronic device.
[0305] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units.
[0306] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. A vehicle fault detection method, characterized in that: The method is performed by a vehicle gateway, and the method includes: When the vehicle gateway is powered on, the vehicle fault code variable and the fault global variable are initialized. The vehicle fault code variable at least includes the fault code of all vehicle faults, the fault status and the fault detection callback function corresponding to each fault code. The fault global variable includes the fault detection information of at least some fault codes in the vehicle fault code variable. receiving a fault diagnosis response message, registering the vehicle fault code variable according to the fault information carried in the fault diagnosis response message, and obtaining a registered fault code; In response to receiving a message for starting a fault detection timer, starting a preset fault detection timer, and traversing the vehicle fault code variable for each registered fault code to obtain a matching target fault code; Calling the fault detection callback function of the target fault code to determine whether a fault exists, and generating a fault state corresponding to the target fault code; Saving the fault status of the target fault code in the vehicle fault code variable; Among them, according to the fault generation conditions and fault clearance conditions of the fault code value matching the target fault code in the fault global variable, the fault state of the target fault code is judged, and the fault state of the target fault code includes: no fault exists and it is not recovered after a fault, no fault exists and it is recovered after a fault, and there is a fault.
2. The method according to claim 1, characterized in that After the vehicle gateway is powered on, the method further includes: Receiving a configuration word sent by a diagnostic device, and converting the configuration word into a configuration variable, wherein the configuration variable is used to identify whether each fault needs to be detected; The calling of the fault detection callback function of the target fault code to determine whether there is a fault includes: Determining whether a target fault corresponding to the target fault code is identified in the configuration variable as requiring detection; In response to determining that a target fault corresponding to the target fault code is identified in the configuration variable as requiring detection, a fault detection callback function of the target fault code is called to determine whether a fault exists.
3. The method according to claim 1 or 2, characterized in that: The initialization of the fault global variable includes: Get the fault configuration table; Using the fault configuration table to initialize fault code values in the fault global variable, generate fault conditions, and release fault conditions; The fault state in the fault global variable is initialized to no fault, and the fault generation count and fault release count in the fault global variable are initialized to 0.
4. The method according to claim 3, characterized in that The calling of the fault detection callback function of the target fault code to determine whether there is a fault, and generating a fault state of the registered fault code corresponding to the target fault code, includes: Calling the fault detection callback function of the target fault code to determine whether the target fault code satisfies the target fault generation condition or the target fault elimination condition; Determine the fault state corresponding to the target fault code according to the judgment result; The target fault generation condition is a fault generation condition corresponding to a target fault code value in a fault global variable, and the target fault elimination condition is a fault elimination condition corresponding to a target fault code value in a fault global variable.
5. The method according to claim 4, characterized in that Calling the fault detection callback function to determine whether the target fault code meets the target fault generation condition, and determining the fault state corresponding to the target fault code according to the determination result, including: In response to determining that the target fault code satisfies a target fault generation condition, setting a fault release count of the target fault code value in the fault global variable to 0, and performing an increment operation on a fault generation count of the target fault code value in the fault global variable; In response to determining that the fault count after the addition operation is performed is greater than or equal to a first preset threshold, setting the fault state corresponding to the target fault code to a fault exists in the vehicle fault code variable; In response to determining that the fault count after the plus 1 operation is performed is less than a first preset threshold, in the vehicle fault code variable, the fault state corresponding to the target fault code is set to no fault.
6. The method according to claim 4, characterized in that Calling the fault detection callback function to determine whether the target fault code meets the target fault removal condition, and determining the fault state corresponding to the target fault code according to the determination result, including: In response to determining that the target fault code satisfies a target fault release condition, adding 1 to a fault release count of the target fault code value in the fault global variable, and setting a fault generation count of the target fault code value in the fault global variable to 0; In response to determining that the fault release count after the addition operation is performed is greater than or equal to a second preset threshold, setting the fault state corresponding to the target fault code in the vehicle fault code variable to post-fault recovery; In response to determining that the fault release count after the plus 1 operation is performed is less than a second preset threshold, in the vehicle fault code variable, the fault state corresponding to the target fault code is set to a fault exists.
7. The method according to claim 4, characterized in that Calling a fault detection callback function to determine whether the target fault code satisfies a fault generating condition or a fault clearing condition, and determining a fault state corresponding to the target fault code according to the determination result, including: In response to determining that the target fault code satisfies neither a fault generation condition nor a fault release condition, setting a fault generation count of the target fault code value in the fault global variable to 0, and setting a fault release count of the target fault code value in the fault global variable to 0; In the vehicle fault code variable, the fault state corresponding to the target fault code is set to no fault.
8. The method according to claim 2, characterized in that: When the vehicle gateway is powered on, the method further includes: Get the fault configuration table; Initialize the node timeout global variable using the fault configuration table; The timeout count of the node timeout global variable is initialized to 0, and the timeout state of the node timeout global variable is initialized to a node non-lost state.
9. The method according to claim 8, characterized in that The method further comprises: In response to receiving a message for starting a node loss timer, a preset node loss timer is started, all nodes in the node timeout global variable are traversed, and a timeout status of each node is determined.
10. The method according to claim 9, characterized in that Determining the timeout status of each node includes: In response to determining that in the configuration variable, the node loss fault bit corresponding to the target node is set to need to be detected, and there is no current fault diagnosis response message of the target node in the node timeout global variable, performing an increment operation on the timeout count of the target node in the node timeout global variable, the target node being any node among all the nodes in the node timeout global variable; In response to determining that the timeout count of the target node after the plus 1 operation is performed is greater than or equal to a third preset threshold, determining that a node loss failure occurs at the target node; The timeout state of the target node is set to a node loss state, and the timeout count of the target node is set to 0.
11. The method according to claim 10, characterized in that: After determining that the configuration word corresponding to the target node is 1, the method further includes: In response to determining that the node timeout global variable includes the current fault diagnosis response message of the target node, the timeout state of the target node is set to a node non-lost state, and the timeout count of the target node is set to 0.
12. The method according to claim 1, characterized in that The vehicle fault code variable at least includes a fault code, a fault state, a fault count and a fault detection callback function; The fault code and the fault detection callback function are configured in the initialization phase, and the fault code can be registered in the phase of registering the vehicle fault code variable according to the fault information carried in the fault diagnosis response message to obtain a registered fault code, and the fault state and fault count are configured and updated in the phase of registering the vehicle fault code variable according to the fault information carried in the fault diagnosis response message; The configuration of updating the fault status and fault count in the phase of registering the vehicle fault code variable with the fault information carried in the fault diagnosis response message includes: Parsing the fault information carried in the fault diagnosis response message to obtain the fault status and fault count of the fault code corresponding to the message; or Parsing the fault information carried in the fault diagnosis response message, and inputting the parsed information into the fault detection callback function of the fault code corresponding to the message; The fault state and fault count are determined according to the return value of the fault detection callback function of the fault code corresponding to the message.
13. The method according to claim 1, characterized in that The step of storing the fault status of the target fault code in the vehicle fault code variable includes: In response to determining that the target fault code does not have a fault and is not recovered after a fault, setting the fault state of the target fault code in the vehicle fault code variable to a first state; In response to determining that the target fault code does not have a fault and is recovered after a fault, setting the fault state of the target fault code in the vehicle fault code variable to a second state; In response to determining that the target fault code has a fault, setting the fault state of the target fault code in the vehicle fault code variable to a third state; Among them, the target fault code is any fault code in the vehicle fault code variable.
14. The method according to claim 2, characterized in that The method further comprises: In response to determining that an electronic control unit in the vehicle has been changed, or determining that a fault diagnosis scenario has been changed, receiving an updated configuration word sent by a diagnostic device, and converting the updated configuration word into an updated configuration variable; In response to determining that a target fault corresponding to a target fault code is identified in the updated configuration variable as requiring detection, a fault detection callback function of the target fault code is called to determine whether a fault exists.
15. The method according to claim 3, characterized in that The method further comprises: In response to determining that an electronic control unit in the vehicle has been changed, or determining that a fault diagnosis scenario has been changed, receiving an updated configuration word sent by a diagnostic device, and converting the updated configuration word into an updated configuration variable; Acquire an updated fault configuration table, wherein the updated fault configuration table at least includes an updated fault code value, an updated fault generating condition, and an updated fault clearing condition; In response to determining that the target fault corresponding to the target fault code is identified in the updated configuration variable as requiring detection, the fault detection callback function of the target fault code is called, and the updated fault code value, the updated fault generation condition and the updated fault clearance condition are used to determine whether a fault exists.
16. The method according to claim 1, characterized in that After the fault state of the target fault code is saved in the vehicle fault code variable, the method further includes: In response to receiving a fault query instruction, querying fault information from the vehicle fault code variable; In response to receiving a fault clearing instruction, the fault information in the vehicle fault code variable is cleared.
17. The method according to claim 1, characterized in that The vehicle gateway communicates with the electronic control unit in the vehicle using a local interconnect network LIN communication protocol; The fault diagnosis response message is a LIN message, which is sent by the electronic control unit to the vehicle gateway.
18. A vehicle fault detection device, characterized in that: include: An initialization module is configured to initialize a vehicle fault code variable and a fault global variable when the vehicle gateway is powered on, wherein the vehicle fault code variable at least includes the fault code of all vehicle faults, the fault state and the fault detection callback function corresponding to each fault code, and the fault global variable includes the fault detection information of at least some fault codes in the vehicle fault code variable; A registration module is configured to receive a fault diagnosis response message, register the vehicle fault code variable according to the fault information carried in the fault diagnosis response message, and obtain a registered fault code; A detection module is configured to start a preset fault detection timer in response to receiving a message for starting a fault detection timer, and traverse the vehicle fault code variable for each registered fault code to obtain a matching target fault code; A judgment module is configured to call a fault detection callback function of the target fault code to determine whether a fault exists, and generate a fault state corresponding to the target fault code; A saving module is configured to save the fault state of the target fault code in the vehicle fault code variable; Among them, according to the fault generation conditions and fault clearance conditions of the fault code value matching the target fault code in the fault global variable, the fault state of the target fault code is judged, and the fault state of the target fault code includes: no fault exists and it is not recovered after a fault, no fault exists and it is recovered after a fault, and there is a fault.
Citation Information
Patent Citations
Key adhesion fault detection device and method
CN113777481A
Operation machine fault diagnosis method and device and operation machine
CN114690743A
