A data storage method based on a T-Box, an in-vehicle T-Box, and a vehicle.

By setting the OpenCPU start time and calculating the timestamp difference in the T-Box system, the data timestamp is corrected, which solves the problems of incomplete data and inaccurate time caused by slow OpenCPU startup or RTC failure, and realizes accurate storage and traceability of data during the vehicle startup phase.

CN116708068BActive Publication Date: 2026-03-10ZHENGZHOU YUTONG BUS CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-10-09
Publication Date
2026-03-10

AI Technical Summary

Technical Problem

In existing T-Box systems, slow OpenCPU startup time or RTC failure results in incomplete data storage obtained by the MCU and inaccurate system time, making it impossible to properly handle and trace vehicle problems during the vehicle startup phase.

Method used

By receiving and storing MCU data before setting the OpenCPU start time, and calculating the difference between the MCU end timestamp and the MCU timestamp in the data, the OpenCPU system time is deduced, the data timestamp is corrected, and data integrity and accuracy are ensured.

Benefits of technology

It achieves complete storage and accurate time stamping of data during the vehicle startup phase, supports problem tracing, and solves the problems of incomplete data storage and inaccurate time. In particular, it can still effectively store and analyze data when OpenCPU restarts abnormally or RTC fails.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116708068B_ABST
    Figure CN116708068B_ABST
Patent Text Reader

Abstract

This invention belongs to the field of vehicle-mounted T-Box terminal technology, specifically relating to a data storage method based on a T-Box, a vehicle-mounted T-Box, and a vehicle. This invention obtains the difference between the MCU timestamp corresponding to the normal operation of the OpenCPU and the MCU timestamp corresponding to the CAN data during the disconnection phase. Then, based on this difference and the normal operation time of the OpenCPU, it deduces the OpenCPU system time corresponding to the CAN data during the disconnection phase, thus obtaining CAN data carrying accurate time. On the other hand, during the disconnection phase, the MCU saves the received CAN data locally, waiting for the connection to be established before sending it to the OpenCPU, ensuring the integrity of the CAN data. Therefore, this invention solves the problem in the prior art where slow OpenCPU startup time or real-time clock failure leads to incomplete CAN data storage and inaccurate OpenCPU system time.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The application belongs to the technical field of vehicle-mounted T-Box terminals, and particularly relates to a data storage method based on a T-Box, a vehicle-mounted T-Box and a vehicle. BACKGROUND

[0002] T-Box: Telematics BOX, installed in a vehicle, used for realizing information transmission between a cloud and a vehicle, having power management, CAN communication, 3G / 4G / 5G communication and positioning capability, and capable of realizing time information reporting, remote query and remote control functions. OpenCPU: open computer system, used for sharing a processor and FLASH, RAM resources in a module. CAN: abbreviation of Controller Area Network, a bus, having strong anti-interference and error correction capability, widely applied in vehicles, and having standard frames and extended frames on the bus.

[0003] Currently, T-Box mostly adopts an OpenCPU+MCU architecture, and an RTC is connected to the OpenCPU side. In runtime, the MCU sends the collected CAN data to the OpenCPU through serial communication, and the OpenCPU processes and analyzes the CAN data with correct time stamps. The OpenCPU adopts a Linux operating system, and the MCU adopts a bare machine or a real-time operating system, and the startup time is in the order of hundreds of milliseconds. In the Linux startup phase, the MCU stores the collected CAN data into a FLASH, and after the Linux startup is completed, the MCU sends the CAN data in the startup phase and the real-time collected CAN data to the OpenCPU through a serial port for processing and analysis.

[0004] The startup sequence of the OpenCPU and the MCU in the OpenCPU+MCU architecture of the vehicle-mounted T-Box is shown in FIG. 1, and specifically described as follows: Figure 1

[0005] Q1) The terminal is powered on simultaneously for the OpenCPU and the MCU, the power-on time of the OpenCPU is recorded as Ts1, and the power-on time of the MCU is recorded as Tm1;

[0006] Q2) The MCU is started at Tm2, and can normally collect data, which is 100 milliseconds later than Tm1;

[0007] Q3) The OpenCPU is started at Ts3, which is 20 seconds later than Tm2;

[0008] Q4) At Ts4 and Tm4, the OpenCPU and the MCU successfully handshake, and can perform data transmission, which is about 1 second later than Ts3; ​

[0009] Q5) At Ts5, the OpenCPU time correction action is completed, and the current system time is correct and available. Limited by the network signal at that time, the difference is several seconds or tens of seconds later than Ts4.

[0010] The above time sequence is in turn: Ts1, Tm1 (terminal power-on) → Tm2 (MCU startup completion) → Ts3 (OpenCPU startup completion) → Ts4, Tm4 (OpenCPU and MCU handshake success) → Ts5 (OpenCPU time correction action completion).

[0011] Based on the architecture, there are the following problems:

