A large-scale vehicle-mounted CAN message storage and query system and its control method

By combining memory cache with hard disk storage, the storage and query problems of large-scale vehicle CAN messages are solved, and data integrity and efficient query are achieved.

CN120512381BActive Publication Date: 2025-09-12NANJINYAN HIGH TECH (NANJING) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510983927.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-07-17
Publication Date
2025-09-12
Estimated Expiration
2045-07-17

AI Technical Summary

Technical Problem

Existing technologies are unable to effectively store and query large volumes of on-board CAN messages, especially the large amounts of data generated during vehicle road tests and durability tests, resulting in data loss and inefficient querying.

Method used

A storage method combining memory cache and hard disk is adopted. Messages are initially stored and sorted in the memory cache area. After exceeding the threshold, they are transferred to the hard disk database. Asynchronous processing of the memory database and the hard disk database is used to achieve fast query.

Benefits of technology

It achieves complete storage and fast query of large-volume on-board CAN messages, avoids data loss, and improves query efficiency and storage capacity.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120512381B_ABST
    Figure CN120512381B_ABST
Patent Text Reader

Abstract

The present invention discloses a large-volume vehicle-mounted CAN message storage and query system, comprising a message capture unit for capturing message data, a message receiving and verification unit for receiving messages and performing message format verification, a message processing unit for caching messages and completing message storage and transfer, a message storage unit for storing message data, and a message query unit for completing message data query. The present invention also discloses a specific control method thereof. The present invention can complete the storage and synchronous archiving of large-volume vehicle-mounted CAN messages to ensure that data is not lost, and can also realize rapid message query.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of message data processing, and in particular relates to a large-volume vehicle-mounted CAN message storage and query system and a control method thereof. Background Art

[0002] CAN (Controller Area Network) is a serial communication protocol widely used in automotive, industrial control, and other fields. In automotive electronics, the CAN bus connects ECUs (electronic control units), such as the engine control module (ECM), transmission control unit (TCU), and ABS systems, enabling data exchange. During automotive R&D, testing, and after-sales service, engineers need to monitor, record, and parse CAN messages to perform tasks such as fault diagnosis (such as reading DTCs), ECU calibration and flashing (such as updating software via the UDS protocol), performance testing (such as analyzing powertrain response time), and compliance verification (such as ISO21434 cybersecurity logging).

[0003] Currently, software for analyzing and recording CAN messages includes ZHIYUAN's zxDoc and TsMaster from THONGXING. zxDoc can save a limited number of CAN messages by configuring the buffer size for storing message data. For example, 500MB of memory can store 1.17 million messages.

[0004] The number of messages received by TsMaster is not fixed. It usually displays the latest partial message data. One screen shows 2048 messages from 5272 to 7319. The number may fluctuate depending on the sending frequency but will not exceed 3000.

[0005] In the automotive electronics field, analyzing and recording CAN messages often requires continuous recording, such as in vehicle road tests and vehicle durability tests. A car may have multiple CAN buses, each with a common baud rate of 500kbps to 1Mbps, generating approximately 2000-6300 frames of data per second. Recording for hundreds of hours requires analysis during durability testing. If statistics are taken over 100 hours, each bus will generate at least 720 million frames of data. ZXDoc and TSMaster clearly cannot meet the analysis requirements. Summary of the Invention

[0006] In order to solve the technical problems existing in the above-mentioned prior art, the present invention provides a large-scale vehicle-mounted CAN message storage and query system and its control method, which can complete the storage and synchronous archiving of large-scale vehicle-mounted CAN messages to ensure that data is not lost, and can also realize rapid query of messages.

[0007] The present invention solves the technical problem by the following technical solutions:

[0008] A large-scale vehicle-mounted CAN message storage and query system, comprising:

[0009] A message capture unit, used for capturing message data;

[0010] A message receiving and verification unit, used to receive messages and perform message format verification;

[0011] A message processing unit, used for caching and transferring messages;

[0012] A message storage unit, used for storing message data;

[0013] Message query unit, used to complete the query of message data;

[0014] The message processing unit adopts memory, and the message storage unit adopts hard disk.

[0015] A control method for a large-scale vehicle-mounted CAN message storage and query system, wherein the system storage process comprises the following steps:

