Log collection method of vehicle-mounted system and related product
By automatically identifying and processing the serial port connection information of the vehicle system, the self-starting and automatic recovery of the vehicle system logs are realized, which solves the problems of low log collection efficiency and poor stability in the existing technology, improves the collection efficiency and stability, and supports multiple People share log data.
Patent Information
- Application Number
- CN202410746483.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-11
- Publication Date
- 2024-08-23
AI Technical Summary
The existing in-vehicle system log collection method is inefficient and requires manual intervention. It is easy to cause collection failure due to system compatibility issues, and the log information is easily lost, affecting work efficiency.
Identify the serial port connection information of each output log processing device in the vehicle system through the kernel log message of the log collection device, automatically generate a serial communication path, realize self-starting and automatic recovery of log collection, and use blocking read calls to improve collection efficiency and Stability, and flexible management and sharing of data through log saving queues and databases.
It improves the efficiency and stability of log collection, reduces manual intervention, ensures the integrity and reliability of logs, and enables multiple people to share and view log data at the same time.
Smart Images

Figure CN118535442A
Abstract
Description
Technical Field
[0001] The present invention relates to automotive electronic equipment, and in particular to a log collection method for an on-board system and related products. Background Art
[0002] With the development of vehicle intelligence, various types of on-board electronic devices are becoming more and more complex. In the development and testing stage, in order to locate and analyze problems, it is necessary to collect various logs, such as the log information output by the serial ports of the vehicle system MCU, ECU, BIOS and other modules. The existing collection method is to use a computer to connect to the debugging board for real-time collection, otherwise the log will be lost. The system log cache on the vehicle can generally only save information within a period of time in the past (for example, about 30 minutes). If it is not exported in time, it will be overwritten by new content. When the problem recurs for a long time, it is necessary to manually trigger the export regularly to ensure the integrity of the log. Based on the above situation, dedicated debugging personnel are required to follow the vehicle to collect logs, and the manpower investment is relatively large.
[0003] In addition, the log collection conditions in the real vehicle environment are extremely unstable, and it is easy to encounter various problems that lead to collection failures, and frequent manual intervention is required to ensure the normal operation of log collection. For example, when the debug board for serial port log collection is connected to the computer, a special device driver needs to be installed, and system compatibility and other problems may occur. The serial port wiring is often plugged and unplugged, which will cause the log collection to be interrupted. After the wiring is restored, it needs to be manually restored in the collection software. Every time the debug board or computer is replaced, the collection software must be configured again before it can be used normally. Once the power of the entire vehicle is cut off, the collection software on the computer also needs to be manually reconnected before it can continue to be used. Some log information requires manual input of commands to open the corresponding debugging options in order to be collected, and it must be entered every time the vehicle is restarted.
[0004] In addition, since there are many interfaces that need to collect logs, a lot of records and configurations are required to determine the devices connected to each serial port. In the on-site working environment, there are many cables, which are prone to problems such as misplugging and configuration errors, which also seriously affects work efficiency. Summary of the invention
[0005] One purpose of the present invention is to intelligently identify the serial port access of each processing device that outputs logs in a vehicle-mounted system, realize automatic log collection and storage, and improve collection work efficiency.
[0006] A further object of the present invention is to achieve automatic recovery of anomalies that occur during the collection process, thereby improving the stability and reliability of log collection.
[0007] Another purpose of the present invention is to enable multiple people to simultaneously share and view the collected logs, thereby improving the interactive capability.
[0008] In particular, the present invention provides a log collection method for a vehicle-mounted system. The method comprises:
[0009] Get the kernel log messages of the log collection device;
[0010] Using the preset serial port keywords to perform line-by-line matching in the kernel log message, the serial port connection information is extracted, and the serial port connection information can identify the processing device of each output log in the vehicle system;
[0011] Generate a serial communication path according to serial port connection information;
[0012] Open the serial communication path, and send corresponding configuration parameters to the serial communication interface corresponding to the serial communication path;
[0013] Collect and save log data provided by the serial communication interface.
[0014] Optionally, the step of sending corresponding configuration parameters to a serial communication interface corresponding to the serial communication path includes:
[0015] Get the identifier provided by the serial communication interface;
[0016] Matches the identifier with predefined identifiers;
[0017] In the case of successful matching, the configuration parameters corresponding to the serial communication interface are sent to the serial communication interface, so that the serial communication interface enters a waiting state for reading and writing.
[0018] Optionally, the step of collecting and saving log data provided by the serial communication interface includes:
[0019] Use the serial port read / write thread to execute a blocking read call on the serial communication interface that has entered the waiting read / write state;
[0020] After the serial port reading and writing thread reads the data from the serial communication interface, it sends the data to the preset log saving queue;
[0021] Write the data of the log storage queue into the corresponding log file.
[0022] Optionally, the step of writing the data of the log storage queue into a corresponding log file includes:
[0023] Get the preset log storage parameters, which specify the size threshold of the log file;
[0024] Read data from the log storage queue and determine the target log file corresponding to the read data;
[0025] Determine whether the size of the target log file is greater than the size threshold of the log file;
[0026] If not, the read data is written into the target log file;
[0027] If so, archive the target log file in the set archive directory, create a new log file and write the read data.
[0028] Optionally, the log storage parameter further specifies a threshold value for the number of archived files and a threshold value for the capacity of the archive directory; and
[0029] Before archiving the target log file in the set archive directory, the following steps are also included:
[0030] Check whether the number of archived files in the archive directory is greater than or equal to the number threshold or whether the file size in the archive directory is greater than or equal to the capacity threshold;
[0031] If any judgment result is yes, the archive file with the oldest archive time is deleted from the archive directory.
[0032] Optionally, after the serial port reading and writing thread reads the data from the serial communication interface, the step further includes:
[0033] Match the read data line by line with the preset startup keywords;
[0034] If the match is successful, the configuration parameters are rewritten to the serial communication interface.
[0035] Optionally, the process of using the serial port read / write thread to execute a blocking read call on the serial communication interface that enters the waiting read / write state also includes:
[0036] Determine whether a call error occurs;
[0037] If so, reopen the serial communications path.
[0038] Optionally, the process of using the serial port read / write thread to execute a blocking read call on the serial communication interface that enters the waiting read / write state also includes:
[0039] Determine whether a call timeout occurs;
[0040] If so, re-obtain the kernel log message of the log collection device;
[0041] Check the kernel log message to see if there is any error message about the serial communication interface;
[0042] If it exists, reload the driver of the serial communication interface;
[0043] If not present, returns a blocking read call.
[0044] Optionally, after the step of collecting and saving the log data provided by the serial communication interface, the method further includes:
[0045] Establishing and maintaining a log database corresponding to the identification of the serial communication interface;
[0046] Establishing a network connection with a log viewing device;
[0047] Receiving a log request from a log viewing device, the log request at least including an identifier of a serial communication interface;
[0048] The data of the log database is provided to the log viewing device according to the log request.
[0049] According to another aspect of the present invention, a log collection device for a vehicle-mounted system is also provided, which includes a processor, a memory, and multiple serial communication ports. A computer program is stored in the memory, and when the computer program is executed by the processor, the steps of any of the above-mentioned log collection methods for the vehicle-mounted system are implemented.
[0050] According to another aspect of the present invention, a log collection system for a vehicle-mounted system is also provided. The log collection system comprises:
[0051] The debugging box is connected to the processing devices of the output logs and the log collection device in the vehicle system through the serial port;
[0052] The log collection device is a log collection device according to the above-mentioned vehicle-mounted system. The log collection device also includes a network connection port, and is connected to the system data transmission port of the vehicle-mounted system through the network connection port to obtain the system log data of the vehicle-mounted system.
[0053] According to another aspect of the present invention, a computer program product is provided, which includes a computer program. When the computer program is executed by a processor, the steps of any of the above-mentioned log collection methods for an in-vehicle system are implemented.
[0054] The log collection method for the vehicle-mounted system of the present invention utilizes the kernel log message of the log collection device to identify the serial port connection information of each processing device of the output log in the vehicle-mounted system, that is, the kernel log of the log collection device is used to automatically identify the connected serial port and determine the corresponding device, thereby eliminating the need for manual serial port identification and configuration. After identifying the serial port connection information, the method generates and opens a serial communication path according to the serial port connection information, automatically sends corresponding configuration parameters to the serial communication interface corresponding to the serial communication path, realizes the self-start of log collection, and does not need to manually send log collection instructions, thereby greatly improving the efficiency of log collection.
[0055] Furthermore, the log collection method of the vehicle-mounted system of the present invention can comprehensively consider the real-time performance and resource occupation of log collection when the serial communication interface enters the waiting read and write state and executes the blocking read call. When processing the data of the log storage queue, the log distribution can be automatically realized and saved according to the device that generates the log.
[0056] Furthermore, the log collection method of the vehicle-mounted system of the present invention can set the size threshold of the log file, the number threshold of the archived files, and the capacity threshold of the archive directory as needed, so as to realize the flexible generation of log files, effectively avoid the loss of logs and the automatic cleaning of expired data.
[0057] Furthermore, the log collection method of the vehicle-mounted system of the present invention can identify restart events based on the power-on keywords in the log, and perform targeted processing on call errors and call timeouts, so that it can automatically recover from abnormalities such as disconnection of the serial port connection and restart of the vehicle system without manual intervention, thereby improving the stability and reliability of log collection.
[0058] Furthermore, the log collection method of the vehicle-mounted system of the present invention also improves the interaction mode with the log output device, establishes a network connection with the log viewing device, provides log data according to the log request, can be used by multiple log clients, and retrieve data at the same time, thereby realizing timely sharing of logs.
[0059] Based on the following detailed description of specific embodiments of the present invention in conjunction with the accompanying drawings, those skilled in the art will become more aware of the above and other objects, advantages and features of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0060] Hereinafter, some specific embodiments of the present invention will be described in detail in an exemplary and non-limiting manner with reference to the accompanying drawings. The same reference numerals in the accompanying drawings indicate the same or similar components or parts. It should be understood by those skilled in the art that these drawings are not necessarily drawn to scale. In the accompanying drawings:
[0061] Figure 1 is a schematic diagram of device connection of a log collection system of a vehicle-mounted system according to an embodiment of the present invention;
[0062] Figure 2 is a schematic diagram of a log collection method for a vehicle-mounted system according to an embodiment of the present invention;
[0063] Figure 3 is a flow chart of generating and opening a serial communication path in a log collection method of a vehicle-mounted system according to an embodiment of the present invention;
[0064] Figure 4 is a flow chart of sending configuration parameters in a log collection method of a vehicle-mounted system according to an embodiment of the present invention;
[0065] Figure 5 is a flow chart of distributing log data in a log collection method for a vehicle-mounted system according to an embodiment of the present invention;
[0066] Figure 6 is a flowchart of archiving log data in a log collection method of a vehicle-mounted system according to an embodiment of the present invention;
[0067] Figure 7 is a flowchart of abnormality detection and automatic recovery in a log collection method for a vehicle-mounted system according to an embodiment of the present invention;
[0068] Figure 8 is a flow chart of providing data to an output device in a log collection method of a vehicle-mounted system according to an embodiment of the present invention;
[0069] Fig. 9 is a flow chart of sharing log data in a log collection method of a vehicle-mounted system according to an embodiment of the present invention;
[0070] Fig.10 is a schematic diagram of a log display interface in a log collection method for a vehicle-mounted system according to an embodiment of the present invention;
[0071] Fig.11 is a schematic diagram of a computer program product according to an embodiment of the present invention;
[0072] Fig.12 is a schematic diagram of a computer-readable storage medium according to an embodiment of the present invention;
[0073] Fig.13 is a schematic diagram of a log collection device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0074] The embodiments of the present invention provide a log collection method for a vehicle-mounted system and corresponding log collection equipment, log collection system, and computer program products for the vehicle-mounted system, which are used to realize the automatic collection and storage of logs of various processing devices in the vehicle-mounted system and the vehicle-mounted system.
[0075] Figure 1: This is a device connection diagram of a log collection system of a vehicle-mounted system according to an embodiment of the present invention. As shown in the figure, the log collection device 30 is connected to the vehicle-mounted system 10 through the debugging box 20, and is directly connected to the vehicle-mounted system 10. The vehicle-mounted system 10 may include multiple domain controllers (Domain Hub Unit, DHU for short) such as MCU, EC, APU, etc. These DHUs have serial ports respectively, and can output log data through the serial ports, that is, the vehicle-mounted system 10 has multiple processing devices that output logs through serial ports, and these processing devices include multiple DHUs such as MCU, EC, APU, etc. The log collection device 30 can use an electronic device with a certain data processing capability equipped with an operating system, and has multiple serial communication ports. In some embodiments, the log collection device 30 can be implemented through secondary development through Raspberry Pi or other similar electronic devices.
[0076] The debugging box 20 can be connected to each log output processing device and the log collection device 30 in the vehicle system 30 through the serial port. The log output processing device includes multiple DHUs such as MCU, EC, APU, etc. in the vehicle system 30, and its log data volume is relatively small, so the log data is transmitted by serial port. Therefore, the debugging box 20 is connected to each log output processing device in the vehicle system through the serial port.
[0077] The log collection device 30 is also provided with a network connection port, and is connected to the system data transmission port of the vehicle-mounted system 10 through the network connection port to obtain the system log data of the vehicle-mounted system 10. The system log of the vehicle-mounted system 10, such as the operating system log, has a relatively large amount of data, and is transmitted through the network connection using the system data transmission port. The network connection port of the log collection device 30 can obtain the system log data of the vehicle-mounted system 10 through RJ45 or other methods. In other words, the log collection device 30 can be directly connected to the system data transmission port of the vehicle-mounted system 10 through a network connection port such as RJ45, thereby obtaining the operating system log of the vehicle-mounted system 10.
[0078] The log viewing device 40 may be a computer device such as a personal computer, a tablet computer, a notebook computer, etc., which may be connected to the log collection device 30 via a network to output and / or analyze the log data stored in the log collection device 30 .
[0079] After completing the cable connection of the log collection device 30, the log collection device 30 can complete the log collection work of the vehicle-mounted system by executing the computer program.
[0080] In an optional embodiment, the vehicle system 10 includes multiple DHUs such as MCU, EC, APU, etc., which output their respective logs through serial ports. In addition, the vehicle system 10 itself can also have a system data transmission port in the form of a network interface, and output the operating system log through the system data transmission port. On the one hand, the log collection device 30 is connected to multiple serial ports of the vehicle system 10 through the debugging box 20, so as to obtain the logs of the processing devices such as MCU, EC, APU, etc.; on the other hand, the log collection device 30 is directly connected to the system data transmission port of the vehicle system 10 through a network connection port such as RJ45, so as to obtain the operating system log of the vehicle system 10.
[0081] A main purpose of the solution of this embodiment is to intelligently identify the serial port access of each processing device that outputs logs in the vehicle-mounted system 10, realize automatic log collection and storage, and improve the efficiency of collection work.
[0082] Figure 2 is a schematic diagram of a log collection method for a vehicle-mounted system according to an embodiment of the present invention. The log collection method for the vehicle-mounted system may generally include the following steps:
[0083] Step S201, obtain the kernel log message of the log collection device. In the case of using Raspberry Pi or other similar electronic devices to develop the log collection device, the kernel log message can be a dmesg log. The dmesg log can output the information generated by the system kernel, which can reflect the events, hardware configuration information, driver information and abnormal error information that occurred during the system startup process. When the log collection device has a serial communication interface connected, the content of the dmesg log will be reflected. The above dmesg log is only an example, and those skilled in the art can obtain the corresponding system kernel message according to the system type of the log collection device. The above kernel log message can be accompanied by a timestamp. After the log collection device is started, the incremental kernel log after the kernel log message was obtained last time is obtained according to the timestamp, and the newly connected serial port is promptly identified.
[0084] Step S202, using the preset serial port keywords to perform line-by-line matching in the kernel log message, and extract the serial port connection information. The serial port connection information can identify the processing device of each output log in the vehicle system. The above serial port keywords can be configured according to the serial port information of the vehicle-mounted devices such as MCU, EC, APU, etc., and the serial port connection information of the above vehicle-mounted devices can be determined through these serial port keywords, so as to determine which serial port device each connected serial port is connected to.
[0085] Step S203, generating a serial communication path according to the serial port connection information. The serial communication path can be generated by a predetermined prefix and the serial port connection information obtained by the above matching.
[0086] Step S204, open the serial communication path, and send corresponding configuration parameters to the serial communication interface corresponding to the serial communication path. The configuration parameters can be configured according to the serial port log output characteristics of the vehicle-mounted device, for example, they can include log request information, log startup information, log configuration information, etc.
[0087] Step S205, collecting and saving log data provided by the serial communication interface.
[0088] The log collection method for the vehicle-mounted system of the above-mentioned embodiment uses the kernel log message of the log collection device to identify the serial port connection information of each processing device that outputs the log in the vehicle-mounted system, that is, the kernel log of the log collection device is used to automatically identify the connected serial port and determine the corresponding device, thereby eliminating the need for manual serial port identification and configuration. After identifying the serial port connection information, the method generates and opens a serial communication path according to the serial port connection information, automatically sends corresponding configuration parameters to the serial communication interface corresponding to the serial communication path, realizes the self-start of log collection, and does not need to manually send log collection instructions, which greatly improves the efficiency of log collection.
[0089] Figure 3 This is a flow chart of generating and opening a serial communication path in a log collection method for a vehicle-mounted system according to an embodiment of the present invention. The flow may include:
[0090] Step S301: The log collection device starts to run log collection. The log collection device can automatically start to run log collection after startup.
[0091] Step S302, obtaining kernel log messages of the log collection device. The log collection device can poll dmesg log information after startup by default. The kernel log message has a timestamp, so that the incremental kernel log message can be processed according to the timestamp.
[0092] Step S303, matching kernel log messages using serial port keywords. The serial port keywords are set according to the prompts and feature information models of devices such as MCU, EC, APU, etc.
[0093] Step S304, determining whether there is serial port connection information.
[0094] Step S305, if there is serial port connection information, generate a UART path through the serial port connection information. For example, a UART path string can be generated through a predefined fixed prefix and the serial port connection information. UART (Universal Asynchronous Receiver / Transmitter) is a universal asynchronous receiver / transmitter transmission port, which is a way of performing asynchronous serial communication between devices. The serial communication interface in this embodiment can be a UART interface. The UART path can be used to associate the serial port with the services of devices such as MCU, EC, APU, etc.
[0095] Step S306, determining whether the path is generated correctly.
[0096] Step S307: When it is determined that the path is correctly generated, the UART path is opened.
[0097] Step S308, determining whether the path is opened successfully.
[0098] Step S309: If the path is successfully opened, it is determined that the UART is in the first opening state.
[0099] The above process can determine the serial port connection through system kernel log messages such as dmesg and open the serial port path.
[0100] The step of sending corresponding configuration parameters to the serial communication interface corresponding to the serial communication path in the method of the above embodiment may include: obtaining an identifier provided by the serial communication interface; matching the identifier with a predefined identifier; and if the match is successful, sending the configuration parameters corresponding to the serial communication interface to the serial communication interface, so that the serial communication interface enters a waiting state for reading and writing.
[0101] Figure 4 This is a flow chart of sending configuration parameters in a log collection method for a vehicle-mounted system according to an embodiment of the present invention. The flow may include:
[0102] Step S401, UART is in an open state;
[0103] Step S402, obtaining a serial port data from the UART;
[0104] Step S403, determining whether the data is acquired successfully;
[0105] Step S404, matching the successfully acquired serial port data with a predefined identifier;
[0106] Step S405, determining whether the match is successful;
[0107] Step S406, if the match is successful, obtaining the configuration parameters of the UART interface, which are pre-configured according to the log output requirements of the device connected to the serial port;
[0108] Step S407, determining whether the configuration parameter acquisition is successful;
[0109] Step S408, sending configuration parameters to the UART interface;
[0110] Step S409, determining whether the sending and acquisition is successful;
[0111] Step S410, when the transmission is successful, the UART interface enters a waiting state for reading and writing.
[0112] Through the above process, serial port parameters can be automatically configured without manual configuration, which improves collection efficiency and reduces the workload of operators.
[0113] The steps of collecting and saving log data provided by the serial communication interface in the method of the above embodiment may include: using the serial port read and write thread to execute a blocking read call on the serial communication interface that has entered a waiting read and write state; after the serial port read and write thread reads the data from the serial communication interface, the data is sent to a preset log saving queue; and the data in the log saving queue is written into a corresponding log file.
[0114] Among them, after the serial port reading and writing thread reads the data of the serial communication interface, the steps may also include: matching the read data line by line with the preset power-on keyword; if the match is successful, rewriting the configuration parameters to the serial communication interface, so that when the device of the vehicle system is restarted or rebooted, the serial port collection work is restored in time.
[0115] Figure 5 This is a flow chart of distributing log data in a log collection method for a vehicle-mounted system according to an embodiment of the present invention. The process may include:
[0116] Step S501, the UART interface enters a waiting state for reading and writing;
[0117] Step S502, executing a blocking read call, in which the read thread is suspended until the read operation is completed or certain specific conditions are met (for example, after a set size of data is read). The blocking read call can save resources and improve the reading efficiency.
[0118] Step S503, read serial port data;
[0119] Step S504, the read data is sent to the log storage queue;
[0120] Step S505, analyzing whether the read data matches the power-on keyword, that is, determining whether the device connected to the serial port is restarted, and if it is determined to be restarted, the configuration parameters of the UART need to be re-input;
[0121] Step S506, when the power-on keyword is matched, obtaining the configuration parameters of the UART interface;
[0122] Step S507, the configuration parameters are sent to the input queue, which finally stores the data sent by the log collection device to the serial port, such as log call instruction data, serial port configuration parameters, etc.;
[0123] Step S508, reading data in the input queue;
[0124] Step S509, determining whether the input queue data is read successfully;
[0125] Step S510, checking whether the target serial port is in a readable and writable state;
[0126] Step S511, writing the data read from the input queue into the UART interface.
[0127] Through the above process, the log collection function can be automatically restored when the device whose logs are being collected is restarted.
[0128] The step of writing the data in the log storage queue to the corresponding log file in the method of this embodiment may include: obtaining a preset log storage parameter, which specifies a size threshold of the log file; reading data from the log storage queue and determining a target log file corresponding to the read data; judging whether the size of the target log file is greater than the size threshold of the log file; if not, writing the read data to the target log file; if so, archiving the target log file in a set archiving directory, creating a new log file and writing the read data.
[0129] In some embodiments, the log storage parameters further specify a number threshold of archived files and a capacity threshold of the archive directory; and before archiving the target log file in the set archive directory, the method further includes: checking whether the number of archived files in the archive directory is greater than or equal to the number threshold or whether the file size in the archive directory is greater than or equal to the capacity threshold; if any of the judgment results is yes, deleting the archived file with the oldest archive time from the archive directory. Using the log storage parameters, the size of the log file can be flexibly configured and automatically cleared.
[0130] Figure 6 This is a flow chart of archiving log data in a log collection method for a vehicle-mounted system according to an embodiment of the present invention. The process may include:
[0131] Step S601, reading log storage parameters from a configuration file, where the log storage parameters may specify a threshold for the number of archived files, a threshold for the capacity of an archive directory, and a threshold for the size of a log file;
[0132] Step S602, blocking the log storage queue for reading;
[0133] Step S603, checking whether the block has read new data;
[0134] Step S604, determining a log saving path according to the identifier of the UART, where the log saving path may include a path of a target log file and a set archive directory. In this embodiment, a corresponding log saving path may be set for each UART;
[0135] Step S605, determining the target log file according to the log saving path;
[0136] Step S606, determining whether the target log file size exceeds the limit, that is, determining whether the size of the target log file is greater than the size threshold of the log file;
[0137] Step S610, when the target log file size exceeds the limit, archiving the target log file in a set archiving directory;
[0138] Step S611, whether the number of files in the archive directory exceeds the limit, that is, checking whether the number of archive files in the archive directory is greater than or equal to the number threshold;
[0139] Step S612, whether the capacity of the archive directory exceeds the limit, that is, checking whether the file size in the archive directory is greater than or equal to the capacity threshold;
[0140] Step S613: If the number of files in the archive directory exceeds the limit or the capacity of the archive directory exceeds the limit, the archive file with the oldest archive time is deleted;
[0141] Step S614: writing data into the target log file.
[0142] Through the above process, the size of log files and archive files can be managed under control, avoiding excessive space usage or log loss.
[0143] The method of this implementation can also detect abnormalities in the log collection device and automatically recover. For example, in the process of using the serial port read and write thread to execute a blocking read call on a serial communication interface that has entered a waiting read and write state, it can also include: determining whether a call error occurs; if so, reopening the serial communication path; and determining whether a call timeout occurs; if so, re-obtaining the kernel log message of the log collection device; checking whether there is error information about the serial communication interface in the kernel log message; if so, reloading the driver of the serial communication interface; if not, returning to execute the blocking read call.
[0144] Figure 7 This is a flow chart of abnormality detection and automatic recovery in a log collection method for a vehicle-mounted system according to an embodiment of the present invention. The process may include:
[0145] Step S701, the UART interface enters a waiting state for reading and writing;
[0146] Step S702, executing a blocking read call;
[0147] Step S703, a serial port line disconnection event occurs, for example, the serial port line is unplugged;
[0148] Step S704, blocking the read call and returning an error;
[0149] Step S711, a vehicle system restart event occurs;
[0150] Step S712, blocking the read call and returning a timeout;
[0151] Step S713, re-obtaining dmesg message;
[0152] Step S714, determining whether there is serial port error information in the dmesg incremental message;
[0153] Step S715, reload the module driver;
[0154] Step S716, reopen the UART path.
[0155] Through the above process, abnormalities in the serial port connection can be discovered in time and automatically restored, which improves the reliability of log collection. That is, if the vehicle restarts during the continuous execution of the blocking read call, the abnormality can be discovered by checking whether there is a specific error in the dmesg log information after the single blocking read call execution times out, and the error can be restored by reloading the serial port driver, and then by re-identifying the multiple UART interfaces and opening the UART path node, the UART path can be opened. Figure 3 It has been introduced in , so I won’t repeat it here.
[0156] The method of this embodiment may further include, after the step of collecting and saving the log data provided by the serial communication interface: establishing and maintaining a log database corresponding to the identifier of the serial communication interface; establishing a network connection with a log viewing device; receiving a log request from the log viewing device, the log request including at least the identifier of the serial communication interface; and providing data in the log database to the log viewing device according to the log request, thereby realizing log sharing.
[0157] Figure 8 This is a flow chart of providing data to an output device in a log collection method of a vehicle-mounted system according to an embodiment of the present invention. The flow may include:
[0158] Step S801, the log viewing device is connected to the log collection device through a network. The log viewing device may be a terminal device such as a personal computer, a tablet computer, a mobile phone, etc. The network connection may be a dedicated network (such as a wireless network access point (Wi-Fi AP) provided by the log viewing device) or a wireless Internet or a local area network;
[0159] Step S802: The client initiates a log request. For example, the client may be a browser of a log viewing device.
[0160] Step S803: Check whether the server of the log collection device receives the log request. If not, the process ends.
[0161] In step S804, the server establishes and maintains a websocket connection with the client. For example, the log collection device provides services as the server, and the browser and other clients establish a websocket link with the server. When switching to the page of the log viewing device, the client sends the required UART interface identifier to the server, and the server maintains a database of the correspondence between websocket requests and UART identifiers.
[0162] Step S805, the server records the UART identifier of the connection corresponding request;
[0163] Step S806, establishing a link with the server log database, that is, establishing a database session;
[0164] Step S807: Whether the client switches the required UART identifier;
[0165] Step S808, if switched, the server updates the corresponding UART identifier in the link session database;
[0166] Step S809, obtaining the input data of the client, that is, determining the required log data;
[0167] Step S810, the client sends input data to the server via the websocket connection;
[0168] Step S811, the server puts the reply data into the reply queue, and the server puts the reply data into the reply queue to wait for processing. When multiple users request the same UART and make input requests at the same time, the server receives the message and puts it into the queue in a serialized manner, ensuring that the message will not be lost.
[0169] Fig. 9 This is a flow chart of sharing log data in a log collection method of a vehicle-mounted system according to an embodiment of the present invention. The process may include:
[0170] Step S901: Block the read log storage queue
[0171] Step S902: whether a new message is received;
[0172] Step S903, querying the link session database;
[0173] Step S904: whether the requested serial port identifier is matched;
[0174] Step S905: Send data to each matching link
[0175] Step S906: The client display page is refreshed in real time to display the received data.
[0176] The above process enables multiple clients to share and display UART logs in real time. The server uses a working thread to monitor the log storage queue. When a new message is received, it will query the database of the corresponding relationship between the websocket connection and the UART identifier. If the connection corresponding to the UART identifier is found, the data will be sent to each connection. All clients that request the UART interface can receive the same data and immediately update the page display, realizing the real-time sharing function for multiple people.
[0177] The log collection device can remotely debug the UART interface, input commands in real time and obtain results through the above interaction with the client. And all the interactive data are saved in the log file for subsequent tracing.
[0178] Fig.10 This is a schematic diagram of a log display interface in a log collection method for a vehicle-mounted system according to an embodiment of the present invention. This schematic diagram is an example of a log display interface, and those skilled in the art can select the content to be displayed and the corresponding operation buttons as needed. For example, the content that can be displayed includes: device name (UART identification), connection information (UART path), collection status, operation instructions, refresh options, etc. In addition, the system can also provide viewing services for archived files and other information as needed.
[0179] Through the above introduction, those skilled in the art should understand that the method of this embodiment can achieve the following technical effects: intelligently identify the serial port access of each vehicle module, and automatically collect and save data in the background. It has the ability to automatically identify and recover from various abnormal collection conditions in the real vehicle environment, ensuring the stability and efficiency of data collection. It intelligently detects the disconnection and reconnection of the serial port and the restart operation of the vehicle system, and automatically issues predefined instructions for the specified serial port. Through the improvement of interaction with the client, the serial port can be shared and viewed by multiple people at the same time.
[0180] This embodiment also provides a computer program product 110 , a computer-readable storage medium 120 , and a log collection device 30 for a vehicle-mounted system. Fig.11 is a schematic diagram of a computer program product 110 according to an embodiment of the present invention, Fig.12 is a schematic diagram of a computer-readable storage medium 120 according to an embodiment of the present invention, Fig.13 is a schematic diagram of a log collection device 30 according to an embodiment of the present invention. The computer program product 110 includes a computer program 111, which implements the steps of any of the above-mentioned log collection methods for an in-vehicle system when the computer program 111 is executed by a processor 310. The computer-readable storage medium 120 stores the above-mentioned computer program 111, which implements the steps of any of the above-mentioned in-vehicle system log collection methods when the computer program 111 is executed by the processor 310. The log collection device 30 may include a memory 320, a processor 310, and a computer program 111 stored in the memory 320 and running on the processor 310.
[0181] The computer program 111 for performing the operation of the present invention may be an assembly instruction, an instruction set architecture (ISA) instruction, a machine instruction, a machine-dependent instruction, a microcode, a firmware instruction, a state setting data, a configuration data of an integrated circuit, or a source code or an object code written in any combination of one or more programming languages and a procedural programming language. The computer program 111 may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the latter case, the remote computer may be connected to the user's computer via any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet Service Provider). In some embodiments, to perform aspects of the present invention, electronic circuits including, for example, programmable logic circuits, Field-Programmable Gate Arrays (FPGAs), or Programmable Logic Arrays (PLAs) may execute computer-readable program instructions by utilizing state information of the computer-readable program instructions to personalize the electronic circuits.
[0182] In the description of this embodiment, the computer program product 110 is a related product including the computer program 111 .
[0183] For the purposes of the description of this embodiment, the computer-readable storage medium 120 is a tangible device capable of retaining and storing the computer program 111, which may be any device that can contain, store, communicate, propagate or transmit the program 111 for use with or in conjunction with an instruction execution system, device or apparatus. More specific examples (a non-exhaustive list) of the computer-readable storage medium 120 include the following: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a static random access memory (SRAM), a portable compact disk read-only memory (CD-ROM), a digital versatile disk (DVD), a memory stick, a floppy disk, a mechanical encoding device, and any suitable combination of the foregoing.
[0184] The log collection device 30 may be, for example, a computer device or a secondary developed hardware combination. The log collection device 30 may be described in the general context of computer system executable instructions (such as program modules) executed by a computer system. Typically, a program module may include routines, programs, object programs, components, logic, data structures, etc. that perform specific tasks or implement specific abstract data types.
[0185] The log collection device 30 may include a processor 310 adapted to execute stored instructions, and a memory 320 providing temporary storage space for the operation of the instructions during operation. The processor 310 may be a single-core processor, a multi-core processor, a computing cluster, or any number of other configurations. The memory 320 may include a random access memory (RAM), a read-only memory, a flash memory, or any other suitable storage system.
[0186] The log collection device 30 may also include a network adapter / interface and an input / output (I / O) interface. The I / O interface allows data to be input and output with external devices that can be connected to the computer device. The network adapter / interface can provide communication between the computer device and a network, which is usually shown as a communication network.
[0187] At this point, those skilled in the art should recognize that, although multiple exemplary embodiments of the present invention have been shown and described in detail herein, many other variations or modifications that conform to the principles of the present invention can still be directly determined or derived based on the content disclosed in the present invention without departing from the spirit and scope of the present invention. Therefore, the scope of the present invention should be understood and recognized as covering all these other variations or modifications.
Claims
1. A log collection method for a vehicle-mounted system, characterized in that include: Get the kernel log messages of the log collection device; Using a preset serial port keyword to perform line-by-line matching in the kernel log message, extracting serial port connection information, wherein the serial port connection information can identify a processing device of each output log in the vehicle-mounted system; Generate a serial communication path according to the serial port connection information; Open the serial communication path, and send corresponding configuration parameters to the serial communication interface corresponding to the serial communication path; Collect and save log data provided by the serial communication interface.
2. The log collection method of the vehicle-mounted system according to claim 1, characterized in that: The step of sending the corresponding configuration parameters to the serial communication interface corresponding to the serial communication path comprises: Obtaining an identifier provided by the serial communication interface; matching the identifier with predefined identifiers; In the case of successful matching, the configuration parameters corresponding to the serial communication interface are sent to the serial communication interface, so that the serial communication interface enters a waiting state for reading and writing.
3. The log collection method of the vehicle-mounted system according to claim 2, characterized in that: The step of collecting and saving the log data provided by the serial communication interface includes: Utilize the serial port read / write thread to execute a blocking read call on the serial communication interface that has entered the waiting read / write state; After the serial port reading and writing thread reads the data of the serial communication interface, the data is sent to a preset log saving queue; The data in the log storage queue is written into the corresponding log file.
4. The log collection method of the vehicle-mounted system according to claim 3, characterized in that: The step of writing the data of the log storage queue into the corresponding log file comprises: Obtaining a preset log storage parameter, wherein the log storage parameter specifies a size threshold of the log file; Reading data from the log storage queue and determining a target log file corresponding to the read data; Determine whether the size of the target log file is greater than the size threshold of the log file; If not, writing the read data into the target log file; If so, the target log file is archived in the set archive directory, a new log file is created and the read data is written into it.
5. The log collection method of the vehicle-mounted system according to claim 4, characterized in that: The log storage parameters also specify a threshold value for the number of archived files and a threshold value for the capacity of the archive directory; and Before the step of archiving the target log file in the set archiving directory, the method further includes: Check whether the number of archived files in the archive directory is greater than or equal to the number threshold or whether the file size in the archive directory is greater than or equal to the capacity threshold; If any judgment result is yes, the archive file with the oldest archive time is deleted from the archive directory.
6. The log collection method of the vehicle-mounted system according to claim 3, characterized in that: After the step of reading the data of the serial communication interface from the serial port reading and writing thread, the method further includes: Matching the read data line by line with the preset startup keywords; If the match is successful, the configuration parameters are rewritten to the serial communication interface.
7. The log collection method of the vehicle-mounted system according to claim 3, characterized in that: The process of using the serial port read / write thread to perform a blocking read call on the serial communication interface that enters the waiting read / write state also includes: Determine whether a call error occurs; If so, the serial communication path is reopened.
8. The log collection method of the vehicle-mounted system according to claim 3, characterized in that: The process of using the serial port read / write thread to perform a blocking read call on the serial communication interface that enters the waiting read / write state also includes: Determine whether a call timeout occurs; If yes, re-obtain the kernel log message of the log collection device; Check whether there is error information of the serial communication interface in the kernel log message; If it exists, reload the driver of the serial communication interface; If not present, returns to execute the blocking read call.
9. The log collection method of the vehicle-mounted system according to claim 2, characterized in that: After the step of collecting and saving the log data provided by the serial communication interface, the step further includes: Establishing and maintaining a log database corresponding to the identifier of the serial communication interface; Establishing a network connection with a log viewing device; receiving a log request from the log viewing device, wherein the log request at least includes an identifier of the serial communication interface; The data of the log database is provided to the log viewing device according to the log request.
10. A log collection device for a vehicle-mounted system, comprising a processor, a memory, and a plurality of serial communication ports, wherein the memory stores a computer program, and when the computer program is executed by the processor, the steps of the log collection method for the vehicle-mounted system according to any one of claims 1 to 9 are implemented.
11. A log collection system for a vehicle-mounted system, characterized in that include: The debugging box is connected to the processing device of each output log and the log collection device in the vehicle-mounted system through the serial port; The log collection device is a log collection device for a vehicle-mounted system according to claim 10, and the log collection device also includes a network connection port, and is connected to a system data transmission port of the vehicle-mounted system through the network connection port to obtain system log data of the vehicle-mounted system.
12. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the log collection method of the vehicle-mounted system described in any one of claims 1 to 9 are implemented.
Citation Information
Cited By
Server log automatic storage method and device, equipment, storage medium and product
CN119356996A
Multi-serial port management method of interlocking equipment
CN120429259A
Multi-serial port management method of interlocking device
CN120429259B