[0012] 1) The real-time clock RTC is externally connected to the OpenCPU side, and the startup phase CAN data collected by the MCU does not have a timestamp. When the OpenCPU receives the startup phase CAN data sent by the MCU, it cannot be correctly processed, analyzed, and stored, and thus the vehicle problems generated during the vehicle startup phase cannot be traced back;

[0013] 2) The real-time clock RTC fails during the terminal life cycle, the time information is incorrect, the CAN data cannot be sequentially stored, and the reason analysis and locking after remote or local extraction are difficult, and thus the vehicle problems generated during the vehicle startup phase cannot be traced back;

[0014] 3) When the OpenCPU abnormally restarts due to some reason, the CAN data during the abnormal restart phase cannot be stored in time, and the part of the CAN data does not have correct timestamp information. The data storage is not complete, and the vehicle running problem analysis and reason locking in this phase are difficult. SUMMARY

[0015] The purpose of the present application is to provide a T-Box-based data storage method to solve the problem of incomplete storage of data obtained by the MCU and inaccurate OpenCPU system time caused by slow OpenCPU startup time or real-time clock RTC failure in the prior art; also provide a vehicle-mounted T-Box capable of storing the data obtained by the MCU completely and carrying accurate OpenCPU system time; and further provide a vehicle configured with the vehicle-mounted T-Box capable of storing the data obtained by the MCU completely and carrying accurate OpenCPU system time.

[0016] To solve the above technical problems, the technical solutions provided by the present application and the beneficial effects corresponding to the technical solutions are as follows:

[0017] The T-Box-based data storage method of the present application comprises the following steps:

[0018] 1) OpenCPU receives and stores the data acquired by the MCU before the set OpenCPU starting time, denoted as starting phase data; the starting phase data includes data content and corresponding MCU timestamp; the value range of the set OpenCPU starting time is [t1, t2]; t1 is the time when the MCU and OpenCPU handshake successfully; t2 is the time when the OpenCPU time correction action is completed;

[0019] 2) in the case that the data validity verification of the set OpenCPU starting time is successful, the MCU terminal timestamp corresponding to the set OpenCPU starting time is recorded as the MCU terminal timestamp, and the received starting phase data is time corrected to obtain the starting phase data complete and carrying accurate OpenCPU system time; the following method is used to correct the time of any data in the starting phase data:

[0020] Calculate the difference Δt between the MCU terminal timestamp and the MCU timestamp in the data; the time obtained by subtracting the difference Δt from the set OpenCPU starting time is regarded as the OpenCPU system time corresponding to the data content, and the data content and the OpenCPU system time are stored.

[0021] The beneficial effects of the above technical solution are: the present application first determines the set OpenCPU starting time, which is any time from the time when the MCU and OpenCPU handshake successfully to the time when the OpenCPU time correction action is completed. Within this range of time, the OpenCPU has started to obtain the OpenCPU system time, and if the set OpenCPU starting time is not the time when the OpenCPU time correction action is completed, the OpenCPU system time at this time may also be accurate and does not need to be corrected; even if there is an error, the error at this time is very small and can also be used as a time basis. Then the present application calculates the difference between the MCU timestamp corresponding to the set OpenCPU starting time and the MCU timestamp of each data before, and reverses the OpenCPU system time according to the difference and the set OpenCPU starting time, so as to attach the correct time to the CAN data content before the set OpenCPU starting time. On the other hand, the MCU saves the received CAN data to the local during the disconnection phase, and sends it to the OpenCPU after the connection is established, thereby ensuring the integrity of the CAN data. Therefore, the present application solves the problem of incomplete CAN data storage and inaccurate OpenCPU system time carrying in the prior art due to slow OpenCPU startup time or invalid real-time clock (RTC).

[0022] Specifically, the first aspect: effectively solve the problem that the data received by the MCU before starting cannot be correctly stored, so as to trace the problems generated in the whole vehicle starting stage, have the functions of collecting data before starting and accurate system time, and correct storage. The second aspect: effectively solves the problem of data storage disorder when RTC fails, and stores the data received by the MCU after the RTC fails, so as to trace the problems generated in the whole vehicle starting stage, have the functions of collecting the data received by the MCU correctly and not disorderly when the RTC fails. The third aspect: effectively solves the problem that the data received by the MCU cannot be stored in the OpenCPU abnormal restart stage, so as to ensure complete data storage, facilitate problem analysis and reason locking in this stage, and have the function of accurately and completely storing the data received by the MCU in the OpenCPU abnormal restart stage.

[0023] Further, in order to improve the accuracy of system time, the stored information about the completion time of OpenCPU time correction action is verified for validity, if the verification is successful, the completion time of OpenCPU time correction action is set as the starting time of OpenCPU; if the verification fails, the stored information about the time when MCU and OpenCPU handshake is successfully verified for validity, if the verification is successful, the time when MCU and OpenCPU handshake is successfully set as the starting time of OpenCPU.

