Log sending method and device of electronic control unit and storage medium
By receiving log calibration instructions and output instructions in the electronic control unit (ECU), storing and marking log information, and performing log output based on these instructions, the problem of not being able to classify the output of ECU operation status information in the prior art is solved, and the correct implementation is achieved Efficient classification and output of ECU logs.
Patent Information
- Application Number
- CN202411447392.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-16
- Publication Date
- 2025-02-07
AI Technical Summary
The prior art cannot classify the operation status information of an electronic control unit (ECU) based on the software unit and the status type.
By receiving the log marking instruction sent by the upper computer, the original log of the target electronic control unit is stored in the target buffer area, and tag information, including the first tag information and the second tag information, is added to it to distinguish between the target log and the non-target log. . Then, according to the log output instruction, the target log carrying the first mark information is sent from the specified starting address.
It realizes the classification calibration and output of the ECU logs, which facilitates users to quickly understand the operating status of each ECU software unit.
Smart Images

Figure CN119396651A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of log processing, and in particular to a log sending method, device, storage medium and electronic device of an electronic control unit. Background Art
[0002] In the prior art, during the operation of the Electronic Control Unit (ECU) on a car, the outside world can only control the functional modules inside the ECU and obtain the operating status of the ECU through limited means such as the Diagnostic Communication Manager (DCM), but cannot classify and output the operating status information of the ECU based on software units and status types. Summary of the invention
[0003] In order to solve at least one of the above-mentioned technical problems, the present disclosure proposes a log sending method, device, storage medium and electronic device of an electronic control unit.
[0004] According to one aspect of the present disclosure, a log sending method of an electronic control unit is provided, comprising:
[0005] Receive a log calibration instruction sent by a host computer; the log calibration instruction includes a target log unit type and a target log state type;
[0006] Storing the original log corresponding to the target electronic control unit in the target buffer area;
[0007] Adding marking information to the original log in the target buffer; the marking information includes first marking information and second marking information, wherein the target log in the original log carries the first marking information, and the non-target log in the original log carries the second marking information; the unit type of the target log is the target log unit type, and the state type of the target log is the target log state type;
[0008] Receive a log output instruction from the host computer; the log output instruction includes a log output starting address;
[0009] When the log output control information corresponding to the original log is the on information, the target log carrying the first mark information is sent from the log output start address, and the log output control information is used to represent the total switch information of the log record output of the control target electronic control unit.
[0010] In some possible implementations, the method further includes:
[0011] In response to receiving a control information address location instruction sent by the host computer, determining address information of the log output control information corresponding to the original log;
[0012] When the address information of the log output control information is located, sending an address location success instruction to the host computer, so that the host computer generates an output control update instruction after receiving the address location success instruction;
[0013] In response to receiving the output control update instruction sent by the host computer, the log output control information corresponding to the original log is updated to enable information.
[0014] In some possible implementations, sending the target log carrying the first marking information from the log output start address includes:
[0015] If the length of the target log is greater than a preset log length, dividing the target log into at least one target log package based on the preset log length;
[0016] The at least one target log package is sent to the host computer in sequence based on the timestamp, where the timestamp is the first target log timestamp in the target log package.
[0017] In some possible implementations, the original log includes at least one log record, each log record includes a unit type, a field, and a state type field; and adding tag information to the original log in the target buffer area includes:
[0018] Based on the target log unit type and the target log state type, the target log is determined from the original log; the field value of the unit type field of the target log is the target log unit type, and the field value of the state type field of the target log is the target log state type;
[0019] Add a tag field to the target log; the field value of the tag field of the target log is the first tag information;
[0020] A mark field is added to the non-target log in the original log; and the field value of the mark field of the non-target log is the second mark information.
[0021] In some possible implementations, determining the target log from the original log based on the target log unit type and the target log state type includes:
[0022] Matching the unit type of each log, the field value of the field and the field value of the status type field in the original log with the target log unit type and the target log status type respectively;
[0023] The unit type of each log in the original log, the field value of the field is the target log unit type and the field value of the status type field of each log in the original log is the target log status type. The log record is determined as the target log.
[0024] In some possible implementations, the method further includes:
[0025] Periodically checking whether the size of the original log in the target buffer area meets a preset size condition;
[0026] If satisfied, the original log is copied to a target storage area, where the target storage area is used to represent a storage area with non-volatility.
[0027] In some possible implementations, the method further includes:
[0028] In response to the initialization operation, the target period log within a preset period in the target storage area is copied to the target buffer area.
[0029] According to a second aspect of the present disclosure, a log sending device for an electronic control unit is provided, the device comprising:
[0030] The calibration instruction receiving module is used to receive the log calibration instruction sent by the host computer; the log calibration instruction includes a target log unit type and a target log state type;
[0031] A transfer module, used for storing the original log corresponding to the target electronic control unit into the target buffer area;
[0032] a marking module, configured to add marking information to the original log in the target buffer; the marking information includes first marking information and second marking information, wherein the target log in the original log carries the first marking information, and the non-target log in the original log carries the second marking information; the unit type of the target log is the target log unit type, and the state type of the target log is the target log state type;
[0033] An output instruction receiving module, used for receiving a log output instruction from the host computer; the log output instruction includes a log output starting address;
[0034] A sending module is used to send a target log carrying the first marking information from the log output start address when the log output control information corresponding to the original log is the opening information, wherein the log output control information is used to represent the total switch information of the log record output of the control target electronic control unit.
[0035] According to a third aspect of the present disclosure, an electronic device is provided, comprising at least one processor and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the at least one processor implements a log sending method for an electronic control unit as described in any one of the first aspects by executing the instructions stored in the memory.
[0036] According to a fourth aspect of the present disclosure, a computer-readable storage medium is provided, in which at least one instruction or at least one program is stored, and the at least one instruction or at least one program is loaded and executed by a processor to implement a log sending method for an electronic control unit as described in any one of the first aspects.
[0037] It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
[0038] The implementation of this disclosure has the following beneficial effects:
[0039] Receive the log calibration instruction sent by the host computer; the log calibration instruction includes the target log unit type and the target log status type; the host computer sends the unit and type of the required log to the target electronic control unit, stores the original log corresponding to the target electronic control unit in the target buffer area, and stores the original log on the temporary storage of the target electronic control unit in the fixed storage area, namely the target buffer area, to prevent the original log from being erased; add marking information to the original log in the target buffer area; wherein the target log in the original log carries the first marking information, and the non-target log in the original log carries the second marking information; the unit type of the target log is the target log unit type, and the status type of the target log is the target log status type; before obtaining the log, the original log is first classified and calibrated based on the target log unit type and the target log status type, so as to output the target log. Receive the log output instruction of the host computer; the log output instruction includes the log output starting address; send the target log carrying the first marking information from the log output starting address. Export the log records corresponding to the required unit type and status type in the fixed address, so that users can quickly understand the running status of each software unit of the ECU.
[0040] Further features and aspects of the present disclosure will become apparent from the following detailed description of exemplary embodiments with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] In order to more clearly illustrate the technical solution of the present application, the following is a brief introduction to the drawings required for use in the embodiments or prior art descriptions. Obviously, the drawings described below are only some embodiments of the present application, and for ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0042] Figure 1 A schematic flow chart showing a log sending method of an electronic control unit according to an embodiment of the present disclosure;
[0043] Figure 2 A schematic diagram showing a flow chart of a method for updating log output control information of an original log according to an embodiment of the present disclosure;
[0044] Figure 3 A schematic diagram showing a flow chart of a calibration method according to an embodiment of the present disclosure;
[0045] Figure 4 A schematic diagram showing a flow chart of a method for interacting between a target electronic control unit and a host computer according to an embodiment of the present disclosure;
[0046] Figure 5 A schematic diagram showing a flow chart of a target log sub-packaging and sending method according to an embodiment of the present disclosure;
[0047] Figure 6 A schematic diagram showing a flow chart of a method for adding a tag field according to an embodiment of the present disclosure;
[0048] Figure 7 A schematic diagram showing a flow chart of a target log determination method according to an embodiment of the present disclosure;
[0049] Figure 8 A schematic diagram showing a flow chart of a backup method according to an embodiment of the present disclosure;
[0050] Fig. 9 A schematic structural diagram of a log sending device of an electronic control unit according to an embodiment of the present disclosure is shown;
[0051] Fig.10 A block diagram of an electronic device according to an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0052] The following will be combined with the drawings in the embodiments of this specification to clearly and completely describe the technical solutions in the embodiments of this specification. Obviously, the described embodiments are only part of the embodiments of this specification, not all of the embodiments. Based on the embodiments in this specification, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0053] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product, or server that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products, or devices.
[0054] Various exemplary embodiments, features and aspects of the present disclosure will be described in detail below with reference to the accompanying drawings. The same reference numerals in the accompanying drawings represent elements with the same or similar functions. Although various aspects of the embodiments are shown in the accompanying drawings, the drawings are not necessarily drawn to scale unless otherwise specified.
[0055] The word “exemplary” is used exclusively herein to mean “serving as an example, example, or illustration.” Any embodiment described herein as “exemplary” is not necessarily to be construed as preferred or advantageous over other embodiments.
[0056] The term "and / or" herein is only a description of the association relationship of the associated objects, indicating that there may be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the term "at least one" herein represents any combination of at least two of any one or more of a plurality of. For example, including at least one of A, B, and C can represent including any one or more elements selected from the set consisting of A, B, and C.
[0057] In addition, in order to better illustrate the present disclosure, numerous specific details are given in the following specific embodiments. It should be understood by those skilled in the art that the present disclosure can also be implemented without certain specific details. In some examples, methods, means, components and circuits well known to those skilled in the art are not described in detail in order to highlight the subject matter of the present disclosure.
[0058] Figure 1 A flow chart of a log sending method of an electronic control unit according to an embodiment of the present disclosure is shown as follows: Figure 1 As shown, the above method includes:
[0059] S101, receiving a log calibration instruction sent by a host computer; the log calibration instruction includes a target log unit type and a target log state type;
[0060] The execution subject of this application is the target electronic control unit (ECU) of the automobile, and the host computer includes but is not limited to handheld computers, desktop computers, mobile phones, personal digital assistants and various combinations of the aforementioned devices. The electronic equipment on the car can be connected to a network using a bus through the universal measurement and calibration protocol (Extended Calibration Protocol, XCP) to achieve data sharing between the on-board electronic control units. This application can use the measurement and calibration software CANape and the VX1000 analysis tool, combined with the host computer control software, to send information in a preset format to the ECU, triggering the log output inside the ECU.
[0061] In some embodiments, the host computer is connected to the target electronic control unit of the automobile by communication, and the host computer sends a log calibration instruction to the target electronic control unit, and the log calibration instruction includes a target log unit type and a target log status type. The target electronic control unit includes a plurality of software units, and the software unit can be an application layer software, a bottom layer software and a boot program in the target electronic control unit. The target log unit type is used to characterize the software unit to which the log to be sent belongs, and the target log status type is used to characterize the type to which the log to be sent belongs. The target log unit includes but is not limited to one or more of a microcontroller unit (MCU), an analog-to-digital converter (ADC), a port (PORT), a serial peripheral interface (SPI) and a digital input / output (DIO). The target log status type includes but is not limited to one or more of an error (Error), a warning (Warning), a debug (Debug) and an information (Info).
[0062] S102, storing the original log corresponding to the target electronic control unit into the target buffer area;
[0063] The original log is obtained from the temporary storage area of the target electronic control unit, and the original log is stored in the target buffer area of the target electronic control unit, and the target buffer area can be a fixed storage area. The temporary storage area is an area where the operation logs generated by each software unit of the target electronic control unit are temporarily stored.
[0064] In some embodiments, the target cache area is a cache area with a fixed address divided from a main memory random access memory (RAM) of the target electronic control unit.
[0065] S103, adding marking information to the original log in the target buffer area; the marking information includes first marking information and second marking information, wherein the target log in the original log carries the first marking information, and the non-target log in the original log carries the second marking information; the unit type of the target log is the target log unit type, and the state type of the target log is the target log state type;
[0066] Marking information is added to the original log in the target buffer area based on the target log unit type and the target log state type.
[0067] In some embodiments, the first tag information is used to characterize the information of log opening output, and the second tag information is used to characterize the information of log closing output; the target log in the original log is determined based on the target log unit type and the target log status type, the first tag information is added to the target log, and the second tag information is added to the non-target log.
[0068] In some embodiments, the target log unit type is MCU, the target log status type is Error, and the first tag information is added to the Error type log record belonging to the MCU in the original log to obtain the target log carrying the first tag information. Exemplarily, the first tag information may be 1. The second tag information is added to the log record that does not belong to the MCU or is not an Error type in the original log to obtain a non-target log carrying the second tag information. Exemplarily, the second tag information may be 0.
[0069] In some embodiments, a record output control field is added to each log record of the original log, and the field value of the record output control field corresponding to each log record of the original log defaults to the second marking information; the method of adding the first marking information includes: updating the field value of the record output control field corresponding to the target log to the first marking information.
[0070] S104, receiving a log output instruction from a host computer; the log output instruction includes a log output starting address;
[0071] The log output start address includes a start address and an end address. The host computer sends the log output start address to the target electronic control unit. The target electronic control unit determines the output range of the original log in the target buffer area according to the log output start address, and sends an address setting success instruction to the host computer. After receiving the address setting success instruction, the host computer sends a log output instruction to the target electronic control unit.
[0072] S105. When the log output control information corresponding to the original log is on information, a target log carrying first marking information is sent starting from the log output start address, wherein the log output control information is used to represent the total switch information of the log record output of the target electronic control unit.
[0073] The target electronic control unit receives the log upload instruction sent by the host computer. If the log output control information corresponding to the original log is the open information, the target log is sent to the host computer from the output range of the original log. The log output control information is the total switch information for controlling the log record output of the target electronic control unit. The log output control information includes the open information and the close information. If the log output control information is the open information, the log output interface corresponding to each software unit is in the activated state, and each software unit can call the log output interface to output the log record. If the log output control information is the close information, the log output interface corresponding to each software unit is in the deactivated state, and each software unit cannot call the log output interface to output the log record.
[0074] In some embodiments, a target log carrying first tag information is sent based on a preset format starting from the log output start address. The preset format may be that the target log includes a timestamp, state type information, unit type information, and log content information, the unit type information is used to characterize a software unit in an electronic control unit, and the state type information includes an error type log (Error), a warning type log (Warning), a debug type log (Debug), and an information type log (Info), as shown in Table 1.
[0075] Table 1. Log output format
[0076]
[0077]
[0078] In some embodiments, each software unit of the target electronic control unit can call a log output interface, which includes but is not limited to an error log output interface, a warning log output interface, a debug log output interface, and an information log output interface. The target log is output to the host computer by calling the log output interface corresponding to the target log status type through the software unit corresponding to the target log unit type.
[0079] The above technical solution calibrates the units and types specified in the original log of the target electronic control unit through the host computer according to user needs, and then uploads the target log within the specified range according to the starting address sent by the host computer, and outputs various types of operation logs of various functional modules of the electronic control unit in a targeted manner, so that users can quickly understand or record the operating status of a certain functional module during the development process or problem location process.
[0080] See also Figure 2 In some embodiments, the method further comprises:
[0081] S201, in response to receiving a control information address location instruction sent by a host computer, determining address information of log output control information corresponding to the original log;
[0082] S202, when the address information of the log output control information is located, sending an address location success instruction to the upper computer, so that the upper computer generates an output control update instruction after receiving the address location success instruction;
[0083] S203: In response to receiving the output control update instruction sent by the host computer, the log output control information corresponding to the original log is updated to enable information.
[0084] The log output control information is used to represent the total switch information of the log record output of the target electronic control unit; before the log record output is performed, the host computer first needs to send an instruction to update the log output control information to the open information. The update process of the log output control information is as follows: the host computer communicates with the target electronic control unit of the vehicle, the host computer can read the address information of the original log in the target electronic control unit, the host computer sends a control information address positioning instruction, the target electronic control unit receives the control information address positioning instruction sent by the host computer, the target electronic control unit locates the address of the log output control information, obtains the address information of the log output control information, sends an address positioning success instruction to the host computer, after the host computer receives the address positioning success instruction sent by the target electronic control unit, sends an output control update instruction to the target electronic control unit, after the target electronic control unit receives the output control update instruction, it updates the log output control information to the open information, and sends an update confirmation instruction to the host computer.
[0085] In some embodiments, the log output control information is set to off information by default. The off information is used to indicate that the general switch for uploading logs is off, and the on information is used to indicate that the general switch for uploading logs is on. Figure 3 As shown, in the calibration process of the log output control information, in the first message, the host computer sends a control information address location instruction to the target electronic control unit, and the control information address location instruction will write a new address value. In the second message, the target electronic control unit confirms the instruction and sends an address location success instruction. The third message transmits the output control update instruction, including the hexadecimal value and the number of valid bytes. The number of valid bytes is 4. In the fourth message, the target electronic control unit confirms the instruction and sends an update confirmation instruction to the host computer. Involving the communication between the host computer and the electronic control unit, if the log output control information needs to be updated to the electronic control unit, the host computer needs to notify the electronic control unit of the location of the parameters and the content of the updated parameters.
[0086] In some embodiments, the target log unit type and target log state type calibration process is similar to the log output control information calibration process. Take the target log unit type as an example:
[0087] The target electronic control unit receives the target log unit address positioning instruction sent by the host computer, the target electronic control unit locates the address of the target log unit, obtains the address information of the target log unit, and sends an address positioning success instruction to the host computer. After the host computer receives the address positioning success instruction sent by the target electronic control unit, it sends a first log calibration instruction to the target electronic control unit, receives the first log calibration instruction sent by the host computer, the first log calibration instruction includes the target log unit type, and updates the unit mark bit of the log record corresponding to the target log unit type in the original log to the output enable mark.
[0088] For log output control information, the XCP protocol usually uses 5 bytes to define the address, of which 4 bytes are used for the actual address and 1 byte is used for address extension. If the log output control information is set to a 4-byte value and you want to send these two pieces of information in one CAN message at the same time, there is not enough space to complete this operation. Therefore, the calibration request process is that the host computer sends two instructions to the target electronic control unit, and the target electronic control unit confirms that these two instructions are completed, which solves the problem that a CAN message cannot complete a complete calibration request. The same XCP operation process controls the variables in the log output request: log output control information, target log unit type, and target log status type can all be controlled to achieve the control of the unit type and status type of the log output.
[0089] In some embodiments, the target electronic control unit receives the output control update instruction sent by the host computer, updates the log output control information to the opening information, so as to open all log output interfaces, and the opening information is used to characterize that the main switch of log upload is in the opening state. Receive the log calibration instruction sent by the host computer, the log calibration instruction includes the target log unit type and the target log state type, add the first mark information to the log record corresponding to the target log unit type and the target log state type in the original log, exemplarily, the target log unit type is MCU, the target log state type is Debug, in the MCU software module, all Debug log records add the first mark information, the log output interface of the target log carrying the first mark information is the warning log output interface has been activated and enabled by the output control update instruction, when the software runs to the corresponding position, the corresponding log content will be combined with the state type information, the unit type information and the timestamp, and sent to the low priority log sending task for processing.
[0090] The priority of the log sending task is the lowest in the system, and the impact on the load of the operating system of the entire system is minimized. The log sending task receives the log storage data of each software unit and saves it to the set target cache area. When the log in the target cache area meets the preset size condition, the data in the target cache area is synchronized to the target storage area for data backup. When the log output instruction of the host computer is received, the log data saved in the log output start address in the target cache area is sent to the host computer according to the XCP message protocol.
[0091] If the host computer needs to stop receiving log information, the host computer sends an output control update instruction. After receiving the control update instruction, the target electronic control unit updates the log output control information to the shutdown information, deactivates various log output interfaces of all software units, and stops the output of the target log.
[0092] See also Figure 4 The target electronic control unit receives the diary enable instruction sent by the host computer based on the XCP protocol. The diary enable instruction includes an output control update instruction and a log calibration instruction to activate and enable the log output interface corresponding to the target log status type of the target log unit type. The diary print task (Log PrintTask) in the target electronic control unit receives the original diary generated by the application software unit (Application SW), performs data transfer, and copies the original diary from the target buffer area to the target storage area. The target buffer area can be ram, and the target storage area can be flash. The host computer sends a log output instruction, and the log output instruction includes a log print task receiving a log output instruction, and outputting the target log based on the XCP protocol.
[0093] The above technical solution controls the main switch of log output through log output control information, and can turn on and off log output with one click, thereby improving log output efficiency and facilitating users.
[0094] See also Figure 5 In some embodiments, sending a target log carrying first tag information from a log output start address includes:
[0095] S1051. If the length of the target log is greater than the preset log length, split the target log into at least one target log package based on the preset log length;
[0096] S1052: Send at least one target log package to the host computer in sequence based on the timestamp, where the timestamp is the first target log timestamp in the target log package.
[0097] The target range of the original log is confirmed based on the log output start address, the log record with the first tag information is searched within the target range, and the log record with the first tag information is used as the target log.
[0098] In some embodiments, the host computer sends a log output start address to a target electronic control unit. After the target electronic control unit locates the log output start address in the original log, it sends a confirmation message to the host computer. The host computer sends an upload instruction to the target electronic control unit. The target electronic control unit receives the upload instruction and uploads a target log with first tag information from the log output start address. If the length of the target log is greater than a preset log length, the target log is sent sequentially in multiple times based on the preset log length and the timestamp of the target log.
[0099] The above technical solution, when the target log is long, sends the target log in sequence for multiple times to avoid blockage or failure in the process of log sending.
[0100] See also Figure 6 In some embodiments, the original log includes at least one log record, each log record includes a unit type, field, and a state type field; adding marking information to the original log in the target buffer area includes:
[0101] S1031, based on the target log unit type and the target log state type, determine the target log from the original log; the field value of the unit type field of the target log is the target log unit type, and the field value of the state type field of the target log is the target log state type;
[0102] S1032, adding a tag field to the target log; the field value of the tag field of the target log is the first tag information;
[0103] S1033: Add a mark field to the non-target log in the original log; the field value of the mark field of the non-target log is the second mark information.
[0104] In some embodiments, the target log in the original log is determined based on the target log unit type and the target log status type, and the target log is marked with first marking information, the first marking information is used to represent output enable information, and the non-target log is marked with second marking information, the second marking information is used to represent output disable information.
[0105] In some embodiments, a record output control field is added to each log record of the original log, and the field value of the record output control field corresponding to each log record in the original log defaults to the second marking information; based on the target log unit type and the target log status type, the target log in the original log is determined, and the field value of the record output control field of the target log is updated to the first marking information.
[0106] In some embodiments, the unit type field corresponding to each log record of the original log is associated with a unit mark bit, and the state type field corresponding to each log record of the original log is associated with a type mark bit. The mark information of the unit mark bit corresponding to each log record of the original log and the mark information of the type mark bit corresponding to each log record are both output closing marks by default. The process of adding the first mark information includes: receiving a first log calibration instruction sent by a host computer, the first log calibration instruction includes a target log unit type, and updating the unit mark bit of the log record corresponding to the target log unit type in the original log to an output opening mark; receiving a second log calibration instruction sent by the host computer, the second log calibration instruction includes a target log state type, and updating the type mark bit of the log record corresponding to the target log state type in the original log to an output opening mark; determining the log record in which the unit mark bit and the type mark bit in the target in the original log are both output opening marks as the target log, and the first mark information includes that the unit mark bit and the type mark bit are both output opening marks. The second mark information includes that the unit mark bit is an output closing mark or the type mark bit is an output closing mark.
[0107] In the above technical solution, the host computer calibrates the unit and type of the original log in advance according to the actual log requirements, so that the target electronic control unit outputs the log of the unit and type required by the host computer, which is convenient for users to quickly and clearly locate the log content.
[0108] See also Figure 7 In some embodiments, based on the target log unit type and the target log state type, determining the target log from the original log includes:
[0109] S10311, matching the unit type of each log, the field value of the field, and the field value of the status type field in the original log with the target log unit type and the target log status type respectively;
[0110] S10312: Determine as a target log the log record whose unit type field of each log in the original log has a field value of the target log unit type and whose state type field of each log in the original log has a field value of the target log state type.
[0111] In some embodiments, the unit type of each log record in the original log and the field value corresponding to the field are detected. If the unit type of the log record and the field value corresponding to the field match the target log unit type, the log record is confirmed to be a first target unit log; the field value corresponding to the status type field of each log record in the original log is detected. If the field value corresponding to the status type field of the log record matches the target log status type, the log record is confirmed to be a second target unit log. The log records that exist in both the first target unit log and the second target unit log are target logs.
[0112] The above technical solution queries the target log unit type and the target log status type from the original log, outputs them as the target log, and outputs different types of log information of the operation of each functional module of the ECU, so that the user can record the status of each functional module in real time during the development process or problem location process.
[0113] See also Figure 8 In some embodiments, the method further comprises:
[0114] S301, periodically checking whether the size of the original log in the target buffer area meets a preset size condition;
[0115] S302: If satisfied, copy the original log to a target storage area, where the target storage area is used to represent a non-volatile storage area.
[0116] In some embodiments, the target cache area is used to represent a main storage area with a fixed address, the target cache area may be an area with a fixed address divided from a RAM, and the target storage area may be a flash memory (Flash).
[0117] In some embodiments, a special periodic task with low priority is created to process the host computer log control information and the log printing information of each unit. It is mainly used for data synchronization of log messages in the target buffer area (RAM) and the target storage area (FLASH). The task will always receive the log output data of each module unit in the ECU controller. The log output data includes timestamp, status type information, unit type information and log content information. When the log accumulates to a preset size, data is moved. The data information in the target buffer area (RAM) is moved to the target storage area (FLASH) based on the XCP protocol.
[0118] In some embodiments, the address association between the target cache area and the target storage area is achieved by hardware means, that is, a hardware address mapping method supported by the chip, through register configuration.
[0119] In other embodiments, synchronous storage of the target cache area and the target storage area address space is achieved by adding an address offset.
[0120] The above technical solution stores the log data in the target buffer area and the target storage area, and while realizing the online output of the log, the log data is double-backed up to prevent data loss after the vehicle loses power.
[0121] In some embodiments, the method further comprises:
[0122] In response to the initialization operation, the target period log within a preset period in the target storage area is copied to the target buffer area.
[0123] The preset cycle may be an ignition cycle, which may be the period between two initialization operations of the electronic control unit. When the target electronic control unit performs a power-on initialization operation, a log of an ignition cycle in the target storage area is copied to the target cache area.
[0124] The above technical solution can read the historical log data after the electronic control unit is powered on again to ensure that the data is not lost when the electronic control unit is unable to output the log online due to abnormal power supply of the vehicle or software crash, that is, when it is abnormally disconnected.
[0125] See also Fig. 9 According to a second aspect of the present disclosure, a log sending device for an electronic control unit is provided, the device comprising:
[0126] The calibration instruction receiving module 10 is used to receive the log calibration instruction sent by the host computer; the log calibration instruction includes the target log unit type and the target log state type;
[0127] The transfer module 20 is used to store the original log corresponding to the target electronic control unit into the target buffer area;
[0128] The marking module 30 is used to add marking information to the original log in the target buffer area; the marking information includes first marking information and second marking information, wherein the target log in the original log carries the first marking information, and the non-target log in the original log carries the second marking information; the unit type of the target log is the target log unit type, and the state type of the target log is the target log state type;
[0129] The output instruction receiving module 40 is used to receive the log output instruction of the host computer; the log output instruction includes the log output starting address;
[0130] The sending module 50 is used to send the target log carrying the first marking information from the log output start address when the log output control information corresponding to the original log is the opening information, and the log output control information is used to represent the total switch information of the log record output of the control target electronic control unit.
[0131] In some embodiments, the apparatus further comprises:
[0132] An address information determination module, configured to determine address information of log output control information corresponding to the original log in response to receiving a control information address location instruction sent by the host computer;
[0133] A positioning success instruction sending module is used to send an address positioning success instruction to the upper computer when the address information of the log output control information is located, so that the upper computer generates an output control update instruction after receiving the address positioning success instruction;
[0134] The log output control information updating module is used to update the log output control information corresponding to the original log to the enabling information in response to receiving the output control updating instruction sent by the host computer.
[0135] In some embodiments, sending a target log carrying first tag information from a log output start address includes:
[0136] A segmentation module, used for segmenting the target log into at least one target log package based on the preset log length if the length of the target log is greater than the preset log length, and the timestamp is the timestamp of the first target log in the target log package;
[0137] The packet sending module is used to send at least one target log packet to the host computer in sequence based on the timestamp.
[0138] In some embodiments, the original log includes at least one log record, each log record includes a unit type, a field, and a state type field; the marking module includes:
[0139] The target log determination unit is used to determine the target log from the original log based on the target log unit type and the target log state type; the field value of the unit type field of the target log is the target log unit type, and the field value of the state type field of the target log is the target log state type;
[0140] A target log field marking unit is used to add a marking field to the target log; the field value of the marking field of the target log is the first marking information;
[0141] The non-target log field marking unit is used to add a marking field to the non-target log in the original log; the field value of the marking field of the non-target log is the second marking information.
[0142] In some embodiments, the target log determination unit includes:
[0143] A matching unit, used to match the unit type of each log, the field value of the field, and the field value of the status type field in the original log with the target log unit type and the target log status type respectively;
[0144] Determine the unit, which is used to determine the log record whose unit type of each log in the original log, the field value of the field is the target log unit type and the field value of the status type field of each log in the original log is the target log status type as the target log.
[0145] In some embodiments, the apparatus further comprises:
[0146] A detection module, used for periodically detecting whether the size of the original log in the target buffer area meets a preset size condition;
[0147] The backup module is used to copy the original log to the target storage area if the conditions are met, and the target storage area is used to represent a storage area with non-volatility.
[0148] In some embodiments, the apparatus further comprises:
[0149] The initialization copy module is used to copy the target period log within a preset period in the target storage area to the target buffer area in response to the initialization operation.
[0150] In some embodiments, the functions or modules included in the device provided by the embodiments of the present disclosure can be used to execute the method described in the above method embodiments. The specific implementation can refer to the description of the above method embodiments, and for the sake of brevity, it will not be repeated here.
[0151] An embodiment of the present application provides a log sending device for an electronic control unit, which may be a terminal or a server. The log sending device for the electronic control unit includes a processor and a memory, in which at least one instruction or at least one program is stored. The at least one instruction or the at least one program is loaded and executed by the processor to implement a log sending method for an electronic control unit as provided in the above method embodiment.
[0152] The memory can be used to store software programs and modules. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory. The memory can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, application programs required for functions, etc.; the data storage area can store data created according to the use of the device, etc. In addition, the memory can include a high-speed random access memory and can also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices. Accordingly, the memory can also include a memory controller to provide the processor with access to the memory.
[0153] The method embodiments provided in the embodiments of the present application can be executed in electronic devices such as mobile terminals, computer terminals, servers or similar computing devices. Fig.101 is a hardware structure block diagram of an electronic device of a log sending method of an electronic control unit provided in an embodiment of the present application. Fig.10 As shown, the electronic device 900 may have relatively large differences due to different configurations or performances, and may include one or more central processing units (CPU) 910 (the processor 910 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory 930 for storing data, and one or more storage media 920 (such as one or more mass storage devices) for storing application programs 923 or data 922. Among them, the memory 930 and the storage medium 920 can be short-term storage or permanent storage. The program stored in the storage medium 920 may include one or more modules, each of which may include a series of instruction operations in the electronic device. Furthermore, the central processing unit 910 can be configured to communicate with the storage medium 920 to execute a series of instruction operations in the storage medium 920 on the electronic device 900. The electronic device 900 may also include one or more power supplies 960, one or more wired or wireless network interfaces 950, one or more input and output interfaces 940, and / or one or more operating systems 921, such as Windows ServerTM, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM, etc.
[0154] The input / output interface 940 may be used to receive or send data via a network. The specific example of the network may include a wireless network provided by a communication provider of the electronic device 900. In one example, the input / output interface 940 includes a network adapter (Network Interface Controller, NIC), which may be connected to other network devices via a base station so as to communicate with the Internet. In one example, the input / output interface 940 may be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0155] It can be understood by those skilled in the art that Fig.10 The structure shown is only for illustration and does not limit the structure of the above electronic device. Fig.10 More or fewer components as shown, or with Fig.10 Different configurations shown.
[0156] An embodiment of the present application also provides a computer-readable storage medium, which can be set in an electronic device to store at least one instruction or at least one program related to a log sending method for an electronic control unit in a method embodiment. The at least one instruction or the at least one program is loaded and executed by the processor to implement the log sending method for the electronic control unit provided in the above method embodiment.
[0157] Optionally, in this embodiment, the storage medium may be located in at least one of the multiple network servers of the computer network. Optionally, in this embodiment, the storage medium may include, but is not limited to, various media that can store program codes, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk, or an optical disk.
[0158] According to one aspect of the present application, a computer program product or a computer program is provided, the computer program product or the computer program comprising computer instructions, the computer instructions being stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the methods provided in the above-mentioned various optional implementations.
[0159] As can be seen from the embodiments of the log sending method, device, equipment, terminal, server, storage medium or computer program of the electronic control unit provided by the above-mentioned application, the application receives the log calibration instruction sent by the host computer; the log calibration instruction includes the target log unit type and the target log state type; the host computer sends the unit and type of the required log to the target electronic control unit, stores the original log corresponding to the target electronic control unit in the target buffer area, and stores the original log on the temporary storage of the target electronic control unit in a fixed storage area, i.e., the target buffer area, to prevent the original log from being erased; add marking information to the original log in the target buffer area; wherein the target log in the original log carries the first marking information, and the non-target log in the original log carries the second marking information; the unit type of the target log is the target log unit type, and the state type of the target log is the target log state type; before obtaining the log, the original log is first classified and calibrated based on the target log unit type and the target log state type, so as to output the target log. Receive the log output instruction of the host computer; the log output instruction includes the log output starting address; send the target log carrying the first marking information from the log output starting address. The log information of the type and unit in the fixed address can be exported according to the required unit and type, so that users can quickly understand the operating status of each functional module of the ECU.
[0160] It should be noted that the above-mentioned sequence of the embodiments of the present application is for description only and does not represent the advantages and disadvantages of the embodiments. The above-mentioned specific embodiments of the present application are described. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0161] Each embodiment in this application is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device, equipment and storage medium embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0162] A person skilled in the art will understand that all or part of the steps to implement the above embodiments may be accomplished by hardware, or may be accomplished by instructing the relevant hardware through a program, and the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a disk or an optical disk, etc.
[0163] The above description is only a preferred embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application should be included in the protection scope of the present application.
Claims
1. A log sending method for an electronic control unit, characterized in that: The method comprises: Receive a log calibration instruction sent by a host computer; the log calibration instruction includes a target log unit type and a target log state type; Storing the original log corresponding to the target electronic control unit in the target buffer area; Adding marking information to the original log in the target buffer; the marking information includes first marking information and second marking information, wherein the target log in the original log carries the first marking information, and the non-target log in the original log carries the second marking information; the unit type of the target log is the target log unit type, and the state type of the target log is the target log state type; Receive a log output instruction from the host computer; the log output instruction includes a log output starting address; When the log output control information corresponding to the original log is the on information, the target log carrying the first mark information is sent from the log output start address, and the log output control information is used to represent the total switch information of the log record output of the control target electronic control unit.
2. The method according to claim 1, characterized in that The method further comprises: In response to receiving a control information address location instruction sent by the host computer, determining address information of the log output control information corresponding to the original log; When the address information of the log output control information is located, sending an address location success instruction to the host computer, so that the host computer generates an output control update instruction after receiving the address location success instruction; In response to receiving the output control update instruction sent by the host computer, the log output control information corresponding to the original log is updated to enable information.
3. The method according to claim 1, characterized in that The sending of the target log carrying the first marking information from the log output start address includes: If the length of the target log is greater than a preset log length, dividing the target log into at least one target log package based on the preset log length; The at least one target log package is sent to the host computer in sequence based on the timestamp, where the timestamp is the first target log timestamp in the target log package.
4. The method according to claim 1, characterized in that: The original log includes at least one log record, each log record includes a unit type, a field, and a status type field; the adding mark information to the original log in the target buffer area includes: Based on the target log unit type and the target log state type, the target log is determined from the original log; the field value of the unit type field of the target log is the target log unit type, and the field value of the state type field of the target log is the target log state type; Add a tag field to the target log; the field value of the tag field of the target log is the first tag information; A mark field is added to the non-target log in the original log; and the field value of the mark field of the non-target log is the second mark information.
5. The method according to claim 4, characterized in that The determining the target log from the original log based on the target log unit type and the target log state type comprises: Matching the unit type of each log, the field value of the field and the field value of the status type field in the original log with the target log unit type and the target log status type respectively; The log record whose unit type and field value of each log in the original log is the target log unit type and whose field value of the status type field of each log in the original log is the target log status type is determined as the target log.
6. The method according to claim 1, characterized in that The method further comprises: Periodically checking whether the size of the original log in the target buffer area meets a preset size condition; If satisfied, the original log is copied to a target storage area, where the target storage area is used to represent a storage area with non-volatility.
7. The method according to claim 6, characterized in that The method further comprises: In response to the initialization operation, the target period log within a preset period in the target storage area is copied to the target buffer area.
8. A log sending device for an electronic control unit, characterized in that: The device comprises: The calibration instruction receiving module is used to receive the log calibration instruction sent by the host computer; the log calibration instruction includes the target log unit type and the target log state type; A transfer module, used for storing the original log corresponding to the target electronic control unit into the target buffer area; a marking module, configured to add marking information to the original log in the target buffer; the marking information includes first marking information and second marking information, wherein the target log in the original log carries the first marking information, and the non-target log in the original log carries the second marking information; the unit type of the target log is the target log unit type, and the state type of the target log is the target log state type; An output instruction receiving module, used for receiving a log output instruction from the host computer; the log output instruction includes a log output starting address; A sending module is used to send a target log carrying the first marking information from the log output start address when the log output control information corresponding to the original log is the opening information, wherein the log output control information is used to represent the total switch information of the log record output of the control target electronic control unit.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores at least one instruction or at least one program, and the at least one instruction or at least one program is loaded and executed by the processor to implement the log sending method of the electronic control unit as described in any one of claims 1-7.
10. An electronic device, characterized in that: It includes at least one processor and a memory that is communicatively connected to the at least one processor; wherein the memory stores instructions that can be executed by the at least one processor, and the at least one processor implements the log sending method of the electronic control unit as described in any one of claims 1 to 7 by executing the instructions stored in the memory.