Automatic generation method and device of drive code, computer equipment and storage medium

By automatically generating driver code, the problems of low development efficiency and high cost when parsing or constructing messages or table entries of large space content in traditional methods are solved, achieving more efficient code development and reducing labor costs.

CN119512533APending Publication Date: 2025-02-25SHENZHEN JAGUAR MICROSYSTEMS CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311083554.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-08-25
Publication Date
2025-02-25

AI Technical Summary

Technical Problem

In traditional ways, when analyzing or constructing messages or table entries of large space content, it takes a lot of time and manual writing of parsing code for each bit segment, resulting in low code development efficiency and high labor costs.

Method used

Provides an automatic generation method of driver code. By obtaining format description data and initial driver code that matches the target data format, the format description data is written into the data structure of the initial driver code to generate driver code for processing the target. Data related to data format.

Benefits of technology

It reduces the probability of errors in the process of human code writing, improves the development efficiency of driver code, and reduces labor costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119512533A_ABST
    Figure CN119512533A_ABST
Patent Text Reader

Abstract

The invention relates to an automatic generation method and device of a drive code, computer equipment, a storage medium and a computer program product. The method comprises the steps of obtaining format description data matched with a target data format; the format description data comprises a bit field name, a start bit and a bit field width of each bit field in a plurality of bit fields, and the target data format comprises a message protocol format or a table item format; obtaining an initial driving code, wherein the initial driving code comprises a preset data structure and a code interface; the code interface comprises at least one of a bit field data configuration interface and a bit field data acquisition interface; writing the format description data into a data structure of the initial drive code to generate a drive code; the driving code is used for processing data related to the target data format, and the processing comprises at least one of analysis or construction. By adopting the method, the error probability in the manual code writing process can be reduced, the development efficiency of the drive code can be improved, and the labor cost can be reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a method, apparatus, computer device, storage medium and computer program product for automatically generating a driver code. Background Art

[0002] In the traditional way, when parsing messages or table entries, or constructing messages or table entries, the program code is manually written to parse or construct the value of each bit segment. When faced with the parsing or construction tasks of large space content (for example, PCIE configuration space, about 340 bytes), it takes a lot of time and manual writing of parsing codes for each bit segment. This method has low code development efficiency and high labor costs. Summary of the invention

[0003] Based on this, it is necessary to provide a method, device, computer equipment, computer-readable storage medium and computer program product for automatically generating driver code that can improve code development efficiency and reduce labor costs in response to the above technical problems.

[0004] In a first aspect, the present application provides a method for automatically generating a driver code. The method comprises:

[0005] Acquire format description data matching the target data format; the format description data includes a bit segment name, a start bit, and a bit segment width of each bit segment in a plurality of bit segments, and the target data format includes a message protocol format or a table entry format;

[0006] Acquire an initial driving code, wherein the initial driving code includes a preset data structure and a code interface; the code interface includes at least one of a bit segment data configuration interface or a bit segment data acquisition interface;

[0007] The format description data is written into the data structure of the initial driver code to generate a driver code; the driver code is used to process data related to the target data format, and the processing includes at least one of parsing or constructing.

[0008] In one embodiment, the construction process of the initial driver code includes:

[0009] Create code interface;

[0010] Constructing a data structure in which a bit segment name, a starting bit, and a bit segment width are declared;

[0011] The code interface is associated with the data structure to obtain an initial driving code.

[0012] In one of the embodiments, the bit segment data configuration interface is provided with a first start bit parameter and a first bit segment width parameter, and the bit segment data acquisition interface is provided with a second start bit parameter and a second bit segment width parameter;

[0013] The step of associating the code interface with the data structure to obtain an initial driving code includes:

[0014] Generate starting bit calling information and bit segment width calling information according to the data structure;

[0015] The starting position calling information is written into the first starting position parameter and / or the second starting position parameter, and the bit segment width calling information is written into the first bit segment width parameter and / or the second bit segment width parameter to obtain an initial driving code.

[0016] In one embodiment, the bit segment data acquisition interface is provided with a first address parameter; the method further comprises:

[0017] Writing address information of the data to be parsed into the first address parameter, the data to be parsed including a message to be parsed or a table entry to be parsed;

[0018] After the writing is completed, the driver code performs a parsing operation on the data to be parsed.

[0019] In one of the embodiments, the bit segment data configuration interface is provided with a second address parameter and a configuration value parameter;

[0020] The method further comprises:

[0021] Writing address information of the data to be constructed into the second address parameter, and writing information to be filled in into the configuration value parameter, wherein the data to be constructed includes a message to be constructed or a table item to be constructed;

[0022] After the writing is completed, the driver code performs a construction operation on the data to be constructed.

[0023] In one embodiment, the method further comprises:

[0024] Storing the driving code according to the identification information of the target data format;

[0025] When receiving data to be processed, querying a corresponding target driver code according to identification information of a format of the data to be processed, wherein the data to be processed includes a message to be processed or a table item to be processed;