[0024] Further, in order to facilitate the storage of CAN data, the starting stage data is stored according to the following format:

[0025] The first timestamp file stores the time correction flag, the time when MCU and OpenCPU handshake is successfully, and the corresponding MCU timestamp; the second timestamp file stores the time correction flag, the completion time of OpenCPU time correction action, and the corresponding MCU timestamp; the CAN original content file stores MCU timestamp n and the corresponding data content n line by line, n≥1; the time correction flag is used to mark whether the OpenCPU time correction action is completed.

[0026] Further, in order to facilitate reading the stored CAN data when tracing the problem, the OpenCPU system time before storing the data content and the OpenCPU system time needs to be converted into the time format of year, month, day, hour, minute, second and millisecond.

[0027] Further, in order to ensure the integrity of the data, before the time when MCU and OpenCPU handshake is successfully, the MCU saves the data obtained in the MCU local, and stores each piece of data in the form of MCU timestamp n and corresponding data content n, n≥1; from the time when MCU and OpenCPU handshake is successfully to the set OpenCPU starting time, the MCU sends the data obtained to OpenCPU in real time.

[0028] Further, before the moment of successful handshake between MCU and OpenCPU, the MCU first stores the acquired data in the first storage module according to the receiving order, and then stores the data in the first storage module in MCU local according to the stored order.

[0029] Further, in order to improve data integrity and reduce data processing amount, from the set OpenCPU starting moment, the OpenCPU receives data in real time, and stores the real-time data content and the corresponding OpenCPU system time.

[0030] Further, in order to improve data integrity and reduce data processing amount, from the set OpenCPU starting moment, the OpenCPU receives data in real time, and stores the real-time data content and the corresponding OpenCPU system time.

[0031] The vehicle-mounted T-Box of the present application comprises MCU, OpenCPU and real-time clock RTC; the MCU is connected to the OpenCPU, the OpenCPU provides OpenCPU system time through the real-time clock RTC; the MCU is used for sending data; the OpenCPU is used for:

[0032] receiving and storing the data acquired by the MCU before the set OpenCPU starting moment, which is called starting stage data; the starting stage data includes data content and corresponding MCU timestamp; the value range of the set OpenCPU starting moment is [t1, t2]; t1 is the moment of successful handshake between MCU and OpenCPU; t2 is the moment of completion of OpenCPU time correction action; in the case of successful data validity verification of the set OpenCPU starting moment, the MCU timestamp corresponding to the set OpenCPU starting moment is recorded as the MCU termination timestamp, and is used for time correction processing of the starting stage data, to obtain starting stage data which is complete and carries accurate OpenCPU system time; the following method is used for time correction processing of any data in the starting stage data:

[0033] calculating the difference Δt between the MCU termination timestamp and the MCU timestamp in the data; the moment obtained by subtracting the difference Δt from the set OpenCPU starting moment is taken as the OpenCPU system time corresponding to the data content, and the data content and the OpenCPU system time are stored.

[0034] The beneficial effects of the above technical solutions are: the application firstly determines the set OpenCPU starting moment, which is any moment from the moment when the MCU and the OpenCPU successfully handshake to the moment when the OpenCPU time correction action is completed, and the OpenCPU has started to obtain the OpenCPU system time within the range of time, and if the set OpenCPU starting moment is not the moment when the OpenCPU time correction action is completed, the OpenCPU system time at this moment may also be accurate and does not need to be corrected; even if there is an error, the error at this moment is very small and can also be used as a time basis. Then the application calculates the difference between the MCU timestamp corresponding to the set OpenCPU starting moment and the MCU timestamp of each piece of data before, and reverses the OpenCPU system moment according to the difference and the set OpenCPU starting moment, so as to attach correct time to the CAN data content before the set OpenCPU starting moment. On the other hand, the MCU saves the CAN data received in the disconnection stage to the local, and sends it to the OpenCPU after the connection is established, so as to ensure the integrity of the CAN data. Thus, the application provides a vehicle-mounted T-Box containing CAN data in the OpenCPU starting stage or the real-time clock RTC invalidation stage and carrying accurate OpenCPU system time.

[0035] The application provides a vehicle, which comprises a vehicle-mounted T-Box, the vehicle-mounted T-Box comprising an MCU, an OpenCPU and a real-time clock RTC; the MCU is connected to the OpenCPU, and the OpenCPU provides OpenCPU system time through the real-time clock RTC; the MCU is used for sending data; and the OpenCPU is used for:

[0036] receiving and storing the data acquired by the MCU before the set OpenCPU starting moment, which is referred to as starting stage data; the starting stage data comprises data content and a corresponding MCU timestamp; the set OpenCPU starting moment is in the range of [t1, t2]; t1 is the moment when the MCU and the OpenCPU successfully handshake; t2 is the moment when the OpenCPU time correction action is completed; in the case that the data validity verification at the set OpenCPU starting moment is successful, the MCU timestamp corresponding to the set OpenCPU starting moment is recorded as an MCU termination timestamp, and is used for time correction processing of the starting stage data, so as to obtain starting stage data which is complete and carries accurate OpenCPU system time; the starting stage data is processed in the following manner:

