Vehicle data processing method and device based on TBox, automobile and readable storage medium
By adopting a single producer-dual consumer queue-single consumer model in the TBox system, the data collection and monitoring functions are decoupled, which solves the contradiction between real-time performance and CPU occupation pressure during the data collection process in new energy vehicles, and achieves stability. And precise data collection and monitoring improve the stability and reliability of the system.
Patent Information
- Application Number
- CN202410375374.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-29
- Publication Date
- 2024-09-10
- Estimated Expiration
- 2044-03-29
AI Technical Summary
The TBox system in new energy vehicles has a conflict between real-time performance and high CPU occupancy pressure during the data collection process, resulting in unstable data collection and system chaos. Moreover, existing technology cannot effectively decouple data storage and monitoring functions, resulting in excessive thread CPU occupancy. high.
Using a TBox-based vehicle data processing method, the data collection thread and the monitor thread share the global static area storage space. The data collection thread is responsible for receiving and storing data, and the monitor thread independently completes data monitoring and processing, forming a single producer-double producer. Consumption queue - a single consumer model that reduces thread CPU usage and improves system stability.
It achieves the stability and accuracy of data collection, reduces the thread CPU occupancy pressure, improves the stability and reliability of the system, and avoids the situation where the data collection thread must process high-frequency data in real time while also taking into account monitoring.
Smart Images

