A multi-level cache method and system based on CAN bus communication
By implementing a multi-level caching method on the CAN bus, dynamically adjusting the data transmission interval and optimizing the data packaging strategy, the problem of low transmission efficiency during the CAN bus upgrade process was solved, achieving efficient data transmission and improved vehicle response speed.
Patent Information
- Application Number
- CN202510286821.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-12
- Publication Date
- 2025-11-25
- Estimated Expiration
- 2045-03-12
AI Technical Summary
In existing technologies, when vehicles are upgraded via the CAN bus, the data transmission efficiency is low, resulting in wasted writing time and failing to effectively improve the utilization and transmission speed of the CAN bus.
A multi-level caching method based on CAN bus communication is adopted. By obtaining the impact coefficient under different load scenarios, the data transmission interval is dynamically adjusted and the data packaging strategy is optimized. Combined with ring buffer management, high-priority data is identified and transmitted first, bus resources are reasonably allocated, and the bandwidth occupation of low-priority data is reduced.
It improves data transmission efficiency, ensures timely transmission of high-priority data, reduces bandwidth usage of low-priority data, optimizes bus resource utilization, and enhances overall communication performance and vehicle response speed.
Smart Images

Figure CN119788456B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of data transmission, in particular to a multi-level cache method and system based on CAN bus communication. BACKGROUND
[0002] In today's high-speed development of new energy vehicle industry, the automation program of vehicles is getting higher and higher, and multiple modules inside the vehicle need continuous OTA iteration.
[0003] Currently, vehicles are mostly upgraded through CAN bus, and generally communicate with the vehicle CAN bus through Bluetooth or other low-speed buses. The low-speed bus is limited by the frequency of the bus itself in the process of forwarding data, and the data transmission efficiency is low. For example, the CAN bus, the data packet from the computer to the CAN bus will pass through the low-speed bus, which will cause a lot of waste of flashing time in transmission time. SUMMARY
[0004] The present application aims to solve the problem of how to improve the utilization rate and transmission speed of the vehicle to the CAN bus, and provides a multi-level cache method and system based on CAN bus communication.
[0005] The present application adopts the following technical means to solve the technical problems:
[0006] The present application provides a multi-level cache method based on CAN bus communication, comprising:
[0007] Based on the preset load scenario, the influence coefficient of the CAN bus on different baud rates is obtained, wherein the load scenario specifically includes idle state, low load state and high load state;
[0008] Determine whether the influence coefficient is limited by the hardware of the CAN bus;
[0009] If not, activate the preset cache mechanism of the CAN bus, apply a ring buffer to transmit communication data, dynamically adjust the sending interval of the communication data according to the pre-acquired CAN bus load condition, detect the peak transmission period of the CAN bus to the communication data, and optimize the preset data packaging strategy in a single data frame according to the peak transmission period, wherein the data frame specifically includes a frame header, a control field and a check field, and the data packaging strategy specifically includes merging small data, data alignment and reducing padding bytes;
[0010] Determine whether the data frame reaches the preset processing response speed;
[0011] If not, the sending frequency of the communication data is obtained, the ID priority of the CAN bus is reset based on the sending frequency, the category information of the communication data is collected according to the preset priority of the communication data, and the message sending duration of the communication data is dynamically adjusted according to the category information, wherein the ID priority specifically includes ECU control signals, sensor data and state logs.
[0012] Further, the CAN bus is activated in the step of activating the preset buffer mechanism of the CAN bus, and the step of applying a ring buffer to transmit the communication data further comprises:
[0013] Based on the maximum data flow of the communication data, the capacity parameter of the ring buffer is constructed;
[0014] It is judged whether the capacity parameter is suitable for the preset data storage mode;
[0015] If yes, the memory overhead of the ring buffer is dynamically allocated according to the data storage mode, the frame length of the communication data is obtained, the communication data is accessed by applying an index table data block according to the frame length, and the reading information of the ring buffer is recorded in real time, wherein the reading information specifically includes overflow or empty reading.
[0016] Further, before the step of detecting the peak transmission period of the communication data by the CAN bus, the step further comprises:
[0017] Based on the preset test target of the CAN bus, the bus utilization rate of the CAN bus is dynamically adjusted, the concurrent communication capability of a plurality of communication nodes is collected, and the bit error rate of the CAN bus is obtained;
[0018] It is judged whether the bit error rate exceeds a preset threshold;
[0019] If yes, a preset high-frequency interference signal is injected within a preset transmission distance of the CAN bus, the bit error change rate of the communication node is tested, and the bus arbitration priority of the CAN bus is dynamically adjusted according to the bit error change rate, wherein the bus arbitration priority specifically includes reasonable allocation of ID, reduction of sending frequency of high-priority data and use of time slice scheduling.
[0020] Further, in the step of collecting the category information of the communication data and dynamically adjusting the message sending duration of the communication data according to the category information, the step further comprises:
[0021] Based on the real-time category data collected by the vehicle, the bandwidth load of the CAN bus is collected according to the real-time category data, wherein the real-time category data specifically includes high real-time data, medium real-time data and low real-time data;
[0022] determining whether the bandwidth load reaches a preset bus load;
[0023] If yes, a preset multicast sending mode is applied, low-priority data is merged into the same frame, a time slice scheduling mechanism is introduced, a sending time of the real-time category data is allocated, a corresponding sending failure number is monitored, and a retransmission strategy of the real-time category data is constructed according to the sending failure number.
[0024] Further, the step of determining whether the influence coefficient is limited by the hardware of the CAN bus further comprises:
[0025] Based on the preset baud rate of the CAN bus, a communication parameter corresponding to the baud rate is collected, wherein the communication parameter specifically includes communication stability, data loss rate and error frame number;
[0026] determining whether the communication parameter matches a preset data throughput;
[0027] If no, a fixed-size data frame is sent, the maximum data flow per unit time is calculated according to the data frame, the bus load of the CAN bus is monitored according to the maximum data flow, and the bus utilization rate under different baud rates is calculated through the bus load.
[0028] Further, the step of determining whether the data frame reaches a preset processing response speed further comprises:
[0029] Based on a preset oscilloscope of the vehicle, a signal waveform of the CAN bus is detected;
[0030] determining whether the signal waveform contains a preset fault content, wherein the fault content specifically includes distortion, reflection and noise interference;
[0031] If yes, the driving capability of the CAN bus is evaluated according to a preset transceiver of the CAN bus, the terminal resistance of the CAN bus is identified, and the bus impedance of the CAN bus is dynamically adjusted according to the terminal resistance.
[0032] Further, the step of acquiring the influence coefficient of the CAN bus for different baud rates based on a preset load scenario further comprises:
[0033] Based on a preset data type of the vehicle, the number of frames successfully sent and received by the CAN bus is collected, wherein the data type specifically includes periodic data, burst data and burst-period combination data;
[0034] determining whether the frame number matches a preset average delay;
[0035] If not, the error frame on the CAN bus is acquired, and the cache depth of the CAN bus is dynamically adjusted according to the error frame, wherein the error frame specifically includes ACK loss, bit error and format error.
[0036] The application further provides a multi-level cache system based on CAN bus communication, comprising:
[0037] The acquisition module is configured to acquire an influence coefficient of the CAN bus for different baud rates based on a preset load scenario, wherein the load scenario specifically includes an idle state, a low load state and a high load state.
[0038] The judgment module is configured to judge whether the influence coefficient is limited by hardware of the CAN bus.
[0039] The execution module is configured to activate a preset cache mechanism of the CAN bus if not, apply a ring buffer to transmit communication data, dynamically adjust a sending interval of the communication data according to a pre-acquired load condition of the CAN bus, detect a peak transmission period of the CAN bus for the communication data, and optimize a preset data packaging strategy in a single data frame according to the peak transmission period, wherein the data frame specifically includes a frame header, a control field and a check field, and the data packaging strategy specifically includes merging small data, data alignment and reducing padding bytes.
[0040] The second judgment module is configured to judge whether the data frame reaches a preset processing response speed.
[0041] The second execution module is configured to acquire a sending frequency of the communication data if not, reset an ID priority of the CAN bus based on the sending frequency, acquire category information of the communication data according to a preset priority of the communication data, and dynamically adjust a message sending duration of the communication data according to the category information, wherein the ID priority specifically includes an ECU control signal, sensor data and a state log.
[0042] Further, the execution module further comprises:
[0043] The construction unit is configured to construct a capacity parameter of the ring buffer based on a maximum data flow of the communication data.
[0044] The judgment unit is configured to judge whether the capacity parameter is adapted to a preset data storage mode.
[0045] The execution unit is used for if yes, then according to the data storage mode, dynamically allocating the memory overhead of the ring buffer, obtaining the frame length of the communication data, applying an index table data block to the communication data according to the frame length, and recording reading information of the ring buffer in real time, wherein the reading information specifically includes overflow or empty reading.
[0046] Further, it further comprises:
[0047] The acquisition module is used for dynamically adjusting the bus utilization rate of the CAN bus, acquiring the concurrent communication capability of the plurality of communication nodes, and obtaining the error code rate of the CAN bus based on the test target of the CAN bus.
[0048] The third judgment module is used for judging whether the error code rate exceeds a preset threshold.
[0049] The third execution module is used for if yes, then injecting a preset high-frequency interference signal within a preset transmission distance of the CAN bus, testing the error code change rate of the communication node, and dynamically adjusting the bus arbitration priority of the CAN bus according to the error code change rate, wherein the bus arbitration priority specifically includes reasonably allocating an ID, reducing the sending frequency of high-priority data, and using time slice scheduling.
[0050] The application provides a multi-level cache method and system based on CAN bus communication, and has the following beneficial effects:
[0051] The application obtains the influence coefficient of the CAN bus through a preset load scenario (idle, low load, and high load), judges whether it is limited by hardware, and ensures the accuracy of the optimization direction. The ring buffer is used for data cache management, the data sending interval is dynamically adjusted, and the data packaging strategy (merging small data, data alignment, and reducing padding bytes) is optimized, so that the data transmission efficiency is improved. The CAN ID priority is dynamically adjusted by collecting the communication data category information, so that the high-priority data (such as ECU control signals) is transmitted in time, the bandwidth occupation of low-priority data is reduced, and the processing response speed of the data frame is monitored. If it does not meet the standard, the data sending frequency is optimized, and the real-time performance is improved. BRIEF DESCRIPTION OF DRAWINGS
[0052] Figure 1 It is a flowchart of one embodiment of the multi-level cache method based on CAN bus communication of the application;
[0053] Figure 2 It is a structural block diagram of one embodiment of the multi-level cache system based on CAN bus communication of the application. DETAILED DESCRIPTION
[0054] It should be understood that the specific embodiments described herein are merely illustrative of the present application and do not limit the present application, and the purpose, features and advantages of the present application will be further illustrated with reference to the embodiments and the accompanying drawings.
[0055] The technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the accompanying drawings of the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, but not all the embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without creative work fall within the scope of protection of the present application.
[0056] Reference is made to the accompanying drawings Figure 1 For the multi-level cache method based on CAN bus communication in an embodiment of the present application, comprising:
[0057] S1: based on a preset load scenario, obtaining an influence coefficient of the CAN bus for different baud rates, wherein the load scenario specifically includes an idle state, a low load state and a high load state;
[0058] S2: judging whether the influence coefficient is limited by the hardware of the CAN bus;
[0059] S3: if not, activating a preset cache mechanism of the CAN bus, applying a ring buffer to transmit communication data, dynamically adjusting the sending interval of the communication data according to the pre-acquired CAN bus load condition, detecting the peak transmission period of the CAN bus for the communication data, and optimizing a preset data packaging strategy in a single data frame according to the peak transmission period, wherein the data frame specifically includes a frame header, a control field and a check field, and the data packaging strategy specifically includes merging small data, data alignment and reducing padding bytes;
[0060] S4: judging whether the data frame reaches a preset processing response speed;
[0061] S5: if not, obtaining the sending frequency of the communication data, resetting the ID priority of the CAN bus based on the sending frequency, acquiring the category information of the communication data according to the preset priority of the communication data, and dynamically adjusting the message sending length of the communication data according to the category information, wherein the ID priority specifically includes an ECU control signal, sensor data and a state log.
[0062] In the embodiment, the system obtains the influence coefficients of the CAN bus for different baud rates based on the load scenarios preset by the vehicle, the load scenarios specifically including an idle state, a low load state and a high load state, and then the system judges whether the influence coefficients are limited by the hardware of the CAN bus to perform corresponding steps; for example, when the system determines that the influence coefficients of the CAN bus for different baud rates are limited by the hardware of the CAN bus, the system considers that the bottleneck is not caused by data scheduling or cache management, but by the performance limitation of the physical layer or the controller itself, reduces the length of the wire harness to avoid too long branches to reduce signal attenuation and interference, checks the processing capacity of the CAN controller of the MCU, replaces the MCU with a high-performance one or externally connects a more efficient CAN controller if the processing capacity of the CAN controller is low and may cause data transmission delay, and ensures that all ECU nodes support CAN-FD and performs compatibility test to prevent communication failure between new and old devices; for example, when the system determines that the influence coefficients of the CAN bus for different baud rates are not limited by the hardware of the CAN bus, the system considers that the bottleneck is caused by data scheduling or cache management, activates the cache mechanism preset by the CAN bus, applies a ring buffer to transmit communication data, dynamically adjusts the transmission interval of communication data according to the previously collected load conditions of the CAN bus, detects the peak transmission period of the CAN bus for communication data, optimizes the data packaging strategy preset in a single data frame according to different peak transmission periods, the data frame specifically includes a frame header, a control field and a check field, and the data packaging strategy specifically includes merging small data, data alignment and reducing padding bytes; the system manages data through the ring buffer to ensure the orderly transmission of data flow, avoid data loss or bus blocking caused by instantaneous data overload, improve data throughput, dynamically adjust the data transmission interval according to the real-time load condition of the CAN bus to ensure balanced use of bus resources, reduce transmission conflicts, improve channel utilization, make data transmission smoother, detect the peak transmission period and optimize the data transmission strategy to ensure that high-priority data can be processed in time, reduce the influence of low-priority data on the overall performance of the system, combine the data packaging optimization strategy (merging small data, data alignment and reducing padding bytes) to reduce redundant data, improve the effective load ratio of a single frame, reduce the bus occupancy rate, thereby speeding up the transmission, and optimize the data frame structure (frame header, control field and check field) to ensure data integrity and reliability, reduce unnecessary overhead, improve data processing efficiency, adjust the data transmission interval according to the load condition of the bus to avoid too high delay caused by burst data transmission, make the system response more stable and improve the overall communication performance; then the system judges whether the data frames reach the preset processing response speed to perform corresponding steps.For example, when the system determines that the data frame can reach the pre-set processing response speed, the system considers that the current data transmission strategy and cache management has been optimized, the communication efficiency of the CAN bus has met the system requirements, and there is no need for further adjustment. The system maintains the current optimization strategy and continues to operate according to the existing ring buffer management, dynamic data scheduling and data packaging optimization scheme to ensure that the system can still maintain efficient communication under different load conditions. At the same time, the system continues to monitor the system load, continues to collect the load state and communication delay of the CAN bus, establishes a long-term data analysis model to ensure that the strategy can be quickly adjusted when the load fluctuates, and appropriately reduces the power consumption. On the premise of ensuring communication efficiency, reduce data redundancy and unnecessary transmission frequency, improve energy efficiency ratio, and optimize the overall operation efficiency of the CAN bus; for example, when the system determines that the data frame cannot reach the pre-set processing response speed, the system considers that the current data transmission strategy and cache management has not been optimized. The system obtains the transmission frequency of the communication data, resets the ID priority of the CAN bus based on different transmission frequencies, the ID priority specifically includes ECU control signals, sensor data and state logs, acquires the category information of the communication data according to the pre-set priority of the communication data, and dynamically adjusts the message transmission length of the communication data according to different category information. The system accurately identifies the root cause of the decrease in data frame response speed by obtaining the transmission frequency of the communication data, avoids blind optimization, improves the accuracy of problem positioning, resets the ID priority of the CAN bus according to different transmission frequencies, ensures that high-priority data (such as ECU control signals) can be transmitted in time, and all data are not treated equally, reducing the interference of low-priority data on data with high real-time requirements. At the same time, through the redistribution of ID priority, it is ensured that ECU control signals (such as brake, steering and other key signals) are always transmitted in priority, avoiding the delay of control signals due to bus congestion, improving vehicle safety and response speed, and sensor data and state logs and other low-priority data can be appropriately delayed when the bus load is high. Ensure the stability and reliability of the core control signal, and according to the category information of the communication data (such as real-time control data, environmental monitoring data, historical logs, etc.), the system can dynamically adjust the transmission length of the data, reduce the occupation of the bus by irrelevant data, optimize the transmission strategy, for example, for high real-time data (such as brake control), the system can shorten the transmission length to improve the refresh rate; for low-time-efficiency data (such as vehicle state logs), the transmission period can be appropriately extended to reduce the bus load.
[0063] In the embodiment, the CAN bus pre-set cache mechanism is activated, and in the step S3 of applying the ring buffer to transmit the communication data, the step further includes:
[0064] S31: based on the maximum data flow of the communication data, constructing the capacity parameter of the ring buffer;
[0065] S32: determining whether the capacity parameter is adapted to a preset data storage mode;
[0066] S33: if yes, dynamically allocating memory overhead of the ring buffer according to the data storage mode, obtaining a frame length of the communication data, applying an index table data block to data access of the communication data according to the frame length, and recording read information of the ring buffer in real time, wherein the read information specifically includes overflow or empty reading.
[0067] In this embodiment, the system constructs the capacity parameters of the ring buffer based on the maximum data flow of the communication data, and then determines whether the capacity parameters adapt to the pre-set data storage mode to perform corresponding steps; for example, when the system determines that the capacity parameters of the ring buffer do not adapt to the pre-set data storage mode, the system considers that if the capacity is too small, the data write rate may be higher than the read rate, the buffer overflows, and thus data loss or system processing delay occurs, and if the capacity is too large, the data flow is relatively small, which causes storage resource waste and reduces the efficiency of cache management. The system dynamically adjusts the capacity of the ring buffer according to the data flow to avoid the adaptability problem caused by fixed capacity setting, uses an adaptive capacity adjustment algorithm, expands or reduces the buffer size in real time according to the historical data flow trend, ensures that overflow does not occur due to sudden data growth, and also ensures that resource waste does not occur due to excessive redundant space. At the same time, high-frequency data buffers and low-frequency data buffers are set, high real-time data (such as ECU control signals) is stored in the high-speed buffer, and a high-priority read strategy is set. Low-priority data (such as state logs) is stored in the secondary buffer, which allows batch transmission under low load to reduce bus occupancy. If it is found that buffer overflow is caused by frequent sending of some data, the data sending rhythm can be optimized, the data packet size can be adjusted or repeated data can be merged to reduce transmission pressure. A flow control mechanism is used to temporarily delay the storage of low-priority data when the data flow is too large, to ensure the integrity and timeliness of critical data. For example, when the system determines that the capacity parameters of the ring buffer adapt to the pre-set data storage mode, the system considers that the organization mode of the buffer (such as FIFO, LIFO, etc.) matches the actual data flow mode of the CAN bus, and does not affect the data access efficiency. The system dynamically adjusts the memory overhead of the ring buffer according to different data storage modes, obtains the frame length of the communication data, applies the index table data block to access the communication data according to the frame length, and records the read information of the ring buffer in real time. The read information specifically includes overflow or empty read. The system dynamically adjusts the memory overhead of the ring buffer to avoid allocating too much or too little memory, improves the memory utilization rate, allocates appropriate cache size according to different data storage modes (such as fixed-size data block or variable-length data block), reduces resource waste caused by excessive reservation, or performance degradation caused by insufficient space, and at the same time, by obtaining the frame length of the communication data, the system can more accurately allocate cache space to prevent storage fragmentation problems caused by mismatched frame sizes. The index table data block management mechanism ensures that data can be accessed along the optimal path to improve query and write speed, reduce CPU occupancy rate, and adapt the buffer to different data communication modes to ensure that delay or packet loss does not occur due to unreasonable cache mechanism under high data flow scenarios. Under low load conditions, the system can reduce unnecessary data access operations to reduce power consumption and improve overall communication efficiency.
[0068] In the embodiment, before the step S3 of detecting the peak transmission period of the communication data of the CAN bus, further comprising:
[0069] S301: based on the test target preset by the CAN bus, dynamically adjusting the bus utilization rate of the CAN bus, collecting the concurrent communication capability of the plurality of communication nodes, and obtaining the bit error rate of the CAN bus;
[0070] S302: judging whether the bit error rate exceeds a preset threshold;
[0071] S303: if yes, injecting a preset high-frequency interference signal within a preset transmission distance of the CAN bus, testing the bit error change rate of the communication node, and dynamically adjusting the bus arbitration priority of the CAN bus according to the bit error change rate, wherein the bus arbitration priority specifically includes reasonably allocating ID, reducing the sending frequency and usage time of high-priority data, and using time slice scheduling.
[0072] In the embodiment, the system dynamically adjusts the bus utilization of the CAN bus based on the test target preset by the CAN bus, collects the concurrent communication capability of multiple communication nodes to obtain the error code rate of the CAN bus, and then judges whether the error code rate exceeds the preset threshold to perform corresponding steps; for example, when the system determines that the error code rate of the CAN bus does not exceed the preset threshold, the system considers that the current bus communication quality is within an acceptable range, the stability and reliability of data transmission are high, and no serious signal interference or data loss occurs, the system dynamically adjusts the sending timing of the data frame, reduces the bus idle time, improves the data transmission efficiency, optimizes the data flow scheduling, appropriately increases the sending frequency of low-priority messages, ensures that the CAN bus bandwidth is fully utilized without affecting the transmission of high-priority data, and dynamically adjusts the data sending priority when the load increases to prevent data congestion caused by high load, dynamically allocates the time slot resources of the CAN bus to ensure that the communication of each node is not affected under different loads, improves the overall throughput of the system, and improves the bandwidth utilization and communication efficiency of the CAN bus under the premise of ensuring low error code rate, reduces the data transmission delay, improves the system response speed, reduces the bus idle time, improves the concurrent communication capability, and ensures that multiple nodes can stably and efficiently exchange data; for example, when the system determines that the error code rate of the CAN bus exceeds the preset threshold, the system considers that the current bus communication quality is abnormal, the system injects a pre-set high-frequency interference signal within the pre-set transmission distance of the CAN bus to test the error code change rate of the communication node, dynamically adjusts the bus arbitration priority of the CAN bus according to different error code change rates, and the bus arbitration priority specifically includes reasonable allocation of ID, reduction of the sending frequency of high-priority data, and use of time slice scheduling; by adjusting the ID priority, the system can preferentially ensure the transmission of important messages (such as safety data, real-time control signals, etc.), reduce data loss caused by error codes, help ensure that high-priority messages are not disturbed by low-priority data, and improve the reliability of critical data transmission, and according to different error code change rates, the system can adjust the working strategy of the bus in real time, if the system detects that the error code rate of a part of the area or a specific node abnormally increases, the interference influence can be alleviated by adjusting the communication strategy of the area or the node, and by simulating a high-frequency interference signal and adjusting the transmission strategy according to the error code rate, the system can better adapt to harsh environments and improve the communication stability and reliability in high-interference conditions.
[0073] In the embodiment, the step S5 of collecting the category information of the communication data and dynamically adjusting the message sending duration of the communication data further includes:
[0074] S51: collecting bandwidth load of the CAN bus based on real-time category data pre-collected by the vehicle, wherein the real-time category data specifically includes high real-time data, medium real-time data and low real-time data;
[0075] S52: judging whether the bandwidth load reaches a preset bus load;
[0076] S53: if yes, applying a preset multicast sending mode, merging low-priority data into the same frame, introducing a time slice scheduling mechanism, allocating sending time of the real-time category data, monitoring corresponding sending failure number, and constructing a retransmission strategy of the real-time category data according to the sending failure number.
[0077] In the embodiment, the system determines whether the bandwidth load reaches the pre-set bus load based on the real-time category data collected by the vehicle in advance, and the real-time category data specifically includes high real-time data, medium real-time data and low real-time data, and then the system executes corresponding steps; for example, when the system determines that the bandwidth load of the real-time category data on the CAN bus does not reach the pre-set bus load, the system considers that the use efficiency of the CAN bus has not reached the maximum, and there may be a situation that the bandwidth resources are not fully utilized, and the system can increase the sending frequency of the low real-time data, fully utilize the bandwidth resources without affecting the transmission of high real-time data, adjust the sending interval of medium real-time data, and appropriately increase the sending frequency to better utilize the idle bandwidth, and if the bandwidth resources are sufficient, the priority of low real-time data can be appropriately improved to avoid the situation that low-priority data is waiting for transmission for a long time, if the load of the real-time category data is light, the size of the data frame can be appropriately increased, multiple small data packets can be combined, the packing efficiency of data can be improved, the bus occupation time can be reduced, and the transmission capacity of the bus can be improved by reasonably adjusting the timing and frequency of sending data, so that the bus can efficiently carry more data streams and improve its transmission capacity and reduce invalid idle time, if the bandwidth is not fully occupied, the storage and reading of data can be optimized by using a ring buffer or other caching strategies to reduce the delay during data transmission; for example, when the system determines that the bandwidth load of the real-time category data on the CAN bus reaches the pre-set bus load, the system considers that the use efficiency of the CAN bus reaches the maximum, and the system applies the pre-set multicast sending mode, combines low-priority data into the same frame, introduces a time scheduling mechanism to allocate the sending time of the real-time category data, monitors the corresponding number of sending failures, and constructs a retransmission strategy for the real-time category data according to different numbers of sending failures; the system combines low-priority data into the same frame to avoid the repeated overhead of sending multiple low-priority data, which can effectively reduce the number of data frames and improve the data transmission efficiency of the bus.Through the multicast mode, the bandwidth can be more efficiently utilized, the communication delay and transmission time slot waste can be reduced, the bandwidth occupation can be reduced, by merging low-priority data, not only the bandwidth is saved, but also the transmission speed of data is improved, so that the high-priority data can be transmitted faster, and meanwhile, through the introduction of the time scheduling mechanism, the sending time of each real-time category data can be accurately controlled, the data transmission according to the priority and the preset time window is ensured, so as to avoid the conflict and congestion of data transmission, the system can reasonably allocate the bandwidth, optimize the time allocation of the overall data flow, further improve the use efficiency of the bus, the reasonable scheduling opportunity avoids that the low-priority data occupies too much bandwidth, causes the delay of the high-priority data, ensures that the real-time requirement of the system is met, and through monitoring the number of sending failures, the system can timely find the problems in transmission and make adjustment, for example, if a certain data frame fails to be sent for many times, the system can preferentially resend the data, ensures the transmission integrity and reliability of the data, according to the number of sending failures, the system can dynamically adjust the retransmission strategy, ensures that the data can be reliably transmitted under network pressure, the retransmission strategy can determine whether to adjust the sending frequency, the priority or the scheduling opportunity according to the high or low of the number of failures, further optimizes the communication quality.
[0078] It should be noted that the multicast sending mode is applied, the low-priority data is merged into the same frame, the time slice scheduling mechanism is introduced, the sending time of the real-time category data is allocated, the number of sending failures corresponding to the real-time category data is monitored, the retransmission strategy of the real-time category data is constructed according to the number of sending failures, and a specific example is as follows.
[0079] Suppose that there is a vehicle-mounted system, in which multiple sensors (such as a vehicle speed sensor, a temperature sensor, and an oil quantity sensor) generate real-time data, and the data is transmitted to the ECU of the vehicle through the CAN bus for processing; different types of data (such as sensor data and state logs) have different real-time requirements: the vehicle speed data has a high real-time requirement, the temperature data has a medium real-time requirement, and the oil quantity data is low real-time data.
[0080] Application scenario, classification of real-time category data:
[0081] High real-time data: vehicle speed sensor data, which must be transmitted as soon as possible;
[0082] Medium real-time data: temperature sensor data, which has a slightly lower real-time requirement;
[0083] Low real-time data: oil quantity sensor data, which can be delayed in transmission and does not greatly affect the system performance;
[0084] Pre-set multicast sending mode, when sending data, low-priority data (such as oil quantity data) will be combined into a data frame, which can reduce the number of data frames and reduce transmission overhead; for example, temperature sensor data (medium real-time) and oil quantity sensor data (low real-time) can be combined into the same frame to reduce the sending frequency and reduce the demand for bandwidth;
[0085] Time slice scheduling mechanism, under the time slice scheduling mechanism, the system will allocate specific sending time for different categories of data; for high real-time data (vehicle speed data), the sending time will be allocated preferentially; medium real-time data (temperature data) will be sent after high-priority data; low real-time data (oil quantity data) will be arranged to be sent during system idle period;
[0086] For example:
[0087] Vehicle speed data: sent once every 100 ms, with the highest priority;
[0088] Temperature data: sent once every 500 ms, with the second priority;
[0089] Oil quantity data: sent once every 1000 ms, with the lowest priority;
[0090] Monitoring the number of sending failures, if a certain data frame fails to be successfully sent at the predetermined time, the system will record the number of sending failures; assuming that the oil quantity data fails to be sent for 2 times, the system will detect this failure;
[0091] According to the number of sending failures, a retransmission strategy is constructed, when the number of sending failures exceeds a predetermined threshold (for example, 3 times), the system considers that there is a network problem or bus congestion, which causes the data to be unable to be normally transmitted; at this time, the system will adopt a retransmission strategy, for example:
[0092] Priority retransmission of failed data: for example, retransmission of oil quantity data will be performed during the transmission gap of high real-time data;
[0093] Adjusting the sending frequency: if some data frequently fails, the sending frequency can be reduced to reduce the bus burden;
[0094] Delay retransmission: retransmission of failed low-priority data (such as oil quantity data) can be performed in off-peak period or idle period to avoid occupying too much bandwidth;
[0095] In summary, by the above, the system combines low priority data into a data frame (multicast transmission), reduces the number of data frames, and thereby improves the efficiency of the use of bus bandwidth. Meanwhile, through the time slice scheduling mechanism, the system can reasonably allocate the transmission time of each type of data, avoiding the delayed transmission of high priority data. Furthermore, by monitoring transmission failures and adjusting the transmission strategy based on the number of failures, the system can adjust in time when communication is abnormal, to ensure efficient and reliable data transmission. This approach not only reduces bandwidth occupation, but also ensures timely transmission of high priority data in the case of limited bandwidth. Through dynamic adjustment of the retransmission strategy, the system improves communication stability and reliability.
[0096] In the embodiment, the step S2 of judging whether the influence coefficient is limited by the hardware of the CAN bus further comprises:
[0097] S21: Collect communication parameters corresponding to the baud rate based on the pre-set baud rate of the CAN bus, wherein the communication parameters specifically include communication stability, data loss rate, and number of error frames;
[0098] S22: Judge whether the communication parameters match the pre-set data throughput;
[0099] S23: If not, transmit a data frame of fixed size, calculate the maximum data flow per unit time based on the data frame, monitor the bus load of the CAN bus according to the maximum data flow, and calculate the bus utilization rate under different baud rates based on the bus load.
[0100] In the embodiment, the system collects the communication parameters corresponding to the baud rates preset based on the CAN bus, the communication parameters specifically including communication stability, data loss rate and number of error frames, and then the system judges whether the communication parameters match the preset data throughput to perform corresponding steps; for example, when the system determines that the communication parameters corresponding to the baud rate can match the preset data throughput, the system considers that the CAN bus communication performance under the baud rate is good and can meet the data transmission demand, the system judges whether the baud rate can guarantee the stability of communication through the collected communication parameters (such as the number of error frames, the data loss rate, etc.), if the parameters meet the expected target, the system confirms that the baud rate can maintain the communication quality, at the same time, when the data throughput matches the baud rate, the system considers that the transmission stability, throughput and error rate under the current baud rate are in the best state, there is no need to adjust the baud rate, and when the communication parameters reach the expectation, the system can allocate resources to other modules, such as optimizing buffer management, adjusting data packaging strategy, etc., to ensure that other operations on the bus are not affected, and further improve the overall performance, although the baud rate has met the throughput demand, the system should continue to monitor the communication parameters, such as the number of error frames, the amount of lost data, etc., to ensure that there is no performance bottleneck or communication problem on the bus in actual work; for example, when the system determines that the communication parameters corresponding to the baud rate cannot match the preset data throughput, the system considers that the CAN bus communication performance under the baud rate is poor and cannot meet the data transmission demand, the system sends data frames of a fixed size, calculates the maximum data flow per unit time according to different data frames, monitors the bus load of the CAN bus according to different maximum data flow, and calculates the bus utilization rate under different baud rates through the bus load; the system can identify the bottleneck of the communication performance by analyzing the situation that the baud rate cannot meet the data throughput, and clearly the deficiencies under the baud rate, so as to accurately locate the performance problem and avoid wasting resources, at the same time, by sending data frames of a fixed size, the system can accurately calculate the maximum data flow per unit time, which helps the system to optimize in subsequent data transmission, ensures to improve the data transmission efficiency as much as possible under the current baud rate, so as to realize better bandwidth utilization, and by monitoring the bus load of the CAN bus in real time, the system can understand the actual use of the bus under different baud rates, further evaluate whether the current baud rate is too inefficient or causes bus congestion, real-time load monitoring can help the system to judge whether to switch to a higher baud rate, and by monitoring the bus load under different baud rates, the system can accurately calculate the utilization rate of the bus to help judge whether the transmission capacity of the current bus is fully utilized, if the bus utilization rate is too low, it may mean that the baud rate is not properly selected, and the system can adjust the transmission strategy or the baud rate according to this index.
[0101] In the embodiment, the step S4 of judging whether the data frame reaches the preset processing response speed further comprises:
[0102] S41: detecting a signal waveform of the CAN bus based on a vehicle preset oscilloscope;
[0103] S42: judging whether the signal waveform has preset fault content, wherein the fault content specifically includes distortion, reflection and noise interference;
[0104] S43: if yes, evaluating driving capability of the CAN bus according to a preset transceiver of the CAN bus, identifying a terminal resistance of the CAN bus, and dynamically adjusting bus impedance of the CAN bus according to the terminal resistance.
[0105] In this embodiment, the system detects the signal waveform of the CAN bus based on the oscilloscope preset by the vehicle, and then determines whether the signal waveform contains the preset fault content, which specifically includes distortion, reflection and noise interference, to perform corresponding steps; for example, when the system determines that the signal waveform of the CAN bus does not contain the preset fault content, the system considers that the signal transmission of the CAN bus is normal, without distortion, reflection or noise interference, etc. The system regularly monitors the signal waveform to ensure that the signal quality remains stable during long-term use, which helps to discover potential problems in time and prevent future communication failures. At the same time, based on the current good signal quality, the efficiency of data transmission is further optimized, such as optimizing the baud rate, data frame structure or data scheduling strategy, to improve the communication efficiency and response speed. In addition, by determining that the signal waveform is normal, the system can confirm that the bus state is healthy, which can maintain efficient and stable communication with other communication nodes and reduce failure or maintenance time; for example, when the system determines that the signal waveform of the CAN bus contains the preset fault content, the system considers that the signal transmission of the CAN bus is abnormal. The system evaluates the driving capability of the CAN bus and identifies the terminal resistance of the CAN bus according to the pre-set transceiver of the CAN bus, and dynamically adjusts the bus impedance of the CAN bus according to these terminal resistances. By evaluating and adjusting the driving capability and bus impedance of the CAN bus, the system can effectively repair problems such as signal distortion, reflection or noise interference, which helps to improve the integrity and transmission quality of the signal and ensure accurate data transmission. At the same time, dynamically adjusting the bus impedance and terminal resistance helps to maintain stable electrical matching between different nodes of the bus, preventing signal reflection and voltage fluctuation, which can enhance communication stability, reduce communication errors, and adjust the terminal resistance and driving capability to reduce signal distortion and reflection, avoid bit errors caused by mismatched impedance, reduce the generation of data loss or error frames during communication, and thus improve the reliability of the entire system. By dynamically adjusting the electrical parameters of the system, hardware damage or performance degradation caused by signal abnormalities can be prevented, and the service life of the CAN bus system and related equipment can be prolonged.
[0106] In this embodiment, in step S1 of obtaining the influence coefficient of the CAN bus for different baud rates based on the preset load scenario, the following steps are further included:
[0107] S11: Based on the data type preset by the vehicle, the number of successfully transmitted and received frames of the CAN bus is collected, wherein the data type specifically includes periodic data, burst data and burst-period combination data;
[0108] S12: Determine whether the number of frames matches the preset average time delay;
[0109] S13: If no, acquiring an error frame on the CAN bus, dynamically adjusting a cache depth of the CAN bus according to the error frame, wherein the error frame specifically includes an ACK loss, a bit error, and a format error.
[0110] In this embodiment, the system collects the number of frames sent and received successfully by the CAN bus based on the data types preset by the vehicle, which specifically include periodic data, burst data, and burst-period combination data, and then determines whether the number of frames matches the average latency preset by the system to perform corresponding steps; for example, when the system determines that the number of frames sent and received successfully by the CAN bus can match the average latency preset, the system considers that the communication efficiency and latency of the CAN bus are normal, and the CAN bus can transmit data as expected. The system further optimizes the scheduling and bandwidth allocation of communication data; for example, other tasks or data types can be scheduled without increasing additional load, maintaining efficient communication operations, while the current CAN bus configuration and data scheduling strategy can be maintained due to the expected effect of the current system settings, which reduces unnecessary adjustments and resource waste, ensures stable system operation, and when the number of frames matches the latency, the system can predict that the CAN bus can continue to provide the required performance under similar future loads, which helps to expand more devices or nodes without affecting communication efficiency, and if the system can successfully match the expected latency and frame number, it indicates that the working state of the CAN bus is healthy, reducing the cost of troubleshooting and repair and simplifying maintenance work; for example, when the system determines that the number of frames sent and received successfully by the CAN bus cannot match the average latency preset, the system considers that the communication efficiency and latency of the CAN bus are abnormal, and the system obtains the error frames on the CAN bus, dynamically adjusts the cache depth of the CAN bus according to different error frames, which specifically include ACK loss, bit error, and format error. By identifying and analyzing the types of error frames, the system can timely discover potential problems in communication. Dynamically adjusting the cache depth can help alleviate the impact of errors and improve the stability of communication, especially when encountering format errors, ACK loss, or bit errors, adjusting the cache depth can ensure better data storage and retransmission, avoiding information loss, while appropriately adjusting the cache depth when detecting latency abnormalities can better manage data flow on the CAN bus, reducing data conflicts and buffer overflow, thereby improving the utilization of the bus. By dynamically adjusting the cache depth, the system can flexibly allocate resources according to the current load and data transmission requirements to ensure effective bandwidth utilization, and when error frames occur during communication, they usually cause data loss or transmission failure. Dynamically adjusting the cache depth can provide sufficient buffer space when errors occur to facilitate data retransmission after the system recovers, which can significantly reduce the data loss rate caused by latency abnormalities, and timely adjusting the cache depth helps to alleviate the load pressure caused by a large number of error frames and latency problems. When the system encounters communication problems, increasing the cache capacity can provide more space for the system to handle burst error frames, avoiding frequent retransmission requests and bus congestion.
[0111] Reference is made to the drawingsFigure 2 For the multi-level cache system based on CAN bus communication in an embodiment of the present application, comprising:
[0112] The acquisition module 10 is configured to acquire an influence coefficient of the CAN bus for different baud rates based on a preset load scenario, wherein the load scenario specifically includes an idle state, a low load state and a high load state.
[0113] The judgment module 20 is configured to judge whether the influence coefficient is limited by the hardware of the CAN bus.
[0114] The execution module 30 is configured to activate a preset cache mechanism of the CAN bus if not, apply a ring buffer to transmit communication data, dynamically adjust a sending interval of the communication data according to a pre-acquired load condition of the CAN bus, detect a peak transmission period of the CAN bus for the communication data, and optimize a preset data packaging strategy in a single data frame according to the peak transmission period, wherein the data frame specifically includes a frame header, a control field and a check field, and the data packaging strategy specifically includes merging small data, data alignment and reducing padding bytes.
[0115] The second judgment module 40 is configured to judge whether the data frame reaches a preset processing response speed.
[0116] The second execution module 50 is configured to acquire a sending frequency of the communication data if not, reset an ID priority of the CAN bus based on the sending frequency, acquire category information of the communication data according to a preset priority of the communication data, and dynamically adjust a message sending duration of the communication data according to the category information, wherein the ID priority specifically includes an ECU control signal, sensor data and a state log.
[0117] In the embodiment, the acquisition module 10 acquires the influence coefficients of the CAN bus for different baud rates based on the load scenarios preset by the vehicle, and the load scenarios specifically include an idle state, a low load state and a high load state, and then the judgment module 20 judges whether the influence coefficients are limited by the hardware of the CAN bus to perform corresponding steps; for example, when the system determines that the influence coefficients of the CAN bus for different baud rates are limited by the hardware of the CAN bus, the system considers that the bottleneck is not caused by data scheduling or cache management, but by the performance limitation of the physical layer or the controller itself, the system reduces the length of the wire harness to avoid too long branches to reduce signal attenuation and interference, and checks the processing capacity of the CAN controller of the MCU at the same time, if the processing capacity of the CAN controller is low, which may cause data transmission delay, a high-performance MCU or a higher-efficiency CAN controller can be replaced, and all ECU nodes need to support CAN-FD and compatibility test to prevent communication failure between new and old devices; for example, when the system determines that the influence coefficients of the CAN bus for different baud rates are not limited by the hardware of the CAN bus, the execution module 30 considers that the bottleneck is caused by data scheduling or cache management, the system activates the cache mechanism preset by the CAN bus, applies a ring buffer to transmit communication data, dynamically adjusts the transmission interval of communication data according to the previously collected load conditions of the CAN bus, detects the peak transmission period of the CAN bus for communication data, optimizes the data packaging strategy preset in a single data frame according to different peak transmission periods, the data frame specifically includes a frame header, a control field and a check field, and the data packaging strategy specifically includes merging small data, data alignment and reducing padding bytes; the system manages data through the ring buffer to ensure the orderly transmission of data flow, avoid data loss or bus blocking caused by instantaneous data overload, improve data throughput capacity, dynamically adjust the data transmission interval according to the real-time load condition of the CAN bus to ensure balanced utilization of bus resources, reduce transmission conflicts, improve channel utilization rate, make data transmission smoother, detect peak transmission periods and optimize data transmission strategies at the same time to ensure that high-priority data can be processed in time, reduce the influence of low-priority data on the overall performance of the system, combine the data packaging optimization strategy (merging small data, data alignment and reducing padding bytes) to reduce redundant data, improve the effective load ratio of a single frame, reduce bus occupancy rate, thereby speeding up transmission, and optimize the data frame structure (frame header, control field and check field) to ensure data integrity and reliability, reduce unnecessary overhead, improve data processing efficiency, adjust the data transmission interval according to the load condition of the bus to avoid too high delay caused by burst data transmission, make the system response more stable, and improve overall communication performance; then the second judgment module 40 judges whether the data frames reach the preset processing response speed to perform corresponding steps.For example, when the system determines that the data frame can reach the pre-set processing response speed, the system considers that the current data transmission strategy and cache management have been optimized, the communication efficiency of the CAN bus has met the system requirements, and there is no need for further adjustment. The system maintains the current optimization strategy and continues to operate according to the existing ring buffer management, dynamic data scheduling and data packaging optimization scheme to ensure that the system can still maintain efficient communication under different load conditions. At the same time, the system continues to monitor the system load, continues to collect the load state and communication delay of the CAN bus, establishes a long-term data analysis model to ensure that the strategy can be quickly adjusted when the load fluctuates, and appropriately reduces the power consumption. On the premise of ensuring communication efficiency, reduce data redundancy and unnecessary transmission frequency, improve energy efficiency ratio, and optimize the overall operation efficiency of the CAN bus; for example, when the system determines that the data frame cannot reach the pre-set processing response speed, the second execution module 50 considers that the current data transmission strategy and cache management have not been optimized. The system obtains the transmission frequency of the communication data, resets the ID priority of the CAN bus based on different transmission frequencies, the ID priority specifically includes ECU control signals, sensor data and state logs, acquires the category information of the communication data according to the pre-set priority of the communication data, and dynamically adjusts the message transmission length of the communication data according to different category information. The system accurately identifies the root cause of the decrease in data frame response speed by obtaining the transmission frequency of the communication data, avoids blind optimization, improves the accuracy of problem positioning, resets the ID priority of the CAN bus according to different transmission frequencies, ensures that high-priority data (such as ECU control signals) can be transmitted in time, and all data are not treated equally, reducing the interference of low-priority data on data with high real-time requirements. At the same time, through the redistribution of the ID priority, it is ensured that the ECU control signals (such as brake, steering and other key signals) are always transmitted in priority, avoiding the delay of control signals caused by bus congestion, improving the safety and response speed of the vehicle, and the low-priority data such as sensor data and state logs can be appropriately delayed when the bus load is high. The stability and reliability of the core control signal are guaranteed, and according to the category information of the communication data (such as real-time control data, environmental monitoring data, historical logs, etc.), the system can dynamically adjust the transmission length of the data, reduce the occupation of the bus by irrelevant data, optimize the transmission strategy, for example, for high real-time data (such as brake control), the system can shorten the transmission length to improve the refresh rate; for low-time-efficiency data (such as vehicle state logs), the transmission period can be appropriately extended to reduce the bus load.
[0118] In the embodiment, the execution module further includes:
[0119] The construction unit is configured to construct the capacity parameter of the ring buffer based on the maximum data flow of the communication data.
[0120] A judging unit is configured to judge whether the capacity parameter is adapted to a preset data storage mode.
[0121] An executing unit is configured to, if yes, dynamically allocate a memory overhead of the ring buffer according to the data storage mode, acquire a frame length of the communication data, apply an index table data block to data access of the communication data according to the frame length, and record read information of the ring buffer in real time, where the read information specifically includes overflow or empty reading.
[0122] In this embodiment, the system constructs the capacity parameters of the ring buffer based on the maximum data flow of the communication data, and then determines whether the capacity parameters adapt to the pre-set data storage mode to perform corresponding steps; for example, when the system determines that the capacity parameters of the ring buffer do not adapt to the pre-set data storage mode, the system considers that if the capacity is too small, the data write rate may be higher than the read rate, the buffer overflows, and thus data loss or system processing delay occurs, and if the capacity is too large, the data flow is relatively small, which causes storage resource waste and reduces the efficiency of cache management. The system dynamically adjusts the capacity of the ring buffer according to the data flow to avoid the adaptability problem caused by fixed capacity setting, uses an adaptive capacity adjustment algorithm, expands or reduces the buffer size in real time according to the historical data flow trend, ensures that overflow does not occur due to sudden data growth, and also ensures that resource waste does not occur due to excessive redundant space. At the same time, high-frequency data buffers and low-frequency data buffers are set, high real-time data (such as ECU control signals) is stored in the high-speed buffer, and a high-priority read strategy is set. Low-priority data (such as state logs) is stored in the secondary buffer, which allows batch transmission under low load to reduce bus occupancy. If it is found that buffer overflow is caused by frequent sending of some data, the data sending rhythm can be optimized, the data packet size can be adjusted or repeated data can be merged to reduce transmission pressure. A flow control mechanism is used to temporarily delay the storage of low-priority data when the data flow is too large, to ensure the integrity and timeliness of critical data. For example, when the system determines that the capacity parameters of the ring buffer adapt to the pre-set data storage mode, the system considers that the organization mode of the buffer (such as FIFO, LIFO, etc.) matches the actual data flow mode of the CAN bus, and does not affect the data access efficiency. The system dynamically adjusts the memory overhead of the ring buffer according to different data storage modes, obtains the frame length of the communication data, applies the index table data block to access the communication data according to the frame length, and records the read information of the ring buffer in real time. The read information specifically includes overflow or empty read. The system dynamically adjusts the memory overhead of the ring buffer to avoid allocating too much or too little memory, improves the memory utilization rate, allocates appropriate cache size according to different data storage modes (such as fixed-size data block or variable-length data block), reduces resource waste caused by excessive reservation, or performance degradation caused by insufficient space, and at the same time, by obtaining the frame length of the communication data, the system can more accurately allocate cache space to prevent storage fragmentation problems caused by mismatched frame sizes. The index table data block management mechanism ensures that data can be accessed along the optimal path to improve query and write speed, reduce CPU occupancy rate, and adapt the buffer to different data communication modes to ensure that delay or packet loss does not occur due to unreasonable cache mechanism under high data flow scenarios. Under low load conditions, the system can reduce unnecessary data access operations to reduce power consumption and improve overall communication efficiency.
[0123] In the embodiment, further comprising:
[0124] The collection module is configured to dynamically adjust a bus utilization rate of the CAN bus based on a test target preset for the CAN bus, collect concurrent communication capabilities of the plurality of communication nodes, and obtain a bit error rate of the CAN bus.
[0125] The third judging module is configured to judge whether the bit error rate exceeds a preset threshold.
[0126] The third executing module is configured to, if yes, inject a preset high-frequency interference signal within a preset transmission distance of the CAN bus, test a bit error change rate of the communication node, and dynamically adjust a bus arbitration priority of the CAN bus according to the bit error change rate, wherein the bus arbitration priority specifically includes reasonably allocating an ID, reducing a sending frequency and a usage time slice of high-priority data.
[0127] In the embodiment, the system dynamically adjusts the bus utilization of the CAN bus based on the test target preset by the CAN bus, collects the concurrent communication capability of the plurality of communication nodes to obtain the error code rate of the CAN bus, and then judges whether the error code rate exceeds the preset threshold to perform corresponding steps; for example, when the system determines that the error code rate of the CAN bus does not exceed the preset threshold, the system considers that the current bus communication quality is within an acceptable range, the stability and reliability of data transmission are high, and no serious signal interference or data loss occurs, the system dynamically adjusts the sending timing of the data frame, reduces the bus idle time, improves the data transmission efficiency, optimizes the data flow scheduling, appropriately increases the sending frequency of low-priority messages, ensures that the CAN bus bandwidth is fully utilized without affecting the transmission of high-priority data, simultaneously collects the concurrent communication capability of the plurality of communication nodes in real time, dynamically adjusts the data sending priority when the load increases, prevents data congestion caused by high load, dynamically allocates the time slot resources of the CAN bus, ensures that the communication of each node is not affected under different load conditions, improves the overall throughput of the system, and under the premise of ensuring low error code rate, improves the bandwidth utilization and communication efficiency of the CAN bus, reduces the data transmission delay, improves the system response speed, reduces the bus idle time, improves the concurrent communication capability, and ensures that the plurality of nodes can stably and efficiently exchange data; for example, when the system determines that the error code rate of the CAN bus exceeds the preset threshold, the system considers that the current bus communication quality is abnormal, the system injects a pre-set high-frequency interference signal within the pre-set transmission distance of the CAN bus to test the error code change rate of the communication node, dynamically adjusts the bus arbitration priority of the CAN bus according to different error code change rates, and the bus arbitration priority specifically includes reasonably allocating ID, reducing the sending frequency of high-priority data, and using time slice scheduling; by adjusting the ID priority, the system can preferentially ensure the transmission of important messages (such as safety data, real-time control signals, etc.), reduce data loss caused by error codes, help ensure that high-priority messages are not disturbed by low-priority data, improve the reliability of critical data transmission, and simultaneously according to different error code change rates, the system can adjust the working strategy of the bus in real time, if the system detects that the error code rate of a part of the region or a specific node abnormally increases, the interference influence can be alleviated by adjusting the communication strategy of the region or the node, and by simulating a high-frequency interference signal and adjusting the transmission strategy according to the error code rate, the system can better adapt to harsh environments, improve the communication stability and reliability in high-interference conditions.
[0128] In the embodiment, the second execution module further includes:
[0129] The collecting unit is used for collecting bandwidth load of the CAN bus based on real-time category data pre-collected by the vehicle, wherein the real-time category data specifically includes high real-time data, medium real-time data and low real-time data;
[0130] The second judging unit is used for judging whether the bandwidth load reaches a preset bus load or not.
[0131] The second executing unit is used for, if yes, applying a preset multicast sending mode, merging low-priority data into the same frame, introducing a time slice scheduling mechanism, allocating sending time of the real-time category data, monitoring corresponding sending failure number, and constructing a retransmission strategy of the real-time category data according to the sending failure number.
[0132] In the embodiment, the system determines whether the bandwidth load reaches the pre-set bus load based on the real-time category data collected by the vehicle in advance, and the real-time category data specifically includes high real-time data, medium real-time data and low real-time data, and then the system executes corresponding steps; for example, when the system determines that the bandwidth load of the real-time category data on the CAN bus does not reach the pre-set bus load, the system considers that the use efficiency of the CAN bus has not reached the maximum, and there may be a situation that the bandwidth resources are not fully utilized, and the system can increase the sending frequency of the low real-time data, fully utilize the bandwidth resources without affecting the transmission of high real-time data, adjust the sending interval of medium real-time data, and appropriately increase the sending frequency to better utilize the idle bandwidth, and if the bandwidth resources are sufficient, the priority of low real-time data can be appropriately improved to avoid the situation that low-priority data is waiting for transmission for a long time, if the load of the real-time category data is light, the size of the data frame can be appropriately increased, multiple small data packets can be combined, the packing efficiency of data can be improved, the bus occupation time can be reduced, and the transmission capacity of the bus can be improved by reasonably adjusting the timing and frequency of sending data, so that the bus can efficiently carry more data streams and improve its transmission capacity and reduce invalid idle time, if the bandwidth is not fully occupied, the storage and reading of data can be optimized by using a ring buffer or other caching strategies to reduce the delay during data transmission; for example, when the system determines that the bandwidth load of the real-time category data on the CAN bus reaches the pre-set bus load, the system considers that the use efficiency of the CAN bus reaches the maximum, and the system applies the pre-set multicast sending mode, combines low-priority data into the same frame, introduces a time scheduling mechanism to allocate the sending time of the real-time category data, monitors the corresponding number of sending failures, and constructs a retransmission strategy for the real-time category data according to different numbers of sending failures; the system combines low-priority data into the same frame to avoid the repeated overhead of sending multiple low-priority data, which can effectively reduce the number of data frames and improve the data transmission efficiency of the bus.Through the multicast mode, the bandwidth can be more efficiently utilized, the communication delay and transmission time slot waste can be reduced, the bandwidth occupation can be reduced, by merging low-priority data, not only the bandwidth is saved, but also the data transmission speed is improved, so that the high-priority data can be transmitted faster, and meanwhile, through the introduction of the time scheduling mechanism, the sending time of each real-time category data can be accurately controlled, the data transmission according to the priority and the preset time window is ensured, so that the conflict and congestion of data transmission are avoided, the system can reasonably allocate the bandwidth, optimize the time allocation of the overall data flow, further improve the use efficiency of the bus, the reasonable scheduling opportunity avoids that the low-priority data occupies too much bandwidth, causes the delay of the high-priority data, ensures that the real-time requirement of the system is met, and through monitoring the number of sending failures, the system can timely find the problems in transmission and make adjustment, for example, if a certain data frame fails to be sent for many times, the system can preferentially resend the data, ensures the transmission integrity and reliability of the data, according to the number of sending failures, the system can dynamically adjust the retransmission strategy, ensures that the data can be reliably transmitted under network pressure, the retransmission strategy can determine whether to adjust the sending frequency, the priority or the scheduling opportunity according to the high or low of the number of failures, further optimizes the communication quality.
[0133] In the embodiment, the judging module further comprises:
[0134] The second acquisition unit is configured to acquire a communication parameter corresponding to the baud rate according to the baud rate of the CAN bus, and the communication parameter specifically includes communication stability, a data loss rate and an error frame number.
[0135] The third judging unit is configured to judge whether the communication parameter matches a preset data throughput.
[0136] The third execution unit is configured to, if no, send a data frame with a fixed size, calculate a maximum data flow in a unit time according to the data frame, monitor a bus load of the CAN bus according to the maximum data flow, and calculate a bus utilization rate under different baud rates according to the bus load.
[0137] In the embodiment, the system collects the communication parameters corresponding to the baud rates preset based on the CAN bus, the communication parameters specifically including communication stability, data loss rate and number of error frames, and then the system judges whether the communication parameters match the preset data throughput to perform corresponding steps; for example, when the system determines that the communication parameters corresponding to the baud rate can match the preset data throughput, the system considers that the CAN bus communication performance under the baud rate is good and can meet the data transmission demand, the system judges whether the baud rate can guarantee the stability of communication through the collected communication parameters (such as the number of error frames, the data loss rate, etc.), if the parameters meet the expected target, the system confirms that the baud rate can maintain the communication quality, at the same time, when the data throughput matches the baud rate, the system considers that the transmission stability, throughput and error rate under the current baud rate are in the best state, there is no need to adjust the baud rate, and when the communication parameters reach the expectation, the system can allocate resources to other modules, such as optimizing buffer management, adjusting data packaging strategy, etc., to ensure that other operations on the bus are not affected, and further improve the overall performance, although the baud rate has met the throughput demand, the system should continue to monitor the communication parameters, such as the number of error frames, the amount of lost data, etc., to ensure that there is no performance bottleneck or communication problem on the bus in actual work; for example, when the system determines that the communication parameters corresponding to the baud rate cannot match the preset data throughput, the system considers that the CAN bus communication performance under the baud rate is poor and cannot meet the data transmission demand, the system sends data frames of a fixed size, calculates the maximum data flow per unit time according to different data frames, monitors the bus load of the CAN bus according to different maximum data flow, and calculates the bus utilization rate under different baud rates through the bus load; the system can identify the bottleneck of the communication performance by analyzing the situation that the baud rate cannot meet the data throughput, and clearly the deficiencies under the baud rate, so as to accurately locate the performance problem and avoid wasting resources, at the same time, by sending data frames of a fixed size, the system can accurately calculate the maximum data flow per unit time, which helps the system to optimize in subsequent data transmission, ensures to improve the data transmission efficiency as much as possible under the current baud rate, so as to realize better bandwidth utilization, and by monitoring the bus load of the CAN bus in real time, the system can understand the actual use of the bus under different baud rates, further evaluate whether the current baud rate is too inefficient or causes bus congestion, real-time load monitoring can help the system to judge whether to switch to a higher baud rate, and by monitoring the bus load under different baud rates, the system can accurately calculate the utilization rate of the bus to help judge whether the transmission capacity of the current bus is fully utilized, if the bus utilization rate is too low, it may mean that the baud rate is not properly selected, the system can adjust the transmission strategy or the baud rate according to this index.
[0138] In the embodiment, the second judging module further comprises:
[0139] a detecting unit configured to detect a signal waveform of the CAN bus based on an oscilloscope preset by the vehicle;
[0140] a fourth judging unit configured to judge whether the signal waveform has preset fault content, wherein the fault content specifically includes distortion, reflection and noise interference;
[0141] a fourth executing unit configured to, if yes, evaluate driving capability of the CAN bus according to a preset transceiver of the CAN bus, identify a terminal resistance of the CAN bus, and dynamically adjust bus impedance of the CAN bus according to the terminal resistance.
[0142] In this embodiment, the system detects the signal waveform of the CAN bus based on the oscilloscope preset by the vehicle, and then the system judges whether the signal waveform has the preset fault content, and the fault content specifically includes distortion, reflection and noise interference, to perform the corresponding steps; for example, when the system determines that the signal waveform of the CAN bus does not have the preset fault content, the system considers that the signal transmission of the CAN bus is normal, and there is no problem such as distortion, reflection or noise interference, and the system regularly monitors the signal waveform to ensure that the signal quality remains stable during long-term use, which helps to discover potential problems in time and prevent future communication failures, and based on the current good signal quality, further optimize the efficiency of data transmission, such as optimizing the baud rate, data frame structure or data scheduling strategy, to improve the communication efficiency and response speed, and by judging that the signal waveform is normal, the system can confirm that the bus state is healthy, and can maintain efficient and stable communication with other communication nodes, reducing failure or maintenance time; for example, when the system determines that the signal waveform of the CAN bus has the preset fault content, the system considers that the signal transmission of the CAN bus is abnormal, and the system evaluates the driving capability of the CAN bus according to the pre-set transceiver of the CAN bus, identifies the terminal resistance of the CAN bus, and dynamically adjusts the bus impedance of the CAN bus according to the terminal resistance; by evaluating and adjusting the driving capability and bus impedance of the CAN bus, the system can effectively repair problems such as signal distortion, reflection or noise interference, which helps to improve the integrity and transmission quality of the signal, and ensures accurate data transmission, while dynamically adjusting the bus impedance and terminal resistance helps to maintain stable electrical matching between different nodes of the bus, preventing signal reflection and voltage fluctuation, which can enhance communication stability, reduce communication errors, and adjusting the terminal resistance and driving capability can reduce signal distortion and reflection, avoid bit errors caused by unmatched impedance, reduce the generation of data loss or error frames in the communication process, and thus improve the reliability of the entire system, and by dynamically adjusting the electrical parameters of the system, it can prevent hardware damage or performance degradation caused by signal abnormalities, and prolong the service life of the CAN bus system and related equipment.
[0143] In this embodiment, the acquisition module further comprises:
[0144] The third acquisition unit is configured to acquire the number of frames successfully sent and received by the CAN bus based on the data type preset by the vehicle, wherein the data type specifically includes periodic data, burst data and burst-period combination data.
[0145] The fifth judgment unit is configured to judge whether the number of frames matches the preset average time delay.
[0146] The fifth execution unit is configured to, if no, acquire an error frame on the CAN bus, and dynamically adjust a cache depth of the CAN bus according to the error frame, wherein the error frame specifically includes an ACK loss, a bit error, and a format error.
[0147] In the embodiment, the system collects the number of frames sent and received successfully by the CAN bus based on the data type preset by the vehicle, and the data type specifically includes periodic data, burst data, and burst-period combination data, and then the system determines whether the number of frames matches the preset average latency to perform corresponding steps; for example, when the system determines that the number of frames sent and received successfully by the CAN bus can match the preset average latency, the system considers that the communication efficiency and latency of the CAN bus are normal, and the CAN bus can transmit data as expected, and the system further optimizes the scheduling and bandwidth allocation of communication data; for example, other tasks or data types can be scheduled without increasing additional load, efficient communication operation is maintained, and at the same time, since the current system setting has achieved the expected effect, the current CAN bus configuration and data scheduling strategy can be maintained, which reduces unnecessary adjustment and resource waste, ensures stable operation of the system, and when the number of frames matches the latency, the system can predict that the CAN bus can continue to provide the required performance under similar future loads, which helps to expand more devices or nodes without affecting the communication efficiency, and if the system can successfully match the expected latency and frame number, it indicates that the working state of the CAN bus is healthy, reducing the cost of troubleshooting and repair and simplifying maintenance work; for example, when the system determines that the number of frames sent and received successfully by the CAN bus cannot match the preset average latency, the system considers that the communication efficiency and latency of the CAN bus are abnormal, and the system obtains error frames on the CAN bus, dynamically adjusts the cache depth of the CAN bus according to different error frames, and the error frames specifically include ACK loss, bit error, and format error. The system can timely discover potential problems in communication by identifying and analyzing the types of error frames. Dynamically adjusting the cache depth can help alleviate the impact of errors and improve the stability of communication, especially when encountering format errors, ACK loss, or bit errors, adjusting the cache depth can ensure better data storage and retransmission, avoid information loss, and at the same time, when latency anomalies are detected, appropriately adjusting the cache depth can better manage data flow on the CAN bus, reduce data conflicts and buffer overflow, thereby improving the utilization of the bus. By dynamically adjusting the cache depth, the system can flexibly allocate resources according to the current load and data transmission requirements to ensure effective bandwidth utilization, and when error frames occur during communication, they usually cause data loss or transmission failure. Dynamically adjusting the cache depth can provide sufficient buffer space when errors occur to facilitate data retransmission after the system recovers to normal, which can significantly reduce the data loss rate caused by latency anomalies, and timely adjusting the cache depth helps to alleviate the load pressure caused by a large number of error frames and latency problems. When the system encounters communication problems, increasing the cache capacity can provide more space for the system to handle burst error frames, avoiding frequent retransmission requests and bus congestion.
[0148] While embodiments of the application have been shown and described, it is to be understood that the embodiments described are merely exemplary of the principles and application of the present application. Numerous modifications and adaptions can be effected without departing from the spirit and scope of the present application, which is not limited to the exact construction and arrangement described. It is intended, therefore, to cover all modifications and adaptions that fall within the scope of the claims and their equivalents.
Claims
1. A multi-level cache method based on CAN bus communication, characterized in that, Includes the following steps: Based on a preset load scenario, the impact coefficient of the CAN bus on different baud rates is obtained. The load scenario specifically includes idle state, low load state, and high load state. It is determined whether the impact coefficient is limited by the CAN bus hardware. If not, the preset caching mechanism of the CAN bus is activated, and a circular buffer is applied to transmit communication data. The transmission interval of the communication data is dynamically adjusted according to the pre-collected CAN bus load. The peak transmission period of the CAN bus for the communication data is detected, and based on the peak transmission period, a preset data packing strategy is optimized in a single data frame. The data frame specifically includes a frame header, control field, and check field. The data packing strategy specifically includes merging small data, data alignment, and reducing padding bytes. It is determined whether the data frame reaches a preset processing response speed. If not, the transmission frequency of the communication data is obtained. Based on the transmission frequency, the ID priority of the CAN bus is reset. According to the preset priority of the communication data, the category information of the communication data is collected. Based on the category information, the message transmission duration of the communication data is dynamically adjusted. The ID priority specifically includes ECU control signals, sensor data, and status logs. The preset CAN bus cache mechanism is then activated. The caching mechanism, in the step of using a ring buffer to transmit communication data, further includes: constructing the capacity parameter of the ring buffer based on the maximum data flow of the communication data; determining whether the capacity parameter is compatible with a preset data storage method; if so, dynamically allocating the memory overhead of the ring buffer according to the data storage method, obtaining the frame length of the communication data, and using an index table data block to access the communication data according to the frame length, and recording the read information of the ring buffer in real time, wherein the read information specifically includes overflow or empty read. Before the step of detecting the peak transmission period of the communication data by the CAN bus, the mechanism further includes: dynamically adjusting the bus utilization of the CAN bus based on the preset test target of the CAN bus, collecting the concurrent communication capabilities of multiple communication nodes, and obtaining the bit error rate of the CAN bus; determining whether the bit error rate exceeds a preset threshold; if so, injecting a preset high-frequency interference signal within the preset transmission distance of the CAN bus, testing the bit error rate change rate of the communication nodes, and dynamically adjusting the bus arbitration priority of the CAN bus according to the bit error rate change rate, wherein the bus arbitration priority specifically includes reasonable allocation of IDs, reducing the transmission frequency of high-priority data, and using time slice scheduling.
2. The multi-level cache method based on CAN bus communication according to claim 1, wherein, The step of collecting the category information of the communication data, dynamically adjusting the message sending duration of the communication data according to the category information, further comprises: collecting the bandwidth load of the CAN bus based on the real-time category data pre-collected by the vehicle, wherein the real-time category data specifically includes high real-time data, medium real-time data and low real-time data; determining whether the bandwidth load reaches a preset bus load; if yes, applying a preset multicast sending mode, merging low-priority data into the same frame, introducing a time slice scheduling mechanism, allocating the sending time of the real-time category data, monitoring the corresponding sending failure number, and constructing a retransmission strategy of the real-time category data according to the sending failure number.
3. The multi-level cache method based on CAN bus communication according to claim 1, wherein, The step of determining whether the influence coefficient is limited by the hardware of the CAN bus further comprises: collecting the communication parameters corresponding to the baud rate based on the preset baud rate of the CAN bus, wherein the communication parameters specifically include communication stability, data loss rate and error frame number; determining whether the communication parameters match a preset data throughput; if not, sending a data frame of a fixed size, calculating the maximum data flow in a unit of time according to the data frame, monitoring the bus load of the CAN bus according to the maximum data flow, and calculating the bus utilization rate under different baud rates through the bus load.
4. The multi-level cache method based on CAN bus communication according to claim 1, wherein, The step of determining whether the data frame reaches a preset processing response speed further comprises: detecting the signal waveform of the CAN bus based on a preset oscilloscope of the vehicle; determining whether the signal waveform contains a preset fault content, wherein the fault content specifically includes distortion, reflection and noise interference; if yes, evaluating the driving capability of the CAN bus according to a preset transceiver of the CAN bus, identifying the terminal resistance of the CAN bus, and dynamically adjusting the bus impedance of the CAN bus according to the terminal resistance.
5. The multi-level cache method based on CAN bus communication according to claim 1, wherein, The step of obtaining the influence coefficient of the CAN bus for different baud rates based on a preset load scenario further comprises: collecting the number of frames sent and received successfully by the CAN bus based on a preset data type of the vehicle, wherein the data type specifically includes periodic data, burst data and burst-period combination data; determining whether the number of frames matches a preset average delay; if not, obtaining error frames on the CAN bus, and dynamically adjusting the cache depth of the CAN bus according to the error frames, wherein the error frames specifically include ACK loss, bit error and format error.
6. A multi-level cache system based on CAN bus communication, characterized in that, Comprise: The acquisition module is used for acquiring an influence coefficient of a CAN bus for different baud rates based on a preset load scenario, wherein the load scenario specifically includes an idle state, a low load state and a high load state; the judgment module is used for judging whether the influence coefficient is limited by hardware of the CAN bus; the execution module is used for activating a preset cache mechanism of the CAN bus if not, applying a ring buffer to transmit communication data, dynamically adjusting a sending interval of the communication data according to a pre-acquired CAN bus load condition, detecting a peak transmission period of the CAN bus for the communication data, and optimizing a preset data packaging strategy in a single data frame according to the peak transmission period, wherein the data frame specifically includes a frame header, a control field and a check field, and the data packaging strategy specifically includes merging small data, data alignment and reducing padding bytes; the second judgment module is used for judging whether the data frame reaches a preset processing response speed; and the second execution module is used for resetting an ID priority of the CAN bus based on a sending frequency of the communication data, collecting category information of the communication data according to a preset priority of the communication data, and dynamically adjusting a message sending duration of the communication data according to the category information if the data frame does not reach the preset processing response speed, wherein the ID priority specifically includes an ECU control signal, sensor data and a state log; wherein the execution module further includes a construction unit used for constructing a capacity parameter of the ring buffer based on a maximum data flow of the communication data; a judgment unit used for judging whether the capacity parameter is adapted to a preset data storage mode; and an execution unit used for dynamically allocating a memory overhead of the ring buffer according to the data storage mode if yes, acquiring a frame length of the communication data, applying an index table data block to data access of the communication data according to the frame length, and recording reading information of the ring buffer in real time, wherein the reading information specifically includes overflow or empty reading; wherein the multi-level cache system further includes an acquisition module used for dynamically adjusting a bus utilization rate of the CAN bus based on a preset test target of the CAN bus, collecting concurrent communication capabilities of multiple communication nodes, and acquiring a bit error rate of the CAN bus; a third judgment module used for judging whether the bit error rate exceeds a preset threshold; and a third execution module used for injecting a preset high-frequency interference signal within a preset transmission distance of the CAN bus if yes, testing a bit error change rate of the communication nodes, and dynamically adjusting a bus arbitration priority of the CAN bus according to the bit error change rate, wherein the bus arbitration priority specifically includes reasonably allocating an ID, reducing a sending frequency of high-priority data and using time slice scheduling.
Citation Information
Patent Citations
CAN bus data processing method and control system
CN109960177A
High-frequency data remote transmission method and system
CN119520639A