Message timestamp alignment method, electronic device and vehicle
By detecting and supplementing the sending cycle of CAN messages, it ensures that data of different cycles are aligned on the same time axis, solving the problem of data volume inconsistency and misalignment caused by different CAN message cycles, and achieving effective data alignment.
Patent Information
- Application Number
- CN202211239406.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-11
- Publication Date
- 2024-08-30
- Estimated Expiration
- 2042-10-11
AI Technical Summary
The CAN message periods sent between different ECUs are different, resulting in inconsistent data amounts and easily leading to data misalignment.
By detecting the alignment conditions between the sending cycle of the target message and the preset target cycle, data supplementation is performed to ensure that messages of different periods are aligned on the same timeline. Data supplementation methods include delayed interpolation, nonlinear adaptive interpolation and linear interpolation. Interpolate, verify and save.
It achieves one-to-one correspondence between data in different transmission cycles on the same timeline, ensuring that the data volume is consistent and effective, and avoiding data misalignment.
Smart Images

Figure CN115664592B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of vehicle communication, and in particular to a message timestamp alignment method, electronic equipment and a vehicle. Background Art
[0002] CAN is the abbreviation of Controller Area Network (CAN), which is one of the most widely used modern buses in the world. It has the characteristics of high accuracy, high speed and large amount of information. At present, CAN messages can communicate with each other through different ECUs (Electronic Control Units). ECU periodically sends messages to the CAN bus line, and the common cycles are 10ms, 20ms, 50ms, 100ms and other types. In the actual communication process, the message information to be obtained is sent in different cycles, for example: vehicle speed 10ms cycle, vehicle charging status message 10ms cycle, ambient temperature information 100ms cycle. Due to different message sending cycles in the same time period, different amounts of data will be obtained (usually the longer the cycle, the less data), which is easy to cause data misalignment. Summary of the invention
[0003] The purpose of the embodiments of the present invention is to provide a message timestamp alignment method, electronic device and vehicle, which can ensure that data with different sending cycles are aligned on the same time axis, so that messages with different sending cycles have the same amount of data and can correspond one-to-one on the same time axis, ensuring that the obtained data will not be misplaced and is valid.
[0004] To achieve the above object, an embodiment of the present invention provides a message timestamp alignment method, including:
[0005] When a target message that meets a preset parsing condition is detected to be transmitted on the bus, the target message is parsed to obtain target data;
[0006] Get the preset target period;
[0007] When the sending period of the target message and the target period meet a preset alignment condition, the target message is supplemented with data according to the target data.
[0008] As an improvement of the above solution, the alignment condition is:
[0009] The target message sending period is greater than the target period; or,
[0010] The sending period of the target message is smaller than the target period, and the target period is not a multiple of the sending period of the target message.
[0011] As an improvement of the above solution, before supplementing the target message with data according to the target data, the method further includes:
[0012] All target messages are classified according to the sending period of the target message, so as to classify the target messages with the same period into the same category; then, supplementing the target message with data according to the target data includes:
[0013] The target messages of different period categories are supplemented with data according to the target data.
[0014] As an improvement of the above solution, the step of supplementing the target message with data according to the target data includes:
[0015] The target data sent by the vehicle-mounted unit in the previous N times is obtained as the data sent by the vehicle-mounted unit in the current target period; wherein N is an integer greater than 1.
[0016] As an improvement of the above solution, the step of supplementing the target message with data according to the target data includes:
[0017] The target data sent by the vehicle-mounted unit for the previous M times are obtained, an M-1 order polynomial is fitted with the M target data, and the data that needs to be supplemented by the vehicle-mounted unit in the current target cycle is obtained according to the M-1 order polynomial; wherein M is an integer greater than 2.
[0018] As an improvement of the above solution, the step of supplementing the target message with data according to the target data includes:
[0019] The target data sent by the vehicle-mounted unit twice in succession is obtained, a linear function is constructed by linearization according to time, and the data that needs to be supplemented by the vehicle-mounted unit in the current target period is obtained according to the linear function.
[0020] As an improvement of the above solution, after the target message is supplemented with data according to the target data, the method further includes:
[0021] The supplemented data is verified, and the supplemented data is saved after the verification passes.
[0022] As an improvement to the above solution, the verification of the supplemented data includes at least one of the following verification methods:
[0023] Verifying the integrity of the supplemented data according to the target period; wherein each target period corresponds to a supplemented data;
[0024] Comparing the supplemented data with preset standard rules to find out data that does not meet the standard rules;
[0025] Calculate the change rate of several consecutive supplemented data to find out the mutation data;
[0026] The supplemented data is validated in the form of a character string to filter out data that does not conform to a set format.
[0027] To achieve the above objectives, an embodiment of the present invention also provides an electronic device, including a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein when the processor executes the computer program, the message timestamp alignment method as described in any of the above embodiments is implemented.
[0028] To achieve the above objective, an embodiment of the present invention further provides a vehicle, comprising a vehicle body and the electronic device described in the above embodiment.
[0029] Compared with the prior art, the message timestamp alignment method, electronic device and vehicle disclosed in the embodiment of the present invention, when a target message that meets the preset parsing conditions is detected to be transmitted on the bus, the target message is parsed to obtain target data; a preset target cycle is obtained; when the sending cycle of the target message and the target cycle meet the preset alignment conditions, the target message is supplemented with data according to the target data. It can ensure that data with different sending cycles are aligned on the same time axis, so that messages with different sending cycles have the same amount of data, and can correspond one to one on the same time axis, ensuring that the obtained data will not be misplaced and is valid. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] Figure 1 It is a flow chart of a message timestamp alignment method provided by an embodiment of the present invention;
[0031] Figure 2 is a schematic diagram of message data before filling provided by an embodiment of the present invention;
[0032] Figure 3 is a schematic diagram of message data after filling provided by an embodiment of the present invention;
[0033] Figure 4 is an interpolation schematic diagram of a nonlinear adaptive interpolation method provided by an embodiment of the present invention;
[0034] Figure 5 is an interpolation schematic diagram of the linear interpolation method provided by an embodiment of the present invention;
[0035] Figure 6 is a flow chart of another message timestamp alignment method provided by an embodiment of the present invention;
[0036] Figure 7It is a structural block diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0037] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0038] See also Figure 1 , Figure 1 1 is a flow chart of a message timestamp alignment method provided by an embodiment of the present invention, the message timestamp alignment method is implemented by an electronic device, and the message timestamp alignment method includes:
[0039] S1. When a target message that meets a preset parsing condition is detected to be transmitted on the bus, the target message is parsed to obtain target data;
[0040] S2, obtaining a preset target period;
[0041] S3. When the sending period of the target message and the target period meet a preset alignment condition, the target message is supplemented with data according to the target data.
[0042] Specifically, in step S1, the bus is a CAN bus, and the on-board unit periodically sends a signal to the electronic device, and the signal is transmitted in the form of a message on the CAN bus, for example, the on-board unit is an ECU. The electronic device supports online CAN data input, offline CAN data playback and other time data types such as CAVASERS, and the data is usually continuous data that is periodic on the time axis.
[0043] Exemplarily, the parsing condition is: a signal sequence of a certain bite x to bite y under a certain single or multiple ID messages is the target message. The target data can be obtained by parsing the target message, for example, when a car air conditioner sends a temperature signal to an electronic device, the target message is the temperature information message sent by the car air conditioner, and the target data is the temperature value in the car; for example, when a battery management system sends a power signal to the electronic device, the target message is the battery charging status message sent by the battery management system, and the target data is the battery power.
[0044] Furthermore, while parsing the target message, the sending period of the target message can also be parsed. For example, the sending period of the target message is a predicted periodic value, and the electronic device knows the sending period of the target message in advance; or the sending period of the target message can be determined by rounding the time interval between two consecutive frames.
[0045] Specifically, in step S2, the target period is used to align the timestamps of messages sent by different vehicle-mounted units. The target period may be the maximum or minimum value of the target message sending period that needs to be aligned, or a set value. For example, there are 6 target messages that need to be aligned at this time. Figure 2 As shown in the figure, the six target messages are message1 to message6. The sending period of message1 and message2 is 10ms, the sending period of message3 and message4 is 20ms, and the sending period of message5 and message6 is 30ms. Figure 2 The black dots in the middle are the target data parsed from the target message sent by the vehicle-mounted unit. The target period can be 10ms, 30ms, or other values (such as 5ms).
[0046] Specifically, in step S3, the alignment condition is:
[0047] The target message sending period is greater than the target period; or,
[0048] The sending period of the target message is smaller than the target period, and the target period is not a multiple of the sending period of the target message.
[0049] Exemplarily, after obtaining the sending period of the target message, the sending period of the target message is compared with the target period. When the sending period and the target period meet the preset alignment condition, it means that the on-board unit has not sent a message within the target period, and the electronic device cannot obtain the data of this on-board unit at the time corresponding to the current target period. For example, when the target period is 10ms, the periods of message3~6 are all greater than the target period, then it is necessary to supplement the data at the time corresponding to the target period. Since the period of message3~4 is 20ms, it is necessary to supplement one data between two adjacent target data. Since the period of message5~6 is 30ms, it is necessary to supplement two data between two adjacent target data. Please refer to Figure 3For example, the white dots represent the supplemented data. At this time, for each message, the electronic device can collect the corresponding data when the target cycle is 10ms. For another example: when the target cycle is 15ms, the sending cycle (10ms) of message 1-2 is less than the target cycle, and the sending cycle is not a multiple of the target cycle, and one data needs to be supplemented between two adjacent target data (between 10ms and 20ms).
[0050] Exemplarily, when the sending period of the target message is equal to the target period, it means that the electronic device hopes that the period of the message sent by this onboard unit is exactly the period of the message sent by the current onboard unit, and there is no need to supplement the data of the message sent by this onboard unit, such as message1~2. Alternatively, the sending period of the target message is less than the target period, and the target period is a multiple of the sending period; for example, when the target period is 20ms, the target period is a multiple of the period (10ms) of message1~2, then the data of message1~2 at 20ms, 40ms, and 60ms can be directly obtained, and there is no need to supplement the data at this time, and the original sequence is maintained.
[0051] Specifically, before supplementing the target message with data according to the target data, the method further includes:
[0052] All target messages are classified according to the sending period of the target message, so as to classify the target messages with the same period into the same category; then, supplementing the target message with data according to the target data includes:
[0053] The target messages of different period categories are supplemented with data according to the target data.
[0054] Exemplarily, after obtaining the sending period of the target message, all target messages are classified according to the sending period of the target message, for example, the period of message1 and message2 is 10ms, and they are classified as bag_3_10, the period of message3 and message4 is 20ms, and they are classified as bag_3_20, and the period of message5 and message6 is 30ms, and they are classified as bag_3_30. When the target period is 10ms, for message3 and message4 under the same bag_3_20 category, it is necessary to uniformly supplement data at 10ms, 30ms, and 50ms.
[0055] In an embodiment of the present invention, messages are classified according to the sending period of the target message. When data is subsequently supplemented, after the electronic device learns the moment when one signal needs to supplement data, it can learn the moment when other signals belonging to the same period category need to add data. There is no need to calculate the time for supplementing data for each signal one by one, thereby improving the efficiency of data alignment.
[0056] Specifically, in the embodiment of the present invention, the method of supplementing the target message with data according to the target data includes three methods, namely, delayed interpolation, nonlinear adaptive interpolation and linear interpolation.
[0057] ① Delay interpolation: obtaining the target data sent by the on-board unit in the previous N times as the data sent by the on-board unit in the current target cycle; wherein N is an integer greater than 1.
[0058] For example, when the target period is 10ms, message3 needs to be supplemented with data at 30ms, and the target data obtained last time (20ms) can be used for supplementation, that is, the target interpolation position is equal to the data at the previous moment; message3 needs to be supplemented with data at 50ms, and the target data obtained last time (40ms) or the previous two times (20ms) can be used for supplementation.
[0059] ② Nonlinear adaptive interpolation: obtain the target data sent by the vehicle-mounted unit for the previous M times (continuously), fit the M target data to obtain an M-1 order polynomial, and obtain the data that needs to be supplemented by the vehicle-mounted unit in the current target cycle according to the M-1 order polynomial; wherein M is an integer greater than 2.
[0060] For example, when the target period is 10 ms, see Figure 4 , Figure 4 The three points A(x0,y0), B(x1,y1), and C(x2,y2) represent the target data of message3 at 20ms, 40ms, and 60ms, respectively. The coordinates of the three points A, B, and C can be used to construct a quadratic polynomial, such as y=ax^2+bx+c. Then, according to this quadratic polynomial, the x coordinates corresponding to a, b, and c (10ms, 30ms, and 50ms, respectively) are substituted, and the y values obtained are the data that need to be supplemented at 10ms, 30ms, and 50ms. It can be understood that when the target data obtained is four, a cubic polynomial is constructed.
[0061] ③ Linear interpolation: Obtain the target data sent by the on-board unit twice in succession, construct a linear function by linearizing it according to time, and obtain the data that needs to be supplemented by the on-board unit in the current target period according to the linear function.
[0062] For example, when the target period is 10 ms, see Figure 5 , Figure 5 D(x3, y3) and E(x4, y5) in the figure respectively represent the target data of message3 at 20ms and 40ms. The straight line equation is constructed with these two target data. For example, the straight line equation is a two-point straight line equation: Then, according to the two-point straight line equation, substitute the x coordinate (30ms) corresponding to point d, and the obtained y value is the data that needs to be supplemented at 30ms.
[0063] In an embodiment of the present invention, by using the above-mentioned interpolation methods to supplement the data of the signal sent by the vehicle-mounted unit, it is possible to ensure that the data of different sending cycles are aligned on the same time axis, so that the messages of different sending cycles have the same amount of data and can correspond one-to-one on the same time axis, ensuring that the obtained data will not be misplaced and is valid.
[0064] Specifically, after the target message is supplemented with data according to the target data, the method further includes: verifying the supplemented data, and saving the supplemented data after the verification passes, such as saving the aligned data to a text document, a document in other formats such as *.mat, *.csv, or storing the aligned data in a file in a format such as excel / CSV / Text and storing it at a specified address.
[0065] Specifically, the verification of the supplemented data includes at least one of the following verification methods:
[0066] a. Verify the integrity of the supplemented data according to the target period; wherein each target period corresponds to a supplemented data. Exemplarily, the continuity of the data needs to be in accordance with the actual target period, and the data shall not have blank or NA fields (garbled characters). If blank data or garbled characters are encountered, re-interpolation calculation is performed to obtain supplemented data.
[0067] b. Compare the supplemented data with the preset standard rules to find out the data that does not meet the standard rules. For example, according to the physical meaning of different data, non-physical values shall not appear, for example, the wheel speed pulse shall not appear a value less than 0, and the switch signal shall not appear a value other than 0 or 1. The inspection rules need to be determined according to the actual situation. If data that does not meet the standard rules is encountered, the interpolation calculation is re-performed to obtain the supplemented data.
[0068] c. Calculate the change rate of several consecutive supplemented data to find out the mutation data. For example, in terms of interpolation data change, the curvature of normal continuous data is usually continuous and will not change significantly. If mutation data is encountered, re-interpolation calculation is performed to obtain supplemented data.
[0069] d. Perform string verification on the supplemented data to filter out data that does not conform to the set format. For example, the alignment data is usually numerical data such as Float, Int, etc.
[0070] In the embodiment of the present invention, after the data is supplemented, the data in the signal of the supplemented data is verified to ensure the integrity of the supplemented data and improve the accuracy of the supplemented data.
[0071] Further, the above process can refer to Figure 6 .
[0072] Compared with the prior art, the message timestamp alignment method disclosed in the embodiment of the present invention, when a target message that meets the preset parsing condition is detected to be transmitted on the bus, the target message is parsed to obtain target data; a preset target cycle is obtained; when the sending cycle of the target message and the target cycle meet the preset alignment condition, the target message is supplemented with data according to the target data. It can ensure that data of different sending cycles are aligned on the same time axis, so that messages of different sending cycles have the same amount of data, and can correspond one to one on the same time axis, ensuring that the obtained data will not be misplaced and is valid.
[0073] See also Figure 7 , Figure 7 1 is a structural block diagram of an electronic device 10 provided in an embodiment of the present invention, wherein the electronic device 10 includes a processor 11, a memory 12, and a computer program stored in the memory 12 and executable on the processor 11. When the processor 11 executes the computer program, the steps in the above-mentioned embodiments of the message timestamp alignment method are implemented, such as steps S1 to S3. Alternatively, when the processor 11 executes the computer program, the functions of the modules / units in the above-mentioned device embodiments are implemented.
[0074] Exemplarily, the computer program may be divided into one or more modules / units, which are stored in the memory 12 and executed by the processor 11 to implement the present invention. The one or more modules / units may be a series of computer program instruction segments capable of implementing specific functions, which are used to describe the execution process of the computer program in the electronic device 10.
[0075] The electronic device 10 may include, but is not limited to, a processor 11 and a memory 12. Those skilled in the art will appreciate that the schematic diagram is merely an example of the electronic device 10 and does not limit the electronic device 10. The electronic device 10 may include more or fewer components than shown in the figure, or may combine certain components, or different components. For example, the electronic device 10 may also include input and output devices, network access devices, buses, etc.
[0076] The processor 11 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc. The processor 11 is the control center of the electronic device 10, and uses various interfaces and lines to connect various parts of the entire electronic device 10.
[0077] The memory 12 can be used to store the computer program and / or module. The processor 11 implements various functions of the electronic device 10 by running or executing the computer program and / or module stored in the memory 12 and calling the data stored in the memory 12. The memory 12 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area can store data created according to the use of the mobile phone (such as audio data, a phone book, etc.), etc. In addition, the memory 12 can include a high-speed random access memory, and can also include a non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0078] Wherein, if the module / unit integrated in the electronic device 10 is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the present invention implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor 11. Wherein, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electrical carrier signal, telecommunication signal and software distribution medium, etc. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media does not include electrical carrier signals and telecommunication signals.
[0079] Compared with the prior art, the electronic device 10 disclosed in the embodiment of the present invention, when detecting that a target message that meets the preset parsing conditions is transmitted on the bus, parses the target message to obtain target data; obtains a preset target cycle; when the sending cycle of the target message and the target cycle meet the preset alignment conditions, supplements the target message according to the target data. It can ensure that data of different sending cycles are aligned on the same time axis, so that messages of different sending cycles have the same amount of data, and can correspond one to one on the same time axis, ensuring that the obtained data will not be misplaced and is valid.
[0080] Furthermore, an embodiment of the present invention also provides a vehicle, including a vehicle body and the electronic device described in the above embodiment.
[0081] Compared with the prior art, the vehicle disclosed in the embodiment of the present invention, when detecting that a target message that meets the preset parsing conditions is transmitted on the bus, parses the target message to obtain target data; obtains the preset target cycle; when the sending cycle of the target message and the target cycle meet the preset alignment conditions, supplements the target message according to the target data. It can ensure that data of different sending cycles are aligned on the same time axis, so that messages of different sending cycles have the same amount of data, and can correspond one to one on the same time axis, ensuring that the obtained data will not be misplaced and is valid.
[0082] The above is a preferred embodiment of the present invention. It should be pointed out that a person skilled in the art can make several improvements and modifications without departing from the principle of the present invention. These improvements and modifications are also considered to be within the scope of protection of the present invention.
Claims
1. A message timestamp alignment method, It is characterized in that include: When a target message that meets a preset parsing condition is detected to be transmitted on the bus, the target message is parsed to obtain target data; Get the preset target period; When the sending period of the target message and the target period meet a preset alignment condition, supplementing the target message with data according to the target data; Wherein, the alignment condition is: The target message sending period is greater than the target period; or, The sending period of the target message is less than the target period, and the target period is a multiple of the sending period of the non-target message; The step of supplementing the target message with data according to the target data includes: Obtaining the target data sent by the vehicle-mounted unit in the previous N times as the data sent by the vehicle-mounted unit in the current target period; wherein N is an integer greater than 1; or, Obtain the target data sent by the vehicle-mounted unit for the previous M times, fit the M target data to obtain an M-1 degree polynomial, and obtain the data that needs to be supplemented by the vehicle-mounted unit in the current target cycle according to the M-1 degree polynomial; wherein M is an integer greater than 2; or, The target data sent by the vehicle-mounted unit twice in succession is obtained, a linear function is constructed by linearization according to time, and the data that needs to be supplemented by the vehicle-mounted unit in the current target period is obtained according to the linear function.
2. The message timestamp alignment method according to claim 1, It is characterized in that Before supplementing the target message with data according to the target data, the method further includes: All target messages are classified according to the sending period of the target message, so as to classify the target messages with the same period into the same category; then, supplementing the target message with data according to the target data includes: The target messages of different period categories are supplemented with data according to the target data.
3. The message timestamp alignment method as claimed in claim 1, It is characterized in that After the target message is supplemented with data according to the target data, the method further includes: The supplemented data is verified, and the supplemented data is saved after the verification passes.
4. The message timestamp alignment method as claimed in claim 3, It is characterized in that The verifying of the supplemented data includes at least one of the following verification methods: Verifying the integrity of the supplemented data according to the target period; wherein each target period corresponds to a supplemented data; Comparing the supplemented data with preset standard rules to find out data that does not meet the standard rules; Calculate the change rate of several consecutive supplemented data to find out the mutation data; The supplemented data is validated in the form of a character string to filter out data that does not conform to a set format.
5. An electronic device, It is characterized in that The method comprises a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor implements the message timestamp alignment method as described in any one of claims 1 to 4 when executing the computer program.
6. A vehicle, It is characterized in that The electronic device comprises a vehicle body and the electronic device as claimed in claim 5.
Citation Information
Patent Citations
Vehicle data acquisition method and system, computer equipment and storage medium
CN113079072A
Data fusion method and device, electronic equipment and computer readable medium
CN113992469A
