A rapid off-line calibration method and system for vehicle-mounted s19 files
By combining binary search and sorting optimization of the s19 file Merge process, the problem of low calibration efficiency of s19 files is solved, realizing fast and accurate one-click calibration, which is suitable for various calibration scenarios of vehicle ECUs.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SHAANXI FAST GEAR CO LTD
- Filing Date
- 2026-03-24
- Publication Date
- 2026-07-14
Smart Images

Figure CN122387501A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of automotive electronic control unit software development and testing technology, specifically to a rapid offline calibration method and system for automotive S19 files. Background Technology
[0002] In the development and testing of automotive electronic control unit (ECU) software, APP programs typically exist in two mainstream file formats: s19 files based on Motorola mode (low address first) and Hex files based on Intel mode (high address first). The calibration methods for these two file formats are highly similar. Among them, the calibration efficiency of s19 files, due to their widespread use in automotive ECU development, directly affects the development cycle and testing accuracy of the entire vehicle's electronic control system.
[0003] In the current development of automotive ECUs, offline calibration is the core step in configuring calibration parameters. Accurate positioning and rapid modification of calibration parameters (including types such as VALUE, CURVE, VAL_BLK, AXIS, and MAP) are crucial for offline calibration. The s19 program file inherently exhibits a monotonically increasing address sequence from top to bottom, and various calibration parameters show a specific distribution pattern in the random access memory (RAM) of the automotive microcontroller unit (MCU): VALUE, AXIS, VAL_BLK, MAP, and CURVE calibration parameters have consecutive addresses in the MCU RAM. Looking at the arrangement of calibration parameters in the s19 Record, all bytes of VALUE type variables are concentrated in the same record line. Although AXIS, VAL_BLK, MAP, and CURVE use VALUE as their basic unit, and their core VALUE data is also located in the same record line, other derived VALUE data may be distributed in different records.
[0004] Existing offline calibration methods for S19 files mostly rely on manual location of calibration quantification addresses and line-by-line modification of Record data, or linear traversal for quantification matching. These methods suffer from low calibration efficiency, susceptibility to calibration failures due to address matching errors, and difficulty in adapting to the need for rapid calibration of large batches of quantifications. Although algorithms such as binary search, sorting, and interval convergence are maturely applied in data retrieval and matching, no technology has yet combined these algorithms with the address distribution patterns and calibration quantification arrangement characteristics of S19 files, nor has there been any targeted improvement to the S19Merge process to adapt to rapid calibration scenarios. Summary of the Invention
[0005] To overcome the shortcomings of the existing technology, the present invention aims to provide a fast offline calibration method and system for vehicle-mounted S19 files, so as to solve the technical problem of how to optimize the S19Merge process based on the inherent properties and calibration quantity arrangement rules of S19 files, combined with techniques such as bisection, sorting, and interval convergence, to achieve one-click fast offline calibration of Excel scalar quantities based on A2L files and S19 files.
[0006] This invention is achieved through the following technical solution: In a first aspect, the present invention provides a rapid offline calibration method for vehicle-mounted S19 files, comprising: Step 1: Obtain the data to be labeled and related file information, supplement the information of the variables, and obtain a variable set containing complete information; Step 2: Based on the monotonically increasing property of the s19 file address, sort and preprocess the variable set of complete information to prepare for standardization and rewriting. Step 3: For the first variable after sorting, use the binary search method to determine its Record rewriting position in the s19 file, complete the information field rewriting and establish the Merge table; Step 4: Process the remaining variables after sorting in sequence. Based on the consistency between the Block index of the variable and the previous variable, use the corresponding binary search boundary determination method to locate the rewrite position, complete the information domain rewrite and update the Merge table. Step 5: For the CURVE, AXIS, and VAL_BLK type calibration values, based on their address continuity and Record distribution characteristics, rewrite the information fields of all constituent values and update the Merge table. Step 6: For MAP type calibration, first convert its matrix format into a one-dimensional sequence according to the piecewise linear continuous address rule, and then rewrite the information field and update the Merge table according to the corresponding rule; Step 7: Repeat steps 3 to 6 to complete the calibration of all variables to be calibrated, and obtain the Merge table with monotonically increasing Record positions. Step 8: Use a binary search method to merge the rewritten information in the Merge table into the original s19 file, update the checksum of the corresponding Record, and output the calibrated s19 file to achieve fast offline calibration of the vehicle s19 file.
[0007] Preferably, the specific process of obtaining the target data and related file information in step 1, and supplementing the variables with information to obtain a variable set containing complete information, includes: Step 11: Read the variable names and calibration values to be calibrated from the Excel spreadsheet. The initial format of a single variable is [variable name, variable value]. Step 12: Load the A2L file, read the ECU address, calibration type, and variable data type of the variable, and update the format of a single variable to [variable name, variable value, variable calibration type, variable data type, variable ECU address]; Step 13: Load the s19 file, identify one or more Block regions in the s19 file, obtain the start and end addresses of each Block region, and supplement the Block index for the variable according to the Block region range to which the variable ECU address belongs. The final form of a single variable is [variable name, variable value, variable scalar type, variable data type, variable ECU address, variable Block index], forming a variable set containing complete information.
[0008] Preferably, in step 2, based on the monotonically increasing property of the s19 file address, the variable set of complete information is sorted and preprocessed to prepare for calibration and rewriting. Taking advantage of the monotonically increasing property of the s19 file address from top to bottom, the variable set of complete information is sorted from smallest to largest based on the ECU address of the variable. The sorting result is stored in a table as program variables, which serve as the prerequisite data for subsequent calibration and rewriting.
[0009] Preferably, in step 3, for the first variable after sorting, the binary search method is used to determine its Record rewrite position in the s19 file. The specific process of completing the information field rewrite and establishing the Merge table includes: Step 31: Determine the Block region to which the first variable ECU address belongs, and use the upper boundary of the Block region as the upper boundary of the binary search for the variable. Step 32: Calculate the address offset between the ECU address of the first variable and the upper boundary of the Block area. If the upper boundary of the Block area + the offset > the lower boundary of the Block area, then the right boundary of the bisection is set as the lower boundary of the Block area; otherwise, the upper boundary of the Block area + the offset is used as the right boundary of the bisection. Step 33: Determine the record rewriting position of the first variable in the s19 file using the binary search method, complete the rewriting of the record information field, and obtain the rewritten record information field; Step 34: Create the Merge table. Each row in the Merge table stores the information status as [the information field content of the current Record, the position index of the current Record].
[0010] Preferably, in step 4, the remaining variables after sorting are processed sequentially. Based on the consistency between the Block index of the variable and the previous variable, the corresponding binary search boundary determination method is used to locate the rewrite position. The specific process of completing the information domain rewrite and updating the Merge table is as follows: Step 41: Read the next variable after sorting and determine whether the Block index of the variable is the same as the Block index of the previous processed variable; Step 42, if the Block index is the same: use the Record rewrite position of the previous variable as the left boundary of the binary search for the current variable, and calculate the offset between the ECU address of the current variable and the starting address of the Record of the previous rewrite position; if the starting address of the Record + the offset > the lower boundary of the Block area to which the current variable belongs, then the right boundary of the binary search is set as the lower boundary of the Block area, otherwise the starting address of the Record + the offset is used as the right boundary of the binary search; determine the Record rewrite position of the current variable by binary search; if the current rewrite position is the same as the rewrite position of the previous variable, then directly rewrite based on the information field of the previous rewrite in the Merge table; if the rewrite positions are different, obtain the information field content of the current Record in the s19 file, and insert the rewrite result and the rewrite position into the Merge table after the rewrite is completed; Step 43, if the Block index is different: according to the binary search boundary determination method of the first variable in Step 3, combined with the upper and lower boundaries of the Block area to which the current variable belongs and the address offset, determine the Record rewriting position of the current variable; since the Block areas are different, the current variable and the previous variable must not be in the same row of Record, directly obtain the information field of the current Record to complete the rewriting, and insert the rewriting result and rewriting position into the Merge table.
[0011] Preferably, in step 5, for the CURVE, AXIS, and VAL_BLK type calibration values, based on their address continuity and Record distribution characteristics, the specific process of rewriting the information fields of all constituent values and updating the Merge table is as follows: Step 51: The CURVE, AXIS, and VAL_BLK type values are all composed of several VALUE type values. The addresses of each unit are distributed continuously. All bytes of a single VALUE type value must be located in the same row of Records. Multiple VALUE type values can be located in the same row or multiple consecutive rows of Records. Step 52: Using the address of the first value of the calibrated value in the A2L file as a reference, deduce the addresses of the remaining constituent units according to the data type of the variable. Step 53: Determine the Record rewrite position of the first value according to the algorithm flow of Step 3 and Step 4, convert the first value into a hexadecimal string according to the corresponding data type, rewrite the Record information field and record the rewrite position, and update the Merge table. Step 54: Process the remaining constituent units in sequence and determine whether their addresses are within the Record address range of the first value. If they are, rewrite and update the information field of the corresponding Record in the Merge table directly. If they are not, obtain the Record information field at the Record position + 1 of the first value, and insert the information field content and the rewritten position into the Merge table after rewriting. Step 55: Repeat step 54 to complete the rewriting of all constituent units of the CURVE, AXIS, and VAL_BLK type calibrators.
[0012] Preferably, in step 6, for MAP type calibration quantities, the matrix format is first converted into a one-dimensional sequence according to the piecewise linear continuous address rule, and then the information field is rewritten and the Merge table is updated according to the corresponding rule. The specific process is as follows: Step 61: The MAP type calibration data is presented in a matrix format in an Excel spreadsheet, and its physical addresses are distributed in a continuous line shape. Step 62: Convert the matrix-formatted MAP values in the Excel spreadsheet into a one-dimensional sequence according to the continuous address rule of the broken line. Specifically, based on the ECU address of the first value of the MAP value in the A2L file, the addresses of the remaining constituent units are derived in sequence according to the data type of the variables. The address connection follows the rule of Var1→Var7→Var2→Var8→Var3→Var9→Var4→Var10→Var5→Var11→Var6→Var12. Step 63: Following the rewriting rules for the CURVE type standard in Step 5, rewrite the information fields of all constituent units of the MAP type standard and update the Merge table.
[0013] Preferably, steps 3 to 6 are executed cyclically to calibrate all the variables to be calibrated in the Excel table one by one until all variables are processed, and finally a Merge table is obtained. The Merge table records all the rewritten Record information fields and their corresponding Record positions, and the Record positions in the Merge table show a monotonically increasing trend from top to bottom.
[0014] Preferably, in step 8, the rewritten information in the Merge table is merged into the original s19 file using a binary search method, the checksum of the corresponding Record is updated, and the calibrated s19 file is output. The specific process is as follows: Step 81: Determine the interval [position 1, position n] of the Record position in the Merge table, where position 1 is the smallest Record position in the Merge table and position n is the largest Record position in the Merge table; Step 82: Read the original s19 file into the software memory, iterate through the Record position index of the original s19 file line by line, and determine whether the position index is within the interval [position 1, position n]. Step 83: If the position index is within the interval, use [0, Merge table height - 1] as the left and right boundaries of the binary search, and use the binary search method to find whether there is a Record position in the Merge table that is the same as the current iteration position index; if not found, do not process the original s19 file in memory; if found, replace the information field of the current position of the original s19 file with the information field of the corresponding position in the Merge table, and recalculate the checksum of the Record. Step 84, the checksum calculation process is as follows: add the current Record's offset address, record type, information field, and record length without carry, subtract the addition result from 255 to obtain a new checksum, and update the current Record's checksum with this new checksum; Step 85: If the position index is not within the range, no processing is performed on the original s19 file in memory; Step 86: After all Record position index iterations have been completed, output the merged s19 file from memory. This file is the offline calibrated s19 file.
[0015] Secondly, the present invention also provides a rapid offline calibration system for vehicle-mounted S19 files, used to implement the aforementioned rapid offline calibration method for vehicle-mounted S19 files, comprising: The information acquisition module is used to acquire the data to be labeled and related file information, supplement the information of variables, and obtain a variable set containing complete information. The variable sorting module is used to sort and preprocess the variable set of complete information based on the monotonically increasing property of s19 file address, in order to prepare for standardization and rewriting. The first value calibration module is used to determine the Record rewrite position in the s19 file for the first variable after sorting using a binary search method, complete the information field rewrite and establish the Merge table; The subsequent calibration module is used to process the remaining variables after sorting in sequence. Based on the consistency between the Block index of the variable and the previous variable, the corresponding binary search boundary determination method is used to locate the rewrite position, complete the information domain rewrite and update the Merge table. The curve calibration module is used to calibrate the CURVE, AXIS, and VAL_BLK types. Based on their address continuity and Record distribution characteristics, it rewrites the information fields of all constituent values and updates the Merge table. The matrix calibration module is used for MAP type calibration. First, it converts the matrix format into a one-dimensional sequence according to the continuous address rule of the piecewise linear method. Then, it rewrites the information field and updates the Merge table according to the corresponding rule. The loop calibration module is used to repeatedly execute tasks, complete the calibration of all variables to be calibrated, and obtain a Merge table with monotonically increasing Record positions; The file merging module is used to merge the rewritten information in the Merge table into the original s19 file using a binary search method, update the checksum of the corresponding Record, and output the calibrated s19 file, thereby realizing fast offline calibration of vehicle s19 files.
[0016] Compared with the prior art, the present invention has the following beneficial technical effects: This invention provides a fast offline calibration method for vehicle-mounted S19 files. Leveraging the inherent monotonically increasing address property of S19 files, it combines sorting preprocessing with binary search for localization, replacing the traditional linear traversal method. This significantly shortens the address retrieval time for calibration data, effectively reduces address matching errors, and improves calibration efficiency. By using a corresponding binary search boundary determination method based on the differences in the Block index of the variables, the rewriting logic is optimized, reducing redundant operations and further improving calibration smoothness. For different types of calibration data (CURVE, AXIS, VAL_BLK, and MAP), customized rewriting schemes are designed to match their respective address distribution patterns and structural characteristics, ensuring calibration accuracy and adapting to various calibration scenarios for vehicle ECUs. The merge process uses binary search to merge rewritten information and synchronously updates the Record checksum according to rules, ensuring the validity and stability of the calibrated S19 files. The entire process enables one-click calibration of scalar quantities in Excel, eliminating the need for manual row-by-row positioning and modification. This simplifies the operation process, reduces labor costs and error rates, and provides an efficient and reliable offline calibration solution for vehicle ECU software development and testing. It is easy to promote and apply in the industry and significantly shortens the development cycle of electronic control systems. Attached Figure Description
[0017] Figure 1 This is a flowchart of a rapid offline calibration method for vehicle-mounted S19 files in an embodiment of the present invention; Figure 2 This is a schematic diagram illustrating the address pattern of the vehicle-mounted S19 file in an embodiment of the present invention; Figure 3 This is a schematic diagram of the variables before sorting in an embodiment of the present invention; Figure 4 This is a schematic diagram of the sorted variables in an embodiment of the present invention; Figure 5 This is a schematic diagram of the Merge table format in an embodiment of the present invention; Figure 6This is a schematic diagram of the Merge process (partial) in an embodiment of the present invention; Figure 7 This is a schematic diagram illustrating the continuous physical address pattern of the Curve type in an embodiment of the present invention; Figure 8 This is a schematic diagram illustrating the continuous pattern of MAP type physical addresses in an embodiment of the present invention; Figure 9 This is a schematic diagram illustrating the single-element storage pattern in an embodiment of the present invention; Figure 10 This describes the storage pattern of multi-element variable types using the single-byte BYTE data type in this embodiment of the invention. Figure 11 This describes the storage pattern for 2-byte INT data type multi-element variables in this embodiment of the invention. Figure 12 shows the storage pattern of 4-byte FLOAT data type multi-element variable type in an embodiment of the present invention. Figure 13 This is a schematic diagram of the rapid offline calibration system for vehicle-mounted S19 files in an embodiment of the present invention. In the diagram: 1. Information acquisition module; 2. Variable sorting module; 3. Initial value calibration module; 4. Subsequent calibration module; 5. Curve calibration module; 6. Matrix calibration module; 7. Loop calibration module; 8. File merging module. Detailed Implementation
[0018] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. 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 should fall within the scope of protection of the present invention.
[0019] The purpose of this invention is to provide a fast offline calibration method and system for vehicle-mounted S19 files, in order to solve the technical problem of how to optimize the S19Merge process based on the inherent properties and calibration quantity arrangement rules of S19 files, combined with techniques such as bisection, sorting, and interval convergence, to achieve one-click fast offline calibration of Excel scalar quantities based on A2L files and S19 files.
[0020] The present invention will now be described in further detail with reference to the accompanying drawings: See Figure 1 In one embodiment of the present invention, a rapid offline calibration method for vehicle-mounted S19 files is provided, comprising: Step 1: Obtain the data to be labeled and related file information, supplement the information of the variables, and obtain a variable set containing complete information; Specifically, the process in step 1 includes: Step 11: Read the variable names and calibration values to be calibrated from the Excel spreadsheet. The initial format of a single variable is [variable name, variable value]. Step 12: Load the A2L file, read the ECU address, calibration type, and variable data type of the variable, and update the format of a single variable to [variable name, variable value, variable calibration type, variable data type, variable ECU address]; Step 13: Load the s19 file, identify one or more Block regions in the s19 file, obtain the start and end addresses of each Block region, and supplement the Block index for the variable according to the Block region range to which the variable ECU address belongs. The final form of a single variable is [variable name, variable value, variable scalar type, variable data type, variable ECU address, variable Block index], forming a variable set containing complete information.
[0021] Step 2: Based on the monotonically increasing property of the s19 file address, sort and preprocess the variable set of complete information to prepare for standardization and rewriting. Specifically, in step 2, based on the monotonically increasing property of the s19 file address, the variable set of complete information is sorted and preprocessed to prepare for the calibration and rewriting. Taking advantage of the monotonically increasing property of the s19 file address from top to bottom, the variable set of complete information is sorted from smallest to largest based on the ECU address of the variable. The sorting result is stored in a table as program variables, which serve as the prerequisite data for subsequent calibration and rewriting.
[0022] Step 3: For the first variable after sorting, use the binary search method to determine its Record rewriting position in the s19 file, complete the information field rewriting and establish the Merge table; Specifically, step 3 includes the following processes: Step 31: Determine the Block region to which the first variable ECU address belongs, and use the upper boundary of the Block region as the upper boundary of the binary search for the variable. Step 32: Calculate the address offset between the ECU address of the first variable and the upper boundary of the Block area. If the upper boundary of the Block area + the offset > the lower boundary of the Block area, then the right boundary of the bisection is set as the lower boundary of the Block area; otherwise, the upper boundary of the Block area + the offset is used as the right boundary of the bisection. Step 33: Determine the record rewriting position of the first variable in the s19 file using the binary search method, complete the rewriting of the record information field, and obtain the rewritten record information field; Step 34: Create the Merge table. Each row in the Merge table stores the information status as [the information field content of the current Record, the position index of the current Record].
[0023] Step 4: Process the remaining variables after sorting in sequence. Based on the consistency between the Block index of the variable and the previous variable, use the corresponding binary search boundary determination method to locate the rewrite position, complete the information domain rewrite and update the Merge table. Specifically, the process in step 4 is as follows: Step 41: Read the next variable after sorting and determine whether the Block index of the variable is the same as the Block index of the previous processed variable; Step 42, if the Block index is the same: use the Record rewrite position of the previous variable as the left boundary of the binary search for the current variable, and calculate the offset between the ECU address of the current variable and the starting address of the Record of the previous rewrite position; if the starting address of the Record + the offset > the lower boundary of the Block area to which the current variable belongs, then the right boundary of the binary search is set as the lower boundary of the Block area, otherwise the starting address of the Record + the offset is used as the right boundary of the binary search; determine the Record rewrite position of the current variable by binary search; if the current rewrite position is the same as the rewrite position of the previous variable, then directly rewrite based on the information field of the previous rewrite in the Merge table; if the rewrite positions are different, obtain the information field content of the current Record in the s19 file, and insert the rewrite result and the rewrite position into the Merge table after the rewrite is completed; Step 43, if the Block index is different: according to the binary search boundary determination method of the first variable in Step 3, combined with the upper and lower boundaries of the Block area to which the current variable belongs and the address offset, determine the Record rewriting position of the current variable; since the Block areas are different, the current variable and the previous variable must not be in the same row of Record, directly obtain the information field of the current Record to complete the rewriting, and insert the rewriting result and rewriting position into the Merge table.
[0024] Step 5: For the CURVE, AXIS, and VAL_BLK type calibration values, based on their address continuity and Record distribution characteristics, rewrite the information fields of all constituent values and update the Merge table. Specifically, the process in step 5 is as follows: Step 51: The CURVE, AXIS, and VAL_BLK type values are all composed of several VALUE type values. The addresses of each unit are distributed continuously. All bytes of a single VALUE type value must be located in the same row of Records. Multiple VALUE type values can be located in the same row or multiple consecutive rows of Records. Step 52: Using the address of the first value of the calibrated value in the A2L file as a reference, deduce the addresses of the remaining constituent units according to the data type of the variable. Step 53: Determine the Record rewrite position of the first value according to the algorithm flow of Step 3 and Step 4, convert the first value into a hexadecimal string according to the corresponding data type, rewrite the Record information field and record the rewrite position, and update the Merge table. Step 54: Process the remaining constituent units in sequence and determine whether their addresses are within the Record address range of the first value. If they are, rewrite and update the information field of the corresponding Record in the Merge table directly. If they are not, obtain the Record information field at the Record position + 1 of the first value, and insert the information field content and the rewritten position into the Merge table after rewriting. Step 55: Repeat step 54 to complete the rewriting of all constituent units of the CURVE, AXIS, and VAL_BLK type calibrators.
[0025] In this embodiment, the constituent units of CURVE are composed of several value scalars, as shown below. Var1,Var2,Var3,Var4,Var5,Var6,Var7,Var8.
[0026] Address connection processing is as follows: Var1->Var2->Var3->Var4->Var5->Var6->Var7->Var8 Because the value type occupies 1, 2, or 4 bytes according to the data type, the distribution of calibrated values in the Record was studied. Regardless of whether it is a single value, occupying 1, 2, 4, or four bytes, it must be located in the same line of Record. However, in the case of multiple values, depending on the number of values, they may be located in one line of Record or multiple consecutive lines of Record.
[0027] Taking [value 0, value 1, value 2, value 3, value 4, value 5] as an example, the address of A2L is first the address of value 0. The addresses of the remaining values can be determined by adding the data type of the variable to the address of value 0. Assuming the scaling value is of type WORD and occupies two bytes, then according to the MCU address continuity rule, the address of value 1 is value 0 + 2, and the addresses of the remaining values are of type WORD.
[0028] During calibration, the position of value 0 is determined according to the preceding algorithm process. First, the value 0 is converted into a hexadecimal string according to the corresponding data type. Then, the information field is rewritten and the rewriting position is recorded, and the Merge table is updated.
[0029] When processing value 1, binary search is no longer needed. We can determine whether the address of value 1 is within the Record range of value 0 based on the address of value 1: If so, directly retrieve the corresponding information field from the Merge table and rewrite and update it.
[0030] If not, retrieve the information field content at record position + 1, rewrite the information field, and insert the information field information and the record rewrite position into the Merge table.
[0031] Repeat the above process to rewrite the CURVE. The AXIS and VAL_BLK data formats are similar to CURVE, and the rewriting process is exactly the same.
[0032] Step 6: For MAP type calibration, first convert its matrix format into a one-dimensional sequence according to the piecewise linear continuous address rule, and then rewrite the information field and update the Merge table according to the corresponding rule; Specifically, the process in step 6 is as follows: Step 61: The MAP type calibration data is presented in a matrix format in an Excel spreadsheet, and its physical addresses are distributed in a continuous line shape. Step 62: Convert the matrix-formatted MAP values in the Excel spreadsheet into a one-dimensional sequence according to the continuous address rule of the broken line. Specifically, based on the ECU address of the first value of the MAP value in the A2L file, the addresses of the remaining constituent units are derived in sequence according to the data type of the variables. The address connection follows the rule of Var1→Var7→Var2→Var8→Var3→Var9→Var4→Var10→Var5→Var11→Var6→Var12. Step 63: Following the rewriting rules for the CURVE type standard in Step 5, rewrite the information fields of all constituent units of the MAP type standard and update the Merge table.
[0033] In this embodiment, the process of rewriting the calibration data of MAP type is handled as follows. Since automotive electronics engineers generally complete the calibration in CANape, the data format of the completed calibration and transferred to an Excel spreadsheet is generally as follows: Var1, Var2, Var3, Var4, Var5, Var6; Var7, Var8, Var9, Var10, Var11, Var12; However, after actual analysis, the physical addresses of the variables in the matrix format exhibit a continuous, broken-line pattern. The address connections are processed as follows: Var1->Var7->Var2->Var8->Var3->Var9->Var4->Var10->Var5->Var11->Var6->Var12.
[0034] The address of Var1 is determined by Ecu_Addr in A2L. Let's assume the current calibration value is of type FLOAT, occupying four bytes. Then the address of Var7 is Var1+4, and the rest can be deduced similarly. After processing, its calibration steps are similar to those of the CURVE type.
[0035] Step 7: Repeat steps 3 to 6 to complete the calibration of all variables to be calibrated, and obtain the Merge table with monotonically increasing Record positions. Specifically, steps 3 to 6 are executed repeatedly to calibrate all the variables to be calibrated in the Excel spreadsheet one by one until all variables have been processed, and finally the Merge table is obtained. The Merge table records all the rewritten Record information fields and their corresponding Record positions, and the Record positions in the Merge table increase monotonically from top to bottom.
[0036] Step 8: Use a binary search method to merge the rewritten information in the Merge table into the original s19 file, update the checksum of the corresponding Record, and output the calibrated s19 file to achieve fast offline calibration of the vehicle s19 file.
[0037] Specifically, the process in step 8 is as follows: Step 81: Determine the interval [position 1, position n] of the Record position in the Merge table, where position 1 is the smallest Record position in the Merge table and position n is the largest Record position in the Merge table; Step 82: Read the original s19 file into the software memory, iterate through the Record position index of the original s19 file line by line, and determine whether the position index is within the interval [position 1, position n]. Step 83: If the position index is within the interval, use [0, Merge table height - 1] as the left and right boundaries of the binary search, and use the binary search method to find whether there is a Record position in the Merge table that is the same as the current iteration position index; if not found, do not process the original s19 file in memory; if found, replace the information field of the current position of the original s19 file with the information field of the corresponding position in the Merge table, and recalculate the checksum of the Record. Step 84, the checksum calculation process is as follows: add the current Record's offset address, record type, information field, and record length without carry, subtract the addition result from 255 to obtain a new checksum, and update the current Record's checksum with this new checksum; Step 85: If the position index is not within the range, no processing is performed on the original s19 file in memory; Step 86: After all Record position index iterations have been completed, output the merged s19 file from memory. This file is the offline calibrated s19 file.
[0038] In this embodiment, the Merge table is still merged into the original s19 file using the binary search method. The processing procedure is as follows: First, the Merge table has the following structure in the program: Information Domain 1 Location 1 Information domain 2 Location 3 Information domain 3, location 6 ^^^^^^^^^^^^^ Information domain n, location n Since it is monotonically increasing, position 1 must be the minimum position and position n must be the maximum position, forming the position interval [position 1, position n].
[0039] The original s19 file is read into the software memory. The original s19 file is read line by line, and the position index is used for iteration to determine whether the position index is within the interval [position 1, position n]. If so, perform a binary search using [0, table height - 1] as the left and right boundaries, checking if there exists a position index in the table that matches the current iteration position index. If not found, do not process s19 in memory. Otherwise, replace the information field of the current position in s19 with the information field of the corresponding position in the table. Because the information field has been replaced, the checksum corresponding to this row position also needs to be recalculated and updated. The checksum calculation process is as follows: the offset address of the constituent parts of the Record, the Record type, the information field, and the Record length are added without carry. The result of the addition is then subtracted from 255 to obtain the checksum, which is used to update the current Record checksum.
[0040] If not, the s19 file in memory is not processed. After the Merge process iterates through the results, the merged s19 file is output from memory, which is the offline calibrated file.
[0041] The entire S19 file compilation and rewriting workflow in this embodiment is as follows. The entire process combines techniques such as binary search, sorting, and interval convergence to achieve efficient and accurate offline calibration of various types of calibration quantities in the vehicle ECU software. The detailed workflow description is as follows: Data preparation and loading: Read the variable names and calibration values to be calibrated from the Excel spreadsheet to form an initial variable list: [variable name, variable value].
[0042] Load the A2L file, extract the key information for each variable (including ECU address, calibrated value type, and data type), and update the variable list to: [variable name, variable value, calibrated value type, data type, ECU address].
[0043] Load the S19 file, identify multiple Block regions (each Block has a start address and an end address), determine the Block index to which the variable belongs based on the Ecu address, and finally the variable format is: [variable name, variable value, standard variable type, data type, Ecu address, Block index].
[0044] Variable Sorting and Preprocessing: Utilizing the monotonically increasing address property of the S19 file from top to bottom, all variables are sorted in ascending order by their ECU addresses, and the sorting results are stored in program variables. This provides an ordered foundation for subsequent rewriting operations. A diagram illustrating the address sorting pattern of the S19 file is shown below. Figure 2 As shown. The variables before and after sorting are respectively as follows. Figure 3 and Figure 4 As shown, the sorted Ecu addresses are monotonically increasing.
[0045] Scalar rewriting and Merge table construction: First variable processing: Using the upper boundary of the Block to which the first variable belongs as the upper boundary of the binary search, calculate the offset between the Ecu address of the variable and the upper boundary of the Block.
[0046] The lower boundary of the binary search is determined based on the relationship between the offset and the lower boundary of the block: if "the upper boundary of the block + the offset" is greater than the lower boundary of the block, then the lower boundary is used as the right boundary; otherwise, "the upper boundary of the block + the offset" is used as the right boundary.
[0047] The specific Record position of the variable in the S19 file is located using a binary search method, the information field is rewritten, and the rewritten information field and Record position index are recorded in the Merge table in the format: [Information Field Content, Record Position Index]. Figure 5 and Figure 6 As shown.
[0048] Subsequent variable processing: Subsequent variables are processed according to the sorting order. First, it is determined whether the current variable and the previous variable belong to the same block. If they belong to the same block, the rewrite position of the previous variable is used as the left boundary of the binary search. The offset between the current variable's Ecu address and the starting address of the previous rewritten Record is calculated to determine the right boundary of the binary search (using the same method as the first variable). If the rewrite position is the same as the previous variable, it is directly rewritten based on the previous information field in the Merge table; otherwise, the information field of the new Record is obtained, rewritten, and the Merge table is updated. If they belong to different blocks: the binary search boundary is redefined using the method for the first variable, and the information field rewriting and Merge table update are completed independently.
[0049] Special type calibration processing: CURVE, AXIS, and VAL_BLK types: These types consist of multiple values at consecutive addresses (e.g., CURVE contains multiple VALUEs). The physical address contiguousness of the CURVE type follows the pattern shown below. Figure 7 As shown. Using the address of the first value as a reference, the position of subsequent values is determined by address offset. After the first value is located and rewritten using a binary search method, subsequent values are determined based on their addresses to see if they belong to the same Record: if so, they are directly rewritten based on the Merge table information field; otherwise, the next Record information field is retrieved, rewritten, and the Merge table is updated.
[0050] MAP type: Physical addresses are distributed in a continuous, polygonal pattern (e.g., Var1→Var7→Var2→Var8…). Starting from the first value address, subsequent value addresses are calculated according to data type. The processing flow is similar to the CURVE type, ensuring that all values are rewritten sequentially according to address continuity. The physical address sorting rule for this type is as follows: Figure 8 As shown.
[0051] like Figure 9 As shown, when a single element is included, each value (whether 4 bytes, 2 bytes, or 1 byte) is stored independently within a single Record. All values are stored without spanning multiple rows, ensuring the integrity of each individual data record. Figure 10 As shown, if a variable contains multiple elements, and each element is 1 byte in size, these elements may be stored entirely within a single record or distributed across multiple consecutive records. Regardless, the data of any single element is guaranteed to be stored completely within a single record and will not be split across rows. Figure 11 , 12 The distribution patterns of elements with sizes of 2 and 4 bytes are described respectively.
[0052] Merge table and S19 file merging: After all variables are rewritten, the Record position index in the Merge table is monotonically increasing. When merging the Merge table with the original S19 file, a binary search method is used to efficiently locate the Record that needs to be modified. The original S19 file is read line by line, and it is determined whether the current line position index is within the position range of the Merge table. If so, a binary search is performed with all positions in the Merge table as the search range: If a matching position is found, the corresponding information field in the Merge table is used to replace the information field of the current Record, and the checksum is recalculated (by adding the Record's offset address, type, information field, and length without carry, and subtracting the result from 255 to update the checksum). If no match is found or the Record is not within the range, the original Record is left unchanged.
[0053] After outputting the calibrated file and completing the replacement, verification, and update of all records, the S19 data in memory is output as a new S19 file, which is the final file after offline calibration.
[0054] Example 2 This embodiment also mentions a fast offline calibration system for vehicle-mounted S19 files, used to implement the aforementioned fast offline calibration method for vehicle-mounted S19 files, including: Information acquisition module 1 is used to acquire the data to be labeled and related file information, supplement the information of variables, and obtain a variable set containing complete information; Variable sorting module 2 is used to sort and preprocess the variable set of complete information based on the monotonically increasing property of s19 file address, in order to prepare for standardization and rewriting. The first value calibration module 3 is used to determine the Record rewriting position in the s19 file for the first variable after sorting using a binary search method, complete the information field rewriting and establish the Merge table; The subsequent calibration module 4 is used to process the remaining variables after sorting in sequence. Based on the consistency between the Block index of the variable and the previous variable, the corresponding binary search boundary determination method is used to locate the rewrite position, complete the information domain rewrite and update the Merge table. Curve calibration module 5 is used to calibrate the CURVE, AXIS, and VAL_BLK types. Based on their address continuity and Record distribution characteristics, it rewrites the information fields of all constituent values and updates the Merge table. Matrix calibration module 6 is used for MAP type calibration. First, it converts the matrix format into a one-dimensional sequence according to the broken line continuous address rule, and then rewrites the information field and updates the Merge table according to the corresponding rule. The loop calibration module 7 is used to perform the task in a loop, complete the calibration of all variables to be calibrated, and obtain the Merge table with monotonically increasing Record positions; The file merging module 8 is used to merge the rewritten information in the Merge table into the original s19 file using a binary search method, update the checksum of the corresponding Record, and output the calibrated s19 file, thereby realizing the fast offline calibration of the vehicle s19 file.
[0055] In summary, this invention provides a fast offline calibration method and system for vehicle-mounted S19 files. Leveraging the inherent monotonically increasing address property of S19 files, it combines sorting preprocessing and binary search for localization, replacing the traditional linear traversal method. This significantly shortens the address retrieval time for calibration data, effectively reduces address matching errors, and improves calibration efficiency. By using a corresponding binary search boundary determination method based on the differences in the Block index of the variables, the rewriting logic is optimized, reducing redundant operations and further improving calibration smoothness. For different types of calibration data (CURVE, AXIS, VAL_BLK, and MAP), customized rewriting schemes are designed to match their respective address distribution patterns and structural characteristics, ensuring calibration accuracy and adapting to various calibration scenarios for vehicle ECUs. The merge process uses binary search to merge rewritten information and synchronously updates the Record checksum according to rules, ensuring the validity and stability of the calibrated S19 files. The entire process enables one-click calibration of scalar quantities in Excel, eliminating the need for manual row-by-row positioning and modification. This simplifies the operation process, reduces labor costs and error rates, and provides an efficient and reliable offline calibration solution for vehicle ECU software development and testing. It is easy to promote and apply in the industry and significantly shortens the development cycle of electronic control systems.
[0056] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit it. Although the present invention has been described in detail with reference to the above embodiments, those skilled in the art should understand that modifications or equivalent substitutions can still be made to the specific implementation of the present invention. Any modifications or equivalent substitutions that do not depart from the spirit and scope of the present invention should be covered within the scope of protection of the claims of the present invention.
Claims
1. A rapid offline calibration method for vehicle-mounted S19 files, characterized in that, include: Step 1: Obtain the data to be labeled and related file information, supplement the information of the variables, and obtain a variable set containing complete information; Step 2: Based on the monotonically increasing property of the s19 file address, sort and preprocess the variable set of complete information to prepare for standardization and rewriting. Step 3: For the first variable after sorting, use the binary search method to determine its Record rewriting position in the s19 file, complete the information field rewriting and establish the Merge table; Step 4: Process the remaining variables after sorting in sequence. Based on the consistency between the Block index of the variable and the previous variable, use the corresponding binary search boundary determination method to locate the rewrite position, complete the information domain rewrite and update the Merge table. Step 5: For the CURVE, AXIS, and VAL_BLK type calibration values, based on their address continuity and Record distribution characteristics, rewrite the information fields of all constituent values and update the Merge table. Step 6: For MAP type calibration, first convert its matrix format into a one-dimensional sequence according to the piecewise linear continuous address rule, and then rewrite the information field and update the Merge table according to the corresponding rule; Step 7: Repeat steps 3 to 6 to complete the calibration of all variables to be calibrated, and obtain the Merge table with monotonically increasing Record positions. Step 8: Use a binary search method to merge the rewritten information in the Merge table into the original s19 file, update the checksum of the corresponding Record, and output the calibrated s19 file to achieve fast offline calibration of the vehicle s19 file.
2. The rapid offline calibration method for vehicle-mounted S19 files according to claim 1, characterized in that, Step 1 involves obtaining the target data and related file information, supplementing the variables with information, and obtaining a variable set containing complete information. The specific process includes: Step 11: Read the variable names and calibration values to be calibrated from the Excel spreadsheet. The initial format of a single variable is [variable name, variable value]. Step 12: Load the A2L file, read the ECU address, calibration type, and variable data type of the variable, and update the format of a single variable to [variable name, variable value, variable calibration type, variable data type, variable ECU address]; Step 13: Load the s19 file, identify one or more Block regions in the s19 file, obtain the start and end addresses of each Block region, and supplement the Block index for the variable according to the Block region range to which the variable ECU address belongs. The final form of a single variable is [variable name, variable value, variable scalar type, variable data type, variable ECU address, variable Block index], forming a variable set containing complete information.
3. The rapid offline calibration method for vehicle-mounted S19 files according to claim 1, characterized in that, In step 2, based on the monotonically increasing property of the s19 file address, the variable set of complete information is sorted and preprocessed to prepare for the calibration and rewriting. Taking advantage of the monotonically increasing property of the s19 file address from top to bottom, the variable set of complete information is sorted from smallest to largest based on the ECU address of the variable. The sorting result is stored in a table as program variables, which serve as the prerequisite data for subsequent calibration and rewriting.
4. The rapid offline calibration method for vehicle-mounted S19 files according to claim 1, characterized in that, In step 3, for the first variable after sorting, a binary search method is used to determine its Record rewrite position in the s19 file. The specific process of completing the information field rewrite and establishing the Merge table includes: Step 31: Determine the Block region to which the first variable ECU address belongs, and use the upper boundary of the Block region as the upper boundary of the binary search for the variable. Step 32: Calculate the address offset between the ECU address of the first variable and the upper boundary of the Block area. If the upper boundary of the Block area + the offset > the lower boundary of the Block area, then the right boundary of the bisection is set as the lower boundary of the Block area; otherwise, the upper boundary of the Block area + the offset is used as the right boundary of the bisection. Step 33: Determine the record rewriting position of the first variable in the s19 file using the binary search method, complete the rewriting of the record information field, and obtain the rewritten record information field; Step 34: Create the Merge table. Each row in the Merge table stores the information status as [the information field content of the current Record, the position index of the current Record].
5. The rapid offline calibration method for vehicle-mounted S19 files according to claim 1, characterized in that, In step 4, the remaining variables after sorting are processed sequentially. Based on the consistency between the Block index of the variable and the previous variable, the corresponding binary search boundary determination method is used to locate the rewrite position. The specific process of completing the information field rewrite and updating the Merge table is as follows: Step 41: Read the next variable after sorting and determine whether the Block index of the variable is the same as the Block index of the previous processed variable; Step 42, if the Block index is the same: use the Record rewrite position of the previous variable as the left boundary of the binary search for the current variable, and calculate the offset between the ECU address of the current variable and the starting address of the Record of the previous rewrite position; if the starting address of the Record + the offset > the lower boundary of the Block area to which the current variable belongs, then the right boundary of the binary search is set as the lower boundary of the Block area, otherwise the starting address of the Record + the offset is used as the right boundary of the binary search; determine the Record rewrite position of the current variable by binary search; if the current rewrite position is the same as the rewrite position of the previous variable, then directly rewrite based on the information field of the previous rewrite in the Merge table; if the rewrite positions are different, obtain the information field content of the current Record in the s19 file, and insert the rewrite result and the rewrite position into the Merge table after the rewrite is completed; Step 43, if the Block index is different: according to the binary search boundary determination method of the first variable in Step 3, combined with the upper and lower boundaries of the Block area to which the current variable belongs and the address offset, determine the Record rewriting position of the current variable; since the Block areas are different, the current variable and the previous variable must not be in the same row of Record, directly obtain the information field of the current Record to complete the rewriting, and insert the rewriting result and rewriting position into the Merge table.
6. The rapid offline calibration method for vehicle-mounted S19 files according to claim 1, characterized in that, In step 5, for the CURVE, AXIS, and VAL_BLK type calibration values, based on their address continuity and Record distribution characteristics, the specific process of rewriting the information fields of all constituent values and updating the Merge table is as follows: Step 51: The CURVE, AXIS, and VAL_BLK type values are all composed of several VALUE type values. The addresses of each unit are distributed continuously. All bytes of a single VALUE type value must be located in the same row of Records. Multiple VALUE type values can be located in the same row or multiple consecutive rows of Records. Step 52: Using the address of the first value of the calibrated value in the A2L file as a reference, deduce the addresses of the remaining constituent units according to the data type of the variable. Step 53: Determine the Record rewrite position of the first value according to the algorithm flow of Step 3 and Step 4, convert the first value into a hexadecimal string according to the corresponding data type, rewrite the Record information field and record the rewrite position, and update the Merge table. Step 54: Process the remaining constituent units in sequence and determine whether their addresses are within the Record address range of the first value. If they are, rewrite and update the information field of the corresponding Record in the Merge table directly. If they are not, obtain the Record information field at the Record position + 1 of the first value, and insert the information field content and the rewritten position into the Merge table after rewriting. Step 55: Repeat step 54 to complete the rewriting of all constituent units of the CURVE, AXIS, and VAL_BLK type calibrators.
7. The rapid offline calibration method for vehicle-mounted S19 files according to claim 1, characterized in that, In step 6, for MAP type calibration quantities, the matrix format is first converted into a one-dimensional sequence according to the piecewise linear continuous address rule, and then the information field is rewritten and the Merge table is updated according to the corresponding rules. The specific process is as follows: Step 61: The MAP type calibration data is presented in a matrix format in an Excel spreadsheet, and its physical addresses are distributed in a continuous line shape. Step 62: Convert the matrix-formatted MAP values in the Excel spreadsheet into a one-dimensional sequence according to the continuous address rule of the broken line. Specifically, based on the ECU address of the first value of the MAP value in the A2L file, the addresses of the remaining constituent units are derived in sequence according to the data type of the variables. The address connection follows the rule of Var1→Var7→Var2→Var8→Var3→Var9→Var4→Var10→Var5→Var11→Var6→Var12. Step 63: Following the rewriting rules for the CURVE type standard in Step 5, rewrite the information fields of all constituent units of the MAP type standard and update the Merge table.
8. The rapid offline calibration method for vehicle-mounted S19 files according to claim 1, characterized in that, Steps 3 to 6 are executed repeatedly to calibrate all the variables to be calibrated in the Excel spreadsheet one by one until all variables have been processed, and finally the Merge table is obtained. The Merge table records all the rewritten Record information fields and their corresponding Record positions, and the Record positions in the Merge table show a monotonically increasing trend from top to bottom.
9. A rapid offline calibration method for vehicle-mounted S19 files according to claim 1, characterized in that, In step 8, the rewritten information in the Merge table is merged into the original s19 file using a binary search method, the checksum of the corresponding Record is updated, and the calibrated s19 file is output. The specific process is as follows: Step 81: Determine the interval [position 1, position n] of the Record position in the Merge table, where position 1 is the smallest Record position in the Merge table and position n is the largest Record position in the Merge table; Step 82: Read the original s19 file into the software memory, iterate through the Record position index of the original s19 file line by line, and determine whether the position index is within the interval [position 1, position n]. Step 83: If the position index is within the interval, use [0, Merge table height - 1] as the left and right boundaries of the binary search, and use the binary search method to find whether there is a Record position in the Merge table that is the same as the current iteration position index; if not found, do not process the original s19 file in memory; if found, replace the information field of the current position of the original s19 file with the information field of the corresponding position in the Merge table, and recalculate the checksum of the Record. Step 84, the checksum calculation process is as follows: add the current Record's offset address, record type, information field, and record length without carry, subtract the addition result from 255 to obtain a new checksum, and update the current Record's checksum with this new checksum; Step 85: If the position index is not within the range, no processing is performed on the original s19 file in memory; Step 86: After all Record position index iterations have been completed, output the merged s19 file from memory. This file is the offline calibrated s19 file.
10. A rapid offline calibration system for vehicle-mounted S19 files, characterized in that, A method for implementing a rapid offline calibration method for vehicle-mounted S19 files as described in any one of claims 1-9 includes: The information acquisition module is used to acquire the data to be labeled and related file information, supplement the information of variables, and obtain a variable set containing complete information. The variable sorting module is used to sort and preprocess the variable set of complete information based on the monotonically increasing property of s19 file address, in order to prepare for standardization and rewriting. The first value calibration module is used to determine the Record rewrite position in the s19 file for the first variable after sorting using a binary search method, complete the information field rewrite and establish the Merge table; The subsequent calibration module is used to process the remaining variables after sorting in sequence. Based on the consistency between the Block index of the variable and the previous variable, the corresponding binary search boundary determination method is used to locate the rewrite position, complete the information domain rewrite and update the Merge table. The curve calibration module is used to calibrate the CURVE, AXIS, and VAL_BLK types. Based on their address continuity and Record distribution characteristics, it rewrites the information fields of all constituent values and updates the Merge table. The matrix calibration module is used for MAP type calibration. First, it converts the matrix format into a one-dimensional sequence according to the continuous address rule of the piecewise linear method. Then, it rewrites the information field and updates the Merge table according to the corresponding rule. The loop calibration module is used to repeatedly execute tasks, complete the calibration of all variables to be calibrated, and obtain a Merge table with monotonically increasing Record positions; The file merging module is used to merge the rewritten information in the Merge table into the original s19 file using a binary search method, update the checksum of the corresponding Record, and output the calibrated s19 file, thereby realizing fast offline calibration of vehicle s19 files.