CAN message storage method, device, equipment and storage medium based on domain controller
The two-level buffer queue and storage method of the domain controller solves the problems of incomplete storage and low reliability of CAN bus messages, and realizes the complete storage and fast reading of all CAN bus messages in the vehicle.
Patent Information
- Application Number
- CN202310626795.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-29
- Publication Date
- 2025-09-12
- Estimated Expiration
- 2043-05-29
AI Technical Summary
In the prior art, the message storage of the CAN bus in the vehicle is incomplete and has low reliability. Especially when the number of messages on the CAN bus is too large, T-BOX collection may result in frame omissions.
The target message of the CAN bus is obtained in real time through the domain controller, cached using the first-level buffer queue and the second-level buffer queue, packaged to generate message files, and stored in the memory in real time to ensure the integrity and reliability of the message.
It achieves the integrity and reliability of message storage for all CAN buses in the vehicle, avoids storage omissions caused by insufficient transmission rate, and ensures that complete message data can be quickly obtained during fault analysis.
Smart Images

Figure CN116708070B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of message storage, and in particular to a CAN message storage method, device, equipment and storage medium based on a domain controller. Background Art
[0002] Currently, electronic controllers within vehicles primarily communicate via the CAN (Controller Area Network) bus. During actual vehicle operation, the CAN bus carries a large number of messages, including various types of vehicle control information and status information. These messages enable performance analysis and troubleshooting of the vehicle. However, with the advancement of intelligent vehicles, the number of controllers within vehicles continues to increase, and the integration of domain controllers is becoming increasingly sophisticated. Consequently, the number of CAN messages is growing exponentially. The question arises how to effectively store CAN messages so that, when a vehicle malfunctions, technicians can easily access the stored messages and analyze the cause of the malfunction based on the stored messages. In related technologies, messages on the CAN bus are typically collected and stored using a vehicle's T-BOX (Telematics BOX), an in-vehicle networked intelligent terminal.
[0003] Chinese patent CN218567887U discloses a CAN message collection system for electric vehicles. This system uses a T-BOX inside the vehicle to collect and store CAN message data from an external CAN bus. It also extracts and transmits CAN message data before and after a fault to an operations platform, where it can display the CAN messages. However, this solution can only store message data from the CAN bus connected to the T-BOX, not all CAN buses in the vehicle. The stored message data is incomplete, and when the number of messages on the CAN bus is too large, the T-BOX may miss frames in the collected messages, resulting in low message storage reliability.
[0004] Therefore, how to improve the integrity and reliability of message storage on the CAN bus is an urgent problem to be solved. Summary of the Invention
[0005] In view of the above-mentioned shortcomings of the prior art, the present invention provides a CAN message storage method, device, equipment and storage medium based on a domain controller to solve at least one of the above-mentioned technical problems.
[0006] In a first aspect, the present invention provides a CAN message storage method based on a domain controller, comprising: acquiring target messages from a CAN bus in a vehicle in real time based on a domain controller; performing a first cache on the target messages according to the time sequence of the target messages, and caching them in a first-level buffer queue; grouping target messages of a preset number of frames in the first-level buffer queue, determining data packets, performing a second cache on each of the data packets, and caching the data packets in a second-level buffer queue; combining a preset number of data packets in the second-level buffer queue to generate a message file, and storing the message file in real time in a memory.
[0007] In one embodiment of the present invention, the first caching of the target message is performed according to the time sequence of the target message, and the caching is performed in the first-level buffer queue, including: sorting each target message in time order from small to large according to the timestamp of each target message, and determining the caching order of each target message; detecting the number of frames of the target message cached in the first-level buffer queue; if the number of frames of the target message cached in the first-level buffer queue is greater than or equal to the preset number of frames, pausing the first caching; if the number of frames of the target message cached in the first-level buffer queue is less than the preset number of frames, caching the target message in the first-level buffer queue based on the caching order of each target message.
[0008] In one embodiment of the present invention, the second caching is performed on each of the data packets, and the data packets are cached in a secondary buffer queue, including: sorting each of the data packets in order from small to large time according to the timestamp of the last frame target message in each of the data packets, and determining the cache order of each of the data packets; detecting whether there is free space in the secondary buffer queue; if there is free space in the secondary buffer queue, caching the data packets in the secondary buffer queue based on the cache order of each of the data packets; if there is no free space in the secondary buffer queue, pausing the second buffering until there is free space in the secondary buffer queue.
[0009] In one embodiment of the present invention, the data packets of a preset number in the secondary buffer queue are combined to generate a message file, and the message file is stored in a memory, including: sorting each message file in ascending chronological order according to the timestamp of the last data packet in the message file to determine the storage order of each message file; detecting the remaining space of the memory; if the remaining space size of the memory is higher than the preset space threshold, storing each message file in the memory based on the storage order of each message file; if the remaining space size of the memory is lower than the preset space threshold, using the message file with a higher priority to overwrite the message file stored first in the memory according to the storage order of each message file; wherein, before storing the message file in the memory, compressing the message file so that the message file is stored in the memory in the form of a compressed package.
[0010] In one embodiment of the present invention, after combining a preset number of the data packets in the secondary buffer queue to generate a message file, and storing the message file in the memory, it also includes: establishing communication between the host computer and the domain controller; reading the message files in the memory by the host computer in the storage order of each message file to obtain the preset number of the data packets, and the memory is placed in the domain controller; unpacking the preset number of the data packets to obtain multiple frames of the target message; comparing the timestamps of each frame of the target message to splice the multiple frames of the target message in time sequence to obtain the target message of a time period, and the time period is determined by the minimum timestamp and the maximum timestamp in the multiple frames of the target message.
[0011] In one embodiment of the present invention, the domain controller-based acquisition of the target message from the CAN bus in the vehicle includes: acquiring an initial message from the CAN bus in the vehicle; adding a timestamp and message attribute information to each frame of the initial message to obtain the target message, wherein the message attribute information includes a message count, a message identification number, a bus channel, a bus type, a message transmission direction, and a message length.
[0012] In one embodiment of the present invention, the first caching of the target messages according to the time sequence of the target messages also includes: if at least two target messages with the same time are detected, the at least two target messages are arbitrated according to the priority pre-associated with the message attribute information to determine the time sequence of the at least two target messages.
[0013] In a second aspect, the present invention also provides a CAN message storage device based on a domain controller, comprising: an acquisition module for acquiring target messages from a CAN bus in a vehicle based on a domain controller; a first buffer module for performing a first cache on the target messages according to the time sequence of the target messages, and caching them in a first-level buffer queue; a second buffer module for packetizing target messages of a preset number of frames in the first-level buffer queue, determining data packets, performing a second cache on each of the data packets, and caching the data packets in a second-level buffer queue; a storage module for combining a preset number of data packets in the second-level buffer queue, generating a message file, and storing the message file in a memory.
[0014] In a third aspect, the present invention also provides an electronic device comprising: one or more processors; a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the domain controller-based CAN message storage method as described in the above embodiments.
[0015] In a fourth aspect, the present invention further provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor of a computer, the computer executes the domain controller-based CAN message storage method as described in the above embodiment.
[0016] Beneficial effects of the present invention: The present invention proposes a CAN message storage method, device, equipment and storage medium based on a domain controller. The present invention obtains target messages from the CAN bus in the vehicle in real time through the domain controller; performs a first cache on the target message according to the time sequence of the target message, and caches it in a first-level buffer queue; groups the target messages of a preset number of frames in the first-level buffer queue, determines the data packet, performs a second cache on each data packet, and caches the data packet in a second-level buffer queue; combines the preset number of data packets in the second-level buffer queue to generate a message file, and stores the message file in real time in a memory. On the one hand, the target messages existing on all CAN buses in the vehicle can be obtained through the domain controller in the vehicle, ensuring the integrity of the message storage. On the other hand, the target message is cached twice, and the first-level buffer queue and the second-level buffer queue are used as the buffer zone of the target message, avoiding the situation where a large number of messages exist on the CAN bus at a certain moment and the transmission rate is insufficient, resulting in the omission of some target messages, thereby improving the reliability of message storage.
[0017] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] The accompanying drawings are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present invention, and together with the specification, are used to explain the principles of the present invention. Obviously, the drawings described below are only some embodiments of the present invention, and it is clear that a person skilled in the art can derive other drawings based on these drawings without inventive effort. In the drawings:
[0019] Figure 1 1 is a schematic diagram of an implementation environment of a CAN message storage method based on a domain controller according to an exemplary embodiment of the present invention;
[0020] Figure 2 is a schematic structural diagram of a domain controller shown in an exemplary embodiment of the present invention;
[0021] Figure 3 is a flowchart of a CAN message storage method based on a domain controller according to an exemplary embodiment of the present invention;
[0022] Figure 4 is a schematic diagram showing a method of buffering target packets using two-stage queues according to an exemplary embodiment of the present invention;
[0023] Figure 5 is a flowchart of real-time storage and reading of target messages shown in an exemplary embodiment of the present invention;
[0024] Figure 6 is a flowchart of real-time storage of target messages shown in an exemplary embodiment of the present invention;
[0025] Figure 7 is a flow chart of real-time reading of a target message shown in an exemplary embodiment of the present invention;
[0026] Figure 8 is a block diagram of a CAN message storage device based on a domain controller according to an exemplary embodiment of the present invention;
[0027] Figure 9 It is a structural diagram of a computer system suitable for implementing the electronic device of the present invention, shown in an exemplary embodiment of the present invention. DETAILED DESCRIPTION
[0028] The following describes the embodiments of the present invention with reference to the accompanying drawings and preferred embodiments. Those skilled in the art will readily appreciate the other advantages and benefits of the present invention from the disclosure herein. The present invention may also be implemented or applied through various other specific embodiments, and the various details in this specification may be modified or altered based on different viewpoints and applications without departing from the spirit of the present invention. It should be understood that the preferred embodiments are intended only to illustrate the present invention and are not intended to limit the scope of protection of the present invention.
[0029] It should be noted that the illustrations provided in the following embodiments are merely schematic illustrations of the basic concept of the present invention. Therefore, the illustrations only show components related to the present invention and are not drawn according to the number, shape, and size of components in actual implementation. In actual implementation, the type, quantity, and proportion of each component may be changed arbitrarily, and the component layout may also be more complex.
[0030] In the following description, numerous details are discussed to provide a more thorough explanation of the embodiments of the present invention. However, it will be apparent to those skilled in the art that the embodiments of the present invention may be practiced without these specific details. In other embodiments, well-known structures and devices are shown in block diagram form rather than in detail to avoid obscuring the embodiments of the present invention.
[0031] See also Figure 1 , is a schematic diagram of an implementation environment of a CAN message storage method based on a domain controller according to an exemplary embodiment of the present invention.
[0032] Reference Figure 1 As shown, the implementation environment includes a vehicle 101 and a domain controller 102, wherein the domain controller 102 is embedded in the vehicle 101. The domain controller 102 can obtain target messages from all CAN buses in the vehicle 101 in real time, so that the target messages are buffered in the first-level buffer queue and the second-level buffer queue in sequence. This prevents the problem of target message frame leakage during storage due to an excessive number of target messages on the CAN bus, thereby improving the integrity and reliability of target message storage on the CAN bus in the vehicle 101.
[0033] See also Figure 2 , is a schematic diagram of the structure of a domain controller shown in an exemplary embodiment of the present invention. Figure 2As shown, the domain controller includes an MCU (i.e., microcontroller), an MPU (i.e., microprocessor unit) and an EMMC (Embedded Multimedia Card) memory. Among them, the microcontroller is used to obtain target messages from the CAN bus in the vehicle in real time; the target messages are cached in a first-level buffer queue according to the time sequence of the target messages; the target messages of a preset number of frames in the first-level buffer queue are grouped, the data packets are determined, and the second cache is performed on each data packet, and the data packets are cached in a second-level buffer queue; the microprocessor unit is connected to the microcontroller via a high-speed SPI (Serial Peripheral interface) to receive data packets sent by the second-level buffer queue, and processes a preset number of consecutive data packets into message files, each of which has the same size; the EMMC memory has the advantages of large capacity, high speed and low power consumption, and is used as a storage space on the microprocessor side to store message files generated by the microprocessor unit.
[0034] Continue to refer to Figure 2 As shown, in one embodiment of the present invention, the domain controller can use an external WIFI communication interface to establish a stable network connection with an external host computer, and enable the host computer to access the EMMC memory of the domain controller through the FTP communication protocol (i.e., file transfer protocol), and upload the message file stored in the EMMC memory in the form of a compressed package to the host computer to read the target message through the host computer. It should be understood that the host computer is a computer running the host computer software, and the host computer software provides the function of processing and displaying the received target message, thereby realizing fast and real-time reading of the target message.
[0035] See also Figure 3 , is a flowchart of a CAN message storage method based on a domain controller according to an exemplary embodiment of the present invention. This method can be applied to Figure 1 The implementation environment shown in FIG. 1 is specifically configured in the domain controller 102. The method may also be applicable to other exemplary implementation environments and specifically configured in other devices. This embodiment does not limit the implementation environment to which the method is applicable.
[0036] like Figure 3 As shown, in an exemplary embodiment, the CAN message storage method based on the domain controller includes at least steps S310 to S340, which are described in detail as follows:
[0037] Step S310: acquiring target messages from the CAN bus in the vehicle in real time based on the domain controller.
[0038] The target message is determined by:
[0039] Acquire the initial message from the CAN bus in the vehicle; add a timestamp and message attribute information to each frame of the initial message to obtain the target message, where the message attribute information includes message count, message identification number, bus channel, bus type, message transmission direction, and message length.
[0040] In one embodiment of the present invention, a domain controller acquires initial messages from all CAN buses within a vehicle in real time. These initial messages include received messages on the CAN bus and sent messages from the domain controller. While acquiring these initial messages, a data segment is added to each acquired initial message in real time to facilitate subsequent storage. This data segment includes a timestamp and message attribute information. The timestamp is the current real-time timestamp, and the message attribute information includes the message count, ID (i.e., message identification number), bus channel, bus type (CAN or CAN with FlexibleData rate), message transmission direction (whether the initial message is sent or received by the CAN bus), and message length.
[0041] Step S320 , performing a first cache on the target message according to the time sequence of the target message, and caching the target message in a first-level buffer queue.
[0042] Specifically, the time order of the target messages is determined by the timestamps added to the target messages. Target messages with smaller timestamps are arranged in front of target messages with larger timestamps. However, the domain controller may obtain multiple target messages with the same time from multiple CAN buses. These target messages have the same timestamps and cannot be compared. Therefore, when at least two target messages with the same time are detected, the multiple target messages with the same time will be arbitrated based on the priority pre-associated with the message attribute information to determine the time order of the multiple target messages with the same time. For example, based on the priorities of different bus channels preset in the message attributes, the priorities of each target message from different bus channels are determined when the time of each target message is the same to determine the time order of each target message.
[0043] In one embodiment of the present invention, the time sequence of each target message from small to large is used as the cache order of each target message, and the target message is first cached, that is, the target message is cached in a first-level buffer queue according to the cache order of each target message, and the depth of the first-level buffer queue is a preset number of frames. Therefore, if the number of frames of the target message cached in the first-level buffer queue is greater than or equal to the preset number of frames, the first-level buffer queue space is full and cannot continue to receive subsequent target messages, and the first cache will be paused; if the number of frames of the target message cached in the first-level buffer queue is less than the preset number of frames, the first-level buffer queue space is not full, and the target message will be cached in the first-level buffer queue based on the cache order of each target message, wherein the preset number of frames, that is, the depth of the first-level buffer queue can be set according to actual conditions.
[0044] See also Figure 4 , is a schematic diagram showing a method of buffering target messages using two-stage queues according to an exemplary embodiment of the present invention. Figure 4 As shown, the depth of the first-level buffer queue is n, and the target message follows the first-in-first-out principle of the queue. Each target message is cached in the first-level buffer queue from the end of the queue in chronological order, and then taken out from the head of the queue.
[0045] In one embodiment of the present invention, to prevent frame loss when target messages are cached in a first-level buffer queue, a loop count is performed for each preset number of target messages based on the message count in the message attribute information, starting with the first target message in the preset number of target messages and continuing until the last target message in the preset number of target messages is reached. If the count is discontinuous or the counts for the first and last target messages are incorrect, frame loss occurs during the first buffering process, and a prompt indicating the target message is lost is generated. This counting method effectively prevents frame loss during message storage, thereby improving the reliability of message storage.
[0046] In one embodiment of the present invention, in order to prevent the target messages on different CAN buses from conflicting in time sequence, each target message can be grouped according to the message attribute information. For example, the target messages on the same CAN bus can be treated as a message combination according to the bus channel in the message attribute information, and each message combination can be buffered in a first-level buffer queue respectively.
[0047] Step S330 , grouping target messages of a preset number of frames in the primary buffer queue, determining data packets, performing a second buffer on each data packet, and buffering the data packets in the secondary buffer queue.
[0048] Specifically, continue to refer to Figure 4 ,After the target message is taken out from the head of the first-level buffer queue, it is necessary to group the target messages into packets, that is, treat the target messages with the preset number of frames as a data packet, and put the data packets into the second-level buffer queue from the tail of the second-level buffer queue. Figure 4 As shown, the depth of the secondary buffer queue is m, that is, the space of the secondary buffer queue can cache m data packets at most.
[0049] In one embodiment of the present invention, in order to meet the requirements of high-speed communication between the microcontrol unit and the microprocessing unit and to fully utilize the transmission rate between the microcontrol unit and the microprocessing unit, it is necessary to package the target message. The preset frame number of each target message with a preset frame number can be adjusted according to the actual memory resources of the microprocessing unit. The larger the preset frame number, the greater the memory resources required. This method does not limit this.
[0050] Specifically, the caching order of each data packet follows the first-in, first-out principle of the secondary buffer queue. Based on the timestamp of the last target message in each packet, the data packets are sorted in ascending order of time to determine the caching order of each data packet. The secondary buffer queue is checked for free space. If free space is available, the data packet is cached in the secondary buffer queue based on the caching order of each data packet. If free space is not available, the secondary buffer is suspended to prevent data packet loss due to insufficient space in the secondary buffer queue, which could result in the loss of data packets and the loss of target message frames.
[0051] In one embodiment of the present invention, a data packet represents a target message of a time period, that is, based on the timestamp of the first frame target message and the timestamp of the last frame target message in each data packet, the start time and the end time of each data packet combination can be obtained, and by comparing the time periods between each data packet, it can be determined whether there is a data packet loss when executing the second buffering; if the time periods between each data packet are continuous, then there is no data packet loss; if the time periods between each data packet are discontinuous, then there is a data packet loss.
[0052] Through the above method, the first-level buffer queue and the second-level buffer queue have a buffering effect in the process of message storage. When there are a large number of target messages on the CAN bus in a short period of time, the first-level buffer queue and the second-level buffer queue act as buffers to avoid the situation where some messages are missed due to insufficient transmission rate, thereby improving the integrity and reliability of message storage.
[0053] Step S340 , combining a preset number of data packets in the secondary buffer queue to generate a message file, and storing the message file in a memory in real time.
[0054] Specifically, if Figure 2 As shown, after the data packets taken out from the secondary buffer queue are sent to the MPU via the high-speed SPI, the MPU is used to process the preset number of data packets into message files, compress the message files, and store the message files in the memory in the form of compressed packages.
[0055] In one embodiment of the present invention, each message file is sorted in ascending chronological order according to the timestamp of the last data packet in the message file to determine the storage order of each message file; the remaining space of the memory is detected; if the remaining space size of the memory is higher than a preset space threshold, each message file is stored in the memory based on the storage order of each message file; if the remaining space size of the memory is lower than the preset space threshold, the message file stored first in the memory is overwritten with a message file with a high priority according to the storage order of each message file; wherein, before storing the message file in the memory, the message file is compressed so that the message file is stored in the memory in the form of a compressed package.
[0056] Specifically, in order to save memory space, the message file is compressed, compressed into a compressed package, and then stored in the memory. When the memory is full, the new compressed package will overwrite the compressed package stored first in the memory, realizing circular rolling storage in the memory.
[0057] In one embodiment of the present invention, after step S340, it also includes: establishing communication between the host computer and the domain controller; reading the message files in the memory by the host computer according to the storage order of each message file to obtain a preset number of data packets, and the memory is placed in the domain controller; unpacking the preset number of data packets to obtain multiple frames of target messages; comparing the timestamps of each frame of the target message to splice the multiple frames of target messages in time sequence to obtain a target message of a time period, and the time period is determined by the minimum timestamp and the maximum timestamp in the multiple frames of target messages.
[0058] Specifically, because the message file is stored in the memory in the form of a compressed package, the host computer needs to decompress the compressed message file after reading the message file, convert the message file into multiple data packets, and then unpack each data packet to obtain multiple frames of target messages, and splice these target messages to obtain continuous target messages within a time period. It should be understood that a communication channel can be established between the host computer and the domain controller in a wired or wireless manner, and the host computer directly reads the message file in the memory through the channel. There is no restriction on its communication method here. Alternatively, a connection between the cloud and the domain controller is first established, the message file in the memory is uploaded to the cloud, and the host computer then accesses the cloud to obtain the message file from the cloud.
[0059] See also Figure 5 , is a flowchart of real-time storage and reading of target messages shown in an exemplary embodiment of the present invention. Figure 5 As shown, when the domain controller receives a request from the vehicle application layer, including a message storage request and a message read request, the message storage request and the message read request are issued separately. If the domain controller receives a message storage request, it will perform the real-time message storage operation; if the domain controller receives a message read request, it will first perform the real-time message storage operation and then perform the real-time message read operation. Message storage or read requests can also be issued by other parts of the vehicle, and the present invention is not limited to this.
[0060] See also Figure 6 , is a flowchart of real-time storage of target messages shown in an exemplary embodiment of the present invention. Figure 6 As shown, Figure 5The operation of real-time storage of messages in the process includes: obtaining the initial messages of all CAN buses in the vehicle in real time, adding a data segment containing the current timestamp and message attribute information to the initial message, and obtaining the target message; after placing the target message into the first-level buffer queue, grouping the target messages taken out from the first-level buffer queue to obtain a data packet; after placing the data packet into the second-level buffer queue, processing the data packet taken out from the second-level buffer queue to obtain a message file and compressing it and storing it in the memory.
[0061] See also Figure 7 , is a flowchart of real-time reading of a target message shown in an exemplary embodiment of the present invention. Figure 7 As shown, Figure 5 The operation of real-time reading of messages in the domain controller includes: establishing a connection between the domain controller and the host computer, uploading the compressed package of the message file to the host computer, and after the host computer receives the compressed package of the message file, decompressing it to obtain the data packets in the message file, and then unpacking the data packets in the message file to obtain the target messages in multiple data packets, and finally splicing the target messages in multiple data packets to restore the order of the target messages.
[0062] Through the above method, the integrity and reliability of the stored target message are guaranteed, so that relevant technicians can read the stored target message in real time when a vehicle breaks down, so as to quickly locate the cause of the vehicle failure based on the read target message.
[0063] See also Figure 8 , is a block diagram of a CAN message storage device based on a domain controller according to an exemplary embodiment of the present invention. The device can be applied to Figure 1 The implementation environment shown is specifically configured in the domain controller 102. The apparatus may also be applicable to other exemplary implementation environments and specifically configured in other devices. This embodiment does not limit the implementation environment to which the apparatus is applicable.
[0064] like Figure 8 As shown, the exemplary domain controller-based CAN message storage device includes: an acquisition module 801 , a primary buffer module 802 , a secondary buffer module 803 and a storage module 804 .
[0065] An acquisition module 801 is configured to acquire a target message from a CAN bus in a vehicle based on a domain controller;
[0066] The first-level buffer module 802 is configured to perform a first buffer on the target message according to the time sequence of the target message, and cache the target message in the first-level buffer queue;
[0067] The secondary buffer module 803 is configured to group target messages of a preset number of frames in the primary buffer queue, determine data packets, perform secondary caching on each data packet, and cache the data packets in the secondary buffer queue;
[0068] The storage module 804 is configured to combine a preset number of data packets in the secondary buffer queue, generate a message file, and store the message file in the memory.
[0069] In one embodiment of the present invention, the functions of the acquisition module, the primary buffer module and the secondary buffer module in the CAN message storage device based on the domain controller can be as follows: Figure 2 The storage module can be implemented in the microcontroller unit in the domain controller shown in FIG. Figure 2 It is implemented by the microprocessor unit and embedded multimedia card.
[0070] It should be noted that the domain controller-based CAN message storage device provided in the above embodiment and the domain controller-based CAN message storage method provided in the above embodiment belong to the same concept, and the specific method of executing the operation in each step has been described in detail in the system embodiment and will not be repeated here.
[0071] An embodiment of the present invention also provides an electronic device, comprising: one or more processors; a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the electronic device implements the domain controller-based CAN message storage method provided in each of the above embodiments.
[0072] See also Figure 9 , shows a schematic diagram of the structure of a computer system suitable for implementing an electronic device according to an embodiment of the present invention. It should be noted that, Figure 9 The computer system 900 of the electronic device shown is only an example and should not limit the functions and scope of use of the embodiments of the present invention.
[0073] like Figure 9As shown, the computer system 900 includes a central processing unit (CPU) 901, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 902 or the program loaded from the storage part 908 into the random access memory (RAM) 903, such as executing the method in the above embodiment. Various programs and data required for system operation are also stored in the RAM 903. The CPU 901, ROM 902 and RAM 903 are connected to each other via a bus 904. An input / output (I / O) interface 905 is also connected to the bus 904.
[0074] The following components are connected to the I / O interface 905: an input section 906 including a keyboard, a mouse, and the like; an output section 907 including devices such as a cathode ray tube (CRT), a liquid crystal display (LCD), and a speaker; a storage section 908 including a hard disk and the like; and a communication section 909 including a network interface card such as a LAN (Local Area Network) card or a modem. The communication section 909 performs communication processing via a network such as the Internet. A drive 910 is also connected to the I / O interface 905 as needed. Removable media 911, such as a magnetic disk, an optical disk, a magneto-optical disk, or a semiconductor memory, is installed in the drive 910 as needed, so that computer programs read therefrom can be installed into the storage section 908 as needed.
[0075] In particular, according to an embodiment of the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present invention includes a computer program product that includes a computer program carried on a computer-readable medium, the computer program including a computer program for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network via the communication section 909 and / or installed from a removable medium 911. When the computer program is executed by the central processing unit (CPU) 901, the various functions defined in the system of the present invention are performed.
[0076] Embodiments of the present invention further provide a computer-readable storage medium having a computer program stored thereon. When executed by a computer processor, the computer program causes the computer to perform the aforementioned domain controller-based CAN message storage method. The computer-readable storage medium may be included in the electronic device described in the above embodiments, or may exist independently and not be incorporated into the electronic device.
[0077] It should be noted that the computer-readable medium shown in the embodiments of the present invention may be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. The computer-readable storage medium may, for example, be an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or component, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to, an electrical connection having one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a flash memory, an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present invention, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, which carries a computer-readable computer program. Such a propagated data signal may take a variety of forms, including, but not limited to, an electromagnetic signal, an optical signal, or any suitable combination thereof. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. A computer program embodied on a computer-readable medium may be transmitted using any suitable medium, including but not limited to wireless, wired, or any suitable combination thereof.
[0078] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architectures, functions and operations of the systems, methods and computer program products according to various embodiments of the present invention. Each box in the flowchart or block diagram can represent a module, program segment, or part of the code, and the above-mentioned module, program segment, or part of the code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the boxes can also occur in an order different from that marked in the accompanying drawings. For example, two boxes shown in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or can be implemented using a combination of dedicated hardware and computer instructions.
[0079] The above embodiments are merely illustrative of the principles and effects of the present invention and are not intended to limit the present invention. Anyone skilled in the art may modify or alter the above embodiments without departing from the spirit and scope of the present invention. Therefore, any equivalent modifications or alterations made by one of ordinary skill in the art without departing from the spirit and technical principles disclosed herein are intended to be covered by the claims of the present invention.
Claims
1. A CAN message storage method based on a domain controller, characterized in that: include; Acquire target messages from the CAN bus in the vehicle in real time based on the domain controller; Performing a first cache on the target message according to the time sequence of the target message, caching the target message in a first-level buffer queue; Packetizing target messages with a preset number of frames in the primary buffer queue, determining data packets, performing a second cache on each of the data packets, and caching the data packets in the secondary buffer queue; Combining a preset number of data packets in the secondary buffer queue to generate a message file, and storing the message file in a memory in real time; The acquiring of the target message from the CAN bus in the vehicle based on the domain controller includes: acquiring an initial message from the CAN bus in the vehicle; adding a timestamp and message attribute information to each frame of the initial message to obtain the target message, wherein the message attribute information includes a message count; After executing the first cache, it also includes: according to the message count in the message attribute information, cyclically counting the target messages of each preset frame number, counting from the first frame target message in the target message of the preset frame number until the last frame target message of the target message of the preset frame number ends; if the counting is discontinuous, or the counting of the first frame target message and the last frame target message is wrong, there is frame loss when executing the first buffer, and a prompt is generated that the target message is lost.
2. The CAN message storage method based on the domain controller according to claim 1, characterized in that: The performing a first cache on the target message according to the time sequence of the target message, and caching the target message in a first-level buffer queue, includes: According to the timestamps of the target messages, the target messages are sorted in ascending time order to determine the cache order of the target messages; Detecting the number of frames of the target message cached in the first-level buffer queue; If the number of frames of the target message cached in the first-level buffer queue is greater than or equal to the preset number of frames, pausing the first cache; If the number of frames of the target message cached in the first-level buffer queue is less than the preset number of frames, the target message is cached in the first-level buffer queue based on the cache order of each target message.
3. The CAN message storage method based on the domain controller according to claim 2, characterized in that: The performing second caching on each of the data packets to cache the data packets in a secondary buffer queue includes: According to the timestamp of the last target message in each data packet, the data packets are sorted in order of time from smallest to largest, and the cache order of the data packets is determined; Detecting whether there is free space in the secondary buffer queue; If there is free space in the secondary buffer queue, caching the data packets in the secondary buffer queue based on the caching order of the data packets; If there is no free space in the secondary buffer queue, the second buffering is suspended until there is free space in the secondary buffer queue.
4. The CAN message storage method based on the domain controller according to claim 3, characterized in that: The combining of the preset number of data packets in the secondary buffer queue to generate a message file, and storing the message file in a memory includes: According to the timestamp of the last data packet in the message file, the message files are sorted in ascending time order to determine the storage order of the message files; Detecting the remaining space of the memory; If the remaining space of the memory is greater than a preset space threshold, storing each of the message files in the memory based on the storage order of each of the message files; If the remaining space of the memory is lower than a preset space threshold, the message file stored first in the memory is overwritten by the message file with a higher priority according to the storage order of the message files; Before storing the message file in the memory, the message file is compressed so that the message file is stored in the memory in the form of a compressed package.
5. The CAN message storage method based on a domain controller according to claim 1, characterized in that: After combining the preset number of data packets in the secondary buffer queue to generate a message file, and storing the message file in a memory, the method further includes: Establishing communication between the host computer and the domain controller; Reading the message files in the memory by the host computer according to the storage order of each message file to obtain the preset number of data packets, the memory being placed in the domain controller; Unpacking the preset number of data packets to obtain multiple frames of the target message; The timestamps of the target messages in each frame are compared to splice the target messages in multiple frames in time sequence to obtain the target messages in a time period, where the time period is determined by the minimum timestamp and the maximum timestamp in the target messages in multiple frames.
6. The CAN message storage method based on a domain controller according to any one of claims 1 to 5, characterized in that: The message attribute information also includes a message identification number, a bus channel, a bus type, a message transmission direction and a message length.
7. The CAN message storage method based on a domain controller according to claim 6, characterized in that: The first caching of the target messages according to the time sequence of the target messages also includes: if it is detected that there are at least two target messages with the same time, arbitration is performed on the at least two target messages according to the priority pre-associated with the message attribute information to determine the time sequence of the at least two target messages.
8. A CAN message storage device based on a domain controller, characterized in that: include: An acquisition module, used for acquiring target messages from the CAN bus in the vehicle based on the domain controller; The acquiring of the target message from the CAN bus in the vehicle based on the domain controller includes: acquiring an initial message from the CAN bus in the vehicle; adding a timestamp and message attribute information to each frame of the initial message to obtain the target message, wherein the message attribute information includes a message count; A first buffering module is configured to perform a first buffering on the target message according to the time sequence of the target message, and cache the target message in a first-level buffer queue; after performing the first buffering, further perform a cyclic counting on each preset number of target messages according to the message count in the message attribute information, counting from the first frame of the target message in the preset number of target messages to the last frame of the target message in the preset number of target messages; if the counting is discontinuous or the counting of the first frame of the target message and the last frame of the target message is incorrect, frame loss occurs when performing the first buffering, and a prompt is generated indicating that the target message is lost; A second buffer module is used to group target messages of a preset number of frames in the first-level buffer queue, determine data packets, perform second caching on each of the data packets, and cache the data packets in the second-level buffer queue; The storage module is used to combine a preset number of the data packets in the secondary buffer queue to generate a message file, and store the message file in a memory.
9. An electronic device, characterized in that: include: one or more processors; A storage device for storing one or more programs, which, when executed by the one or more processors, enables the electronic device to implement the domain controller-based CAN message storage method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that A computer program is stored thereon, and the computer program is used to enable a computer to execute the CAN message storage method based on a domain controller as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Electric automobile CAN message acquisition system
CN218567887U
Frame identifying method for serial data
CN102510323A
Data processing method and device for ADC plug-in
CN106878196A
CAN-Ethernet communication conversion and data storage control method for train
CN107124344A
Data storage method, device and system
CN112925809A