CN113300883B - Protocol information generation method, device and terminal equipment - Google Patents

Protocol information generation method, device and terminal equipment Download PDF

Info

Publication number
CN113300883B
CN113300883B CN202110533722.3A CN202110533722A CN113300883B CN 113300883 B CN113300883 B CN 113300883B CN 202110533722 A CN202110533722 A CN 202110533722A CN 113300883 B CN113300883 B CN 113300883B
Authority
CN
China
Prior art keywords
configuration information
register
information read
read
address
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.)
Active
Application number
CN202110533722.3A
Other languages
Chinese (zh)
Other versions
CN113300883A (en
Inventor
王金水
张晨光
谢建隆
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhangzhou Kehua Technology Co Ltd
Kehua Data Co Ltd
Original Assignee
Zhangzhou Kehua Technology Co Ltd
Kehua Data Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Zhangzhou Kehua Technology Co Ltd, Kehua Data Co Ltd filed Critical Zhangzhou Kehua Technology Co Ltd
Priority to CN202110533722.3A priority Critical patent/CN113300883B/en
Publication of CN113300883A publication Critical patent/CN113300883A/en
Application granted granted Critical
Publication of CN113300883B publication Critical patent/CN113300883B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L41/00Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
    • H04L41/08Configuration management of networks or network elements
    • H04L41/0803Configuration setting
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/28Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
    • H04L12/40Bus networks
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L41/00Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
    • H04L41/08Configuration management of networks or network elements
    • H04L41/0876Aspects of the degree of configuration automation
    • H04L41/0886Fully automatic configuration
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/26Special purpose or proprietary protocols or architectures
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/28Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
    • H04L12/40Bus networks
    • H04L2012/40208Bus networks characterized by the use of a particular bus standard
    • H04L2012/40228Modbus

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Automation & Control Theory (AREA)
  • Computing Systems (AREA)
  • Computer Security & Cryptography (AREA)
  • Communication Control (AREA)

Abstract

The invention is applicable to the technical field of communication, and provides a protocol information generation method, a device and terminal equipment, wherein the protocol information generation method comprises the following steps: reading a configuration file of a protocol; the configuration file records a plurality of pieces of configuration information, and each piece of configuration information at least comprises a register starting address and a byte number; dividing each piece of configuration information into corresponding configuration information groups according to the arrangement sequence of the initial addresses of the registers and a preset dividing rule, wherein each configuration information group at least comprises one piece of configuration information; generating a communication instruction corresponding to the configuration information group; the register initial address of the communication instruction is the minimum register initial address in the configuration information group, and the register address length of the communication instruction is the total byte number of the byte number of each configuration information included in the configuration information group. The invention can reduce the error rate when generating the communication instruction.

Description

Protocol information generation method, device and terminal equipment
Technical Field
The present invention belongs to the field of communication technologies, and in particular, to a method, an apparatus, and a terminal device for generating protocol information.
Background
Modbus is a serial communication protocol, which is widely used for connection communication between industrial electronic devices as an industry standard of industrial-field communication protocols. The RTU (Remote Terminal Unit ) is one of the transmission modes defined in the Modbus protocol specification.
When a configuration file of the Modbus RTU protocol is received, a technician is required to manually convert configuration information such as function codes, register addresses and the like in the configuration file into corresponding one or more communication instructions. However, the error rate is high by manually generating the communication command.
Disclosure of Invention
In view of the above, the embodiments of the present invention provide a method, an apparatus, and a terminal device for generating protocol information, so as to solve the problem of high error rate in the prior art in which communication instructions are manually generated.
A first aspect of an embodiment of the present invention provides a protocol information generating method, including:
reading a configuration file of a protocol; the configuration file records a plurality of pieces of configuration information, and each piece of configuration information at least comprises a register starting address and a byte number;
dividing each piece of configuration information into corresponding configuration information groups according to the arrangement sequence of the initial addresses of the registers and a preset dividing rule; wherein each configuration information group at least comprises one piece of configuration information; for a configuration information group comprising at least two pieces of configuration information, the absolute value of the difference between the register start address of the first configuration information and the register start address of the second configuration information is equal to the byte number of the first configuration information, the first configuration information and the second configuration information are adjacent configuration information in the arrangement sequence, and the register start address of the first configuration information is smaller than the register start address of the second configuration information;
generating a communication instruction corresponding to the configuration information group; the register initial address of the communication instruction is the minimum register initial address in the configuration information group, and the register address length of the communication instruction is the total byte number of the byte number of each configuration information included in the configuration information group.
A second aspect of an embodiment of the present invention provides a protocol information generating apparatus, including:
the reading module is used for reading the configuration file of the protocol; the configuration file records a plurality of pieces of configuration information, and each piece of configuration information at least comprises a register starting address and a byte number;
the grouping module is used for sequentially dividing each piece of configuration information into corresponding configuration information groups according to the arrangement sequence of the initial addresses of the registers and a preset dividing rule; wherein each configuration information group at least comprises one piece of configuration information; for a configuration information group comprising at least two pieces of configuration information, the absolute value of the difference between the register start address of the first configuration information and the register start address of the second configuration information is equal to the byte number of the first configuration information, the first configuration information and the second configuration information are adjacent configuration information in the arrangement sequence, and the register start address of the first configuration information is smaller than the register start address of the second configuration information;
the instruction generation module is used for generating a communication instruction corresponding to the configuration information group; the register initial address of the communication instruction is the minimum register initial address in the configuration information group, and the register address length of the communication instruction is the total byte number of the byte number of each configuration information included in the configuration information group.
A third aspect of an embodiment of the present invention provides a terminal device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, the processor implementing the steps of the method according to the first aspect when executing the computer program.
Compared with the prior art, the embodiment of the invention has the beneficial effects that:
after the configuration file of the protocol is read, each piece of configuration information can be sequentially divided into corresponding configuration information groups according to a preset division rule according to the arrangement sequence of the initial addresses of the registers. Thereafter, the configuration information set may be taken as a whole to generate a communication instruction corresponding to the configuration information set. Because the generated communication instruction corresponding to the configuration information group meets the format requirement of the communication instruction, the generated communication instruction cannot generate an error condition as long as the configuration file is free from errors. Thus, when the configuration file of the protocol is read, the corresponding communication instruction can be automatically generated, thereby replacing the manual generation of the communication instruction, avoiding the situation of error of the manual generation of the communication instruction and reducing the labor cost.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings that are needed in the embodiments or the description of the prior art will be briefly described below, it being obvious that the drawings in the following description are only some embodiments of the present invention, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a flowchart of steps of a protocol information generating method according to an embodiment of the present invention;
fig. 2 is a schematic diagram of a protocol information generating device according to an embodiment of the present invention;
fig. 3 is a schematic diagram of a terminal device according to an embodiment of the present invention.
Detailed Description
In the following description, for purposes of explanation and not limitation, specific details are set forth such as the particular system architecture, techniques, etc., in order to provide a thorough understanding of the embodiments of the present invention. It will be apparent, however, to one skilled in the art that the present invention may be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present invention with unnecessary detail.
In order to illustrate the technical scheme of the invention, the following description is made by specific examples.
As described in the background art, the communication command of the current Modbus RTU protocol is manually generated by a technician, and because of different attentions and experiences of different technicians, the error rate is higher in a mode of manually generating the communication command. In addition, when the configuration file is slightly adjusted, a technician generally changes a part of the communication instructions on the basis of the communication instructions generated in the previous time, and at this time, the situation that the part of the communication instructions are not correspondingly changed easily occurs, so that the error rate is further improved.
In order to solve the problems in the prior art, the embodiment of the invention provides a protocol information generation method, a device and terminal equipment. The protocol information generating method provided by the embodiment of the invention is first described below.
The main body of execution of the protocol information generating method may be a protocol information generating apparatus, and the protocol information generating apparatus may be a terminal device having a processor and a memory, for example, a control device in each industrial control system, for example, a programmable controller, a server, or a personal computer, etc., and embodiments of the present invention are not limited in particular.
As shown in fig. 1, the protocol information generating method provided by the embodiment of the present invention may include the following steps:
step S110, reading the configuration file of the protocol.
The configuration file records a plurality of pieces of configuration information, and each piece of configuration information at least comprises a register starting address and a byte number.
As shown in table one, a configuration file of a protocol is shown, where each line in the configuration file is a piece of configuration information, and each piece of configuration information includes information such as a register address, a byte number, a name, a default value, and the like.
List one
Figure BDA0003068910930000041
It should be noted that, in table one, only part of information of each piece of configuration information is shown, the configuration information may further include a function code, a format, a unit, and the like, where the function code may be a 02 read input state, the format may be a BOOL format, and the unit may be Status.
Step S120, dividing each piece of configuration information into corresponding configuration information groups according to the arrangement sequence of the initial addresses of the registers and a preset dividing rule.
The preset dividing rule may be any dividing rule capable of achieving the following grouping purposes: each configuration information group at least comprises one piece of configuration information; for a configuration information group comprising at least two pieces of configuration information, the absolute value of the difference between the register start address of the first configuration information and the register start address of the second configuration information is equal to the byte number of the first configuration information, the first configuration information and the second configuration information are adjacent configuration information in the arrangement sequence, and the register start address of the first configuration information is smaller than the register start address of the second configuration information.
The applicant finds that after a great deal of creative labor, the format of the communication instruction in the Modbus RTU protocol is relatively fixed, variables in the communication instruction comprise an operation code, a register starting address and a register address length, and the format requirements of the communication instruction in the Modbus RTU protocol can be summarized as follows: the method comprises the steps that configuration information with discontinuous register addresses independently generates a communication instruction; the configuration information with continuous register addresses can be combined to generate a communication instruction, or can generate a communication instruction respectively. Referring to table one again, it can be found that the first configuration information and the fourth configuration information in table one are both configuration information with discontinuous register addresses and are not continuous with register addresses of other configuration information, and the second configuration information, the third configuration information and the fifth to fourteenth configuration information in table one are configuration information with continuous register addresses.
Therefore, after the configuration file of the protocol is read, each piece of configuration information can be divided into corresponding configuration information groups in sequence according to the continuity condition of the register address of each piece of configuration information and the preset division rule.
Alternatively, the order of the register start addresses may be from small to large, and the specific process of step S120 may be as follows: sequentially reading configuration information according to the sequence from small to large of the initial addresses of the registers; dividing the configuration information read at the time into a configuration information group or a new configuration information group to which the configuration information read at the time belongs under the condition that the configuration information read at the time is not the first configuration information and the difference between the register start address of the configuration information read at the time and the register start address of the configuration information read at the time is equal to the byte number of the configuration information read at the time; and dividing the configuration information read at the time into a new configuration information group under the condition that the configuration information read at the time is not the first configuration information and the difference between the register start address of the configuration information read at the time and the register start address of the configuration information read at the previous time is larger than the byte number of the configuration information read at the previous time.
In some embodiments, when the order of the register start addresses is the order of the register start addresses from small to large, one implementation of the preset partitioning rule may be as follows:
for the case where the configuration information read at the time is the first piece of configuration information, one configuration information group may be created, and then the configuration information read at the time is directly divided into the configuration information group.
For the case where the configuration information read at the present time is not the first piece of configuration information and the difference between the register start address of the configuration information read at the present time and the register start address of the configuration information read at the previous time is equal to the number of bytes of the configuration information read at the previous time, it is indicated that the configuration information read at the present time and the configuration information read at the previous time are the configuration information with the continuous register addresses, so that the configuration information read at the present time may be divided into the configuration information group to which the configuration information read at the previous time belongs, or a new configuration information group may be created, and then the configuration information read at the present time may be divided into the created new configuration information group.
For example, when the difference between the register start address of the second piece of configuration information and the register start address of the first piece of configuration information is equal to the number of bytes of the first piece of configuration information, the second piece of configuration information may be divided into the configuration information group to which the first piece of configuration information belongs, or a new configuration information group may be created, and then the second piece of configuration information may be divided into the created new configuration information group.
For the case that the configuration information read at the time is not the first configuration information and the difference between the register start address of the configuration information read at the time and the register start address of the configuration information read at the time is greater than the byte number of the configuration information read at the previous time, it is indicated that the configuration information read at the time and the configuration information read at the previous time are the configuration information with discontinuous register addresses, so that a new configuration information group can be created, and then the configuration information read at the time is divided into the created new configuration information group.
In addition, for the case that the configuration information read at the present time is not the first configuration information, and the difference between the register start address of the configuration information read at the present time and the register start address of the configuration information read at the previous time is smaller than the byte number of the configuration information read at the previous time, an error is indicated in the configuration file, at this time, the configuration information read at the present time can be removed, and alarm information can be generated to prompt a technician to perform investigation.
Alternatively, the order of the register start addresses may be the order of the register start addresses from large to small, and the specific process of step S120 may be as follows: sequentially reading configuration information according to the sequence from the beginning address of the register to the beginning address of the register; dividing the configuration information read at the time into a configuration information group or a new configuration information group to which the configuration information read at the time belongs under the condition that the configuration information read at the time is not the first configuration information and the absolute value of the difference value between the register start address of the configuration information read at the time and the register start address of the configuration information read at the time is equal to the byte number of the configuration information read at the time; and dividing the configuration information read at the time into a new configuration information group under the condition that the configuration information read at the time is not the first piece of configuration information and the absolute value of the difference value between the register start address of the configuration information read at the time and the register start address of the configuration information read at the previous time is larger than the byte number of the configuration information read at the time.
In some embodiments, when the order of the register start addresses is the order of the register start addresses from large to small, another implementation of the preset division rule may be as follows:
for the case where the configuration information read at the time is the first piece of configuration information, one configuration information group may be created, and then the configuration information read at the time is directly divided into the configuration information group.
For the case where the configuration information read at the present time is not the first piece of configuration information and the absolute value of the difference between the register start address of the configuration information read at the present time and the register start address of the configuration information read at the previous time is equal to the number of bytes of the configuration information read at the present time, it is indicated that the configuration information read at the present time and the configuration information read at the previous time are the configuration information whose register addresses are consecutive, so that the configuration information read at the present time may be divided into the configuration information group to which the configuration information read at the previous time belongs, or a new configuration information group may be created, and then the configuration information read at the present time may be divided into the created new configuration information group.
For the case that the configuration information read at the time is not the first configuration information and the absolute value of the difference between the register start address of the configuration information read at the time and the register start address of the configuration information read at the time is larger than the byte number of the configuration information read at the time, the configuration information read at the time and the configuration information read at the time are the configuration information with discontinuous register addresses, so that a new configuration information group can be created, and then the configuration information read at the time is divided into the created new configuration information group.
Similar to the previous embodiment of the order of the register start addresses from small to large, for the case that the configuration information read at the present time is the non-first configuration information, and the absolute value of the difference between the register start address of the configuration information read at the present time and the register start address of the configuration information read at the previous time is smaller than the byte number of the configuration information read at the present time, it indicates that the configuration file has an error, at this time, the configuration information read at the present time may be removed, and alarm information may be generated to prompt a technician to perform an investigation.
It should be noted that, the implementation manner is not limited to the specific limitation of the preset dividing rule, and the preset dividing rule may be other dividing rules. For example, one piece of configuration information can be randomly selected, then all the configuration information is divided into two parts by taking the configuration information as a boundary, and then the configuration information of the two parts is correspondingly divided, so that the advantage of parallel processing can be utilized, the dividing efficiency is improved, and the processing time is shortened.
Optionally, considering that there is a limitation on the register address length of the communication instruction, that is, the register address length threshold of the communication instruction, for example, the register address length of the communication instruction fixed in the Modbus RTU protocol cannot exceed the maximum length 255, or the custom register address set manually, such as 150, 180, etc., in this case, the specific process of dividing the configuration information read at the present time into the configuration information group to which the configuration information read at the previous time belongs or the new configuration information group may be as follows: if the sum value is smaller than or equal to the register address length threshold value of the communication instruction, dividing the configuration information read at present into a configuration information group to which the configuration information read at the previous time belongs, otherwise dividing the configuration information read at present into a new configuration information group; the sum value is the sum of the total bytes of the configuration information group to which the configuration information read at the previous time belongs and the bytes of the configuration information read at the current time.
Alternatively, the configuration information read at present may be divided according to the relation between the reading order and the preset dividing condition, so the specific process of dividing the configuration information read at present into the configuration information group to which the configuration information read at last time belongs or the new configuration information group may be as follows: if the current reading order meets the preset dividing condition, dividing the current reading configuration information into a configuration information group to which the previous reading configuration information belongs, otherwise dividing the current reading configuration information into a new configuration information group.
In some embodiments, the predetermined dividing condition may be a function expression with respect to at least one argument, the dependent variable of the function expression being a read order, e.g., y= X, Y =2x+1, y=2x 2 X is a positive integer.
Taking the preset dividing condition as y=2x as an example, if the current reading order is the third time, it can be obtained that the current reading order does not meet the preset dividing condition, and at this time, the configuration information read at the current time can be divided into new configuration information groups.
Step S130, generating a communication instruction corresponding to the configuration information set.
The register initial address of the communication instruction is the minimum register initial address in the configuration information group, and the register address length of the communication instruction is the total byte number of the byte number of each configuration information included in the configuration information group.
It should be noted that other information, such as a function code, may also exist in the communication instruction, and the generation process of other information is considered to be conventional in the art, which is not described herein.
Referring again to table one, the configuration file shown in table one may be divided into four configuration information groups, which are specifically as follows:
configuration information group 1: a first piece of configuration information;
configuration information group 2: a second piece of configuration information and a third piece of configuration information;
configuration information group 3: fourth piece of configuration information;
configuration information group 4: fifth configuration information to fourteenth configuration information.
Accordingly, a communication instruction including the following key information may be generated:
communication instruction 1: register start address 1, register address length 1;
communication instruction 2: register 10, register address length 2;
communication instruction 3: a register 16, register address length 1;
communication instruction 4: register 144, register address length 10.
In the embodiment of the invention, after the configuration file of the protocol is read, each piece of configuration information can be sequentially divided into the corresponding configuration information groups according to the arrangement sequence of the initial addresses of the registers and the preset division rule. Thereafter, the configuration information set may be taken as a whole to generate a communication instruction corresponding to the configuration information set. Because the generated communication instruction corresponding to the configuration information group meets the format requirement of the communication instruction, the generated communication instruction cannot generate an error condition as long as the configuration file is free from errors. Thus, when the configuration file of the protocol is read, the corresponding communication instruction can be automatically generated, thereby replacing the manual generation of the communication instruction, avoiding the situation of error of the manual generation of the communication instruction and reducing the labor cost.
Based on the protocol information generating method provided by the embodiment, correspondingly, the invention further provides a specific implementation mode of the protocol information generating device applied to the protocol information generating method. Please refer to the following examples.
As shown in fig. 2, there is provided a protocol information generating apparatus 200 including:
a reading module 210, configured to read a configuration file of a protocol; the configuration file records a plurality of pieces of configuration information, and each piece of configuration information at least comprises a register starting address and a byte number;
the grouping module 220 is configured to divide each piece of configuration information into corresponding configuration information groups in sequence according to a preset division rule according to an arrangement sequence of the initial addresses of the registers; wherein each configuration information group at least comprises one piece of configuration information; for a configuration information group comprising at least two pieces of configuration information, the absolute value of the difference between the register start address of the first configuration information and the register start address of the second configuration information is equal to the byte number of the first configuration information, the first configuration information and the second configuration information are adjacent configuration information in the arrangement sequence, and the register start address of the first configuration information is smaller than the register start address of the second configuration information;
an instruction generating module 230, configured to generate a communication instruction corresponding to the configuration information set; the register initial address of the communication instruction is the minimum register initial address in the configuration information group, and the register address length of the communication instruction is the total byte number of the byte number of each configuration information included in the configuration information group.
Optionally, the grouping module is further configured to:
sequentially reading configuration information according to the sequence from small to large of the initial addresses of the registers;
dividing the configuration information read at the time into a configuration information group or a new configuration information group to which the configuration information read at the time belongs under the condition that the configuration information read at the time is not the first configuration information and the difference between the register start address of the configuration information read at the time and the register start address of the configuration information read at the time is equal to the byte number of the configuration information read at the time;
and dividing the configuration information read at the time into a new configuration information group under the condition that the configuration information read at the time is not the first configuration information and the difference between the register start address of the configuration information read at the time and the register start address of the configuration information read at the previous time is larger than the byte number of the configuration information read at the previous time.
Optionally, the protocol information generating state further includes a control module, configured to:
and under the condition that the configuration information read at present is not the first piece of configuration information and the difference between the register initial address of the configuration information read at present and the register initial address of the configuration information read at last is smaller than the byte number of the configuration information read at last, removing the configuration information read at present and generating alarm information.
Optionally, the grouping module is further configured to:
sequentially reading configuration information according to the sequence from the beginning address of the register to the beginning address of the register;
dividing the configuration information read at the time into a configuration information group or a new configuration information group to which the configuration information read at the time belongs under the condition that the configuration information read at the time is not the first configuration information and the absolute value of the difference value between the register start address of the configuration information read at the time and the register start address of the configuration information read at the time is equal to the byte number of the configuration information read at the time;
and dividing the configuration information read at the time into a new configuration information group under the condition that the configuration information read at the time is not the first piece of configuration information and the absolute value of the difference value between the register start address of the configuration information read at the time and the register start address of the configuration information read at the previous time is larger than the byte number of the configuration information read at the time.
Optionally, the control module is further configured to:
and under the condition that the configuration information read at present is not the first piece of configuration information, and the absolute value of the difference value between the register initial address of the configuration information read at present and the register initial address of the configuration information read at last is smaller than the byte number of the configuration information read at present, removing the configuration information read at present, and generating alarm information.
Optionally, the grouping module is further configured to:
if the sum value is smaller than or equal to the register address length threshold value of the communication instruction, dividing the configuration information read at present into a configuration information group to which the configuration information read at the previous time belongs, otherwise dividing the configuration information read at present into a new configuration information group;
the sum value is the sum of the total bytes of the configuration information group to which the configuration information read at the previous time belongs and the bytes of the configuration information read at the current time.
Optionally, the grouping module is further configured to:
if the current reading order meets the preset dividing condition, dividing the current reading configuration information into a configuration information group to which the previous reading configuration information belongs, otherwise dividing the current reading configuration information into a new configuration information group.
Optionally, the preset dividing condition is a function expression regarding at least one argument, and the dependent variable of the function expression is a reading order.
In the embodiment of the invention, after the configuration file of the protocol is read, each piece of configuration information can be sequentially divided into the corresponding configuration information groups according to the arrangement sequence of the initial addresses of the registers and the preset division rule. Thereafter, the configuration information set may be taken as a whole to generate a communication instruction corresponding to the configuration information set. Because the generated communication instruction corresponding to the configuration information group meets the format requirement of the communication instruction, the generated communication instruction cannot generate an error condition as long as the configuration file is free from errors. Thus, when the configuration file of the protocol is read, the corresponding communication instruction can be automatically generated, thereby replacing the manual generation of the communication instruction, avoiding the situation of error of the manual generation of the communication instruction and reducing the labor cost.
Fig. 3 is a schematic diagram of a terminal device according to an embodiment of the present invention. As shown in fig. 3, the terminal device 3 of this embodiment includes: a processor 30, a memory 31 and a computer program 32 stored in said memory 31 and executable on said processor 30. The processor 30, when executing the computer program 32, implements the steps of the various protocol information generation method embodiments described above. Alternatively, the processor 30, when executing the computer program 32, performs the functions of the modules/units of the apparatus embodiments described above.
Illustratively, the computer program 32 may be partitioned into one or more modules/units that are stored in the memory 31 and executed by the processor 30 to complete the present invention. The one or more modules/units may be a series of computer program instruction segments capable of performing specific functions for describing the execution of the computer program 32 in the terminal device 3. For example, the computer program 32 may be divided into a reading module, a grouping module, and an instruction generating module, where each module specifically functions as follows:
the reading module is used for reading the configuration file of the protocol; the configuration file records a plurality of pieces of configuration information, and each piece of configuration information at least comprises a register starting address and a byte number;
the grouping module is used for sequentially dividing each piece of configuration information into corresponding configuration information groups according to the arrangement sequence of the initial addresses of the registers and a preset dividing rule; wherein each configuration information group at least comprises one piece of configuration information; for a configuration information group comprising at least two pieces of configuration information, the absolute value of the difference between the register start address of the first configuration information and the register start address of the second configuration information is equal to the byte number of the first configuration information, the first configuration information and the second configuration information are adjacent configuration information in the arrangement sequence, and the register start address of the first configuration information is smaller than the register start address of the second configuration information;
the instruction generation module is used for generating a communication instruction corresponding to the configuration information group; the register initial address of the communication instruction is the minimum register initial address in the configuration information group, and the register address length of the communication instruction is the total byte number of the byte number of each configuration information included in the configuration information group.
The terminal device 3 may be a computing device such as a desktop computer, a notebook computer, a palm computer, a cloud server, etc. The terminal device may include, but is not limited to, a processor 30, a memory 31. It will be appreciated by those skilled in the art that fig. 3 is merely an example of the terminal device 3 and does not constitute a limitation of the terminal device 3, and may include more or less components than illustrated, or may combine certain components, or different components, e.g., the terminal device may further include an input-output device, a network access device, a bus, etc.
The processor 30 may be a central processing unit (Central Processing Unit, CPU), other general purpose processors, digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), field-programmable gate arrays (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The memory 31 may be an internal storage unit of the terminal device 3, such as a hard disk or a memory of the terminal device 3. The memory 31 may be an external storage device of the terminal device 3, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card) or the like, which are provided on the terminal device 3. Further, the memory 31 may also include both an internal storage unit and an external storage device of the terminal device 3. The memory 31 is used for storing the computer program as well as other programs and data required by the terminal device. The memory 31 may also be used for temporarily storing data that has been output or is to be output.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-described division of the functional units and modules is illustrated, and in practical application, the above-described functional distribution may be performed by different functional units and modules according to needs, i.e. the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-described functions. The functional units and modules in the embodiment may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit, where the integrated units may be implemented in a form of hardware or a form of a software functional unit. In addition, specific names of the functional units and modules are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the present application. The specific working process of the units and modules in the above system may refer to the corresponding process in the foregoing method embodiment, which is not described herein again.
In the foregoing embodiments, the descriptions of the embodiments are emphasized, and in part, not described or illustrated in any particular embodiment, reference is made to the related descriptions of other embodiments.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
In the embodiments provided in the present invention, it should be understood that the disclosed apparatus/terminal device and method may be implemented in other manners. For example, the apparatus/terminal device embodiments described above are merely illustrative, e.g., the division of the modules or units is merely a logical function division, and there may be additional divisions in actual implementation, e.g., multiple units or components may be combined or integrated into another system, or some features may be omitted or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection via interfaces, devices or units, which may be in electrical, mechanical or other forms.
The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in the embodiments of the present invention may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit. The integrated units may be implemented in hardware or in software functional units.
The integrated modules/units, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored in a computer readable storage medium. Based on such understanding, the present invention may implement all or part of the flow of the method of the above embodiment, or may be implemented by a computer program to instruct related hardware, where the computer program may be stored in a computer readable storage medium, and when the computer program is executed by a processor, the computer program may implement the steps of each of the method embodiments described above. Wherein the computer program comprises computer program code which may be in source code form, object code form, executable file or some intermediate form etc. The computer readable medium may include: any entity or device capable of carrying the computer program code, a recording medium, a U disk, a removable hard disk, a magnetic disk, an optical disk, a computer Memory, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), an electrical carrier signal, a telecommunications signal, a software distribution medium, and so forth. It should be noted that the computer readable medium contains content that can be appropriately scaled according to the requirements of jurisdictions in which such content is subject to legislation and patent practice, such as in certain jurisdictions in which such content is subject to legislation and patent practice, the computer readable medium does not include electrical carrier signals and telecommunication signals.
The above embodiments are only for illustrating the technical solution of the present invention, and not for limiting the same; although the invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present invention, and are intended to be included in the scope of the present invention.