[0037] Calculate the difference Δt between the MCU termination timestamp and the MCU timestamp in the data; take the time obtained by subtracting the difference Δt from the OpenCPU start time as the OpenCPU system time corresponding to the data content, and store the data content and the OpenCPU system time.

[0038] The beneficial effects of the above technical solution are: the present application first determines the set OpenCPU start time, which is any time from the time when the MCU and the OpenCPU successfully handshake to the time when the OpenCPU time correction action is completed. Within this range of time, the OpenCPU has started to obtain the OpenCPU system time, and if the set OpenCPU start time is not the time when the OpenCPU time correction action is completed, the OpenCPU system time at this time may also be accurate and does not need to be corrected; even if there is an error, the error at this time is very small and can also be used as a time basis. Then the present application calculates the difference between the MCU timestamp corresponding to the set OpenCPU start time and the MCU timestamp of each previous data, and reverses the OpenCPU system time according to the difference and the set OpenCPU start time, thereby attaching correct time to the CAN data content before the set OpenCPU start time. On the other hand, the MCU saves the CAN data received during the disconnection stage to the local, and sends it to the OpenCPU after the connection is established, thereby ensuring the integrity of the CAN data. Thus, the present application provides a vehicle-mounted T-Box containing CAN data of the OpenCPU startup stage or real-time clock RTC failure stage and carrying accurate OpenCPU system time. BRIEF DESCRIPTION OF DRAWINGS

[0039] Figure 1 is the OpenCPU and MCU startup sequence comparison diagram in the OpenCPU+MCU architecture of the T-Box in the background technology of the present application;

[0040] Figure 2 is the format diagram of the MCU local storage CAN data in a vehicle embodiment of the present application;

[0041] Figure 3 is the format diagram of the OpenCPU temporary file storage CAN data in a vehicle embodiment of the present application;

[0042] Figure 4 is the format diagram of the OpenCPU target file storage CAN data in a vehicle embodiment of the present application;

[0043] Figure 5 is the CAN data storage flow diagram in a vehicle embodiment of the present application. DETAILED DESCRIPTION

[0044] In order to make the objects, technical solutions and advantages of the present application clearer and more apparent, the present application will be further described in detail below with reference to the accompanying drawings and embodiments.

[0045] A vehicle embodiment of the present application comprises a vehicle-mounted T-Box installed in the vehicle, which is a device for realizing information transmission between the cloud and the vehicle, and has power management, CAN communication, 3G / 4G / 5G communication, positioning capability, and can realize time information reporting, remote query, and remote control functions. As shown in the figure, under normal circumstances, the MCU first receives the CAN data sent by the CAN interface and forwards the CAN data to the OpenCPU, and the OpenCPU saves the CAN data to the target file for tracing after the vehicle has a problem. At present, due to the slow startup time of the OpenCPU or the failure of the real-time clock RTC, there is a disconnection phase, which leads to the problem of incomplete storage of data obtained by the MCU and inaccurate OpenCPU system time carried. Under the disconnection condition, the MCU first receives the CAN data sent by the CAN interface and stores the CAN data locally, and after establishing a handshake connection with the OpenCPU, the locally stored CAN data and the real-time received CAN data are sent to the OpenCPU, which is saved after time correction processing, for tracing after the vehicle has a problem.

[0046] Figure 5 In order to ensure the integrity and time accuracy of the CAN data, the present application designs a data storage method based on the T-Box, and the overall idea is as follows: the present application obtains the difference between the MCU timestamp corresponding to the normal running time of the OpenCPU and the MCU timestamp corresponding to the CAN data in the disconnection phase, and then inversely calculates the OpenCPU system time corresponding to the CAN data in the disconnection phase according to the difference and the normal running time of the OpenCPU, so as to obtain the CAN data carrying accurate time. The above-mentioned normal running time of the OpenCPU is also called the set OpenCPU starting time, and its value range is [t1, t2]; t1 is the time when the MCU and the OpenCPU successfully handshake; t2 is the time when the OpenCPU time correction action is completed. On the other hand, the MCU saves the received CAN data locally during the disconnection phase, and then sends it to the OpenCPU after establishing a connection, thereby ensuring the integrity of the CAN data.

[0047] In order to ensure the integrity and time accuracy of the CAN data, the present application designs a data storage method based on the T-Box, and the overall idea is as follows: the present application obtains the difference between the MCU timestamp corresponding to the normal running time of the OpenCPU and the MCU timestamp corresponding to the CAN data in the disconnection phase, and then inversely calculates the OpenCPU system time corresponding to the CAN data in the disconnection phase according to the difference and the normal running time of the OpenCPU, so as to obtain the CAN data carrying accurate time. The above-mentioned normal running time of the OpenCPU is also called the set OpenCPU starting time, and its value range is [t1, t2]; t1 is the time when the MCU and the OpenCPU successfully handshake; t2 is the time when the OpenCPU time correction action is completed. On the other hand, the MCU saves the received CAN data locally during the disconnection phase, and then sends it to the OpenCPU after establishing a connection, thereby ensuring the integrity of the CAN data.