[0016] Step S1: Capture and receive message data, attach a microsecond-level high-precision timestamp to it, and then verify the message format. After passing the verification, sort the messages according to the time of the microsecond-level high-precision timestamp, number them, and then generate a unique index. Store them in the memory buffer through the message receiving thread, and then determine whether the number of messages stored in the memory buffer exceeds the set threshold. If so, jump to step S2, otherwise repeat step S1;

[0017] Step S2: Create a memory database to store the threshold message, then save the created memory database to the hard disk and jump to step S3;

[0018] Step S3: Capture and confirm whether to continue receiving bus messages. If so, jump to step S1; otherwise, jump to step S4.

[0019] Step S4: Check whether there are any unstored messages in the memory buffer area. If so, create a memory database, save all messages, and then save the created memory database to the hard disk, stop capturing messages and complete storage. If not, directly stop capturing messages and complete storage.

[0020] Furthermore, the system query process includes the following steps:

[0021] Step Sa, initiate a query request, parse the query conditions and generate a query task list;

[0022] Step Sb, confirm whether the message exists in the memory buffer area, if so, jump to step Sc, otherwise, jump to Sd;

[0023] Step Sc, querying the message data from the memory. If the query is successful, the target message data is output to complete the query process. Otherwise, jump to step Sd;

[0024] Step Sd: Calculate the message index of the memory database where the message exists, and query the message data through the message index. If the query is successful, output the target message data to complete the query process, otherwise jump to step Se;

[0025] Step Se: If all the messages to be queried are not found, continue to query the remaining message data and then return to step Sd; otherwise, complete and close the query request.

[0026] Furthermore, in step S1, if the message format fails to pass the verification, it will be discarded and the number of erroneous messages will be recorded. If the number of messages with erroneous formats exceeds the set value, the CAN controller will automatically shut down the bus; in step S3, the bus messages are captured in real time through the polling mechanism.

[0027] Furthermore, in step S1, the memory cache area is divided into 5 segments, and the threshold of the number of messages stored in each segment is set to 100,000 messages. After reaching the set threshold, the action of jumping to step S3 is triggered. The jump action uses atomic pointer exchange to switch, and the jump action delay time is <1μs.

[0028] Furthermore, while steps S1-S2 are being performed, step S3 can still be performed synchronously, continuously inserting messages into the memory database according to the attached microsecond-level high-precision timestamp to complete data integration.

[0029] Furthermore, in step S2, the in-memory database is set as the target database through the ATTACH command, and then the in-memory database is saved to the hard disk through the VACUUM command. This process specifically includes the following steps:

[0030] Step S2.1, create an in-memory database;

[0031] Step S2.2: Enable single-threaded mode of the in-memory database.

[0032] Step S2.3: Add a memory checkpoint for the in-memory database and start a transaction for the in-memory database to prevent data loss caused by unexpected stops.

[0033] Step S2.4: Enable hard disk synchronization, and save data to the hard disk immediately when it is written;

[0034] Step S2.5: Mount the hard disk database as a backup of the memory database;

[0035] Step S2.6: Execute the hard disk database backup operation to back up the memory database to the hard disk to complete a data copy;

[0036] Step S2.7: Close the hard disk database transaction and complete the data copy;

[0037] Step S2.8: Create hard disk database index information based on the saved message range. The index information includes the start message index, end message index, and number of valid messages in the hard disk database file.

[0038] Step S2.9: Close the hard disk database connection.

[0039] Furthermore, the method for confirming whether the message exists in the memory cache area in step Sb is specifically, obtaining a valid message index list of the memory cache area, generating a query index list by querying the task list, matching the query index list with the valid message index list of the memory cache area, and performing a binary query on the valid message index list contained in the memory cache area through the memory cache area, that is, the search process starts from the middle element of the array. If the middle element happens to be the element to be searched, the search process ends. If a specific element is greater than or less than the middle element, the search is performed in the part of the array that is greater than or less than the middle element, and the comparison is also started from the middle element. When the search process ends, the data is synchronously marked as the latest used message, and the messages in the set range before and after it are marked as the most recently used message data or preloaded message data of the preloaded message, and the average query delay is less than 1ms.

[0040] Furthermore, in step Sc, the target message data is the message data corresponding to the valid message index list of the memory cache area that matches the query index list, and the priority corresponding to the group of target message data is updated and increased;

[0041] Step Sd specifically involves analyzing the index range of the request message using the microsecond-level high-precision timestamp of the request message, locating the valid hard disk database file based on the query message index using the index information of the hard disk database file, and then searching for the message in the hard disk database file.

