Data processing method and device, electronic equipment and storage medium
By obtaining and parsing the service information files of middleware services and generating protocol parsing files, the problem of inconsistent SOME/IP payload data structure is solved, and efficient data analysis and labor cost are achieved.
Patent Information
- Application Number
- CN202410935919.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-12
- Publication Date
- 2025-03-14
AI Technical Summary
In the prior art, the custom characteristics of SOME/IP service of each OEM factory lead to inconsistent load data structures, and the test tool only supports SOME/IP header protocol analysis, resulting in poor accuracy and low efficiency of load data analysis.
By obtaining the service information file of the middleware service used in the vehicle, determining the target parameter data, and writing it to the pre-developed protocol resolution template, a protocol resolution file for the middleware service is generated, so that the data analysis tool can parse communication data packets.
It realizes the analysis of custom data of SOME/IP services of each OEM factory, improves analysis efficiency and reduces the labor cost of analysis.
Smart Images

Figure CN119629259A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of vehicle communication data processing, and in particular to a data processing method and device, electronic equipment, and storage medium. Background Art
[0002] After the automobile switched from traditional architecture to SOA (Service-Oriented Architecture), SOME / IP (Scalable Service-Oriented MiddlewarE over IP) protocol became one of the most widely used middleware to implement SOA. In the entire development process of the vehicle, developers and test verification personnel need to deal with SOME / IP data; especially when querying problems, they need to monitor SOME / IP data packets online in real time or play back and analyze the data, which requires the playback tool or device to support SOME / IP protocol parsing.
[0003] In the prior art, due to the customized characteristics of SOME / IP services of various host manufacturers, the SOME / IP payload data structure is not unified, and the test tools or equipment only support SOME / IP header protocol parsing; the SOME / IP payload data structure is usually complex and may have multiple layers of nesting. Parsing only by human eyes has poor accuracy and low efficiency. Summary of the invention
[0004] In view of the above problems, a method and device for data processing, an electronic device, and a storage medium are proposed to overcome the above problems or at least partially solve the above problems, including:
[0005] In a first aspect of the present invention, a data processing method is provided, wherein the method comprises:
[0006] Obtain service information files of middleware services used in the vehicle;
[0007] Determining target parameter data from the service information file;
[0008] The target parameter data is written into a pre-developed protocol parsing template to generate a protocol parsing file for the middleware service, so that when a data parsing tool obtains a communication data packet of the middleware service, it uses the protocol parsing file to parse and process the communication data packet.
[0009] Optionally, the service information file includes header information parameter data and payload information parameter data, and determining the target parameter data from the service information file includes:
[0010] Determining whether the service information file matches a preset file template;
[0011] When it is determined that the service information file matches the preset file template, multiple load information parameter data are determined from the service information file according to a preset classification mode, and the multiple load information parameter data are determined as target parameter data.
[0012] Optionally, the payload information parameter data includes service definition information and data type definition information, and the determining of a plurality of payload information parameter data from the service information file according to a preset classification mode includes:
[0013] Determining first-category payload information parameter data from the service definition information, wherein the first-category payload information parameter data at least includes a remote call type, interface parameters, and a transmission protocol corresponding to the middleware service;
[0014] Determining second-type load information parameter data from the data type definition information, wherein the second-type load information parameter data includes data type definition information whose data type is a discrete variable;
[0015] The third type of load information parameter data is determined from the service definition information, and the third type of load information parameter data includes the interface parameters and data structure information corresponding to the interface parameters; the data structure information includes at least data component elements, data types, and data length.
[0016] Optionally, the protocol parsing template includes a service determination variable; and the step of writing the target parameter data into a pre-developed protocol parsing template includes:
[0017] determining service determination data from the target parameter data;
[0018] According to the service judgment data, a value is assigned to the service judgment variable of the protocol parsing template to judge whether the communication data packet matches the middleware service.
[0019] Optionally, writing the target parameter data into a pre-developed protocol parsing template includes:
[0020] The payload information parameter data is encapsulated based on a preset protocol parsing language, and the encapsulated target parameter data is written into the protocol parsing template.
[0021] Optionally, encapsulating the payload information parameter data based on a preset protocol parsing language includes:
[0022] Extracting interface parameters corresponding to the middleware service from the first type of load information parameter data;
[0023] Determining data structure information corresponding to the interface parameters from the third type of load information parameter data according to the interface parameters corresponding to the middleware service;
[0024] Processing the data structure information corresponding to the interface parameters in a preset serialization manner to obtain a serial byte data stream, and encapsulating the byte data stream;
[0025] The second type of load information parameter data is encapsulated in the format of an enumerated variable.
[0026] Optionally, the protocol parsing file includes: a protocol parsing object, a parsing main function, and a parsing table. The parsing object includes at least a protocol name and a parsing field corresponding to the protocol. The parsing main function is used to parse the communication data packets of the middleware service. The parsing table is used to register the protocol parsing file into the parsing table of the data parsing tool.
[0027] In a second aspect of the present invention, there is also provided a data processing device, characterized in that it includes:
[0028] A file acquisition module, used to acquire a service information file of a middleware service used in the vehicle;
[0029] A data determination module, used to determine target parameter data from the service information file;
[0030] The parsing file generation module is used to write the target parameter data into a pre-developed protocol parsing template to generate a protocol parsing file for the middleware service, so that when the data parsing tool obtains the communication data packet of the middleware service, it uses the protocol parsing file to parse and process the communication data packet.
[0031] In a third aspect of the present invention, there is also provided an electronic device, comprising a processor, a memory, and a computer program stored in the memory and capable of running on the processor;
[0032] The processor, when the computer program is executed by the processor, implements any of the above-mentioned data processing methods.
[0033] In a fourth aspect of the implementation of the present invention, a computer-readable storage medium is provided, wherein instructions are stored in the computer-readable storage medium, and when the computer-readable storage medium is run on a computer, the computer executes any of the above-mentioned data processing methods.
[0034] The embodiment of the present invention has the following advantages: by acquiring the service information file of the middleware service used in the vehicle, determining the target parameter data from the service information file, writing the target parameter data into a pre-developed protocol parsing template, and generating a protocol parsing file for the middleware service, so that when the data parsing tool acquires the communication data packet of the middleware service, the protocol parsing file is used to parse and process the communication data packet, thereby realizing the parsing of the SOME / IP service custom data of each host manufacturer, improving the parsing efficiency, and reducing the labor cost of the parsing. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] In order to more clearly illustrate the technical solution of the present invention, the accompanying drawings required for use in the description of the present invention will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative labor.
[0036] Figure 1 is a flowchart of steps of a data processing method provided by some embodiments of the present invention;
[0037] Figure 2 is a structural diagram of a parsing module provided in some embodiments of the present invention;
[0038] Figure 3 It is a specific execution flow chart of the generation of the protocol parsing file provided by some embodiments of the present invention;
[0039] Figure 4 It is a structural block diagram of a data processing device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0040] In order to make the above-mentioned purposes, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0041] Reference Figure 1 , shows a flowchart of a data processing method provided by some embodiments of the present invention, which may specifically include the following steps:
[0042] Step 101: Obtain a service information file of a middleware service used in a vehicle.
[0043] The middleware service refers to SOME / IP, which is a service-oriented middleware protocol for the automotive industry. It allows efficient data exchange and service calls between different electronic control units (ECUs) inside the vehicle and between the vehicle and external systems. SOME / IP is part of the AUTOSAR (Automotive Open System Architecture) standard, which is designed to support complex software architectures and functions in modern vehicles. The service information file is a document that describes the service interactions between various electronic control units in the vehicle. This file usually contains detailed information about the service interface, such as service name, method, event, field, and data type. This file is part of the AUTOSAR standard and is used to ensure that communication between different ECUs follows consistent specifications.
[0044] In some embodiments of the present invention, the service information file may also be referred to as a service matrix file. The service matrix file is provided by the vehicle manufacturer or system integrator as an important reference in the vehicle software development and integration process. Developers can use these files to implement SOME / IP communication and ensure correct interaction between different ECUs.
[0045] Specifically, the service information file can be an xlsx (Excel spreadsheet) service matrix file, which is convenient for manual editing and viewing. Files in this format can contain all information related to the SOME / IP service, such as service ID, service interface, method, event, field, data type, etc. The present invention uses a service information file in Excel format, provides an intuitive table layout and powerful data processing functions, so that development and testing members can collaborate and maintain service information more easily.
[0046] Step 102: Determine target parameter data from the service information file.
[0047] In SOME / IP communication, the data packet carrying communication information consists of two parts: the header and the payload. The header contains basic information about the message, and the payload contains the actual data content transmitted. Therefore, the SOME / IP service information file describes the detailed information of the service interface, including parameter information for the header and parameter information for the payload.
[0048] In some embodiments of the present invention, payload information parameter data is determined from the service information file and used as target parameter data. This part of data contains specific information of method calls, event notifications or field updates of the service interface. In the service matrix file in Excel format, the payload part may list in detail the data structure and serialization format of each service operation (method, event, field) in the form of a table.
[0049] In some embodiments of the present invention, the service information file includes header information parameter data and payload information parameter data, and step 101 may include the following sub-steps:
[0050] Sub-step 11: determining whether the service information file matches a preset file template;
[0051] The preset file template refers to the standard format corresponding to the service information file.
[0052] In some embodiments of the present invention, after obtaining the service information file, the input file is first checked according to a preset file template to see whether it conforms to a specified standard template. If it is not standard, a file error is prompted and the system exits.
[0053] Sub-step 12: when it is determined that the service information file matches the preset file template, multiple load information parameter data are determined from the service information file according to a preset classification mode, and the multiple load information parameter data are determined as target parameter data.
[0054] After determining that the service information file complies with the standard format, the data in the service information file will be processed and various load information parameter data will be determined therefrom according to the classification mode.
[0055] In some embodiments of the present invention, the payload information parameter data includes service definition information and data type definition information, and sub-step 12 may further include the following sub-steps:
[0056] Sub-step 111: determining first-category payload information parameter data from the service definition information, wherein the first-category payload information parameter data at least includes a remote call type, interface parameters, and a transmission protocol corresponding to the middleware service.
[0057] The payload information parameter data mainly includes service definition and data type definition. The service definition includes service name, service identifier, RPC type (Remote Procedure Call), event / method id (event / interface unique identifier), transmission protocol, service interface parameters, etc. The transmission protocols include TCP (Transmission Control Protocol) and UDP (User Datagram Protocol). The data type is defined as the specific data structure of the service interface parameters in the service definition, including name, data type (integer, floating point, Boolean, array, string, structure, etc.), basic data type, maximum and minimum length of array or string, dynamic and static, physical maximum value, minimum value, discrete value, etc.
[0058] In some embodiments of the present invention, after the load information parameter data is determined, the extracted data is also verified for validity. If the service name and service identifier in the service definition already exist, or the interface parameters of the service definition are not defined in the data type, or the elements of the array or structure defined in the data type are not completely defined, etc., the data verification fails, a failure message is displayed, and the cause of the error is prompted.
[0059] In some embodiments of the present invention, after determining that the data verification is successful, the data is classified and processed according to three types, and the first type of load information parameter data is determined from the service definition information. The first type of load information parameter data includes the remote call type, interface parameters and transmission protocol corresponding to the middleware service. Specifically, the RPC type corresponding to each service in the service definition and the corresponding interface parameters and transmission protocol are determined as the first type of load information parameter data. For example, the RPC type can be FF (Fire & Forget) or RR (Request-Response), and the transmission protocol can be UDP or TCP.
[0060] Sub-step 112: Determine second-type load information parameter data from the data type definition information, where the second-type load information parameter data includes data type definition information whose data type is a discrete variable.
[0061] In some embodiments of the present invention, the data type definition information contains the data type name and specific discrete description of the discrete value description, and such data is used as the second type of load information parameter data.
[0062] Sub-step 113: Determine the third type of payload information parameter data from the service definition information, wherein the third type of payload information parameter data includes the interface parameters and data structure information corresponding to the interface parameters; the data structure information includes at least data component elements, data type, and data length.
[0063] As can be seen from the foregoing, the service definition information includes interface parameters, and the interface parameters correspond to data structure information. In some embodiments of the present invention, all data types corresponding to all interface parameters are determined from the service definition information, and are determined as the third type of load information parameter data; the data types corresponding to all interface parameters defined by the service are not necessarily all basic data types, but also include array and structure elements. Specifically, the elements in the data whose data structure is a structure or an array are iteratively processed until the data structure of all data is a basic type or a string.
[0064] Step 103: Write the target parameter data into a pre-developed protocol parsing template to generate a protocol parsing file for the middleware service, so that when a data parsing tool obtains a communication data packet of the middleware service, it uses the protocol parsing file to parse the communication data packet.
[0065] Among them, the protocol parsing template is a template for generating a protocol parsing file. The protocol parsing file is a script file. By using the protocol parsing script file through the data parsing tool, the vehicle communication data can be parsed to obtain the parsing result.
[0066] In some embodiments of the present invention, the protocol parsing template is a Lua template, the generated protocol parsing file is a Lua script file, and the data parsing tool can be wireshark. Among them, the Lua template refers to a template engine written in Lua language, and the present invention generates a Lua script file output through the Lua template; wireshark is an open source network protocol analysis tool, which allows users to capture and view data packets on the network. By using wireshark, network administrators and security experts can deeply analyze network traffic, diagnose network problems, monitor network activities, and conduct security audits. Wireshark supports a variety of network protocols and can display detailed information of network data packets in real time, including source address, destination address, protocol used, data packet content, etc. It also provides powerful filtering and search functions to help users quickly locate specific data packets or traffic patterns. In addition, wireshark also supports saving captured data packets in multiple formats, which is convenient for users to perform offline analysis. It is applicable to multiple operating system platforms such as Windows, macOS, and Linux.
[0067] In some embodiments of the present invention, through the wireshark software, enter the folder option, open the personal Lua script folder, put the generated Lua script file in this folder, return to the wireshark operation interface, click the reload Lua script file in the analysis option, run wireshark, capture SOME / IP data packets or replay SOME / IP data, and realize the automatic parsing of SOME / IP header and payload data. In some other embodiments of the present invention, the generation path of the Lua script can also be configured in the python console, the generation path is designated as the Lua script folder of the wireshark software, and the Lua script is directly generated in this folder, so that wireshark loads the Lua script file, captures SOME / IP data packets or replays SOME / IP data.
[0068] like Figure 2 As shown, it is a structural diagram of the parsing module provided by some embodiments of the present invention, including a python console and a wireshark operating console, wherein the python console system includes: a service information file input module, a service information file reading module, a configuration module, a script input module, a service information data processing module, a script data processing module, a script generation module, and a display module; the wireshark operating console includes: placing personal script folders, loading service parsing script controls, and running script file protocol parsing.
[0069] like Figure 3 As shown, it is a specific execution flow chart of the generation of the protocol parsing file provided by some embodiments of the present invention, including the following specific steps:
[0070] Start the Python project and select the SOME / IP service information file for which you want to generate the Lua script. The program will internally check the validity of the file format. If it fails, an error message will be displayed in the display window and then the program will stop.
[0071] If the service information file is verified, the service information file reading module will extract the service definition and data type definition information, and then check the data validity, such as the duplication of service name and service ID, the RPC type does not meet the requirements, the data type is not fully defined, etc. If the verification is passed, the data is processed in categories: enumeration type data, service + interface parameter data, interface parameter data type data;
[0072] Parameter configuration, including the configuration of the transmission protocol UDP / TCP and the identification port, Lua file name and the generated path, and prompts in the display window; the transmission protocol and the specified port are necessary information for the parser to register to the parsing table, and the data is identified by the protocol through these two information; also configure the new Lua file name and specify the Lua file storage path according to actual needs;
[0073] Input protocol parsing template (Lua template), extract service information parameters and write entry information;
[0074] The service information data processing module converts the data classified by the service information file reading module into data streams according to the SOME / IP serialization method and stores the data stream information;
[0075] The script data processing module first encapsulates the enumeration type data and interface parameter data according to the Lua programming language to implement the enumeration type and protocol field definition in the protocol parsing object; secondly, the converted data stream information is combined with the service information parameters of the input protocol parsing template to encapsulate the Lua programming language to implement the main function payload data parsing in the protocol parsing file; finally, the configuration transmission protocol and port are encapsulated according to the Lua programming language to implement the Lua protocol parsing table registration;
[0076] The encapsulated information is written into the input protocol parsing template through the write entry of the input protocol parsing template, a new script file is generated according to the Lua configuration, and output to the configuration file path for subsequent wireshark protocol parsing software to parse the SOME / IP data packet.
[0077] In some embodiments of the present invention, the protocol parsing template includes a service determination variable, and step 103 further includes the following sub-steps:
[0078] Sub-step 21: Determine service judgment data from the target parameter data.
[0079] The service information file can include many services for SOME / IP. Each service has different method interfaces. When parsing the payload information of a service, it is necessary to first identify whether the current data is the service to be parsed. The function of the service judgment variable is to identify whether the current data is the service to be parsed, that is, to match the service, interface, and data packet requests defined in the service information file one by one.
[0080] In the related art, the protocol parsing template has realized the SOME / IP header format parsing, and has the function of parsing the SOME / IP header protocol. The parsed content includes: service id, method id, length field, client id, session id, SOME / IP version, interface version, message type, return code. In some embodiments of the present invention, the protocol parsing template defines the parameter values required for SOME / IP payload parsing, and defines local variables or global variables as service judgment variables required for SOME / IP payload parsing, such as v_serviceid, v_methodid, v_messagetype, v_returncode, etc., and also realizes the calculation of parameters such as v_serviceid, v_methodid, v_messagetype, v_returncode, etc. When parsing the payload field subsequently, it is necessary to obtain these variable values to determine whether the current data is a SOME / IP service, so as to parse the subsequent payload data according to the service interface serialization method corresponding to the service.
[0081] In some embodiments of the present invention, service judgment data is determined from target parameter data, and values are assigned to service judgment variables in a protocol parsing template, thereby matching the services and interfaces defined in the service information file with the corresponding requests and responses during subsequent actual parsing.
[0082] Sub-step 22: assigning a value to the service judgment variable of the protocol parsing template according to the service judgment data to determine whether the communication data packet matches the middleware service.
[0083] After extracting the service judgment data, match and assign values to the service judgment variables in the protocol parsing template, that is, extract the information in the service information file and write it into the protocol parsing template. When parsing the payload field of SOME / IP later, the protocol parsing template uses the values of variables such as v_serviceid, v_methodid, v_messagetype, and v_returncode to determine whether the current data is a certain SOME / IP service, and then parse the subsequent payload data according to the service interface serialization method corresponding to the service.
[0084] In some embodiments of the present invention, step 103 further includes the following sub-steps:
[0085] Sub-step 31: Encapsulate the payload information parameter data based on a preset protocol parsing language, and write the encapsulated target parameter data into a required protocol parsing template.
[0086] Among them, the preset protocol parsing language is Lua, which is a lightweight and efficient scripting language.
[0087] In some embodiments of the present invention, the payload information parameter data is encapsulated based on the Lua protocol parsing language, and the encapsulated parameter data is written into a Lua template, thereby generating a Lua protocol parsing script to implement subsequent parsing operations on the payload data.
[0088] In some embodiments of the present invention, sub-step 31 further includes the following sub-steps:
[0089] Sub-step 211: extracting interface parameters corresponding to the middleware service from the first type of load information parameter data.
[0090] It can be seen from the above steps that the first type of load information parameter data includes interface parameters and transmission protocols. Therefore, according to the transmission protocol set by the previous parameter configuration, the interface parameters under the transmission protocol supported by the service are extracted from the first type of load information parameter data.
[0091] Sub-step 212: Determine data structure information corresponding to the interface parameters from the third type of load information parameter data according to the interface parameters corresponding to the middleware service.
[0092] After the interface parameters are determined, data structure information corresponding to the interface parameters is determined from the third type of payload information parameter data, where the data structure information includes data component elements, data types, and data length.
[0093] Sub-step 213: Process the data structure information corresponding to the interface parameters according to a preset serialization method to obtain a serial byte data stream, and encapsulate the byte data stream.
[0094] The preset serialization method refers to the SOME / IP serialization method. In SOME / IP, serialization generally refers to the process of converting a data structure into a byte stream so as to be sent over a network.
[0095] In some embodiments of the present invention, the data structure information corresponding to the interface parameters is processed by SOME / IP serialization to obtain a serial byte data stream, the format and length of which correspond one-to-one to the bus data actually obtained. The byte stream is encapsulated to implement parsing of each field under the data structure corresponding to each service interface.
[0096] Specifically, 1. Search for all data types corresponding to the interface parameter in the data type definition until the final data type is a basic type; for example: if the data type corresponding to the interface parameter is a structure element, take out all elements under the structure element. If the data types of these elements still exist as arrays and structures, then get all elements under these array and structure data type elements, and follow this method until the data types of the final elements are all basic data types; 2. Sequentially store and record the subordinate relationships between various data types to ensure that subsequent field parsing is carried out according to the defined data structure hierarchy; the data structure defined by the service interface may have a complex hierarchical structure, the most common of which are multi-layer nesting of structures and cross-use of arrays and structures. For example, a service interface is a structure type element. The structure elements contain elements of data types such as integer, string and array, and the elements of array type are composed of structure, array and string data type elements; in the above example, arrays and strings also have static or dynamic types; the data structure is defined according to the complexity of functional requirements. When creating the payload parsing function of each service, any subordination or order error may cause subsequent Lua file errors or wireshark parsing errors. Therefore, when obtaining each element of the data structure, the subordination and order between the elements must be guaranteed; 3. After obtaining the elements that make up the service interface, obtain the current value in the order of the elements obtained, and correspond to the parsing fields one by one, traverse all interface data structures defined by the service, and then you can start constructing the main parsing function in the protocol parsing template.
[0097] In some embodiments of the present invention, in the process of constructing the main parsing function, when the obtained element is a dynamic string or a dynamic array and a structure, a length field of a specified length is added according to the SOME / IP protocol standard; when the obtained element exists in an array or a structure, in order to better display and observe in the subsequent parsing, a subtree is added to the array or structure element, and the array and structure constituent elements are placed under the subtree, and are expanded according to the tree level in the subsequent parsing. In the specific implementation of the present invention, if the name of the previous tree layer is subtree, a new subtree msg_payload_tree is created, which is displayed as "SOME / IP PAYLOAD". If the data structure to be parsed has only one element AppSrv_OnOffCmd, the data type is integer, uint8, and the corresponding service ID and methd ID are 0x0001 and 0x0018 respectively, the RPC type is FF, message type = 0x01, returncode = 0x0; then the parsing function structure is defined as follows:
[0098] msg_payload_tree=subtree:add(p_SOME / IP,buf(),"SOME / IP PAYLOAD")
[0099] if v_serviceid==0x0001 and v_methodid==0x0018 and v_messagetype==0x01 and v_returncode==0x00 then
[0100] msg_payload_tree:add(AppSrv_OnOffCmd,buf(offset,1))
[0101] Among them, offset is the total length from the SOME / IP header to the element before, and 1 represents 1 byte. By adding the word count, when parsing a SOME / IP message in Wireshark, specific nodes are added to the message tree according to the content of the message, so that users can view and analyze the content of the data packet more intuitively.
[0102] In the specific implementation of the present invention, an array subtree is created: a service ID = 0x0002, event / method ID = 0x0001, the RPC type of one of the service interfaces is R / R, the data structure elements of the service interface are CallerId, CfgPara, where CallerId is uint8, length 2 bytes, CfgPara is a dynamic array, the maximum number is 10, then the parsing function structure is defined as follows:
[0103]
[0104]
[0105] Among them, the current tree name is msg_payload_tree. Add an element CallerId with an offset length increment of +2. Since CfgPara is dynamic, a length field also needs to be added. The default length of the length field is 4 bytes, and the offset length is incremented by +4. Since CfgPara is an array, a subtree needs to be added to store all array elements. Add a subtree CfgPara_tree under the msg_payload_tree. The maximum number of elements in the CfgPara array is 10, which is implemented by polling with for i = 0, 9, 1. Since the length of the CfgPara array is dynamic, it is necessary to judge whether the current data offset length is the maximum data length if offset < buf_len before parsing each array element. Each element of the CfgPara array consists of Inputkey and InputValue. Add a single array parsing subtree CfgPara_dynarray to store the elements Inputkey and InputValue, with lengths of 4 bytes respectively. After parsing each element, the offset length is incremented according to the actual length of the element, which further facilitates users to intuitively view and analyze the content of the data packet.
[0106] Sub-step 214: Encapsulate the second type of payload information parameter data in the format of an enumerated variable.
[0107] The second type of payload information parameter obtained in the foregoing step includes data type definition information with a data type of discrete variable. Therefore, in some embodiments of the present invention, it is encapsulated in the format defined by an enumerated variable for subsequent parsing field calls.
[0108] Specifically, the enumerated variable is described as follows:
[0109] appsrv_onoffcmd =
[0110] {
[0111] [0x0] = "APPSRV_ONOFFCMD_NO_REQUEST",
[0112] [0x1] = "APPSRV_ONOFFCMD_OFF",
[0113] [0x2] = "APPSRV_ONOFFCMD_ON"
[0114] }
[0115] Among them, 0x0 is mapped to "APPSRV_ONOFFCMD_NO_REQUEST", indicating no request; 0x1 is mapped to "APPSRV_ONOFFCMD_OFF", indicating a close command; 0x2 is mapped to "APPSRV_ONOFFCMD_ON", indicating an open command.
[0116] If the parsing field uses enumeration data,
[0117] fields.AppSrv_OnOffCmd=ProtoField.uint8("p_SOME / IP.AppSrv_OnOffCmd","AppSrv_OnOffCmd",base.DEC,appsrv_onoffcmd,0xff)
[0118] Among them, p_SOME / IP is the protocol, fields.AppSrv_OnOffCmd is the protocol field of the p_SOME / IP protocol, the data type is uint8, base.DEC represents the decimal display value, and the protocol field fields.AppSrv_OnOffCmd calls the enumeration variable appsrv_onoffcmd for display;
[0119] During parsing, if the value of this field is 0, it will be displayed as AppSrv_OnOffCmd: APPSRV_ONOFFCMD_NO_REQUEST
[0120] If the parsed field does not use enumeration data,
[0121] fields.AppSrv_OnOffCmd=ProtoField.uint8("p_SOME / IP.AppSrv_OnOffCmd","AppSrv_OnOffCmd",base.DEC)
[0122] During parsing, if the value of this field is 0, it is displayed as AppSrv_OnOffCmd: 0.
[0123] In some embodiments of the present invention, a protocol parsing file includes: a protocol parsing object, a parsing main function, and a parsing table. The parsing object includes at least a protocol name and a parsing field corresponding to the protocol. The parsing main function is used to parse the communication data packets of the middleware service, and the parsing table is used to register the protocol parsing file into the parsing table of the data parsing tool.
[0124] The protocol parsing object includes the name of the protocol, the parsing field of the protocol, and the "data" parser; the name of the protocol is the name of the protocol to be parsed, the parsing field of the protocol is the component element of the protocol to be parsed, and the "data" parser is when the data packet is not a custom protocol, Wireshark will call the "data" parser for parsing. The parsing main function is an important part of the protocol parsing. When the data packet is a protocol to be parsed, Wireshark will automatically call the parsing main function. The function of the parsing table is to register the protocol parsing file into the parsing table of Wireshark.
[0125] Specifically, the main function has three variables: buf, pkt, and root, where buf is the protocol data to be parsed; pkt is the information on the protocol parsing tree; root represents the previous parsing tree; in the process of creating the parser main function, the data length and offset length of the protocol parsing field are set through buf to obtain the actual value of the field. Protocol parsing is to correspond the field to the actual value obtained one by one; more levels of subtrees are established through root to better distinguish the levels during parsing; for example: an array-type field with 10 fixed elements, each array element consists of a structure, which contains 1 uint8 and 1 For string type elements, in order to better observe during parsing, a layer of subtree subroot can be established for each array element to store the elements of the structure. When wireshark performs parsing, the data will be displayed layer by layer according to the tree level, that is, root->subroot, subroot has 10 array elements, and each subroot data element is under 1 uint8 element and 1 string element; the main function of the parser converts the data length, data type, etc. defined by the SOME / IP interface parameters into a serial byte data stream on the bus according to the SOME / IP serialization method, thereby realizing data parsing. In addition, the protocol parsing file is registered in the parsing table of wireshark, which mainly includes two registration information: first, adding the transmission protocol to the parsing table, and second, adding a specified port for the transmission protocol. When identifying the communication data later, the protocol is identified according to the port number.
[0126] The embodiment of the present invention obtains the service information file of the middleware service used in the vehicle, determines the target parameter data from the service information file, writes the target parameter data into a pre-opened protocol parsing template, and generates a protocol parsing file for the middleware service, so that when the data parsing tool obtains the communication data packet of the middleware service, it uses the protocol parsing file to parse and process the communication data packet, thereby realizing the parsing of the SOME / IP service custom data of each host manufacturer, improving the parsing efficiency, and reducing the labor cost of the parsing.
[0127] It should be noted that, for the sake of simplicity, the method embodiments are described as a series of action combinations, but those skilled in the art should be aware that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.
[0128] Reference Figure 4 , shows a schematic diagram of the structure of a data processing device provided by an embodiment of the present invention, which may specifically include the following modules:
[0129] The file acquisition module 401 is used to acquire the service information file of the middleware service used in the vehicle;
[0130] A data determination module 402, used to determine target parameter data from the service information file;
[0131] The parsing file generation module 403 is used to write the target parameter data into a pre-developed protocol parsing template to generate a protocol parsing file for the middleware service, so that when the data parsing tool obtains the communication data packet of the middleware service, it uses the protocol parsing file to parse and process the communication data packet.
[0132] In an optional embodiment of the present invention, the data determination module 402 includes:
[0133] A judgment submodule, used to judge whether the service information file matches a preset file template;
[0134] The data determination submodule is used to determine a plurality of load information parameter data from the service information file according to a preset classification mode when it is determined that the service information file matches a preset file template, and determine the plurality of load information parameter data as target parameter data.
[0135] In an optional embodiment of the present invention, the data determination submodule includes:
[0136] A data determining first subunit is used to determine first type of load information parameter data from the service definition information, wherein the first type of load information parameter data at least includes a remote call type, interface parameters and a transmission protocol corresponding to the middleware service;
[0137] A data determination second subunit is used to determine the second type of load information parameter data from the data type definition information, wherein the second type of load information parameter data includes data type definition information whose data type is a discrete variable;
[0138] The data determines the third subunit, which is used to determine the third type of load information parameter data from the service definition information, and the third type of load information parameter data includes the interface parameters and the data structure information corresponding to the interface parameters; the data structure information at least includes data component elements, data type, and data length.
[0139] In an optional embodiment of the present invention, the parsing file generation module 403 includes:
[0140] A judgment data determination submodule, used to determine service judgment data from the target parameter data;
[0141] The variable assignment submodule is used to assign a value to the service judgment variable of the protocol parsing template according to the service judgment data, so as to judge whether the communication data packet matches the middleware service.
[0142] In an optional embodiment of the present invention, the parsing file generation module 403 further includes:
[0143] The encapsulation submodule is used to encapsulate the payload information parameter data based on a preset protocol parsing language, and write the encapsulated target parameter data into the required protocol parsing template.
[0144] In an optional embodiment of the present invention, the encapsulation submodule includes:
[0145] A first encapsulation subunit, configured to extract interface parameters corresponding to the middleware service from the first type of load information parameter data;
[0146] A second encapsulation subunit is used to determine data structure information corresponding to the interface parameters from the third type of load information parameter data according to the interface parameters corresponding to the middleware service;
[0147] A third encapsulation subunit is used to process the data structure information corresponding to the interface parameters according to a preset serialization method to obtain a serial byte data stream, and encapsulate the byte data stream;
[0148] The fourth encapsulation subunit is used to encapsulate the second-type load information parameter data according to the format of enumerated variables.
[0149] In an optional embodiment of the present invention, the protocol parsing file includes: a protocol parsing object, a parsing main function, and a parsing table. The parsing object includes at least a protocol name and a parsing field corresponding to the protocol. The parsing main function is used to parse the communication data packets of the middleware service. The parsing table is used to register the protocol parsing file into the parsing table of the data parsing tool.
[0150] The embodiment of the present invention obtains a service information file of a middleware service used in a vehicle, determines target parameter data from the service information file, writes the target parameter data into a pre-developed protocol parsing template, and generates a protocol parsing file for the middleware service, so that when a data parsing tool obtains a communication data packet of the middleware service, it uses the protocol parsing file to parse and process the communication data packet, thereby realizing the parsing of the SOME / IP service custom data of each host manufacturer, improving the parsing efficiency, and reducing the labor cost of the parsing.
[0151] An embodiment of the present invention further provides an electronic device, which may include a processor, a memory, and a computer program stored in the memory and capable of running on the processor, and the computer program implements the above data processing method when executed by the processor.
[0152] An embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the above data processing method is implemented.
[0153] Some embodiments of the present invention further provide a computer program product, including a computer program, which implements the above data processing method when executed by a processor.
[0154] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0155] 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 the relevant laws, regulations and standards of the relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0156] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0157] Those skilled in the art will appreciate that the embodiments of the present invention may be provided as methods, devices, or computer program products. Therefore, the embodiments of the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the embodiments of the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.
[0158] The embodiments of the present invention are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0159] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0160] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0161] Although the preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present invention.
[0162] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal device. In the absence of further restrictions, the elements defined by the sentence "including one..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the above elements.
[0163] The data processing method and device, electronic device, and storage medium provided above are introduced in detail. Specific examples are used in this article to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.
Claims
1. A method for data processing, characterized in that: The method comprises: Obtain service information files of middleware services used in the vehicle; Determining target parameter data from the service information file; The target parameter data is written into a pre-developed protocol parsing template to generate a protocol parsing file for the middleware service, so that when a data parsing tool obtains a communication data packet of the middleware service, it uses the protocol parsing file to parse and process the communication data packet.
2. The method according to claim 1, characterized in that The service information file includes header information parameter data and payload information parameter data, and determining target parameter data from the service information file includes: Determining whether the service information file matches a preset file template; When it is determined that the service information file matches the preset file template, multiple load information parameter data are determined from the service information file according to a preset classification mode, and the multiple load information parameter data are determined as target parameter data.
3. The method according to claim 2, characterized in that The load information parameter data includes service definition information and data type definition information. The multiple load information parameter data are determined from the service information file according to a preset classification mode, including: Determining first-category payload information parameter data from the service definition information, wherein the first-category payload information parameter data at least includes a remote call type, interface parameters, and a transmission protocol corresponding to the middleware service; Determining second-type load information parameter data from the data type definition information, wherein the second-type load information parameter data includes data type definition information whose data type is a discrete variable; The third type of load information parameter data is determined from the service definition information, and the third type of load information parameter data includes the interface parameters and data structure information corresponding to the interface parameters; the data structure information includes at least data component elements, data types, and data length.
4. The method according to claim 2, characterized in that: The protocol parsing template includes a service judgment variable; the writing of the target parameter data into the pre-developed protocol parsing template includes: determining service determination data from the target parameter data; According to the service judgment data, a value is assigned to the service judgment variable of the protocol parsing template to judge whether the communication data packet matches the middleware service.
5. The method according to claim 3, characterized in that: Writing the target parameter data into a pre-developed protocol parsing template comprises: The payload information parameter data is encapsulated based on a preset protocol parsing language, and the encapsulated target parameter data is written into the protocol parsing template.
6. The method according to claim 5, characterized in that The encapsulating the payload information parameter data based on a preset protocol parsing language includes: Extracting interface parameters corresponding to the middleware service from the first type of load information parameter data; Determining data structure information corresponding to the interface parameters from the third type of load information parameter data according to the interface parameters corresponding to the middleware service; Processing the data structure information corresponding to the interface parameters in a preset serialization manner to obtain a serial byte data stream, and encapsulating the byte data stream; The second type of load information parameter data is encapsulated in the format of an enumerated variable.
7. The method according to claim 1, characterized in that The protocol parsing file includes: a protocol parsing object, a parsing main function, and a parsing table. The parsing object includes at least a protocol name and a parsing field corresponding to the protocol. The parsing main function is used to parse the communication data packets of the middleware service. The parsing table is used to register the protocol parsing file into the parsing table of the data parsing tool.
8. A data processing device, characterized in that: The device comprises: A file acquisition module, used to acquire a service information file of a middleware service used in the vehicle; A data determination module, used to determine target parameter data from the service information file; The parsing file generation module is used to write the target parameter data into a pre-developed protocol parsing template to generate a protocol parsing file for the middleware service, so that when the data parsing tool obtains the communication data packet of the middleware service, it uses the protocol parsing file to parse and process the communication data packet.
9. An electronic device, characterized in that: The method comprises a processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein when the computer program is executed by the processor, the method for data processing according to any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method for data processing according to any one of claims 1 to 7 is implemented.