[0048] The application designs a data storage method based on T-Box, and the specific implementation steps are as follows:

[0049] Step 1: After the MCU is started (at Tm2), the CAN data collected by the MCU is stored in the form of "MCU timestamp + CAN data content" in pieces, as shown in the figure. Figure 2 The "MCU timestamp" can be the MCU system Tick or the incremental time information, and the unit is ms or us.

[0050] Step 2: At Ts3, the OpenCPU is started, and the application program starts.

[0051] Step 3: At Ts4 and Tm4, the MCU and the OpenCPU successfully handshake, the MCU sends the current "MCU timestamp" to the OpenCPU, and when the OpenCPU receives the timestamp, the "MCU timestamp" and the "OpenCPU system time" corresponding to this time are saved, and recorded as the MCU-OpenCPU time pair, namely MCU timestamp B and OpenCPU system time B.

[0052] Step 4: After Ts4 and Tm4, the MCU sends the collected real-time CAN data and the CAN data in the starting stage to the OpenCPU in the form of "MCU timestamp" and "CAN data content", and the OpenCPU saves the real-time CAN data and the CAN data in the starting stage into the CAN data temporary file. The temporary file includes timestamp file 1, timestamp file 2 and CAN original content file. The timestamp file 1 is also called the first timestamp file, and the timestamp file 2 is also called the second timestamp file. Specifically, the OpenCPU stores the CAN data when the time correction action is completed and before the time correction action in the form of "MCU timestamp + SOC system time + time correction flag", wherein the "OpenCPU system time" is also called "SOC system time"; and stores the real-time CAN data in the form of "MCU timestamp + CAN data content", as shown in the figure. Figure 3

[0053] Step 401: The "MCU timestamp A" and "OpenCPU system time A" stored in the timestamp file 1 are the time pair recorded at the time when the MCU and the OpenCPU successfully handshake, and the time correction flag represents whether the time correction action is completed when the time pair is written. The value is written as 0 when the time correction action is not completed, and the value is written as 1 when the time correction action is completed.

[0054] ​Step 402: When the time is successfully calibrated, the content of the time stamp file 1 is updated, and an abnormality occurs due to an application, a system, or an external power supply, etc., causing the content of the time stamp file 1 to be abnormal, so that the CAN data cannot be time processed, and therefore the time stamp file 2 is introduced. The "MCU time stamp B" and "OpenCPU system time B" stored in the time stamp file 2 are time pair information filled after the time calibration action is completed. When the time calibration action is not completed, the time pair value is the same as the value of the time stamp file 1, and after the time calibration action is completed, the "MCU time stamp B" and "OpenCPU system time B" are updated, and the time calibration flag is written as 1. Even if an abnormality occurs when the time stamp file 2 is updated, the time stamp file 1 can still be ensured to be correct. In other embodiments, the time stamp file 2 can not be created first, and after the time calibration action is completed, the "MCU time stamp B", "OpenCPU system time B", and time calibration flag are written into the time stamp file 2

[0055] Step 403: The CAN original content file stores the "MCU time stamp" and "CAN data content" row by row.

[0056] Step 5: After the time Ts5, the OpenCPU time calibration action is completed, the "MCU time stamp B" and the "OpenCPU system time B" corresponding to the time (the correct OpenCPU system time after the time calibration) at that time are recorded, and the time pair is written into the time stamp file 2, and the time calibration flag is filled as 1.

[0057] Step 6: After the start-up phase temporary file and the real-time CAN data temporary file are completely closed, that is, after all the CAN data storage is completed, the following operations are performed:

[0058] Step 601: The time stamp file 2 is opened, the "MCU time stamp B" and "OpenCPU system time B" are obtained, and validity verification is performed. The validity includes the integrity of the time data and whether it is the "MCU time stamp B" and "OpenCPU system time B" data. If the validity verification is successful, step 602 is performed; if not, step 606 is performed.

[0059] Step 602: The CAN original content file is opened, the first line information is obtained, and the difference between the "MCU time stamp 1" and the "MCU time stamp B" is calculated.

[0060] Step 603: The "OpenCPU system time B" is subtracted by the above difference to obtain the correct OpenCPU system time.

[0061] Step 604: Then it is converted into the year-month-day-hour-minute-second-millisecond format, and the "year-month-day-hour-minute-second-millisecond time stamp" and "CAN data content" are written into the CAN data target file row by row, and the storage format is "year-month-day-hour-minute-second time stamp n + CAN data content", such asFigure 4 as shown.

