A vehicle data acquisition method and system, electronic equipment and storage medium
By receiving the collection configuration from the cloud management platform, creating a circular task chain in groups, and performing binary search processing, the problems of configuration updates and resource waste in whole vehicle data collection are solved, and efficient and flexible data collection is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- BEIJING JINGWEI HIRAIN TECH CO INC
- Filing Date
- 2026-05-07
- Publication Date
- 2026-06-19
AI Technical Summary
Existing technologies cannot effectively meet the diverse needs of vehicle data acquisition, especially when acquiring data from the CAN bus. They cannot update the acquisition configuration in a timely manner, resulting in insufficient acquisition of high-frequency signals or excessive acquisition of low-frequency signals. Furthermore, they cannot accurately isolate and manage data from different acquisition cycles.
By receiving the acquisition configuration from the cloud management platform, a circular task list is created in groups, and a timer is used to trigger a loop traversal of the list. Combined with binary search and type processing, efficient acquisition and reporting of CAN bus data is achieved.
This allows for flexible updates to the acquisition configuration without modifying the underlying MCU software, improving the efficiency and accuracy of data acquisition, meeting diverse data acquisition needs, and avoiding resource waste and data loss.
Smart Images

Figure CN122248030A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of vehicle data acquisition technology, and in particular to a vehicle data acquisition method and system, electronic device, and storage medium. Background Technology
[0002] Currently, in the research and development and operation of intelligent connected vehicles, a large number of tasks rely on various data on the vehicle's CAN bus, such as vehicle speed, engine speed, and braking status. Therefore, real-time acquisition of these data on the vehicle's CAN bus is crucial.
[0003] The current method for acquiring data from a vehicle's CAN bus primarily involves hard-coding a list of CAN bus IDs and a set acquisition cycle into the firmware of the microcontroller unit (MCU). During MCU operation, at each acquisition cycle interval, a sequential lookup algorithm compares the ID of the current CAN bus message with the IDs in the written ID list to determine if the current message is the one that needs to be acquired. This allows the acquired message to be uploaded to the cloud management platform via the communication module.
[0004] However, the existing method requires modifications to the MCU's underlying software whenever data acquisition needs change. This necessitates development, testing, and deployment, making updates inconvenient and unable to meet timely acquisition requirements. Using a uniform acquisition cycle, with tasks from different acquisition cycles mixed together, can easily lead to insufficient high-frequency signal acquisition or excessive low-frequency signal acquisition, and ineffective isolation and management, thus failing to accurately meet the acquisition needs of various data types. Furthermore, this method simply collects data, only ordinary application messages. Therefore, the current approach cannot adequately meet diverse data acquisition requirements. Summary of the Invention
[0005] In view of the shortcomings of the prior art, this application provides a vehicle data acquisition method and system, electronic device and storage medium to solve the problem that the prior art cannot effectively meet the diverse vehicle data acquisition needs.
[0006] To achieve the above objectives, this application provides the following technical solution:
[0007] The first aspect of this application provides a method for acquiring vehicle data, including:
[0008] Receive the current collection configuration issued by the cloud management platform; wherein, the current collection configuration includes multiple collection entries; each collection entry includes at least one bus identifier and its corresponding collection period and type;
[0009] The collection items are grouped according to the collection period to obtain multiple period groups;
[0010] Create a circular task list for each of the said periodic groups;
[0011] Within each acquisition cycle of the cycle group, each node of the circular task chain of the cycle group is traversed in turn, and the current bus identifier and its corresponding type are read from the node.
[0012] The current message matching the current bus identifier is found by performing a binary search in the ordered array; wherein, the ordered array includes the ordered arrangement of the bus identifiers of the latest monitored current messages within the acquisition period of the period group;
[0013] Based on the type corresponding to the current bus identifier, the current message is processed to obtain the currently collected data;
[0014] The currently collected data is reported to the cloud management platform.
[0015] Optionally, in the above-described vehicle data acquisition method, receiving the current acquisition configuration issued by the cloud management platform includes:
[0016] The system receives the current collection configuration sent by the cloud management platform through the communication module; wherein the communication module performs integrity verification on the received current collection configuration and sends it out after the current collection configuration passes the integrity verification.
[0017] Optionally, in the above-described vehicle data acquisition method, after creating the circular task list for each of the cycle groups, the method further includes:
[0018] A dedicated timer is configured for each of the period groups based on their acquisition period.
[0019] Register a dedicated trigger function for each of the configured timers;
[0020] The original timer is turned off, the memory of the original ring link table of each of the original period groups is released, and the current ring link table of each of the period groups is set as the current active task link table.
[0021] The configuration result of the current collection configuration is reported to the cloud management platform.
[0022] Optionally, in the above-described vehicle data acquisition method, the step of traversing each node of the circular task chain of the cycle group within each acquisition cycle of the cycle group, and reading the current bus identifier and its corresponding type from the node, includes:
[0023] When any of the timers in the periodic group triggers an interrupt, the trigger function of the timer is called to trigger a loop to traverse each node of the circular task list of the periodic group;
[0024] Read the bus identifier and its corresponding type from the currently traversed node to obtain the current bus identifier and its corresponding type.
[0025] Optionally, in the above-described vehicle data acquisition method, the step of processing the current message found according to the type corresponding to the current bus identifier to obtain the current acquired data includes:
[0026] If the type corresponding to the current bus identifier is a normal application message, extract a specified byte from the found current message;
[0027] If the type corresponding to the current bus identifier is a diagnostic message, record the diagnostic session state of the current message;
[0028] If the type corresponding to the current bus identifier is a multi-frame transmission message, the current message is reassembled with each frame message belonging to the same data.
[0029] Optionally, in the above-described vehicle data collection method, the step of reporting the currently collected data to the cloud management platform includes:
[0030] Perform a validity check on the currently collected data;
[0031] If the currently collected data passes the validity check, then the currently collected data is written into the shared circular buffer;
[0032] When any one of the reporting conditions is met, the currently collected data in the shared circular buffer is reported to the cloud management platform through the communication module; wherein, the reporting conditions include the filling amount of the shared circular buffer is not less than a preset ratio, the reporting time has been reached, and an automatic retrieval command has been received.
[0033] Optionally, the above-mentioned vehicle data acquisition method also includes:
[0034] Upon detection of any abnormal event, it is handled through the abnormal event handling mechanism. The abnormal events include configuration reception failure, memory allocation failure, timer resource conflict, linked list corruption, multi-frame message anomaly, buffer overflow, and network interruption. The handling mechanism for configuration reception failure is to request retransmission a set number of times. The handling mechanism for memory allocation failure is to maintain the data acquisition strategy. The handling mechanism for timer resource conflict is to merge adjacent period groups. The handling mechanism for linked list corruption is to reconnect the corrupted circular task linked list. The handling mechanism for multi-frame message anomaly is to initiate a retransmission request or discard the current session. The handling mechanism for buffer overflow is to pause non-critical signal acquisition. The handling mechanism for network interruption is to enter offline caching mode to cache the acquired data for a set time period, and upon network response, respond to the communication module's heartbeat packet and upload the offline cached acquired data.
[0035] A second aspect of this application provides a vehicle data acquisition system, comprising:
[0036] Cloud management platform, communication module, and data acquisition unit;
[0037] The cloud management platform is used to send the current acquisition configuration to the acquisition unit through the communication module; wherein, the current acquisition configuration includes multiple acquisition entries; each acquisition entry includes at least a bus identifier and its corresponding acquisition cycle and type;
[0038] The acquisition unit is used to group the acquisition items according to the acquisition cycle to obtain multiple cycle groups, and create a circular task list for each cycle group. Within the acquisition cycle of each cycle group, it iterates through each node of the circular task list of the cycle group, reads the current bus identifier and its corresponding type from the node, performs a binary search on the current bus identifier in an ordered array to find the current message matching the current bus identifier, processes the found current message according to the type corresponding to the current bus identifier to obtain the current acquisition data, and reports the current acquisition data to the cloud management platform through the communication module.
[0039] The ordered array includes the ordered arrangement of the bus identifiers of the latest monitored current packets within the acquisition period of the periodic group.
[0040] Optionally, in the above-mentioned vehicle data acquisition system, the communication module is further used for:
[0041] The received current acquisition configuration is verified for integrity, and then sent to the acquisition unit after the current acquisition configuration passes the integrity verification.
[0042] Optionally, in the above-described vehicle data acquisition system, the acquisition unit further includes:
[0043] A dedicated timer is configured for each of the period groups based on their acquisition period.
[0044] Register a dedicated trigger function for each of the configured timers;
[0045] The original timer is turned off, the memory of the original ring link table of each of the original period groups is released, and the current ring link table of each of the period groups is set as the current active task link table.
[0046] The configuration result of the current collection configuration is reported to the cloud management platform.
[0047] Optionally, in the above-described vehicle data acquisition system, when the acquisition unit performs the step of iterating through each node of the circular task chain of each cycle group within each acquisition cycle, and reading the current bus identifier and its corresponding type from the node, it is used for:
[0048] When any of the timers in the periodic group triggers an interrupt, the trigger function of the timer is called to trigger a loop to traverse each node of the circular task list of the periodic group;
[0049] Read the bus identifier and its corresponding type from the currently traversed node to obtain the current bus identifier and its corresponding type.
[0050] Optionally, in the above-described vehicle data acquisition system, when the acquisition unit performs the process of processing the current message found according to the type corresponding to the current bus identifier to obtain the current acquired data, it is used for:
[0051] If the type corresponding to the current bus identifier is a normal application message, extract a specified byte from the found current message;
[0052] If the type corresponding to the current bus identifier is a diagnostic message, record the diagnostic session state of the current message;
[0053] If the type corresponding to the current bus identifier is a multi-frame transmission message, the current message is reassembled with each frame message belonging to the same data.
[0054] Optionally, in the above-described vehicle data acquisition system, when the acquisition unit performs the action of reporting the currently acquired data to the cloud management platform, it is used for:
[0055] Perform a validity check on the currently collected data;
[0056] If the currently collected data passes the validity check, then the currently collected data is written into the shared circular buffer;
[0057] When any one of the reporting conditions is met, the currently collected data in the shared circular buffer is reported to the cloud management platform through the communication module; wherein, the reporting conditions include the filling amount of the shared circular buffer is not less than a preset ratio, the reporting time has been reached, and an automatic retrieval command has been received.
[0058] Optionally, in the above-described vehicle data acquisition system, the acquisition unit is further configured to:
[0059] Upon detection of any abnormal event, it is handled through the abnormal event handling mechanism. The abnormal events include configuration reception failure, memory allocation failure, timer resource conflict, linked list corruption, multi-frame message anomaly, buffer overflow, and network interruption. The handling mechanism for configuration reception failure is to request retransmission a set number of times. The handling mechanism for memory allocation failure is to maintain the data acquisition strategy. The handling mechanism for timer resource conflict is to merge adjacent period groups. The handling mechanism for linked list corruption is to reconnect the corrupted circular task linked list. The handling mechanism for multi-frame message anomaly is to initiate a retransmission request or discard the current session. The handling mechanism for buffer overflow is to pause non-critical signal acquisition. The handling mechanism for network interruption is to enter offline caching mode to cache the acquired data for a set time period, and upon network response, respond to the communication module's heartbeat packet and upload the offline cached acquired data.
[0060] A third aspect of this application provides an electronic device, comprising:
[0061] Memory and processor;
[0062] The memory is used to store programs;
[0063] The processor is used to execute the program, which, when executed, is specifically used to implement the vehicle data acquisition method as described in any of the above.
[0064] The fourth aspect of this application provides a computer storage medium for storing a computer program, which, when executed by a processor, is used to implement the vehicle data acquisition method as described in any of the preceding claims.
[0065] This application provides a vehicle data acquisition method in which the acquisition unit receives the current acquisition configuration from a cloud management platform. The current acquisition configuration includes multiple acquisition entries, each containing at least one bus identifier and its corresponding acquisition period and type. This means that for each bus identifier, a corresponding acquisition period can be set according to the acquisition frequency requirements, rather than using a uniform acquisition period. This satisfies the acquisition needs of various data types and avoids insufficient acquisition of high-frequency signals or excessive acquisition of low-frequency signals. Furthermore, the data type corresponding to each bus identifier needs to be configured to perform data type differentiation processing, thus supporting the acquisition of various data types, no longer limited to just acquiring ordinary application messages. Then, the acquisition entries are grouped according to the acquisition period, resulting in multiple period groups. This groups tasks with the same acquisition period together, facilitating management and the implementation of acquisition tasks. A circular task chain is then created for each period group, thus creating the various acquisition tasks of the current configuration. This facilitates data acquisition, so the acquisition configuration can be updated without modifying the MCU underlying software, achieving online updates of the acquisition configuration. Next, within each acquisition cycle of a cycle group, each node of the circular task list of the cycle group is traversed iteratively. The current bus identifier and its corresponding type are read from the node. Then, a binary search is performed on the current bus identifier in an ordered array to find the current message that matches the current bus identifier. The ordered array contains the ordered arrangement of the bus identifiers of the most recently monitored current messages within the acquisition cycle of the cycle group. By using the ordered array and binary search, the message matching effect is effectively improved, thereby increasing the efficiency of data acquisition. Then, according to the type corresponding to the current bus identifier, the found current message is processed to obtain the current acquisition data, thus enabling the acquisition of data from various types of messages. Finally, the current acquisition data is reported to the cloud management platform. Therefore, a vehicle data acquisition method that can effectively meet diverse data acquisition needs is implemented. Attached Figure Description
[0066] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of this application. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0067] Figure 1 A flowchart illustrating a vehicle data acquisition method provided in this application embodiment;
[0068] Figure 2 This application provides a schematic diagram of the architecture of a vehicle data acquisition system.
[0069] Figure 3 A flowchart illustrating a method for enabling the current data collection configuration provided in this application embodiment;
[0070] Figure 4 A flowchart illustrating a method for reporting currently collected data, provided in an embodiment of this application;
[0071] Figure 5 This is a schematic diagram of the architecture of another vehicle data acquisition system provided in an embodiment of this application;
[0072] Figure 6 This is a schematic diagram of the architecture of an electronic device provided in an embodiment of this application. Detailed Implementation
[0073] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0074] In this application, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0075] This application provides a method for collecting vehicle data, such as... Figure 1 As shown, it includes the following steps:
[0076] S101, Receive the current data collection configuration issued by the cloud management platform.
[0077] The current acquisition configuration includes multiple acquisition entries. Each acquisition entry includes at least one bus identifier and its corresponding acquisition cycle and type.
[0078] In other words, a corresponding acquisition cycle is assigned to each bus identifier, which facilitates subsequent data acquisition according to different data acquisition frequency requirements, i.e., according to its corresponding acquisition cycle. This allows for setting the optimal frequency for each signal, avoiding resource waste and loss of critical data, and achieving refined allocation of acquisition resources.
[0079] Furthermore, the system configures the types corresponding to each bus identifier to differentiate data types, enabling the collection of various data types, such as general application messages, network management messages, diagnostic request / response messages, and multi-frame transmission messages. Therefore, by using message type identifiers, it natively supports the collection and processing of multiple CAN message types, overcoming the poor scalability of traditional solutions.
[0080] Specifically, such as Figure 2 As shown, the cloud management platform sends a structured CAN bus ID list, acquisition cycle, and message type to the communication module, which then transmits the data to the acquisition unit. Specifically, the communication module can be a microprocessor unit (MPU), and the acquisition unit can be a microcontroller unit (MCU). Optionally, as... Figure 2 As shown, the cloud management platform can send the structured current acquisition configuration to the communication module (MPU) in the vehicle via HTTPS / MQTT. The communication module (MPU) then forwards the configuration to the acquisition unit (MCU) as the acquisition unit through the Serial Peripheral Interface (SPI), so that the MCU can listen to and acquire data from the vehicle's CAN bus according to the configuration.
[0081] After receiving the current acquisition configuration, the MCU temporarily stores the information of the current acquisition configuration in the RAM buffer, and then parses the bus identifier can_id, acquisition period cycle_ms, and type frame_type fields of each entry from the current acquisition configuration.
[0082] Optionally, in another embodiment of this application, one specific implementation of step S101 includes:
[0083] Receive the current data collection configuration sent by the cloud management platform through the communication module.
[0084] The communication module performs integrity verification on the received current acquisition configuration and sends it out after the current acquisition configuration passes the integrity verification.
[0085] Optionally, a CRC32 checksum can be configured in the current acquisition configuration. The communication module (MPU) decodes the received current acquisition configuration and performs integrity verification by comparing it with the CRC32 checksum. If the verification fails, the current acquisition configuration sent by the cloud management platform is discarded. If the current acquisition configuration passes the integrity verification, it is sent to the acquisition unit (MCU).
[0086] S102. Group each collection item according to the collection cycle to obtain multiple cycle groups.
[0087] It should be noted that, in this embodiment, data is collected for each bus identifier in the CAN bus ID list according to its corresponding acquisition period. Since the CAN bus ID list may contain multiple bus identifiers with the same acquisition period, to facilitate data collection, the acquisition entries are grouped according to their acquisition period; that is, acquisition entries with the same acquisition period are grouped into one period group, resulting in multiple period groups.
[0088] S103. Create a circular task list for each cycle group.
[0089] To collect data from each cycle group separately through corresponding tasks and to effectively manage each cycle group without mixing all collection tasks together, a circular task linked list is created for each cycle group. Specifically, a corresponding node is constructed using the information of each entry in a cycle group. Each node contains at least a bus identifier and its corresponding type, a pointer to the next node, and all nodes are pre-allocated in a static memory pool (to avoid runtime malloc). The last node points to the first node, thus connecting all nodes into a circular chain, resulting in the circular task linked list for each cycle group.
[0090] For example, a node can be defined as follows:
[0091] "typedef struct CanTaskNode {
[0092] uint32_t can_id;
[0093] uint8_t frame_type;
[0094] struct CanTaskNode *next;
[0095] } CanTaskNode;
[0096] Therefore, by traversing the circular task list in a fixed order, the data acquisition tasks for each bus identifier can be iterated. The circular task list has a simple structure, does not require frequent memory allocation, is suitable for periodic acquisition, and facilitates the insertion and removal of nodes during operation, making it easy to adjust the acquisition tasks. Thus, by creating the circular task list, data acquisition according to the new acquisition configuration can be achieved without MCU software upgrades, shortening the development and deployment cycle from weeks to minutes, realizing "hot configuration" and online updates of the acquisition strategy, and significantly reducing costs.
[0097] Optionally, each bus identifier in each cycle group is sorted in ascending order to form an effective array, and a circular task linked list is constructed based on the sorting result, that is, the nodes of each bus identifier are connected in the order of arrangement.
[0098] Optionally, in another embodiment of this application, after executing step S103, the current acquisition configuration can be further activated, that is, the new acquisition configuration replaces the original acquisition configuration, so as to use the new acquisition configuration for data acquisition. Figure 3 As shown in the embodiment of this application, a method for enabling the current data collection configuration includes:
[0099] S301. Configure a dedicated timer for each period group according to the acquisition period of each period group.
[0100] It should be noted that, in order to promptly initiate the acquisition task for each period group upon reaching its acquisition cycle, a dedicated timer is configured for each period group based on its acquisition cycle. Specifically, the system's available timer resources can be queried, and a dedicated hardware timer can be set up for each non-empty cycle. For example, Timer_A can be configured for a 20ms period group, and Timer_B for a 50ms period group, thus setting corresponding periodic interrupts for each period group.
[0101] S302. Register a dedicated trigger function for each configured timer.
[0102] In order to trigger the traversal and collection action of the circular task chain of the periodic group when the timer expires, a dedicated trigger function is registered for each timer, such as timer20ms_delaycheck(), which is used to trigger the traversal and collection action of the circular task chain of that periodic group.
[0103] S303. Close the original timer, release the memory of the original ring link table of each period group, and set the current ring link table of each period group as the current active task link table.
[0104] Since a new acquisition configuration needs to be enabled, the timer interrupts for the original acquisition configuration are disabled, and the memory for the old circular task lists is released. Alternatively, they can be marked as invalid. Finally, the newly created list is set as the currently active task list, thus enabling the current acquisition configuration.
[0105] S304. Report the configuration results of the current collection configuration to the cloud management platform.
[0106] To inform users of the current configuration status, the final configuration result is returned to the cloud management platform. Optionally, this can be achieved by the communication module returning a configuration result code, which is then reported to the cloud management platform. For example, feedback 0 indicates success, feedback 1 indicates a CRC error, feedback 2 indicates insufficient memory, and feedback 3 indicates a timer conflict.
[0107] S104. Within the acquisition cycle of each cycle group, traverse each node of the circular task chain of the cycle group and read the current bus identifier and its corresponding type from the node.
[0108] Specifically, whenever the acquisition cycle of any cycle group is reached, starting from the head node of the circular task list of the cycle group, each node of the circular task list of the cycle group is continuously traversed within the acquisition cycle of that cycle group. The bus identifier and its corresponding type are read from the traversed node and used as the current bus identifier and its corresponding type, so as to collect the data of the current bus identifier and process the collected data according to its corresponding type.
[0109] Optionally, in another embodiment of this application, when configuring a dedicated timer for each period group and registering a trigger function for the timer, one specific implementation of step S104 includes:
[0110] When the timer of any period group triggers an interrupt, the timer's trigger function is called to trigger a loop to traverse each node of the circular task list of the period group, and reads the bus identifier and its corresponding type from the currently traversed node as the current bus identifier and its corresponding type.
[0111] Specifically, whenever the timer of any period group reaches its timeout, i.e., when the timer of any period group triggers an interrupt, the trigger function of that timer is called to initiate a loop through each node of the circular task list of the period group. Correspondingly, the bus identifier is read from the currently traversed node, and the acquisition function is called to acquire CAN messages based on the current bus identifier. For example, when Timer_A reaches 20ms, the timer's "timer20ms_datacheck()" function is called, traversing each node of the circular task list of the period group, and the "process_can_group(&head_20ms)" function is called to acquire CAN messages.
[0112] S105. By performing a binary search on the current bus identifier in the ordered array, the current message matching the current bus identifier is found.
[0113] The ordered array includes the ordered arrangement of the bus identifiers of the latest monitored current packets within the collection period of the periodic group.
[0114] It should be noted that, in order to efficiently acquire data, in this embodiment of the application, the bus identifier of the CAN bus message in the current acquisition cycle is extracted and arranged in ascending order to form an ordered array of the current cycle group. This facilitates binary search instead of sequential search, and optimizes the matching processing time of thousands of CAN IDs from milliseconds to microseconds, greatly reducing the CPU load of the MCU.
[0115] Optionally, CAN bus messages can be cached in the CAN controller's receive buffer, with the latest messages also cached. That is, for a given bus identifier, when a new message for that bus identifier is received, the original message can be overwritten, thus capturing the latest message. Correspondingly, the CAN controller's receive buffer is monitored for new message arrivals. When a new message is detected in the CAN controller's receive buffer, a binary search is performed on the current bus identifier within the ordered array of the current period group. If a bus identifier matching the current bus identifier is found, the current message corresponding to that bus identifier is taken as the matching current message.
[0116] S106. Based on the type corresponding to the current bus identifier, process the current message found to obtain the current collected data.
[0117] Since different types of messages require different data to be collected, in order to support the collection of various types of messages, the current message is processed according to the type corresponding to the current bus identifier to obtain the current collection data.
[0118] Optionally, in another embodiment of this application, one specific implementation of step S106 includes:
[0119] If the type corresponding to the current bus identifier is a normal application message, extract the specified bytes from the current message that has been found.
[0120] Since specific bytes of data need to be collected from ordinary application messages, the specified bytes can be directly extracted and stored in the upload queue to upload the data to the cloud management platform.
[0121] If the type corresponding to the current bus identifier is a diagnostic message, record the diagnostic session status of the current message.
[0122] For diagnostic messages, the main requirement is to collect the diagnostic status, so the diagnostic session status of the current message is recorded. Corresponding messages are then filtered.
[0123] If the current bus identifier corresponds to a multi-frame transmission message, the current message will be reassembled with other frames that belong to the same data.
[0124] For multi-frame transmission messages, which transmit different parts of the same data, the protocol stack needs to be activated to reassemble the multi-frame data into complete data. Furthermore, the sequence number continuity needs to be checked during the reassembly process to ensure accurate data reconstruction.
[0125] S107. Report the currently collected data to the cloud management platform.
[0126] Specifically, the currently collected data can be reported to the cloud management platform via the communication module. Optionally, the currently collected data can be reported to the cloud management platform in real time, or the latest collected data can be reported at regular intervals, or the data can be reported after a certain amount of data has been accumulated.
[0127] Optionally, in another embodiment of this application, one specific implementation of step S107 is as follows: Figure 4 As shown, it includes:
[0128] S401. Perform a reasonableness check on the currently collected data.
[0129] It should be noted that to avoid reporting abnormal data, the reasonableness of the currently collected data needs to be validated. Optionally, since the collected data can be identified based on the bus identifier corresponding to the currently collected data, corresponding validation logic can be set based on the bus identifier to validate the reasonableness of the currently collected data. For example, for the collected vehicle speed, it can be checked whether it is less than 300km / h. If the vehicle speed is greater than 300km / h, then the data is determined to be abnormal.
[0130] S402. Determine whether the currently collected data has passed the rationality check.
[0131] If the currently collected data passes the validity check, step S303 is executed. If the currently collected data fails the validity check, it can be marked as "invalid" to prevent the upload of abnormal data.
[0132] S403. Write the currently collected data into the shared circular buffer.
[0133] It should be noted that collected data is only reported when certain conditions are met, so valid currently collected data is written to a shared circular buffer. Optionally, the shared circular buffer can employ a two-pointer mechanism to prevent overflow.
[0134] S404. When any one of the reporting conditions is met, the current collected data in the shared circular buffer is reported to the cloud management platform through the communication module.
[0135] The reporting conditions include the shared circular buffer being filled to a preset percentage, the reporting time being reached, and receiving an automatic pull command. Specifically, when the amount of data in the shared circular buffer is not less than a preset percentage (e.g., ≥80%), or when the set time has elapsed since the last data upload (e.g., 2 seconds have passed since the last upload), or when an active pull command is received via the communication module, SPI DMA will be initiated to report all data in the shared circular buffer to the cloud management platform.
[0136] Optionally, in another embodiment of this application, in order to maintain the high reliability of the system, the system's repair and guarantee mechanism is further improved, specifically including:
[0137] When any abnormal event is detected, it is handled through the abnormal event handling mechanism.
[0138] Abnormal events include configuration reception failure, memory allocation failure, timer resource conflict, linked list corruption, multi-frame message abnormality, buffer overflow, and network interruption.
[0139] The configuration for handling reception failures involves requesting a set number of retransmissions. That is, if SPI communication is interrupted or CRC check fails, it will attempt a maximum of the set number of retransmission requests, for example, a maximum of 3 retransmission requests. Specifically, a handshake signal can be used to notify the MPU to retransmit.
[0140] The mechanism for handling memory allocation failures is to maintain the data acquisition strategy. That is, if the node pool of the circular task list is full and memory cannot be allocated to create a new circular task list, an error code can be returned, and the old strategy will continue to run without reporting a new strategy.
[0141] The mechanism for handling timer resource conflicts is to merge adjacent period groups. That is, when a period group has no available timers, adjacent period groups are merged, thereby reducing the number of timers that need to be configured and satisfying the requirement to configure timers for each period group. Adjacent period groups are those whose sampling periods are adjacent in time.
[0142] The mechanism for handling a corrupted linked list is to reconnect the corrupted circular task linked list. Specifically, this can be done periodically in the main loop by checking if the linked list is circular. Optionally, this can be done using fast and slow pointers. If a broken link is detected, the linked list is rebuilt, that is, the circular task linked list is reconstructed using the data from that periodic group.
[0143] The handling mechanism for multi-frame message anomalies is to initiate a retransmission request or discard the current session. Specifically, if multiple frames are received with skipped or duplicate sequence numbers, a retransmission request will be initiated or the current session will be discarded.
[0144] The mechanism for handling buffer overflows is to pause the acquisition of non-critical signals. For example, when the shared circular buffer usage exceeds 90%, the acquisition of non-critical signals is paused to prioritize high-priority signals, such as brake and steering signals.
[0145] The network interruption handling mechanism is to enter offline caching mode to cache the collected data for a set time, and then respond to the heartbeat packet of the communication module after the network is restored, and upload the offline cached collected data.
[0146] Specifically, when the communication module detects a cellular network disconnection, it can notify the MCU to enter "offline caching mode," thus caching the currently collected data offline for later uploading once the network is restored. Optionally, considering limited local storage space and the time-sensitivity of data, it can be configured to store only data from the most recent period, for example, a maximum cache of the last 10 minutes of data.
[0147] After the network is restored, the MPU can send a heartbeat packet to the MCU to let the MCU know that the network has been restored. At this time, the MCU responds and initiates the backlog data retransmission, that is, uploading the offline cached data to the cloud management platform. Optionally, a sliding window protocol can be used to carefully upload the offline cached collected data to avoid congestion.
[0148] Therefore, through the end-to-end anomaly handling and automatic recovery mechanism from configuration and data acquisition to communication, the long-term stable operation of the system and the integrity and reliability of the data are ensured in complex vehicle environments.
[0149] This application provides a method for acquiring vehicle data, in which the acquisition unit receives the current acquisition configuration from a cloud management platform. The current acquisition configuration includes multiple acquisition entries, each containing at least one bus identifier and its corresponding acquisition period and type. This means that for each bus identifier, a corresponding acquisition period can be set according to the acquisition frequency requirements, rather than using a uniform acquisition period. This satisfies the acquisition needs of various data types and avoids insufficient acquisition of high-frequency signals or excessive acquisition of low-frequency signals. Furthermore, the data type corresponding to each bus identifier needs to be configured to perform data type differentiation processing, thereby supporting the acquisition of various data types, no longer limited to just acquiring ordinary application messages. Then, the acquisition entries are grouped according to the acquisition period, resulting in multiple period groups. This groups tasks with the same acquisition period together, facilitating management and the implementation of acquisition tasks. A circular task chain is then created for each period group, thus creating the various acquisition tasks in the current configuration. This facilitates data acquisition, so the acquisition configuration can be updated without modifying the MCU's underlying software, achieving online updates of the acquisition configuration. Next, within each acquisition cycle of a cycle group, each node of the circular task list of the cycle group is traversed iteratively. The current bus identifier and its corresponding type are read from the node. Then, a binary search is performed on the current bus identifier in an ordered array to find the current message that matches the current bus identifier. The ordered array contains the ordered arrangement of the bus identifiers of the most recently monitored current messages within the acquisition cycle of the cycle group. By using the ordered array and binary search, the message matching effect is effectively improved, thereby increasing the efficiency of data acquisition. Then, according to the type corresponding to the current bus identifier, the found current message is processed to obtain the current acquisition data, thus enabling the acquisition of data from various types of messages. Finally, the current acquisition data is reported to the cloud management platform. Therefore, a vehicle data acquisition method that can effectively meet diverse data acquisition needs is implemented.
[0150] Another embodiment of this application provides a vehicle data acquisition system, such as... Figure 5 As shown, it includes:
[0151] The cloud management platform 501, the communication module 502, and the acquisition unit 503.
[0152] The cloud management platform 501 is used to send the current acquisition configuration to the acquisition unit 503 through the communication module 502.
[0153] The current acquisition configuration includes multiple acquisition entries. Each acquisition entry includes at least one bus identifier and its corresponding acquisition cycle and type.
[0154] The acquisition unit 503 is used to group the acquisition items according to the acquisition cycle to obtain multiple cycle groups, and create a circular task chain for each cycle group. Within the acquisition cycle of each cycle group, it iterates through each node of the circular task chain for the cycle group, reads the current bus identifier and its corresponding type from the node, and performs a binary search on the current bus identifier in the ordered array to find the current message that matches the current bus identifier. Based on the type corresponding to the current bus identifier, the current message is processed to obtain the current acquisition data. The current acquisition data is then reported to the cloud management platform 501 through the communication module 502.
[0155] The ordered array includes the ordered arrangement of the bus identifiers of the latest monitored current packets within the collection period of the periodic group.
[0156] Optionally, in another embodiment of the vehicle data acquisition system provided in this application, the communication module is further used for:
[0157] The received current acquisition configuration is verified for integrity, and then sent to the acquisition unit after the current acquisition configuration passes the integrity verification.
[0158] Optionally, in another embodiment of the vehicle data acquisition system provided in this application, the acquisition unit further includes:
[0159] Each period group is configured with a dedicated timer based on its acquisition period.
[0160] Register a dedicated trigger function for each configured timer.
[0161] Turn off the original timers, release the memory of the original circular linked lists of each periodic group, and set the current circular linked lists of each periodic group as the current active task linked lists.
[0162] Report the current configuration results of the collected data to the cloud management platform.
[0163] Optionally, in another embodiment of the vehicle data acquisition system provided in this application, when the acquisition unit performs the following operations within each acquisition cycle of each cycle group: it iterates through each node of the circular task chain of the cycle group and reads the current bus identifier and its corresponding type from the node:
[0164] When a timer in any periodic group triggers an interrupt, the timer's trigger function is called, which triggers a loop to traverse each node of the circular task list of the periodic group.
[0165] Read the bus identifier and its corresponding type from the currently traversed node to obtain the current bus identifier and its corresponding type.
[0166] Optionally, in another embodiment of the vehicle data acquisition system provided in this application, when the acquisition unit processes the current message found according to the type corresponding to the current bus identifier to obtain the current acquisition data, it is used for:
[0167] If the type corresponding to the current bus identifier is a normal application message, extract the specified bytes from the current message that has been found.
[0168] If the type corresponding to the current bus identifier is a diagnostic message, record the diagnostic session status of the current message.
[0169] If the current bus identifier corresponds to a multi-frame transmission message, the current message will be reassembled with other frames that belong to the same data.
[0170] Optionally, in another embodiment of the vehicle data acquisition system provided in this application, when the acquisition unit reports the currently acquired data to the cloud management platform, it is used for:
[0171] Perform a validity check on the currently collected data.
[0172] If the currently collected data passes the validity check, then the currently collected data is written into the shared circular buffer.
[0173] When any one of the reporting conditions is met, the currently collected data in the shared circular buffer is reported to the cloud management platform via the communication module. The reporting conditions include the shared circular buffer being filled to a preset ratio, the reporting time being reached, and receiving an automatic retrieval command.
[0174] Optionally, in another embodiment of the vehicle data acquisition system provided in this application, the acquisition unit is further used for:
[0175] Upon detecting any abnormal event, it is handled according to the abnormal event handling mechanism. These abnormal events include configuration reception failure, memory allocation failure, timer resource conflict, linked list corruption, multi-frame packet anomaly, buffer overflow, and network interruption. The handling mechanism for configuration reception failure is to request retransmission a set number of times. The handling mechanism for memory allocation failure is to maintain the data acquisition strategy. The handling mechanism for timer resource conflict is to merge adjacent period groups. The handling mechanism for linked list corruption is to reconnect the corrupted circular task linked list. The handling mechanism for multi-frame packet anomaly is to initiate a retransmission request or discard the current session. The handling mechanism for buffer overflow is to suspend the acquisition of non-critical signals. The handling mechanism for network interruption is to enter offline caching mode to cache the acquired data for a set time, and upon network recovery, respond to the communication module's heartbeat packet and upload the offline cached acquired data.
[0176] It should be noted that the specific working process of each unit provided in the above embodiments of this application can be referred to the implementation process of the corresponding steps in the above method embodiments, and will not be repeated here.
[0177] Another embodiment of this application provides an electronic device, which may specifically be a data acquisition unit in a system. For example... Figure 6 An electronic device provided in this application includes:
[0178] Memory 601 and processor 602.
[0179] The memory 601 is used to store the program.
[0180] The processor 602 is used to execute the program stored in the memory 601. When the program is executed, it is specifically used to implement the vehicle data acquisition method provided in any of the above embodiments.
[0181] Another embodiment of this application provides a computer storage medium for storing a computer program, which, when executed by a processor, is used to implement the vehicle data acquisition method provided in any of the above embodiments.
[0182] Computer storage media, including both permanent and non-permanent, removable and non-removable media, can store information using any method or technology. Information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0183] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0184] The above description of the disclosed embodiments enables those skilled in the art to make or use this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for acquiring vehicle data, characterized in that, include: Receive the current collection configuration issued by the cloud management platform; wherein, the current collection configuration includes multiple collection entries; each collection entry includes at least one bus identifier and its corresponding collection period and type; The collection items are grouped according to the collection period to obtain multiple period groups; Create a circular task list for each of the said periodic groups; Within each acquisition cycle of the cycle group, each node of the circular task chain of the cycle group is traversed in turn, and the current bus identifier and its corresponding type are read from the node. The current message matching the current bus identifier is found by performing a binary search in the ordered array; wherein, the ordered array includes the ordered arrangement of the bus identifiers of the latest monitored current messages within the acquisition period of the period group; Based on the type corresponding to the current bus identifier, the current message is processed to obtain the currently collected data; The currently collected data is reported to the cloud management platform.
2. The method according to claim 1, characterized in that, The current data collection configuration received from the cloud management platform includes: The system receives the current collection configuration sent by the cloud management platform through the communication module; wherein the communication module performs integrity verification on the received current collection configuration and sends it out after the current collection configuration passes the integrity verification.
3. The method according to claim 1, characterized in that, After creating the circular task list for each of the cycle groups, the method further includes: A dedicated timer is configured for each of the period groups based on their acquisition period. Register a dedicated trigger function for each of the configured timers; The original timer is turned off, the memory of the original ring link table of each of the original period groups is released, and the current ring link table of each of the period groups is set as the current active task link table. The configuration result of the current collection configuration is reported to the cloud management platform.
4. The method according to claim 3, characterized in that, Within each acquisition cycle of the cycle group, each node of the circular task list of the cycle group is traversed cyclically, and the current bus identifier and its corresponding type are read from the node, including: When any of the timers in the periodic group triggers an interrupt, the trigger function of the timer is called to trigger a loop to traverse each node of the circular task list of the periodic group; Read the bus identifier and its corresponding type from the currently traversed node to obtain the current bus identifier and its corresponding type.
5. The method according to claim 1, characterized in that, The process of processing the current message found based on the type corresponding to the current bus identifier to obtain the currently collected data includes: If the type corresponding to the current bus identifier is a normal application message, extract a specified byte from the found current message; If the type corresponding to the current bus identifier is a diagnostic message, record the diagnostic session state of the current message; If the type corresponding to the current bus identifier is a multi-frame transmission message, the current message is reassembled with each frame message belonging to the same data.
6. The method according to claim 1, characterized in that, The step of reporting the currently collected data to the cloud management platform includes: Perform a validity check on the currently collected data; If the currently collected data passes the validity check, then the currently collected data is written into the shared circular buffer; When any one of the reporting conditions is met, the currently collected data in the shared circular buffer is reported to the cloud management platform through the communication module; wherein, the reporting conditions include the filling amount of the shared circular buffer is not less than a preset ratio, the reporting time has been reached, and an automatic retrieval command has been received.
7. The method according to claim 1, characterized in that, Also includes: Upon detection of any abnormal event, it is handled through the abnormal event handling mechanism; wherein, the abnormal events include configuration reception failure, memory allocation failure, timer resource conflict, linked list corruption, multi-frame message anomaly, buffer overflow, and network interruption; the handling mechanism for configuration reception failure is to perform a set number of request retransmissions; the handling mechanism for memory allocation failure is to maintain the data acquisition strategy; the handling mechanism for timer resource conflict is to merge adjacent period groups; and the handling mechanism for linked list corruption is to reconnect the corrupted circular task linked list; The handling mechanism for the multi-frame message anomaly is to initiate a retransmission request or discard the current session; the handling mechanism for the buffer overflow is to pause the acquisition of non-critical signals; the handling mechanism for the network interruption is to enter offline caching mode to cache the acquired data within a set time, and to respond to the heartbeat packet of the communication module after the network reply, and upload the offline cached acquired data.
8. A vehicle data acquisition system, characterized in that, include: Cloud management platform, communication module, and data acquisition unit; The cloud management platform is used to send the current acquisition configuration to the acquisition unit through the communication module; wherein, the current acquisition configuration includes multiple acquisition entries; each acquisition entry includes at least a bus identifier and its corresponding acquisition cycle and type; The acquisition unit is used to group the acquisition items according to the acquisition cycle to obtain multiple cycle groups, and create a circular task list for each cycle group. Within the acquisition cycle of each cycle group, it iterates through each node of the circular task list of the cycle group, reads the current bus identifier and its corresponding type from the node, performs a binary search on the current bus identifier in an ordered array to find the current message matching the current bus identifier, processes the found current message according to the type corresponding to the current bus identifier to obtain the current acquisition data, and reports the current acquisition data to the cloud management platform through the communication module. The ordered array includes the ordered arrangement of the bus identifiers of the latest monitored current packets within the acquisition period of the periodic group.
9. An electronic device, characterized in that, include: Memory and processor; The memory is used to store programs; The processor is used to execute the program, which, when executed, is specifically used to implement the vehicle data acquisition method as described in any one of claims 1 to 7.
10. A computer storage medium, characterized in that, Used to store a computer program, which, when executed by a processor, is used to implement the vehicle data acquisition method as described in any one of claims 1 to 7.