Diagnostic logging method, apparatus, device, and computer-readable storage medium
By capturing and parsing raw data frames for vehicle diagnostic equipment diagnostic log recording, and combining hardware timestamps and protocol stack log recording points, diagnostic logs are generated and encrypted for storage. This solves the data integrity problem in existing technologies and achieves efficient and secure diagnostic log recording.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- NANCHANG XINGWEI SOFTWARE DEVELOPMENT CO LTD
- Filing Date
- 2026-04-13
- Publication Date
- 2026-07-31
AI Technical Summary
When existing diagnostic equipment records large amounts of vehicle bus communication data, the use of serial ports for diagnostic log recording severely affects the timing of communication information, leading to data integrity issues.
The system captures raw diagnostic data frames in the vehicle diagnostic equipment, assigns them hardware timestamps, performs protocol parsing, records diagnostic information based on log recording points in the communication protocol stack, generates and stores diagnostic logs, and encrypts the diagnostic logs.
It improves the data integrity of diagnostic logs, avoids protocol timeout judgments, event causal confusion and buffer overflows, and ensures the reliability and security of diagnostic data.
Smart Images

Figure CN122493554A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of vehicle maintenance technology, and in particular to a diagnostic log recording method, apparatus, device, and computer-readable storage medium. Background Technology
[0002] Current diagnostic equipment typically adopts a host computer and slave computer architecture. The host computer is responsible for implementing diagnostic functions and displaying the user interface, while the slave computer serves as the hardware communication connection, responsible for protocol conversion and data transmission.
[0003] The current method of recording diagnostic logs for diagnostic equipment uses serial ports to select diagnostic data content and operations. This is barely sufficient for logging the communication process when the amount of data is small. However, when the amount of vehicle bus communication data is large, the physical communication method limits the recording of diagnostic logs, which severely affects the timing of communication information and the integrity of the data in the logs. Summary of the Invention
[0004] In view of this, the purpose of this application is to overcome the shortcomings of the prior art and provide a diagnostic log recording method, the method being applied to a vehicle diagnostic device, the method comprising: When communicating with the vehicle being tested, capture raw diagnostic data frames, assign hardware timestamps to the raw diagnostic data frames, and bind the hardware timestamps to the raw diagnostic data frames. The original diagnostic data frame is parsed to obtain key information about the protocol parsing process and diagnostic information. Based on the preset log recording points in the communication protocol stack of the vehicle diagnostic equipment, the original diagnostic data frame, the hardware timestamp, the key information of the protocol parsing process, and the diagnostic information are recorded; A diagnostic log is generated and stored based on the hardware timestamp, the original diagnostic data frame, the key information of the protocol parsing process, and the diagnostic information.
[0005] In one embodiment, prior to the step of allocating a hardware timestamp to the original diagnostic data frame, the following steps are included: Record the local timestamp when the original diagnostic data frame was captured; The local timestamp is synchronized and verified with the international standard time to obtain the hardware timestamp.
[0006] In one embodiment, the step of performing protocol parsing on the original diagnostic data frame to obtain key information about the protocol parsing process and diagnostic information includes: The original diagnostic data frame is analyzed to obtain protocol analysis data, which includes data baud rate, data voltage, frame ID range, protocol behavior fingerprint, first byte mask and protocol handshake sequence; Based on the protocol analysis data, the protocol type corresponding to the original diagnostic data frame is determined; Based on the protocol type, the protocol parsing rules are determined, and the original diagnostic data frame is parsed according to the protocol parsing rules to obtain key information of the protocol parsing process and diagnostic information.
[0007] In one embodiment, the preset log recording points include physical layer log recording points, data link layer log recording points, and application layer log recording points. The step of recording the original diagnostic data frame, the hardware timestamp, key information of the protocol parsing process, and the diagnostic information based on the preset log recording points in the communication protocol stack of the vehicle diagnostic device includes: Based on the physical layer log recording points in the communication protocol stack of the vehicle diagnostic device, the original diagnostic data frame and the hardware timestamp are recorded from the physical layer of the vehicle diagnostic device; Based on the data link layer log recording point in the communication protocol stack of the vehicle diagnostic device, key information of the protocol parsing process is recorded from the data link layer of the vehicle diagnostic device. The key information of the protocol parsing process includes: communication direction, protocol type, communication status, error code and parsed data. Based on the application layer log recording point in the communication protocol stack of the vehicle diagnostic device, the diagnostic information is recorded from the application layer of the vehicle diagnostic device. The diagnostic information includes service identifiers, sub-function codes, and data parameters.
[0008] In one embodiment, after generating the diagnostic log, the method further includes: The diagnostic log data in the diagnostic log is encrypted to obtain an encrypted diagnostic log; The encrypted diagnostic logs are stored based on a preset storage format.
[0009] In one embodiment, the step of encrypting the diagnostic log data in the diagnostic log to obtain an encrypted diagnostic log includes: Based on a preset symmetric encryption key and a random initialization vector, the diagnostic log data in the diagnostic log is symmetrically encrypted to obtain encrypted diagnostic log data. The preset symmetric encryption key is asymmetrically encrypted to obtain the key ciphertext; The hash value of the encrypted diagnostic log data and the key ciphertext is calculated, and the hash value is digitally signed based on the preset signature private key of the vehicle diagnostic device to obtain the encrypted diagnostic log.
[0010] In one embodiment, the method further includes: In response to the log parsing command of the log parsing tool, the encrypted diagnostic log is sent to the log parsing tool, so that the log parsing tool can decrypt and analyze the encrypted diagnostic log based on the preset signature public key and preset asymmetric encryption key of the vehicle diagnostic device to obtain diagnostic log data.
[0011] This application also provides a diagnostic log recording device, the diagnostic log recording device comprising: The binding module is used to capture raw diagnostic data frames when communicating with the vehicle under test, assign hardware timestamps to the raw diagnostic data frames, and bind the hardware timestamps to the raw diagnostic data frames. The parsing module is used to perform protocol parsing on the original diagnostic data frame to obtain key information of the protocol parsing process and diagnostic information; The recording module is used to record the original diagnostic data frame, the hardware timestamp, key information of the protocol parsing process, and the diagnostic information based on the preset log recording points in the communication protocol stack of the vehicle diagnostic equipment. The generation module is used to generate and store diagnostic logs based on the hardware timestamp, the original diagnostic data frame, the key information of the protocol parsing process, and the diagnostic information.
[0012] This application also provides a vehicle diagnostic device, which includes a processor and a memory, the memory storing a computer program, and the processor executing the computer program to implement the diagnostic log recording method described above.
[0013] This application also provides a computer-readable storage medium storing a computer program that, when run on a processor, executes the diagnostic logging method described above.
[0014] The embodiments of this application have the following beneficial effects: This application embodiment is applied to a vehicle diagnostic device. When communicating with the vehicle under test, it captures the original diagnostic data frame and hardware timestamp, and binds the hardware timestamp to the original diagnostic data frame; it performs protocol parsing on the original diagnostic data frame and obtains key information of the protocol parsing process and diagnostic information; based on the preset log recording points in the communication protocol stack of the vehicle diagnostic device, it records the original diagnostic data frame, hardware timestamp, key information of the protocol parsing process, and diagnostic information; based on the hardware timestamp, original diagnostic data frame, key information of the protocol parsing process, and diagnostic information, it generates and stores a diagnostic log. To avoid severely impacting communication timing by selecting diagnostic data content and operations via serial ports, which leads to a three-tiered transmission mechanism of protocol timeout judgment, event causal disorder, and buffer overflow, resulting in semantic invalidation of diagnostic data, physical frame loss, and untraceable root causes, thus undermining data integrity, this approach addresses this issue. By assigning hardware timestamps to the original diagnostic data frames and recording key information from the protocol parsing process and diagnostic information through preset log points in the communication protocol stack, the three-tiered transmission mechanism of protocol timeout judgment, event causal disorder, and buffer overflow in existing technologies is severed, thus improving the data integrity in diagnostic logs. Attached Figure Description
[0015] To more clearly illustrate the technical solutions of this application, the accompanying drawings used in the embodiments will be briefly described below. It should be understood that the following drawings only show some embodiments of this application and therefore should not be considered as a limitation on the scope of protection of this application. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0016] Figure 1 A flowchart illustrating the first embodiment of the diagnostic log recording method provided in this application; Figure 2 The log recording process of the host computer and slave computer of the vehicle diagnostic equipment provided in this application; Figure 3 A flowchart illustrating a second embodiment of the diagnostic log recording method provided in this application; Figure 4 A flowchart illustrating a third embodiment of the diagnostic log recording method provided in this application; Figure 5 A flowchart illustrating the fourth embodiment of the diagnostic log recording method provided in this application; Figure 6 A schematic diagram of the communication log recording system architecture for the vehicle diagnostic equipment's upper and lower computer provided in this application; Figure 7 A flowchart illustrating the fifth embodiment of the diagnostic log recording method provided in this application; Figure 9 A flowchart illustrating the sixth embodiment of the diagnostic log recording method provided in this application; Figure 8 A schematic diagram illustrating the storage of encrypted diagnostic logs provided in this application in binary file format; Figure 10 A flowchart illustrating the seventh embodiment of the diagnostic log recording method provided in this application; Figure 11 A schematic diagram of the diagnostic log recording device provided in this application. Detailed Implementation
[0017] The technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments.
[0018] The components of the embodiments of this application described and illustrated in the accompanying drawings can be arranged and designed in a variety of different configurations. Therefore, the following detailed description of the embodiments of this application provided in the drawings is not intended to limit the scope of the claimed application, but merely to illustrate selected embodiments of the application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application.
[0019] In the following, the terms “comprising,” “having,” and their cognates, which may be used in various embodiments of this application, are intended only to indicate a particular feature, number, step, operation, element, component, or combination thereof, and should not be construed as excluding, firstly, the presence of one or more other features, numbers, steps, operations, elements, components, or combinations thereof, or adding the possibility of one or more features, numbers, steps, operations, elements, components, or combinations thereof.
[0020] Furthermore, the terms "first," "second," and "third" are used only to distinguish descriptions and should not be interpreted as indicating or implying relative importance.
[0021] Unless otherwise specified, all terms used herein (including technical and scientific terms) shall have the same meaning as commonly understood by one of ordinary skill in the art to which the various embodiments of this application pertain. Terms (such as those defined in commonly used dictionaries) shall be interpreted as having the same meaning as in their contextual meaning in the relevant technical field and shall not be construed as having an idealized or overly formal meaning, unless clearly defined in the various embodiments of this application.
[0022] It is understood that the method of this application is applied to vehicle diagnostic equipment, which can be a smart terminal, PC terminal, mobile terminal, etc., and is not limited thereto. For ease of description, the following embodiments use vehicle diagnostic equipment as the execution subject for illustration.
[0023] The following detailed description of some embodiments of this application is provided in conjunction with the accompanying drawings. Unless otherwise specified, the following embodiments and features can be combined with each other.
[0024] Please refer to Figure 1 , Figure 1 This is a flowchart illustrating a first embodiment of the diagnostic log recording method provided in this application. The method is applied to a vehicle diagnostic device and includes: Step S101: When communicating with the vehicle under test, capture the original diagnostic data frame, assign a hardware timestamp to the original diagnostic data frame, and bind the hardware timestamp to the original diagnostic data frame.
[0025] In this embodiment, when the vehicle diagnostic device communicates with the vehicle under test to perform vehicle diagnostics, it captures the original diagnostic data frames sent by the vehicle's ECU; the vehicle diagnostic device assigns a hardware timestamp to the original diagnostic data frames and binds the hardware timestamp to the original diagnostic data frames.
[0026] It should be noted that the vehicle diagnostic equipment adds a precise timestamp to each data frame. The timestamp uses hardware timestamps with microsecond-level accuracy to ensure that data from different buses and different ECUs have a unified time base, avoiding timing disorder of the original diagnostic data frames.
[0027] Step S102: Perform protocol parsing on the original diagnostic data frame to obtain key information of the protocol parsing process and diagnostic information.
[0028] In this embodiment, the vehicle diagnostic equipment performs protocol parsing on the received raw diagnostic data frames to obtain key information about the protocol parsing process and diagnostic information. It should be noted that the protocol types include: CAN, LIN, FlexRay, UDS, ISO 15765, SAE J1939, etc.; the key information about the protocol parsing process includes: communication direction, protocol type, communication status, error codes, and parsed data; the diagnostic information includes: service identifiers, sub-function codes, and data parameters.
[0029] Vehicle diagnostic equipment can recognize raw diagnostic data frames of various protocol types, adapting to the needs of different vehicle models and manufacturers. Through an automatic protocol identification mechanism, new protocol types can be supported without modifying the software.
[0030] It should be noted that, as Figure 2 As shown, Figure 2 The log recording process for the host computer and slave computer of the vehicle diagnostic equipment is as follows: The vehicle diagnostic equipment includes a host computer and a slave computer. The host computer first sends a diagnostic command to the slave computer. The slave computer performs protocol parsing on the received raw diagnostic data frame based on the diagnostic command to obtain key information of the protocol parsing process and diagnostic information. Then, the key information of the protocol parsing process and diagnostic information are stored in the slave computer.
[0031] Step S103: Based on the preset log recording points in the communication protocol stack of the vehicle diagnostic device, record the original diagnostic data frame, the hardware timestamp, the key information of the protocol parsing process, and the diagnostic information.
[0032] In this embodiment, the vehicle diagnostic device records original diagnostic data frames, hardware timestamps, key information from the protocol parsing process, and diagnostic information based on pre-set log points in the communication protocol stack. It should be noted that during the development phase of the vehicle diagnostic device, relevant developers pre-set log points in the communication protocol stack. These log points are set for the physical layer, data link layer, and application layer of the lower-level machine in the vehicle diagnostic device, and can obtain and record original diagnostic data frames, hardware timestamps, key information from the protocol parsing process, and diagnostic information from these layers.
[0033] It should be noted that existing vehicle diagnostic equipment uses serial ports to select and record diagnostic data content and operations, which severely affects the timing of communication information. This leads to a three-level transmission mechanism of protocol timeout judgment, event causal disorder, and buffer overflow, resulting in semantic invalidation of diagnostic data, physical frame loss, and untraceable root causes, thus undermining data integrity. This application records the original diagnostic data frames, hardware timestamps, key information of the protocol parsing process, and diagnostic information through preset log recording points in the communication protocol stack. This breaks the three-level transmission mechanism of protocol timeout judgment, event causal disorder, and buffer overflow in the existing technology, which helps to improve the integrity of the acquired and recorded data.
[0034] Step S104: Generate and store a diagnostic log based on the hardware timestamp, the original diagnostic data frame, the key information of the protocol parsing process, and the diagnostic information.
[0035] In this embodiment, the vehicle diagnostic equipment generates and stores diagnostic logs based on hardware timestamps, original diagnostic data frames, key information from the protocol parsing process, and diagnostic information.
[0036] In one embodiment, the vehicle diagnostic equipment constructs a structured diagnostic log from the device timestamp, raw diagnostic data frame, key information from the protocol parsing process, and diagnostic information. The diagnostic log includes: hardware timestamp: in ISO8601 UTC format, accurate to the microsecond level; communication direction: distinguishing between uplink (host computer to slave computer) and downlink (slave computer to host computer); protocol type: identifying the diagnostic protocol used, such as UDS, ISO 15765, etc.; service identifier (SID): a unique identifier for the diagnostic service; subfunction: the subfunction code of the diagnostic service; data length: the number of bytes in the data field; raw data: the raw data frame in hexadecimal format; parsed data: the structured data after protocol parsing; communication status: a status indicator indicating whether communication was successful or failed; error code: if communication failed, the specific error code is recorded.
[0037] In this embodiment, the vehicle diagnostic device captures the original diagnostic data frame and hardware timestamp when communicating with the vehicle under test, and binds the hardware timestamp to the original diagnostic data frame; it performs protocol parsing on the original diagnostic data frame and obtains key information of the protocol parsing process and diagnostic information; based on the preset log recording points in the communication protocol stack of the vehicle diagnostic device, it records the original diagnostic data frame, hardware timestamp, key information of the protocol parsing process, and diagnostic information; and based on the hardware timestamp, original diagnostic data frame, key information of the protocol parsing process, and diagnostic information, it generates and stores a diagnostic log. To avoid severely impacting communication timing by selecting diagnostic data content and operations via serial ports, which leads to a three-tiered transmission mechanism of protocol timeout judgment, event causal disorder, and buffer overflow, resulting in semantic invalidation of diagnostic data, physical frame loss, and untraceable root causes, thus undermining data integrity, this approach addresses this issue. By assigning hardware timestamps to the original diagnostic data frames and recording key information from the protocol parsing process and diagnostic information through preset log points in the communication protocol stack, the three-tiered transmission mechanism of protocol timeout judgment, event causal disorder, and buffer overflow in existing technologies is severed, thus improving the data integrity in diagnostic logs.
[0038] Please refer to Figure 3 , Figure 3 This is a flowchart illustrating a second embodiment of the diagnostic log recording method provided in this application. The difference between the second embodiment and the first embodiment is that, prior to the step of allocating a hardware timestamp to the original diagnostic data frame, the method includes: Step S201: Record the local timestamp when the original diagnostic data frame was captured.
[0039] Step S202: Synchronize and verify the local timestamp with the international standard time to obtain the hardware timestamp.
[0040] In this embodiment, the vehicle diagnostic device records the local timestamp when the original diagnostic data frame is captured, and performs synchronization verification between the local timestamp and the international standard time to synchronize the local timestamp with the international standard time, thereby obtaining the hardware timestamp.
[0041] In one embodiment, the local timestamp is the built-in low-power timer LPTIM in the MCU of the vehicle diagnostic equipment or the timestamp recorded on the FPGA chip, with a counting frequency of not less than 1 MHz. The RTC module is a dedicated low-power clock circuit integrated inside the MCU or externally. UTC (Coordinated Universal Time) is the international standard time. It is not hardware itself, but a time signal that can be carried by different physical carriers. The RTC module is synchronized with the UTC time source to ensure that the local timestamp is synchronized with the international standard time.
[0042] In this embodiment, the vehicle diagnostic equipment records the local timestamp when the original diagnostic data frame is captured, and synchronizes and verifies the local timestamp with the international standard time to obtain the hardware timestamp. This improves the accuracy of the hardware timestamp and helps to improve the accuracy of allocating hardware timestamps to the original diagnostic data frame. It can avoid timing distortion and thus help improve the data integrity in the recorded diagnostic log.
[0043] Please refer to Figure 4 , Figure 4 This is a flowchart illustrating a third embodiment of the diagnostic log recording method provided in this application. The difference between the third embodiment and the first to second embodiments lies in the step of performing protocol parsing on the original diagnostic data frame to obtain key information of the protocol parsing process and diagnostic information, which includes: Step S301: Analyze the original diagnostic data frame to obtain protocol analysis data, which includes data baud rate, data voltage, frame ID range, protocol behavior fingerprint, first byte mask, and protocol handshake sequence.
[0044] In this embodiment, the vehicle diagnostic equipment analyzes the original diagnostic data frame to obtain protocol analysis data, which includes data baud rate, data voltage, frame ID range, protocol behavior fingerprint, first byte mask, and protocol handshake sequence.
[0045] Step S302: Based on the protocol analysis data, determine the protocol type corresponding to the original diagnostic data frame.
[0046] In this embodiment, the vehicle diagnostic equipment determines the protocol type corresponding to the original diagnostic data frame based on protocol analysis data.
[0047] In one embodiment, the vehicle diagnostic equipment determines the protocol type corresponding to the original diagnostic data frame based on the data baud rate and data voltage in the protocol analysis data. CAN protocol: Its core characteristics are baud rate (commonly 250kbps, 500kbps, 1Mbps), differential voltage transmission (the voltage difference between CAN_H and CAN_L is 2.5V±1V, no single-ended voltage), and single-channel transmission. For example, if the data baud rate in the protocol analysis data obtained by the vehicle diagnostic equipment is 500kbps, and the captured data voltage includes a differential voltage of 2.8V, the protocol type corresponding to the original diagnostic data frame can be determined to be the CAN protocol. LIN protocol: Its core characteristics are baud rate (fixed 9600bps or 19200bps), single-ended voltage transmission (bus voltage is 12V / 0V binary), and a single-master, multi-slave single-channel structure. For example, if the data baud rate in the protocol analysis data obtained by the vehicle diagnostic equipment is 9600bps, and the captured data voltage only includes a single-ended 12V voltage, the protocol type corresponding to the original diagnostic data frame can be determined to be the LIN protocol.
[0048] In one embodiment, the vehicle diagnostic equipment determines the protocol type corresponding to the original diagnostic data frame based on the frame ID range, protocol behavior fingerprint, first-byte mask, and protocol handshake sequence in the protocol analysis data. It should be noted that the frame ID range, the mandatory and exclusive "address space planning" agreed upon by different vehicle protocols on the CAN bus, is the fastest and most reliable initial screening criterion. The protocol behavior fingerprint is the DLC (Data Length Code Distribution) feature; different protocols exhibit statistically significant differences in their use of data length (DLC), stemming from their frame encapsulation rules and typical service requirements. The first-byte mask reflects the fundamental differences in the encoding rules and value range of the first byte (i.e., SID / Service Identifier) of the data field among different protocols, and this byte's position in the frame is fixed. The protocol handshake sequence, required by some protocols for a strict initialization handshake process, presents a fixed ID + DLC + first-byte sequence in the original frame stream, serving as the key evidence for ultimately confirming the protocol type. The vehicle diagnostic equipment is equipped with parameters such as the frame ID range, protocol behavior fingerprint, first byte mask, and protocol handshake sequence for each protocol. When the vehicle diagnostic equipment obtains the frame ID range, protocol behavior fingerprint, first byte mask, and protocol handshake sequence of the original diagnostic data frame, it can determine the protocol type corresponding to the original diagnostic data frame by comparison.
[0049] Step S303: Determine the protocol parsing rules based on the protocol type, and perform protocol parsing on the original diagnostic data frame based on the protocol parsing rules to obtain key information of the protocol parsing process and diagnostic information.
[0050] In this embodiment, after determining the protocol type corresponding to the original diagnostic data frame, the vehicle diagnostic device determines the protocol parsing rules based on the protocol type, and performs protocol parsing on the original diagnostic data frame based on the protocol parsing rules to obtain key information of the protocol parsing process and diagnostic information.
[0051] The vehicle diagnostic equipment in this embodiment analyzes the original diagnostic data frames to obtain protocol analysis data. Based on the protocol analysis data, it determines the protocol type corresponding to the original diagnostic data frames, determines the protocol parsing rules based on the protocol type, and parses the original diagnostic data frames according to the protocol parsing rules to obtain key information about the protocol parsing process and diagnostic information. It can support and be compatible with multiple diagnostic protocols, adapting to the needs of different vehicle models and manufacturers. Through the aforementioned automatic protocol identification mechanism, new protocol types can be supported without modifying the software, improving the vehicle diagnostic equipment's compatibility with diagnostic protocols.
[0052] Please refer to Figure 5 , Figure 5 This is a flowchart illustrating a fourth embodiment of the diagnostic log recording method provided in this application. The difference between this fourth embodiment and the first to third embodiments is that the preset log recording points include physical layer log recording points, data link layer log recording points, and application layer log recording points. The step of recording the original diagnostic data frame, the hardware timestamp, key information of the protocol parsing process, and the diagnostic information based on the preset log recording points in the communication protocol stack of the vehicle diagnostic device includes: Step S401: Based on the physical layer log recording point in the communication protocol stack of the vehicle diagnostic device, record the original diagnostic data frame and the hardware timestamp from the physical layer of the vehicle diagnostic device.
[0053] Step S402: Based on the data link layer log recording point in the communication protocol stack of the vehicle diagnostic device, record the key information of the protocol parsing process from the data link layer of the vehicle diagnostic device. The key information of the protocol parsing process includes: communication direction, protocol type, communication status, error code and parsed data.
[0054] Step S403: Based on the application layer log recording point in the communication protocol stack of the vehicle diagnostic device, record the diagnostic information from the application layer of the vehicle diagnostic device. The diagnostic information includes service identifier, sub-function code and data parameters.
[0055] In this embodiment, the preset log recording points include physical layer log recording points, data link layer log recording points, and application layer log recording points. Please refer to... Figure 6 , Figure 6 This is a schematic diagram of the communication log recording system architecture for vehicle diagnostic equipment between the upper and lower computer. The vehicle ECU interacts with the lower computer, and the lower computer interacts with the upper computer. The lower computer includes a physical layer, a data link layer, and an application layer. The application layer is used for log collection, protocol parsing, encryption processing, and storage management.
[0056] In this embodiment, the vehicle diagnostic device records the original diagnostic data frames and hardware timestamps from the physical layer of the lower-level machine based on the physical layer log recording points in the communication protocol stack; based on the data link layer log recording points, it records key information of the protocol parsing process from the data link layer of the lower-level machine, including: communication direction, protocol type, communication status, error code, and parsed data; based on the application layer log recording points, it records diagnostic information from the application layer of the lower-level machine, including service identifiers, sub-function codes, and data parameters.
[0057] The vehicle diagnostic equipment in this embodiment achieves comprehensive recording of the communication process through log recording points set at key nodes in the communication between the upper and lower computers. This includes complete information from the physical layer, data link layer, and application layer, providing sufficient data support for fault location and improving the data integrity in the recorded diagnostic logs.
[0058] Please refer to Figure 7 , Figure 7 This is a flowchart illustrating a fifth embodiment of the diagnostic log recording method provided in this application. The difference between the fifth embodiment and the first to fourth embodiments is that, after generating the diagnostic log, the method further includes: Step S501: Encrypt the diagnostic log data in the diagnostic log to obtain an encrypted diagnostic log.
[0059] In this embodiment, after obtaining the diagnostic log, the vehicle diagnostic device encrypts the diagnostic log data to avoid the problem of plaintext recording being easily cracked, thus obtaining an encrypted diagnostic log. It should be noted that the vehicle diagnostic device first performs symmetric encryption on the diagnostic log data, and then performs asymmetric encryption on the symmetric encryption key to obtain the encrypted diagnostic log.
[0060] Step S502: Store the encrypted diagnostic log based on a preset storage format.
[0061] In this embodiment, the vehicle diagnostic device stores encrypted diagnostic logs based on a preset storage format. In one embodiment, the preset storage format is a binary file format, which includes a file header, log entries, and an index table. The file header (512 bytes) contains information such as the magic number, version number, encryption algorithm identifier, device ID, timestamp, and number of log entries. Each log entry (variable length) contains complete structured log data. The index table, located at the end of the file, contains the offset address, timestamp, and service identifier for each log entry, facilitating quick querying and location.
[0062] For example, such as Figure 8 As shown, Figure 8 This diagram illustrates the storage of encrypted diagnostic logs in binary file format. The header (512 bytes) contains information such as the magic number (4 bytes), version number (2 bytes), encryption algorithm identifier (2 bytes), device ID (16 bytes), timestamp (8 bytes), and number of log entries (4 bytes). Each log entry contains complete structured log data, including timestamp (8 bytes), communication direction (1 byte), protocol type (1 byte), service identifier (SID) (1 byte), sub-function (1 byte), data length (2 bytes), raw data (N bytes), parsed data (N bytes), and error code (1 byte). The index table includes: N×16 bytes, offset address, and timestamp.
[0063] In one embodiment, after the step of obtaining the encrypted diagnostic log, the method further includes: Step S5021: The encrypted diagnostic log is transmitted to a preset storage device, and the data integrity of the encrypted diagnostic log is verified during the transmission process.
[0064] In this embodiment, the vehicle diagnostic equipment transmits encrypted diagnostic logs to a preset storage device, and verifies the data integrity of the encrypted diagnostic logs during transmission. In one embodiment, the vehicle diagnostic equipment stores the encrypted diagnostic logs in binary file format and transmits them to an external storage device or a host computer via a USB interface. The USB transmission uses a batch transmission method, supports high-speed transmission (480Mbps), and ensures the reliability and efficiency of data transmission. CRC check is performed during transmission to ensure data integrity.
[0065] The vehicle diagnostic equipment in this embodiment encrypts the diagnostic log data to obtain encrypted diagnostic logs. Even if the log file is stolen, the data cannot be decrypted or tampered with without the corresponding private key, ensuring the security of the log data during storage and transmission. Based on a preset storage format, the encrypted diagnostic logs are stored completely offline, meeting the needs of offline analysis in the absence of a network. This improves the security and efficiency of diagnostic log transmission and analysis.
[0066] Please refer to Figure 9 , Figure 9 This is a flowchart illustrating a sixth embodiment of the diagnostic log recording method provided in this application. The difference between the sixth embodiment and the first to fifth embodiments is that the step of encrypting the diagnostic log data in the diagnostic log to obtain an encrypted diagnostic log includes: Step S601: Based on a preset symmetric encryption key and a random initialization vector, the diagnostic log data in the diagnostic log is symmetrically encrypted to obtain encrypted diagnostic log data.
[0067] In this embodiment, the vehicle diagnostic device performs symmetric encryption on the diagnostic log data in the diagnostic log based on a preset symmetric encryption key and a random initialization vector to obtain encrypted diagnostic log data. In one embodiment, the preset symmetric encryption key is derived from the device identifier of the vehicle diagnostic device. The vehicle diagnostic device uses the preset symmetric encryption key and the AES-256 algorithm to perform symmetric encryption on the diagnostic log data in the diagnostic log. At the same time, it randomly generates an initialization vector and uses the CBC (Cipher Block Chaining) encryption mode to bind the symmetrically encrypted diagnostic log data with the initialization vector to obtain encrypted diagnostic log data.
[0068] Step S602: Perform asymmetric encryption on the preset symmetric encryption key to obtain the key ciphertext.
[0069] In this embodiment, the vehicle diagnostic equipment performs asymmetric encryption on a preset symmetric encryption key to obtain key ciphertext. In one embodiment, the RSA-2048 algorithm is used to encrypt and store the symmetric encryption key to obtain key ciphertext.
[0070] Step S603: Calculate the hash value of the encrypted diagnostic log data and the key ciphertext, and perform a digital signature on the hash value based on the preset signature private key of the vehicle diagnostic device to obtain the encrypted diagnostic log.
[0071] In this embodiment, the vehicle diagnostic device binds the encrypted diagnostic log data and the key ciphertext to obtain a data block, calculates the hash value of the data block, and then performs a digital signature on the hash value based on the vehicle diagnostic device's preset signature private key to obtain the encrypted diagnostic log.
[0072] The vehicle diagnostic device in this embodiment performs symmetric encryption on the diagnostic log data based on a preset symmetric encryption key and a random initialization vector to obtain encrypted diagnostic log data. Then, it performs asymmetric encryption on the preset symmetric encryption key to obtain ciphertext. A hash value is calculated between the encrypted diagnostic log data and the ciphertext, and a digital signature is performed on the hash value based on the vehicle diagnostic device's preset signature private key to obtain the encrypted diagnostic log. This hybrid encryption architecture of symmetric and asymmetric decryption, combined with a digital signature mechanism, ensures the security of the diagnostic log during storage and transmission.
[0073] Please refer to Figure 10 , Figure 10 A flowchart illustrating a seventh embodiment of the diagnostic log recording method provided in this application. The difference between the seventh embodiment and the first to sixth embodiments is that the method further includes: Step S701: In response to the log parsing instruction of the log parsing tool, the encrypted diagnostic log is sent to the log parsing tool so that the log parsing tool can decrypt and analyze the encrypted diagnostic log based on the preset signature public key and preset asymmetric encryption key of the vehicle diagnostic device to obtain diagnostic log data.
[0074] In this embodiment, the vehicle diagnostic device responds to the log parsing command of the log parsing tool by sending encrypted diagnostic logs to the log parsing tool. The log parsing tool then decrypts and analyzes the encrypted diagnostic logs based on the vehicle diagnostic device's preset signature public key and preset asymmetric encryption key to obtain diagnostic log data. Specifically, when the log parsing tool programs the device's serial number (SN), it records the chip ID. After obtaining the chip ID, it retrieves the original data from the database and uses an XOR algorithm to obtain the vehicle diagnostic device's public key. Based on the vehicle diagnostic device's preset signature public key, the log parsing tool verifies the digital signature containing the vehicle diagnostic device's preset signature private key. The core function is to confirm that the encrypted diagnostic logs were sent by a legitimate vehicle diagnostic device and have not been tampered with during transmission. The log parsing tool uses its own RSA-2048 private key (PriKey_parsing tool) to perform asymmetric decryption on the received encrypted diagnostic logs to obtain a symmetric encryption key. The log parsing tool then combines the symmetric encryption key with the vehicle diagnostic device's plaintext transmission initialization vector to decrypt the encrypted diagnostic logs and restore the original diagnostic log data. The decryption mode is the same as the encryption mode (CBC mode), and the padding method must match the encryption method (e.g., PKCS7 padding). The encrypted diagnostic logs are then passed to the AES decryption function, along with the symmetric encryption key and the vehicle diagnostic device's plaintext transmission initialization vector, to obtain the decrypted byte stream. This byte stream is then converted into plaintext text to obtain the original diagnostic log data.
[0075] In this embodiment, the vehicle diagnostic equipment, in response to a log parsing command from a log parsing tool, sends encrypted diagnostic logs to the tool. The log parsing tool then decrypts and analyzes the encrypted diagnostic logs based on the vehicle diagnostic equipment's preset signature public key and preset asymmetric encryption key to obtain diagnostic log data. The dedicated parsing tool provides a rich visual interface and intelligent analysis functions, enabling rapid fault location, communication performance analysis, and the generation of detailed diagnostic reports, thus improving the efficiency of diagnostic log analysis. Through standardized log formats and parsing tools, the cost of diagnostic equipment software iteration is reduced. Developers can quickly locate problems by analyzing historical logs, reducing on-site debugging time and costs.
[0076] refer to Figure 11 , Figure 11 This is a schematic diagram of the diagnostic log recording device provided in this application. The diagnostic log recording device includes: The binding module 10 is used to capture raw diagnostic data frames when communicating with the vehicle under test, assign hardware timestamps to the raw diagnostic data frames, and bind the hardware timestamps to the raw diagnostic data frames.
[0077] The parsing module 20 is used to perform protocol parsing on the original diagnostic data frame to obtain key information of the protocol parsing process and diagnostic information.
[0078] The recording module 30 is used to record the original diagnostic data frame, the hardware timestamp, key information of the protocol parsing process, and the diagnostic information based on the preset log recording points in the communication protocol stack of the vehicle diagnostic equipment.
[0079] The generation module 40 is used to generate and store diagnostic logs based on the hardware timestamp, the original diagnostic data frame, the key information of the protocol parsing process, and the diagnostic information.
[0080] It is understood that the diagnostic log recording device of this embodiment corresponds to the diagnostic log recording method of the above embodiment, and the options in the above embodiment are also applicable to this embodiment, so they will not be described again here.
[0081] This application also provides a vehicle diagnostic device, exemplary of which includes a processor and a memory, wherein the memory stores a computer program, and the processor executes the computer program to cause the vehicle diagnostic device to perform the diagnostic log recording method described above.
[0082] The processor can be an integrated circuit chip with signal processing capabilities. The processor can be a general-purpose processor, including at least one of a Central Processing Unit (CPU), Graphics Processing Unit (GPU), Network Processor (NP), Digital Signal Processor (DSP), Application-Specific Integrated Circuit (ASIC), Field-Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. The general-purpose processor can be a microprocessor or any conventional processor, capable of implementing or executing the methods, steps, and logic block diagrams disclosed in the embodiments of this application.
[0083] The memory can be, but is not limited to, Random Access Memory (RAM), Read Only Memory (ROM), Programmable Read-Only Memory (PROM), Erasable Programmable Read-Only Memory (EPROM), Electrically Erasable Programmable Read-Only Memory (EEPROM), etc. The memory is used to store computer programs, and the processor can execute the computer programs accordingly after receiving execution instructions.
[0084] This application also provides a computer storage medium for storing the computer program used in the aforementioned vehicle diagnostic equipment. The computer storage medium can be a readable storage medium, a non-volatile storage medium, or a volatile storage medium. For example, the computer storage medium may include, but is not limited to, various media capable of storing program code, such as a USB flash drive, a portable hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
[0085] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can also be implemented in other ways. The apparatus embodiments described above are merely illustrative. For example, the flowcharts and block diagrams in the accompanying drawings show the architecture, functionality, and operation of possible implementations of apparatus, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that, in alternative implementations, the functions marked in the blocks may occur in a different order than those marked in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagram and / or flowchart, and combinations of blocks in the block diagram and / or flowchart, can be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.
[0086] In addition, the functional modules or units in the various embodiments of this application can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.
[0087] If the aforementioned functions are implemented as software functional modules and sold or used as independent products, they can be stored in a readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a vehicle diagnostic device (which may be a smartphone, personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application.
[0088] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application.
Claims
1. A diagnostic log recording method, characterized in that, The method is applied to vehicle diagnostic equipment, and the method includes: When communicating with the vehicle being tested, capture raw diagnostic data frames, assign hardware timestamps to the raw diagnostic data frames, and bind the hardware timestamps to the raw diagnostic data frames. The original diagnostic data frame is parsed to obtain key information about the protocol parsing process and diagnostic information. Based on the preset log recording points in the communication protocol stack of the vehicle diagnostic equipment, the original diagnostic data frame, the hardware timestamp, the key information of the protocol parsing process, and the diagnostic information are recorded; A diagnostic log is generated and stored based on the hardware timestamp, the original diagnostic data frame, the key information of the protocol parsing process, and the diagnostic information.
2. The diagnostic log recording method according to claim 1, characterized in that, Prior to the step of allocating a hardware timestamp to the original diagnostic data frame, the following steps are included: Record the local timestamp when the original diagnostic data frame was captured; The local timestamp is synchronized and verified with the international standard time to obtain the hardware timestamp.
3. The diagnostic log recording method according to claim 1, characterized in that, The step of parsing the original diagnostic data frame to obtain key information about the protocol parsing process and diagnostic information includes: The original diagnostic data frame is analyzed to obtain protocol analysis data, which includes data baud rate, data voltage, frame ID range, protocol behavior fingerprint, first byte mask and protocol handshake sequence; Based on the protocol analysis data, the protocol type corresponding to the original diagnostic data frame is determined; Based on the protocol type, the protocol parsing rules are determined, and the original diagnostic data frame is parsed according to the protocol parsing rules to obtain key information of the protocol parsing process and diagnostic information.
4. The diagnostic log recording method according to claim 1, characterized in that, The preset log recording points include physical layer log recording points, data link layer log recording points, and application layer log recording points. The step of recording the original diagnostic data frame, the hardware timestamp, key information of the protocol parsing process, and the diagnostic information based on the preset log recording points in the communication protocol stack of the vehicle diagnostic device includes: Based on the physical layer log recording points in the communication protocol stack of the vehicle diagnostic device, the original diagnostic data frame and the hardware timestamp are recorded from the physical layer of the vehicle diagnostic device; Based on the data link layer log recording point in the communication protocol stack of the vehicle diagnostic device, key information of the protocol parsing process is recorded from the data link layer of the vehicle diagnostic device. The key information of the protocol parsing process includes: communication direction, protocol type, communication status, error code and parsed data. Based on the application layer log recording point in the communication protocol stack of the vehicle diagnostic device, the diagnostic information is recorded from the application layer of the vehicle diagnostic device. The diagnostic information includes service identifiers, sub-function codes, and data parameters.
5. The diagnostic log recording method according to claim 1, characterized in that, After generating the diagnostic log, the method further includes: The diagnostic log data in the diagnostic log is encrypted to obtain an encrypted diagnostic log; The encrypted diagnostic logs are stored based on a preset storage format.
6. The diagnostic log recording method according to claim 5, characterized in that, The step of encrypting the diagnostic log data in the diagnostic log to obtain encrypted diagnostic logs includes: Based on a preset symmetric encryption key and a random initialization vector, the diagnostic log data in the diagnostic log is symmetrically encrypted to obtain encrypted diagnostic log data. The preset symmetric encryption key is asymmetrically encrypted to obtain the key ciphertext; The hash value of the encrypted diagnostic log data and the key ciphertext is calculated, and the hash value is digitally signed based on the preset signature private key of the vehicle diagnostic device to obtain the encrypted diagnostic log.
7. The diagnostic log recording method according to claim 6, characterized in that, The method further includes: In response to the log parsing command of the log parsing tool, the encrypted diagnostic log is sent to the log parsing tool, so that the log parsing tool can decrypt and analyze the encrypted diagnostic log based on the preset signature public key and preset asymmetric encryption key of the vehicle diagnostic device to obtain diagnostic log data.
8. A diagnostic log recording device, characterized in that, The diagnostic log recording device includes: The binding module is used to capture raw diagnostic data frames when communicating with the vehicle under test, assign hardware timestamps to the raw diagnostic data frames, and bind the hardware timestamps to the raw diagnostic data frames. The parsing module is used to perform protocol parsing on the original diagnostic data frame to obtain key information of the protocol parsing process and diagnostic information; The recording module is used to record the original diagnostic data frame, the hardware timestamp, key information of the protocol parsing process, and the diagnostic information based on the preset log recording points in the communication protocol stack of the vehicle diagnostic equipment; The generation module is used to generate and store diagnostic logs based on the hardware timestamp, the original diagnostic data frame, the key information of the protocol parsing process, and the diagnostic information.
9. A vehicle diagnostic device, characterized in that, The vehicle diagnostic device includes a processor and a memory, the memory storing a computer program, and the processor executing the computer program to implement the diagnostic log recording method according to any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when run on a processor, executes the diagnostic logging method according to any one of claims 1-7.