Claims (10)

1. A protocol information generation method, comprising:
reading a configuration file of a protocol; the configuration file records a plurality of pieces of configuration information, and each piece of configuration information at least comprises a register starting address and a byte number;
dividing each piece of configuration information into corresponding configuration information groups according to the arrangement sequence of the initial addresses of the registers and a preset dividing rule; wherein each configuration information group at least comprises one piece of configuration information; for the configuration information group comprising at least two pieces of configuration information, the absolute value of the difference between the register start address of the first configuration information and the register start address of the second configuration information is equal to the byte number of the first configuration information, the first configuration information and the second configuration information are adjacent configuration information in the arrangement sequence, and the register start address of the first configuration information is smaller than the register start address of the second configuration information;
generating a communication instruction corresponding to the configuration information group; the register initial address of the communication instruction is the minimum register initial address in the configuration information group, and the register address length of the communication instruction is the total byte number of the byte numbers of each configuration information included in the configuration information group.
2. The protocol information generating method according to claim 1, wherein the sequentially dividing each piece of configuration information into corresponding configuration information groups according to a preset division rule according to an arrangement order of start addresses of registers comprises:
sequentially reading configuration information according to the sequence from small to large of the initial addresses of the registers;
dividing the configuration information read at the present time into a configuration information group or a new configuration information group to which the configuration information read at the previous time belongs under the condition that the configuration information read at the present time is not the first configuration information and the difference between the register start address of the configuration information read at the present time and the register start address of the configuration information read at the previous time is equal to the byte number of the configuration information read at the previous time;
and dividing the configuration information read at the present time into a new configuration information group under the condition that the configuration information read at the present time is not the first piece of configuration information and the difference value between the register starting address of the configuration information read at the present time and the register starting address of the configuration information read at the previous time is larger than the byte number of the configuration information read at the previous time.
3. The protocol information generating method according to claim 2, wherein after the sequential reading of the configuration information in order of the register start addresses from the smaller to the larger, the method further comprises:
and under the condition that the configuration information read at present is not the first piece of configuration information and the difference value between the register initial address of the configuration information read at present and the register initial address of the configuration information read at last is smaller than the byte number of the configuration information read at last, removing the configuration information read at present and generating alarm information.
4. The protocol information generating method according to claim 1, wherein the sequentially dividing each piece of configuration information into corresponding configuration information groups according to a preset division rule according to an arrangement order of start addresses of registers comprises:
sequentially reading configuration information according to the sequence from the beginning address of the register to the beginning address of the register;
dividing the configuration information read at the present time into a configuration information group or a new configuration information group to which the configuration information read at the previous time belongs under the condition that the configuration information read at the present time is not the first configuration information and the absolute value of the difference value between the register start address of the configuration information read at the present time and the register start address of the configuration information read at the previous time is equal to the byte number of the configuration information read at the present time;
and dividing the configuration information read at the present time into a new configuration information group under the condition that the configuration information read at the present time is not the first piece of configuration information and the absolute value of the difference value between the register start address of the configuration information read at the present time and the register start address of the configuration information read at the previous time is larger than the byte number of the configuration information read at the present time.
5. The protocol information generating method according to claim 4, wherein after the sequentially reading the configuration information in order of from the large to the small of the register start address, the method further comprises:
and under the condition that the configuration information read at the present time is not the first piece of configuration information, and the absolute value of the difference value between the register initial address of the configuration information read at the present time and the register initial address of the configuration information read at the previous time is smaller than the byte number of the configuration information read at the present time, removing the configuration information read at the present time, and generating alarm information.
6. The protocol information generating method according to claim 2 or 4, wherein the dividing the configuration information read at the present time into a configuration information group to which the configuration information read at the previous time belongs or a new configuration information group includes:
if the sum value is smaller than or equal to the register address length threshold value of the communication instruction, dividing the configuration information read at present into a configuration information group to which the configuration information read at the previous time belongs, otherwise dividing the configuration information read at present into a new configuration information group;
wherein the sum value is the sum of the total byte number of the configuration information group to which the configuration information read last time belongs and the byte number of the configuration information read last time.
7. The protocol information generating method according to claim 2 or 4, wherein the dividing the configuration information read at the present time into a configuration information group to which the configuration information read at the previous time belongs or a new configuration information group includes:
and if the current reading order meets a preset dividing condition, dividing the current reading configuration information into a configuration information group to which the configuration information read before belongs, otherwise dividing the current reading configuration information into a new configuration information group.
8. The protocol information generating method according to claim 7, wherein the preset dividing condition is a function expression concerning at least one argument, and the argument of the function expression is a reading order.
9. A protocol information generating apparatus, comprising:
the reading module is used for reading the configuration file of the protocol; the configuration file records a plurality of pieces of configuration information, and each piece of configuration information at least comprises a register starting address and a byte number;
the grouping module is used for sequentially dividing each piece of configuration information into corresponding configuration information groups according to the arrangement sequence of the initial addresses of the registers and a preset dividing rule; wherein each configuration information group at least comprises one piece of configuration information; for the configuration information group comprising at least two pieces of configuration information, the absolute value of the difference between the register start address of the first configuration information and the register start address of the second configuration information is equal to the byte number of the first configuration information, the first configuration information and the second configuration information are adjacent configuration information in the arrangement sequence, and the register start address of the first configuration information is smaller than the register start address of the second configuration information;
the instruction generation module is used for generating a communication instruction corresponding to the configuration information group; the register initial address of the communication instruction is the minimum register initial address in the configuration information group, and the register address length of the communication instruction is the total byte number of the byte numbers of each configuration information included in the configuration information group.
10. A terminal device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that the processor implements the steps of the method according to any of claims 1 to 8 when the computer program is executed.
CN202110533722.3A 2021-05-17 2021-05-17 Protocol information generation method, device and terminal equipment Active CN113300883B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110533722.3A CN113300883B (en) 2021-05-17 2021-05-17 Protocol information generation method, device and terminal equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110533722.3A CN113300883B (en) 2021-05-17 2021-05-17 Protocol information generation method, device and terminal equipment