Figure CN118625779A
Abstract
Description
Technical Field
[0001] The present application relates to the field of new energy vehicle technology, and in particular to a vehicle data processing method, device, vehicle, and readable storage medium based on TBox. Background Art
[0002] According to the national standard GB32960.3, new energy vehicles are required to report vehicle data, including:
[0003] 1. General vehicle status: speed / total mileage / location / vehicle status / SOC and other general vehicle status information;
[0004] 2. Three-electric related information: such as battery voltage / current / motor speed / motor torque / charging related information, etc.
[0005] 3. Alarm information: vehicle level 1 / 2 / 3 alarm, and information related to the vehicle status at the time of the alarm.
[0006] Therefore, data collection is on the one hand in response to relevant national regulations and to ensure the personal safety of users, and on the other hand in order to provide smart-related services to better serve users.
[0007] Currently, vehicle data collection is defined by the business, and R&D performs the collection and reporting. Whether manually or automatically tracking data, the common attribute is that the data is defined, the meaning is clear, and the content is understandable. However, a vehicle is composed of dozens of ECUs of various sizes, each of which can generate a large number of signals, each at a different frequency (for example, 10ms / 20ms / 50ms / 100ms / 200ms, etc.). A single vehicle typically requires collection of at least a few thousand signals, and as many as tens of thousands. This imposes a significant cost on collection, reporting, and transmission.
[0008] Specifically, if a vehicle collects vehicle data every 20ms, collecting 5,000 signals at a time, then according to conventional data structure design, the instantaneous throughput reaches 250,000 data points per second. To handle these tens of thousands of data points, the embedded chip must instantly receive the original message, store it in memory, and process each message without delaying normal message reception. Furthermore, it must also deal with numerous challenges, including irregular interactions with other upper-layer applications. This large volume of high-frequency data places extremely high demands on the performance of the MPU, placing immense pressure on the vehicle-side data collection thread, which must not only receive data stably but also monitor the received data as quickly as possible and respond to the needs of upper-layer applications.
[0009] For example, see Figure 1This is an existing TBox data collection model. In this model, the upper-layer TBox receiving chip sequentially unpacks, verifies, stores, monitors, and distributes vehicle message data through the data receiving and unpacking module, data security verification module, global memory storage module, special data monitoring module, and service upload application module. The same process is then repeated for the next vehicle message data. This TBox data collection model has the following practical problems:
[0010] First of all, the reading and writing of the data acquisition module requires read-write locks to protect variables. When storing data, only read locks are generally used. When used as monitoring data, only write locks are generally used. Frequent operations on different locks in the same thread will greatly increase the CPU waiting probability of each action of this thread. In severe cases, it will affect the real-time performance of data acquisition, resulting in the inability to update new data and extremely poor response.
[0011] Secondly, if the data acquisition module wants to achieve stable data collection, it needs to let the program process data most of the time and do as little other things as possible. However, the more accurate the collection of each signal, the more CPU rotation time is required to frequently collect the latest data and process the relationship between data logic. The two are inherently contradictory, and how developers measure the proportion of the two has always been a difficult problem.
[0012] Furthermore, the data acquisition module's interface to the upper-level application is generally cyclically queried through global variables. A better way should be to provide a non-blocking interface for each module to register the value jumps and threshold triggering issues of the messages it wants to pay attention to without taking up too much of its own time.
[0013] Finally, data collection cannot occupy too much Soc memory. Excessive CPU usage will cause device lag, for example, the normal operation of high-precision timers and GNSS (Global Navigation Satellite System) collection processes; and excessive memory and CPU usage will also make it easier to cause various system disorders, such as deadlock problems caused by frequent IO, abnormal interrupts, array access out of bounds, etc.
[0014] Therefore, to achieve stable data collection, the program must spend most of its time processing data and minimizing other tasks. However, the more accurate the acquisition of each signal, the more CPU time is required to frequently collect the latest data and process the relationships between data logic. These two factors are inherently contradictory. Therefore, how to balance these two factors to achieve stable and accurate data collection while also responding to the data interaction needs of layer applications is a technical challenge in the current development of new energy vehicles. Summary of the Invention
[0015] In view of this, the embodiments of the present application provide a vehicle data processing method, device, vehicle and readable storage medium based on TBox to solve the problem of how the TBox system in new energy vehicles can collect data stably and accurately while responding to the data interaction needs of layer applications.
[0016] In a first aspect of an embodiment of the present application, a vehicle data processing method based on TBox is provided, comprising:
[0017] A data collection thread is opened to sequentially perform prescribed processing on the vehicle message data collected by the TBox, and after processing each vehicle message data, a corresponding signal value is sent to a pre-built buffer queue, wherein the prescribed processing includes storing the vehicle message data in a global static area storage space, and the signal value is associated with a vehicle message data stored in the global static area storage space;
[0018] A monitor thread is opened to respond to the signal values in the buffer queue in sequence, and a blocking interface or a non-blocking interface is called to respond to the data request of the upper-layer application where the TBox system is located for the vehicle message data, wherein the data acquisition thread and the monitor thread share the global static area storage space.
[0019] According to a second aspect of an embodiment of the present application, a vehicle data processing device based on a TBox is provided, comprising:
[0020] A first processing module is configured to open a data collection thread to sequentially perform prescribed processing on the vehicle message data collected by the TBox, and send a corresponding signal value to a pre-built buffer queue after processing each vehicle message data, wherein the prescribed processing includes storing the vehicle message data in a global static area storage space, and the signal value is associated with the vehicle message data stored in the global static area storage space;
[0021] The second processing module is configured to open a monitor thread to respond to the signal values in the buffer queue in sequence, and call a blocking interface or a non-blocking interface to respond to the data request of the upper-layer application where the TBox system is located for the vehicle message data, wherein the data acquisition thread and the monitor thread share the global static area storage space.
[0022] According to a third aspect of an embodiment of the present application, a car is provided, comprising a TBox system, wherein the TBox system comprises a TBox bottom-layer acquisition chip and a TBox upper-layer receiving chip, wherein the TBox bottom-layer acquisition chip and the TBox upper-layer receiving chip are connected, and the TBox upper-layer receiving chip comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above method when executing the computer program.
[0023] According to a fourth aspect of an embodiment of the present application, a readable storage medium is provided, which stores a computer program. When the computer program is executed by a processor, the steps of the above method are implemented.
[0024] Compared with the prior art, the embodiments of the present application have the following beneficial effects: the above-mentioned vehicle data processing method based on TBox, by decoupling the data storage and monitoring functions during vehicle data collection into two threads, forms a single producer-dual consumption queue-single consumer model, so that the data collection thread is only responsible for receiving and storing, while the monitor thread independently completes data monitoring and serves the upper layer; thereby, there is no longer a situation where a certain thread has to process the reading and writing of high-frequency data in real time, and also has to take into account the high-frequency reading and monitoring data and provide real-time query functions, which greatly reduces the thread CPU occupancy pressure and makes the system more stable and reliable. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the embodiments or descriptions of the prior art. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0026] Figure 1 This is the architecture diagram of the existing TBox data collection model;
[0027] Figure 2 This is an architectural diagram of a decoupled TBox dual-thread model according to an embodiment of the present application;
[0028] Figure 3 is a flow chart of a vehicle data processing method based on TBox provided in an embodiment of the present application;
[0029] Figure 4 This is an architectural diagram of another decoupled TBox dual-thread model provided in an embodiment of the present application;
[0030] Figure 5 This is an architectural diagram of a limited blocking interface iteration model according to an embodiment of the present application;
[0031] Figure 6 This is an architecture diagram of an existing TBox blocking remote control execution model;
[0032] Figure 7 This is an architectural diagram of a TBox non-blocking remote control execution model provided in an embodiment of the present application;
[0033] Figure 8 1 is a schematic structural diagram of a vehicle data processing device based on TBox provided in an embodiment of the present application;
[0034] Figure 9 This is a partial structural diagram of a car provided in an embodiment of the present application;
[0035] Figure 10 This is an architectural diagram of a complete TBox dual-thread model provided by an embodiment of the present application;
[0036] Figure 11 This is a schematic diagram of the structure of a TBox upper layer receiving chip provided in an embodiment of the present application. DETAILED DESCRIPTION
[0037] In the following description, specific details such as specific system structures and techniques are provided for purposes of illustration rather than limitation to facilitate a thorough understanding of the embodiments of the present application. However, it will be apparent to those skilled in the art that the present application may be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to avoid obscuring the description of the present application with unnecessary detail.
[0038] See Figure 2 In one application scenario of the present application, a decoupled TBox dual-thread model is provided, including a TBox bottom-layer acquisition chip and a TBox upper-layer receiving chip. The TBox upper-layer receiving chip is connected to the TBox bottom-layer acquisition chip, which is connected to the control chip network of each control domain on the vehicle side through a communication bus to receive vehicle message data sent by each control chip. The TBox bottom-layer acquisition chip then transparently transmits the vehicle message data to the TBox upper-layer receiving chip, which processes the received vehicle message data by running a program. Specifically, an architecture of two threads and one storage space is opened up. The two threads are a data acquisition thread and a monitoring server thread, respectively. The storage space is a global static area storage space, and the two threads share the global static area storage space.
[0039] The data acquisition thread is responsible for data reception, legality verification, and data storage. It has high real-time performance, fast execution speed, and the ability to quickly enter the next cycle. After processing each vehicle message data, it only needs to pass a signal value to the buffer queue to notify the monitoring server thread.
[0040] The monitoring server thread acts as a monitor thread, and uses the buffer queue as a buffer for processing speed mismatches. Because of the existence of the buffer queue, there is no need to worry about missing the collected vehicle message data, so each signal can be carefully processed within this thread, and the latest status value of the current vehicle end can be updated at a higher frequency.
[0041] The working principle of the TBox dual-thread model described above is as follows: after the data acquisition thread stores a vehicle message data, it uses the buffer queue to notify the monitoring server thread. The monitoring server thread processes the data according to the incoming CAN message ID index, allowing the monitoring server thread to further handle issues such as signal transitions, trigger thresholds, or provide query interfaces for upper-level applications. As a result, the two threads share a global static area storage space and implement data synchronization and mutual exclusion through read-write locks. Compared to the existing TBox data acquisition model, in this application scenario, a thread no longer needs to handle both the real-time reading and writing of high-frequency data and the high-frequency reading of monitoring data, providing real-time query capabilities. This greatly reduces the thread CPU usage and makes the system more stable and reliable.
[0042] The data receiving and unpacking module, data security verification module, global memory storage module, special data monitoring module and service upload application module sequentially unpack, verify, store, monitor and distribute the vehicle message data. Specifically, the upper-layer applications of the TBox system include but are not limited to the message alarm module, remote module, data reporting module and ECall module, etc. These modules can meet corresponding business needs by querying the vehicle message data stored in the global internal storage module by the TBox upper-layer receiving chip.
[0043] Vehicle message data is usually collected by various control domains of the vehicle. Each control domain is responsible for managing specific vehicle functions and will generate corresponding data. These data are collected by the controller of each control domain at a set frequency and sent to the communication bus connected to the TBox underlying acquisition chip for collection by the TBox underlying acquisition chip. For example, Figure 1 The TBox underlying acquisition chip collects vehicle message data such as BCM domain data, PLG domain data, VCU domain data, etc. on the vehicle side through the CAN bus.
[0044] See Figure 3 In a first embodiment of the present application, a vehicle data processing method based on TBox is provided, comprising the following steps:
[0045] S101, opening a data collection thread to sequentially perform prescribed processing on the vehicle message data collected by the TBox, and sending a corresponding signal value to a pre-built buffer queue after processing each vehicle message data. The prescribed processing includes storing the vehicle message data in a global static area storage space, and the signal value is associated with the vehicle message data stored in the global static area storage space;
[0046] S102, opening a monitor thread to respond to the signal values in the buffer queue in sequence, and calling a blocking interface or a non-blocking interface to respond to the data request of the upper-layer application of the TBox system for the vehicle message data, wherein the data acquisition thread and the monitor thread share the global static area storage space.
[0047] Specifically, the data request of the upper-layer application includes a blocking data request and a non-blocking data request, that is, the latest vehicle message data of the vehicle needs to be obtained to update the service of the upper-layer application.
[0048] The vehicle data processing method provided in this embodiment decouples the data storage and monitoring functions during vehicle data collection into two threads, forming a single producer-dual consumption queue-single consumer model. The data collection thread is only responsible for receiving and storing data, while the monitor thread independently completes data monitoring and provides services to the upper layer. As a result, there is no longer a situation where a thread has to process the reading and writing of high-frequency data in real time, and also has to take into account the high-frequency reading and monitoring data and provide real-time query functions. This greatly reduces the thread CPU usage pressure and makes the system more stable and reliable.
[0049] In the above step S101, the prescribed processing of the vehicle message data includes at least one of receiving, unpacking, security verification and storage. For example, the prescribed processing in this embodiment includes receiving, verifying and storing the vehicle message data in sequence. Figure 2For example, the data acquisition thread receives and unpacks vehicle message data transmitted transparently from the TBox's underlying acquisition chip. This involves parsing and unpacking the vehicle message data according to protocol specifications. Unpacking involves parsing the received data frames and extracting valid information, such as the message ID, data length, and data content. Next, the vehicle message data undergoes security verification to ensure its integrity and authenticity. For example, this security verification can include data integrity verification and data authentication. Data integrity verification can utilize a checksum algorithm, cyclic redundancy check (CRC), or hash algorithm to ensure data has not been tampered with during transmission. Data authentication can utilize digital signatures or other encryption algorithms to verify the data's source and authenticity, preventing data forgery. Furthermore, during these verification processes, the verification results can be used to determine whether to accept or discard the received vehicle message data. Finally, the verified vehicle message data is stored in the global static area, completing the required processing of the vehicle message data.
[0050] A buffer queue is typically a data structure within a program that temporarily stores the signal values corresponding to pending vehicle message data, processed by the data acquisition thread and stored in the global static area, to notify the monitor thread of the next processing. Specifically, the signal value in the buffer queue serves as a marker indicating the data acquisition thread's specific processing of a vehicle message. This is used to notify the monitor thread to process the corresponding vehicle message data based on the signal value index, including but not limited to handling issues such as signal transitions, triggering thresholds, and providing query interfaces to upper-layer applications. Therefore, the signal value can be an index corresponding to the vehicle message data.
[0051] In addition, the data structure type of the buffer queue is not unique. For example, in an optional embodiment, an array can be constructed as the buffer queue. Of course, in practice, the buffer queue can also be other types of data structures, and this embodiment of the application does not limit this.
[0052] The global static area storage space is used to store global static variables and static objects, so that vehicle message data can be shared and accessed by different threads and modules, such as by the data acquisition thread and the monitor thread, thereby realizing the storage and monitoring of vehicle message data.
[0053] See Figure 4 In some optional embodiments, based on the prescribed processing in step S10, before storing the vehicle message data in a global static area storage space, the following steps are further included:
[0054] Identify whether the effective bit length of the message in the vehicle message data is less than or equal to a preset length, where the preset length is an integer multiple of the length of a single byte;
[0055] If yes, compress the vehicle message data into a message of a byte length corresponding to the preset length and store it in the global static area storage space;
[0056] If not, the vehicle message data is directly stored in the global static area storage space.
[0057] Specific, combined Figure 2 Generally speaking, the specifications of vehicle message data collected and sent to the CAN data bus by different control domains are different. The effective bit length of some vehicle message data is relatively long, while the effective bit length of some vehicle message data is relatively short. Therefore, if the same storage space is provided for storing these two different types of messages, it will lead to a waste of global static area storage space.
[0058] In an optional embodiment, assuming that the vehicle message data is an 8-byte message with a preset length of 16 bits, i.e., 2 bytes in length, when the effective bit length of the vehicle message data is less than or equal to 16 bits, the 8-byte message is forcibly converted into a 2-byte message, for example, the upper 6 bytes are deleted and compressed into a 2-byte message, thereby obtaining compressed vehicle message data, and the compressed vehicle message data is stored in the global static area storage space; in addition, when the effective bit length of the vehicle message data is greater than 16 bits, the vehicle message data in 8-byte format is retained, and the uncompressed vehicle message data is stored in the global static area storage space.
[0059] As can be seen, this embodiment simplifies the CAN data of different specifications received by the data acquisition thread into two types, namely compressed messages and normal messages, based on the actual signal length. When the message meets the compression conditions, it is forcibly converted from the original 8-byte message to a 2-byte message, reducing data storage pressure by 4 times, thereby effectively improving the utilization efficiency of the global static area storage space.
[0060] In step S102, the monitor thread provides two data access modes to the upper layer application, namely blocking and non-blocking interfaces. In other words, the monitor thread can respond to both blocking and non-blocking data requests from the upper layer application.
[0061] The specific implementation methods of the monitor thread responding to the blocking data request of the upper-layer application are not unique, including but not limited to synchronous calling, waiting for conditions to be met, waiting for locks, etc.
[0062] In an optional embodiment, the monitor thread responds to the blocking data request of the upper layer application, including:
[0063] Before obtaining vehicle message data, the trywait function is called cyclically to consume all currently available semaphores;
[0064] Within the specified time, call the sem_timedwait function to block and wait for the monitor thread to issue the post primitive;
[0065] If a post primitive is received within the specified time, the monitor thread is allowed to access the vehicle message data in the global static area storage space based on the mutex lock to respond to the blocking data request;
[0066] If the post primitive is not received within the specified time, the sem_timedwait function will automatically exit the response to the blocking data request.
[0067] The trywait function is used to manipulate semaphores and is commonly used in thread synchronization and mutual exclusion mechanisms. Specifically, the trywait function attempts to acquire ownership of a semaphore. If the semaphore's value is greater than zero, the acquisition is successful and the semaphore's value is decremented by one. If the semaphore's value is equal to zero, the trywait function returns immediately without blocking the current thread and returns an error code indicating the reason for the failure to acquire the semaphore.
[0068] sem_timedwait is a function related to semaphore operations, usually used in thread synchronization and mutual exclusion scenarios. Specifically, the sem_timedwait function attempts to obtain semaphore resources. If the semaphore resources are available within the specified timeout period, the resources are obtained and success is returned. If the timeout period expires and the resources are still unavailable, the function returns failure. In the embodiment of the present application, the data acquisition thread and the monitor thread are multi-threaded scenarios. sem_timedwait can be used to handle situations where waiting for resources (such as accessing vehicle message data) is required, but the waiting time needs to be limited to avoid long-term thread blocking, resulting in resource waste or deadlock.
[0069] A mutex is a common synchronization mechanism in multithreaded programming, used to protect shared resources, such as the vehicle message data in this example, by preventing race conditions caused by multiple threads accessing and modifying the same data simultaneously. Specifically, the key feature of a mutex is that only one thread can hold the lock at any given time; other threads must wait for that thread to release the lock before they can acquire it and access the protected shared resource.
[0070] This embodiment is based on the trywait+sem_timedwait+post mechanism and combines the underlying principle of mutex mutual exclusion lock to perform data synchronization and mutual exclusion operations on the global static area storage space, so as to respond to the blocking data request of the upper application.
[0071] For example, in existing technology, automotive electronics safety regulations require that each remote control operation must undergo a mandatory anti-theft authentication process. During this process, the upper-level remote control application, after issuing control commands, queries the authentication results and decides whether to proceed to the next step of result verification. During this authentication result query, the data collection thread determines whether each authentication result is successful. If so, it notifies the remote control thread by modifying the value of a global variable.
[0072] It can be seen that there are two problems with this solution:
[0073] First, the information collection thread needs to store and monitor each message it receives, which consumes a lot of performance.
[0074] Second, since the upper-layer application thread and the information collection thread are multi-threaded communications, there are problems with data synchronization and mutual exclusion that lead to dirty data.
[0075] To solve this technical problem, in combination with the above optional embodiments, and referring to Figure 5 Before collecting data, all available semaphores are consumed through a trywait loop to ensure no interference. Within a specified time (e.g., 1 second), the sem_timedwait interface is called to block and wait for the monitor thread to issue a post primitive. If a post signal is received, the global variable is accessed through the mutex lock. The remote control program can then determine whether the anti-theft authentication has been received and whether the execution succeeded or failed. If no post signal is received after the specified time, the sem_timedwait mechanism automatically exits the blocking primitive, allowing the remote control program to conclude that the anti-theft authentication has been unresponsive.
[0076] This embodiment, on top of the ordinary wait-post optimization mechanism, once again considers the principle of using a blocking query framework, and obtains vehicle message data through the semaphore of the trywait+sem_timedwait+post system primitives. If a deadlock occurs, the sem_timedwait primitive can, based on the specified time entered in advance by the user, actively exit the blocking wait and return a failure message if the required signal is not received within the specified time. This achieves data synchronization and mutual exclusion operations on the core variables in the global static area storage space, avoiding the situation where upper-level applications can only use inefficient polling to query data separately.
[0077] In another optional embodiment, the monitor thread responds to a non-blocking data request from an upper layer application, including:
[0078] Register the callback function with the monitor thread in advance;
[0079] When the monitor thread responds to the non-blocking data request of the upper-layer application of the TBox system, the monitor thread is used to monitor the vehicle message data corresponding to the signal value in turn to see if it meets the callback conditions;
[0080] If so, the callback function is called to process the vehicle message data that meets the callback conditions.
[0081] Specifically, after using the monitor thread to sequentially monitor whether the vehicle message data corresponding to the signal value meets the callback condition, the method further includes: if not, keeping the monitor thread monitoring the vehicle message data.
[0082] The technical solution provided in this embodiment addresses non-blocking data requests from upper-layer applications by porting the Observer pattern from an object-oriented language. The observer registers a callback with the observed object. When the desired event is triggered (i.e., the callback condition is met), the monitored state automatically notifies the upper-layer application, eliminating the need for variable polling. This achieves stable data collection, allowing the fast-processing data collection thread to spend most of its time processing data and minimizing other tasks. This allows the slower monitor thread to spend more CPU time ensuring the most accurate acquisition of each signal for real-time reading by the upper-layer application.
[0083] For example, combined with Figure 6 In existing new energy vehicles, when upper-layer applications need to determine whether a collision has occurred, the TBox program creates a thread and queries the collision validity bit every second or 100ms as needed to determine if it is true. If so, the TSP server is immediately notified and emergency measures are taken. While this approach can accomplish the required business functions, when there are dozens or hundreds of signals on the vehicle, each polling cycle requires checking all signal values for anomalies, significantly consuming CPU resources for these low-probability, high-importance tasks.
[0084] For this technical issue, see Figure 7 This embodiment, based on the observer pattern, uses the upper-level warning process application as an observer. During program initialization, a callback processing function is registered with the data acquisition process's monitor thread. When the monitor thread detects a collision signal, it proactively calls the upper-level application's callback function, completing the upper-level transmission of the alarm information. This demonstrates that by using callback functions, the results of asynchronous operations can be directly passed to the caller, providing a concise and flexible way to handle the results of non-blocking operations.
[0085] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.
[0086] The following are device embodiments of the present application, which can be used to implement the method embodiments of the present application. For details not disclosed in the device embodiments of the present application, please refer to the method embodiments of the present application.
[0087] See Figure 8 In a second embodiment of the present application, a vehicle data processing device based on TBox is provided, comprising:
[0088] The first processing module is configured to open a data collection thread to sequentially perform prescribed processing on the vehicle message data collected by the TBox, and send a corresponding signal value to a pre-built buffer queue after processing each vehicle message data, wherein the prescribed processing includes storing the vehicle message data in a global static area storage space, and the signal value is associated with the vehicle message data stored in the global static area storage space;
[0089] The second processing module is configured to open a monitor thread to respond to the signal values in the buffer queue in sequence, and call a blocking interface or a non-blocking interface to respond to the data request of the upper application of the TBox system for the vehicle message data, wherein the data acquisition thread and the monitor thread share the global static area storage space.
[0090] According to the technical solution provided in the embodiment of the present application, by decoupling the data storage and monitoring functions during vehicle data collection into two threads, a single producer-dual consumption queue-single consumer model is formed, so that the data collection thread is only responsible for receiving and storing, while the monitor thread independently completes data monitoring and serves the upper layer; thereby, there is no longer a situation where a thread has to process the reading and writing of high-frequency data in real time, and also has to take into account the high-frequency reading and monitoring data and provide real-time query functions, which greatly reduces the thread CPU usage pressure and makes the system more stable and reliable.
[0091] In some optional embodiments, the above-mentioned TBox-based vehicle data processing device further includes:
[0092] The compression storage module is configured to identify whether the effective bit length of the message in the vehicle message data is less than or equal to a preset length before storing the vehicle message data in a global static area storage space, and the preset length is an integer multiple of the length of a single byte: if so, the vehicle message data is compressed into a message of a byte length corresponding to the preset length and then stored in the global static area storage space; if not, the vehicle message data is directly stored in the global static area storage space.
[0093] In some optional embodiments, the above-mentioned second processing module is configured as a monitor thread to respond to the blocking data request of the upper-level application. Before obtaining the vehicle message data, it cyclically calls the trywait function to consume all currently available semaphores; within the specified time, it calls the sem_timedwait function to block and wait for the monitor thread to issue a post primitive; if the post primitive is received within the specified time, based on the mutex mutex, the monitor thread is allowed to access the vehicle message data in the global static area storage space to respond to the blocking data request; if the post primitive is not received within the specified time, based on the sem_timedwait function, it automatically exits the response to the blocking data request.
[0094] In some optional embodiments, the above-mentioned second processing module is configured as a monitor thread to respond to the non-blocking data request of the upper-layer application, and pre-registers a callback function to the monitor thread; when the monitor thread responds to the non-blocking data request of the upper-layer application of the TBox system, the monitor thread is used to monitor in sequence whether the vehicle message data corresponding to the signal value meets the callback condition; if so, the callback function is called to process the vehicle message data that meets the callback condition.
[0095] All of the above optional technical solutions can be combined in any way to form optional embodiments of the present application, and will not be described in detail here.
[0096] See Figure 9 In a third embodiment of the present application, a vehicle is provided, including a TBox system. The TBox system includes a TBox bottom-layer acquisition chip and a TBox upper-layer receiving chip, which are connected to each other. The vehicle can be a new energy vehicle, for example, a pure electric vehicle, a plug-in hybrid vehicle, or a hybrid electric vehicle.
[0097] TBox (short for Telematics Box) is an in-vehicle remote communication device, typically installed in new energy vehicles, used to implement functions such as remote vehicle monitoring, remote control, vehicle positioning, and data collection. TBox primarily consists of hardware and software.
[0098] Combine Figure 2 Generally speaking, the hardware of TBox includes the TBox bottom acquisition chip and the TBox upper receiving chip. Among them, the TBox bottom acquisition chip is connected to the control chip network of each control domain on the vehicle side through a communication bus to receive the vehicle message data sent by each control chip, and then the TBox bottom acquisition chip transparently transmits the vehicle message data to the TBox upper receiving chip.
[0099] Of course, in practice, the TBox hardware can also include a main control module, a communication module, a positioning module, and a sensor module. Specifically, the main control module is responsible for handling communication and control of various functional modules. The communication module is used to communicate with the remote server and typically includes a 4G / 5G module, a Bluetooth module, a Wi-Fi module, etc. The positioning module is used to determine the vehicle's location information and typically uses a GPS module.
[0100] The software of TBox includes computer programs running on the TBox bottom acquisition chip and the TBox upper receiving chip. In the embodiment of the present application, Figure 2 For example, software includes but is not limited to computer programs corresponding to functions such as the message alarm module, remote module, data reporting module, and ECall module in the upper-layer applications of the TBox system, as well as computer programs corresponding to the data acquisition thread and monitor thread, or computer programs that implement the steps of the above-mentioned vehicle data processing method based on TBox. These computer programs can run on the TBox bottom-layer acquisition chip or the TBox upper-layer receiving chip, or run on both the TBox bottom-layer acquisition chip and the TBox upper-layer receiving chip, or run on other hardware of the TBox, and the embodiments of the present application are not limited to this.
[0101] In addition, in practice, TBox software can also include embedded software, communication protocol stacks, data processing algorithms, and remote control interfaces or data interfaces. Specifically, embedded software generally runs on the embedded operating system and application programs on the TBox main control module, responsible for controlling hardware modules, processing vehicle data, and communicating with remote servers. The communication protocol stack is used to handle communications with remote servers and generally supports communication protocols such as TCP / IP, HTTP, and MQTT. The data processing algorithm is used to process collected vehicle data. For example, based on the steps of the TBox-based vehicle data processing method, the data acquisition thread is used to perform prescribed processing on the transmitted vehicle message data, while the monitor thread is used to respond to service requests from upper-level applications. The remote control interface is used to implement the function of remotely controlling the vehicle, while the data interface is used for the upper-level applications of the system to obtain the corresponding vehicle message data. For example, the data interface includes blocking and non-blocking interfaces provided by the monitor thread.
[0102] For example, combined with Figure 10 In a TBox dual-thread model application scenario, the TBox consists of two threads and one storage space. The two threads include a data acquisition thread and a monitor thread. The storage space includes, but is not limited to, a buffer queue.
[0103] The data acquisition thread is responsible for data reception, legality verification, and data storage. It must meet the requirements of high real-time performance, fast execution speed, and the ability to quickly enter the next cycle. After each data is processed, it only needs to pass a small signal value to the buffer queue to notify the monitor thread.
[0104] The monitor thread uses the buffer queue as a buffer for processing speed mismatches. Because of the buffer queue, there is no need to worry about missing the reported vehicle-side data, so each signal can be carefully processed within this thread and the latest status value of the current vehicle-side can be updated more frequently.
[0105] Further, combined with Figure 10 As shown, the model architecture provided by this embodiment is equivalent to a single producer-dual queue-single consumer model, which simplifies CAN data of different specifications into two types (compressed messages and normal messages) according to the actual signal usage length. When the message meets the compression conditions, it is forcibly converted from the original 8-byte message to a 2-byte message, reducing the data collection and storage pressure by 4 times.
[0106] In addition, two types of monitoring modes are provided for upper-level applications: blocking mode and non-blocking mode (based on the Observer design pattern), so as to avoid the upper-level applications having to use inefficient polling methods to query data separately.
[0107] The complete process of the TBox upper-layer receiving chip processing vehicle message data is as follows: after receiving the data transmitted by the underlying single-chip microcomputer chip, the Soc chip in the TBox is responsible for receiving and processing this data. The specific processing method is: open a data acquisition thread, a monitor thread and a global flag array, and combine them into a producer-consumer-buffer queue model. The received raw data is processed through multi-threading and division of labor, and an access interface is provided to all other applications. The data acquisition thread is responsible for high-speed and single processing of the received data, the monitor thread is responsible for executing various responsible algorithms, and the global flag array is responsible for marking the data that can be currently processed, so as to further process the data in the buffer; in the process of processing the raw data, according to the characteristics that most vehicle-side CAN data can only take the lower 2 bytes, the data is flexibly compressed, which directly reduces the total amount of data processing; in terms of supporting other modules that require data, two new access methods are added: blocking and non-blocking to obtain the underlying data, which not only reduces the upper-layer application's dependence on the underlying data, but also enables the upper-layer application to flexibly access the underlying data.
[0108] It can be seen that the working principle of the TBox dual-thread model provided by this embodiment is as follows: after the data acquisition thread stores a packet of data, it will use the buffer queue to notify the monitor thread. The monitor thread processes the data according to the incoming CAN message ID index. It can further handle issues such as signal jumps, trigger thresholds, or provide query interfaces for upper-layer applications. The two threads share a global static area storage space and implement data synchronization and mutual exclusion through read-write locks. After the split, there is no longer a thread that has to handle the real-time reading and writing of high-frequency data while also taking into account the high-frequency reading of monitoring data and providing real-time query functions. The thread CPU usage pressure is greatly reduced, and the system is more stable and reliable.
[0109] See Figure 11 The TBox upper-layer receiving chip includes a processor 111, a memory 112, and a computer program 113 stored in the memory 112 and executable by the processor 111. When the processor 111 executes the computer program 113, the steps in the aforementioned method embodiments are implemented. Alternatively, when the processor 111 executes the computer program 113, the functions of the modules in the aforementioned device embodiments are implemented.
[0110] The upper layer receiving chip of the TBox may include but is not limited to the processor 111 and the memory 112. It will be understood by those skilled in the art that Figure 11 This is only an example of the TBox upper layer receiving chip and does not constitute a limitation on the TBox upper layer receiving chip. It may include more or fewer components than shown in the figure, or different components.
[0111] The processor 111 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.
[0112] The memory 112 can be an internal storage unit of the upper-layer receiving chip of the TBox, for example, a hard disk or memory of the upper-layer receiving chip of the TBox. The memory 112 can also be an external storage device of the upper-layer receiving chip of the TBox, for example, a plug-in hard disk equipped on the upper-layer receiving chip of the TBox, a Smart Media Card (SMC), a Secure Digital (SD) card, a Flash Card, etc. The memory 112 can also include both the internal storage unit of the upper-layer receiving chip of the TBox and an external storage device. The memory 112 is used to store computer programs and other programs and data required by the electronic device.
[0113] Those skilled in the art will clearly understand that for the sake of convenience and brevity of description, only the division of the above-mentioned functional modules is used as an example for illustration. In actual applications, the above-mentioned functions can be distributed and completed by different functional modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional modules in the embodiment can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units.
[0114] If the integrated module is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium (such as a computer-readable storage medium). Based on this understanding, the present application implements all or part of the process 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. The computer program may include computer program code, which may be in source code form, object code form, executable file or some intermediate form. The computer-readable storage medium may include: any entity or device capable of carrying computer program code, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium, etc.
[0115] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present application, and should all be included in the scope of protection of the present application.
Claims
1. A vehicle data processing method based on TBox, characterized in that: include: A data collection thread is opened to sequentially perform prescribed processing on the vehicle message data collected by the TBox, and after processing each vehicle message data, a corresponding signal value is sent to a pre-constructed buffer queue. A vehicle data processing method, device, automobile and readable storage medium based on TBox. The prescribed processing includes storing the vehicle message data in a global static area storage space, and the signal value is associated with a vehicle message data stored in the global static area storage space; A monitor thread is opened to respond to the signal values in the buffer queue in sequence, and a blocking interface or a non-blocking interface is called to respond to the data request of the upper layer application where the TBox system is located for the vehicle message data, wherein the data acquisition thread and the monitor thread share the global static area storage space.
2. The method according to claim 1, characterized in that: Before storing the vehicle message data in a global static area storage space, it also includes: Identify whether the effective bit length of the message in the vehicle message data is less than or equal to a preset length, where the preset length is an integer multiple of a single byte length; If yes, compressing the vehicle message data into a message of a byte length corresponding to the preset length and storing it in a global static area storage space; If not, the vehicle message data is directly stored in the global static area storage space.
3. The method according to claim 1 or 2, characterized in that: The monitor thread responds to blocking data requests from upper-layer applications, including: Before obtaining vehicle message data, the trywait function is called cyclically to consume all currently available semaphores; Within the specified time, call the sem_timedwait function to block and wait for the monitor thread to issue a post primitive; If a post primitive is received within the specified time, the monitor thread is allowed to access the vehicle message data in the global static area storage space based on the mutex to respond to the blocking data request; If the post primitive is not received within the specified time, the sem_timedwait function automatically exits responding to the blocking data request.
4. The method according to claim 1 or 2, characterized in that: The monitor thread responds to non-blocking data requests from upper-layer applications, including: Register the callback function with the monitor thread in advance; When the monitor thread responds to the non-blocking data request of the upper layer application of the TBox system, the monitor thread is used to monitor in sequence whether the vehicle message data corresponding to the signal value meets the callback condition; If so, the callback function is called to process the vehicle message data that meets the callback condition.
5. A vehicle data processing device based on TBox, characterized in that: include: The first processing module is configured to open a data collection thread to sequentially perform prescribed processing on the vehicle message data collected by the TBox, and send a corresponding signal value to a pre-built buffer queue after processing each vehicle message data, wherein the prescribed processing includes storing the vehicle message data in a global static area storage space, and the signal value is associated with a vehicle message data stored in the global static area storage space; The second processing module is configured to open a monitor thread to respond to the signal values in the buffer queue in sequence, and call a blocking interface or a non-blocking interface to respond to the data request of the upper-level application where the TBox system is located for the vehicle message data, wherein the data acquisition thread and the monitor thread share the global static area storage space.
6. The device according to claim 5, characterized in that Also includes: The compression storage module is configured to identify whether the effective bit length of the message in the vehicle message data is less than or equal to a preset length before storing the vehicle message data in a global static area storage space, and the preset length is an integer multiple of a single byte length: if so, the vehicle message data is compressed into a message of a byte length corresponding to the preset length and then stored in the global static area storage space; if not, the vehicle message data is directly stored in the global static area storage space.
7. The device according to claim 5 or 6, characterized in that The second processing module is configured as a monitor thread responding to the blocking data request of the upper layer application, and before obtaining the vehicle message data, cyclically calling the trywait function to consume all currently available semaphores; within the specified time, calling the sem_timedwait function to block and wait for the monitor thread to issue a post primitive; if the post primitive is received within the specified time, then based on the mutex, the monitor thread is allowed to access the vehicle message data in the global static area storage space to respond to the blocking data request; If the post primitive is not received within the specified time, the sem_timedwait function automatically exits responding to the blocking data request.
8. The method according to claim 5 or 6, characterized in that: The second processing module is configured as a monitor thread that responds to a non-blocking data request from an upper-layer application, and pre-registers a callback function to the monitor thread; when the monitor thread responds to a non-blocking data request from an upper-layer application of the TBox system, the monitor thread is used to sequentially monitor whether the vehicle message data corresponding to the signal value meets the callback condition; If so, the callback function is called to process the vehicle message data that meets the callback condition.
9. A car, comprising a TBox system, wherein the TBox system comprises a TBox bottom acquisition chip and a TBox upper receiving chip, wherein the TBox bottom acquisition chip and the TBox upper receiving chip are connected, and the TBox upper receiving chip comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 4 are implemented.
10. A readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 4 are implemented.
Citation Information
Patent Citations
Vehicle domain multi-level parallel buffering and context-based streaming data pre-processing system
CN108369593A
Vehicle data recording method and device
CN110225123A
Vehicle running state real-time monitoring method and device, electronic equipment and storage medium
CN116017290A
Vehicle message transmission method, device and system, electronic equipment and storage medium
CN117354335A
Communication control apparatus
JP2010062981A
Cited By
Method and device for remotely controlling ECU and TBOX
CN116909256A
Asynchronous event management system, method and equipment for multiple department logo platforms and storage medium
CN119342101A
Asynchronous event management system, method, device and storage medium for multi-standard platform
CN119342101B