[0042] Furthermore, in steps Sc and Sd, before outputting the target message data to complete the query process, the target message data must first be loaded using an on-demand paging loading method, and only the signal columns of the message data involved in the query are loaded to achieve column storage optimization.

[0043] Compared with the prior art, the present invention has the following beneficial effects:

[0044] The present invention first receives the message and stores it in the memory, and uses a smaller memory space for caching, thereby solving the problem of higher latency of directly using hard disk storage compared to memory storage.

[0045] 2. The present invention verifies and processes received messages and then uses a database to store them on a hard disk, thus solving the problem of message loss due to power failure and inability to store large amounts of data.

[0046] 3. The present invention uses a merging strategy to merge multiple frames of messages in a short period of time, write them uniformly into the memory database, and write the data in the memory database uniformly into the hard disk, avoiding random reading and writing and using continuous reading and writing, which can meet the data volume requirements of messages generated per second in bench testing and other usage scenarios. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] Figure 1 Schematic diagram of the system structure of the present invention;

[0048] Figure 2 It is a schematic diagram of the storage process of the system of the present invention;

[0049] Figure 3 It is a query flow diagram of the system of the present invention;

[0050] Figure 4 Schematic diagram of comparison of main parameter settings of the present invention;

[0051] Figures 5 to 9 Schematic diagram of Example 1 of the present invention;

[0052] Figure 10 This is a schematic diagram of Effect Example 2 of the present invention. DETAILED DESCRIPTION

[0053] To make the objectives, technical solutions, and advantages of the embodiments of the present invention more clear, the technical solutions of the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Generally, the components of the embodiments of the present invention described and shown in the drawings herein can be arranged and designed in various different configurations.

[0054] like Figure 1 As shown, a large-scale vehicle-mounted CAN message storage and query system includes:

[0055] A message capture unit, used for capturing message data;

[0056] A message receiving and verification unit, used to receive messages and perform message format verification;

[0057] The message processing unit is used to cache messages and, under certain conditions, complete message transfer;

[0058] A message storage unit, used for storing message data;

[0059] The message query unit is used to complete the query of message data.

[0060] In this embodiment, the message processing unit uses DDR4 memory, and the message storage unit uses a SATA protocol mechanical hard disk.

[0061] A control method for a large-scale vehicle-mounted CAN message storage and query system, the storage process, the process is as follows Figure 2 As shown, the following steps are included:

[0062] Step S1, capture and receive message data, attach a microsecond-level high-precision timestamp to it, and verify the message format. If the message format fails the verification, it will be discarded and the number of error messages will be recorded. If the number of messages with the wrong format exceeds the set value, the CAN controller will automatically shut down the bus (the bus is automatically shut down by the CAN controller. When the bus is shut down, all devices on the bus cannot continue to receive or send). If the message format passes the verification, the messages are sorted according to the time of the microsecond-level high-precision timestamp, numbered, and a unique index is generated. The messages are stored in the memory buffer through the message receiving thread, and then it is determined whether the number of messages stored in the memory buffer exceeds the set threshold. If so, jump to step S2, otherwise repeat step S1;

[0063] It should be noted that in step S1, the memory cache is divided into 5 segments, and the message threshold for storing each segment is set to 100,000 messages. After reaching the set threshold, the action of jumping to step S2 is triggered. Specifically, after receiving 100,000 messages, all 100,000 messages will be stored in the hard disk and the memory will be released. Then, when it reaches 100,000 again, the threshold is reached again to trigger storage. This jump action uses atomic pointer exchange to switch, and the jump action delay time is less than 1μs. The switching method of atomic pointer exchange refers to ensuring the atomicity of the pointer switching operation in a multi-threaded environment, that is, it will not be interrupted or interfered with by other threads during the entire switching process. Therefore, atomic operations can ensure data consistency and thread safety in a multi-threaded environment, avoid data competition and conflicts, and are usually more efficient than using a lock mechanism.

[0064] Step S2: Create an in-memory database to store the threshold messages (i.e., 100,000 messages this time). Then save the created in-memory database to the hard disk and jump to step S3; use the ATTACH command to set the in-memory database as the target database, and then use the VACUUM command to save the in-memory database to the hard disk. This process specifically includes the following steps:

[0065] Step S2.1, create an in-memory database;

[0066] Step S2.2: Enable single-threaded mode of the in-memory database.

