Method and system for conversion between textual code and graphic code for automobile development
By inserting configuration information when the graphic code is converted into text code, the corresponding relationship between the graphic code and the C code is solved, the accurate conversion between the graphic code and the text code is realized and the stability of multiple conversions is improved, and the automobile is improved Troubleshooting and testing efficiency during development.
Patent Information
- Application Number
- PCT/CN2024/095087
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-09-08
- Filing Date
- 2024-05-24
- Publication Date
- 2024-12-05
AI Technical Summary
During the automotive development process, graphic codes are difficult to manage and compare, which makes it difficult to compare differences in version management systems. The process of inverting the graphics code from text code is cumbersome, and existing software cannot implement strict ones between graphic codes and C codes. Corresponding conversions lead to inconsistent code differences and execution results.
By inserting the configuration information of the graphics code into the comment area of the text code when converting the graphics code into the text code, and extracting this information when converting it back to the graphics code to ensure a one-to-one correspondence between the graphics code and the text code. Achieve the accuracy of multiple conversions.
It realizes a strict one-to-one correspondence between graphic code and text code, ensures the accuracy and efficiency of the conversion process, and improves the convenience and efficiency of the inspection and testing.
Smart Images

Figure CN2024095087_05122024_PF_FP_ABST
Abstract
Description
Method and system for converting text code and graphic code for automobile development
[0001] CROSS-REFERENCE TO RELATED APPLICATIONS
[0002] This application is based upon and claims the benefit of priority from Chinese patent application No. 2023106408403 filed on June 1, 2023, the entire contents of which are incorporated herein by reference. Technical Field
[0003] The present invention belongs to the technical field of automotive software development, and in particular relates to a method and system for converting text codes and graphic codes for automotive development. Background Art
[0004] In the automotive development process, there is first a model built based on graphic code. However, the graphic code runs on the computer side and cannot serve as a carrier for logical operation. For automotive development, the logic of the vehicle controller must be executed based on text code. Therefore, the graphic code needs to be generated into text code before it can be executed in the vehicle controller.
[0005] Summary of the Invention
[0006] The present invention discloses a vehicle development and debugging system, comprising: a computer device, a bus adapter or a burner; wherein
[0007] The computer device includes: a processor, a readable storage medium, a communication bus and a communication interface; wherein
[0008] The readable storage medium is configured to store a program for executing the method for converting a text code into a graphic code, wherein the program causes a processor to execute operations corresponding to the method for converting a text code into a graphic code to generate a text code;
[0009] The processor, the readable storage medium and the communication interface communicate with the bus adapter via the communication bus;
[0010] The processor is configured to compile at least one execution code in the text code;
[0011] The bus adapter is configured to write the compiled execution code into the debugging device; or
[0012] The burner is configured to write the compiled execution code into the debugging device.
[0013] The present invention also discloses a vehicle development and debugging method, comprising:
[0014] Performing operations corresponding to the method for converting text codes into graphic codes by a computer device to generate text codes;
[0015] Write the compiled executable code to the debug device via the bus adapter; or
[0016] Write the compiled executable code into the debugging device through the programmer.
[0017] This summary is intended to provide a brief overview of some of the subject matter described in this document. It should therefore be understood that the above features are merely examples and should not be interpreted as narrowing the scope or nature of the subject matter described herein in any way.
[0018] Other features, aspects, and advantages of the subject matter described herein will become apparent from the following detailed description, drawings, and claims. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the specific embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0020] FIG1 shows a step diagram of a method for converting text codes to graphic codes according to some embodiments;
[0021] FIG2 shows an example of a graphic code according to some embodiments;
[0022] FIG3 illustrates another example of a graphic code according to some embodiments;
[0023] FIG4 shows a third example of a graphic code according to some embodiments;
[0024] FIG5 shows a sub-graphic code of an execution unit B in a third graphic code case according to some embodiments;
[0025] FIG6 shows a fourth example of a graphic code according to some embodiments;
[0026] FIG7 shows a fifth example of a graphic code according to some embodiments;
[0027] FIG8 shows a sixth example of a graphic code according to some embodiments;
[0028] FIG9 shows a principle block diagram of a device for converting code and graphic code involved in some embodiments;
[0029] FIG10 shows a seventh graphic code example according to some embodiments;
[0030] FIG11 is a schematic diagram showing a seventh graphic code case with AV_On highlighted according to some embodiments;
[0031] FIG12 shows a block diagram of an electronic device according to some embodiments;
[0032] FIG13 shows a connection diagram of a vehicle development and debugging system (bus adapter) according to some embodiments;
[0033] FIG14 shows a connection diagram of a vehicle development and debugging system (writer) involved in some embodiments;
[0034] FIG15 shows a step diagram of a vehicle development and debugging method according to some embodiments. DETAILED DESCRIPTION
[0035] To make the objectives, technical solutions, and advantages of the embodiments of the present invention more clear, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the embodiments described are only part of the embodiments of the present invention, not all of them. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.
[0036] As the inventors know, during the automobile development process, it is necessary to rely on version management software such as Git (an open source distributed version control system) to manage text-based C code, for example. However, this type of management software has difficulty managing graphic code and comparing differences between graphic code versions. Therefore, the files used to compare differences in the version management system are generally text code. When users browse the differences between different versions of text code, it is difficult to infer the implementation details of the graphic code from the specific difference code. Moreover, if there is a problem with the logic of the text code, it is necessary to compare the differences with the text code corresponding to the problematic program version, and then infer the graphic code to make corrections. After the graphic code is corrected, the text code is generated again. This process of generating text code from the graphic code is executed in the automobile controller, and then converting the text code back to the graphic code for correction, and then generating text code from the graphic code and continuing to execute is repeated until the program is correct.
[0037] Furthermore, since similar or similar software programs in the automobile development process can only be generated in one direction between graphic code and C code, it is impossible to achieve a strict one-to-one correspondence between each execution action in the graphic code and the C code. That is to say, after the graphic code is generated into C code, the graphic code is generated from the C code again, and there will be differences between the original graphic code and the regenerated graphic code.
[0038] The following example describes the reasons for the differences between the original graphics code and the regenerated graphics code:
[0039] Generally speaking, to repeat an action in a graphic code, you only need to set the number of repetitions for the action. For example, if action k=k+1 needs to be looped three times, you can set the number of repetitions for action k=k+1 to 3. However, the C code generated from this graphic code can produce different results depending on the usage scenario:
[0040] (1) General loop logic, that is, in a common scenario, the generated C code is as follows: for(i=0;i<3;i++){ k=k+1;}
[0041] (2) For high-performance scenarios, the generated C code is as follows: k = k + 1; k = k + 1; k = k + 1;
[0042] The different C codes generated in the above two scenarios will produce completely different results if converted back to graphics code. That is, the converted graphics code may have three actions instead of one, or the graphics code may use diamond branches to implement the for syntax instead of simply using repeated attributes.
[0043] Therefore, at least one embodiment provides a method for converting text code and graphic code for automobile development, including: converting graphic code into text code, and inserting the configuration information of each execution unit in the current graphic code into the comment area of the target text code while the target text code is generated; and when converting the target text code back into graphic code, the graphic program extracts the configuration information of the comment area of the target text code, loads the configuration information, obtains the configuration information of each execution unit in the graphic code, and restores the graphic code based on the configuration information.
[0044] In some embodiments, the configuration information is the graphic code itself, that is, the information after the graphic code is persisted is called configuration information. The graphic code is presented in the form of a block diagram and contains programs such as sequential execution, branch jump execution, and loop execution.
[0045] Since each time a graphic code is converted into a text code, the configuration information of the graphic code is inserted as a comment into the comment area of the target text code, it is ensured that when the text code is converted back into the graphic code, the graphic code can be exactly the same as the original graphic code, that is, the graphic code and the text code can maintain a one-to-one correspondence and be converted back and forth multiple times.
[0046] Various non-limiting implementations of the embodiments of the present disclosure are described in detail below with reference to the accompanying drawings.
[0047] As shown in FIG1 , some embodiments provide a method for converting a text code to a graphic code, including:
[0048] Step S101 : converting the graphic code into text code, and inserting the configuration information of each execution unit in the current graphic code into the comment area of the target text code while generating the target text code.
[0049] Step S102, when converting the target text code back into graphic code, the graphic program extracts the configuration information of the comment area of the target text code and loads the configuration information to obtain the configuration information of each execution unit in the graphic code, and restores the graphic code according to the configuration information.
[0050] In some embodiments, the configuration information is serialized and encoded and inserted into the comment area of the target text code in the form of text; and when the target text code is converted back into a graphic code, the graphics program extracts the configuration information text in the comment area for deserialization and decoding, and loads the configuration information to restore the graphic code.
[0051] Specifically, the graphic program involved in some embodiments refers to a program that runs on a PC and presents a structure such as sequential execution, branch jump execution, and loop execution using computer graphics.
[0052] In some embodiments, the serialization encoding method is, for example but not limited to, base64 encoding; if base64 encoding is used, the corresponding deserialization decoding method uses base64 decoding.
[0053] It should be noted that the following case contents will be described using base64 encoding and base64 decoding as examples.
[0054] In some embodiments, the text code is, for example but not limited to, C code, Java code, Python code, Pascal code, C++ code, Visual Basic code, C# code, etc.
[0055] It should be noted that in the case contents involved below, the conversion between graphic code and C code is described as an example, and the brackets of each function call statement in the C code can be empty or not empty. When there are parameters, they are not empty. For the convenience of description, some embodiments uniformly use function call statements without parameters.
[0056] In some embodiments, the types of execution units in the graphics code can be preset in advance. For example, the execution units in the graphics code can be preset as sequential execution units, branch jump units, nested execution units, and loop units. The type of each execution unit can be identified by reading the type attribute of each execution unit through the graphics code. The methods for converting different types of execution units into C code are as follows:
[0057] Directly convert the sequential execution units in the graphics code into C code corresponding to the unit actions;
[0058] Convert the branch jump unit in the graphic code into C code of "if" or "else if" or "else" structure;
[0059] Converting nested execution units in the graphics code into a function that executes the nested C code and a function that calls the C code; and
[0060] Convert the loop unit in the graphics code into a label, a goto statement and the C code corresponding to the action of the loop unit.
[0061] As an implementation method of converting graphic code into C code, let's take the graphic code including the sequential execution unit shown in FIG2 as an example:
[0062] Specifically, when converting the graphics code into C code, you only need to convert the execution units in sequence according to the execution order. The corresponding C code is as follows:
[0063] A();
[0064] B();
[0065] C();
[0066] As another implementation method of converting graphic code into C code, let's take the graphic code including the branch jump execution unit shown in FIG3 as an example:
[0067] When converting this graphic code into C code, two branches need to be set for the return value of A. If A returns a logical true, the first branch, that is, B, is executed. When B is executed, the logic continues to execute. Otherwise, the second branch, that is, C, is executed. When C is executed, the logic jumps to the next command of B and continues to execute. The corresponding C code is as follows:
[0068] As a third implementation method of converting graphics code into C code, let's take the graphics code containing nested execution units shown in FIG4 as an example:
[0069] As shown in FIG5 , the execution unit B on the graphic code is a nested execution unit, which contains the sub-graphic code.
[0070] When converting the graphics code into C code, the content of execution unit B needs to be converted into a C code function first. The nested inner C code is as follows:
[0071] The code generation for execution unit B then becomes calling function B, and the nested outer C code is as follows:
[0072] A();
[0073] B();
[0074] C();
[0075] As a fourth implementation of converting graphic code into C code, let us take the graphic code including the loop execution unit shown in FIG6 as an example:
[0076] After execution unit A is completed, execution unit B starts to execute. It is a judgment. When the return result is logically true, execution unit C will continue to run downward. Otherwise, it will jump to the right. The jump label is "Loop", which means that the program will jump to the top of execution unit A and continue to execute downward. Execution unit A and execution unit B form a loop.
[0077] When converting this graphic code into C code, you need to set a label Loop above execution unit A and use the C code language goto statement to jump to this label when execution unit B returns a logical false. The generated C code is as follows:
[0078] In some embodiments, the method of inserting configuration information into the comment area of the target code includes: generating persistent configuration information of the graphic code; and inserting the persistent configuration information into the comment area of the target code in the form of text after serializing and encoding.
[0079] Specifically, the one-to-one correspondence between the graphic code and the code can be achieved by encoding and decoding in the form of strings or files.
[0080] For example, the persistent configuration information of the generated graphics code is as follows:
[0081] conf=5704664608865866268;1;-1;4143886487092279683;-1;0;0;0;0;yOu / 2rXj;;-1;0
[0082] After the persistent configuration information is encoded using base64, the following string s can be obtained:
[0083] Y29uZj01NzA0NjY0NjA4ODY1ODY2MjY4OzE7LTE7NDE0Mzg4NjQ4NzA5MjI3OTY4MzstMTswOzA7MDswO3lPdS8yclhqOzstMTsw.
[0084] Simply insert the string s as text into the comment area of the target C code to save all the information of the graphics code in the C code. When converting from the C code back to the graphics code, simply extract the string s from the C code and perform a base64 decoding operation on the string s to obtain the persistent configuration information of the graphics code. Load the persistent configuration information to obtain the complete graphics code.
[0085] In some embodiments, when converting graphics code into C code, in addition to displaying the configuration information of each execution unit in the current graphics code in the target C code, the positioning information of each execution unit in the current graphics code is also displayed in the target C code.
[0086] Specifically, the positioning information includes a globally unique ID corresponding to each execution unit in the graphics code. Each globally unique ID is generated by calling the system API function coCreateGuid. Using the globally unique ID, the execution unit can be directly located, thereby realizing the transition from graphics code to text code: the globally unique ID can be used to directly locate each text code line corresponding to the graphics code; and from text code to graphics code: the globally unique ID can be used to directly locate the execution unit corresponding to the text code line.
[0087] As an optional way to display the positioning information in the target C code, the graphics code is converted into C code, and the positioning information of each execution unit in the current graphics code is inserted into the corresponding target C code line while the target C code is generated.
[0088] The positioning information can be used to locate the position of the execution unit in the graphics code corresponding to a certain code line in the C code, which can greatly improve the convenience and efficiency of troubleshooting in application scenarios where the C code logic needs to be checked. It can also locate the position of the corresponding code line in the C code corresponding to a certain execution unit in the graphics code, which can greatly improve testing efficiency in application scenarios where further testing of functions in the C code is required.
[0089] The following example explains in detail how to insert the positioning information into the corresponding target C code line.
[0090] Assume that the graphic code shown in Figure 7 is used as an example:
[0091] Step S201: When converting from graphic code to C code, a corresponding globally unique ID is generated for each execution unit A, B, and C. The corresponding table between execution unit and ID is as follows:
[0092] Step S202: Generate C code line by line from the graphic code according to the conversion rules, and record the correspondence between line number, C code and ID, as shown in the following table:
[0093] Step S203: add the id as the location information to the corresponding target code line in the form of a comment, preferably to the right of the corresponding target code line. The generated target C code content is as follows: A=1; / / 796586134100579186 B=A+2; / / 4477997354382728721 C=add(A,B); / / 623479023297457637
[0094] As another optional method for displaying the positioning information in the target code, when converting the graphic code into code, a temporary file is created to temporarily store the positioning information of each execution unit in the current graphic code; and the positioning information is serialized and encoded and inserted into the comment area of the target code in the form of text; wherein the positioning information is an association file between each execution unit and the corresponding target code line.
[0095] The following example explains in detail how to present the positioning information in the comment area of the target C code using a temporary file.
[0096] Assume that the graphic code shown in Figure 7 is used as an example:
[0097] Step S301: When converting from graphic code to C code, a corresponding globally unique ID is generated for each execution unit A, B, and C. The corresponding table between execution unit and ID is as follows:
[0098] Step S302: Generate C code line by line from the graphic code according to the conversion rules, and record the correspondence between line number, C code and id, as shown in the following table:
[0099] After the C code is generated, a file with the code line number and ID corresponding to each other is obtained. The file has 3 lines in total and the content is as follows:
[0100] Step S303: The graphic code uses the code line number and the associated file ID as positioning information, and encodes it through base64 to obtain a string s1, the content of which is as follows:
[0101] Nzk2NTg2MTM0MTAwNTc5MTg2DQo0NDc3OTk3MzU0MzgyNzI4NzIxDQo2MjM0NzkwMjMyOTc0NTc2Mzc;
[0102] Step S304: insert the encoded string s1 into the comment area of the target C code in the form of text. The target C code content is as follows: A=1; B=A+2; C=add(A,B); / / Nzk2NTg2MTM0MTAwNTc5MTg2DQo0NDc3OTk3MzU0MzgyNzI4NzIxDQo2MjM0NzkwMjMyOTc0NT c2Mzc
[0103] The following describes in detail the method for converting C code to graphic code according to an embodiment of the present disclosure, in conjunction with a complete case, specifically the complete steps of converting from graphic code to C code and then converting from C code back to graphic code.
[0104] Case 1 (location information is inserted to the right of the corresponding target C code line)
[0105] Assume that the graphics code in this example is as shown in Figure 7:
[0106] According to the described method of some embodiments, the steps of performing conversion between graphics code and C code are as follows:
[0107] Step S401: Generate a corresponding globally unique ID for each execution unit A, B, and C. The corresponding table between execution units and IDs is as follows:
[0108] Step S402: Generate C code line by line from the graphic code according to the rules, and record the correspondence between line number, C code and ID, as shown in the following table:
[0109] After the code is generated, a target C code file is obtained, with a total of 3 lines, the contents of which are shown in the following table:
[0110] After the code is generated, a file with the correspondence between the code line number and the ID is also obtained. There are 3 lines in total, and the content is shown in the following table:
[0111] In step S403, id is added as location information to the right side of the corresponding target code line in the form of a comment. The generated target C code content is as follows: A=1; / / 796586134100579186 B=A+2; / / 4477997354382728721 C=add(A,B); / / 623479023297457637
[0112] Step S404: The graphics code encodes the persistent configuration information of each execution unit using base64:
[0113] Assume that the persistence configuration information is as follows: [ao] conf=5864543089582057106;1;-1;796586134100579186;-1;0;0;0;0;yOu / 2rXj;;-1;0 [a0] conf=623479023297457637;0;4477997354382728721;-1;-1;0;1;0;0;QyA9IEI_;;0;0 [a1] conf=4477997354382728721;0;796586134100579186;623479023297457637;-1;0;3;0;0; QiA9IEEgKyAy;;0;0 [a2] conf=796586134100579186;0;5864543089582057106;4477997354382728721;-1;0;1;0;0;QSA9IDE_;;0;0
[0114] After base64 encoding, the resulting string s2 has the following content: W2FvXQ0KY29uZj01ODY0NTQzMDg5NTgyMDU3MTA2OzE7LTE7Nzk2NTg2MTM0MTAwNTc5MTg2Oy0x OzA7MDswOzA7eU91LzJyWGo7Oy0xOzANClthMF0NCmNvbmY9NjIzNDc5MDIzMjk3NDU3NjM3OzA7NDQ3Nzk5NzM1NDM4MjcyODcyMTstMTstMTswOzE7MDswO1F5QTlJRUlfOzswOzANClthMV0NCmNvbmY9NDQ3Nzk5NzM1NDM4MjcyODcyMTswOzc5NjU4NjEzNDEwMD U3OTE4Njs2MjM0NzkwMjMyOTc0NTc2Mzc7LTE7MDszOzA7MDtRaUE5SUVFZ0t5QXk7OzA7MA0KW2EyXQ0KY29uZj03OTY1ODYxMzQ xMDA1NzkxODY7MDs1ODY0NTQzMDg5NTgyMDU3MTA2OzQ0Nzc5OTczNTQzODI3Mjg3MjE7LTE7MDsxOzA7MDtRU0E5SURFXzs7MDsw.
[0115] In step S405, the graphic code inserts the encoded string s2 as a comment into the target C code comment area in the form of text. The complete target C code after conversion is as follows: A=1; / / 796586134100579186 B=A+2; / / 4477997354382728721 C=add(A,B); / / 623479023297457637 / / W2FvXQ0KY29uZj01ODY0NTQzMDg5NTgyMDU3MTA2OzE7LTE7Nzk2NTg2MTM0MTAwNTc5MTg2Oy 0xOzA7MDswOzA7eU91LzJyWGo7Oy0xOzANClthMF0NCmNvbmY9NjIzNDc5MDIzMjk3NDU3NjM3OzA7NDQ3Nzk5NzM1NDM4MjcyODc yMTstMTstMTswOzE7MDswO1F5QTlJRUlfOzswOzANClthMV0NCmNvbmY9NDQ3Nzk5NzM1NDM4MjcyODcyMTswOzc5NjU4NjEzNDEwM DU3OTE4Njs2MjM0NzkwMjMyOTc0NTc2Mzc7LTE7MDszOzA7MDtRaUE5SUVFZ0t5QXk7OzA7MA0KW2EyXQ0KY29uZj03OTY1ODYxMz QxMDA1NzkxODY7MDs1ODY0NTQzMDg5NTgyMDU3MTA2OzQ0Nzc5OTczNTQzODI3Mjg3MjE7LTE7MDsxOzA7MDtRU0E5SURFXzs7MDsw
[0116] Step S406: The conversion from the graphic code to the C code is completed.
[0117] Step S407, when it is necessary to convert from C code back to graphic code, it is only necessary to read the ID information on the right side of each code line in the C code file and the comment information in the comment area to obtain the positioning information and persistent configuration information of the graphic code. The graphic code loads the persistent configuration information to restore the graphic code that corresponds one to one with the C code.
[0118] Case 2 (Location information is inserted into the comment area of the target C code in the form of text)
[0119] Assume that the graphics code in this example is as shown in Figure 8.
[0120] This graphical code has five execution units: A, B, C, D, and E. When the program executes, A executes first, followed by B. The subsequent steps are executed based on the result of B. If B returns a true value, C executes; otherwise, D executes. After C completes, E executes next. After D completes, E executes next, and no NOPs are executed. After E completes, the program ends, and no NOPs are executed.
[0121] According to the described method of some embodiments, the steps of performing conversion between graphics code and C code are as follows:
[0122] Step S501: Generate a corresponding globally unique ID for each execution unit A, B, C, D, and E. The ID is a 64-bit integer. Different execution units have different IDs. The corresponding table between execution units and IDs is as follows:
[0123] Step S502: Generate C code line by line from the graphic code according to the rules. During the generation process, for each execution unit involved in the generated C code, the graphic code records the correspondence between the line number, C code, and ID. The fourth and sixth lines do not have execution unit information, and the ID is left blank. In this example, the correspondence between the line number, C code, and ID is as follows:
[0124] After the C code is generated, a target C code file is obtained, with a total of 7 lines, the contents of which are as follows:
[0125] After the C code is generated, a file with the corresponding code line numbers and IDs is also obtained. There are 7 lines in total, and the content is as follows:
[0126] Step S503: The graphic code encodes the code line number and the associated file ID through base64 to obtain a string s3, the content of which is as follows:
[0127] NDE0Mzg4NjQ4NzA5MjI3OTY4Mw0KMTQwNDY3MjY5MzIxNjI3Mjg1DQo2NDgyMzc5OTY5NjE5NjQz NTQ5DQoNCjMzMDM2ODMwNTc2NTI0ODQyNjMNCg0KMzU5ODM4Nzk3MTA2MDA4NjgzNw;
[0128] Step S504: The graphics code encodes the persistent configuration information of each execution unit using base64:
[0129] Assume that the persistence configuration information is as follows: [ao] conf=5704664608865866268;1;-1;4143886487092279683;-1;0;0;0;0;yOu / 2rXj;;-1;0 [a0] conf=140467269321627285;0;4143886487092279683;6482379969619643549;3303683057 652484263;0;0;0;0;Qg__;;0;0 [a1] conf=6482379969619643549;0;140467269321627285;3598387971060086837;-1;0;1;0;0;Qw__;;0;0 [a2] conf=3303683057652484263;0;140467269321627285;8309716131964563539;-1;0;1;0;0;RA__;;0;0 [a3] conf=4182729410035600018;0;8309716131964563539;-1;-1;0;0;0;0;Tk9Q;;-1;0 [a4] conf=3598387971060086837;0;6482379969619643549;3450332134183460644;-1;0;1;0;0;RQ__;;0;0 [a5] conf=8309716131964563539;0;3303683057652484263;4182729410035600018;-1;0;0;0;0;Tk9Q;;-1;0 [a6] conf=3450332134183460644;0;3598387971060086837;-1;-1;0;0;0;0;Tk9Q;;-1;0 [a7] conf=4143886487092279683;0;5704664608865866268;140467269321627285;-1;0;1;0;0;QQ__;;0;0;
[0130] After base64 encoding, the resulting string s4 is as follows:
[0131]
[0132] In step S505, the graphic code adds the string s3 and the string s4 as comments in the form of text, i.e., " / / s1, s2", to the comment area of the target C code. The generated complete target C code is as follows:
[0133]
[0134] Step S506: The conversion from the graphic code to the C code is completed.
[0135] Step S507: When it is necessary to convert this C code back into graphic code, first extract the comment information of the comment area of the target C code to obtain two comma-separated strings s5 and s6, where string s5 is the positioning information encoded by base64, and string s6 is the persistent configuration information of the graphic code encoded by base64. The graphic code loads this persistent configuration information to obtain the graphic code that corresponds one-to-one to the C code.
[0136] In summary, the code and graphic code conversion method of some embodiments inserts the configuration information of the graphic code as a comment into the comment area of the target code each time the graphic code is converted into C code, thereby ensuring that when the C code is converted back to the graphic code, the graphic code can be exactly the same as the original graphic code, that is, the graphic code and the C code can maintain a one-to-one correspondence and perform multiple back-and-forth conversions. In addition, some embodiments can also locate the position of the execution unit in the graphic code corresponding to a certain code line in the C code through positioning information, which can greatly improve the convenience and efficiency of troubleshooting in application scenarios where the C code logic needs to be checked; and can also locate the position of the corresponding code line in the C code corresponding to a certain execution unit in the graphic code, which can greatly improve the testing efficiency in application scenarios where further testing of functions in the C code is required. Furthermore, the graphic code involved in some embodiments can be executed directly, and the generated C code program can also be executed directly, and the execution process and execution results of the two are completely corresponding.
[0137] As shown in Figure 9, some embodiments also provide a device for converting text codes and graphic codes, including: a processor for executing a program of the method for converting text codes and graphic codes as described; a storage module for storing a program for executing the method for converting text codes and graphic codes as described in the embodiment; and a display module for displaying the conversion result of the text code and graphic code.
[0138] In some embodiments, the device for converting text codes into graphic codes may also be used as an electronic device or a computer. The electronic device will be described in detail in the following description.
[0139] At least one embodiment further provides a method for converting text codes and graphic codes used in automobile development, comprising:
[0140] The vehicle graphic code is converted into a text code, and configuration information of each execution unit in the current vehicle graphic code is inserted into a comment area of the target text code while a target text code is generated; and when the target text code is converted back into the vehicle graphic code, the vehicle graphic program extracts the configuration information of the comment area of the target text code and loads the configuration information to restore the vehicle graphic code.
[0141] In the scenario used for automobile development, the specific conversion steps for text codes and automotive graphic codes are the same as the aforementioned conversion method for text codes and graphic codes, and will not be repeated here.
[0142] The following uses case studies to explain in detail the conversion method between text code and graphic code used in automotive development scenarios.
[0143] In the development of ABS algorithms for automotive chassis electronics, take the logic for controlling the opening of a pressure relief valve as an example:
[0144] Refer to the graphic code snippet shown in Figure 10.
[0145] This logic checks whether the current wheel slip ratio is less than 0.2. If the result is false, it means that the current wheel slip ratio is greater than or equal to 0.2, and the wheel has a tendency to lock. The pressure relief valve needs to be opened to reduce the pressure on this wheel. The process of generating C code from this graphic code is as follows:
[0146] Step S601: Generate a corresponding globally unique ID for each execution unit in the graphic code. The corresponding table between execution units and IDs is as follows:
[0147] Step S602: Generate C code line by line from the graphic code according to the rules. There are four lines of code in total, and the content is shown in the following table:
[0148] After the code is generated, a file f1 is also generated, which contains 4 lines of code and the corresponding ids. The content is shown in the following table:
[0149] In step S603, the graphics code encodes the persistent configuration information of each execution unit through base64: Assume that the persistent configuration file f2 of the graphics code is as follows: [a1] conf=3302264560674696091;0;3659305742699578;8432990436527128597;342836535060 0537763;0;0;0;0;c2xpcCA8IDAuMiA / ;;0;0 [a2] conf=3428365350600537763;0;3302264560674696091;2570429621957346572;-1;0;1;0; 0;RVZfT24_;;0;0
[0150] After encoding the contents of the associated file f1 and the persistent configuration file f2 using base64, they are inserted into the comment area of the generated target C code as comments. The resulting target C code is as follows:
[0151] / / MzMwMjI2NDU2MDY3NDY5NjA5MQ0KDQozNDI4MzY1MzUwNjAwNTM3NzYzDQoNCg__,W2ExXQ0KY29uZj0zMzAyMjY 0NTYwNjc0Njk2MDkxOzA7MzY1OTMwNTc0MjY5OTU3ODs4NDMyOTkwNDM2NTI3MTI4NTk3OzM0MjgzNjUzNTA2MDA1Mz c3NjM7MDswOzA7MDtjMnhwY0NBOElEQXVNaUEvOzswOzANClthMl0NCmNvbmY9MzQyODM2NTM1MDYwMDUzNzc2Mzsw OzMzMDIyNjQ1NjA2NzQ2OTYwOTE7MjU3MDQyOTYyMTk1NzM0NjU3MjstMTswOzE7MDswO1JWWmZUMjRfOzswOzANCg.
[0152] In step S604, the user compiles the generated target C code and puts it into the vehicle controller for execution. Thus, the conversion of the graphics code for vehicle development into C code is completed.
[0153] The following describes the application of positioning information in automotive development scenarios using the logic of controlling the opening of a pressure relief valve as an example during the development of an ABS algorithm for automotive chassis electronics.
[0154] As shown in Figure 11, when the user finds that the function of opening the AV valve does not work and needs to check the corresponding logic, the user first loads the C code file with the graphic code, reads the comment information in the C code file, and obtains the configuration information and positioning information of the graphic code after base64 decoding. The graphic code is restored through the decoded configuration information; then the user clicks on the line of code "AV_On();" in the C code file window loaded with the graphic code. The graphic code locates the execution unit id "3428365350600537763" corresponding to the line number according to the positioning information, and the window jumps to the graphic code. The execution unit is highlighted in the graphic code display window, which makes it easy for the user to correct the execution unit, greatly improving the convenience and efficiency of troubleshooting.
[0155] The following describes in detail the application of positioning information in automotive test scenarios, taking the logic of controlling the opening of a pressure relief valve as an example during the development of the ABS algorithm for automotive chassis electronic control.
[0156] In actual automotive testing applications, software-in-the-loop (SIL) testing is required using C code logic generated from graphical code. Using the aforementioned logic for controlling the opening of the pressure relief valve as the test object, as shown in Figure 10, after generating C code from this graphical code snippet, further testing is required on the "AV_On" function within the C code to obtain information such as execution time and resource usage. This requires being able to locate the corresponding line of C code using the graphical code.
[0157] The positioning method is as follows: First, the user clicks on the execution unit "AV_On" in the graphic code and tries to jump to the corresponding C code line. The graphic code obtains the execution unit id "3428365350600537763" and reads the comment information in the C code file. After base64 decoding, the positioning information of the graphic code is obtained, that is, the correspondence file between the code line and the id is obtained. Then, the graphic code collects the code lines where this id appears in the file and presents it to the user in the form of a list. The user selects the corresponding option in the list, and the corresponding C code line can be located and displayed, which can greatly improve the test efficiency.
[0158] The following describes the electronic devices in some embodiments from the perspective of hardware processing, but does not limit the specific implementation of the electronic devices.
[0159] As shown in FIG12 , the electronic device includes: a processor, a readable storage medium, a communication bus, and a communication interface; wherein the processor, the readable storage medium, and the communication interface communicate with each other via the communication bus; the readable storage medium is used to store a program for executing the method for converting text codes into graphic codes, and the program enables the processor to execute operations corresponding to the method for converting text codes into graphic codes.
[0160] In other embodiments, a computer device or an industrial computer can also be used as a type of electronic equipment.
[0161] The structure shown in FIG12 does not limit the electronic device and may include fewer or more components than shown in the figure, or combine certain components, or arrange the components differently.
[0162] In some embodiments, the communication interface may be an RS232, RS485, USB port, or TYPE port, which may be connected to an external bus adapter. It may also include a wired or wireless network interface. The network interface may optionally include a wired interface and / or a wireless interface (such as a WI-FI interface, a Bluetooth interface, etc.), which is typically used to establish a communication connection between the computer device and other electronic devices.
[0163] Wherein, the storage module, the readable storage medium or the computer-readable storage medium includes at least one type of memory, and the memory includes a flash memory, a hard disk, a multimedia card, a card-type memory (for example, an SD or DX memory, etc.), a magnetic memory, a magnetic disk, an optical disk, etc. In some embodiments, it can be an internal storage unit of a computer device, such as a hard disk of the computer device. In other embodiments, the memory can also be an external storage device of the computer device, such as a plug-in hard disk equipped on the computer device, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card, etc. Furthermore, the memory can also include both an internal storage unit of the computer device and an external storage device. The memory can be used not only to store application software and various types of data installed in the computer device, such as computer program code, but also to temporarily store data that has been output or is to be output.
[0164] In some embodiments, the processor may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chip, used to run program codes stored in a memory or process data, such as executing a computer program.
[0165] In some embodiments, the communication bus may also be an input / output bus, which may be a Peripheral Component Interconnect (PCI) bus or an Enhanced Industry Standard Architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc.
[0166] Optionally, the computer device may further include a user interface, which may include a display and an input unit such as a keyboard. Optionally, the user interface may also include a standard wired interface or a wireless interface. Optionally, in some embodiments, the display or display module may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, or an OLED (Organic Light-Emitting Diode) touchscreen. The display or display module may also be appropriately referred to as a display screen or display unit, and is used to display information processed in the computer device and to display a visual user interface.
[0167] When the processor executes the program, it implements the steps of the text code to graphic code conversion method embodiment shown in Figure 1, such as steps S101 to S102 shown in Figure 1. Alternatively, when the processor executes the computer program, it implements the functions of each module or unit in the above-mentioned device embodiments.
[0168] In some embodiments, the processor is specifically configured to implement the following steps:
[0169] Converting the graphic code into text code, and inserting the configuration information of each execution unit in the current graphic code into the comment area of the target text code while generating the target text code; and
[0170] When converting the target text code back into the graphic code, the configuration information of the comment area of the target text code is extracted and loaded to restore the graphic code.
[0171] Optionally, as a possible implementation, the processor may also be configured to implement the following steps:
[0172] The configuration information is serialized and encoded and inserted into the comment area of the target text code in the form of text; and
[0173] When converting the target text code back into graphic code, the configuration information text in the comment area is extracted and deserialized and decoded to obtain the configuration information of each execution unit in the graphic code, and the configuration information is loaded to restore the graphic code.
[0174] Optionally, as a possible implementation, the processor may also be configured to implement the following steps:
[0175] Convert the sequential execution units in the graphic code into text codes corresponding to the unit actions;
[0176] Convert the branch jump unit in the graphic code into the text code of "if" or "else if" or "else" structure;
[0177] Converting nested execution units in the graphics code into a function that executes the nested text code and a function that calls the text code; and
[0178] Convert the loop unit in the graphic code into a label, a goto statement and the text code corresponding to the action of the loop unit.
[0179] Optionally, as a possible implementation, the processor may also be configured to implement the following steps:
[0180] Generate persistent configuration information for graphics code; and
[0181] The persistent configuration information is serialized and encoded and inserted into the comment area of the target text code in the form of text.
[0182] Optionally, as a possible implementation, the processor may also be configured to implement the following steps:
[0183] When the target text code is generated, the positioning information of each execution unit in the current graphic code is inserted into the corresponding target text code line.
[0184] Optionally, as a possible implementation, the processor may also be configured to implement the following steps:
[0185] When converting graphic code into text code, a temporary file is created to temporarily store the location information of each execution unit in the current graphic code;
[0186] The positioning information is an association file between each execution unit and the corresponding target text code line; and
[0187] The associated file is serialized and encoded and then inserted into the comment area of the target text code in the form of text.
[0188] At least one embodiment also provides a computer-readable storage medium, which stores a program for a method for converting text codes into graphic codes. When the program is executed by a processor, the specific steps of the method for converting text codes into graphic codes can be implemented. Please refer to the specific description of the method for converting text codes into graphic codes in some embodiments, which will not be repeated here.
[0189] As shown in FIG13 and FIG14, some embodiments further provide a vehicle development and debugging system, including: a computer device, a bus adapter or a burner;
[0190] The computer device includes: a processor, a readable storage medium, a communication bus and a communication interface; wherein
[0191] The readable storage medium is configured to store a program for executing the method for converting a text code into a graphic code, wherein the program causes a processor to execute operations corresponding to the method for converting a text code into a graphic code to generate a text code;
[0192] The processor, the readable storage medium and the communication interface communicate with the bus adapter via the communication bus;
[0193] The processor is configured to compile at least one execution code in the text code;
[0194] The bus adapter is configured to write the compiled execution code into the debugging device; or
[0195] The burner is configured to write the compiled execution code into the debugging device.
[0196] As shown in FIG15 , some embodiments further provide a vehicle development and debugging method, including:
[0197] In step S201, the computer device performs operations corresponding to the method for converting text code to graphic code to generate text code;
[0198] In step S202, the compiled executable code is written into the debugging device via a bus adapter; or the compiled executable code is written into the debugging device via a burner. In some embodiments, the computer device corresponds to the above-mentioned electronic device, which will not be described in detail here.
[0199] The processor is configured to compile at least one execution code in the text code; in some embodiments, the compilation of the text code can be achieved by executing a cross compiler.
[0200] In some embodiments, the configuration information is serialized and encoded and inserted into the comment area of the target text code in the form of text; and when the target text code is converted back into graphic code, the graphics program extracts the configuration information text in the comment area for deserialization and decoding to obtain the configuration information of each execution unit in the graphic code, and loads the configuration information to restore the graphic code.
[0201] In some embodiments, converting the graphic code into text code includes: converting the sequential execution unit in the graphic code into text code corresponding to the unit action; converting the branch jump unit in the graphic code into text code of "if" or "else if" or "else" structure; converting the nested execution unit in the graphic code into a function that executes the nested text code and a text code that calls the function; and converting the loop unit in the graphic code into a label, a goto statement and text code corresponding to the action of the loop unit.
[0202] In some embodiments, inserting the configuration information into the comment area of the target text code includes: generating persistent configuration information of the graphic code; and inserting the persistent configuration information into the comment area of the target text code in the form of text after serialization encoding.
[0203] In some embodiments, while the target text code is being generated, the location information of each execution unit in the current graphics code is respectively inserted into the corresponding target text code line.
[0204] In some embodiments, when converting graphic code into text code, a temporary file is created for temporarily storing the positioning information of each execution unit in the current graphic code; wherein the positioning information is an association file between each execution unit and the corresponding target text code line; and the association file is serialized and encoded and inserted into the comment area of the target text code in the form of text.
[0205] In some embodiments, the bus adapter can be a CAN bus adapter, a CAN FD bus adapter, a FastLIN bus adapter, a LIN bus adapter, an Ethernet bus adapter, or a FlexRay bus adapter. It can also be a one-way to multiple-way bus adapter or a multiple-way to multiple-way bus adapter. Some embodiments do not limit the specific implementation of the bus adapter. In some embodiments, the compiled executable code can be written to the debug device via the UDS, XCP, or CCP protocol.
[0206] In some embodiments, the burner may also be referred to as a programmer.
[0207] In some embodiments, the debugging equipment in the automotive field can specifically be a vehicle ECU and its related systems, such as but not limited to the electronic power steering system EPS, anti-lock braking system ABS, electronic stability system ESC, automobile engine management system, battery management system BMS and other devices can be connected to the computer device via a bus to receive and run the compiled execution code.
[0208] In some embodiments, a computer-readable storage medium stores computer-readable instructions, wherein the computer-readable instructions are executed by at least one processor to perform the following method:
[0209] Converting the graphic code into text code, and inserting the configuration information of each execution unit in the current graphic code into the comment area of the target text code while generating the target text code; and
[0210] When converting the target text code back into the graphic code, the graphic program extracts the configuration information of the comment area of the target text code and loads the configuration information to restore the graphic code.
[0211] In some embodiments, a computer program product includes a computer-readable storage medium storing computer-readable program code, wherein the computer-readable program code includes instructions that cause at least one processor (one or more computer devices) to:
[0212] Converting the graphic code into text code, and inserting the configuration information of each execution unit in the current graphic code into the comment area of the target text code while generating the target text code; and
[0213] When converting the target text code back into the graphic code, the graphic program extracts the configuration information of the comment area of the target text code and loads the configuration information to restore the graphic code.
[0214] In the several embodiments provided by the present invention, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely illustrative. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architectures, functions, and operations of the devices, methods, and computer program products according to multiple embodiments of the present invention. In this regard, each box in the flowchart or block diagram can represent a module, program segment, or part of the code, which contains one or more executable instructions for implementing the specified logical functions. It should also be noted that in some alternative implementations, the functions marked in the boxes can also occur in an order different from that marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, as well as the combination of boxes in the block diagram and / or flowchart, can be implemented using a dedicated hardware-based system that performs the specified functions or actions, or can be implemented using a combination of dedicated hardware and computer instructions.
[0215] In addition, the functional modules in the various embodiments of the present invention may be integrated together to form an independent part, or each module may exist independently, or two or more modules may be integrated to form an independent part.
[0216] If the functions are implemented in the form of software modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the portion that contributes to the prior art, or the portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes a number of instructions for causing a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in various embodiments of the present invention.
[0217] With the above-described preferred embodiments of the present invention as inspiration, and with reference to the above description, relevant personnel are fully capable of making various changes and modifications without departing from the technical scope of this invention. The technical scope of this invention is not limited to the contents of the specification and must be determined according to the scope of the claims.
[0218] Some embodiments further provide a computer program product, comprising a computer program or instructions, wherein when the computer program or instructions are executed on a computer, the computer is enabled to perform any of the above-mentioned possible methods for converting text codes into graphic codes.
Claims
1. A method for converting text code to graphic code, characterized in that: include: Converting the graphic code into text code, and inserting the configuration information of each execution unit in the current graphic code into the comment area of the target text code while the target text code is generated; as well as When converting the target text code back into the graphic code, the graphics program extracts the configuration information of the comment area of the target text code and loads the configuration information to restore the graphic code.
2. The conversion method according to claim 1, characterized in that: Also includes: The configuration information is serialized and encoded and inserted into the comment area of the target text code in the form of text; as well as When the target text code is converted back into the graphic code, the graphics program extracts the configuration information text in the comment area for deserialization decoding to obtain the configuration information of each execution unit in the graphic code, and loads the configuration information to restore the graphic code.
3. The conversion method according to claim 1, characterized in that: Methods for converting graphic codes to text codes include: Convert the sequential execution units in the graphic code into text codes corresponding to the unit actions; Convert the branch jump unit in the graphic code into the text code of "if" or "else if" or "else" structure; Converting nested execution units in the graphics code into a function that executes the nested text code and a function that calls the text code; and Convert the loop unit in the graphic code into a label, a goto statement and the text code corresponding to the action of the loop unit.
4. The conversion method according to claim 2, characterized in that: Methods for inserting configuration information into the comment area of the target text code include: Generate persistent configuration information for graphics code; and The persistent configuration information is serialized and encoded and inserted into the comment area of the target text code in the form of text.
5. The conversion method according to claim 4, characterized in that: Also includes: When the target text code is generated, the location information of each execution unit in the current graphic code is respectively inserted into the corresponding target text code line.
6. The conversion method according to claim 4, characterized in that: Also includes: When converting the graphic code into text code, a temporary file is created to temporarily store the location information of each execution unit in the current graphic code; in The positioning information is an association file between each execution unit and the corresponding target text code line; as well as The associated file is serialized and encoded and then inserted into the comment area of the target text code in the form of text.
7. A device for converting text code and graphic code, characterized in that: include: A processor, configured to execute a program of the method for converting a text code into a graphic code as claimed in any one of claims 1 to 6; A storage module, used for storing the program; as well as The display module is used to display the conversion results between text code and graphic code.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium is configured to store a program for executing the method for converting text code to graphic code as described in any one of claims 1 to 6.
9. An electronic device, comprising: Processor, readable storage medium, communication bus and communication interface; wherein the processor, the readable storage medium and the communication interface communicate with each other via the communication bus; The readable storage medium is used to store a program for executing the method for converting text code and graphic code as described in any one of claims 1 to 6, and the program enables the processor to execute operations corresponding to the method for converting text code and graphic code.
10. A vehicle development and debugging system, characterized in that: include: Computer device, bus adapter or writer; in The computer device comprises: a processor, a readable storage medium, a communication bus and a communication interface; wherein The readable storage medium is configured to store a program for executing the method for converting a text code into a graphic code according to any one of claims 1 to 6, wherein the program enables a processor to execute operations corresponding to the method for converting a text code into a graphic code to generate a text code; The processor, the readable storage medium and the communication interface communicate with the bus adapter via the communication bus; The processor is configured to compile at least one execution code in the text code; The bus adapter is configured to write the compiled execution code into a debugging device; or The burner is configured to write the compiled execution code into the debugging device.
11. The vehicle development and debugging system according to claim 10, characterized in that: The bus adapter is a CAN bus adapter, a CAN FD bus adapter, a FastLIN bus adapter, a LIN bus adapter, an Ethernet bus adapter, or a FlexRay bus adapter, and The bus adapter communicates with the debugging device through the UDS, XCP or CCP protocol to write the compiled execution code.
12. The vehicle development and debugging system according to claim 10, characterized in that: The debugging equipment includes electronic power steering system, anti-lock braking system, electronic stability system, automobile engine management system, and battery management system equipment.
13. A vehicle development and debugging method, characterized in that: include: Performing operations corresponding to the method for converting text code to graphic code according to any one of claims 1 to 6 by a computer device to generate a text code; Writing the compiled executable code into the debugging device via the bus adapter; or Write the compiled execution code to the debugging device through the programmer.
14. The vehicle development and debugging method according to claim 13, characterized in that: The bus adapter is a CAN bus adapter, a CAN FD bus adapter, a FastLIN bus adapter, a LIN bus adapter, an Ethernet bus adapter, or a FlexRay bus adapter, and The bus adapter communicates with the debugging device through UDS or XCP or CCP protocol to write the compiled execution code, and The debugging equipment includes electronic power steering system, anti-lock braking system, electronic stability system, automobile engine management system, and battery management system equipment.
15. A computer program product comprising: A computer program or instruction, wherein when the computer program or instruction is executed on a computer, the computer is enabled to execute the method for converting text code and graphic code as claimed in any one of claims 1 to 6.
Citation Information
Patent Citations
Graphical Python programming interaction method and system and electronic equipment
CN109634592A
Graphical programming system oriented to NB-IoT terminal
CN110941426A
Code display method, system and device for graphical programming scene and storage medium
CN112306481A
Logic diagram compiling detection method and system, electronic device and storage medium
CN114138641A
Graphical programming code conversion method and device, electronic equipment and storage medium
CN115857905A
