Embedded software development method and system
By using spreadsheets and Jinja2 templates to generate embedded software development methods, the problem of cumbersome communication protocol parsing in embedded systems is solved, and efficient and reliable embedded software development is achieved.
Patent Information
- Application Number
- CN202111355719.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-16
- Publication Date
- 2026-02-10
- Estimated Expiration
- 2041-11-16
AI Technical Summary
In embedded system development, communication protocol parsing is a tedious and time-consuming task, and manual parsing can easily introduce defects, affecting the effectiveness of use.
The protocol message data is parsed using spreadsheets, and the target executable file is generated using Jinja2 templates and filters, simplifying the protocol parsing process.
It improves the efficiency and readability of protocol parsing, reduces human error, simplifies the operation process, and improves development efficiency.
Smart Images

Figure CN114153432B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of embedded software development technology, and in particular to an embedded software development method and system. Background Technology
[0002] An embedded system consists of hardware and software, and is a device capable of operating independently. Its software comprises only the software runtime environment and its operating system. The hardware includes various components such as signal processors, memory, and communication modules.
[0003] In the field of embedded system development, it is often necessary to adapt different communication protocols according to different projects or different manufacturers. The parsing of communication protocols is a tedious task, and the parsing of communication protocols has a fixed format, with different data representing different meanings. If communication protocols are parsed manually, a lot of time will be wasted on repetitive work. Furthermore, due to personal negligence, some problems or defects that are not easily detected may be left during this process, affecting future use. Summary of the Invention
[0004] The embedded software development method and system provided by this invention address at least one of the aforementioned problems in the prior art. By using spreadsheets to parse protocol message data, the workload of protocol parsing is simplified, and the readability and maintainability of spreadsheets are improved. Operators can complete the relevant work after only simple training.
[0005] This invention provides an embedded software development method, comprising:
[0006] Based on the communication protocol of the embedded software development project, determine the first instruction for parsing the first message;
[0007] According to the first instruction, the second message is parsed into a preset electronic data table according to the target format;
[0008] The target executable file is determined based on the format of the parsed data in the first instruction and the preset electronic data table;
[0009] The target executable file is burned into the embedded software for execution, thereby completing the development of the embedded software;
[0010] The first message and the second message are both determined based on different data transmitted according to the communication protocol.
[0011] The message includes an identifier, a message ID, a message header, a message body, and a checksum.
[0012] According to an embedded software development method provided by the present invention, the step of parsing the second message into a preset electronic data table according to the first instruction in accordance with the target format includes:
[0013] The target format is determined according to the first instruction;
[0014] According to the target format, the second data is parsed into the preset electronic data table;
[0015] Specifically, after parsing the first message body in the second message to the preset electronic data table according to the target format, the parsed data of the second message body in the second message is automatically generated in the preset electronic data table;
[0016] The second message body is determined based on a message body that is associated with the first message body.
[0017] According to an embedded software development method provided by the present invention, the step of determining the target executable file based on the format of the first instruction and the parsed data in the preset electronic data sheet includes:
[0018] Based on the first instruction and the format of the parsed data, determine the Jinja2 template file;
[0019] The target executable file is determined based on the parsed data in the Jinja2 template file and the preset electronic data table.
[0020] According to an embedded software development method provided by the present invention, the step of determining the Jinja2 template file based on the format of the target instructions and the target data includes:
[0021] Based on the first instruction, the parsed data is formatted by combining the Jinja2 filter, Jinja2 conditional statement, and Jinja2 loop statement to generate the Jinja2 template file.
[0022] According to an embedded software development method provided by the present invention, determining the target executable file based on the parsed data in the Jinja2 template file and the preset electronic data sheet includes:
[0023] The program code file is determined based on the parsed data in the Jinja2 template file and the preset electronic data table;
[0024] The program code file is compiled to obtain the target executable file.
[0025] The present invention also provides an embedded software development system, comprising: an instruction determination module, a data parsing module, a file generation module, and a software development module;
[0026] The instruction determination module is used to determine the first instruction for parsing the first message according to the communication protocol of the embedded software development project.
[0027] The data parsing module is used to parse the second message into a preset electronic data table according to the target format based on the first instruction;
[0028] The file generation module is used to determine the target executable file based on the format of the parsed data in the first instruction and the preset electronic data table;
[0029] The software development module is used to burn the target executable file into the embedded software for execution, so as to complete the development of the embedded software.
[0030] The first message and the second message are both determined based on different data transmitted according to the communication protocol.
[0031] The message includes an identifier, a message ID, a message header, a message body, and a checksum.
[0032] According to an embedded software development system provided by the present invention, the data parsing module is further used for:
[0033] The target format is determined according to the first instruction;
[0034] According to the target format, the second data is parsed into the preset electronic data table;
[0035] Specifically, after parsing the first message body in the second message to the preset electronic data table according to the target format, the parsed data of the second message body in the second message is automatically generated in the preset electronic data table;
[0036] The second message body is determined based on a message body that is associated with the first message body.
[0037] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the steps of any of the embedded software development methods described above.
[0038] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of any of the embedded software development methods described above.
[0039] The present invention also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of any of the embedded software development methods described above.
[0040] The embedded software development method and system provided by this invention can accurately and in real time detect dangerous areas in the blind spot of a driver, and provide an alarm to pedestrians when they enter the dangerous area in the blind spot, thereby reducing the occurrence of safety accidents. Attached Figure Description
[0041] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0042] Figure 1 This is a flowchart illustrating the embedded software development method provided by the present invention;
[0043] Figure 2 This is a schematic diagram of the structure of the embedded software development system provided by the present invention;
[0044] Figure 3 This is a schematic diagram of the physical structure of the electronic device provided by the present invention. Detailed Implementation
[0045] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0046] Figure 1 This is a flowchart illustrating the embedded software development method provided by the present invention, as shown below. Figure 1 As shown, the method includes:
[0047] S1. Determine the first instruction for parsing the first message according to the communication protocol of the embedded software development project;
[0048] S2. According to the first instruction, parse the second message into a preset electronic data table according to the target format;
[0049] S3. Determine the target executable file based on the format of the parsed data in the first instruction and the preset electronic data table;
[0050] S4. Burn the target executable file into the embedded software for execution, thereby completing the development of the embedded software;
[0051] The first message and the second message are both determined based on different data transmitted according to the communication protocol;
[0052] A message includes an identifier, a message ID, a message header, a message body, and a checksum.
[0053] It should be noted that the subject executing the above method can be an electronic device, a component within an electronic device, an integrated circuit, or a chip. The electronic device can be a mobile electronic device or a non-mobile electronic device. For example, a mobile electronic device can be a mobile phone, tablet computer, laptop computer, PDA, in-vehicle electronic device, wearable device, ultra-mobile personal computer (UMPC), netbook, or personal digital assistant (PDA), etc., while a non-mobile electronic device can be a server, network attached storage (NAS), personal computer (PC), television (TV), ATM, or self-service machine, etc. This invention does not impose specific limitations.
[0054] Optionally, based on the communication protocol of the embedded software development project, and by transmitting arbitrary data according to the communication protocol to obtain the first message, a command is manually written to parse the first message according to the protocol. After the command is verified and achieves the actual use effect, this command is used as the first command to parse the first message.
[0055] The first message obtained after data is transmitted via a communication protocol specifically includes an identifier, a message ID, a message header, a message body, and a checksum.
[0056] Among them, communication protocols refer to the rules and agreements that two entities must follow to complete communication or services. Multiple data communication systems in different geographical locations are interconnected through communication channels and devices to enable them to work together to achieve information exchange and resource sharing.
[0057] According to the first instruction received, the second message is parsed into a preset electronic data table according to the target format required by the first instruction, and the parsed data of the second message is obtained; wherein, the second message is obtained by transmitting data based on the communication protocol, and the preset electronic data table can be specifically an Excel spreadsheet.
[0058] Based on the first instruction and the second message parsed into a preset electronic data table according to the target format, the format of the parsed data is obtained, the communication protocol of the embedded software development project is automatically parsed, the target executable file is determined, and then the target executable file is burned into the embedded software for operation, so as to complete the development of the embedded software.
[0059] The embedded software development method provided by this invention uses spreadsheets to parse protocol message data, which simplifies the workload of protocol parsing. Furthermore, spreadsheets have better readability and maintainability, and operators can complete the relevant work after only simple training.
[0060] Furthermore, in one embodiment, step S2 may specifically include:
[0061] S21. Determine the target format according to the first instruction;
[0062] S22. Parse the second data into a preset electronic spreadsheet according to the target format;
[0063] Specifically, after parsing the first message body in the second message to a preset spreadsheet according to the target format, the parsed data of the second message body in the second message is automatically generated in the preset spreadsheet;
[0064] The second message body is determined based on the message body that is related to the first message body.
[0065] Optionally, for message data corresponding to different data transmitted based on the same communication protocol, after receiving the first instruction to parse the first message, the second messages corresponding to other data transmitted based on the same communication protocol can be parsed into a preset electronic data table, such as an Excel spreadsheet, according to the target format required by the first instruction. Specifically:
[0066] The first instruction can be used as a protocol parsing example. In an Excel spreadsheet, the target format can be determined according to the protocol parsing example. Based on this target format, the second message can be parsed and written into the Excel spreadsheet.
[0067] For example, when parsing a second message with message ID 0X47, whose message body includes terminal type, manufacturer ID, terminal ID, terminal SIM card ICCID, terminal hardware version number length, and terminal hardware version number, based on the relationship between the above message bodies, the terminal hardware version number length can be first written into an Excel table according to the target format, and then the terminal hardware version number that is related to the terminal hardware version number length can be automatically generated in the Excel table.
[0068] It should be noted that in the Excel spreadsheet, you can set restrictions according to the actual situation (such as the terminal hardware version number being shorter than a preset value). Data exceeding the restrictions will be displayed as an error, which can prevent the editing of invalid data from causing subsequent code conversion based on the data in the Excel spreadsheet to malfunction.
[0069] The embedded software development method provided by this invention simplifies the workload of editing preset electronic data tables by utilizing the correlation between message bodies in a message.
[0070] Furthermore, in one embodiment, step S3 may specifically include:
[0071] S31. Determine the Jinja2 template file based on the format of the first instruction and the parsed data;
[0072] S32. Determine the target executable file based on the parsed data in the Jinja2 template file and the preset spreadsheet.
[0073] Furthermore, in one embodiment, step S31 may specifically include:
[0074] S311. Based on the first instruction, and in conjunction with the Jinja2 filter, Jinja2 conditional statement, and Jinja2 loop statement, the parsed data is format-converted to generate a Jinja2 template file.
[0075] Optionally, based on the format of the parsed data in the first instruction and the preset electronic spreadsheet, a Jinja2 template file is prepared, specifically:
[0076] Based on the first instruction, and in combination with Jinja2 filters, Jinja2 conditional statements, and Jinja2 loop statements, the parsed data in the preset spreadsheet is formatted to generate a Jinja2 template file.
[0077] Jinja2 filters can specifically include escape filters, format filters, and built-in filters.
[0078] Jinja2 conditional statements can be written in the following format:
[0079] {%if condition 1%}
[0080] Statement block 1
[0081] {%elif condition 2%}
[0082] statement block 2
[0083] {%else%}
[0084] Not meeting all conditions
[0085] {%endif%}
[0086] Jinja2 loop statements can be written in the following format:
[0087] {%for item in list%}
[0088] Execute if list is not empty
[0089] {%else%}
[0090] The default statement block executed when list is empty.
[0091] {%endfor%}
[0092] It should be noted that you can also write fixed text data in the generated Jinja2 template file to convert code that does not depend on Excel;
[0093] In Jinja2 template files, template code can be written according to coding standards, thereby avoiding manually written code that does not conform to coding standards.
[0094] The embedded software development method provided by this invention uses code files converted from Excel to completely replace the original files in the embedded software development project. It allows for one-click copy and paste without the need for code porting, which greatly saves development time and improves development efficiency in actual development.
[0095] Furthermore, in one embodiment, step S32 may specifically include:
[0096] S321. Determine the program code file based on the parsed data in the Jinja2 template file and the preset spreadsheet;
[0097] S322. Compile the program code file to obtain the target executable file.
[0098] Optionally, based on the generated Jinja2 template file and Excel spreadsheet data, a Python script (i.e., a program code file) is written to automatically convert the parsed data in the preset spreadsheet. After running the corresponding .py file, the target file is generated.
[0099] Depending on the actual engineering application, the code for converting data from an Excel spreadsheet can be divided into multiple different files, making it more flexible and convenient in practical applications.
[0100] The obtained program code file is compiled, and after successful compilation, the target file is replaced in the project to generate the target executable file. Finally, the target executable file is burned to the embedded device for execution.
[0101] It should be noted that a Python script refers to a complete Python program written in the Python language and saved in a file ending in .py.
[0102] Jinja2 templates are a template language implemented in Python. They are characterized by flexibility, speed, and security, and are widely used.
[0103] The embedded software development method provided by this invention uses Jinja2 templates and can be adapted to different coding languages such as C / C++, providing great convenience and flexibility in actual project needs.
[0104] The embedded software development system provided by the present invention is described below. The embedded software development system described below can be referred to in correspondence with the embedded software development method described above.
[0105] Figure 2 This is a schematic diagram of the embedded software development system provided by the present invention, such as... Figure 2 As shown, it includes:
[0106] The instruction determination module 210, the data parsing module 211, the file generation module 212, and the software development module 213;
[0107] The instruction determination module 210 is used to determine the first instruction for parsing the first message according to the communication protocol of the embedded software development project;
[0108] The data parsing module 211 is used to parse the second message into a preset electronic data table according to the target format based on the first instruction;
[0109] The file generation module 212 is used to determine the target executable file according to the first instruction and the format of the parsed data in the preset electronic data table;
[0110] Software development module 213 is used to burn the target executable file into the embedded software for execution, so as to complete the development of the embedded software;
[0111] Both the first message and the second message are determined based on data transmitted according to a communication protocol.
[0112] A message includes an identifier, a message ID, a message header, a message body, and a checksum.
[0113] The embedded software development system provided by this invention uses spreadsheets to parse protocol message data, which simplifies the workload of protocol parsing. Furthermore, spreadsheets have better readability and maintainability, and operators can complete related tasks after only simple training.
[0114] Furthermore, in one embodiment, the data parsing module 211 can also be specifically used for:
[0115] Determine the target format based on the first instruction;
[0116] According to the target format, the second data is parsed into a preset electronic spreadsheet;
[0117] Specifically, after parsing the first message body in the second message to a preset spreadsheet according to the target format, the parsed data of the second message body in the second message is automatically generated in the preset spreadsheet;
[0118] The second message body is determined based on the message body that is related to the first message body.
[0119] The embedded software development system provided by this invention,
[0120] Figure 3 This is a schematic diagram of the physical structure of an electronic device provided by the present invention, such as... Figure 3 As shown, the electronic device may include a processor 310, a communication interface 311, a memory 312, and a bus 313, wherein the processor 310, the communication interface 311, and the memory 312 communicate with each other via the bus 313. The processor 310 can call logical instructions in the memory 312 to execute the following methods:
[0121] Based on the communication protocol of the embedded software development project, determine the first instruction for parsing the first message;
[0122] According to the first instruction, the second message is parsed into a preset electronic data table according to the target format;
[0123] The target executable file is determined based on the format of the parsed data in the first instruction and the preset electronic data sheet;
[0124] The target executable file is burned into the embedded software for execution, thereby completing the development of the embedded software;
[0125] Both the first message and the second message are determined based on data transmitted according to a communication protocol.
[0126] A message includes an identifier, a message ID, a message header, a message body, and a checksum.
[0127] Furthermore, the logical instructions in the aforementioned memory can be implemented as software functional units and sold or used as independent products, and can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or a part 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 several instructions to cause a computer power supply (which may be a personal computer, server, or network power supply, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0128] Furthermore, this invention discloses a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium. The computer program includes program instructions, and when these instructions are executed by a computer, the computer can execute the embedded software development methods provided in the above-described method embodiments, such as including:
[0129] Based on the communication protocol of the embedded software development project, determine the first instruction for parsing the first message;
[0130] According to the first instruction, the second message is parsed into a preset electronic data table according to the target format;
[0131] The target executable file is determined based on the format of the parsed data in the first instruction and the preset electronic data sheet;
[0132] The target executable file is burned into the embedded software for execution, thereby completing the development of the embedded software;
[0133] Both the first message and the second message are determined based on data transmitted according to a communication protocol.
[0134] A message includes an identifier, a message ID, a message header, a message body, and a checksum.
[0135] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to perform the embedded software development methods provided in the above embodiments, for example including:
[0136] Based on the communication protocol of the embedded software development project, determine the first instruction for parsing the first message;
[0137] According to the first instruction, the second message is parsed into a preset electronic data table according to the target format;
[0138] The target executable file is determined based on the format of the parsed data in the first instruction and the preset electronic data sheet;
[0139] The target executable file is burned into the embedded software for execution, thereby completing the development of the embedded software;
[0140] Both the first message and the second message are determined based on data transmitted according to a communication protocol.
[0141] A message includes an identifier, a message ID, a message header, a message body, and a checksum.
[0142] The system embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0143] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., including several instructions to cause a computer power supply (which may be a personal computer, server, or network power supply, etc.) to execute the methods described in various embodiments or some parts of the embodiments.
[0144] 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 them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. An embedded software development method, characterized in that, include: Based on the communication protocol of the embedded software development project, determine the first instruction for parsing the first message; According to the first instruction, the second message is parsed into a preset electronic data table according to the target format; The target executable file is determined based on the format of the parsed data in the first instruction and the preset electronic data table; The target executable file is burned into the embedded software for execution, thereby completing the development of the embedded software; The first message and the second message are both determined based on different data transmitted according to the communication protocol. The message includes an identifier, a message ID, a message header, a message body, and a checksum; The step of parsing the second message into a preset electronic data table according to the target format based on the first instruction includes: The target format is determined according to the first instruction; According to the target format, the second data is parsed into the preset electronic data table; Specifically, after parsing the first message body in the second message to the preset electronic data table according to the target format, the parsed data of the second message body in the second message is automatically generated in the preset electronic data table; The second message body is determined based on a message body that is associated with the first message body.
2. The embedded software development method according to claim 1, characterized in that, The step of determining the target executable file based on the format of the parsed data in the first instruction and the preset electronic data table includes: Based on the first instruction and the format of the parsed data, determine the Jinja2 template file; The target executable file is determined based on the parsed data in the Jinja2 template file and the preset electronic data table.
3. The embedded software development method according to claim 2, characterized in that, The step of determining the Jinja2 template file based on the first instruction and the format of the parsed data includes: Based on the first instruction, the parsed data is formatted by combining the Jinja2 filter, Jinja2 conditional statement, and Jinja2 loop statement to generate the Jinja2 template file.
4. The embedded software development method according to claim 2, characterized in that, The step of determining the target executable file based on the parsed data in the Jinja2 template file and the preset electronic data sheet includes: The program code file is determined based on the parsed data in the Jinja2 template file and the preset electronic data table; The program code file is compiled to obtain the target executable file.
5. An embedded software development system, characterized in that, include: The module includes an instruction determination module, a data parsing module, a file generation module, and a software development module. The instruction determination module is used to determine the first instruction for parsing the first message according to the communication protocol of the embedded software development project. The data parsing module is used to parse the second message into a preset electronic data table according to the target format based on the first instruction; The file generation module is used to determine the target executable file based on the format of the parsed data in the first instruction and the preset electronic data table; The software development module is used to burn the target executable file into the embedded software for execution, thereby completing the development of the embedded software. The first message and the second message are both determined based on different data transmitted according to the communication protocol. The message includes an identifier, a message ID, a message header, a message body, and a checksum; The data parsing module is also used for: The target format is determined according to the first instruction; According to the target format, the second data is parsed into the preset electronic data table; Specifically, after parsing the first message body in the second message to the preset electronic data table according to the target format, the parsed data of the second message body in the second message is automatically generated in the preset electronic data table; The second message body is determined based on a message body that is associated with the first message body.
6. An electronic device comprising a processor and a memory storing a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the embedded software development method according to any one of claims 1 to 4.
7. A processor-readable storage medium, characterized in that, The processor-readable storage medium stores a computer program that causes the processor to perform the steps of the embedded software development method according to any one of claims 1 to 4.
8. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by the processor, it implements the steps of the embedded software development method as described in any one of claims 1 to 4.
Citation Information
Patent Citations
Code generation method and device, electronic equipment and computer readable storage medium
CN112256253A