[0067] Step S2.3: Add a memory checkpoint for the in-memory database and start a transaction for the in-memory database to prevent data loss caused by unexpected stops.

[0068] Step S2.4: Enable hard disk synchronization, and save data to the hard disk immediately when it is written;

[0069] Step S2.5: Mount the hard disk database as a backup of the memory database;

[0070] Step S2.6: Execute the hard disk database backup operation to back up the memory database to the hard disk to complete a data copy;

[0071] Step S2.7: Close the hard disk database transaction and complete the data copy;

[0072] Step S2.8: Create hard disk database index information based on the saved message range, the index information including the start message index, end message index, and number of valid messages in the hard disk database file;

[0073] Step S2.9: Close the hard disk database connection.

[0074] It should be noted that while steps S1-S2 are in progress, step S3 can still be carried out synchronously, continuously inserting messages into the memory database according to the attached microsecond-level high-precision timestamp to complete data integration. Specifically, first create the memory database, then enable the memory database to process transactions; finally, insert the message data sequentially into the memory database.

[0075] Step S3: Capture and confirm whether to continue receiving bus messages. If so, jump to step S1; otherwise, jump to step S4.

[0076] Step S4: Check whether there are any unstored messages in the memory buffer area. If so, create a memory database, save all messages, and then save the created memory database to the hard disk, stop capturing messages and complete storage. If not, directly stop capturing messages and complete storage.

[0077] It should be noted that in this embodiment, the message threshold is 100,000 messages because it is the optimal value. The disk transmission rate is lower when the message threshold is less than or greater than this value. The following example illustrates the disk transmission rate when the message threshold is randomly selected to be 10,000. Figure 4 As shown in (a) in the figure; when the message threshold is 1 million, the disk transmission rate diagram is as follows: Figure 4 As shown in (b); when the message threshold is 100,000, the disk transmission rate diagram is as follows: Figure 4 As shown in (c), it can be seen intuitively that when the message threshold is 100,000 messages, the disk has the highest transmission rate.

[0078] A control method for a large-scale vehicle-mounted CAN message storage and query system, the query process, the flow is as follows Figure 3 As shown, the following steps are included:

[0079] Step Sa, initiating a query request, that is, the user or system initiates a query request for the vehicle CAN message as required (such as by time range, message ID, value threshold, direction, channel, frame type, etc.), parses the query conditions and generates a query task list;

[0080] Step Sb, confirm whether the message exists in the memory cache area. If so, jump to step Sc, otherwise, jump to Sd. The specific process is to obtain the valid message index list of the memory cache area, and match the query index list generated by the query task list with the valid message index list of the memory cache area. The valid message index list contained in the memory cache area is binary searched through the memory cache area, that is, the search process starts from the middle element of the array. If the middle element is exactly the element to be searched, the search process ends. If a specific element is greater than or less than the middle element, the part of the array that is greater than or less than the middle element is searched, and the comparison is also started from the middle element. When the search process ends, the data is synchronously marked as the latest used message, and the messages within a certain range before and after it are marked as the most recently used message data or preloaded message data of the preloaded message. The average query delay is less than 1ms;

[0081] Step Sc, querying message data from the memory. If the query is successful, that is, the target message data is the message data corresponding to the valid message index list of the memory cache area that matches the query index list, then the target message data is output to complete the query process, and the priority corresponding to the group of target message data is updated and increased (the message query process is usually continuous and repeated. If there are 200,000 messages in the current memory, but the user determines that the message range is between 10,000 and 20,000, then when displaying messages, the query can be performed within the determined range. In actual operation, the query speed within 200,000 is very slow, so only the valid messages between 10,000 and 20,000 are extracted, thereby improving the query efficiency). Otherwise, jump to step Sd;

[0082] Step Sd: Calculate the message index of the memory database where the message exists, and query the message data using the message index. If the query is successful, output the target message data to complete the query process. Otherwise, jump to step Se; analyze the index range of the message using the microsecond-level high-precision timestamp of the request message, locate the valid hard disk database file based on the query message index using the index information of the hard disk database file, and then query the message in the hard disk database file;

[0083] It should be noted that in steps Sc and Sd, before outputting the target message data to complete the query process, it is necessary to first load the target message data using on-demand paging. For example, 1MB data blocks are read each time (reducing the number of I / O operations). At the same time, only the signal columns of the message data involved in the query are loaded to achieve column storage optimization (for example, only the message data with ID = 0x0CF is read).