[0026] A parsing operation or a construction operation is performed on the data to be processed according to the target driving code.

[0027] In a second aspect, the present application also provides a device for automatically generating a driving code. The device comprises:

[0028] A data acquisition module, used to acquire format description data matching a target data format; the format description data includes a bit segment name, a start bit, and a bit segment width of each bit segment in a plurality of bit segments, and the target data format includes a message protocol format or a table entry format;

[0029] A code acquisition module, used to acquire an initial driving code, wherein the initial driving code includes a preset data structure and a code interface; the code interface includes at least one of a bit segment data configuration interface or a bit segment data acquisition interface;

[0030] A code generation module is used to write the format description data into the data structure of the initial driver code to generate a driver code; the driver code is used to process data related to the target data format, and the processing includes at least one of parsing or construction.

[0031] In a third aspect, the present application further provides a computer device. The computer device includes a memory and a processor, the memory stores a computer program, and the processor implements the following steps when executing the computer program:

[0032] Acquire format description data matching the target data format; the format description data includes a bit segment name, a start bit, and a bit segment width of each bit segment in a plurality of bit segments, and the target data format includes a message protocol format or a table entry format;

[0033] Acquire an initial driving code, wherein the initial driving code includes a preset data structure and a code interface; the code interface includes at least one of a bit segment data configuration interface or a bit segment data acquisition interface;

[0034] The format description data is written into the data structure of the initial driver code to generate a driver code; the driver code is used to process data related to the target data format, and the processing includes at least one of parsing or constructing.

[0035] In a fourth aspect, the present application further provides a computer-readable storage medium. The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the following steps are implemented:

[0036] Acquire format description data matching the target data format; the format description data includes a bit segment name, a start bit, and a bit segment width of each bit segment in a plurality of bit segments, and the target data format includes a message protocol format or a table entry format;

[0037] Acquire an initial driving code, wherein the initial driving code includes a preset data structure and a code interface; the code interface includes at least one of a bit segment data configuration interface or a bit segment data acquisition interface;

[0038] The format description data is written into the data structure of the initial driver code to generate a driver code; the driver code is used to process data related to the target data format, and the processing includes at least one of parsing or constructing.

[0039] In a fifth aspect, the present application further provides a computer program product. The computer program product includes a computer program, and when the computer program is executed by a processor, the following steps are implemented:

[0040] Acquire format description data matching the target data format; the format description data includes a bit segment name, a start bit, and a bit segment width of each bit segment in a plurality of bit segments, and the target data format includes a message protocol format or a table entry format;

[0041] Acquire an initial driving code, wherein the initial driving code includes a preset data structure and a code interface; the code interface includes at least one of a bit segment data configuration interface or a bit segment data acquisition interface;

[0042] The format description data is written into the data structure of the initial driver code to generate a driver code; the driver code is used to process data related to the target data format, and the processing includes at least one of parsing or constructing.

[0043] The above-mentioned automatic generation method, device, computer equipment, storage medium and computer program product of driver code obtain format description data matching the target data format; the format description data includes the bit segment name, start bit and bit segment width of each bit segment in multiple bit segments, and the target data format includes a message protocol format or a table item format; obtain the initial driver code, the initial driver code includes a preset data structure and a code interface; the code interface includes at least one of a bit segment data configuration interface or a bit segment data acquisition interface; write the format description data into the data structure of the initial driver code to generate the driver code; the driver code is used to process data related to the target data format, and the processing includes at least one of parsing or construction. On the one hand, it can reduce the probability of errors in the process of manual code writing, and on the other hand, it can improve the development efficiency of the driver code and reduce labor costs. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] Figure 1 A schematic diagram of a process of automatically generating a driving code in an embodiment;

[0045] Figure 2 is a schematic diagram of a target data format in one embodiment;

[0046] Figure 3 A schematic diagram of a flow chart of performing a parsing operation using a driver code in one embodiment;

[0047] Figure 4 A schematic diagram of a process of executing a construction operation using a driver code in one embodiment;

[0048] Figure 5 It is a flowchart of using driver code to perform a parsing operation or a building operation in another embodiment;

[0049] Figure 6 is a structural block diagram of an automatic generation device of a driving code in an embodiment;

[0050] Figure 7 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0051] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0052] In one embodiment, Figure 1 As shown, this embodiment uses the method applied to a network device as an example for illustration. It can be understood that the method can also be applied to a computer, a server or a terminal, and can also be applied to a system including a network device and a server, and is implemented through the interaction between the network device and the server. This embodiment does not limit this. In this embodiment, the method includes the following steps:

[0053] Step 202, obtaining format description data matching the target data format; the format description data includes a bit segment name, a start bit and a bit segment width of each bit segment in a plurality of bit segments, and the target data format includes a message protocol format or a table entry format.

