A log recording method, device and storage medium for vehicle parts
By obtaining and matching the log storage paths of vehicle parts, the problem of missing log information of vehicle parts is solved, and reliable recording and efficient analysis of log information is achieved.
Patent Information
- Application Number
- CN202311596697.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-27
- Publication Date
- 2025-03-18
- Estimated Expiration
- 2043-11-27
AI Technical Summary
When existing vehicle parts do not have a file system during operation, log information can only be temporarily recorded in memory and will be cleared after power failure, resulting in lost or missing log information, affecting the efficiency of fault analysis and resolution.
By obtaining preset configuration parameters, including vehicle component identification and log storage path, matching the target log storage path, recording the data of pending tasks to avoid the loss of log information.
It realizes the secure recording of log information, improves the reliability and traceability of log information, and enhances the efficiency of fault analysis and resolution.
Smart Images

Figure CN117573409B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of vehicle technology, and specifically to a log recording method, device and storage medium for vehicle parts. Background Art
[0002] The entire vehicle system is composed of many component controllers. Logs are the most common way to track problems. Each component can record program runtime logs during operation, so that maintenance or developers can track problems when problems occur. The loss or missing of log information will cause the failure or abnormality of components to occur, and the previous program running status cannot be traced, which will lead to bottlenecks in problem analysis, resulting in inefficient resolution of component failures or abnormalities, and may even make it impossible to track component failures or abnormalities.
[0003] However, some components do not have a file system. When the program is running, they can only temporarily record key segment information in the memory at the expense of some resources, and the information will be cleared when the power is off. The log information cannot be saved, resulting in the loss or deletion of log information, resulting in low security and reliability of log information. Summary of the invention
[0004] In view of the above problems, the embodiments of the present application provide a log recording method, device and storage medium for vehicle parts, which are used to securely record log information.
[0005] According to one aspect of an embodiment of the present application, a log recording method for vehicle parts is provided, the log recording method comprising: obtaining preset configuration parameters; wherein the configuration parameters include a vehicle part identifier and a log storage path corresponding to the vehicle part; obtaining the vehicle part identifier to be processed corresponding to the pending task in the log recording queue, and based on the vehicle part identifier to be processed, matching the corresponding target log storage path in the configuration parameters; and recording the data of the pending task based on the target log storage path.
[0006] In an optional manner, before obtaining the identification of the pending vehicle parts corresponding to the pending tasks in the log recording queue, the log recording method also includes: detecting the number of log processing modules; wherein the log processing module is used to record the data corresponding to the pending tasks, and the number of log processing modules corresponds to the number of log recording queues; if the number of log processing modules is one, then based on the transmission time of the pending tasks, the pending tasks are transmitted to the log recording queue corresponding to the log processing module; if the number of log processing modules is multiple, then based on the task processing threshold corresponding to the log processing module, the pending tasks are transmitted to the log recording queue corresponding to one of the multiple log processing modules.
[0007] In an optional manner, multiple log processing modules include a first log processing module; based on the task processing threshold corresponding to the log processing module, the to-be-processed task is transferred to the log record queue corresponding to a log processing module among the multiple log processing modules, further including: if the number of to-be-processed tasks in the log record queue corresponding to the first log processing module is less than the task processing threshold, the to-be-processed task is transferred to the log record queue corresponding to the first log processing module; if the number of to-be-processed tasks in the log record queue corresponding to the first log processing module is not less than the task processing threshold, the log record queue corresponding to the second log processing module other than the first log processing module among the multiple log processing modules is initialized, and based on the number of to-be-processed tasks in the log record queue corresponding to the first log processing module and the number of to-be-processed tasks in the log record queue corresponding to the log processing module, a target log processing module is obtained to transfer the to-be-processed task to the target log processing module.
[0008] In an optional manner, the method of obtaining the identification of the vehicle parts to be processed corresponding to the pending tasks in the log record queue further includes: obtaining a transmission method for transmitting the pending tasks to the log record queue; if the transmission method is a method of transmitting data via Ethernet, then using the logical identification in the pending tasks as the identification of the vehicle parts to be processed; if the transmission method is a method of transmitting data via a controller local area network, then using the controller local area network identification in the pending tasks as the identification of the vehicle parts to be processed.
[0009] In an optional manner, recording the data of the task to be processed based on the target log storage path further includes: detecting whether a first log file exists based on the target storage path; wherein the first log file is a log file that records data at a current time point, and the first log file includes a preset time range for recording data; if the first log file exists, detecting whether the current time point is within the preset time range for recording data; if the current time point is not within the time range for recording data in the first log file, creating a second log file, and recording the data of the task to be processed to the second log file.
[0010] In an optional manner, during the detecting of whether the current time point is after the preset time range of the recorded data, the log recording method further includes: if the current time point is within the time range of the recorded data of the first log file, detecting within the preset time range of the recorded data whether the size of the first log file after the recorded data exceeds the file storage threshold set for the first log file; if the size of the first log file after the recorded data exceeds the file storage threshold set for the first log file, creating a third log file, and recording the data of the task to be processed in the third log file.
[0011] In an optional manner, after detecting whether the current time point is within the preset time range of the recorded data, the log recording method further includes: if the current time point is within the preset time range of the recorded data, treating the task to be processed as the first task to be processed; if the number of the first tasks to be processed is greater than a preset first threshold, expanding the file storage threshold set for the log file.
[0012] According to another aspect of an embodiment of the present application, a log recording device for vehicle parts is provided, and the log recording device includes: a configuration parameter acquisition module, used to obtain preset configuration parameters; wherein the configuration parameters include a vehicle part identification and a log storage path corresponding to the vehicle part; a path acquisition module, used to obtain the identification of the vehicle part to be processed corresponding to the task to be processed in the log recording queue, and based on the identification of the vehicle part to be processed, match the corresponding target log storage path in the configuration parameters; a log recording module, used to record the data of the task to be processed based on the target log storage path.
[0013] According to one aspect of an embodiment of the present application, an electronic device is provided, including: a controller; and a memory for storing one or more programs, which, when the one or more programs are executed by the controller, perform the above-mentioned logging method.
[0014] According to one aspect of an embodiment of the present application, a computer-readable storage medium is further provided, on which computer-readable instructions are stored. When the computer-readable instructions are executed by a processor of a computer, the computer executes the above-mentioned logging method.
[0015] According to one aspect of the embodiments of the present application, a computer program product or a computer program is also provided, the computer program product or the computer program includes a computer instruction, and the computer instruction is stored in a computer-readable storage medium. The processor of the computer device reads the computer instruction from the computer-readable storage medium, and the processor executes the computer instruction, so that the computer device performs the above-mentioned logging method.
[0016] The embodiment of the present application writes the pending task into a log processing queue, thereby writing a log to the data of the pending task based on the queue. In this process, the log storage path is obtained in the configuration data through the pending task, so that the data corresponding to the pending task is saved based on the log storage path, thereby avoiding the loss of log information and ensuring the reliability of the log information.
[0017] The above description is only an overview of the technical solution of the embodiment of the present application. In order to more clearly understand the technical means of the embodiment of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the embodiment of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] The drawings herein are incorporated into the specification and constitute a part of the specification, illustrate embodiments consistent with the present application, and are used together with the specification to explain the principles of the present application. Obviously, the drawings described below are only some embodiments of the present application, and for ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0019] Figure 1 It is a structural schematic diagram of a log recording system for vehicle parts shown in an exemplary embodiment of the present application.
[0020] Figure 2 It is a flowchart of a log recording method for vehicle parts shown in an exemplary embodiment of the present application.
[0021] Figure 3 It is a flowchart of a log recording method for vehicle parts shown in another exemplary embodiment of the present application.
[0022] Figure 4 It is a schematic diagram of the structure of tasks to be processed shown in an exemplary embodiment of the present application.
[0023] Figure 5 It is a schematic diagram of the data format structure of a task to be processed shown in an exemplary embodiment of the present application.
[0024] Figure 6 It is a schematic diagram of a mapping table structure shown in an exemplary embodiment of the present application.
[0025] Figure 7 is based on Figure 2 A schematic flow chart of a log recording method for vehicle parts is shown in an embodiment.
[0026] Figure 8 It is a schematic structural diagram of a log recording device for vehicle parts shown in an exemplary embodiment of the present application.
[0027] Fig. 9 It is a structural diagram of a computer system of an electronic device shown in an exemplary embodiment of the present application. DETAILED DESCRIPTION
[0028] Here, exemplary embodiments will be described in detail, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are only examples of devices and methods consistent with some aspects of the present application as detailed in the attached claims.
[0029] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities may be implemented in software form, or in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.
[0030] The flowcharts shown in the accompanying drawings are only exemplary and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps can be decomposed, and some operations / steps can be combined or partially combined, so the actual execution order may change according to actual conditions.
[0031] The term "multiple" as used in this application refers to two or more than two. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the related objects are in an "or" relationship.
[0032] The existing vehicle system is composed of many component controllers. Logs are the most common way to track problems. Each component can record program runtime logs during operation to facilitate maintenance or developers to track problems when problems occur. Many components in the vehicle use MCU (microcontroller unit chip) without a file system. When the program is running, the log records can only be temporarily recorded in the memory at the expense of some resources. Key segment information is cleared when the power is off. There is no file storage to save log information, which leads to the loss or missing of log information of some components.
[0033] To this end, one aspect of the present application provides a log recording method for vehicle parts, which can be used in vehicle parts with a file system and in vehicle parts using an MCU without a file system to avoid the loss of log information.
[0034] First, please refer to Figure 1 , Figure 1 The log recording system of a vehicle component shown in an exemplary embodiment of the present application, wherein the MCU is an MCU vehicle component, of course Figure 1 The MCU components are temporarily shown in the figure. It is understandable that the logging system of the vehicle components may also contain non-MCU components. Figure 1 Not shown yet.
[0035] The relevant vehicle parts are located in the whole vehicle system, and the log recording device of the vehicle parts is arranged in the management vehicle parts. The management vehicle parts are high-performance vehicle parts. The log recording device of the vehicle parts can be used to implement the following vehicle parts log recording method.
[0036] Among them, each vehicle component is connected through a CAN bus (controller area network bus) or Ethernet. Of course, the end-to-end connection between each component is not limited to adjacent devices but can also span multiple vehicle components. The management of vehicle components synchronizes log information to the cloud server through the on-board gateway, on-board TBOX (on-board electrical components) and the network (internet).
[0037] Please refer to Figure 2 , Figure 2 1 is a flow chart of a log recording method for vehicle parts shown in an exemplary embodiment of the present application. The log recording method at least includes S210 to S230, which are described in detail as follows:
[0038] S210: Obtain preset configuration parameters.
[0039] In this embodiment, the log recording device for managing vehicle parts will first load configuration parameters, which include the vehicle part identification, the log storage path corresponding to the vehicle part, the periodic synchronization cloud time, the size of a single log file (file storage threshold) and the recording period of a single log file, the Ethernet UDP service listening port, the number of tasks that can be started to process log records (task processing threshold) and other information.
[0040] S220: Obtain the identification of the vehicle parts to be processed corresponding to the pending tasks in the log record queue, and match the corresponding target log storage path in the configuration parameters based on the identification of the vehicle parts to be processed.
[0041] Please refer to Figure 3Another exemplary embodiment of the present application shows a flow chart of a log recording method for vehicle parts, wherein after obtaining configuration parameters, the management of vehicle parts starts the main task (log processing module), opens the listening service for managing vehicle parts, opens the UDP listening port for Ethernet connection, opens the listening CAN message channel for CAN bus connection, and waits for the vehicle parts log transmission task.
[0042] In this embodiment, Figure 4 As shown, the transmission mode and the identification of the vehicle parts to be processed can be obtained in the pending task, so the transmission mode of transmitting the pending task to the log record queue can be obtained first; if the transmission mode is a method of transmitting data through Ethernet, the logical identification in the pending task is used as the identification of the vehicle parts to be processed; if the transmission mode is a method of transmitting data through a controller local area network, the controller local area network identification in the pending task is used as the identification of the vehicle parts to be processed.
[0043] Specifically, if the vehicle parts are connected via Ethernet, the transmission method is deemed to be data transmission via Ethernet, that is, the information transmitted from the vehicle parts to the management vehicle parts is in the UDP message format. If the vehicle parts are connected via the CAN bus, the transmission method is data transmission via the controller area network, that is, the information transmitted from the vehicle parts to the management vehicle parts is in the CAN message format. During operation, the vehicle parts transmit the data generated by the operation to the management vehicle parts. The main task of the management vehicle parts listens to the transmitted data and inserts it into the log record queue as a pending task. Then, based on the pending tasks in the log record queue, the management vehicle parts perform log recording on behalf of the management vehicle parts. After the management vehicle parts perform log recording for each vehicle part, it is synchronized to the cloud through the external communication module.
[0044] In a specific embodiment, regardless of whether the task to be processed is in the UDP message format or the CAN message format, it carries the corresponding vehicle component identifier to be processed. Therefore, the corresponding target log storage path can be matched in the configuration parameters through the vehicle component identifier to be processed of the task to be processed. Therefore, when the subsequent log processing module processes the tasks to be processed in the log record queue in sequence, it can record the corresponding data of the task to be processed based on the target log storage path, that is, the log information of the vehicle component to be processed corresponding to the task to be processed.
[0045] If the transmission mode is to transmit data via Ethernet, the data format of the task to be processed is as follows: Figure 5As shown, it includes UDP Header (User Datagram Protocol header file, occupying 8 bytes), LogicalId (logical identifier, occupying 2 bytes), DateLen (data length, occupying 2 bytes) and Date (data, occupying 0-1500 bytes), and the logical identifier is used as the identifier of the vehicle parts to be processed; and if the transmission method is a method of transmitting data through a controller area network, the controller area network identifier (CAN ID) in the task to be processed is used as the identifier of the vehicle parts to be processed, so that after determining the vehicle parts identifier, the target log storage path is matched.
[0046] In this embodiment, since there are two transmission modes, for the same vehicle parts, there may be the following Figure 6 The mapping table shown, that is, for a vehicle component name, it corresponds to a logical ID (identifier) in the UDP message format and a CANID in the CAN message format. Therefore, when matching the target log storage path, it is generally matched through a two-tuple, that is, the vehicle component identifier and the transmission method. Specifically, the transmission method is used to determine whether the vehicle component identifier is a logical ID or a CANID, so as to match the corresponding vehicle component name and obtain the target log storage path.
[0047] In this embodiment, the configuration parameters may not contain the identification of the vehicle parts to be processed corresponding to the task to be processed, that is, the target log storage path cannot be matched in the configuration parameters. At this time, it may be because the vehicle parts to be processed generate log information for the first time. In this case, the vehicle parts identification and log storage path corresponding to the task to be processed can be added to the configuration parameters, and the newly added log storage path can be used as the target log storage path, and then wait for processing by the log processing module.
[0048] In some embodiments, there may be one or more log recording queues, which correspond to log processing modules, that is, each log processing module has a corresponding log recording queue, which records the data corresponding to the tasks to be processed, that is, the log processing module records the log information of the vehicle parts to be processed corresponding to the tasks to be processed in the corresponding log processing queue.
[0049] Specifically, the number of log processing modules can be detected; if the number of log processing modules is one, the task to be processed is transmitted to the log record queue corresponding to the log processing module based on the transmission time of the task to be processed; if the number of log processing modules is multiple, the task to be processed is transmitted to the log record queue corresponding to one of the multiple log processing modules based on the task processing threshold corresponding to the log processing module.
[0050] In a specific embodiment, if the number of the log processing module is one, all the transmitted tasks to be processed enter a log record queue to wait for processing according to the order of arrival.
[0051] If there are multiple log processing modules, at this time, there is a first log processing module, which is the first log processing module to be initialized. At this time, other log processing modules may not be initialized first, that is, the log processing queues corresponding to other log processing modules do not accept tasks to be processed.
[0052] If the number of pending tasks in the log record queue corresponding to the first log processing module is less than the task processing threshold, the pending tasks are transmitted to the log record queue corresponding to the first log processing module;
[0053] If the number of pending tasks in the log record queue corresponding to the first log processing module is not less than the task processing threshold, then the log record queue corresponding to the second log processing module other than the first log processing module among multiple log processing modules is initialized, and based on the number of pending tasks in the log record queue corresponding to the first log processing module and the number of pending tasks in the log record queue corresponding to the log processing module, the target log processing module is obtained to transfer the pending tasks to the target log processing module.
[0054] Specifically, there are multiple log processing modules. When the number of pending tasks in the log recording queue corresponding to the first log processing module is not less than the task processing threshold, which is preset in the configuration parameters. Generally speaking, the task processing threshold is the number of vehicle parts online multiplied by the log trigger frequency of a single vehicle part, the second log processing module is started, and the log processing queue corresponding to the second log processing module is initialized, and the next pending task entering the log processing queue is inserted into the log processing queue corresponding to the second log processing module.
[0055] In one embodiment, when a pending task enters a log processing queue, the number of pending objects in each log processing queue can be queried, and the log processing queue with a small number of pending objects can be used as the target log processing module to transfer the pending task to the target log processing module. In this way, the relative balance of the number of pending tasks in each log processing queue is ensured, so that the log processing module can process the pending tasks in parallel.
[0056] S230: Recording the data of the task to be processed based on the target log storage path.
[0057] In this embodiment, based on the target log storage path, the log file corresponding to the data of the task to be processed can be obtained. At this time, you can check whether the log file is recording data. If so, you can choose to create a new log file to store the data of the task to be processed or still store the data of the task to be processed in the log file.
[0058] In this embodiment, a log recording method for vehicle parts is proposed. The method can directly connect to the vehicle Ethernet or CAN interface or cross-device to store logs for vehicle parts without a file system and dynamically manage logs, and support high-concurrency processing. At the same time, the method can periodically report logs to the cloud to achieve multi-terminal recording, avoid the loss of log information, and facilitate development or operation and maintenance personnel to quickly analyze and solve problems. At the same time, the method has high portability and fast deployment, which saves time and economic costs for vehicle development, greatly reduces the development cycle, and can be quickly applied to multiple models.
[0059] In another exemplary embodiment of the present application, a method for recording data of a task to be processed is described in detail, such as Figure 7 As shown, in Figure 2 In S230 of the log recording method shown, S71 to S73 are further included, which are described in detail as follows:
[0060] S71: Detect whether a first log file exists based on the target storage path.
[0061] In this embodiment, based on the target storage path, a log file in which the data corresponding to the task to be processed is written can be obtained. If the log file is a log file that records data at the current time point, then the log file is the first log file. At the same time, the first log file can be obtained including a preset time range for recording data. The time range is the time period for recording data preset in the first log file. Within this time range, the first log file can write recorded data.
[0062] S72: If the first log file exists, detect whether the current time point is within a preset time range for recording data.
[0063] S73: If the current time point is not within the time range for recording data in the first log file, create a second log file and record the data of the task to be processed in the second log file.
[0064] In this embodiment, if the current time point is not within the time range for recording data in the first log file, the first log file can be directly closed, and a second log file can be created. The current time point is used as the starting time, and the starting time plus the single log file recording period (the recording period means that a single log folder only records the logs / data of pending tasks within the corresponding time of the period. For example, if the recording period is 30 minutes, it means that a single log folder only records logs within 30 minutes) is used as the end time. The start time and the end time are used as the time range for recording data in the second log file, and the second log file is named according to the time range for recording data in the second log file. The data of the pending tasks is written into the second log file to obtain the corresponding log information.
[0065] In some embodiments, if the current time point is within the time range of recording data in the first log file, detecting whether the size of the first log file after recording data exceeds the file storage threshold set for the first log file within the preset time range of recording data;
[0066] If the size of the first log file after recording the data exceeds the file storage threshold set for the first log file, a third log file is created, and the data of the task to be processed is recorded in the third log file.
[0067] Specifically, if the current time point is within the time range of the recorded data of the first log file, it can be calculated that within the preset time range of the recorded data, the size of the first log file after the recorded data is released exceeds the file storage threshold set for the first log file (which can be obtained in the configuration data). If it exceeds, the first log file can no longer write the data of the task to be processed. At this time, a third log file can be created, and the data of the task to be processed can be recorded in the third log file. The same as the second log file, the time range of the recorded data of the third log file is obtained, and the third log file is named according to the time range of the recorded data of the third log file, the data of the task to be processed is written into the third log file, and the corresponding log information is obtained.
[0068] In one embodiment, the pending tasks at the current time point within the preset time range of the recorded data can be recorded, and the pending tasks are taken as the first pending tasks; if the number of the first pending tasks is greater than the preset first threshold, the file storage threshold set for the log file is expanded.
[0069] Specifically, the number of the first tasks to be processed is greater than the preset first threshold. When the time range is less than the preset single-file recording time range for five consecutive times, it means that there are many logs that need to be recorded for the vehicle parts in the current period, that is, the number of tasks to be processed for the vehicle parts is large. At this time, the file storage threshold of the log file is dynamically adjusted according to the rules to avoid the creation of too many log files in a time period, affecting the device performance. Specifically, the file storage threshold can be expanded by an integer multiple to expand the file storage threshold set for the log file.
[0070] In some embodiments, the pending tasks in the log processing queue are processed separately, and if the pending tasks are processed multiple times in succession, the size of the first log file corresponding to the pending task after recording the data is greater than the file storage threshold set for the first log file, and the size of the first log file after recording the data is less than half of the file storage threshold, indicating that the vehicle parts have fewer files written to the log during the recording period, the recording period of the log file is dynamically adjusted to ensure that the size of each log file can reach saturation to avoid excessive file fragmentation. Specifically, the recording period of the log file can be expanded by an integer multiple to expand the recording period of the log file.
[0071] In this embodiment, a method of recording the data of the task to be processed is proposed. Through this method, it can be ensured that the log information of vehicle parts is stored, thereby improving the reliability of the log information. At the same time, it can reduce excessive log files and maximize the utilization of log recording resources.
[0072] Another aspect of the present application also provides a log recording device for vehicle parts, such as Figure 8 As shown, Figure 8 800 is a schematic diagram of a log recording device for a vehicle component according to an exemplary embodiment of the present application. The log recording device 800 includes:
[0073] The configuration parameter acquisition module 810 is used to acquire preset configuration parameters; wherein the configuration parameters include vehicle component identification and log storage path corresponding to the vehicle component.
[0074] The path acquisition module 830 is used to obtain the identification of the vehicle parts to be processed corresponding to the pending tasks in the log record queue, and match the corresponding target log storage path in the configuration parameters based on the identification of the vehicle parts to be processed.
[0075] The log recording module 850 is used to record the data of the task to be processed based on the target log storage path.
[0076] In an optional manner, the log recording device 800 further includes:
[0077] The quantity acquisition module is used to detect the number of log processing modules; wherein the log processing module is used to record the data corresponding to the task to be processed, and the number of log processing modules corresponds to the number of log recording queues.
[0078] The first queue processing module is used to transmit the task to be processed to the log record queue corresponding to the log processing module based on the transmission time of the task to be processed if the number of the log processing module is one.
[0079] The second queue processing module is used to transfer the to-be-processed task to the log record queue corresponding to one of the multiple log processing modules based on the task processing threshold corresponding to the log processing module if there are multiple log processing modules.
[0080] In an optional manner, the multiple log processing modules include a first log processing module; and the second queue processing module includes:
[0081] The first processing unit is configured to transfer the to-be-processed tasks to the log record queue corresponding to the first log processing module if the number of to-be-processed tasks in the log record queue corresponding to the first log processing module is less than a task processing threshold.
[0082] The second processing unit is used to initialize the log record queue corresponding to the second log processing module other than the first log processing module among multiple log processing modules if the number of pending tasks in the log record queue corresponding to the first log processing module is not less than the task processing threshold, and obtain the target log processing module based on the number of pending tasks in the log record queue corresponding to the first log processing module and the number of pending tasks in the log record queue corresponding to the log processing module, so as to transfer the pending tasks to the target log processing module.
[0083] In an optional manner, the path acquisition module 830 includes:
[0084] The transmission mode acquisition unit is used to acquire the transmission mode for transmitting the pending task to the log record queue.
[0085] The first identification acquisition unit is used to use the logical identification in the task to be processed as the identification of the vehicle component to be processed if the transmission mode is a mode of data transmission via Ethernet.
[0086] Second Identifier Acquisition If the transmission mode is a mode of transmitting data through a controller area network, the controller area network identifier in the task to be processed is used as the vehicle component identifier to be processed.
[0087] In an optional manner, the path acquisition module 830 includes:
[0088] The first log file detection unit is used to detect whether a first log file exists based on the target storage path; wherein the first log file is a log file that records data at a current time point, and the first log file includes a preset time range for recording data.
[0089] The time range detection unit is used to detect whether the current time point is within a preset time range for recording data if the first log file exists.
[0090] The second log file creation unit is used to create a second log file if the current time point is not within the time range of the recorded data in the first log file, and record the data of the task to be processed in the second log file.
[0091] In an optional manner, the path acquisition module 830 includes:
[0092] The file size detection unit is used to detect whether the size of the first log file after recording data exceeds the file storage threshold set for the first log file within the preset time range of the recorded data if the current time point is within the time range of the recorded data of the first log file.
[0093] The third log file creation unit is used to create a third log file if the size of the first log file after recording data exceeds the file storage threshold set for the first log file, and record the data of the task to be processed in the third log file.
[0094] In an optional manner, the path acquisition module 830 includes:
[0095] The first to-be-processed task acquisition unit is configured to take the to-be-processed task as the first to-be-processed task if the current time point is within a preset time range of the recorded data.
[0096] The file adjustment unit is used to increase the file storage threshold set for the log file if the number of the first tasks to be processed is greater than a preset first threshold.
[0097] The log recording device of the present application writes the pending task into the log processing queue, thereby writing the log to the data of the pending task based on the queue. In this process, the log storage path is obtained in the configuration data through the pending task to save the data corresponding to the pending task based on the log storage path, thereby avoiding the loss of log information and ensuring the reliability of log information.
[0098] It should be noted that the log recording device provided in the above embodiment and the log recording method provided in the above embodiment belong to the same concept, wherein the specific manner in which each module and unit performs operations has been described in detail in the method embodiment and will not be repeated here.
[0099] Another aspect of the present application provides an electronic device, including: a controller; a memory for storing one or more programs, and when the one or more programs are executed by the controller, the above-mentioned logging method is executed.
[0100] See also Fig. 9 , Fig. 9 1 is a schematic diagram of the structure of a computer system of an electronic device shown in an exemplary embodiment of the present application, which shows a schematic diagram of the structure of a computer system of an electronic device suitable for implementing an embodiment of the present application.
[0101] It should be noted that Fig. 9 The computer system 900 of the electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0102] like Fig. 9 As shown, the computer system 900 includes a central processing unit (CPU) 901, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 902 or the program loaded from the storage part 908 to the random access memory (RAM) 903, such as executing the method in the above embodiment. In the RAM 903, various programs and data required for system operation are also stored. The CPU 901, ROM 902 and RAM 903 are connected to each other through a bus 904. An input / output (I / O) interface 905 is also connected to the bus 904.
[0103] The following components are connected to the I / O interface 905: an input section 906 including a keyboard, a mouse, etc.; an output section 907 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker; a storage section 908 including a hard disk, etc.; and a communication section 909 including a network interface card such as a LAN (Local Area Network) card, a modem, etc. The communication section 909 performs communication processing via a network such as the Internet. A drive 910 is also connected to the I / O interface 905 as needed. A removable medium 911, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 910 as needed so that a computer program read therefrom is installed into the storage section 908 as needed.
[0104] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a computer program for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication section 909, and / or installed from a removable medium 911. When the computer program is executed by a central processing unit (CPU) 901, various functions defined in the system of the present application are executed.
[0105] It should be noted that the computer-readable medium shown in the embodiment of the present application can be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium can be, for example, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media can include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a flash memory, an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable storage medium can be any tangible medium containing or storing a program, which can be used by an instruction execution system, device or device or used in combination with it. In the present application, a computer-readable signal medium can include a data signal propagated in a baseband or as a part of a carrier wave, wherein a computer-readable computer program is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate, or transmit programs for use by or in conjunction with an instruction execution system, apparatus, or device. The computer program contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.
[0106] The flowchart and block diagram in the accompanying drawings illustrate the possible architecture, functions and operations of the system, method and computer program product according to various embodiments of the present application. Wherein, each box in the flowchart or block diagram can represent a module, a program segment, or a part of the code, and the above-mentioned module, program segment, or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order than the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0107] The units involved in the embodiments described in this application may be implemented by software or hardware, and the units described may also be set in a processor. The names of these units do not, in some cases, constitute limitations on the units themselves.
[0108] Another aspect of the present application also provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, the log recording method as described above is implemented. The computer-readable storage medium can be included in the electronic device described in the above embodiment, or it can exist independently without being assembled into the electronic device.
[0109] Another aspect of the present application also provides a computer program product or a computer program, which includes a computer instruction stored in a computer-readable storage medium. A processor of a computer device reads the computer instruction from the computer-readable storage medium, and the processor executes the computer instruction, so that the computer device executes the logging method provided in each of the above embodiments.
[0110] According to one aspect of an embodiment of the present application, a computer system is also provided, including a central processing unit (CPU), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) or a program loaded from a storage portion into a random access memory (RAM), such as executing the method in the above embodiment. In RAM, various programs and data required for system operation are also stored. CPU, ROM and RAM are connected to each other via a bus. An input / output (I / O) interface is also connected to the bus.
[0111] The following components are connected to the I / O interface: an input part including a keyboard, a mouse, etc.; an output part including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker; a storage part including a hard disk, etc.; and a communication part including a network interface card such as a LAN (Local Area Network) card, a modem, etc. The communication part performs communication processing via a network such as the Internet. A drive is also connected to the I / O interface as needed. Removable media, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., are installed on the drive as needed so that the computer program read therefrom is installed into the storage part as needed.
[0112] The above content is only a preferred exemplary embodiment of the present application and is not intended to limit the implementation scheme of the present application. A person skilled in the art can easily make corresponding changes or modifications based on the main concept and spirit of the present application. Therefore, the scope of protection of the present application shall be based on the scope of protection required by the claims.
Claims
1. A log recording method for vehicle parts, characterized in that: The logging method includes: Obtaining preset configuration parameters; wherein the configuration parameters include vehicle component identification and log storage path corresponding to the vehicle component; Obtaining the identification of the vehicle parts to be processed corresponding to the pending tasks in the log record queue, and matching the corresponding target log storage path in the configuration parameters based on the identification of the vehicle parts to be processed; Recording the data of the task to be processed based on the target log storage path; Before obtaining the identification of the to-be-processed vehicle parts corresponding to the to-be-processed tasks in the log recording queue, the log recording method further includes: Detect the number of log processing modules; wherein the log processing modules are used to record the data corresponding to the tasks to be processed, and the number of the log processing modules corresponds to the number of the log recording queues; If the number of the log processing module is one, based on the transmission time of the task to be processed, the task to be processed is transmitted to the log record queue corresponding to the log processing module; If there are multiple log processing modules, based on the task processing threshold corresponding to the log processing module, the to-be-processed task is transmitted to a log record queue corresponding to one of the multiple log processing modules.
2. The log recording method according to claim 1, characterized in that: The plurality of log processing modules include a first log processing module; the task to be processed is transmitted to a log record queue corresponding to a log processing module in the plurality of log processing modules based on a task processing threshold corresponding to the log processing module, further comprising: If the number of pending tasks in the log record queue corresponding to the first log processing module is less than the task processing threshold, the pending tasks are transmitted to the log record queue corresponding to the first log processing module; If the number of pending tasks in the log record queue corresponding to the first log processing module is not less than the task processing threshold, then initialize the log record queue corresponding to the second log processing module other than the first log processing module among the multiple log processing modules, and based on the number of pending tasks in the log record queue corresponding to the first log processing module and the number of pending tasks in the log record queue corresponding to the log processing module, obtain the target log processing module to transfer the pending tasks to the target log processing module.
3. The log recording method according to claim 1, characterized in that: The step of obtaining the identification of the vehicle parts to be processed corresponding to the tasks to be processed in the log record queue further includes: Obtaining a transmission method for transmitting the pending task to the log record queue; If the transmission mode is a mode of data transmission via Ethernet, the logical identifier in the task to be processed is used as the identifier of the vehicle component to be processed; If the transmission mode is a mode of transmitting data through a controller area network, the controller area network identifier in the task to be processed is used as the identifier of the vehicle component to be processed.
4. The log recording method according to claim 1, characterized in that: The step of recording the data of the task to be processed based on the target log storage path further includes: Detecting whether a first log file exists based on the target storage path; wherein the first log file is a log file that records data at a current time point, and the first log file includes a preset time range for recording data; If the first log file exists, detecting whether the current time point is within the preset time range of the recorded data; If the current time point is not within the time range of the recorded data of the first log file, a second log file is created, and the data of the task to be processed is recorded in the second log file.
5. The log recording method according to claim 4, characterized in that: After detecting whether the current time point is within the preset time range for recording data, the log recording method further includes: If the current time point is within the time range of the recorded data of the first log file, detecting whether the size of the first log file after recording the data exceeds the file storage threshold set for the first log file within the preset time range of the recorded data; If the size of the first log file after recording the data exceeds the file storage threshold set for the first log file, a third log file is created, and the data of the task to be processed is recorded in the third log file.
6. The log recording method according to claim 4, characterized in that: After detecting whether the current time point is within the preset time range for recording data, the log recording method further includes: If the current time point is within the preset time range of the recorded data, the task to be processed is taken as the first task to be processed; If the number of the first tasks to be processed is greater than a preset first threshold, the file storage threshold set for the log file is increased.
7. A log recording device for vehicle parts, characterized in that: The log recording device comprises: A configuration parameter acquisition module, used to acquire preset configuration parameters; wherein the configuration parameters include vehicle component identification and log storage path corresponding to the vehicle component; A path acquisition module, used to obtain the identification of the vehicle parts to be processed corresponding to the pending tasks in the log record queue, and match the corresponding target log storage path in the configuration parameters based on the identification of the vehicle parts to be processed; A log recording module, used for recording the data of the task to be processed based on the target log storage path; A quantity acquisition module, used to detect the number of log processing modules; wherein the log processing module is used to record the data corresponding to the task to be processed, and the number of the log processing modules corresponds to the number of the log recording queues; A first queue processing module, configured to transmit the to-be-processed task to the log record queue corresponding to the log processing module based on the transmission time of the to-be-processed task if the number of the log processing module is one; The second queue processing module is used to transfer the to-be-processed task to a log record queue corresponding to one of the multiple log processing modules based on a task processing threshold corresponding to the log processing module if there are multiple log processing modules.
8. An electronic device, characterized in that: include: Controller; A memory for storing one or more programs, which, when executed by a controller, enables the controller to implement the logging method described in any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that: Computer-readable instructions are stored thereon, and when the computer-readable instructions are executed by a processor of a computer, the computer is caused to execute the logging method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Vehicle-mounted log recording method and device and controller
CN115712539A