[0084] Step Se: If all the messages to be queried are not found, continue to query the remaining message data and then return to step Sd; otherwise, complete and close the query request.

[0085] It should also be noted that the hard disk database file contains multiple messages and is a storage medium for messages. When querying messages, the message needs to be found from the index information corresponding to the hard disk database file.

[0086] In this embodiment, both the in-memory database and the hard disk database use the SQLite database. Conventional databases require server deployment and require network access when accessed by software. They cannot directly operate database files, and the performance of frequent database access is insufficient to meet the performance requirements of our software. Using the SQLite database, a file-based relational database, plays a positive role in meeting the high concurrency and low latency requirements for message storage.

[0087] At the same time, although the database type is the same, SQLite database, the storage containers are divided into memory and hard disk. Different containers lead to different performance. By utilizing the characteristics of different storage containers and overcoming the problems caused by simply merging the two, the message storage performance is greatly optimized.

[0088] Effect Example 1

[0089] Connect the software in this effect example and ZXDoc to the same bus. The bus arbitration domain baud rate is 1Mbps and the bus load is 90%. Start receiving message data at the same time. After 2 minutes and 27 seconds, ZXDoc starts to prompt that the memory is insufficient and the historical data will be deleted in sequence. The prompt content is as follows: Figure 9 After another 3 seconds, the data on the bus stops being received, and all the messages currently recorded are queried from ZXDoc. Due to insufficient memory, the messages are discarded. The earliest valid message time is 11:03:56.875500, as shown in Figure 5 The date corresponding to the first frame message (i.e. message number 1) when the actual reception starts is 11:02:22, as shown in the figure. Figure 7 As shown, this situation indicates that the ZXDoc message is lost and a large amount of vehicle CAN messages cannot be stored.

[0090] The timestamp of the last frame message received by AXDoc is 11:06:20.281300. Figure 6 shown.

[0091] The message range recorded in this example is from 11:02:22.974862 to 11:06:20:361594, respectively. Figure 7 and Figure 8 Although there is a microsecond deviation in the calibration time of the first frame message of the startup software, the number of messages should be consistent. ZXDoc shows that the Rx count is 3732096 messages, that is, the actual number of messages received is 3732096. The present invention counts, as shown in the figure. Figure 8 As shown, the last frame message sequence number is shown as 3732096, which is consistent with the display. However, since the message time range that ZXDoc can query is smaller than the query range displayed by the integrated software of the present invention, it means that ZXDoc has indeed discarded the message and the actual number of messages that can be queried is less than 3732096.

[0092] Effect Example 2

[0093] This effect example uses the software of the present invention to receive 2-channel CAN message data. The message of each channel is 7900 frames / s for 14 hours. The complete record of the message generates 796320000 frames of message without loss. The actual measurement starts at 18:19 on April 17 and ends at 8:35 on April 18. A total of about 811907895 frames of message are recorded. Figure 10 As shown in (a) and (b).

[0094] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0095] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.

[0096] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0097] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit it. Although the present invention has been described in detail with reference to the above embodiments, ordinary technicians in the field should understand that the specific implementation methods of the present invention can still be modified or replaced by equivalents. Any modification or equivalent replacement that does not depart from the spirit and scope of the present invention should be covered by the scope of protection of the claims of the present invention.

Claims