[0054] The format description data may be Excel table data, or other format data that supports computer reading. This embodiment uses Excel table data as an example for explanation. During use, network devices are configured with multiple message protocols to exchange and transmit data units in the network, and multiple table entries are maintained to complete routing addressing or forwarding functions. Different message protocols and different table entries follow different formats. In this embodiment, format description data matching the message protocol format or table entry format is obtained so that the network device can know the structure and bit segment meaning of the message protocol or table entry format.

[0055] For example, refer to Figure 2 , Figure 2 The table of PCIE Configuration Space Header is shown in Figure 1, where different bit segments represent different meanings and the length of the bit segments are also inconsistent. For example, "Revision ID" is from bit64 to bit71, a total of 8 bits; "ClassCode" is from bit72 to bit95, a total of 24 bits. Figure 2 The table entry format shown is filled in the following Table 1. The first column "name" in Table 1 is the bit segment name field, the second column "lsb" is the starting bit field, which is used to describe the starting bit of the bit segment, and the third column "width" is the bit segment width field. Optionally, the format description data also includes a default value field, such as the "default_value" column in Table 1, where the default value can be left blank, and the default value is 0 when not filled in.

[0056] Table 1:

[0057]

[0058] Among them, the bit field is a data storage structure that can store data compactly in the form of bits and allow the program to operate on the bits of this structure. The format description data can be filled in by the programmer according to the message protocol format or table entry format.

[0059] Optionally, a preset template is provided, and the programmer fills in the preset template according to the message protocol format or the table item format to obtain the format description data, and the preset template includes a blank bit segment name field, a start bit field, and a bit segment width field. The format description data can also be obtained by the network device querying the expression picture or description text of the target data format through the network, extracting the bit segment name, start bit, and bit segment width from it, and automatically filling it into each field of the preset template to obtain the format description data.

[0060] Optionally, the programmer stores format description data of various message protocol formats or table entry formats in a specific storage area, and the network device obtains the format description data from the storage area in sequence or according to identification information of the format to be processed, and generates corresponding driver code for each format description data.

[0061] Step 204, obtaining an initial driving code, wherein the initial driving code includes a preset data structure and a code interface; the code interface includes at least one of a bit segment data configuration interface or a bit segment data acquisition interface.

[0062] The initial driver code is the code generated by the code micro-architecture design in advance, refer to Figure 2 , in order to Figure 2To describe the PCIE configuration space table entry structure shown, it is necessary to analyze the bit segment meaning and bit segment range. For example, the "Device Id" in the table entry means that the device ID is stored in this bit segment, and its bit segment range is bit31 to bit16. Based on this, the designed initial driver code includes a bit code interface and a data structure, wherein the purpose of designing a bit segment data configuration interface or a bit segment data acquisition interface is to write or read data within each bit segment range, and the purpose of designing a data structure is to correspond the bit segment meaning to the bit segment range, and to express the bit interval in which the bit segment value of the table entry or message is located.

[0063] Step 206, writing the format description data into the data structure of the initial driver code to generate a driver code; the driver code is used to process data related to the target data format, and the processing includes at least one of parsing or constructing.

[0064] Among them, the format description data is written into the data structure of the initial driver code to form a new driver code, thereby realizing the automatic generation of the driver code. The initial driver code is a template code constructed in advance according to the code rules of all types of messages or table items. In different driver code generation scenarios, the same initial driver code can be called to realize the automatic generation of the driver code, thereby reducing the labor cost. The generated driver code can be directly used in the project. If the project has many messages or table items, the code can be automatically written by the method of this embodiment, with high generation efficiency and high code quality.

[0065] When the code interface includes a bit segment data configuration interface, the automatically generated driver code can be used to construct data related to the target data format; when the code interface includes a bit segment data acquisition interface, the automatically generated driver code can be used to parse data related to the target data format.

[0066] Optionally, when executing a data forwarding task, a driver code corresponding to the message protocol format is generated by the method of this embodiment, the driver code is run to construct a message to be forwarded, and the message is forwarded to other devices; when receiving a message sent by other devices, a driver code corresponding to the message protocol format is generated by the method of this embodiment, the driver code is run to parse the received message, and the value expressed by each segment of the message is extracted according to the format description data.

[0067] In the above-mentioned automatic generation method of driver code, format description data matching the target data format is obtained; the format description data includes the bit segment name, start bit and bit segment width of each bit segment in multiple bit segments, and the target data format includes a message protocol format or a table entry format; an initial driver code is obtained, and the initial driver code includes a preset data structure and a code interface; the code interface includes at least one of a bit segment data configuration interface or a bit segment data acquisition interface; the format description data is written into the data structure of the initial driver code to generate the driver code; the driver code is used to process data related to the target data format, and the processing includes at least one of parsing or construction. On the one hand, it can reduce the probability of errors in the process of manual code writing, and on the other hand, it can improve the development efficiency of the driver code and reduce labor costs.

[0068] In one embodiment, the construction process of the initial driver code includes: creating a code interface; constructing a data structure, in which a bit segment name, a starting bit and a bit segment width are declared; and associating the code interface with the data structure to obtain the initial driver code.