Publications (2)

Publication Number Publication Date
CN113300883A CN113300883A (en) 2021-08-24
CN113300883B true CN113300883B (en) 2023-05-02

Family

ID=77322468

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110533722.3A Active CN113300883B (en) 2021-05-17 2021-05-17 Protocol information generation method, device and terminal equipment

Country Status (1)

Country Link
CN (1) CN113300883B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113824626B (en) * 2021-09-24 2023-12-22 广东科瑞德电气科技有限公司 Communication management method for preventing information interaction loss
CN114070732B (en) * 2021-11-17 2024-01-05 远景智能国际私人投资有限公司 Data processing method, device, equipment and medium based on Internet of things
CN116661865B (en) * 2023-07-26 2023-12-08 深圳大学 Register management method, device, terminal equipment and storage medium

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112073280A (en) * 2020-09-07 2020-12-11 合肥阳光新能源科技有限公司 Communication method and device based on Modbus protocol and communication equipment

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2010097912A1 (en) * 2009-02-25 2010-09-02 Suginaka Junko Information processing device, transmission information encrypting method and transmission information encrypting program
US9298614B2 (en) * 2014-03-14 2016-03-29 International Business Machines Corporation Combined rank and linear address incrementing utility for computer memory test operations

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112073280A (en) * 2020-09-07 2020-12-11 合肥阳光新能源科技有限公司 Communication method and device based on Modbus protocol and communication equipment

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
徐荣茂."Modbus TCP/IP协议安全加固关键技术研究与实现".《中国优秀硕士学位论文全文数据库信息科技辑》.2018,I140-353. *

