A method for controlling the timing of consecutive frames of ECU diagnostics to reduce software load
By decoupling the timing method in the ECU diagnostic process and dynamically switching the timing reference type, high-precision transmission of continuous frames is achieved during the ECU diagnostic process. This solves the problems of excessive software load and insufficient timing accuracy, ensuring the safe response and diagnostic efficiency of the ECU.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SHANGHAI LEEKR TECHNOLOGY CO LTD
- Filing Date
- 2026-04-17
- Publication Date
- 2026-06-19
AI Technical Summary
In the existing technology, the timing method of continuous frames during ECU diagnosis has the problem of excessive software load or insufficient timing accuracy, which leads to prolonged braking response time and abnormal termination of the diagnostic session, and cannot meet the timing requirements of STmin parameters of different magnitudes.
By receiving the flow control frames sent by the diagnostic instrument, the original encoded byte values are decoupled from the time base scale and the effective value of the time multiplier. Combined with the ECU operating mode, the timing base type is dynamically switched. The timing method is either passively driven by a cycle or actively driven by a polling method to ensure that the timing base of the CAN transmission protocol module and the diagnostic communication management module are synchronized, thereby achieving high-precision continuous frame transmission.
While ensuring the response speed of safety-critical tasks, it reduces the software load rate, meets the timing requirements of STmin parameters of different magnitudes, avoids abnormal termination of diagnostic sessions, and optimizes the cumulative time determination deviation in the transmission of long sequence continuous frames.
Smart Images