[0062] Step 605: Read the second line of the file in sequence until the end of the file, repeat steps 602-604, and the target file can be extracted remotely or locally by the platform for problem analysis and cause locking.

[0063] Step 606: If the integrity check fails in step 601, obtain the timestamp file 1 information as time pair information, i.e., replace OpenCPU system time B with OpenCPU system time A, and replace MCU timestamp B with MCU timestamp A, verify the validity of the time information, and if the verification is successful, repeat steps 602-605.

[0064] In this embodiment, the OpenCPU starting time is selected as one of the MCU and OpenCPU handshake success time and the OpenCPU time setting action completion time, and in other embodiments, any time between the handshake success time and the time setting action completion time can also be selected. For example, the OpenCPU starting time can also be selected as three times, specifically the MCU and OpenCPU handshake success time, the OpenCPU time setting action completion time, and any time between the two times, which is referred to as the third time. The corresponding CAN data storage format becomes: timestamp file 1 stores the time setting flag, the MCU and OpenCPU handshake success time, and the corresponding MCU timestamp; i.e., "MCU timestamp A" and "OpenCPU system time A". Timestamp file 2 stores the time setting flag, the third time, and the corresponding MCU timestamp; i.e., "MCU timestamp C" and "OpenCPU system time C". Another timestamp file 3 stores the time setting flag, the OpenCPU time setting action completion time, and the corresponding MCU timestamp; i.e., "MCU timestamp B" and "OpenCPU system time B". The CAN original content file and the subsequent line store the MCU timestamp n and the corresponding data content n in sequence, n≥1; the time setting flag is used to mark whether the OpenCPU time setting action is completed. The CAN data storage format can also be adjusted according to requirements.

[0065] In order to more clearly describe the entire flow process of CAN data sequence and safe storage, the CAN data storage behavior of OpenCPU abnormal restart is taken as an example for description, as shown in Figure 5 The specific process is as follows:

[0066] ①: The MCU stores the collected CAN data into the RAM buffer area (first storage module);

[0067] ②: MCU fetches CAN data from RAM buffer after successful handshake with OpenCPU;

[0068] ③: MCU sends the fetched CAN data to OpenCPU through serial port;

[0069] ④: After receiving CAN data, OpenCPU sends an acknowledgement message to MCU and writes it into "real-time target file" in the format of "year-month-day-hour-minute-second-millisecond timestamp" and "CAN data content";

[0070] ⑤: When MCU fails to receive the acknowledgement message sent by OpenCPU, it determines that it has lost contact with OpenCPU. MCU writes the data in RAM buffer into FLASH in the format of "MCU timestamp" and "CAN data content";

[0071] ⑥: After successful re-handshake with OpenCPU, MCU fetches data from FLASH and sends it to OpenCPU;

[0072] ⑦: OpenCPU receives data during the period of disconnection and stores it in the format of "temporary file" content;

[0073] ⑧: After the time correction action is completed, OpenCPU updates the corresponding content of "temporary file" and writes it into "corrected target file" in the format of "year-month-day-hour-minute-second-millisecond timestamp" and "CAN data content". This file can be extracted locally or remotely for problem analysis.

[0074] The application firstly determines the set OpenCPU starting moment, which is any moment from the moment when the MCU and the OpenCPU successfully handshake to the moment when the OpenCPU time correction action is completed. Within the range of time, the OpenCPU has started to obtain the OpenCPU system time, and if the set OpenCPU starting moment is not the moment when the OpenCPU time correction action is completed, the OpenCPU system time at this moment is also likely to be accurate and does not need to be corrected. Even if there is an error, the error at this moment is very small and can also be used as a time basis. Then the application calculates the difference between the MCU timestamp corresponding to the set OpenCPU starting moment and the MCU timestamp of each previous data, and reverses the OpenCPU system time according to the difference and the set OpenCPU starting moment, thereby attaching correct time to the CAN data content before the set OpenCPU starting moment. On the other hand, the MCU saves the received CAN data to the local during the disconnection stage, and then sends it to the OpenCPU after the connection is established, thereby ensuring the integrity of the CAN data. Thus, the application solves the problem of incomplete CAN data storage and inaccurate OpenCPU system time caused by slow OpenCPU startup time or RTC failure in the prior art.

[0075] Specifically, the first aspect: effectively solves the problem that CAN data cannot be correctly stored before starting, thereby enabling the problems occurring in the vehicle starting stage to be traced back, and having the functions of collecting CAN data before starting and storing the system time correctly and without disorder. The second aspect: effectively solves the problem of CAN data storage disorder when RTC fails. When RTC fails, the application stores CAN data by using the scheme, thereby enabling the problems occurring in the vehicle starting stage to be traced back, and having the functions of collecting CAN data correctly and storing without disorder when RTC fails. The third aspect: effectively solves the problem that CAN data cannot be stored during the OpenCPU abnormal restart stage, thereby ensuring complete data storage, facilitating problem analysis and reason locking in the stage, and having the functions of collecting CAN data correctly and storing without loss during the OpenCPU abnormal restart stage.