[0069] By associating the code interface in the initial driver code with the data structure, the driver code generated based on the initial driver code can read and write data from the bit segment range corresponding to each bit segment based on the data stored in the data structure during runtime.

[0070] Exemplarily, the data structure is designed as follows, which is used to express the bit interval where the bit segment value of the table entry / message is located:

[0071] typedef struct{

[0072] char*name;

[0073] unsigned int pos;

[0074] unsigned int width;

[0075] unsigned int reset_value;

[0076] }TBL_ENTRY_INFO_S;

[0077] Wherein, name indicates the name of the bit segment, pos indicates the starting position (which bit the corresponding bit segment starts from), width indicates the width of the bit segment (how many bits the corresponding bit segment occupies), and reset_value indicates the default value. This embodiment does not limit the specific composition of the data structure.

[0078] In one embodiment, the bit segment data configuration interface is provided with a first start bit parameter and a first bit segment width parameter, and the bit segment data acquisition interface is provided with a second start bit parameter and a second bit segment width parameter;

[0079] The method of associating the code interface with the data structure to obtain the initial driving code includes: generating starting position calling information and bit segment width calling information according to the data structure; writing the starting position calling information into the first starting position parameter and / or the second starting position parameter, and writing the bit segment width calling information into the first bit segment width parameter and / or the second bit segment width parameter to obtain the initial driving code.

[0080] Among them, the code interface is associated with the data structure through the starting bit calling information and the bit segment width calling information generated by the data structure, so that the driver code generated based on the initial driver code can read and write data from the bit segment range corresponding to each bit segment based on the data stored in the data structure when running. Optionally, the starting bit calling information and the bit segment width calling information are generated according to the name of the data structure and the preset calling information generation rules. The first and the second are only used to distinguish the parameters in different interfaces. In practice, the same parameter name can be used to represent them, or different parameter names can be used to represent them. This embodiment does not limit this.

[0081] Exemplarily, the bit segment data configuration interface is designed as follows:

[0082] int set_entry(unsigned int*tbl,int pos_bit,int width,unsigned longlong value);

[0083] Among them, set_entry is the bit segment data configuration interface, the input parameter tbl points to the address of the table entry / message, pos_bit is the first starting bit parameter, which is used to express the starting bit position, width is the first bit segment width parameter, which is used to express the bit segment width, and value is the configured value.

[0084] For example, the start position call information is A.pos, the bit segment width call information is A.width, the start position call information is written into the first start position parameter, and the bit segment width call information is written into the first bit segment width parameter. The bit segment data configuration interface in the initial driver code is as follows:

[0085] int set_entry(unsigned int*tbl,A.pos,A.width,value).

[0086] Exemplarily, the bit segment data acquisition interface is designed as follows:

[0087] unsigned long long get_entry(unsigned int*tbl,int pos_bit,int width);

[0088] Among them, get_entry is the bit segment data acquisition interface, the input parameter tbl points to the address of the table entry / message, pos_bit is the second starting bit parameter, used to express the starting bit position, and width is the second bit segment width parameter, used to express the bit segment width. Based on the bit segment data configuration interface and the bit segment data acquisition interface, data at a specified bit position can be obtained or configured.

[0089] For example, the starting position calling information is A.pos, the bit segment width calling information is A.width, the starting position calling information is written into the second starting position parameter, and the bit segment width calling information is written into the second bit segment width parameter, and the bit segment data acquisition interface in the initial driver code is obtained as follows:

[0090] unsigned long long get_entry(unsigned int*tbl,A.pos,A.width).

[0091] In this embodiment, by designing the driver interface and data structure, the parsing code of all types of messages or table items is regularly expressed, and the driver code corresponding to different message protocol formats or table item formats is automatically generated based on the code rules, thereby improving the development efficiency of the driver code and reducing labor costs.

[0092] In one embodiment, Figure 3 As shown, the bit segment data acquisition interface is provided with a first address parameter;

[0093] The method further comprises:

[0094] Step 302: write address information of the data to be parsed into the first address parameter, wherein the data to be parsed includes a message to be parsed or a table entry to be parsed.

[0095] The address information of the data to be parsed is used to indicate the storage location of the data to be parsed in the storage area. The address information of the data to be parsed is written into the first address parameter so that the data can be read from the storage location when the driver code is run.

[0096] Step 304: After writing is completed, the driver code performs a parsing operation on the data to be parsed.

[0097] For example, refer to the following get_entry data acquisition interface:

[0098] int set_entry(unsigned int*tbl,int pos_bit,int width,unsigned longlong value);

[0099] Among them, tbl is the first address parameter. The address information of the data to be parsed is written into the tbl parameter. The driver code can be run to read the bit segment data from the data to be parsed according to the start bit and bit segment width of each bit segment according to the address information to realize the data parsing operation.

[0100] In this embodiment, by writing the address information of the data to be parsed into the first address parameter of the bit segment data acquisition interface, the data to be parsed includes a message to be parsed or a table entry to be parsed; after the writing is completed, the parsing operation is performed on the data to be parsed through the driver code, and the automatically generated driver code can be used to parse the message or table entry, thereby improving the parsing efficiency of the message or table entry.