Also Published As

Publication number Publication date
CN113300883A (en) 2021-08-24

Similar Documents

Publication Publication Date Title
CN113300883B (en) Protocol information generation method, device and terminal equipment
CN108388598B (en) Electronic device, data storage method, and storage medium
CN107832062B (en) Program updating method and terminal equipment
CN106569806A (en) Method achieving adaptive PCIE bandwidth distribution of BIOS, BIOS and motherboard
CN111522574B (en) Differential packet generation method and related equipment
CN110569038B (en) Random verification parameter design method, device, computer equipment and storage medium
CN115114219A (en) PCI-E topological method, device, equipment and storage medium
CN113177063B (en) Thermal reset method and related device of PCI bus equipment
CN111247516A (en) Circuit structure, system-on-chip (SoC) and data processing method
CN112733510A (en) Financial certificate generation method, device, equipment and computer readable storage medium
CN111381905B (en) Program processing method, device and equipment
CN109408035B (en) Flow configuration method, storage medium and server of business system
CN111178513A (en) Convolution implementation method and device of neural network and terminal equipment
CN113434489B (en) Real-time database online capacity expansion method, system, equipment and storage medium
CN114006819A (en) Detection strategy generation and device, and data transmission method and device
CN111258733B (en) Embedded OS task scheduling method and device, terminal equipment and storage medium
CN115952129A (en) Blade server setting method and device and readable storage medium
CN112148470B (en) Parameter synchronization method, computer device and readable storage medium
CN113873026A (en) Dynamic timeout response method, device, terminal equipment and storage medium
CN112421760A (en) Method and device for controlling exciting current of UPS (uninterrupted Power supply) isolation transformer
CN111193648B (en) Data transmission method for reducing CAN bus load, terminal equipment and storage medium
CN109614246B (en) Message processing method and device and message processing server
CN109491604B (en) Method, device and system for processing hard disk drive letter repetition problem
CN107708036B (en) Method and device for debugging output power of audio equipment
CN111538589B (en) Operation optimization method, device, terminal and medium for embedded OS thread blocking queue

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
GR01 Patent grant
GR01 Patent grant