[0076] A data storage method based on T-Box

[0077] An embodiment of a data storage method based on T-Box of the present application, the purpose of the method of the present application is to solve the problem of incomplete data storage and inaccurate OpenCPU system time caused by slow OpenCPU startup time or real-time clock RTC failure in the disconnection phase. To solve the above problem, the present application obtains the difference between the MCU timestamp corresponding to the normal running time of OpenCPU and the MCU timestamp corresponding to the CAN data in the disconnection phase, and then inversely deduces the OpenCPU system time corresponding to the CAN data in the disconnection phase according to the difference and the normal running time of OpenCPU, thereby obtaining CAN data carrying accurate time. The above normal running time of OpenCPU is also called the set OpenCPU starting time, and its value range is [t1, t2]; t1 is the time when the MCU and OpenCPU successfully handshake; t2 is the time when the OpenCPU time correction action is completed. On the other hand, the MCU saves the received CAN data to the local during the disconnection phase, and sends it to the OpenCPU after the connection is established, thereby ensuring the integrity of the CAN data. The method is consistent with the above-mentioned one based on T-Box data storage method in a vehicle embodiment, which will not be repeated here.

[0078] Therefore, the present application solves the problem of incomplete CAN data storage and inaccurate OpenCPU system time caused by slow OpenCPU startup time or real-time clock RTC failure in the prior art.

[0079] A vehicle-mounted T-Box embodiment:

[0080] An embodiment of the application is a vehicle-mounted T-Box, which comprises an MCU, an OpenCPU and a real-time clock RTC; the MCU is connected to the OpenCPU, the OpenCPU provides OpenCPU system time through the real-time clock RTC; the OpenCPU receives and stores CAN data collected by the MCU. Since the OpenCPU has a slow start-up time or the real-time clock RTC is invalid, there is a disconnection phase, which leads to the problem that the data collected by the MCU is not complete and the OpenCPU system time carried by the data is not accurate. To solve the above problem, the application obtains the difference between the MCU timestamp corresponding to the time when the OpenCPU is normally running and the MCU timestamp corresponding to the CAN data in the disconnection phase, and then reverses the OpenCPU system time corresponding to the CAN data in the disconnection phase according to the difference and the time when the OpenCPU is normally running, so as to obtain CAN data carrying accurate time. The time when the OpenCPU is normally running is also called the set OpenCPU start time, and its value range is [t1, t2]; t1 is the time when the MCU and the OpenCPU successfully handshake; t2 is the time when the OpenCPU time correction action is completed. On the other hand, the MCU saves the received CAN data locally during the disconnection phase, and then sends it to the OpenCPU after the connection is established, so as to ensure the integrity of the CAN data. The method is consistent with the data storage method based on T-Box introduced in the above-mentioned one embodiment of the vehicle, and will not be described here.

[0081] Therefore, the application provides a vehicle-mounted T-Box which contains CAN data in the OpenCPU start-up phase or the real-time clock RTC invalid phase and carries accurate OpenCPU system time.

Claims

1. A T-Box based data storage method, characterized by: The method comprises the following steps: 1) Before the moment when the MCU and the OpenCPU successfully handshake, the MCU saves the acquired data in the MCU locally, and stores the data in the form of MCU timestamp n and corresponding data content, n≥1; from the moment when the MCU and the OpenCPU successfully handshake to the set OpenCPU starting moment, the MCU sends the acquired data to the OpenCPU in real time; 2) The OpenCPU receives and stores the data acquired by the MCU before the set OpenCPU starting moment, which is referred to as the starting stage data; the starting stage data comprises data content and corresponding MCU timestamp; the value range of the set OpenCPU starting moment is [t1, t2]; t1 is the moment when the MCU and the OpenCPU successfully handshake; t2 is the moment when the OpenCPU time correction action is completed; 3) In the case that the data validity verification of the set OpenCPU starting moment is successful, the MCU terminal timestamp corresponding to the set OpenCPU starting moment is recorded, and the received starting stage data is subjected to time correction processing to obtain the starting stage data which is complete and carries accurate OpenCPU system time; The following method is adopted to perform time correction processing on any data in the starting stage data: The difference Δt between the MCU terminal timestamp and the MCU timestamp in the data is calculated; the moment obtained by subtracting the difference Δt from the set OpenCPU starting moment is regarded as the OpenCPU system moment corresponding to the data content, and the data content and the OpenCPU system moment are stored.

2. The data storage method based on T-BOX according to claim 1, characterized in that: The validity of the stored information about the moment when the OpenCPU time correction action is completed is verified first; if the verification is successful, the moment when the OpenCPU time correction action is completed is taken as the set OpenCPU starting moment; if the verification fails, the validity of the stored information about the moment when the MCU and the OpenCPU successfully handshake is verified; if the verification is successful, the moment when the MCU and the OpenCPU successfully handshake is taken as the set OpenCPU starting moment.