[0101] In one embodiment, Figure 4 As shown, the bit segment data configuration interface is provided with a second address parameter and a configuration value parameter;

[0102] The method further comprises:

[0103] Step 402: write the address information of the data to be constructed into the second address parameter, and write the information to be filled in into the configuration value parameter. The data to be constructed includes a message to be constructed or a table item to be constructed.

[0104] The address information of the data to be constructed is used to indicate the storage location of the data to be constructed in the storage area, and the information to be filled in is the data that needs to be filled in each segment or any segment in the message or table item. The address information of the data to be constructed is written into the second address parameter, and the information to be filled in is written into the configuration value parameter, so that when the driver code is run, the information to be filled in can be written into the data stored in the storage location. The first address parameter and the second address parameter are only used to distinguish parameters in different interfaces. In practice, the same parameter name can be used to represent them, or different parameter names can be used to represent them. This embodiment does not limit this.

[0105] Step 404: After writing is completed, a construction operation is performed on the data to be constructed through the driver code.

[0106] Optionally, refer to the following set_entry configuration interface:

[0107] int set_entry(unsigned int*tbl,int pos_bit,int width,unsigned longlong value);

[0108] Among them, tbl is the second address parameter, value is the configuration value parameter, the address information of the data to be constructed is written into the tbl parameter, and the information to be filled in is written into the value. When the driver code is run, the position of each segment in the data to be constructed can be determined according to the address information, the starting bit and the width of each segment, and the information to be filled in can be written into the corresponding position to realize the data construction operation.

[0109] In this embodiment, by writing the address information of the data to be constructed into the second address parameter of the bit segment data configuration interface, and writing the information to be filled in into the configuration value parameter, the data to be constructed includes a message to be constructed or a table item to be constructed; after the writing is completed, the construction operation is performed on the data to be constructed through the driver code, and the automatically generated driver code can be used to construct the message or table item, thereby improving the construction efficiency of the message or table item.

[0110] In one embodiment, Figure 5 As shown, the method also includes:

[0111] Step 502: Store the driving code according to the identification information of the target data format.

[0112] Optionally, the identification information of the target data format is stored correspondingly to the storage address of the driver code generated according to the target data format, exemplarily in the form of a key-value pair. For example, if the target data format is a PCIE protocol format, the corresponding identification information is "PCIE", and "PCIE" and the storage address of the driver code are stored in the form of a key-value pair.

[0113] Step 504: when receiving the data to be processed, query the corresponding target driver code according to the identification information of the format of the data to be processed, wherein the data to be processed includes a message to be processed or a table item to be processed.

[0114] Among them, a plurality of one-to-one corresponding identification information and driving codes are stored locally, and the identification information of the format of the data to be processed is used as a condition to query locally, determine the corresponding target storage address, access the target storage address, and obtain the corresponding target driving code.

[0115] Step 506: perform a parsing operation or a constructing operation on the data to be processed according to the target driver code.

[0116] Wherein, the address information of the data to be processed is written into the first address parameter of the bit segment data acquisition interface in the target driver code, and after the writing is completed, the target driver code performs a parsing operation on the data to be processed. Alternatively, the address information of the data to be processed is written into the second address parameter of the bit segment data configuration interface in the target driver code, and the data to be filled in is written into the configuration value parameter of the bit segment data configuration interface in the target driver code, and after the writing is completed, the target driver code performs a construction operation on the data to be processed.

[0117] In this embodiment, the driver code is stored according to the identification information of the target data format; when receiving the data to be processed, the corresponding target driver code is queried according to the format identification of the data to be processed, and the data to be processed includes a message to be processed or a table item to be processed; and the data to be processed is parsed or constructed according to the target driver code. In the above manner, when facing a large amount of data to be processed in different formats, the automatically generated driver code can be queried, and the queried driver code can be used to parse or construct the data, thereby improving the parsing efficiency and construction efficiency of the message or table item.

[0118] To illustrate the effect of the automatic generation method of the driving code in this solution, an example is described below:

[0119] 1. Build an automated tool to read message / table entry information, accurately identify the bit segments of the message / table entry, the meaning of each segment, and the bit range of each segment; and also to parse the message / table entry information and generate the corresponding driver code file.

[0120] 2. Since the protocol message and table entry formats are as follows Figure 2 The picture shown is for display and cannot be used directly. In this embodiment, the message / table item format is expressed in the Excel table shown in Table 1. Run the developed automation tool, read the data from the Excel table, and generate the driver code. The generated driver code can be directly used in the project. If the project has many messages or table items, the code can be automatically written in the manner of this embodiment. On the one hand, it can reduce the error probability in the process of manual code writing, and on the other hand, it can improve the development efficiency of the driver code and reduce labor costs.

