Log extraction method of vehicle-mounted communication terminal, vehicle-mounted communication terminal and storage medium
By setting up a serial peripheral interface and asynchronous serial transmitting and receiving line in the on-board communication terminal, and selecting the transmission path according to the log level and data characteristics, the problems of poor log viewing flexibility and stability in the existing technology are solved, and efficient and reliable are achieved log data transmission.
Patent Information
- Application Number
- CN202411151282.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-21
- Publication Date
- 2024-11-26
- Estimated Expiration
- 2044-08-21
AI Technical Summary
The log viewing flexibility, stability and reliability of existing vehicle-mounted communication terminals are mainly due to the high MCU resource usage due to the dependence on serial port printing method, which affects system stability.
By setting a serial peripheral interface line and an asynchronous serial transmitting and receiving line between the microcontroller and the microprocessor of the vehicle communication terminal, the target line is determined based on the log level and data volume or transmission frequency, and multiple ways of extracting log data are realized. , avoid the loss of important log data, and make full use of line characteristics to improve transmission efficiency.
It improves the flexibility and reliability of log data extraction, reduces the MCU load rate, avoids the loss of important log data, and improves the efficiency of log data transmission.
Smart Images

Figure CN119025382A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of log transmission, and in particular to a log extraction method for a vehicle-mounted communication terminal, a vehicle-mounted communication terminal and a storage medium. Background Art
[0002] The log of the MCU (Micro Controller Unit) in the vehicle communication terminal (Telematics Box, T-Box) is very important. Whether in the debugging stage or the mass production stage, developers need to locate and analyze problems by viewing the log. The MCU log is generally printed to the host computer in real time through the serial port.
[0003] However, the serial port printing method requires a USB to TTL (Transistor-Transistor Logic) module to view and save the logs. If this module is not available or after the vehicle is installed, the logs cannot be viewed. In addition, the serial port log printing consumes MCU resources, that is, occupies the MCU load rate, which has a great impact on the embedded real-time system. This leads to the problems of poor flexibility and system stability in the existing technology. Summary of the invention
[0004] In view of the above-mentioned defects or deficiencies in the prior art, the present application aims to provide a log extraction method for a vehicle-mounted communication terminal, a vehicle-mounted communication terminal and a storage medium to solve the problems of poor flexibility, poor stability and poor reliability in log viewing in the prior art.
[0005] The embodiment of the present application provides a log extraction method for a vehicle-mounted communication terminal, the method being applied to the vehicle-mounted communication terminal, the vehicle-mounted communication terminal comprising a microcontroller and a microprocessor, the microcontroller comprising a print output serial port, a serial peripheral interface circuit and an asynchronous serial transceiver circuit being provided between the microcontroller and the microprocessor, the method comprising: The microcontroller determines the log level of the log data to be transmitted; In response to the log level being lower than a preset level, the microcontroller outputs the log data to be transmitted to the print output serial port; or, in response to the log level being greater than or equal to the preset level, determines a target line in the serial peripheral interface line and / or the asynchronous serial transceiver line based on the data volume or transmission frequency of the log data to be transmitted, and transmits the log data to be transmitted to the microprocessor via the target line.
[0006] Optionally, before outputting the log data to be transmitted to the print output serial port, the method further includes: The microcontroller obtains a flag bit of a serial port printing function; If the flag is function-on, the step of outputting the log data to be transmitted to the print output serial port is executed.
[0007] Optionally, the method further includes: The microcontroller receives the diagnostic instruction sent by the diagnostic device, and determines whether the diagnostic instruction is a function-enabling instruction. If so, the flag bit of the serial port printing function is set to function-enabling.
[0008] Optionally, before determining the target line in the serial peripheral interface line and / or the asynchronous serial transceiver line, the method further includes: In response to detecting that the vehicle-mounted communication terminal is restarted, the microcontroller determines whether a serial peripheral interface line and an asynchronous serial transceiver line between the microprocessor and the microprocessor are successfully established; If yes, the microcontroller executes the step of determining a target line in the serial peripheral interface line and / or the asynchronous serial transceiver line.
[0009] Optionally, the microcontroller further includes a log buffer; and the method further includes: If the microcontroller determines that the serial peripheral interface line and the asynchronous serial transceiver line are not successfully established, the log data to be transmitted is written into the log buffer.
[0010] Optionally, the method further includes: The microprocessor receives a log reading request sent by the vehicle system, and based on the log reading request, sends the stored log data to the vehicle system, so that the vehicle system transmits the log data to the connected mobile storage device; or, The microprocessor receives the diagnostic instruction sent by the diagnostic device, and determines whether the diagnostic instruction is a data reading instruction. If so, the microprocessor sends the stored log data to the diagnostic device.
[0011] Optionally, the serial peripheral interface circuit includes a serial peripheral host sending channel, a serial peripheral host receiving channel, a host handshake input channel and a host handshake output channel, and the asynchronous serial transceiver circuit includes an asynchronous serial host sending channel and an asynchronous serial host receiving channel; transmitting the log data to be transmitted to the microprocessor through the target circuit includes: If the target line is the serial peripheral interface line, the microcontroller sends a handshake input signal to the microprocessor through the host handshake input channel, and the microprocessor starts data transmission with the microcontroller in response to the handshake input signal, so that the microcontroller transmits the log data to be transmitted through the serial peripheral host receiving channel; and If the target line is the asynchronous serial transceiver line, the microcontroller sends the log data to be transmitted to the microprocessor through the asynchronous serial host receiving channel.
[0012] Optionally, after transmitting the log data to be transmitted to the microprocessor through the target line, the method further includes: The microprocessor stores the received log data in a disk by running the open source code file.
[0013] The embodiment of the present application further provides a vehicle-mounted communication terminal, the vehicle-mounted communication terminal includes a microcontroller and a microprocessor, the microcontroller includes a print output serial port, and a serial peripheral interface circuit and an asynchronous serial transceiver circuit exist between the microcontroller and the microprocessor, wherein: The microcontroller is used to determine the log level of the log data to be transmitted, and in response to the log level being lower than a preset level, output the log data to be transmitted to the print output serial port, or, in response to the log level being greater than or equal to the preset level, determine a target line in the serial peripheral interface line and / or the asynchronous serial transceiver line based on the data volume or transmission frequency of the log data to be transmitted, and transmit the log data to be transmitted to the microprocessor via the target line.
[0014] The present application also provides an electronic device, the electronic device comprising: Processor and memory; The processor is used to execute the steps of the log extraction method for the vehicle-mounted communication terminal provided in any embodiment of the present application by calling the program or instruction stored in the memory.
[0015] An embodiment of the present application also provides a computer-readable storage medium, which stores a program or instruction, and the program or instruction enables a computer to execute the steps of the log extraction method of the vehicle-mounted communication terminal provided in any embodiment of the present application.
[0016] In summary, the present application proposes a log extraction method for a vehicle-mounted communication terminal, which is applied to a vehicle-mounted communication terminal including a microcontroller and a microprocessor, wherein the microcontroller determines the log level of the log data to be transmitted, and when the log level is lower than a preset level, the microcontroller outputs the log data to be transmitted to a print output serial port, or when the log level is greater than or equal to the preset level, according to the data volume or transmission frequency of the log data to be transmitted, determines the target line in the serial peripheral interface line and / or the asynchronous serial transceiver line between the microcontroller and the microprocessor, and sends the log data to be transmitted to the microprocessor through the target line, thereby realizing the output of the log to the print output serial port and to the microprocessor. Compared with the prior art which only relies on the serial port Printing, this method can realize multiple log extraction methods, effectively solving the problems of poor flexibility, high load rate, poor reliability and so on caused by printing only through the serial port; moreover, this method first determines whether it needs to be transmitted to the print output serial port according to the log level, and can output the log data with lower importance through serial port printing, and transmit the log data with higher importance through the line, thereby avoiding the loss of log data with higher importance; in addition, this method determines the target line according to the data volume or transmission frequency, and can make full use of the transmission characteristics of the line, and select the appropriate line for the transmission of log data, which greatly improves the efficiency of log data transmission while ensuring the reliability of log data transmission, thereby improving the efficiency of log data extraction and avoiding data loss. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the specific implementation methods of the present application or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0018] Figure 1 A schematic diagram of a vehicle-mounted communication terminal provided in an embodiment of the present application; Figure 2 A schematic diagram of a circuit structure provided in an embodiment of the present application; Figure 3 is a flow chart of a log extraction method of a vehicle-mounted communication terminal provided in an embodiment of the present application; Figure 4 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0019] The present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the relevant invention, rather than to limit the invention. It is also necessary to explain that, for ease of description, only the parts related to the invention are shown in the accompanying drawings.
[0020] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present application can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0021] The log extraction method of the vehicle-mounted communication terminal provided in the embodiment of the present application is mainly suitable for extracting the logs of the vehicle-mounted communication terminal. Through the print output serial port of the microcontroller in the vehicle-mounted communication terminal and the line between the microprocessor and the microcontroller, serial port printing-based log extraction and microprocessor-based log extraction are realized.
[0022] like Figure 1 As shown, Figure 1 A schematic diagram of a vehicle-mounted communication terminal provided in an embodiment of the present application, wherein the vehicle-mounted communication terminal includes a microcontroller and a microprocessor, the microcontroller includes a print output serial port, and a serial peripheral interface line and an asynchronous serial transceiver line exist between the microcontroller and the microprocessor.
[0023] The serial peripheral interface line may be a traditional four-wire SPI (Serial Peripheral Interface) line, where the four wires are a chip select channel, a clock channel, a serial peripheral host transmission channel, and a serial peripheral host reception channel.
[0024] Alternatively, the serial peripheral interface line may be a six-wire SPI line improved on the conventional four-wire SPI line, such as Figure 2 As shown, Figure 2 A schematic diagram of a circuit structure provided for an embodiment of the present application. Among them, the six lines are a chip select channel, a clock channel, a serial peripheral host transmission channel, a serial peripheral host receiving channel, a host handshake input channel, and a host handshake output channel. Among them, the host handshake input channel and the host handshake output channel are used to control the communication handshake between the microcontroller and the microprocessor. By adding the host handshake input channel and the host handshake output channel, bidirectional data transmission between the microcontroller and the microprocessor can be achieved.
[0025] In this embodiment, the asynchronous serial transceiver circuit may be a UART (Universal Asynchronous Receiver / Transmitter) circuit. Figure 2As shown, the asynchronous serial transceiver line may include an asynchronous serial host transmission channel and an asynchronous serial host receiving channel. In the vehicle-mounted communication terminal, the composite communication structure composed of SPI and UART can greatly improve the log data transmission bandwidth between the microprocessor and the microcontroller, improve the log data transmission efficiency and reliability, and avoid data loss.
[0026] As mentioned in the background technology, in response to the problems in the prior art, the present application proposes a log extraction method for a vehicle-mounted communication terminal. Figure 3 is a flow chart of a log extraction method for a vehicle-mounted communication terminal provided in an embodiment of the present application. Figure 3 , the log extraction method of the vehicle-mounted communication terminal specifically includes: S110 , the microcontroller determines the log level of the log data to be transmitted.
[0027] The log data to be transmitted may be the log data of the vehicle communication terminal that the microcontroller expects to send. Exemplarily, in response to detecting the log data of the new vehicle communication terminal, the microcontroller may use the latest generated log data as the log data to be transmitted; or, the microcontroller may use the log data of the vehicle communication terminal generated within a preset transmission cycle as the log data to be transmitted.
[0028] Specifically, for the log data to be transmitted, the microcontroller may first determine the log level of the log data to be transmitted, so as to determine whether to send it to the print output serial port or the microprocessor according to the log level.
[0029] In this embodiment, the log level can reflect the importance of the log data to be transmitted to the subsequent data analysis. For example, the log level can be divided into 4 levels, from high to low: log_error, log_warn, log_info, log_debug.
[0030] Among them, log_error represents the error level log, which is generally used to record serious errors that occur during the operation of the vehicle communication terminal program. These errors may cause the program to fail to run normally or produce irreversible results; for example, database connection failure, file reading error, etc.
[0031] Among them, log_warn represents a warning level log, which is used to record some information that may have problems or exceptions in the vehicle communication terminal, but the program can still continue to run; for example, the value of a configuration item is unreasonable, but it does not cause the program to crash.
[0032] Among them, log_info represents the information level log, which is used to record general useful information in the vehicle communication terminal to help understand the running status and process of the program; for example, system startup, module loading success, etc.
[0033] Among them, log_debug represents the debug level log, which usually contains detailed information about the program execution process. It is usually only used in the development and debugging stages and is generally not enabled in the production environment to avoid generating too much log data; for example, the input parameters of the function, the values of internal variables, etc.
[0034] S120. In response to the log level being lower than a preset level, the microcontroller outputs the log data to be transmitted to the print output serial port. Alternatively, in response to the log level being greater than or equal to the preset level, the microcontroller determines a target line in the serial peripheral interface line and / or the asynchronous serial transceiver line based on the data volume or transmission frequency of the log data to be transmitted, and transmits the log data to be transmitted to the microprocessor via the target line.
[0035] Specifically, after determining the log level of the log data to be transmitted, the microcontroller may compare the log level with a preset level, wherein the preset level may be a pre-set critical level for distinguishing between transmitting data to the print output serial port and the microprocessor.
[0036] For example, considering that the debug level log (log_debug) is usually only used in the development and debugging stages, and it contains information about the program execution process, which is less important for subsequent accident analysis, the preset level can be set to the information level log (log_info) to output the debug level log (log_debug) through the print output serial port, and other levels of logs are output to the microprocessor for storage to avoid the loss of important logs.
[0037] In this embodiment, if the microcontroller detects that the log level is lower than the preset level, it means that the importance of the log data to be transmitted is low, and the microcontroller can send the log data to be transmitted to the print output serial port. By determining the log transmission method through the log level, the free allocation of log data can be realized, which improves the flexibility of MCU log recording.
[0038] It should be noted that if the print output serial port is connected to the host computer, the host computer can obtain and display the log data to be transmitted by the microcontroller to the print output serial port. If the print output serial port is not connected to the host computer, the log data to be transmitted will be lost after being sent to the print output serial port. Since the debug level log (log_debug) is less important, the loss of debug level log data will not affect the subsequent data analysis of the vehicle communication terminal.
[0039] In this embodiment, considering that the process of sending log data to the print output serial port will also occupy the load of the microcontroller and reduce the stability of the microcontroller, this embodiment can also turn on or off the function of the microcontroller sending log data to the print output serial port according to demand, that is, turn on or off the serial port log output function of the microcontroller.
[0040] In a specific implementation, before outputting the log data to be transmitted to the print output serial port, the method further includes: The microcontroller obtains the flag bit of the serial port printing function; if the flag bit indicates that the function is enabled, the step of outputting the log data to be transmitted to the print output serial port is executed.
[0041] The flag bit is used to describe whether the serial port printing function is enabled. Specifically, if the log level of the log data to be transmitted is lower than the preset level, the microcontroller can obtain the flag bit of the serial port printing function before outputting the log data to be transmitted to the print output serial port.
[0042] Furthermore, the microcontroller determines whether the flag is enabled. If so, it indicates that there is a need to obtain a debug level log (log_debug). The microcontroller can output the log data to be transmitted to the print output serial port.
[0043] Through the above implementation, the microcontroller can output the log data to be transmitted to the print output serial port when the serial port printing function is turned on, and cancel the sending of the log data to be transmitted when the serial port printing function is not turned on, which can reduce the load of the microcontroller and improve the stability of the microcontroller.
[0044] Optionally, the method provided in the embodiment of the present application further includes: The microcontroller receives the diagnostic instruction sent by the diagnostic device, and determines whether the diagnostic instruction is a function-enabling instruction. If so, the flag bit of the serial port printing function is set to function-enabling.
[0045] The diagnostic device can send a diagnostic instruction to the microcontroller through the UDS (Unified Diagnostic Services) protocol. The diagnostic device can use the diagnostic instruction to control the serial port printing function of the microcontroller.
[0046] Specifically, after receiving the diagnostic instruction sent by the diagnostic device, the microcontroller can determine whether the diagnostic instruction is a function-enabling instruction, wherein the flag bit of the serial port printing function is set to function-off by default. For example, if the diagnostic instruction is 0322 BB AA, it can be determined that the diagnostic instruction is a function-enabling instruction.
[0047] Furthermore, in response to detecting the function enable instruction, the microcontroller can set the flag of the serial port printing function to function enable to enable the serial port printing function. Of course, after enabling the serial port printing function through the function enable instruction sent by the diagnostic device, the microcontroller can also disable the serial port printing function through the function disable instruction sent by the diagnostic device.
[0048] In this way, the serial port printing function can be enabled according to the actual demand for logs, thereby improving the flexibility of the microcontroller in outputting log data through the print output serial port.
[0049] In this embodiment, in addition to turning on or off the serial port log output function according to the demand for logs, the microcontroller can also turn on or off the serial port log output function according to its own load occupancy rate. Exemplarily, the microcontroller can obtain the current load occupancy rate, and if the current load occupancy rate is less than the preset occupancy rate threshold, the flag bit of the serial port printing function is set to function on, otherwise, the flag bit of the serial port printing function is set to function off.
[0050] In this embodiment, if the microcontroller determines that the log level of the log data to be transmitted is greater than or equal to the preset level, it means that the importance of the log data to be transmitted is relatively high. At this time, a target line can be selected from the serial peripheral interface line and / or the asynchronous serial transceiver line, such as using the serial peripheral interface line as the target line, or using the asynchronous serial transceiver line as the target line, or using the serial peripheral interface line and the asynchronous serial transceiver line as the target line at the same time, so as to send the log data to be transmitted to the microprocessor for storage to avoid data loss.
[0051] Among them, in order to ensure that the log data to be transmitted can be reliably transmitted to the microprocessor for storage, this embodiment sets two lines between the microcontroller and the microprocessor, namely, the serial peripheral interface line and the asynchronous serial transceiver line. The log data of the microcontroller is transmitted through dual-line communication to ensure that data loss will not occur, thereby improving the reliability of microcontroller log data storage and log recording frequency.
[0052] Specifically, the microcontroller can use one of the serial peripheral interface line and the asynchronous serial transceiver line as the target line according to the data volume or transmission frequency of the log data to be transmitted, or use both the serial peripheral interface line and the asynchronous serial transceiver line as the target line.
[0053] Exemplarily, considering that the serial peripheral interface line has a high transmission frequency and can transmit messages with a large amount of data, and the asynchronous serial transceiver line has a low transmission frequency, in this embodiment, based on the amount of data or the transmission frequency of the log data to be transmitted, the target line is determined in the serial peripheral interface line and / or the asynchronous serial transceiver line, which can be: If the data volume of the log data to be transmitted is greater than the preset data volume threshold, or the transmission frequency of the log data to be transmitted is greater than the preset frequency threshold, the target line is determined to be a serial peripheral interface line; and if the data volume of the log data to be transmitted is lower than the preset data volume threshold, or the transmission frequency of the log data to be transmitted is the frequency of triggered transmission, the target line is determined to be an asynchronous serial transceiver line.
[0054] In this embodiment, in combination with the line transmission characteristics of the serial peripheral interface line and the asynchronous serial transceiver line, for high-frequency transmission or large data volume log data to be transmitted, by selecting the serial peripheral interface line as the target line, the characteristics of the serial peripheral interface line with high transmission frequency and the ability to transmit large data volume messages can be fully utilized to achieve efficient transmission of the log data; for triggered transmission or small data volume log data to be transmitted, by selecting the asynchronous serial transceiver line as the target line, the characteristics of the asynchronous serial transceiver line with low transmission frequency can be fully utilized, and the small data volume or triggered log data can be sent through the asynchronous serial transceiver line. While ensuring the transmission reliability and transmission efficiency of the small data volume or triggered log data, it is avoided that the small data volume or triggered log data occupies the synchronous serial peripheral interface line, which can further ensure the efficient transmission of the log data.
[0055] It should be noted that when the microcontroller needs to send multiple log data to be transmitted to the microprocessor at the same time, the corresponding target line can be determined for transmission according to the data volume or transmission frequency of each log data to be transmitted. In addition, considering that some data may have the characteristics of low transmission frequency but large data volume, such data can be split, and part of the data can be transmitted through the serial peripheral interface line, and the other part can be transmitted through the asynchronous serial transceiver line.
[0056] In a specific implementation, the serial peripheral interface circuit includes a serial peripheral host transmission channel, a serial peripheral host receiving channel, a host handshake input channel, and a host handshake output channel, and the asynchronous serial transceiver circuit includes an asynchronous serial host transmission channel and an asynchronous serial host receiving channel; the log data to be transmitted is transmitted to the microprocessor through the target circuit, including: If the target line is a serial peripheral interface line, the microcontroller sends a handshake input signal to the microprocessor through the host handshake input channel, and the microprocessor responds to the handshake input signal and starts data transmission between the microcontroller and the microcontroller, so that the microcontroller transmits the log data to be transmitted through the serial peripheral host receiving channel; and If the target line is an asynchronous serial transceiver line, the microcontroller sends the log data to be transmitted to the microprocessor through the asynchronous serial host receiving channel.
[0057] Among them, the serial peripheral host transmit channel is used by the microprocessor to send data to the microcontroller, the serial peripheral host receive channel is used by the microprocessor to receive data sent by the microcontroller, the master handshake input (Master Handshake Input, MHI) channel is used by the microprocessor to receive the handshake input signal sent by the microcontroller, and the master handshake output (Master Handshake Output, MHO) channel is used by the microprocessor to send a handshake output signal to the microcontroller.
[0058] Specifically, if the target line is an SPI line, the process of the microcontroller sending the log data to be transmitted to the microprocessor is as follows: first, the microcontroller can mount the shift register in the buffer, and pull up the handshake input level to generate a handshake input signal (which can be understood as an interrupt signal), and send the handshake input signal to the microprocessor through the host handshake input channel. After the microprocessor detects the handshake input signal, it starts data transmission with the microcontroller, and the microcontroller can send the log data to be transmitted to the microprocessor through the serial peripheral host receiving channel.
[0059] Furthermore, if the target line is a UART line, the microcontroller can control the log data to be transmitted to be sent to the microprocessor through the asynchronous serial host receiving channel through the built-in UART controller. In the process of the microcontroller sending log data through the asynchronous serial host receiving channel, the microcontroller can also count the number of transmitted bytes and stop data transmission when it is detected that the number of transmitted bytes reaches the preset data length.
[0060] The above implementation method realizes log data transmission based on SPI and UART, wherein the communication handshake between the microcontroller and the microprocessor can be realized through the host handshake input channel and the host handshake output channel, thereby ensuring the reliability of establishing the communication link and avoiding data loss during log data transmission.
[0061] It should be noted that the above describes the process of the microcontroller sending log data to the microprocessor. The microprocessor can also send data to the microcontroller through SPI or UART, such as through a serial peripheral host sending channel or an asynchronous serial host sending channel. The process of the microprocessor sending data can refer to the previous description of the process of the microcontroller sending data, which will not be repeated here.
[0062] In this embodiment, considering that the vehicle-mounted communication terminal may be powered on or reset as a whole board, and the startup time of the microcontroller in the vehicle-mounted communication terminal is short, and the startup time of the microprocessor is long, during the power-on or reset of the vehicle-mounted communication terminal as a whole board, the communication line between the microcontroller and the microprocessor is not established, resulting in the microcontroller's log data being unable to be transmitted to the microprocessor for storage. Therefore, to address this problem, the microcontroller can also determine whether the communication line is established before sending the log data.
[0063] In a specific implementation manner, before determining the target line in the serial peripheral interface line and / or the asynchronous serial transceiver line, the method further includes: In response to detecting that the vehicle-mounted communication terminal is restarted, the microcontroller determines whether the serial peripheral interface line and the asynchronous serial transceiver line between the microprocessor are successfully established; if so, the microcontroller executes the step of determining the target line in the serial peripheral interface line and / or the asynchronous serial transceiver line.
[0064] Specifically, if the microcontroller detects that the on-board communication terminal is restarted, it means that the microprocessor may be in the startup process. At this time, the serial peripheral interface line and the asynchronous serial transceiver line between the microprocessor may not be successfully established. Therefore, the microcontroller can determine whether the serial peripheral interface line and the asynchronous serial transceiver line between the microprocessor are successfully established. If successful, the microcontroller can further determine the target line in the serial peripheral interface line and / or the asynchronous serial transceiver line, and then send the log data to be transmitted through the target line.
[0065] If the establishment is not successful, the microprocessor may send the log data to be transmitted to the print output serial port, or store the log data to be transmitted in the buffer area.
[0066] In one example, the microcontroller further includes a log buffer; the method provided by the embodiment of the present application further includes: If the microcontroller determines that the serial peripheral interface line and the asynchronous serial transceiver line are not successfully established, the log data to be transmitted is written into the log buffer.
[0067] The log buffer may be a ring buffer opened in the microcontroller, such as a ringbuf buffer. For example, a log buffer may be opened according to the size of the log volume of the microcontroller, and the log buffer is used to cache the log data that the microcontroller needs to save during the startup of the microprocessor.
[0068] Specifically, the microcontroller may write the log data to be transmitted into the log buffer when the serial peripheral interface line and the asynchronous serial transceiver line are not successfully established.
[0069] Furthermore, when the microcontroller detects that the serial peripheral interface line and the asynchronous serial transceiver line are successfully established, the microcontroller can send the log data cached in the log buffer through the line to the microprocessor for storage.
[0070] Through the above implementation, when the entire board of the vehicle communication terminal is powered on or reset, the microcontroller can first cache the log data to avoid the situation where the communication line is not established due to the long startup time of the microprocessor, which in turn causes the loss of log data, thereby ensuring the integrity of the microcontroller log data.
[0071] In this embodiment, considering that the serial peripheral interface line can transmit log data with a large amount of data, and the asynchronous serial transceiver line can transmit log data with a small amount of data, the data structure of the log data transmitted in the serial peripheral interface line and the asynchronous serial transceiver line can also be defined, so that when the microcontroller sends the log data to be transmitted, the log data to be transmitted is transmitted in the data structure corresponding to the target line, thereby further improving the efficiency of log data transmission.
[0072] Exemplarily, when the target line is a serial peripheral interface line, the microcontroller sends the log data to be transmitted to the microprocessor in the form of a first data frame through the target line; and when the target line is an asynchronous serial transceiver line, the microcontroller sends the log data to be transmitted to the microprocessor in the form of a second data frame through the target line. The first data frame includes a frame header, a packet length, a sending device identifier, a receiving device identifier, a frame sequence number, the length of each first data block, each first data block, and a check code, the first data block includes a data block identifier and a data body, the second data frame includes each sub-frame identifier, a frame length, a second data block, and a check code, and the second data block includes a data block identifier, a packet number, and a data body.
[0073] Among them, since the length of a data frame of the serial peripheral interface line is fixed and the data length that can be carried is relatively large, multiple data blocks (payload) are defined in one frame, thereby effectively improving the transmission efficiency of the six-wire SPI. For example, Table 1 shows a first data frame. As shown in Table 1, the frame header can occupy two bytes, which is defined by default as AA 77, indicating the beginning of a communication packet. The packet length can occupy two bytes, indicating the total length of the effective content of a frame protocol message, that is, the length of Byte0 - ByteM, using big endian byte order (big endian), total length = Length(2) +Length(1)*256. The sending device identifier indicates the identifier of the device sending data, which is a required item in multi-device communication. The receiving device identifier indicates the identifier of the device receiving data, which is a required item in multi-device communication. The frame sequence number indicates the sequence number of the sent frame, representing whether the sender has continuous transmission, and 1~127 is used cyclically. The first data block consists of a data block identifier and a data body. The data block identifier describes the specific meaning of each first data block, and the data body is the specific log data to be transmitted. The check code is used to ensure the reliability of data transmission and reception. Considering the different processing of different chips, an efficient and generally reliable XOR algorithm can be used, that is, Byte(0)~Byte(M-1) can be XORed, and the result of the XOR can be used as a check code to fill Byte(M).
[0074] Table 1 A first data frame
[0075] Since the transmission speed of the asynchronous serial transceiver line is relatively slow, each transmitted log data frame to be transmitted is set to a variable frame length, and one data frame carries only one data block. For example, Table 2 shows a second data frame. As shown in Table 2, the frame identifier can be defined as 0x66aabbccdd55, which is used to find a data frame in the RingBuf cache, so as to perform data parsing processing; the frame length occupies two bytes, which is the sum of the lengths of byte0~byteM, including the frame length itself, and adopts big endian byte order (big endian), and the total length = Length(2) +Length(1)*256; the second data block consists of a data block identifier, a packet number, and a data body. The data block identifier can be divided into two bytes, the high byte identifies the message type, and the low byte represents the message identifier. The packet number occupies one byte, and the value range is 0~255 cyclically increasing, and the data body is the valid log data to be transmitted; the check code can be the result of XORing the data from Byte 0 to ByteM-1.
[0076] Table 2 A second data frame
[0077] In addition, considering that there may be line interruptions during data transmission between the microcontroller and the microprocessor, in order to ensure the reliability of data transmission, a channel anomaly detection mechanism can also be defined to implement channel anomaly detection through heartbeat frames to improve the reliability of system data transmission.
[0078] Exemplarily, when the microcontroller transmits the log data to be transmitted to the microprocessor through the target line, the method further includes: The microcontroller sends a heartbeat frame corresponding to the target line to the microprocessor through the target line, so that the microprocessor feeds back a response frame corresponding to the target line in response to the received heartbeat frame, and feeds back a transmission line switching request in the case where the heartbeat frame is not received; If the microcontroller does not receive the response frame, or receives a transmission line switching request fed back by the microprocessor, the target line is switched.
[0079] Specifically, in the process of the microcontroller sending the log data to be transmitted through the target line, a heartbeat frame corresponding to the target line can be sent at intervals of a preset period. For example, the heartbeat frame corresponding to the serial peripheral interface line can be "0102", and the heartbeat frame corresponding to the asynchronous serial transceiver line can be "0A02".
[0080] Furthermore, after receiving the heartbeat frame, the microprocessor can reply with a response frame corresponding to the target line. For example, the response frame corresponding to the serial peripheral interface line can be "8102", and the response frame corresponding to the asynchronous serial transceiver line can be "8A02". Of course, if the target device does not receive the heartbeat frame due to line interruption or other reasons, the microprocessor can directly feedback the transmission line switching request.
[0081] Furthermore, if the microcontroller receives a response frame, it can continue to wait for the next preset period and send a heartbeat frame; if the microcontroller does not receive the response frame due to line interruption or other reasons, or the microcontroller receives a transmission line switching request, the target line can be switched to set the target line to another line. For example, the target line is switched from a serial peripheral interface line to an asynchronous serial transceiver line, or the target line is switched from an asynchronous serial transceiver line to a serial peripheral interface line.
[0082] Through the above method, the detection of channel anomalies can be realized. When one line is abnormal, it can be switched to another line for transmission in time, further improving the reliability of log data transmission. In addition, if the new target line still has the problem of heartbeat stopping after switching the target line, the data transmission between the microcontroller and the microprocessor can be restarted to quickly restore to normal state.
[0083] In this embodiment, considering that in the process of transmitting log data, there may be a situation where the data cache of a certain line is about to be full, in this case, a portion of the log data with a shorter length can be allocated to the asynchronous serial transceiver line, or a portion of the log data with a longer length can be allocated to the serial peripheral interface line to ensure the real-time transmission of the log data. That is, in the process of sending the log data to be transmitted to the microprocessor through the target line, the microcontroller responds to detecting that the data cache corresponding to the target line is greater than the preset threshold, and sends part of the data in the log data to be transmitted to the microprocessor through other lines.
[0084] In addition, in this embodiment, after the microcontroller sends the log data to be transmitted to the microprocessor, the microprocessor may save the log data to be transmitted.
[0085] In one example, after the log data to be transmitted is transmitted to the microprocessor through the target line, the method provided by the embodiment of the present application further includes: the microprocessor stores the received log data in a disk by running an open source code file.
[0086] The open source code file may be a DLT (Diagnostic Log and Trace) file. Specifically, the open source code file may be pre-installed in the microprocessor, and then the microprocessor may run the open source code file, and the received log data may be stored in the disk through the running open source code file, thereby realizing the storage and management of the log data.
[0087] In this way, the microprocessor can store and manage the received log data without reconfiguring the code file, thereby improving the storage and management efficiency of the log data.
[0088] In addition, in this embodiment, multiple methods are provided for exporting logs. For example, logs can be exported through a connection between a mobile storage device and a vehicle system, or through a connection between a diagnostic device and a microprocessor.
[0089] In a specific implementation, the method provided in the embodiment of the present application further includes: The microprocessor receives a log reading request sent by the vehicle system, and based on the log reading request, sends the stored log data to the vehicle system, so that the vehicle system transfers the log data to the connected mobile storage device; or, the microprocessor receives a diagnostic instruction sent by the diagnostic device, and determines whether the diagnostic instruction is a data reading instruction. If so, the stored log data is sent to the diagnostic device.
[0090] Specifically, when the vehicle system detects that a mobile storage device (such as a USB flash drive) is connected, it can display a log export control through the central control screen. In response to detecting that the user triggers the log export control, it generates a log read request and sends it to the microprocessor. The microprocessor then responds to the log read request and sends the stored log data to the vehicle system, so that the vehicle system transfers the log data to the connected mobile storage device.
[0091] In addition to exporting log data through the vehicle system, the microprocessor can also receive diagnostic instructions sent by a diagnostic device connected using the OBD (On-Board Diagnostics) interface, wherein the diagnostic instructions may be generated by the UDS (Unified Diagnostic Services) protocol of DoIP (Diagnostic Communication over Internet Protocol); further, the microprocessor can determine whether the diagnostic protocol is a data read instruction, and if so, transmit the stored log data to the diagnostic device.
[0092] Through the above implementation, log export based on the vehicle system and diagnostic equipment can be realized, and multiple log export methods are provided, thereby improving the flexibility of MCU log export.
[0093] The log extraction method of the vehicle communication terminal provided in the embodiment of the present application is applied to the vehicle communication terminal including a microcontroller and a microprocessor, wherein the microcontroller determines the log level of the log data to be transmitted, and outputs the log data to be transmitted to the print output serial port when the log level is lower than the preset level, or determines the target line in the serial peripheral interface line and / or the asynchronous serial transceiver line between the microcontroller and the microprocessor according to the data volume or transmission frequency of the log data to be transmitted when the log level is greater than or equal to the preset level, and sends the log data to be transmitted to the microprocessor through the target line, thereby realizing the output of the log to the print output serial port and to the microprocessor, which is different from the prior art that only relies on Serial port printing, this method can realize multiple log extraction methods, effectively solving the problems of poor flexibility, high load rate, poor reliability and so on caused by only printing through serial port; moreover, this method first determines whether it needs to be transmitted to the print output serial port according to the log level, and can output the log data with lower importance through serial port printing, and transmit the log data with higher importance through the line, thereby avoiding the loss of log data with higher importance; in addition, this method determines the target line according to the data volume or transmission frequency, and can make full use of the transmission characteristics of the line and select the appropriate line for the transmission of log data, which greatly improves the efficiency of log data transmission while ensuring the reliability of log data transmission, thereby improving the efficiency of log data extraction.
[0094] Based on the same purpose, an embodiment of the present application also provides a vehicle-mounted communication terminal, which includes a microcontroller and a microprocessor. The microcontroller includes a print output serial port. A serial peripheral interface circuit and an asynchronous serial transceiver circuit exist between the microcontroller and the microprocessor, wherein: The microcontroller is used to determine the log level of the log data to be transmitted, and in response to the log level being lower than a preset level, output the log data to be transmitted to a print output serial port, or, in response to the log level being greater than or equal to the preset level, determine a target line in a serial peripheral interface line and / or an asynchronous serial transceiver line based on the data volume or transmission frequency of the log data to be transmitted, and transmit the log data to be transmitted to the microprocessor through the target line.
[0095] In some implementations, the microcontroller is further used to obtain a flag bit of a serial port printing function; if the flag bit indicates that the function is enabled, the step of outputting the log data to be transmitted to the print output serial port is executed.
[0096] In some implementations, the microcontroller is further configured to receive a diagnostic instruction sent by a diagnostic device, and determine whether the diagnostic instruction is a function enable instruction. If so, the flag bit of the serial port printing function is set to function enable.
[0097] In some embodiments, the microcontroller is also used to determine whether the serial peripheral interface line and the asynchronous serial transceiver line between the microprocessor are successfully established in response to detecting that the vehicle-mounted communication terminal is restarted; if so, execute the step of determining the target line in the serial peripheral interface line and / or the asynchronous serial transceiver line.
[0098] In some embodiments, the microcontroller further includes a log buffer, and the microcontroller is further configured to write the log data to be transmitted into the log buffer if it is determined that the serial peripheral interface line and the asynchronous serial transceiver line are not successfully established.
[0099] In some implementations, the microprocessor is further configured to receive a log reading request sent by the vehicle system, and based on the log reading request, send the stored log data to the vehicle system, so that the vehicle system transmits the log data to the connected mobile storage device; or, The microprocessor is also used to receive the diagnostic instruction sent by the diagnostic device and determine whether the diagnostic instruction is a data reading instruction. If so, the stored log data is sent to the diagnostic device.
[0100] In some embodiments, the serial peripheral interface line includes a serial peripheral host transmission channel, a serial peripheral host receiving channel, a host handshake input channel, and a host handshake output channel, and the asynchronous serial transceiver line includes an asynchronous serial host transmission channel and an asynchronous serial host receiving channel; the microcontroller is further used to send a handshake input signal to the microprocessor through the host handshake input channel if the target line is a serial peripheral interface line, and the microprocessor is further used to start data transmission with the microcontroller in response to the handshake input signal, so that the microcontroller transmits the log data to be transmitted through the serial peripheral host receiving channel; and, The microcontroller is also used for sending the log data to be transmitted to the microprocessor through the asynchronous serial host receiving channel if the target line is an asynchronous serial transceiver line.
[0101] In some implementations, the microprocessor is further configured to store the received log data into a disk by running an open source code file.
[0102] The vehicle-mounted communication terminal provided in the embodiment of the present application has execution steps and beneficial effects which are not described in detail here.
[0103] Figure 4 Schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Figure 4 As shown, the electronic device 400 includes one or more processors 401 and a memory 402 .
[0104] The processor 401 may be a central processing unit (CPU) or other forms of processing units having data processing capabilities and / or instruction execution capabilities, and may control other components in the electronic device 400 to perform desired functions.
[0105] The memory 402 may include one or more computer program products, which may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. The volatile memory may include, for example, random access memory (RAM) and / or cache memory (cache), etc. The non-volatile memory may include, for example, read-only memory (ROM), hard disk, flash memory, etc. One or more computer program instructions may be stored on the computer-readable storage medium, and the processor 301 may run the program instructions to implement the log extraction method of the vehicle-mounted communication terminal of any embodiment of the present application described above and / or other desired functions. Various contents such as initial external parameters, thresholds, etc. may also be stored in the computer-readable storage medium.
[0106] In one example, the electronic device 400 may further include: an input device 403 and an output device 404, which are interconnected via a bus system and / or other forms of connection mechanisms (not shown). The input device 403 may include, for example, a keyboard, a mouse, etc. The output device 404 may output various information to the outside, including early warning prompt information, braking force, etc. The output device 404 may include, for example, a display, a speaker, a printer, a communication network and a remote output device connected thereto, etc.
[0107] Of course, to simplify, Figure 4 Only some of the components related to the present application in the electronic device 400 are shown, and components such as a bus, an input / output interface, etc. are omitted. In addition, according to specific application conditions, the electronic device 400 may also include any other appropriate components.
[0108] In addition to the above-mentioned methods and devices, an embodiment of the present application may also be a computer program product, which includes computer program instructions, which, when executed by a processor, enable the processor to execute the steps of the log extraction method for the vehicle-mounted communication terminal provided in any embodiment of the present application.
[0109] The computer program product may be written in any combination of one or more programming languages to write program codes for performing the operations of the embodiments of the present application, including object-oriented programming languages, such as Java, C++, etc., and conventional procedural programming languages, such as "C" language or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user computing device, as an independent software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server.
[0110] In addition, an embodiment of the present application may also be a computer-readable storage medium on which computer program instructions are stored. When the computer program instructions are executed by a processor, the processor executes the steps of the log extraction method for the vehicle-mounted communication terminal provided in any embodiment of the present application.
[0111] The computer readable storage medium can adopt any combination of one or more readable media. The readable medium can be a readable signal medium or a readable storage medium. The readable storage medium can include, for example, but is not limited to, a system, device or device of electricity, magnetism, light, electromagnetic, infrared, or semiconductor, or any combination of the above. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or 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.
[0112] It should be noted that the terms used in this application are only for describing specific embodiments, rather than limiting the scope of this application. As shown in the specification and claims of this application, unless the context clearly indicates an exception, the words "one", "a", "a kind of" and / or "the" do not specifically refer to the singular, but may also include the plural. The terms "include", "comprise" or any other variant thereof are intended to cover non-exclusive inclusion, so that the process, method or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method or device. In the absence of further restrictions, the elements defined by the sentence "including one..." do not exclude the presence of other identical elements in the process, method or device including the elements.
[0113] It should also be noted that the terms "center", "up", "down", "left", "right", "vertical", "horizontal", "inside", "outside", etc., indicating the orientation or position relationship, are based on the orientation or position relationship shown in the drawings, and are only for the convenience of describing the present application and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation on the present application. Unless otherwise clearly specified and limited, the terms "installed", "connected", "connected", etc. should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be an indirect connection through an intermediate medium, or it can be a connection between the two elements. For those of ordinary skill in the art, the specific meanings of the above terms in this application can be understood according to specific circumstances.
[0114] This article uses specific examples to illustrate the principles and implementation methods of this application. The description of the above embodiments is only used to help understand the method and its core ideas of this application. The above is only the preferred implementation method of this application. It should be pointed out that due to the limitations of textual expression and the objective existence of infinite specific structures, ordinary technicians in this technical field can make several improvements, modifications or changes without departing from the principles of this application, and can also combine the above technical features in an appropriate manner; these improvements, modifications, changes or combinations, or the direct application of the concept and technical solution of the invention to other occasions without improvement, should be regarded as the scope of protection of this application.
Claims
1. A log extraction method for a vehicle-mounted communication terminal, characterized in that: The method is applied to a vehicle-mounted communication terminal, the vehicle-mounted communication terminal includes a microcontroller and a microprocessor, the microcontroller includes a print output serial port, a serial peripheral interface line and an asynchronous serial transceiver line exist between the microcontroller and the microprocessor, and the method includes: The microcontroller determines the log level of the log data to be transmitted; In response to the log level being lower than a preset level, the microcontroller outputs the log data to be transmitted to the print output serial port; or, in response to the log level being greater than or equal to the preset level, determines a target line in the serial peripheral interface line and / or the asynchronous serial transceiver line based on the data volume or transmission frequency of the log data to be transmitted, and transmits the log data to be transmitted to the microprocessor via the target line.
2. The method according to claim 1, characterized in that Before outputting the log data to be transmitted to the print output serial port, the method further includes: The microcontroller obtains a flag bit of a serial port printing function; If the flag is function-on, the step of outputting the log data to be transmitted to the print output serial port is executed.
3. The method according to claim 2, characterized in that The method further comprises: The microcontroller receives the diagnostic instruction sent by the diagnostic device, and determines whether the diagnostic instruction is a function-enabling instruction. If so, the flag bit of the serial port printing function is set to function-enabling.
4. The method according to claim 1, characterized in that: Before determining the target line in the serial peripheral interface line and / or the asynchronous serial transceiver line, the method further includes: In response to detecting that the vehicle-mounted communication terminal is restarted, the microcontroller determines whether a serial peripheral interface line and an asynchronous serial transceiver line between the microprocessor and the microprocessor are successfully established; If yes, the microcontroller executes the step of determining a target line in the serial peripheral interface line and / or the asynchronous serial transceiver line.
5. The method according to claim 4, characterized in that The microcontroller also includes a log buffer; the method also includes: If the microcontroller determines that the serial peripheral interface line and the asynchronous serial transceiver line are not successfully established, the log data to be transmitted is written into the log buffer.
6. The method according to claim 1, characterized in that The method further comprises: The microprocessor receives a log reading request sent by the vehicle system, and based on the log reading request, sends the stored log data to the vehicle system, so that the vehicle system transmits the log data to the connected mobile storage device; or, The microprocessor receives the diagnostic instruction sent by the diagnostic device, and determines whether the diagnostic instruction is a data reading instruction. If so, the microprocessor sends the stored log data to the diagnostic device.
7. The method according to claim 1, characterized in that The serial peripheral interface circuit includes a serial peripheral host transmission channel, a serial peripheral host receiving channel, a host handshake input channel and a host handshake output channel, and the asynchronous serial transceiver circuit includes an asynchronous serial host transmission channel and an asynchronous serial host receiving channel; Transmitting the to-be-transmitted log data to the microprocessor through the target line includes: If the target line is the serial peripheral interface line, the microcontroller sends a handshake input signal to the microprocessor through the host handshake input channel, and the microprocessor starts data transmission with the microcontroller in response to the handshake input signal, so that the microcontroller transmits the log data to be transmitted through the serial peripheral host receiving channel; as well as, If the target line is the asynchronous serial transceiver line, the microcontroller sends the log data to be transmitted to the microprocessor through the asynchronous serial host receiving channel.
8. The method according to claim 1, characterized in that After transmitting the to-be-transmitted log data to the microprocessor via the target line, the method further includes: The microprocessor stores the received log data in a disk by running the open source code file.
9. A vehicle-mounted communication terminal, characterized in that: The vehicle-mounted communication terminal includes a microcontroller and a microprocessor, the microcontroller includes a print output serial port, and a serial peripheral interface circuit and an asynchronous serial transceiver circuit exist between the microcontroller and the microprocessor, wherein: The microcontroller is used to determine the log level of the log data to be transmitted, and in response to the log level being lower than a preset level, output the log data to be transmitted to the print output serial port, or, in response to the log level being greater than or equal to the preset level, determine a target line in the serial peripheral interface line and / or the asynchronous serial transceiver line based on the data volume or transmission frequency of the log data to be transmitted, and transmit the log data to be transmitted to the microprocessor via the target line.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a program or an instruction, and the program or the instruction enables a computer to execute the steps of the log extraction method of the vehicle-mounted communication terminal according to any one of claims 1 to 8.
Citation Information
Patent Citations
Log printing method, system and device
CN108563576A
A debugging log grading method based on a whitley platform under a server management system
CN109918301A
Method and device for modifying log output level, electronic equipment and storage medium
CN111488230A
Embedded log management system and method
CN112306834A
Method, system and equipment for realizing effective positioning of log and storage medium
CN114675991A
