CAN bus log data acquisition system and method
By providing a CAN bus data log acquisition system, using general CAN data communication equipment and various components, the problems of high cost of acquisition of CAN data logs and poor compatibility in the prior art are solved, and efficient and compatible CAN bus data log acquisition is achieved.
Patent Information
- Application Number
- CN202411735706.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-29
- Publication Date
- 2025-04-22
AI Technical Summary
The cost of obtaining CAN data logs in the existing industry is too high and the compatibility is not strong, so it is impossible to effectively obtain and analyze CAN bus data logs.
By providing a CAN bus data log acquisition system, it uses ordinary general CAN data communication equipment, combined with CAN log receiver, log data cache module, log writing scheduling service, log format function module and other components, to achieve accurate and efficient acquisition of CAN bus data logs, and is compatible with multiple log formats.
It realizes the use of ordinary general CAN data communication equipment to obtain CAN bus data logs, which reduces costs, improves acquisition efficiency, and solves the problem of compatibility of multiple log formats.
Smart Images

Figure CN119862169A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of industrial communications, and in particular to a CAN bus log data acquisition system and method. Background Art
[0002] CAN bus technology is currently widely used in industries such as automobile manufacturing and industrial control. In the technical research and development, production and testing of related industries, it is necessary to obtain and analyze CAN data logs. How to obtain CAN data logs accurately and quickly is a technology that is urgently needed by related industries.
[0003] At present, the industry mostly uses foreign CAN tool software systems to obtain CAN data logs. Although these software systems can obtain CAN data logs, they need to purchase their matching CAN data communication equipment, which is dozens of times more expensive than similar domestic general CAN data communication equipment. In other words, if you want to obtain CAN data logs, you must use both software and hardware together.
[0004] In terms of hardware, the function of CAN data communication equipment is only to transmit CAN data, but it does not have the function of obtaining CAN data logs. Obtaining CAN data logs is achieved through software, and there is no unified international standard for the CAN log format. Often, one software can only be compatible with one or two log formats. Summary of the invention
[0005] The purpose of the present invention is to provide a CAN bus data log acquisition system and method to solve the technical problems of the existing industry CAN data log acquisition cost being too high and the compatibility being weak. Through the system and method of the present invention, the technical effect of accurately and efficiently acquiring CAN bus data logs and being compatible with multiple log formats can be achieved by using ordinary general CAN data communication equipment.
[0006] The present invention provides a CAN bus data log acquisition system, comprising:
[0007] CAN application system or equipment, CAN bus and CAN bus data log acquisition system;
[0008] The CAN application system or device transmits the CAN bus data read and write logs to be saved to the CAN bus data log acquisition system through one-way communication;
[0009] Two-way communication between CAN application system or device and CAN bus.
[0010] Furthermore, the CAN application system or device is a hardware device or software system that reads and writes CAN bus data.
[0011] Furthermore, the CAN bus data log acquisition system includes: a CAN log receiver, a log data cache module, a log write scheduling service, a log format function module, a system abnormality log function module and a system configuration function module.
[0012] Furthermore, the CAN log receiver provides an external interface for communicating with a CAN application system or device, and is used for storing CAN data logs and switching CAN log files.
[0013] Furthermore, the log data cache module includes: a local data cache unit and a cache fuse unit; the local data cache unit is used to cache the CAN data log locally; when the log write exceeds the fuse threshold, the cache fuse unit starts the fuse mechanism and abandons the blocked data.
[0014] Furthermore, the log writing scheduling service uniformly schedules the log writing operation, batch-picks out all or specified log data in the log data cache according to time slices, and batch-writes the log data into the log file in the order of the original submission time.
[0015] Furthermore, the log format function module saves the CAN file in a specified file format through the setting of the system configuration file.
[0016] Furthermore, when a fuse exception occurs in the system, the exception information is saved in the system log.
[0017] Furthermore, the system configuration function module provides system configuration functions including: CAN log file format setting, log file path change, log cache fuse threshold setting and single processing log data maximum number setting.
[0018] A CAN bus log data acquisition method is applied to a CAN bus log data acquisition system, comprising the following steps:
[0019] S1. The log receiver calls the external interface to receive log data from the CAN application system or device; the log writing scheduling service is started, the scheduling service cyclically starts the log writing processing task process, and the log file is initialized;
[0020] S2, calling the new log data function in the log data cache module to add the log data to the data cache; at this time, judging whether the log data cache reaches the fuse threshold, when the log data cache length exceeds the fuse threshold, starting the log data cache fuse processing, clearing the blocked data in the log data cache, calling the system log function in the system exception log function module, and outputting the fuse system exception log; otherwise, proceeding to step S3;
[0021] S3. The log writing scheduling service starts the log writing process regularly. After entering the log writing time slice, the processing flow takes out all or the specified length data in the log data cache, processes the write data into standard format data, generates log data in the specified format, and writes the log data into files in batches.
[0022] The beneficial effects provided by the present invention are:
[0023] Firstly, the present invention saves the received CAN data into the log data cache, and the log writing scheduling service writes it in batches at regular intervals, thereby reducing the system IO operations and improving the system's ability to obtain CAN data; adopts a fuse mechanism and an abnormal output method, adjusts the fuse threshold, improves the system IO utilization efficiency, and ensures the real-time performance and concurrent processing capability of the system.
[0024] Secondly, in this method, the log file switching information is stored in the cache. When the log writing scheduling service identifies the file switching information in the cache, the log file switching operation is scheduled to be executed, thereby avoiding the loss of CAN data during the log file switching process.
[0025] Finally, the log format function module in the present invention is compatible with the current mainstream CAN log file format in the industry, and can flexibly add its own CAN log file format, solving the compatibility problem of multiple CAN log file formats. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] Figure 1 It is a schematic diagram of the system structure of the present invention;
[0027] Figure 2 It is a structural diagram of the CAN bus data log acquisition system;
[0028] Figure 3 It is a flow chart of the method of the present invention. DETAILED DESCRIPTION
[0029] In order to make the objectives, technical solutions and advantages of the present invention more clear, the embodiments of the present invention will be further described below with reference to the accompanying drawings.
[0030] Before formally describing the present invention, the scheme of the present invention is first generally described for easy understanding.
[0031] Please refer to Figure 1 , Figure 1 It is a schematic diagram of the system structure of the present invention.
[0032] The present invention provides a CAN bus data log acquisition system, comprising:
[0033] CAN application system or equipment, CAN bus and CAN bus data log acquisition system;
[0034] The CAN application system or device transmits the CAN bus data read and write logs to be saved to the CAN bus data log acquisition system through one-way communication;
[0035] Two-way communication between CAN application system or device and CAN bus.
[0036] It should be noted that the CAN application system or device is a hardware device that reads and writes CAN bus data.
[0037] As an embodiment, the CAN application system or device transmits the CAN bus data read and write logs to be saved to the CAN bus data log acquisition system through one-way communication.
[0038] The CAN bus data log acquisition system acquires and saves CAN bus data log information.
[0039] The CAN application system or device can be a hardware device system that reads and writes CAN bus data, or it can be CAN bus test software, tooling software, CAN application host computer software, etc.
[0040] Please note that, please refer to Figure 2 , Figure 2 It is a structural diagram of the CAN bus data log acquisition system;
[0041] The CAN bus data log acquisition system includes: a CAN log receiver, a log data cache module, a log writing scheduling service, a log format function module, a system abnormality log function module and a system configuration function module.
[0042] It should be noted that the CAN log receiver provides an external interface for communicating with a CAN application system or device, and is used to save CAN data logs and switch CAN log files.
[0043] As an embodiment, the CAN log receiver provides an external calling interface, and the external system and hardware initialize the system configuration, save the CAN data log, switch the CAN log file, etc. by calling the interface provided by it.
[0044] It should be noted that the log data cache module includes: a local data cache unit and a cache fuse unit; the local data cache unit is used to cache the CAN data log locally; when the log write exceeds the fuse threshold, the cache fuse unit activates the fuse mechanism and abandons the blocked data.
[0045] As an embodiment, the local data cache unit caches the CAN data received by the log receiver, and the log writing scheduling service saves them in batches, thereby reducing the number of system IO calls, improving the log saving concurrency capability, and reducing the delay of the log saving operation;
[0046] In addition, the cache fuse unit provides a cache fuse function. When the log writing concurrency exceeds the fuse threshold, the fuse mechanism is activated to abandon some blocked data to ensure that the subsequent CAN log data writing is not affected. The fuse threshold can be adjusted according to the system IO capability to reduce or prevent the occurrence of fuse events.
[0047] It should be noted that the log write scheduling service uniformly schedules log write operations, batch-retrieves all or specified log data in the log data cache according to time slices, and writes the log data to the log file in batches in the order of the original submission time, thereby reducing the number of IO times for writing log files and improving the efficiency of log file writing.
[0048] It should be noted that the log format function module saves the CAN file in the specified file format through the settings of the system configuration file. Therefore, through this function, this system can be compatible with the mainstream CAN log file format in the industry.
[0049] It should be noted that the specific function of the system exception log function module is: when a fuse exception occurs in the system, the exception information is saved in the system log.
[0050] Finally, the system configuration function module provides system configuration functions including: CAN log file format setting, log file path change, log cache fuse threshold setting and maximum number of log data processed at a time.
[0051] A CAN bus log data acquisition method is applied to a CAN bus log data acquisition system, comprising the following steps:
[0052] S1. The log receiver calls the external interface to receive log data from the CAN application system or device; the log writing scheduling service is started, the scheduling service cyclically starts the log writing processing task process, and the log file is initialized;
[0053] S2, calling the new log data function in the log data cache module to add the log data to the data cache; at this time, judging whether the log data cache reaches the fuse threshold, when the log data cache length exceeds the fuse threshold, starting the log data cache fuse processing, clearing the blocked data in the log data cache, calling the system log function in the system exception log function module, and outputting the fuse system exception log; otherwise, proceeding to step S3;
[0054] S3. The log writing scheduling service starts the log writing process regularly. After entering the log writing time slice, the processing flow takes out all or the specified length data in the log data cache, processes the write data into standard format data, generates log data in the specified format, and writes the log data into files in batches.
[0055] Please refer to Figure 3 , Figure 3 The figure is a flow chart of the method of the present invention. In the method of the present invention, the log data cache module and the log writing scheduling service are core functions.
[0056] As an embodiment, the method specifically includes the following:
[0057] 1. After the log data cache is initialized, the log receiving monitoring service is started in the log receiver to receive the CAN log data and log file conversion requests transmitted to the monitoring interface by the external system; the log writing scheduling service is started, and the scheduling service cyclically starts the log writing processing task process, and the log file is initialized;
[0058] 2. When the log receiver receives CAN log data, it calls the new log data function in the log data cache module to add the log data to the data cache;
[0059] 3. In step 2, before adding data to the data cache, determine whether the log data cache has reached the fuse threshold. When the log data cache length exceeds the fuse threshold, start the log data cache fuse processing, clear the blocked data in the log data cache, call the system log function in the system exception log function module, and output the fuse system exception log. In this system and method, the log data cache fuse is a very rare event. If a fuse event occurs, it can be solved by adjusting the fuse threshold setting, improving the file system IO capability, etc.
[0060] 4. The log writing scheduling service starts the log writing process at a fixed time. After entering the log writing time slice, the processing flow takes out all or the specified length of data in the log data cache, processes the written data into standard format data, generates log data in the specified format, and writes the log data into files in batches;
[0061] 5. When the log writing scheduling service writes data, if the log data cache contains the transformation file information, the processing flow executes the switch log data storage file; the log file switching operation includes closing the original log file, adding and initializing the new log file;
[0062] 6. After receiving the log file change request, the log receiver adds the change file information to the log data cache. When the log write scheduling service reads the log file switch information in the next log write processing time slice, it executes the log file switch operation;
[0063] 7. When this processing flow ends, the log writing scheduling service stops the scheduled log writing process after receiving the "end of obtaining log data".
[0064] As an embodiment, the present invention has been applied in various usage environments such as test software, tooling software, hardware debugging tools, etc. The CAN data log acquisition method has the characteristics of high concurrency and low latency. It also has the technical characteristics of flexible switching of log files and support for multiple CAN log file formats, which is convenient for use by other calling systems and improves the efficiency of development, production and testing work.
[0065] The CAN data log acquisition method uses a relatively low-priced general CAN data acquisition device during use to achieve CAN data log acquisition, thereby reducing the cost of obtaining the relevant CAN data log and generating greater economic benefits.
[0066] The beneficial effects of the present invention are:
[0067] Firstly, the present invention saves the received CAN data into the log data cache, and the log writing scheduling service writes it in batches at regular intervals, thereby reducing the system IO operations and improving the system's ability to obtain CAN data; adopts a fuse mechanism and an abnormal output method, adjusts the fuse threshold, improves the system IO utilization efficiency, and ensures the real-time performance and concurrent processing capability of the system.
[0068] Secondly, in this method, the log file switching information is stored in the cache. When the log writing scheduling service identifies the file switching information in the cache, the log file switching operation is scheduled to be executed, thereby avoiding the loss of CAN data during the log file switching process.
[0069] Finally, the log format function module in the present invention is compatible with the current mainstream CAN log file format in the industry, and can flexibly add its own CAN log file format, solving the compatibility problem of multiple CAN log file formats.
[0070] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A CAN bus log data acquisition system, characterized in that: include: CAN application system or equipment, CAN bus and CAN bus data log acquisition system; The CAN application system or device transmits the CAN bus data read and write logs to be saved to the CAN bus data log acquisition system through one-way communication; Two-way communication between CAN application system or device and CAN bus.
2. A CAN bus log data acquisition system as claimed in claim 1, characterized in that: CAN application system or device is a hardware device or software system that reads and writes CAN bus data.
3. A CAN bus log data acquisition system as claimed in claim 1, characterized in that: The CAN bus data log acquisition system includes: a CAN log receiver, a log data cache module, a log writing scheduling service, a log format function module, a system abnormality log function module and a system configuration function module.
4. A CAN bus log data acquisition system as claimed in claim 3, characterized in that: The CAN log receiver provides an external interface for communicating with CAN application systems or devices, and is used to save CAN data logs and switch CAN log files.
5. A CAN bus log data acquisition system as claimed in claim 3, characterized in that: The log data cache module includes: a local data cache unit and a cache fuse unit; the local data cache unit is used to cache the CAN data log locally; when the log write exceeds the fuse threshold, the cache fuse unit starts the fuse mechanism and abandons the blocked data.
6. A CAN bus log data acquisition system as claimed in claim 3, characterized in that: The log writing scheduling service uniformly schedules log writing operations, batch-retrieves all or specified log data in the log data cache according to time slices, and batch-writes the log data into log files in the order of the original submission time.
7. A CAN bus log data acquisition system as claimed in claim 3, characterized in that: The log format function module saves the CAN file in the specified file format through the settings of the system configuration file.
8. A CAN bus log data acquisition system as claimed in claim 3, characterized in that: The specific function of the system exception log function module is: when a fuse exception occurs in the system, the exception information is saved in the system log.
9. A CAN bus log data acquisition system as claimed in claim 3, characterized in that: The system configuration function module provides system configuration functions including: CAN log file format setting, log file path change, log cache fuse threshold setting and maximum number of log data processed at a time.
10. A CAN bus log data acquisition method, applied to a CAN bus log data acquisition system according to any one of claims 1 to 9, characterized in that: The method comprises the following steps: S1. The log receiver calls the external interface to receive log data from the CAN application system or device; the log writing scheduling service is started, the scheduling service cyclically starts the log writing processing task process, and the log file is initialized; S2, calling the new log data function in the log data cache module to add the log data to the data cache; at this time, judging whether the log data cache reaches the fuse threshold, when the log data cache length exceeds the fuse threshold, starting the log data cache fuse processing, clearing the blocked data in the log data cache, calling the system log function in the system exception log function module, and outputting the fuse system exception log; otherwise, proceeding to step S3; S3. The log writing scheduling service starts the log writing process regularly. After entering the log writing time slice, the processing flow takes out all or the specified length data in the log data cache, processes the write data into standard format data, generates log data in the specified format, and writes the log data into files in batches.