[0121] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0122] Based on the same inventive concept, the embodiment of the present application also provides a device for automatically generating a driver code for implementing the method for automatically generating a driver code involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in the embodiments of one or more devices for automatically generating driver codes provided below can refer to the limitations of the method for automatically generating driver codes above, and will not be repeated here.

[0123] In one embodiment, Figure 6 As shown, a device for automatically generating a driving code is provided, comprising:

[0124] The data acquisition module 120 is used to acquire format description data matching the target data format; the format description data includes the bit segment name, start bit and bit segment width of each bit segment in multiple bit segments, and the target data format includes a message protocol format or a table entry format.

[0125] The code acquisition module 140 is used to acquire the initial driving code, wherein the initial driving code includes a preset data structure and a code interface; the code interface includes at least one of a bit segment data configuration interface or a bit segment data acquisition interface.

[0126] The code generation module 160 is used to write the format description data into the data structure of the initial driver code to generate the driver code; the driver code is used to process the data related to the target data format, and the processing includes at least one of parsing or construction.

[0127] In the above-mentioned automatic generation device of driver code, by obtaining format description data matching the target data format; the format description data includes the bit segment name, start bit and bit segment width of each bit segment in multiple bit segments, and the target data format includes a message protocol format or a table item format; obtaining the initial driver code, the initial driver code includes a preset data structure and a code interface; the code interface includes at least one of a bit segment data configuration interface or a bit segment data acquisition interface; writing the format description data into the data structure of the initial driver code to generate the driver code; the driver code is used to process data related to the target data format, and the processing includes at least one of parsing or construction. On the one hand, it can reduce the probability of errors in the process of manual code writing, and on the other hand, it can improve the development efficiency of the driver code and reduce labor costs.

[0128] In one embodiment, the automatic generation device of the driving code further includes a framework module;

[0129] The framework module is used to create a code interface; construct a data structure in which a bit segment name, a start bit and a bit segment width are declared; and associate the code interface with the data structure to obtain an initial driver code.

[0130] In one embodiment, the bit segment data configuration interface is provided with a first start bit parameter and a first bit segment width parameter, and the bit segment data acquisition interface is provided with a second start bit parameter and a second bit segment width parameter;

[0131] The framework construction module is also used to generate starting position calling information and bit segment width calling information according to the data structure; write the starting position calling information into the first starting position parameter and / or the second starting position parameter, and write the bit segment width calling information into the first bit segment width parameter and / or the second bit segment width parameter to obtain the initial driving code.

[0132] In one embodiment, the automatic generation device of the driving code further comprises a parsing module, and the bit segment data acquisition interface is provided with a first address parameter;

[0133] The parsing module is used to write address information of the data to be parsed into the first address parameter, and the data to be parsed includes a message to be parsed or a table entry to be parsed; after the writing is completed, the driver code performs a parsing operation on the data to be parsed.

[0134] In one embodiment, the automatic generation device of the driving code further comprises a construction module, and the bit segment data configuration interface is provided with a second address parameter and a configuration value parameter;

[0135] The construction module is used to write the address information of the data to be constructed into the second address parameter, and write the information to be filled in into the configuration value parameter, the data to be constructed includes a message to be constructed or a table item to be constructed; after the writing is completed, the construction operation is performed on the data to be constructed through the driver code.

[0136] In one embodiment, the automatic generation device of the driving code further includes a storage module, a query module and an execution module;

[0137] The storage module is used to store the driving code according to the identification information of the target data format;

[0138] The query module is used to query the corresponding target driver code according to the identification information of the format of the data to be processed when receiving the data to be processed, wherein the data to be processed includes a message to be processed or a table item to be processed;

[0139] The execution module is used to perform a parsing operation or a construction operation on the data to be processed according to the target driver code.

[0140] Each module in the automatic generation device of the above-mentioned driving code can be implemented in whole or in part by software, hardware and a combination thereof. Each of the above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory in the computer device in the form of software, so that the processor can call and execute the operations corresponding to each of the above modules.

[0141] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 7 As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. Among them, the processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store message data, table data or format description data. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a method for automatically generating a driver code is implemented.

[0142] Those skilled in the art will understand that Figure 7The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0143] In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the following steps are implemented:

[0144] Acquire format description data matching the target data format; the format description data includes a bit segment name, a start bit, and a bit segment width of each bit segment in a plurality of bit segments, and the target data format includes a message protocol format or a table entry format;

[0145] Acquire an initial driving code, wherein the initial driving code includes a preset data structure and a code interface; the code interface includes at least one of a bit segment data configuration interface or a bit segment data acquisition interface;

[0146] The format description data is written into the data structure of the initial driver code to generate a driver code; the driver code is used to process data related to the target data format, and the processing includes at least one of parsing or constructing.

[0147] In one embodiment, when the processor executes the computer program, the following steps are also implemented:

[0148] Create code interface;

[0149] Constructing a data structure in which a bit segment name, a starting bit, and a bit segment width are declared;

[0150] The code interface is associated with the data structure to obtain an initial driving code.