1. A control method based on a large-scale vehicle-mounted CAN message storage and query system, characterized in that: The system includes a system message capture unit for capturing message data; A message receiving and verification unit, used to receive messages and perform message format verification; A message processing unit, used for caching and transferring messages; A message storage unit, used for storing message data; Message query unit, used to complete the query of message data; The message processing unit adopts a memory, and the message storage unit adopts a hard disk; The system stored procedure includes the following steps: Step S1: Capture and receive message data, attach a microsecond-level high-precision timestamp to it, and then verify the message format. After passing the verification, sort the messages according to the time of the microsecond-level high-precision timestamp, number them, and then generate a unique index. Store them in the memory buffer through the message receiving thread, and then determine whether the number of messages stored in the memory buffer exceeds the set threshold. If so, jump to step S2, otherwise repeat step S1; Step S2: Create a memory database to store the threshold message, then save the created memory database to the hard disk and jump to step S3; Step S3: Capture and confirm whether to continue receiving bus messages. If so, jump to step S1; otherwise, jump to step S4. Step S4: Check whether there are any unstored messages in the memory buffer area. If so, create a memory database, save all messages, and then save the created memory database to the hard disk, stop capturing messages and complete storage. If not, directly stop capturing messages and complete storage; The system query process includes the following steps: Step Sa, initiate a query request, parse the query conditions and generate a query task list; Step Sb, obtain the valid message index list of the memory cache area, match the query index list with the valid message index list of the memory cache area by querying the query index list generated by the task list, and perform a binary search on the valid message index list contained in the memory cache area through the memory cache area, that is, the search process starts from the middle element of the array. If the middle element is exactly the element to be found, the search process ends. If a specific element is greater than or less than the middle element, search in the part of the array that is greater than or less than the middle element, and also start the comparison from the middle element. When the search process ends, the data is synchronously marked as the latest used message, and the messages within the set range before and after it are marked as the most recently used message data or preloaded message data of the preloaded message. The average query delay is less than 1ms. Finally, confirm whether the message exists in the memory cache area. If so, jump to step Sc, otherwise, jump to Sd; Step Sc, querying the message data from the memory. If the query is successful, the target message data is output to complete the query process. Otherwise, jump to step Sd; Step Sd, calculating the message index of the memory database where the message exists, querying the message data through the message index, and if the query is successful, outputting the target message data to complete the query process, otherwise jumping to step Se; Step Se: If all the messages to be queried are not found, continue to query the remaining message data and then return to step Sd; otherwise, complete and close the query request.

2. The control method of the large-scale vehicle-mounted CAN message storage and query system according to claim 1 is characterized in that: In step S1, if the message format fails to pass the verification, it will be discarded and the number of erroneous messages will be recorded. If the number of messages with erroneous formats exceeds the set value, the CAN controller will automatically shut down the bus. In step S3, the bus messages are captured in real time through the polling mechanism.

3. The control method of the large-scale vehicle-mounted CAN message storage and query system according to claim 1 is characterized in that: In step S1, the memory cache is divided into 5 segments, and the threshold value of the number of messages stored in each segment is set to 100,000 messages. When the set threshold is reached, the action of jumping to step S3 is triggered. The jump action adopts the atomic pointer exchange method to switch, and the jump action delay time is less than 1μs.

4. The control method of the large-scale vehicle-mounted CAN message storage and query system according to claim 1 is characterized in that: While steps S1-S2 are being performed, step S3 can still be performed synchronously, and messages are continuously inserted into the memory database according to the attached microsecond-level high-precision timestamp to complete data integration.

5. The control method of the large-scale vehicle-mounted CAN message storage and query system according to claim 1 is characterized in that: In step S2, the in-memory database is set as the target database through the ATTACH command, and then the in-memory database is saved to the hard disk through the VACUUM command. The process specifically includes the following steps: Step S2.1, create an in-memory database; Step S2.2: Enable single-threaded mode of the in-memory database. Step S2.3: Add a memory checkpoint for the in-memory database and start a transaction for the in-memory database to prevent data loss caused by unexpected stops. Step S2.4: Enable hard disk synchronization, and save data to the hard disk immediately when it is written; Step S2.5: Mount the hard disk database as a backup of the memory database; Step S2.6: Execute the hard disk database backup operation to back up the memory database to the hard disk to complete a data copy; Step S2.7: Close the hard disk database transaction and complete the data copy; Step S2.8: Create hard disk database index information based on the saved message range, the index information including the start message index, end message index, and number of valid messages in the hard disk database file; Step S2.9: Close the hard disk database connection.

6. The control method of the large-scale vehicle-mounted CAN message storage and query system according to claim 1 is characterized in that: In the step Sc, the target message data is the message data corresponding to the valid message index list of the memory cache area that matches the query index list, and the priority corresponding to the group of target message data is updated and increased; Specifically, step Sd is to analyze the index range of the message through the microsecond-level high-precision timestamp of the request message, locate the valid hard disk database file according to the query message index through the index information of the hard disk database file, and then query the message in the hard disk database file.

7. The control method of the large-scale vehicle-mounted CAN message storage and query system according to claim 6 is characterized in that: In the steps Sc and Sd, before outputting the target message data to complete the query process, the target message data must first be loaded using an on-demand paging loading method, and only the signal columns of the message data involved in the query are loaded.

Citation Information

Patent Citations

  • Method and equipment for obtaining attack message

    CN102231747A

  • High performance data message capture method and device based on Linux

    CN103441941A