3. The method of claim 1, wherein: The starting stage data is stored according to the following format: A first timestamp file stores a time correction flag, the moment when the MCU and the OpenCPU successfully handshake, and the corresponding MCU timestamp; A second timestamp file stores a time correction flag, the moment when the OpenCPU time correction action is completed, and the corresponding MCU timestamp; a CAN original content file stores MCU timestamp n and corresponding data content row by row, n≥1; the time correction flag is used to mark whether the OpenCPU time correction action is completed.

4. The method of claim 1, wherein: Before the data content and the OpenCPU system moment are stored in step 3), the OpenCPU system moment needs to be converted into a moment in the format of year, month, day, hour, minute, second and millisecond.

5. The method of claim 4, wherein: Before the moment when the MCU and the OpenCPU successfully handshake, the MCU first stores the acquired data in the first storage module according to the receiving order, and then stores the data in the first storage module in the MCU locally according to the stored order.

6. The T-Box based data storage method according to any one of claims 1 to 5, characterized in that: From the set OpenCPU starting time, OpenCPU receives data in real time, and stores real-time data content and corresponding OpenCPU system time.

7. The T-Box based data storage method of claim 6, wherein: In step 2), OpenCPU stores the starting phase data to a temporary file, and in step 3), OpenCPU stores the starting phase data after time correction processing to a correction target file, and stores the real-time data received from the set OpenCPU starting time to a real-time target file.

8. A T-Box for a vehicle, characterized in that: The vehicle-mounted T-Box comprises an MCU, an OpenCPU and a real-time clock RTC; the MCU is connected to the OpenCPU, and the OpenCPU provides OpenCPU system time through the real-time clock RTC; The MCU is configured to: before the time when the MCU and the OpenCPU successfully perform handshaking, save the acquired data in the MCU locally, and store the data in the form of MCU timestamp n and corresponding data content in pieces, n≥1; from the time when the MCU and the OpenCPU successfully perform handshaking to the set OpenCPU starting time, send the acquired data to the OpenCPU in real time; The OpenCPU is configured to: receive and store the data acquired by the MCU before the set OpenCPU starting time, which is referred to as starting phase data; the starting phase data comprises data content and corresponding MCU timestamp; the set OpenCPU starting time is in the range of [t1, t2]; t1 is the time when the MCU and the OpenCPU successfully perform handshaking; t2 is the time when the OpenCPU time correction action is completed; in the case that the data validity verification at the set OpenCPU starting time is successful, the MCU timestamp corresponding to the set OpenCPU starting time is recorded as a MCU termination timestamp, and is used for time correction processing of the starting phase data, so as to obtain starting phase data that is complete and carries accurate OpenCPU system time; The time correction processing of any one piece of data in the starting phase data is performed in the following manner: calculate the difference ∆t between the MCU termination timestamp and the MCU timestamp in the data; take the time obtained by subtracting the difference ∆t from the set OpenCPU starting time as the OpenCPU system time corresponding to the data content, and store the data content and the OpenCPU system time.

9. A vehicle comprising an on-board T-Box, characterized in that: The vehicle-mounted T-Box comprises an MCU, an OpenCPU and a real-time clock RTC; the MCU is connected to the OpenCPU, and the OpenCPU provides OpenCPU system time through the real-time clock RTC; The MCU is configured to: before the time when the MCU and the OpenCPU successfully perform handshaking, save the acquired data in the MCU locally, and store the data in the form of MCU timestamp n and corresponding data content in pieces, n≥1; from the time when the MCU and the OpenCPU successfully perform handshaking to the set OpenCPU starting time, send the acquired data to the OpenCPU in real time; The OpenCPU is configured to: Receiving and storing data acquired by MCU before setting OpenCPU starting time, denoted as starting phase data; the starting phase data includes data content and corresponding MCU timestamp; the value range of the set OpenCPU starting time is [t1, t2]; t1 is the time when MCU and OpenCPU handshake successfully; t2 is the time when OpenCPU time correction action is completed; in the case of successful data validity verification of the set OpenCPU starting time, the MCU timestamp corresponding to the set OpenCPU starting time is recorded as the MCU termination timestamp, and is used for time correction processing of the starting phase data, to obtain the starting phase data complete and carrying accurate OpenCPU system time; The following method is used to perform time correction processing on any one data in the starting phase data: Calculate the difference ∆t between the MCU termination timestamp and the MCU timestamp in the data; the time obtained by subtracting the difference ∆t from the set OpenCPU starting time is taken as the OpenCPU system time corresponding to the data content, and the data content and the OpenCPU system time are stored.

Citation Information

Patent Citations

  • Vehicle-mounted network connection terminal TBOX

    CN112468172A

  • Vehicle time service method and system based on wireless communication terminal

    CN113271169A