[0151] In one embodiment, the bit segment data configuration interface is provided with a first start bit parameter and a first bit segment width parameter, and the bit segment data acquisition interface is provided with a second start bit parameter and a second bit segment width parameter; when the processor executes the computer program, the following steps are also implemented:

[0152] The step of associating the code interface with the data structure to obtain an initial driving code includes:

[0153] Generate starting bit calling information and bit segment width calling information according to the data structure;

[0154] The starting position calling information is written into the first starting position parameter and / or the second starting position parameter, and the bit segment width calling information is written into the first bit segment width parameter and / or the second bit segment width parameter to obtain an initial driving code.

[0155] In one embodiment, the bit segment data acquisition interface is provided with a first address parameter, and the processor further implements the following steps when executing the computer program:

[0156] Writing address information of the data to be parsed into the first address parameter, the data to be parsed including a message to be parsed or a table entry to be parsed;

[0157] After the writing is completed, the driver code performs a parsing operation on the data to be parsed.

[0158] In one embodiment, the bit segment data configuration interface is provided with a second address parameter and a configuration value parameter, and the processor further implements the following steps when executing the computer program:

[0159] Writing address information of the data to be constructed into the second address parameter, and writing information to be filled in into the configuration value parameter, wherein the data to be constructed includes a message to be constructed or a table item to be constructed;

[0160] After the writing is completed, the driver code performs a construction operation on the data to be constructed.

[0161] In one embodiment, when the processor executes the computer program, the following steps are also implemented:

[0162] Storing the driving code according to the identification information of the target data format;

[0163] When receiving data to be processed, querying a corresponding target driver code according to identification information of a format of the data to be processed, wherein the data to be processed includes a message to be processed or a table item to be processed;

[0164] A parsing operation or a construction operation is performed on the data to be processed according to the target driving code.

[0165] In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:

[0166] Acquire format description data matching the target data format; the format description data includes a bit segment name, a start bit, and a bit segment width of each bit segment in a plurality of bit segments, and the target data format includes a message protocol format or a table entry format;

[0167] Acquire an initial driving code, wherein the initial driving code includes a preset data structure and a code interface; the code interface includes at least one of a bit segment data configuration interface or a bit segment data acquisition interface;

[0168] The format description data is written into the data structure of the initial driver code to generate a driver code; the driver code is used to process data related to the target data format, and the processing includes at least one of parsing or constructing.

[0169] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0170] Create code interface;

[0171] Constructing a data structure in which a bit segment name, a starting bit, and a bit segment width are declared;

[0172] The code interface is associated with the data structure to obtain an initial driving code.

[0173] In one embodiment, the bit segment data configuration interface is provided with a first start bit parameter and a first bit segment width parameter, and the bit segment data acquisition interface is provided with a second start bit parameter and a second bit segment width parameter; when the computer program is executed by the processor, the following steps are also implemented:

[0174] Generate starting bit calling information and bit segment width calling information according to the data structure;

[0175] The starting position calling information is written into the first starting position parameter and / or the second starting position parameter, and the bit segment width calling information is written into the first bit segment width parameter and / or the second bit segment width parameter to obtain an initial driving code.

[0176] In one embodiment, the bit segment data acquisition interface is provided with a first address parameter, and when the computer program is executed by the processor, the following steps are further implemented:

[0177] Writing address information of the data to be parsed into the first address parameter, the data to be parsed including a message to be parsed or a table entry to be parsed;

[0178] After the writing is completed, the driver code performs a parsing operation on the data to be parsed.

[0179] In one embodiment, the bit segment data configuration interface is provided with a second address parameter and a configuration value parameter, and when the computer program is executed by the processor, the following steps are further implemented:

[0180] Writing address information of the data to be constructed into the second address parameter, and writing information to be filled in into the configuration value parameter, wherein the data to be constructed includes a message to be constructed or a table item to be constructed;

[0181] After the writing is completed, the driver code performs a construction operation on the data to be constructed.

[0182] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0183] Storing the driving code according to the identification information of the target data format;

[0184] When receiving data to be processed, querying a corresponding target driver code according to identification information of a format of the data to be processed, wherein the data to be processed includes a message to be processed or a table item to be processed;

[0185] A parsing operation or a construction operation is performed on the data to be processed according to the target driving code.

[0186] In one embodiment, a computer program product is provided, comprising a computer program, which, when executed by a processor, implements the following steps:

[0187] Acquire format description data matching the target data format; the format description data includes a bit segment name, a start bit, and a bit segment width of each bit segment in a plurality of bit segments, and the target data format includes a message protocol format or a table entry format;

[0188] Acquire an initial driving code, wherein the initial driving code includes a preset data structure and a code interface; the code interface includes at least one of a bit segment data configuration interface or a bit segment data acquisition interface;

[0189] The format description data is written into the data structure of the initial driver code to generate a driver code; the driver code is used to process data related to the target data format, and the processing includes at least one of parsing or constructing.

[0190] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0191] Create code interface;

