CN115086449A - Data analysis method and device and computer readable storage medium - Google Patents
Data analysis method and device and computer readable storage medium Download PDFInfo
- Publication number
- CN115086449A CN115086449A CN202210511804.2A CN202210511804A CN115086449A CN 115086449 A CN115086449 A CN 115086449A CN 202210511804 A CN202210511804 A CN 202210511804A CN 115086449 A CN115086449 A CN 115086449A
- Authority
- CN
- China
- Prior art keywords
- data
- analysis
- parameter
- frame
- offset
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 48
- 238000007405 data analysis Methods 0.000 title claims abstract description 42
- 238000004458 analytical method Methods 0.000 claims abstract description 204
- 238000006243 chemical reaction Methods 0.000 claims description 43
- 238000007667 floating Methods 0.000 claims description 28
- 230000001360 synchronised effect Effects 0.000 claims description 4
- 238000004891 communication Methods 0.000 description 11
- 238000010586 diagram Methods 0.000 description 6
- 230000008569 process Effects 0.000 description 4
- 230000005540 biological transmission Effects 0.000 description 3
- 238000005516 engineering process Methods 0.000 description 2
- 230000006870 function Effects 0.000 description 2
- 238000004519 manufacturing process Methods 0.000 description 2
- 238000012545 processing Methods 0.000 description 2
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000010276 construction Methods 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 238000012423 maintenance Methods 0.000 description 1
- 238000007726 management method Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 238000004806 packaging method and process Methods 0.000 description 1
- 230000007723 transport mechanism Effects 0.000 description 1
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L69/00—Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
- H04L69/18—Multiprotocol handlers, e.g. single devices capable of handling multiple protocols
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L12/00—Data switching networks
- H04L12/28—Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
- H04L12/40—Bus networks
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L69/00—Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
- H04L69/22—Parsing or analysis of headers
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Computer Security & Cryptography (AREA)
- Communication Control (AREA)
Abstract
The embodiment of the invention discloses a data analysis method, a data analysis device and a computer readable storage medium, wherein the data analysis method comprises the following steps: acquiring data frames to be analyzed transmitted based on bus protocols, wherein the formats of the data frames transmitted by different bus protocols are different; searching whether an analysis format matched with a bus protocol exists in a preset analysis file, wherein different analysis formats corresponding to different bus protocol data frame formats are configured in the analysis file; and when the analysis file has an analysis format matched with the bus protocol, analyzing the data frame to be analyzed by using the analysis format. The data analysis method, the data analysis device and the computer readable storage medium disclosed by the embodiment of the invention can support various protocol types, support the analysis of any frame format and solve the problem that codes need to be reconstructed when the protocol is changed at present.
Description
Technical Field
The present invention relates to the field of communications, and in particular, to a data parsing method, apparatus and computer readable storage medium.
Background
In the field of data communication, protocol is made according to project requirements, different production units have respective specific data formats, and most of the current protocol analysis adopts a method of making a corresponding protocol analysis program for each type of data protocol.
When data transmission is carried out based on a bus protocol, the interface characteristics of each port are defined differently, received data frames are different, if a message receiving processing logic is designed for each frame of message aiming at each interface, the workload is large, when the protocol is changed, codes must be modified, even all the codes need to be rewritten occasionally, the software of the whole system is huge and is fat, the whole system is not universal, and the subsequent maintenance and management are not facilitated.
Disclosure of Invention
The embodiment of the application provides a data analysis method, which comprises the following steps:
acquiring data frames to be analyzed transmitted based on bus protocols, wherein the formats of the data frames transmitted by different bus protocols are different;
searching whether an analysis format matched with the bus protocol exists in a preset analysis file, wherein different analysis formats corresponding to different bus protocol data frame formats are configured in the analysis file;
and when an analysis format matched with the bus protocol exists in the analysis file, analyzing the data frame to be analyzed by using the analysis format.
The embodiment of the application also provides a data analysis device, which comprises a memory and a processor, wherein the memory is used for storing the execution instruction; the processor calls the execution instruction to execute the data analysis method of any embodiment.
The embodiments of the present application also provide a computer-readable storage medium, on which computer instructions are stored, and when the instructions are executed by a processor, the steps of the method described in any embodiment are implemented.
Compared with the prior art, the data analysis method, the data analysis device and the computer-readable storage medium provided by at least one embodiment of the application have the following beneficial effects: the method can receive data frames of various bus protocols according to the analysis file, determine a frame analysis mode according to the bus protocol adopted by the data frames, convert the frame analysis mode into a parameter value with practical significance, can support various protocol types and support the analysis of any frame format, does not need to modify a program when the frame protocol is changed, only needs to modify the analysis file, improves the flexibility and the universality of data analysis, and solves the problem that codes need to be reconstructed when the protocol is changed at present.
Additional features and advantages of the application will be set forth in the description which follows, and in part will be obvious from the description, or may be learned by the practice of the application. Other advantages of the present application may be realized and attained by the instrumentalities and combinations particularly pointed out in the specification and the drawings.
Drawings
The accompanying drawings are included to provide an understanding of the present disclosure and are incorporated in and constitute a part of this specification, illustrate embodiments of the disclosure and together with the examples serve to explain the principles of the disclosure and not to limit the disclosure.
Fig. 1 is a flowchart of a data parsing method according to an exemplary embodiment of the present invention;
FIG. 2 is a block diagram of a parse file according to an example embodiment of the present invention;
FIG. 3 is a block diagram of a parse file according to another exemplary embodiment of the present invention;
FIG. 4 is a flowchart of a data parsing method according to another exemplary embodiment of the present invention;
FIG. 5 is a flowchart of a data parsing method according to another exemplary embodiment of the present invention;
fig. 6 is a block diagram of a data analysis apparatus according to an embodiment of the present invention.
Detailed Description
The present application describes embodiments, but the description is illustrative rather than limiting and it will be apparent to those of ordinary skill in the art that many more embodiments and implementations are possible within the scope of the embodiments described herein. Although many possible combinations of features are shown in the drawings and discussed in the detailed description, many other combinations of the disclosed features are possible. Any feature or element of any embodiment may be used in combination with or instead of any other feature or element in any other embodiment, unless expressly limited otherwise.
The present application includes and contemplates combinations of features and elements known to those of ordinary skill in the art. The embodiments, features and elements disclosed in this application may also be combined with any conventional features or elements to form a unique inventive concept as defined by the claims. Any feature or element of any embodiment may also be combined with features or elements from other inventive aspects to form yet another unique inventive aspect, as defined by the claims. Thus, it should be understood that any of the features shown and/or discussed in this application may be implemented alone or in any suitable combination. Accordingly, the embodiments are not to be restricted except in light of the attached claims and their equivalents. Furthermore, various modifications and changes may be made within the scope of the appended claims.
Further, in describing representative embodiments, the specification may have presented the method and/or process as a particular sequence of steps. However, to the extent that the method or process does not rely on the particular order of steps set forth herein, the method or process should not be limited to the particular sequence of steps described. Other orders of steps are possible as will be understood by those of ordinary skill in the art. Therefore, the particular order of the steps set forth in the specification should not be construed as limitations on the claims. Furthermore, the claims directed to the method and/or process should not be limited to the performance of their steps in the order written, and one skilled in the art can readily appreciate that the sequences may be varied and still remain within the spirit and scope of the embodiments of the present application.
Fig. 1 is a flowchart of a data parsing method according to an example embodiment of the present invention, and as shown in fig. 1, the data parsing method may include:
s101: and acquiring the data frame to be analyzed transmitted based on the bus protocol, wherein the data frames transmitted by different bus protocols have different formats.
In this embodiment, when data transmission is performed based on a bus protocol, a transmitted data frame to be analyzed may be acquired.
In one example, a generic protocol parse file may be first established, which may include a communication interface and a communication protocol parse format. The acquisition of the universal protocol analysis file refers to a plurality of analysis files which can support a plurality of protocol types, and one protocol type corresponds to one analysis file in an analysis format. The communication interface may include: ethernet, serial port and CAN.
Establishing a universal protocol analysis file, loading the universal protocol analysis file, starting a data receiving thread and a data analysis thread, receiving a data frame to be analyzed transmitted based on a bus protocol by the data receiving thread, and placing the data frame to a cache region. And the data analysis thread acquires the data frame from the buffer area and analyzes the data frame according to the bus protocol adopted by the data frame and the analysis format in the analysis file.
S102: and searching whether an analysis format matched with the bus protocol exists in a preset analysis file, wherein different analysis formats corresponding to different bus protocol data frame formats are configured in the analysis file.
The bus protocol adopted by the data frame can be identified through the communication interface in the analysis file, and the corresponding analysis format is matched through the bus protocol, so that whether the analysis format matched with the bus protocol exists or not is searched from the preset analysis file.
S103: and when the analysis file has an analysis format matched with the bus protocol, analyzing the data frame to be analyzed by using the analysis format.
And after the data frame is acquired by the data analysis thread, the corresponding analysis format is matched according to the bus protocol adopted by the data frame, and the data frame is analyzed by adopting the matched analysis format.
The data analysis method provided by the embodiment of the invention can receive data frames of various bus protocols according to the analysis file, determine the frame analysis mode according to the bus protocol adopted by the data frames, convert the frame analysis mode into a parameter value with practical significance, can support various protocol types, support the analysis of any frame format, and only need to modify the analysis file without modifying a program when the frame protocol is changed, thereby improving the flexibility and the universality of data analysis and solving the problem that the code needs to be reconstructed when the protocol is changed at present.
In an exemplary embodiment of the present invention, the parsing file may be a tree structure, and the nodes of the tree structure may sequentially include: bus nodes, message nodes and physical quantity nodes.
In this embodiment, the establishment of the universal protocol parsing file can be realized based on the construction of the tree structure. The protocol analysis file needs to configure contents including bus nodes, message nodes and physical quantity nodes.
The bus node is provided with a plurality of data bus interfaces supporting different bus protocols and used for determining the bus protocol used for sending the data frame to be analyzed.
The bus nodes are provided with specific bus interfaces which comprise common data bus interfaces such as Ethernet, serial ports and CAN, each bus comprises specific parameter information required by starting the bus, and different node types are added under the bus according to the bus types. The data frames sent on the basis of which bus protocol can be distinguished by the data bus interface in the bus node, i.e. the data frames to be parsed are distinguished by which bus protocol.
And the message node is configured with analysis identifiers in different analysis formats and used for determining the analysis format matched with the bus protocol according to the analysis identifiers.
The message node mainly configures the parsing format of the bus data according to whether the bus type exists, and the parsing format may include: and distinguishing the analysis identification of each frame protocol.
The message node is actual data of one communication of the bus, and a signal node is added below the message node.
And the physical quantity node is configured with analysis parameters of different analysis formats and used for analyzing the data frame to be analyzed according to the analysis parameters.
The signal node is a physical quantity node container, and the physical quantity node is a basic unit of the bus received data, and is configured with analysis parameters such as the type of the parameter to be analyzed, the data type, and the offset from the whole frame. The method can support filling of data types such as integer type, floating point type, character string and the like, and can cover all analysis types.
In an exemplary embodiment of the present invention, searching whether a parsing format matching a bus protocol exists in a preset parsing file includes:
and traversing each node of the tree structure in a positive sequence, and searching whether an analysis format matched with the bus protocol exists in a preset analysis file.
And the data analysis thread acquires the data frame to be analyzed from the cache region, traverses each node of the tree structure in a positive sequence, searches whether the analysis format of the data frame to be analyzed exists according to the configured analysis identifier, and if so, performs data analysis according to the analysis parameters in the physical node under the message node, and traverses all the analysis formats to analyze all the parameters.
Fig. 2 is a composition diagram of a parsing file according to an example embodiment of the present invention, and as shown in fig. 2, a bus node may include: and the network bus node is used for receiving the network IP address and the port so as to determine a bus protocol used for sending the data frame to be analyzed.
In this embodiment, the parsing file of the network data may be configured according to a network protocol, so as to implement the parsing method of the universal network bus data. The network bus node is used for receiving the network IP address and the port, the receiving mode can comprise unicast or multicast, and when the receiving mode is multicast, the multicast address can be received.
As shown in fig. 2, a frame information node may be added below the network bus node, and a message node may be added below the frame information node. The parsing format may be set as frame information, and the frame information node defines frame header information such as frame data, a synchronization header, a frame identifier, a frame length, and the like of the frame information corresponding to the parsing format, and frame tail information.
The parsing identifications of the different parsing formats configured by the message node may include: frame header information of different parsing formats, the frame header information may include a synchronization header for distinguishing different parsing formats. The synchronous head is used for judging whether the analysis file is analyzed according to the frame configuration node. And the data analysis thread acquires the data frame to be analyzed from the cache region, searches whether an analysis format for analyzing the data frame exists according to the configured synchronous head, and if so, performs data analysis according to analysis parameters in the physical node under the message node and traverses all the analysis formats to analyze all the parameters.
In an example, the format of the matching and parsing may be performed according to configured information such as a synchronization header, a frame identifier, a length, a frame end, and the like, if the matching is successful, the parsing is performed according to a message node configured by the frame information, and if the matching is not satisfactory, the parsing is discarded.
Fig. 3 is a composition diagram of a parsing file according to another example embodiment of the present invention, and as shown in fig. 3, a bus node may include: and the CAN bus node is used for configuring the CAN module interface so as to determine the bus protocol used for sending the data frame to be analyzed.
In this embodiment, a CAN data analysis file may be generated according to data that the CAN needs to analyze, so as to implement the analysis method for the general CAN data. The CAN bus node is used for configuring a CAN module interface, packaging a standard CAN module operation interface library, a configuration library name, an equipment ID, a CAN channel number and the like.
The standard CAN module operational interface library may include five interfaces: the CAN module initialization interface, the CAN data acquisition interface, the CAN data transmission interface, the CAN module reset interface and the CAN module closing interface CAN be packaged according to the five interfaces for any CAN card type.
The parsing identifications of the different parsing formats configured by the message node may include: and the CAN IDs in different analysis formats are used for distinguishing different analysis formats.
And the data analysis thread acquires the data frame to be analyzed from the cache region, searches whether the analysis format for analyzing the data frame exists according to the configured CAN ID, and if so, performs data analysis according to the analysis parameters in the physical nodes under the message node, and analyzes all the parameters by traversing all the analysis formats.
In an exemplary embodiment of the present invention, as shown in fig. 2 and fig. 3, the node that parses the tree structure of the file may further include: and (4) a device node. The device node serves as a root node of the tree structure, and is configured with specific device information under which any bus type can be added.
In an example embodiment of the present invention, the physical quantity node may be one, and all types of parameters that need to be resolved are configured in one physical quantity node. Alternatively, as shown in fig. 2 and 3, the number of the physical quantity nodes may be multiple, and each physical quantity node is configured with one type of parameter to be analyzed.
In an example embodiment of the present invention, resolving the parameters may include: parameter name, parameter type, first offset from the entire frame, and byte length (occupied position). The first offset is an offset from the entire frame, and may be referred to as a first offset and a floating point offset as a second offset, for distinguishing from an offset of a floating point number in the following embodiments.
The physical quantity node can support filling of data types such as integer type, floating point type, character string and the like, and is divided into five types according to different data types of filling, namely continuous quantity, discrete quantity, multiplexing quantity (which can be called Label quantity), discrete combined output quantity and custom type.
The continuous quantity realizes the output of integer type, floating point type and other numerical value types. The discrete quantity realizes the output of the character string type variable. And a discrete combined output quantity, wherein the received data is combined and output by a plurality of parameters. The Label quantity is for the case of a multiplexed data segment, the multiplexed data segment is a segment of data, and the value of a parameter (byte) determines what type of data is output, and the Label quantity may be embedded in a physical quantity.
The user-defined type defines a uniform interface form aiming at the non-existent analytic mode or non-existent analytic parameter type of the current analytic file, generates a general analytic file or a general analytic parameter type, the analytic format of the general analytic file adopts a preset analytic format pre-stored in an analytic library, the name of the analytic library is recorded in the general analytic file, and when the parameter is analyzed, the analytic library is loaded to obtain the preset analytic format for data analysis. The general analysis parameter type (namely, the user-defined type data) adopts the preset offset and the preset byte length relative to the whole frame, and is suitable for the condition that the parameter type of the data to be analyzed does not conform to continuous quantity, discrete quantity, complex quantity (which can be called Label quantity) and discrete combined output quantity.
Parsing the data frame to be parsed using the parsing format may include:
determining the parameter type according to the parameter name; determining a first offset and a byte length of a corresponding relative whole frame according to the parameter type; and acquiring corresponding position bytes according to the first offset and the byte length during analysis, and converting and outputting the position bytes.
The parameter type of the data frame to be analyzed can be determined firstly, the data analysis of the bus protocol is realized according to the matched parameter type in the analysis file, the corresponding offset and the byte length are obtained by matching each parameter type, and the analysis is realized by combining the offset and the byte length.
In the embodiment, the data frames of various different bus protocols are received according to the analysis file, the analysis format of the frames is determined according to the analysis identifier, the data frames to be analyzed can be converted into parameter values with practical significance through the analysis parameters, when the frame protocol is changed, a program does not need to be modified, only the analysis file needs to be modified, and the flexibility and the universality of program analysis are improved.
In an example embodiment of the present invention, the parameter name includes at least one of: continuous quantity integer data, continuous quantity floating point data, discrete data, multiplexing parameter data, discrete combination output data and custom type data.
The configured parsing format may include a parameter name, a parameter type, an offset of the parameter with respect to the whole frame, and a byte length, and the parsing method may include the following steps:
and continuous quantity integer data is output in integer numerical type, is provided with a first offset and a byte length relative to the whole frame, and is used for acquiring corresponding position bytes according to the first offset and the byte length during analysis to perform conversion output. For example, the obtained parameters of the corresponding location bytes may be directly converted into int values and then output.
The continuous quantity integer data realizes the output of integer numerical value type, can define the offset and the byte length of the relative whole frame, and obtains the corresponding position byte for conversion output according to the offset and the byte length of the relative whole frame during analysis. The continuous floating point type data is output in a floating point type numerical value type, and is provided with a first offset, a byte length, a resolution and a second offset of a floating point number relative to the whole frame, and is used for obtaining a corresponding position byte according to the first offset and the byte length during analysis, converting the corresponding position byte, multiplying the converted position byte by the resolution and adding the second offset, and outputting the converted position byte.
The continuous floating point type data realizes the output of the floating point type numerical value type, can define the offset and the byte length of a relative whole frame, and can define the offset of resolution and a floating point number, and the continuous floating point type data is output after acquiring the byte conversion of a corresponding position according to the offset and the byte length of the relative whole frame and multiplying the converted position by the resolution and the offset of the floating point number during analysis.
The discrete data is output in a character string type, is provided with a first offset relative to the whole frame, a character string corresponding to a byte length and different conversion values, and is used for obtaining a corresponding position byte according to the first offset and the byte length during analysis, converting the corresponding position byte to obtain a conversion value, searching the character string corresponding to the conversion value, and outputting the character string.
The discrete data realizes the output of character string type variables, defines output character strings corresponding to the offset, the byte length and the conversion value of the relative whole frame, acquires corresponding position bytes according to the offset and the byte length of the relative whole frame during analysis, searches character strings corresponding to the conversion value according to the converted value of the corresponding position bytes and outputs the character strings.
Multiplexing parameter data is output of a multiplexing data segment, the multiplexing data segment refers to determining which type of data is output according to a value of a certain byte, an output parameter format corresponding to a first offset, a byte length and different multiplexing parameter conversion values of a whole frame is set, and the multiplexing parameter data is used for obtaining a corresponding position byte according to the first offset and the byte length during analysis, converting the corresponding position byte to obtain a multiplexing parameter conversion value, searching the output parameter format corresponding to the multiplexing parameter conversion value, and outputting according to the output parameter format.
The multiplexing parameter data realizes the output of the data section of the multiplexing parameter, firstly the offset and the byte length corresponding to the Label quantity of the multiplexing parameter are obtained, the output parameter format corresponding to the Label conversion value is searched according to the offset and the byte length, the byte at the corresponding position is obtained according to the first offset and the byte length during analysis and is converted to obtain the multiplexing parameter conversion value, and then the output parameter format corresponding to the multiplexing parameter conversion value is searched and is output according to the output parameter format. For example, the multiplexing parameter Label quantity is a parameter a, and when the conversion value of the parameter a is 0, the output format corresponding to the current parameter B is 1; when the conversion value of the parameter a is 1, the output format corresponding to the current parameter B is 0.
And the discrete combination output data is output by combining a plurality of parameters for received data, is provided with a plurality of first offsets and a plurality of byte lengths of the plurality of parameters relative to the whole frame respectively, and one parameter corresponds to one first offset and one byte length and is used for acquiring byte conversion values of corresponding positions according to the plurality of first offsets and the plurality of byte lengths of the plurality of parameters relative to the whole frame respectively during analysis and then combining and outputting the values.
The discrete combination output data realizes that the received data is output by a plurality of parameter combinations, can define a plurality of parameters as the offset and the byte length relative to the whole frame respectively, and respectively obtain the byte conversion value of the corresponding position for splicing and outputting.
The user-defined type data is output in a preset parameter type, and is provided with a set offset, a set byte length and a set interface type analysis library file relative to the whole frame, the analysis library file is used for obtaining corresponding position bytes according to the set offset and the set byte length relative to the whole frame in the user-defined type data when the continuous integral data, the continuous floating point data, the discrete data, the multiplexing parameter data and the discrete combination output data are all inconsistent during analysis, and the analysis library file is called for conversion output.
The parsing library file may represent a parsing rule in a unified interface library written in advance by a user, and is used to describe how to parse the obtained parameter of the corresponding location byte, for example, if the parsing rule defined by the parsing library file is an open root, the open root number conversion is performed on the obtained parameter of the corresponding location byte, and then the parameter is output.
The custom type data can preset the set offset and the set byte length of the relative whole frame, is suitable for the condition that the parameter types of the data to be analyzed do not conform to the output data of the continuous integer data, the continuous floating point data, the discrete data, the multiplexing parameter data and the discrete combination, and can obtain the corresponding position byte for conversion output according to the preset offset and the set byte length of the relative whole frame during analysis.
In this embodiment, when the parsing format for parsing the data frame to be parsed is matched, the parameter type of the data frame to be parsed may be determined first, and the data frame to be parsed is matched according to the parameter type in the parsing format, and if one of the continuous integer data, the continuous floating point data, the discrete data, the multiplexing parameter data, and the discrete combination output data is matched, the data frame is parsed according to the matched parameter type, for example, the continuous integer data is matched, and the corresponding position byte is obtained according to the offset and the byte length of the relative integer frame defined by the continuous integer data during parsing, so as to perform conversion output. And if the continuous integral data, the continuous floating point data, the discrete data, the multiplexing parameter data and the discrete combination output data do not conform to each other, performing data analysis according to the user-defined type data, and acquiring corresponding position bytes for conversion and output according to the set offset and the set byte length of the relative integral frame defined by the user-defined type data during analysis. All the analysis types can be covered, the analysis of any frame parameter type is supported, and the universality of data analysis is improved.
In an example embodiment of the present invention, the data parsing method may further include:
and when the analysis file does not have an analysis format matched with the bus protocol, analyzing the data frame to be analyzed by using a preset general analysis format, wherein the general analysis format is a frame file adopting the preset analysis format.
In this embodiment, a uniform interface format may be defined for a case where an analysis format matching a bus protocol does not exist in an analysis file, a general analysis file is generated, the analysis format of the general analysis file adopts a preset analysis format pre-stored in an analysis library, an analysis library name is recorded in the general analysis file, and when the parameter is analyzed, the analysis library is loaded to acquire the preset analysis format to perform data analysis.
The analysis parameter in the preset analysis format can be a self-defined type, the self-defined type can define the offset and the byte length of the parameter relative to the whole frame, and the interface of the analysis library is called for analysis output after the byte conversion of the relative position is obtained according to the predefined offset and the byte length.
In the embodiment, the data frames of various different bus protocols can be received according to the analysis file, the analysis format is determined according to whether the bus protocol adopted by the data frames is matched with the analysis identifier, the data frames to be analyzed are converted into the parameter values with practical significance, when the frame protocol is changed, a program does not need to be modified, only the analysis file needs to be modified, the analysis flexibility and the analysis universality are improved, the parameter value analysis is not limited to the type of the configuration of the analysis file, and all types of data can be analyzed according to the standard interface custom analysis mode.
Fig. 4 is a flowchart of a data parsing method according to another exemplary embodiment of the present invention, and as shown in fig. 4, the data parsing method may include:
s401: and loading the bus data analysis file.
S402: a data receiving thread is started.
S403: and acquiring a data frame to be analyzed.
S404: and storing the data into a buffer area.
S405: and starting a data analysis thread.
S406: and acquiring the data frame to be analyzed from the buffer area.
S407: and judging whether the analysis format of the data frame exists in the analysis file. If so, then S408 is performed. Otherwise, the data frame is discarded.
S408: and analyzing the data.
In this embodiment, an analysis file of a general protocol, including an analysis format of a communication interface and a communication protocol, may be established first, the analysis file may be loaded, and a data receiving thread and a data analysis thread may be started. And the data receiving thread receives the bus data and places the bus data into the cache region. And the data analysis thread acquires data from the cache region and performs data analysis according to the analysis format in the protocol data matching analysis file.
Fig. 5 is a flowchart of a data parsing method according to another exemplary embodiment of the present invention, and as shown in fig. 5, the data parsing method may include:
s501: and finding out the corresponding analysis format of the data to be analyzed.
S502: the type of the parameter to be analyzed and the offset relative to the whole frame are obtained, and the parameter is analyzed into the value of each parameter field.
S503: whether all parameters have been resolved. If yes, executing S504; otherwise, S502 is executed.
S504: and (5) completing the analysis.
Fig. 6 is a block diagram of a data analysis apparatus according to an embodiment of the present invention, and as shown in fig. 6, the data analysis apparatus may include: a memory 61 and a processor 62.
The memory is used for storing and executing instructions, and the processor may be a Central Processing Unit (CPU), an Application Specific Integrated Circuit (ASIC), or one or more Integrated circuits that implement embodiments of the present invention. When the data analysis device is operated, the processor is communicated with the memory, and the processor calls the execution instruction to execute the following operations:
acquiring data frames to be analyzed transmitted based on bus protocols, wherein the formats of the data frames transmitted by different bus protocols are different;
searching whether an analysis format matched with the bus protocol exists in a preset analysis file, wherein different analysis formats corresponding to different bus protocol data frame formats are configured in the analysis file;
and when an analysis format matched with the bus protocol exists in the analysis file, analyzing the data frame to be analyzed by using the analysis format.
The data analysis device provided by the embodiment of the invention is used for executing the technical scheme of any data analysis method embodiment, the implementation principle and the implementation effect are similar, and the details are not repeated here.
In an exemplary embodiment of the present invention, the parsing file is a tree structure, and nodes of the tree structure sequentially include: the system comprises a bus node, a message node and a physical quantity node;
the bus node is provided with a plurality of data bus interfaces supporting different bus protocols and used for determining the bus protocol used for sending the data frame to be analyzed;
the message node is configured with analysis identifiers with different analysis formats and used for determining the analysis format matched with the bus protocol according to the analysis identifiers;
and the physical quantity node is configured with analysis parameters in different analysis formats and used for analyzing the data frame to be analyzed according to the analysis parameters.
In an example embodiment of the present invention, the searching, by the processor, whether a parsing format matching the bus protocol exists from a preset parsing file may include:
and traversing each node of the tree structure in a positive sequence, and searching whether an analysis format matched with the bus protocol exists in a preset analysis file.
In an example embodiment of the present invention, the parsing parameters include: parameter name, parameter type, first offset relative to the whole frame, and byte length;
the processor analyzes the data frame to be analyzed by using the analysis format, and the method comprises the following steps:
determining the parameter type according to the parameter name;
determining a first offset corresponding to the whole frame according to the parameter type;
and acquiring corresponding position bytes according to the first offset and the byte length during analysis, and converting and outputting the position bytes.
In an example embodiment of the present invention, the parameter name includes at least one of: continuous quantity integer data, continuous quantity floating point data, discrete data, multiplexing parameter data, discrete combination output data and user-defined type data;
the continuous quantity integer data is output in integer numerical type, is provided with a first offset and a byte length relative to an entire frame, and is used for acquiring corresponding position bytes according to the first offset and the byte length during analysis to carry out conversion output;
the continuous floating point type data is output in a floating point type numerical value type, is provided with a first offset, a byte length, a resolution and a second offset of the floating point number relative to the whole frame, is used for obtaining a corresponding position byte according to the first offset and the byte length during analysis, and is output after being multiplied by the resolution and added with the second offset;
the discrete data is output in a character string type, is provided with a first offset relative to the whole frame, a byte length and character strings corresponding to different conversion values, and is used for obtaining corresponding position bytes according to the first offset and the byte length during analysis, converting the corresponding position bytes to obtain a conversion value, searching the character string corresponding to the conversion value and outputting the character string;
the multiplexing parameter data is output of a multiplexing data segment, the multiplexing data segment refers to data of which type is determined to be output by a value of a certain byte, an output parameter format corresponding to a first offset, a byte length and different multiplexing parameter conversion values of a whole frame is set, and the multiplexing parameter data is used for obtaining a corresponding position byte according to the first offset and the byte length during analysis, converting the corresponding position byte to obtain a multiplexing parameter conversion value, searching an output parameter format corresponding to the multiplexing parameter conversion value, and outputting according to the output parameter format;
the discrete combination output data is output by combining a plurality of parameters for received data, a plurality of first offsets and a plurality of byte lengths of the parameters relative to the whole frame are set, one parameter corresponds to one first offset and one byte length, and the discrete combination output data is used for obtaining byte conversion values of corresponding positions according to the plurality of first offsets and the plurality of byte lengths of the parameters relative to the whole frame respectively and then is output in a combined mode during analysis;
the user-defined type data is output in a preset parameter type, is provided with a set offset and a set byte length relative to the whole frame, is used for being inconsistent with the continuous quantity integer data, the continuous quantity floating point data, the discrete type data, the multiplexing parameter data and the discrete combination output data during analysis, and is output after a byte conversion value at a corresponding position is obtained according to the set offset and the set byte length relative to the whole frame in the user-defined type data.
In an example embodiment of the present invention, the processor is further configured to, when an analysis format matching the bus protocol does not exist in the analysis file, analyze the data frame to be analyzed using a preset general analysis format, where the general analysis format is a frame file adopting a preset analysis format.
In an example embodiment of the present invention, the bus node includes: the network bus node is used for receiving a network IP address and a port so as to determine a bus protocol used for sending the data frame to be analyzed;
the parsing identifiers of different parsing formats configured by the message node comprise: and the frame header information comprises synchronous headers for distinguishing different analysis formats.
In an example embodiment of the present invention, the bus node includes: the CAN bus node is used for configuring a CAN module interface so as to determine a bus protocol used for sending the data frame to be analyzed;
the parsing identifiers of different parsing formats configured by the message node comprise: and the CAN IDs in different analysis formats are used for distinguishing different analysis formats.
The embodiment of the present invention further provides a computer-readable storage medium, on which computer instructions are stored, and when the instructions are executed by a processor, the steps of the data parsing method described in any of the above embodiments are implemented.
It will be understood by those of ordinary skill in the art that all or some of the steps of the methods, systems, functional modules/units in the devices disclosed above may be implemented as software, firmware, hardware, and suitable combinations thereof. In a hardware implementation, the division between functional modules/units mentioned in the above description does not necessarily correspond to the division of physical components; for example, one physical component may have multiple functions, or one function or step may be performed by several physical components in cooperation. Some or all of the components may be implemented as software executed by a processor, such as a digital signal processor or microprocessor, or as hardware, or as an integrated circuit, such as an application specific integrated circuit. Such software may be distributed on computer readable media, which may include computer storage media (or non-transitory media) and communication media (or transitory media). The term computer storage media includes volatile and nonvolatile, removable and non-removable media implemented in any method or technology for storage of information such as computer readable instructions, data structures, program modules or other data, as is well known to those of ordinary skill in the art. Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, Digital Versatile Disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other medium which can be used to store the desired information and which can accessed by a computer. In addition, communication media typically embodies computer readable instructions, data structures, program modules or other data in a modulated data signal such as a carrier wave or other transport mechanism and includes any information delivery media as known to those skilled in the art.
Claims (10)
1. A data parsing method, comprising:
acquiring data frames to be analyzed transmitted based on bus protocols, wherein the formats of the data frames transmitted by different bus protocols are different;
searching whether an analysis format matched with the bus protocol exists in a preset analysis file, wherein different analysis formats corresponding to different bus protocol data frame formats are configured in the analysis file;
and when an analysis format matched with the bus protocol exists in the analysis file, analyzing the data frame to be analyzed by using the analysis format.
2. The method according to claim 1, wherein the parsing file is a tree structure, and the nodes of the tree structure sequentially comprise: the system comprises a bus node, a message node and a physical quantity node;
the bus node is provided with a plurality of data bus interfaces supporting different bus protocols and used for determining the bus protocol used for sending the data frame to be analyzed;
the message node is configured with analysis identifiers with different analysis formats and used for determining the analysis format matched with the bus protocol according to the analysis identifiers;
and the physical quantity node is configured with analysis parameters in different analysis formats and used for analyzing the data frame to be analyzed according to the analysis parameters.
3. The method of claim 2, wherein the searching for whether a parsing format matching with the bus protocol exists from a preset parsing file comprises:
and traversing each node of the tree structure in a positive sequence, and searching whether an analysis format matched with the bus protocol exists in a preset analysis file.
4. The method of claim 2, wherein the parsing parameters comprise: parameter name, parameter type, first offset relative to the whole frame and byte length;
the analyzing the data frame to be analyzed by using the analysis format comprises the following steps:
determining the parameter type according to the parameter name;
determining a first offset and a byte length of a corresponding relative whole frame according to the parameter type;
and acquiring corresponding position bytes according to the first offset and the byte length during analysis to perform conversion output.
5. The method of claim 4, wherein the parameter name comprises at least one of: continuous quantity integer data, continuous quantity floating point data, discrete data, multiplexing parameter data, discrete combination output data and user-defined type data;
the continuous quantity integer data is output in integer numerical type, is provided with a first offset and a byte length relative to an entire frame, and is used for acquiring corresponding position bytes according to the first offset and the byte length during analysis to carry out conversion output;
the continuous floating point type data is output in a floating point type numerical value type, is provided with a first offset, a byte length, a resolution and a second offset of the floating point number relative to the whole frame, is used for obtaining a corresponding position byte according to the first offset and the byte length during analysis, and is output after being multiplied by the resolution and added with the second offset;
the discrete data is output in a character string type, is provided with a first offset relative to the whole frame, a byte length and character strings corresponding to different conversion values, and is used for acquiring corresponding position bytes according to the first offset and the byte length during analysis, converting the corresponding position bytes to obtain a conversion value, searching the character string corresponding to the conversion value and outputting the character string;
the multiplexing parameter data is output of a multiplexing data segment, the multiplexing data segment refers to data of which type is determined to be output by a value of a certain byte, an output parameter format corresponding to a first offset, a byte length and different multiplexing parameter conversion values of a whole frame is set, and the multiplexing parameter data is used for obtaining a corresponding position byte according to the first offset and the byte length during analysis, converting the corresponding position byte to obtain a multiplexing parameter conversion value, searching an output parameter format corresponding to the multiplexing parameter conversion value, and outputting according to the output parameter format;
the discrete combination output data is output by combining a plurality of parameters for received data, a plurality of first offsets and a plurality of byte lengths of the parameters relative to the whole frame are set, one parameter corresponds to one first offset and one byte length, and the discrete combination output data is used for acquiring corresponding position bytes for conversion output according to the plurality of first offsets and the plurality of byte lengths of the parameters relative to the whole frame respectively during analysis;
the user-defined type data is output in a preset parameter type, and is provided with an analysis library file in a setting offset, a setting byte length and a setting interface form relative to the whole frame, and is used for obtaining corresponding position bytes according to the setting offset and the setting byte length of the relative whole frame in the user-defined type data when the continuous quantity whole type data, the continuous quantity floating point type data, the discrete type data, the multiplexing parameter data and the discrete combination output data are inconsistent during analysis, and outputting after calling a conversion value of the analysis library file.
6. The method according to any one of claims 1-5, further comprising:
and when the analysis file does not have an analysis format matched with the bus protocol, analyzing the data frame to be analyzed by using a preset general analysis format, wherein the general analysis format is a frame file adopting the preset analysis format.
7. The method of claim 2, wherein the bus node comprises: the network bus node is used for receiving a network IP address and a port so as to determine a bus protocol used for sending the data frame to be analyzed;
the parsing identifiers of different parsing formats configured by the message node comprise: and the frame header information comprises synchronous headers for distinguishing different analysis formats.
8. The method of claim 2, wherein the bus node comprises: the CAN bus node is used for configuring a CAN module interface so as to determine a bus protocol used for sending the data frame to be analyzed;
the parsing identifiers of different parsing formats configured by the message node comprise: and the CAN IDs in different analysis formats are used for distinguishing different analysis formats.
9. The data analysis device is characterized by comprising a memory and a processor, wherein the memory is used for storing execution instructions; the processor calls the execution instruction for executing the data parsing method of any one of claims 1-8.
10. A computer-readable storage medium having stored thereon computer instructions, which when executed by a processor, implement the steps of the method of any one of claims 1-8.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210511804.2A CN115086449A (en) | 2022-05-11 | 2022-05-11 | Data analysis method and device and computer readable storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210511804.2A CN115086449A (en) | 2022-05-11 | 2022-05-11 | Data analysis method and device and computer readable storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN115086449A true CN115086449A (en) | 2022-09-20 |
Family
ID=83246522
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202210511804.2A Pending CN115086449A (en) | 2022-05-11 | 2022-05-11 | Data analysis method and device and computer readable storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN115086449A (en) |
Cited By (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115512508A (en) * | 2022-10-20 | 2022-12-23 | 九江中船消防设备有限公司 | Many detection unit compatible type marine fire alarm system |
CN115580662A (en) * | 2022-09-26 | 2023-01-06 | 四川九洲空管科技有限责任公司 | Interface dynamic adaptation method and device in non-drop state |
CN115801881A (en) * | 2022-10-19 | 2023-03-14 | 中国航空工业集团公司沈阳飞机设计研究所 | Reusable man-machine data interface representation method |
CN115914427A (en) * | 2022-10-24 | 2023-04-04 | 宁波义钛云软件有限公司 | Terminal protocol integration and calling method and device, computer equipment and storage medium |
CN116301881A (en) * | 2023-02-01 | 2023-06-23 | 浙江万里扬新能源驱动有限公司杭州分公司 | DBC-based protocol layer code generation method and generation tool |
CN117707653A (en) * | 2024-02-06 | 2024-03-15 | 天津医康互联科技有限公司 | Parameter monitoring method, device, electronic equipment and computer readable storage medium |
CN117714564A (en) * | 2024-02-05 | 2024-03-15 | 成都汉度科技有限公司 | Universal DLT645 protocol analysis method and device based on java language |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US5748905A (en) * | 1996-08-30 | 1998-05-05 | Fujitsu Network Communications, Inc. | Frame classification using classification keys |
US20080062989A1 (en) * | 2006-09-08 | 2008-03-13 | Dominic Coupal | Smart match search method for captured data frames |
CN102143148A (en) * | 2010-11-29 | 2011-08-03 | 华为技术有限公司 | Parameter acquiring and general protocol analyzing method and device |
CN106850339A (en) * | 2016-12-30 | 2017-06-13 | 广州致远电子股份有限公司 | A kind of bus signals protocol-decoding method |
CN108521378A (en) * | 2018-04-23 | 2018-09-11 | 天津芯海创科技有限公司 | Retransmission method, device and the network switching equipment of heterogeneous protocol message |
-
2022
- 2022-05-11 CN CN202210511804.2A patent/CN115086449A/en active Pending
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US5748905A (en) * | 1996-08-30 | 1998-05-05 | Fujitsu Network Communications, Inc. | Frame classification using classification keys |
US20080062989A1 (en) * | 2006-09-08 | 2008-03-13 | Dominic Coupal | Smart match search method for captured data frames |
CN102143148A (en) * | 2010-11-29 | 2011-08-03 | 华为技术有限公司 | Parameter acquiring and general protocol analyzing method and device |
CN106850339A (en) * | 2016-12-30 | 2017-06-13 | 广州致远电子股份有限公司 | A kind of bus signals protocol-decoding method |
CN108521378A (en) * | 2018-04-23 | 2018-09-11 | 天津芯海创科技有限公司 | Retransmission method, device and the network switching equipment of heterogeneous protocol message |
Cited By (10)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115580662A (en) * | 2022-09-26 | 2023-01-06 | 四川九洲空管科技有限责任公司 | Interface dynamic adaptation method and device in non-drop state |
CN115801881A (en) * | 2022-10-19 | 2023-03-14 | 中国航空工业集团公司沈阳飞机设计研究所 | Reusable man-machine data interface representation method |
CN115512508A (en) * | 2022-10-20 | 2022-12-23 | 九江中船消防设备有限公司 | Many detection unit compatible type marine fire alarm system |
CN115914427A (en) * | 2022-10-24 | 2023-04-04 | 宁波义钛云软件有限公司 | Terminal protocol integration and calling method and device, computer equipment and storage medium |
CN116301881A (en) * | 2023-02-01 | 2023-06-23 | 浙江万里扬新能源驱动有限公司杭州分公司 | DBC-based protocol layer code generation method and generation tool |
CN116301881B (en) * | 2023-02-01 | 2024-05-10 | 浙江万里扬新能源驱动有限公司杭州分公司 | DBC-based protocol layer code generation method and generation tool |
CN117714564A (en) * | 2024-02-05 | 2024-03-15 | 成都汉度科技有限公司 | Universal DLT645 protocol analysis method and device based on java language |
CN117714564B (en) * | 2024-02-05 | 2024-04-23 | 成都汉度科技有限公司 | Universal DLT645 protocol analysis method and device based on java language |
CN117707653A (en) * | 2024-02-06 | 2024-03-15 | 天津医康互联科技有限公司 | Parameter monitoring method, device, electronic equipment and computer readable storage medium |
CN117707653B (en) * | 2024-02-06 | 2024-05-10 | 天津医康互联科技有限公司 | Parameter monitoring method, device, electronic equipment and computer readable storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN115086449A (en) | Data analysis method and device and computer readable storage medium | |
EP2866142A1 (en) | Upgrade package generation method and device, dynamic file differential upgrade method and terminal | |
CN110096628B (en) | Quick matching identification method and device based on character strings | |
CN109995588B (en) | Flexible Ethernet link management method and system | |
EP4024782A1 (en) | Method by which host network performance requirements may be programmed, device and system | |
WO2021208843A1 (en) | Segment routing header compression method and apparatus and service processing method and apparatus | |
CN112350934A (en) | Data transmission method, network node and data transmission system | |
CN109120477A (en) | Dynamic analysis method, apparatus, server and storage medium based on modbus agreement | |
CN109728968B (en) | Method, related equipment and system for obtaining target transmission path | |
CN107070719B (en) | Equipment management method and device | |
CN113157975B (en) | Extensible markup language parsing system and method | |
US20230328007A1 (en) | Method for processing interface data, sender device and receiver device | |
CN112737995B (en) | Method, device and equipment for processing Ethernet frame and storage medium | |
CN116016345B (en) | Network flow restoration method based on custom protocol description language | |
CN112713960B (en) | Data transmission method, data reception device, communication node, and storage medium | |
CN108092942B (en) | Message processing method and device | |
WO2017215438A1 (en) | Service activating method, device and system, and storage medium | |
EP3300384A1 (en) | Onu template generating method and device | |
US9577669B2 (en) | Methods, systems, and computer readable media for optimized message decoding | |
CN108737347B (en) | Data communication method, device and equipment | |
CN115842792A (en) | Data processing method and device, storage medium and electronic equipment | |
CN114024598A (en) | Forward transmission interface test method and device | |
RU2795936C1 (en) | Method and device for segment routing header compression, method and device for service processing | |
CN115134688B (en) | Remote debugging method and system of GPON ONU | |
CN117472387B (en) | Method and device for dynamically analyzing data and cloud platform |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20220920 |
|
RJ01 | Rejection of invention patent application after publication |