Figure CN122050009B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of automotive ECU diagnostic communication technology, and more specifically, to an ECU diagnostic continuous frame timing control method that reduces software load. Background Technology
[0002] During automotive ECU diagnostics, according to the flow control mechanism requirements of the ISO15765-2:2016 protocol, the diagnostic tool sends the minimum consecutive frame interval (STmin) parameter via flow control frames. This parameter supports two encoding levels: milliseconds (ms) and 100 microseconds (μs), indicating the minimum time interval for the ECU to send consecutive frames. In existing technologies, the ECU's CAN transmission protocol typically employs two timing methods: one is by calculating the time difference using system timestamps. This method offers high timing accuracy and can meet the μs-level STmin parameter requirement, but it requires frequent calls to the system time interface, causing the braking ECU's software load rate to exceed 45%, exceeding the safety threshold and extending the braking response time to over 50 milliseconds. The other method uses a task counter, but its timing accuracy is affected by the task execution order and instruction runtime, failing to meet the μs-level STmin parameter requirement and causing a deviation between the ECU's response time interval and the STmin time requested by the diagnostic tool.
[0003] In addition, the timing references of the CAN transmission protocol module and the diagnostic communication management module in the existing technology are not consistent. The former mostly uses a task counter, while the latter mostly uses a system timestamp. During the transmission of long sequence of continuous frames, there will be a cumulative time judgment deviation, which will trigger the P2Server timeout of the diagnostic communication management module, causing the diagnostic session to terminate abnormally and affecting the diagnostic and writing efficiency.
[0004] To address the aforementioned issues, if a system timestamp timing method is adopted to eliminate the time interval deviation between consecutive frames, all timing logic in the software platform needs to be completely modified, resulting in high development costs and a significant increase in software load. If the traditional task counter timing method is continued to be used, it will not only fail to meet the timing requirements of STmin parameters of different magnitudes, but also cause multiple frames to be sent in a single cycle task due to the conflict between the magnitude of microsecond-level STmin and millisecond-level task cycles, leading to the expansion of task execution time and further affecting safety-critical tasks.
[0005] To address the above problems, this invention proposes a solution. Summary of the Invention
[0006] In order to overcome the above-mentioned defects of the prior art, embodiments of the present invention provide an ECU diagnostic continuous frame timing control method for reducing software load rate, so as to solve the problems mentioned in the background art.
[0007] To achieve the above objectives, the present invention provides the following technical solution:
[0008] An ECU diagnostic continuous frame timing control method for reducing software load includes the following steps: receiving a flow control frame sent by a diagnostic instrument and extracting the original encoded byte value of the minimum continuous frame time interval parameter; performing encoding interval attribution determination on the original encoded byte value, and decoupling it into a time reference scale that identifies the time magnitude partition and a time multiplier effective value that identifies the multiplier coefficient based on the encoding interval it falls into;
[0009] Obtain the ECU operating mode identifier and determine the timing reference type. The first operating mode corresponds to the task counter timing method based on the periodic task scheduler, and the first operating mode corresponds to the system timestamp timing method based on the underlying hardware timer. Simultaneously configure the timing reference of the CAN transmission protocol module and the diagnostic communication management module as the timing reference type.
[0010] Based on the effective value of the time reference scale and the time multiplier, the trigger threshold is sent by combining the operation mode identifier. In the first operation mode, the magnitude conflict is checked according to the time reference scale and the periodic task execution cycle, and the minimum continuous frame time interval is mapped to the number of discrete task runs according to the check result. In the second operation mode, the minimum continuous frame time interval is mapped to the high-precision target time difference comparison threshold.
[0011] After sending consecutive frames, in the first operating mode, the cumulative number of times the periodic task is run is counted and compared with the number of times the discrete task is run to achieve passive periodic driving timing; in the second operating mode, the real-time time difference of the system timestamp is compared with the high-precision target time difference comparison threshold to achieve active polling driving timing; when the corresponding threshold condition is met, the next consecutive frame is triggered to be sent.
[0012] In a preferred embodiment, the determination of the coding interval attribution is based on predefined coding interval division parameters: the coding interval division parameters include the first effective coding interval start value and the first effective coding interval end value that define the first effective coding interval, and the second effective coding interval start value and the second effective coding interval end value that define the second effective coding interval;
[0013] The rules for determining the time base scale are as follows: when the value of the original encoded byte is greater than or equal to the starting value of the first effective encoding interval and less than or equal to the ending value of the first effective encoding interval, the value of the original encoded byte falls into the first effective encoding interval, and the time base scale is assigned a value of 1, which is defined as the first-level scale, representing the time interval partition with a larger time granularity as the basic unit of measurement; when the value of the original encoded byte is greater than or equal to the starting value of the second effective encoding interval and less than or equal to the ending value of the second effective encoding interval, the value of the original encoded byte falls into the second effective encoding interval, and the time base scale is assigned a value of 2, which is defined as the second-level scale, representing the time interval partition with a smaller time granularity as the basic unit of measurement.
[0014] In a preferred embodiment, when the value of the original encoded byte falls neither into the first valid encoding interval nor the second valid encoding interval, the value of the original encoded byte belongs to the reserved encoding segment; the CAN transmission protocol module replaces the original encoded byte value of the reserved encoding segment with the termination value of the first valid encoding interval, the time base scale is 1, and the effective value of the time multiplier is the value corresponding to the termination value of the first valid encoding interval.
[0015] In a preferred embodiment, the extraction rule for the effective value of the time multiplier is as follows: when the time reference scale is the first level scale, the value of the original encoded byte value is directly assigned to the effective value of the time multiplier; when the time reference scale is the second level scale, the result of subtracting the predefined second encoding interval offset base value from the original encoded byte value is assigned to the effective value of the time multiplier; wherein the second encoding interval offset base value is the offset reference value that needs to be subtracted when extracting the effective multiplier coefficient from the original encoded byte value of the second-level encoding partition;
[0016] The actual physical time corresponding to the minimum consecutive frame time interval parameter is obtained by multiplying the effective value of the time multiplier with the time base unit corresponding to the current time base scale, where the first-level scale corresponds to the first-level scale time base unit and the second-level scale corresponds to the second-level scale time base unit.
[0017] In a preferred embodiment, the first operating mode is the normal operating state of the ECU running application. In this state, the ECU performs safety-critical tasks including braking control, motor motion control, and valve motion control. The operating system schedules the operation of each task module at a fixed cycle.
[0018] The second operating mode is the working state in which the ECU performs software flashing. In this state, the ECU does not perform the aforementioned safety-critical tasks. The operating mode identifier is obtained by calling the mode query interface provided by the ECU operating system. The operating mode identifier is assigned a value of 1 in the first operating mode and a value of 2 in the second operating mode.
[0019] In the task counter timing method based on the periodic task scheduler, the CAN transmission protocol module itself does not actively call the system time interface; the system timestamp timing method based on the underlying hardware timer obtains the microsecond-level timestamp by reading the current count value of the hardware timer.
[0020] In a preferred embodiment, magnitude conflict verification is performed by defining a magnitude conflict flag: the magnitude conflict flag is a Boolean variable that indicates whether there is an irreconcilable magnitude difference between the time granularity represented by the time reference scale and the execution cycle of the periodic task; when the time reference scale is a second-level scale, the minimum continuous frame time interval parameter is in the microsecond range, and there is a magnitude difference of more than one order of magnitude between it and the execution cycle of the periodic task, so the magnitude conflict flag is determined to be TRUE; when the time reference scale is a first-level scale, the two are in the same magnitude range, so the magnitude conflict flag is determined to be FALSE.
[0021] In a preferred embodiment, the minimum number of runs is defined as the lowest cycle count of consecutive frame intervals in the first running mode, and the cycle count unit of the cycle task is defined as the ratio of the cycle execution cycle of the cycle task to the time reference unit of the first-level scale; wherein, the time reference unit of the first-level scale is the time reference unit corresponding to the first-level scale.
[0022] The calculation rules for the number of discrete task runs are as follows: when the magnitude conflict flag is TRUE, the number of discrete task runs is assigned to the minimum number of runs; when the magnitude conflict flag is FALSE and the effective value of the time multiplier is less than the periodic count unit of the periodic task, the number of discrete task runs is assigned to the minimum number of runs; when the magnitude conflict flag is FALSE and the effective value of the time multiplier is greater than or equal to the periodic count unit of the periodic task, the number of discrete task runs is the rounded-up value of the ratio of the effective value of the time multiplier to the periodic count unit of the periodic task.
[0023] In a preferred embodiment, in the first operating mode, the passive cycle-driven timing is executed as follows: the current count value is defined as a non-negative integer counter that records the cumulative number of times the cycle task is scheduled to be executed; after the CAN transmission protocol module sends a continuous frame, the current count value is initialized to 0, and then the current count value is incremented by 1 in each cycle task execution. When the current count value is greater than or equal to the number of discrete task executions, the next continuous frame is sent and the current count value is reset to 0; the instruction execution order inside the cycle task is as follows: first, safety-critical control instructions, including braking control instructions, motor action control instructions, and valve action control instructions, are executed; after the safety-critical control instructions are executed, the CAN transmission protocol module executes the continuous frame sending logic.
[0024] In a preferred embodiment, in the second operating mode, the active polling-driven timing is executed as follows: After the CAN transmission protocol module sends a continuous frame, it calls the microsecond-level timestamp acquisition interface provided by the underlying hardware timer to read the system timestamp and assign it to the timestamp of the previous continuous frame; then it enters an active polling loop, reading the current system timestamp in each polling iteration, calculating the difference between the current system timestamp and the timestamp of the previous continuous frame to obtain the real-time time difference; when the real-time time difference is less than the high-precision target time difference comparison threshold, polling continues; when the real-time time difference is greater than or equal to the high-precision target time difference comparison threshold, the next continuous frame is sent, and the timestamp of the previous continuous frame is updated to the system timestamp obtained after the current sending is completed; wherein, the polling time interval of the active polling loop is set based on the clock resolution of the underlying hardware timer.
[0025] In a preferred embodiment, the absolute value of the difference between the actual time interval and the theoretical time interval of adjacent consecutive frames is constrained within a preset tolerance deviation threshold; the theoretical time interval is the product of the number of discrete task runs and the execution cycle of the periodic task.
[0026] The technical effects and advantages of the ECU diagnostic continuous frame timing control method for reducing software load rate according to the present invention are as follows:
[0027] 1. This invention addresses the specific application environment of the ECU (Electronic Control Unit) for braking safety components. By acquiring the ECU's operating mode and dynamically switching the timing reference type, in the critical operating phase ensuring safety (the first operating mode), a passive cycle-driven timing method based on the cumulative number of tasks in a statistical cycle is adopted. This greatly eliminates the overhead of high-frequency system calls, minimizes the software load, and effectively ensures the rapid response of the brake motor and valve actions, eliminating potential braking safety hazards. In the software flashing phase (the second operating mode), the method switches to an active polling drive based on microsecond-level system timestamps, precisely meeting the stringent accuracy requirements of rapid flashing for continuous frame transmission intervals.
[0028] 2. Faced with the complex and ever-changing STmin parameters in the diagnostic protocol, this invention no longer adopts a crude direct numerical comparison. Instead, it first decouples the original encoded bytes structurally and extracts the effective values of the time base scale and time multiplier. In particular, in the first operating mode, an innovative magnitude conflict verification mechanism is added. When the diagnostic instrument sends the extreme minimum continuous frame time interval of the second-level scale, the system can actively identify the magnitude conflict between it and the fixed-period task and force it to be mapped to the minimum number of discrete task runs. This mechanism optimizes the task execution time expansion caused by the stacking of multiple frames in a single periodic task from the algorithm's bottom layer.
[0029] 3. To address the frequent communication failures caused by inconsistent timing references between the transmission layer and the application layer in existing technologies, this invention, after determining the timing reference type, forces the timing references of the CAN transmission protocol module and the diagnostic communication management module to be globally synchronized. This architecture-level design ensures that the two modules always operate under the same time reference system and timing granularity, optimizing the cumulative time determination deviation caused by the difference in granularity between the task counter (millisecond level) and the system timestamp (microsecond level) during long-sequence continuous frame transmission. Attached Figure Description
[0030] Figure 1 This is a flowchart illustrating an ECU diagnostic continuous frame timing control method for reducing software load rate according to the present invention.
[0031] Figure 2 This is a schematic diagram illustrating the implementation structure of the ECU diagnostic continuous frame timing control method for reducing software load rate according to the present invention.
[0032] Figure 3 This is the timing sequence for continuous frame timing execution in the dual-operation mode of the present invention. Detailed Implementation
[0033] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0034] Example
[0035] This invention provides a method for controlling continuous frame timing in ECU diagnostics to reduce software load. It is applicable not only to ECUs for braking safety components but also to other automotive ECUs that employ periodic task scheduling and require continuous frame diagnostic transmission. When the length of the response data corresponding to the diagnostic request sent by the diagnostic tool to the ECU exceeds the single-frame carrying capacity, the ECU needs to complete multi-frame data transmission through a continuous frame sequence—a sequence of several data frames sent consecutively after the first frame—which is the standard frame sequence form for multi-frame data transmission in the CAN diagnostic protocol. This method decouples the underlying encoding of diagnostic parameters structurally, aligns the ECU operating mode with the timing reference globally, performs dynamic mapping calculation of the continuous frame transmission trigger threshold based on magnitude and state, and performs timing compensation control for timing execution under heterogeneous physical drive sources. In this embodiment, continuous frame interval control with extremely low software load and controllable deviation is achieved in the first operating mode, while high-precision system timestamps meet the requirements for rapid flashing in the second operating mode. The two modes are seamlessly connected through unified pre-parse and global reference alignment.
[0036] Please see Figure 1 As shown, this invention discloses an ECU diagnostic continuous frame timing control method for reducing software load, comprising the following steps:
[0037] Step 1: The CAN transmission protocol module receives the flow control frame sent by the diagnostic instrument and extracts the original encoded byte value of the minimum consecutive frame time interval parameter; it performs encoding interval assignment determination on the original encoded byte value, and decouples it into the time reference scale of the time magnitude partition and the effective value of the time multiplier of the identification multiplier coefficient based on the encoding interval it falls into.
[0038] During multi-frame data communication between the diagnostic tool and the ECU, the diagnostic tool sends a diagnostic request to the ECU. When the length of the ECU's response data exceeds the single-frame carrying capacity, the ECU's CAN transmission protocol module sends the first frame. Subsequently, the diagnostic tool generates a flow control frame and sends it to the ECU based on its own receiving capabilities and communication rhythm requirements. The flow control frame contains the original encoded byte value of the minimum consecutive frame time interval parameter, which is denoted as... The STmin parameter, extracted from the flow control frame, is the original byte used to instruct the ECU on the minimum time interval requirement that must be met between consecutive adjacent frames. After receiving the flow control frame, the CAN transmission protocol module extracts the STmin parameter from the byte positions specified by the communication protocol within the frame data. For example, in this embodiment, after receiving the flow control frame, the CAN transmission protocol module extracts the 3rd byte specified in the CAN diagnostic protocol ISO15765-2 from the frame data. ;
[0039] Extracting the original encoded byte values Then, and before entering any timing branch, the CAN transmission protocol module processes the raw encoded byte values. Perform a unified underlying encoding scale parsing operation; the purpose of this parsing operation is to: characterize different time scales according to the magnitude partitioning characteristics defined in the STmin encoding structure in the communication protocol, i.e., different value ranges of the same byte; and to convert the original encoded byte values... A coupled single-byte raw code is decoupled into two independent state variables, defined as a time base scale and a time multiplier effective value, respectively. The time base scale identifies the time magnitude partition to which the raw code belongs, and the time multiplier effective value identifies the multiplier coefficient within that magnitude. After decoupling, the two state variables are stored independently and used as standardized pre-inputs for subsequent cross-mode calculations, so that subsequent steps do not need to repeat the magnitude judgment logic of the raw code.
[0040] The coding scale parsing is based on the following predefined coding interval partitioning parameters, defining the starting value of the first effective coding interval. The effective starting position of its first-order coding partition is initially set to 0x00; the termination value of the first effective coding interval is defined. This is the effective coding termination position of the first-order coding partition, initially set to 0x7F; the starting value of the second effective coding interval is defined. This represents the effective starting position of the second-order coding partition, initially set to 0xF1; the termination value of the second effective coding interval is defined. This is the effective coding termination position of the second-order coding partition, initially set to 0xF9; the second coding interval offset base value is defined. , which is the offset reference value that needs to be subtracted when extracting the effective multiplier coefficient from the original code of the second-order coding partition, and the initial value is set to 0xF0;
[0041] Time base scale It is a dimensionless integer identifier used to represent the original encoded byte value. The time-scale encoding partition; this invention addresses the original encoded byte values. This is achieved by performing a code range attribution determination, which involves determining the original encoded byte value. The value is compared with the predefined encoding intervals to determine the corresponding magnitude partition identifier based on the interval it falls into; specifically, when the original encoded byte value The value falls within the starting value of the first valid coding interval. and the termination value of the first valid coding interval Within the first valid coding interval defined When the value is determined to belong to the first-order coding partition, the time base scale is adjusted. Assigning a value of 1 defines it as the first-level scale, representing a time interval partition with a larger time granularity as the basic unit of measurement;
[0042] When the original encoded byte value The value falls within the starting value of the second valid coding interval. Second effective coding interval termination value Within the defined second valid coding interval, i.e. When this value is determined to belong to the second-order coding partition, the time base scale is adjusted. The value is assigned to 2, which is defined as the second-level scale, representing the time interval partition with a smaller time granularity as the basic unit of measurement;
[0043] For the original encoded byte value The case where the value falls neither in the first valid encoding interval nor in the second valid encoding interval, i.e., the original encoded byte value. The encoding range outside the two valid encoding ranges mentioned above belongs to the reserved encoding segment defined by the protocol; the CAN transmission protocol module will uniformly assign the byte values of the reserved encoding segment to the termination value of the first valid encoding range. Perform substitution processing, i.e., time base scaling. Take 1; For example, the alternative processing of the reserved coded segment is the real-time synchronous trigger operation in the flow control frame parsing stage, which is completed within 5μs after the original coded byte value is extracted, and this processing only occupies 1 CPU clock cycle and will not affect the real-time communication performance of the ECU.
[0044] It should be noted that the division of the first and second valid encoding intervals is based on the single-byte encoding specification of the STmin parameter in the ISO15765-2:2016 protocol. The initial values of STmin, 0x00 to 0x7F, correspond to time intervals in the millisecond range, and 0xF1 to 0xF9 correspond to time intervals in the 100μs range. This is fully compatible with the encoding rules specified in the protocol.
[0045] In an exemplary embodiment of the present invention, for the application scenario of the CAN diagnostic protocol ISO15765-2, the starting value of the first effective encoding interval is... That is, the original encoded byte value The minimum value is set to 0x00, which is the termination value of the first valid coding interval. The initial value is set to 0x7F, which is the starting value of the second effective coding interval. The initial value is set to 0xF1, which is the termination value of the second effective coding interval. The initial value is set to 0xF9. At this time, the first effective coding range is 0x00 to 0x7F, the second effective coding range is 0xF1 to 0xF9, and the reserved coding range is 0x80 to 0xF0 and 0xFA to 0xFF.
[0046] Effective value of time multiplier It is a dimensionless positive integer representing the scale of the current time base. At the corresponding order of magnitude, the multiple of the reference unit contained in the minimum consecutive frame time interval; when the time reference scale When equal to 1, the original encoded byte value The value directly corresponds to the effective multiplier within the first effective coding interval, without the need for offset conversion, and the original coded byte value is... The value is directly assigned to the effective value of the time multiplier. When the current time base scale When equal to 2, the original encoded byte value The encoding offset reference, which includes the second-order-of-magnitude encoding partition, needs to be removed to obtain the effective multiplier coefficient. The original encoded byte values... Subtract the second coding interval offset base value The result is then assigned to the effective value of the time multiplier. The above extraction rules are expressed as a formula:
[0047]
[0048] Furthermore, define the first-level scale time reference unit. The initial value is set to 1ms, representing the physical time amount corresponding to each multiplier unit under the first-level scale; and the time base unit for the second-level scale is defined. Its initial value is set to 100 μs, representing the amount of physical time corresponding to each multiplier unit under the second-level scale; thus, the actual physical time corresponding to the STmin parameter. Effective value of time multiplier The result is obtained by multiplying the time base unit corresponding to its scale, expressed by the formula: In the formula To scale with the current time base The corresponding time base unit, i.e. hour Pick , hour Pick ;
[0049] To illustrate the execution process of this step, in a specific implementation scenario, the initial values of the parameters for dividing each encoding interval are taken, i.e. , , , , Assuming the flow control frame sent by the diagnostic instrument contains... The decimal value of 0x14 is 20, which satisfies... (0x00)≤0x14≤ If the condition (0x7F) falls within the first valid encoding interval, the logic is determined based on the time base scale. Based on the logic of determining the effective value of the time multiplier, we get According to the actual physical time formula, This indicates that the diagnostic tool requires the ECU to send consecutive frames at intervals of not less than 20ms; assuming The value is 0xF3, which satisfies... (0xF1)≤0xF3≤ If the condition (0xF9) falls within the second valid encoding range, the same judgment will be made. , (0xF0) = 3, This indicates that the diagnostic tool requires the ECU to send consecutive frames at intervals of not less than 300 μs; assuming The value is 0x85, which does not satisfy the condition. Since 0x85 > 0x7F, it also does not satisfy the condition. Since 0x85 < 0xF1, it belongs to the reserved coding segment, and the CAN transmission protocol module will process it according to... Perform alternative processing. Take 1, Taking 0x7F is equivalent to 127 in decimal. After completing the above analysis, the CAN transmission protocol module will scale the time base. Effective value of time multiplier It is stored as an independent state variable for direct reference in subsequent steps.
[0050] Please see Figure 2 As shown, step two: obtain the ECU operating mode identifier and determine the timing reference type. The first operating mode corresponds to the task counter timing method based on the periodic task scheduler, and the second operating mode corresponds to the system timestamp timing method based on the underlying hardware timer; simultaneously configure the timing reference of the CAN transmission protocol module and the diagnostic communication management module as the timing reference type;
[0051] After completing the underlying coding scale parsing in step one and obtaining the time reference scale Effective value of time multiplier Next, the system enters the operating mode identification and global timing reference architecture alignment stage. The core task of this step is to determine the current operating mode of the ECU and, based on this operating mode, uniformly configure the same type of timing reference for the CAN transmission protocol module and the diagnostic communication management module, thus building a consistent timing environment from the diagnostic application layer to the transmission protocol layer. Specifically:
[0052] Define the running mode identifier , is an integer variable used to identify the current operating mode of the ECU; the ECU has two operating modes: a first operating mode and a second operating mode; in this embodiment, the first operating mode is the normal working state of the ECU running the application, i.e., APP mode. In this mode, the ECU performs safety-critical tasks including braking control, motor action control, and valve action control. The operating system schedules the operation of each task module at a fixed cycle and has strict constraints on the software load rate; the software load rate is directly related to safety-critical indicators such as braking response time, motor action response time, and valve action response time. Excessive software load will prolong the response time of the above indicators, bringing braking safety hazards; the second operating mode is a special working state of the ECU performing software flashing, i.e., Bootloader mode. In this mode, the ECU does not perform conventional safety-critical tasks, the operating system scheduling structure is simplified, and the constraints on the software load rate are more relaxed, but there are high requirements for the speed and accuracy of diagnostic communication to meet the needs of rapid flashing;
[0053] The CAN transmission protocol module obtains the current operating mode of the ECU by calling the mode query interface provided by the ECU operating system, such as Os_GetEcuRunMode(), and then... The value is assigned to the corresponding operating mode identifier: when the ECU is in the first operating mode, the operating mode identifier is... The value is assigned to 1; when the ECU is in the second operating mode, the operating mode identifier is... The value is assigned to 2. It should be noted that the Os_GetEcuRunMode() interface has no input parameters and returns an 8-bit unsigned integer. Returning 0x01 indicates the first running mode and returning 0x02 indicates the second running mode.
[0054] Define the timing reference type It is an integer variable used to identify the type of timing mechanism to be used; this method sets two timing reference types: a first timing reference and a second timing reference; the first timing reference is... This is a task counter timing method based on the operating system's periodic task scheduler. It relies on the operating system's fixed-period task triggering mechanism for timing, with the timing granularity equal to the execution cycle of the periodic task. The transmission protocol module itself does not actively call the system time interface, resulting in extremely low software overhead. The second timing reference is... This is a system timestamp timing method based on the underlying hardware timer. It obtains the microsecond-level timestamp by reading the current count value of the hardware timer. It has high timing accuracy, but each time the timestamp is obtained, a system call needs to be executed, which will generate a certain increase in software load.
[0055] Timing reference type Identified by operating mode It is determined that the mapping relationship is: when When equal to 1, The value is assigned to 1, meaning the first timing reference is used in the first operating mode; when When equal to 2, The value is assigned to 2, meaning that the second timing reference is used in the second operating mode;
[0056] Determining the type of timing reference Afterwards, the system performs a global reference architecture alignment operation. The timing reference is synchronized and configured to the CAN transmission protocol module and the diagnostic communication management module through the global shared register 0x1008. This register is a 32-bit read and write register. After writing the timing reference type value into this register, the two modules achieve the unification of the timing reference by reading the register value in real time. The read and write response time of the register is less than 1μs.
[0057] Define the timing reference of the CAN transmission protocol module as Define the timing reference for the diagnostic communication management module as follows: The execution rule for global baseline architecture alignment is: to... and All are assigned the currently determined value. This value ensures that both modules use the exact same type of timing reference in the same operating mode; expressed by the formula: ;
[0058] It should be noted that in the ECU diagnostic communication link, the CAN transmission protocol module is responsible for timing control of continuous frame transmission, while the diagnostic communication management module is responsible for monitoring response timeouts and managing sessions at the diagnostic service layer. If the two modules use different types of timing references; for example, the CAN transmission protocol module uses a task counter while the diagnostic communication management module uses a system timestamp, then their timing granularity and time reference source will differ: the task counter's timing granularity is the periodic task execution cycle, i.e., on the order of milliseconds, while the system timestamp's timing granularity is the hardware timer resolution, i.e., on the order of microseconds. During long-sequence continuous frame transmission, this difference in timing granularity will cause the two modules to have different timing reference sources. Over time, accumulated deviations may occur, potentially causing the diagnostic communication management module to trigger a response timeout (P2Server timeout) before the CAN transmission protocol module has completed sending all consecutive frames. This timeout is the maximum timeout period specified in the CAN diagnostic protocol ISO15765-3 for the diagnostic communication management module to wait for the CAN transmission protocol module to complete the transmission of consecutive frames. If this timeout is exceeded, the diagnostic session is deemed abnormal and communication is terminated, resulting in abnormal termination of the diagnostic session and communication interruption. By using global alignment, both modules always operate under the same time reference system and the same timing granularity, fundamentally eliminating the risk of accumulated deviations caused by inconsistencies in cross-module timing references.
[0059] For example, when the ECU powers on and enters normal operating mode to run the application, the mode query interface returns the first operating mode, which the system recognizes. ,but ,according to Will and Both are configured to 1, meaning that the CAN transmission protocol module and the diagnostic communication management module both use a task counter timing method based on a periodic task scheduler, and all timing logic operates with the periodic task execution cycle as the smallest timing granularity; when the ECU receives a flashing request and enters the software flashing process, the system identifies... Based on this, the type of timing reference is determined. The timing reference of the CAN transmission protocol module Timing reference for diagnostic communication management module All are configured with a system timestamp timing method based on the underlying hardware timer, supporting high-frequency continuous frame transmission and accurate service timeout monitoring during the fast writing process with microsecond-level precision;
[0060] The above-mentioned pattern recognition and reference alignment operations are performed once every time the ECU starts, and are also re-executed when the ECU operating mode changes, such as when switching from the first operating mode to the second operating mode for flashing, or when switching back from the second operating mode to the first operating mode after flashing, to ensure that the global timing reference is always synchronized with the current operating mode.
[0061] Step 3: Based on the effective value of the time base scale and the time multiplier, and combined with the operation mode identifier, the trigger threshold is sent; in the first operation mode, the time base scale and the periodic task execution cycle are checked for conflict of magnitude and mapped to the number of discrete task runs; in the second operation mode, it is mapped to the high-precision target time difference comparison threshold.
[0062] After completing step two, which involves identifying the operating mode and aligning with the global baseline architecture, the system enters the dynamic mapping calculation phase for timing thresholds. The core task of this step is to combine the time baseline scale extracted in step one. Effective value of time multiplier and the operating mode identifier determined in step two. and timing reference type Map the STmin parameter to a specific send trigger threshold that matches the current timing reference type;
[0063] Because the two timing benchmarks differ fundamentally in their physical driving mechanisms and numerical representation dimensions—the first timing benchmark uses discrete task cycle runs as its timing unit, while the second timing benchmark uses continuous microsecond-level absolute time values—the same set of state variables output from step one ( , Different mapping paths are required to generate thresholds that can be directly used for numerical comparison and determination under their respective timing benchmarks; the specific logic of threshold mapping is explained below according to the two operating modes:
[0064] When the running mode is identified When the value equals 1, the system adopts the first timing reference, and the transmission interval of consecutive frames is controlled by the number of times the periodic task is run; the execution period of the periodic task is defined. Its initial value is set to 10ms, representing the fixed scheduling interval of the periodic tasks carried out by the CAN transmission protocol module in the operating system; and the minimum period count of the consecutive frame interval in the first running mode is defined as the minimum number of runs. Its initial value is set to 1, indicating that under any circumstances, at least one cycle task must be completed before the next consecutive frame can be sent. Even if the time interval required by the STmin parameter is less than one cycle task execution cycle, the system will not send multiple consecutive frames in the same cycle task to avoid the task execution time from being bloated due to the superposition of multiple frame sending operations in a single task, thereby affecting key safety indicators; the minimum number of runs Its initial value can be determined based on the ECU's periodic task execution cycle. Dynamic adjustment, for example, based on the ratio of the ECU's actual cyclic task execution cycle to the industry-standard benchmark cycle of the ECU's safety-critical tasks, such as 10ms.
[0065] Calculating the number of times a discrete task is run First, a magnitude conflict check is performed; the purpose of the magnitude conflict check is to determine the time reference scale extracted in step one. Whether the time granularity represented is consistent with the time granularity of the currently used first timing benchmark, i.e., the execution cycle of the periodic task. There are irreconcilable differences in magnitude between them; define a magnitude conflict flag. It is a Boolean variable, and its determination rule is: when the time base scale is... When the value is 2, the STmin parameter is in the second-order coding partition. The maximum value is the termination value of the second effective coding interval. Subtract the second coding interval offset base value The effective value of the time multiplier obtained The maximum value and The product of the two, taking the initial value and substituting it into the equation equals... ,and The difference between the two is more than an order of magnitude, with a time reference of 10ms. Physically, the first timing reference cannot provide a timing resolution matching the microsecond level. If TRUE, it is marked as a magnitude conflict; when When STmin equals 1, it is in the first-order coding partition, and its granularity is... If they are within the same order of magnitude and do not constitute a conflict of magnitudes, then... FALSE;
[0066] In terms of magnitude conflict Once determined, define the periodic task periodic counting unit. For periodic task execution cycle Compared with the first-level scale time base unit The ratio, i.e. Calculate the number of times the discrete task is run according to the following rules. :
[0067] Equivalent magnitude conflict flag When set to TRUE, there is a magnitude conflict. Forced assignment Equivalent magnitude conflict flag For FALSE and Less than hour, Less than Similarly, Assigned value Equivalent magnitude conflict flag For FALSE and Greater than or equal to hour, Pick and The ratio is rounded up; the above calculation rule is expressed by the formula:
[0068] In the formula, This represents the floor function operator; it should be noted that... The reason for choosing to round up rather than round down or to the nearest integer is that STmin defines the minimum consecutive frame time interval, meaning the actual interval cannot be less than STmin; if If we round down, the actual interval is... Possibly smaller This violates the minimum interval constraint of the protocol; rounding up ensures... Always greater than or equal to This satisfies the minimum interval requirement;
[0069] An example illustrating the threshold mapping process in the first operating mode: When , hour, For FALSE, , ,but That is, it waits for 3 cycle task runs before sending the next consecutive frame, with an actual interval of about 30ms, which is greater than STmin=25ms; when , hour, For FALSE, , , The actual interval is approximately 10ms, which is greater than STmin = 5ms; when , hour, TRUE The actual interval is about 10ms, which is greater than STmin=300μs; the actual interval in all three cases meets the minimum interval requirement of STmin.
[0070] When the running mode is identified When the value equals 2, the system adopts the second timing reference, and the transmission interval of consecutive frames is controlled by comparing the time difference of the system timestamps; at this time, the data extracted in step one needs to be... and The time threshold should be converted to an absolute time threshold in microseconds, and the conversion process should only involve integer operations to avoid introducing the computational overhead and precision uncertainty caused by floating-point operations.
[0071] Define the first-order scale microsecond conversion factor Its initial value is set to 1000, representing the coefficient for converting each multiplier unit to microseconds under the first-level scale, for example, 1 ms equals 1000 μs; the microsecond conversion coefficient for the second-level scale is defined. Its initial value is set to 100, representing the coefficient for converting each multiplier unit to microseconds under the second-level scale; for example, 100μs equals 100μs. This will be compared with the current time base scale. The corresponding microsecond conversion factor is denoted as ,Right now hour Pick , hour Pick ;
[0072] The continuous frame transmission trigger threshold in the second operating mode is defined as the high-precision target time difference comparison threshold. The calculation method is as follows: the effective value of the time multiplier. The microsecond conversion factor corresponding to its scale Multiplying these yields a positive integer threshold in microseconds; expressed by the formula: This calculation process involves only one integer multiplication operation and requires no floating-point operations; the calculation result... It is a positive integer in microseconds;
[0073] An example illustrating the threshold mapping process in the second operating mode: When , hour, ,but That is, 20ms; when , hour, ,but ;
[0074] After completing the above mapping, the system passes the corresponding threshold to step four based on the current operating mode: passing the number of discrete task runs in the first operating mode. In the second operating mode, the high-precision target time difference comparison threshold is transmitted. Each of these serves as the trigger criterion for sending in its respective timing execution logic.
[0075] Step 4: After sending consecutive frames, in the first operating mode, the cumulative number of runs of the periodic task is counted and compared with the number of runs of the discrete task to achieve passive periodic driving timing; in the second operating mode, the real-time time difference of the system timestamp is compared with the high-precision target time difference comparison threshold to achieve active polling driving timing; when the corresponding threshold condition is met, the next consecutive frame is triggered to be sent.
[0076] Please see Figure 3 As shown in the timing diagram of continuous frame timing execution under dual operation modes, the timing sequence of the first operation mode is triggered by the scheduling of periodic tasks, with safety-critical instructions executed first and continuous frame transmission logic executed later. The transmission interval between adjacent continuous frames is N periodic task execution cycles. The timing sequence of the second operation mode is triggered by the reading of the timestamp of the hardware timer. The polling interval is determined based on the clock resolution of the ECU's underlying hardware timer and satisfies the dual constraints of timing accuracy and software load control. When the real-time time difference reaches the high-precision target time difference comparison threshold, continuous frame transmission is triggered immediately without task scheduling delay. Specifically:
[0077] When the timing reference type When the value equals 1, the CAN transmission protocol module runs within a fixed-cycle task of the operating system. The execution cycle of this task is... The CAN transmission protocol module itself does not actively acquire any time information. Instead, it achieves timing by counting the cumulative number of times the task in its cycle is scheduled and executed by the operating system scheduler. Its physical driving source for timing comes entirely from the periodic triggering of the operating system scheduler, which is a passive timing driver.
[0078] Define the current count value This is a non-negative integer variable used to record the cumulative number of times the periodic task has been scheduled and executed since the completion of the last consecutive frame transmission; the specific execution flow is as follows: the CAN transmission protocol module, in a certain instance... Successfully sent consecutive frames during the execution of the periodic task After that, where is the sequence index identifier of the consecutive frames, which is a dimensionless positive integer used to characterize the transmission order of consecutive frames in multi-frame transmission. This represents the i-th consecutive frame. This indicates the (i+1)th consecutive frame that follows, which consists of two adjacent frames in the consecutive frame sequence.
[0079] Set the current count value Initialize to 0; during each subsequent cycle of task execution, the CAN transmission protocol module will update the current count value. Increment by 1, then return the current count value. The number of discrete task runs calculated in step three Comparison and determination: when the current count value Less than If the timing is not yet complete, the CAN transmission protocol module will not perform continuous frame transmission in this cycle task, and will wait for the scheduling trigger of the next cycle task; when the current count value... Greater than or equal to When the timing is complete, the CAN transmission protocol module immediately triggers the next consecutive frame. Send, and simultaneously send the current count value. Reinitialize to 0 and begin the next round of timing; the above judgment condition can be expressed by the formula shown below: ;
[0080] In the above passive periodic drive process, consecutive frames and The actual time interval between Its theoretical value is However, within the cyclic tasks of the braking safety component ECU, the CAN transmission protocol module is not at the forefront of the task execution sequence. Based on the design principle of prioritizing braking safety, the instruction execution order within the cyclic tasks strictly follows the following arrangement: first, safety-critical control instructions directly related to ECU actions, including brake motor action control instructions and valve action control instructions, are executed; only after all the above control instructions have been executed does the CAN transmission protocol module begin to run its continuous frame transmission logic. Placing safety-critical control instructions before the CAN transmission protocol module ensures that the action control of the brake motor and valves is given priority in each cyclic task, and their response time is not delayed due to the continuous frame transmission operation of diagnostic communication.
[0081] Because the execution time of the brake motor action control command and the valve action control command will fluctuate slightly during different cycle tasks due to differences in control target values, sensor sample values, and control branch logic, this fluctuation will be transmitted to the actual start execution time of the CAN transmission protocol module, causing the difference between the transmission times of two adjacent consecutive frames to deviate from the theoretical value. A small deviation occurs between them; this small deviation is defined as... This refers to the absolute difference between the actual time interval of consecutive frames and the theoretical interval; and a preset tolerance deviation threshold is defined. The initial value is set at 38μs. This is based on the execution time of three types of safety-critical commands—braking control, motor action control, and valve action control—under 1000 typical operating conditions (idle, braking, and acceleration) on an ECU hardware platform with a CPU frequency of 80MHz and memory of 128KB. The maximum value of the execution time fluctuation is obtained by statistically analyzing the execution time of all control commands preceding the CAN transmission protocol module in the cyclic tasks of the braking safety component ECU under various operating condition combinations. The upper limit of the execution time fluctuation range obtained is the preset tolerance deviation threshold. The deviation constraint can be expressed as a formula as shown below: ;
[0082] The above-mentioned preset tolerance deviation threshold The magnitude is 38 μs, which is at least one time interval relative to the actual response interval of the STmin parameter in the first operating mode. In this case, its proportion is no more than 0.38%, which is within the acceptable receiving time window of the diagnostic instrument. It will not trigger the frame timeout judgment or frame receiving sequence abnormality on the diagnostic instrument side, so it will not affect the normal operation of diagnostic communication. At the same time, since the entire timing process relies entirely on the periodic triggering of the operating system scheduler and one integer comparison operation, the CAN transmission protocol module itself does not perform any system timestamp reading calls, does not introduce additional system call overhead, maintains the low software load rate characteristics of the first operating mode, and ensures that key safety indicators such as brake motor action response time and valve action response time are not affected by diagnostic communication.
[0083] When the timing reference type When the value equals 2, the CAN transmission protocol module uses a microsecond-level system timestamp provided by the underlying hardware timer for active timing; it also defines the transmission timestamp of the previous consecutive frames. This is a positive integer variable in microseconds, used to record the system timestamp value of the time when the previous consecutive frame was completed; it also defines the current system timestamp. The real-time timestamp value is the system's current timestamp value obtained in real time by the CAN transmission protocol module; therefore, the real-time time difference... Current system timestamp Timestamp of the previous consecutive frame The difference; the specific execution process is as follows:
[0084] After the CAN transmission protocol module has sent consecutive frames Then, immediately call the microsecond-level timestamp retrieval interface provided by the underlying hardware timer, such as Timer_GetUsTimestamp(void). This interface has no input parameters and returns a 32-bit unsigned integer in microseconds, representing the current cumulative count value of the hardware timer. Read the current microsecond-level system timestamp and assign it to the timestamp of the previous consecutive frame. Subsequently, the CAN transmission protocol module enters an active polling loop: in each polling iteration, it calls the microsecond-level timestamp acquisition interface to read the current system timestamp. Calculate real-time time difference and will The threshold is compared with the high-precision target time difference calculated in step three. Perform numerical comparisons; when real-time time difference Less than the high-precision target time difference comparison threshold If the timeout period has not yet been completed, proceed to the next round of polling; if the real-time time difference... Greater than or equal to the high-precision target time difference comparison threshold When the timing is complete, the CAN transmission protocol module immediately triggers the next consecutive frame. Send, and include the timestamp of the previous consecutive frame. Update to the system timestamp re-acquired after this transmission is completed, and enter the next round of timing wait; the above real-time time difference calculation and trigger judgment conditions are expressed by the formula shown below:
[0085] ;
[0086] It should be noted that in this embodiment, the polling interval of the active polling-driven timing is initially set to 50μs. This interval is determined by the clock resolution of the underlying hardware timer, and the polling operation only includes one timestamp reading and one integer subtraction operation. The CPU overhead of a single polling iteration is less than 1μs.
[0087] The accuracy of this timing method depends on the clock resolution of the underlying hardware timer. With the support of microsecond-level timestamps, the actual interval between consecutive frames is... The deviation can be controlled at the microsecond level, which can accurately meet the interval accuracy requirements of high-frequency continuous frame transmission for rapid software writing in the second operating mode. Since the ECU does not perform conventional safety-critical tasks such as brake motor control and valve action control in the second operating mode, the software load increment caused by frequent reading of system timestamps will not affect any safety-critical indicators.
[0088] The above formulas are all dimensionless calculations. The formulas are derived from software simulations based on a large amount of collected data to obtain the most recent real-world results. The preset parameters in the formulas are set by those skilled in the art according to the actual situation.
[0089] The above embodiments can be implemented, in whole or in part, by software, hardware, firmware, or any other combination thereof. When implemented using software, the above embodiments can be implemented, in whole or in part, in the form of a computer program product.
[0090] Those skilled in the art will recognize that the modules and algorithm modules of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and inventive constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0091] In addition, the functional modules in the various embodiments of this application can be integrated into one processing module, or each module can exist physically separately, or two or more modules can be integrated into one module.
[0092] The above are merely specific embodiments of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
[0093] In conclusion, the above are merely preferred embodiments of the present invention and are not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A method for ECU diagnostic continuous frame timing control to reduce software load, characterized in that, The process includes the following steps: receiving the flow control frame sent by the diagnostic instrument and extracting the original encoded byte value of the minimum consecutive frame time interval parameter; performing encoding interval attribution determination on the original encoded byte value, and decoupling it into the effective value of the time reference scale for identifying the time magnitude partition and the time multiplier for identifying the multiplier coefficient based on the encoding interval it falls into; Obtain the ECU operating mode identifier and determine the timing reference type. The first operating mode corresponds to the task counter timing method based on the periodic task scheduler, and the second operating mode corresponds to the system timestamp timing method based on the underlying hardware timer. Simultaneously configure the timing reference of the CAN transmission protocol module and the diagnostic communication management module to the timing reference type; Based on the time base scale and the effective value of the time multiplier, and combined with the operation mode identifier, a sending trigger threshold is mapped; In the first operating mode, a magnitude conflict check is performed based on the time base scale and the periodic task execution cycle, and the minimum consecutive frame time interval is mapped to the number of discrete task runs based on the check result. In the second operating mode, the minimum consecutive frame time interval is mapped to the high-precision target time difference comparison threshold. After sending consecutive frames, in the first running mode, the cumulative number of runs of the periodic task is counted and compared with the number of runs of the discrete task to achieve passive periodic driving timing. In the second operating mode, the real-time time difference of the system timestamp is compared with the high-precision target time difference comparison threshold to achieve active polling-driven timing; when the corresponding threshold condition is met, the next consecutive frame is triggered to be sent.
2. The ECU diagnostic continuous frame timing control method for reducing software load rate according to claim 1, characterized in that, The determination of the coding interval is based on predefined coding interval division parameters: the coding interval division parameters include the first effective coding interval start value and the first effective coding interval end value that define the first effective coding interval, and the second effective coding interval start value and the second effective coding interval end value that define the second effective coding interval; The rules for determining the time base scale are as follows: when the value of the original encoded byte is greater than or equal to the starting value of the first effective encoding interval and less than or equal to the ending value of the first effective encoding interval, the value of the original encoded byte falls into the first effective encoding interval, and the time base scale is assigned a value of 1, which is defined as the first-level scale, representing the time interval partition with a larger time granularity as the basic unit of measurement; when the value of the original encoded byte is greater than or equal to the starting value of the second effective encoding interval and less than or equal to the ending value of the second effective encoding interval, the value of the original encoded byte falls into the second effective encoding interval, and the time base scale is assigned a value of 2, which is defined as the second-level scale, representing the time interval partition with a smaller time granularity as the basic unit of measurement.
3. The ECU diagnostic continuous frame timing control method for reducing software load rate according to claim 2, characterized in that, When the value of the original encoded byte falls neither into the first valid encoding interval nor the second valid encoding interval, the value of the original encoded byte belongs to the reserved encoding segment. The CAN transmission protocol module replaces the original encoded byte value of the reserved encoding segment with the termination value of the first valid encoding interval, takes the time base scale as 1, and takes the effective value of the time multiplier as the value corresponding to the termination value of the first valid encoding interval.
4. The ECU diagnostic continuous frame timing control method for reducing software load rate according to claim 1, characterized in that, The extraction rules for the effective value of the time multiplier are as follows: when the time base scale is the first level scale, the value of the original encoded byte value is directly assigned to the effective value of the time multiplier; when the time base scale is the second level scale, the result of subtracting the predefined second encoding interval offset base value from the original encoded byte value is assigned to the effective value of the time multiplier; where the second encoding interval offset base value is the offset base value that needs to be subtracted when extracting the effective multiplier coefficient from the original encoded byte value of the second-level encoding partition; The actual physical time corresponding to the minimum consecutive frame time interval parameter is obtained by multiplying the effective value of the time multiplier with the time base unit corresponding to the current time base scale, where the first-level scale corresponds to the first-level scale time base unit and the second-level scale corresponds to the second-level scale time base unit.
5. The ECU diagnostic continuous frame timing control method for reducing software load rate according to claim 1, characterized in that, The first operating mode is the normal working state of the ECU running the application. In this state, the ECU performs safety-critical tasks including braking control, motor motion control, and valve motion control. The operating system schedules the operation of each task module at a fixed cycle. The second operating mode is the working state in which the ECU performs software flashing. In this state, the ECU does not perform the aforementioned safety-critical tasks. The operating mode identifier is obtained by calling the mode query interface provided by the ECU operating system. The operating mode identifier is assigned a value of 1 in the first operating mode and a value of 2 in the second operating mode. In the task counter timing method based on the periodic task scheduler, the CAN transmission protocol module itself does not actively call the system time interface; the system timestamp timing method based on the underlying hardware timer obtains the microsecond-level timestamp by reading the current count value of the hardware timer.
6. The ECU diagnostic continuous frame timing control method for reducing software load rate according to claim 1, characterized in that, Scale conflict verification is performed by defining a scale conflict flag: the scale conflict flag is a Boolean variable that indicates whether there is an irreconcilable scale difference between the time granularity represented by the time reference scale and the execution cycle of the periodic task; when the time reference scale is a second-level scale, the minimum continuous frame time interval parameter is in the microsecond range, and there is a scale difference of more than one order of magnitude between it and the execution cycle of the periodic task, the scale conflict flag is judged as TRUE; when the time reference scale is a first-level scale, the two are in the same scale range, the scale conflict flag is judged as FALSE.
7. The ECU diagnostic continuous frame timing control method for reducing software load rate according to claim 6, characterized in that, The minimum number of runs is defined as the lowest period count of consecutive frame intervals in the first running mode, and the period count unit of the periodic task is defined as the ratio of the periodic task execution period to the time base unit of the first-level scale; where the time base unit of the first-level scale is the time base unit corresponding to the first-level scale. The calculation rules for the number of discrete task runs are as follows: when the magnitude conflict flag is TRUE, the number of discrete task runs is assigned to the minimum number of runs; when the magnitude conflict flag is FALSE and the effective value of the time multiplier is less than the periodic count unit of the periodic task, the number of discrete task runs is assigned to the minimum number of runs; when the magnitude conflict flag is FALSE and the effective value of the time multiplier is greater than or equal to the periodic count unit of the periodic task, the number of discrete task runs is the rounded-up value of the ratio of the effective value of the time multiplier to the periodic count unit of the periodic task.
8. The ECU diagnostic continuous frame timing control method for reducing software load rate according to claim 1, characterized in that, In the first operating mode, the passive cycle-driven timing is executed as follows: the current count value is defined as a non-negative integer counter that records the cumulative number of times the cycle task has been scheduled for execution; After the CAN transmission protocol module sends a continuous frame, it initializes the current count value to 0. Thereafter, the current count value is incremented by 1 in each periodic task execution. When the current count value is greater than or equal to the number of discrete task runs, the next continuous frame is sent and the current count value is reset to 0. The instruction execution order within the periodic task is as follows: first, safety-critical control instructions, including braking control instructions, motor action control instructions, and valve action control instructions, are executed. After the safety-critical control instructions are executed, the CAN transmission protocol module executes the continuous frame sending logic.
9. The ECU diagnostic continuous frame timing control method for reducing software load rate according to claim 1, characterized in that, In the second operating mode, the execution method of the active polling driven timing is as follows: after the CAN transmission protocol module sends a continuous frame, it calls the microsecond-level timestamp acquisition interface provided by the underlying hardware timer to read the system timestamp and assign it to the sending timestamp of the previous continuous frame. It then enters an active polling loop. In each polling iteration, it reads the current system timestamp and calculates the difference between the current system timestamp and the timestamp of the previous consecutive frame to obtain the real-time time difference. When the real-time time difference is less than the high-precision target time difference comparison threshold, it continues polling. When the real-time time difference is greater than or equal to the high-precision target time difference comparison threshold, it triggers the transmission of the next consecutive frame and updates the timestamp of the previous consecutive frame to the system timestamp obtained after the current transmission is completed. The polling time interval of the active polling loop is set based on the clock resolution of the underlying hardware timer.
10. The ECU diagnostic continuous frame timing control method for reducing software load rate according to claim 8, characterized in that, The absolute value of the difference between the actual time interval and the theoretical time interval of adjacent consecutive frames is constrained within a preset tolerance deviation threshold; the theoretical time interval is the product of the number of times the discrete task runs and the execution cycle of the periodic task.