[0192] Constructing a data structure in which a bit segment name, a starting bit, and a bit segment width are declared;

[0193] The code interface is associated with the data structure to obtain an initial driving code.

[0194] In one embodiment, the bit segment data configuration interface is provided with a first start bit parameter and a first bit segment width parameter, and the bit segment data acquisition interface is provided with a second start bit parameter and a second bit segment width parameter; when the computer program is executed by the processor, the following steps are also implemented:

[0195] Generate starting bit calling information and bit segment width calling information according to the data structure;

[0196] The starting position calling information is written into the first starting position parameter and / or the second starting position parameter, and the bit segment width calling information is written into the first bit segment width parameter and / or the second bit segment width parameter to obtain an initial driving code.

[0197] In one embodiment, the bit segment data acquisition interface is provided with a first address parameter, and when the computer program is executed by the processor, the following steps are further implemented:

[0198] Writing address information of the data to be parsed into the first address parameter, the data to be parsed including a message to be parsed or a table entry to be parsed;

[0199] After the writing is completed, the driver code performs a parsing operation on the data to be parsed.

[0200] In one embodiment, the bit segment data configuration interface is provided with a second address parameter and a configuration value parameter, and when the computer program is executed by the processor, the following steps are further implemented:

[0201] Writing address information of the data to be constructed into the second address parameter, and writing information to be filled in into the configuration value parameter, wherein the data to be constructed includes a message to be constructed or a table item to be constructed;

[0202] After the writing is completed, the driver code performs a construction operation on the data to be constructed.

[0203] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0204] Storing the driving code according to the identification information of the target data format;

[0205] When receiving data to be processed, querying a corresponding target driver code according to identification information of a format of the data to be processed, wherein the data to be processed includes a message to be processed or a table item to be processed;

[0206] A parsing operation or a construction operation is performed on the data to be processed according to the target driving code.

[0207] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.

[0208] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.

[0209] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0210] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A method for automatically generating a driving code, characterized in that: The method comprises: Acquire format description data matching the target data format; the format description data includes a bit segment name, a start bit, and a bit segment width of each bit segment in a plurality of bit segments, and the target data format includes a message protocol format or a table entry format; Acquire an initial driving code, wherein the initial driving code includes a preset data structure and a code interface; the code interface includes at least one of a bit segment data configuration interface or a bit segment data acquisition interface; The format description data is written into the data structure of the initial driver code to generate a driver code; the driver code is used to process data related to the target data format, and the processing includes at least one of parsing or constructing.

2. The method according to claim 1, characterized in that: The construction process of the initial driver code includes: Create code interface; Constructing a data structure in which a bit segment name, a starting bit, and a bit segment width are declared; The code interface is associated with the data structure to obtain an initial driving code.

3. The method according to claim 2, characterized in that The bit segment data configuration interface is provided with a first start bit parameter and a first bit segment width parameter, and the bit segment data acquisition interface is provided with a second start bit parameter and a second bit segment width parameter; The step of associating the code interface with the data structure to obtain an initial driving code includes: Generate starting bit calling information and bit segment width calling information according to the data structure; The starting position calling information is written into the first starting position parameter and / or the second starting position parameter, and the bit segment width calling information is written into the first bit segment width parameter and / or the second bit segment width parameter to obtain an initial driving code.

4. The method according to any one of claims 1 to 3, characterized in that The bit segment data acquisition interface is provided with a first address parameter; the method further comprises: Writing address information of the data to be parsed into the first address parameter, the data to be parsed including a message to be parsed or a table entry to be parsed; After the writing is completed, the driver code performs a parsing operation on the data to be parsed.

5. The method according to any one of claims 1 to 3, characterized in that The bit segment data configuration interface is provided with a second address parameter and a configuration value parameter; The method further comprises: Writing address information of the data to be constructed into the second address parameter, and writing information to be filled in into the configuration value parameter, wherein the data to be constructed includes a message to be constructed or a table item to be constructed; After the writing is completed, the driver code performs a construction operation on the data to be constructed.

6. The method according to any one of claims 1 to 3, characterized in that The method further comprises: Storing the driving code according to the identification information of the target data format; When receiving data to be processed, querying a corresponding target driver code according to identification information of a format of the data to be processed, wherein the data to be processed includes a message to be processed or a table item to be processed; A parsing operation or a construction operation is performed on the data to be processed according to the target driving code.

7. A device for automatically generating a driving code, characterized in that: The device comprises: A data acquisition module, used to acquire format description data matching a target data format; the format description data includes a bit segment name, a start bit, and a bit segment width of each bit segment in a plurality of bit segments, and the target data format includes a message protocol format or a table entry format; A code acquisition module, used to acquire an initial driving code, wherein the initial driving code includes a preset data structure and a code interface; the code interface includes at least one of a bit segment data configuration interface or a bit segment data acquisition interface; A code generation module is used to write the format description data into the data structure of the initial driver code to generate a driver code; the driver code is used to process data related to the target data format, and the processing includes at least one of parsing or construction.

8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.