CN113300883A - Protocol information generation method and device and terminal equipment - Google Patents

Protocol information generation method and device and terminal equipment Download PDF

Info

Publication number
CN113300883A
CN113300883A CN202110533722.3A CN202110533722A CN113300883A CN 113300883 A CN113300883 A CN 113300883A CN 202110533722 A CN202110533722 A CN 202110533722A CN 113300883 A CN113300883 A CN 113300883A
Authority
CN
China
Prior art keywords
configuration information
register
current time
information read
read
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.)
Granted
Application number
CN202110533722.3A
Other languages
Chinese (zh)
Other versions
CN113300883B (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 suitable for 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 initial address and byte number; according to the arrangement sequence of the initial addresses of the registers, sequentially dividing each piece of configuration information into corresponding configuration information groups according to a preset division 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 numbers of each configuration information included in the configuration information group. The invention can reduce the error rate when generating the communication command.

Description

Protocol information generation method and device and terminal equipment
Technical Field
The invention belongs to the technical field of communication, and particularly relates to a protocol information generation method, a protocol information generation device and terminal equipment.
Background
Modbus is a serial communication protocol, which is an industry standard of industrial communication protocols and is widely used for connection communication between industrial electronic devices. An RTU (Remote Terminal Unit) is one of the transmission methods defined in the Modbus protocol specification.
When receiving a configuration file of a Modbus RTU protocol, a technician is required to manually convert configuration information such as a function code, a register address and the like in the configuration file into one or more corresponding communication instructions. However, the way of manually generating the communication command has a high error rate.
Disclosure of Invention
In view of this, embodiments of the present invention provide a method, an apparatus, and a terminal device for generating protocol information, so as to solve the problem in the prior art that an error rate is high when a communication instruction is manually generated.
A first aspect of an embodiment of the present invention provides a method for generating protocol information, 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 initial address and byte number;
sequentially dividing each piece of configuration information into corresponding configuration information groups according to a preset division rule according to the 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 value between the register starting address of first configuration information and the register starting address of 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 starting address of the first configuration information is smaller than the register starting 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.
A second aspect of an embodiment of the present invention provides a protocol information generating apparatus, including:
the reading module is used for 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 initial address and 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 division 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 value between the register starting address of first configuration information and the register starting address of 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 starting address of the first configuration information is smaller than the register starting address of the second configuration information;
the command generation module is used for generating a communication command 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.
A third aspect of embodiments of the present invention provides a terminal device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements 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 following beneficial effects:
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 the arrangement sequence of the initial addresses of the registers and the preset division rule. Then, the configuration information group can be taken as a whole to generate a communication instruction corresponding to the configuration information group. Because the generated communication instruction corresponding to the configuration information group meets the format requirement of the communication instruction, the generated communication instruction cannot have an error condition as long as the configuration file has no error. Therefore, when the configuration file of the protocol is read, the corresponding communication instruction can be automatically generated, so that the manual generation of the communication instruction is replaced, the condition that the communication instruction is generated manually and is mistaken is avoided, and the labor cost is reduced.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the embodiments or the prior art descriptions will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without inventive exercise.
Fig. 1 is a flowchart illustrating 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 apparatus 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 particular system structures, techniques, etc. in order to provide a thorough understanding of the embodiments of the 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 explain the technical means of the present invention, the following description will be given by way of specific examples.
As described in the background art, the communication command of the current Modbus RTU protocol is manually generated by technicians, and because different technicians have different levels of care and experience, the manner of manually generating the communication command has a high error rate. In addition, when the configuration file is slightly adjusted, technicians usually change part of the communication instructions on the basis of the communication instructions generated in the previous time, and at this time, the situation that part of the communication instructions are not correspondingly changed easily occurs, so that the error rate is further improved.
In order to solve the problem of the prior art, embodiments of the present invention provide a method and an apparatus for generating protocol information, and a terminal device. First, a protocol information generating method provided in an embodiment of the present invention is described below.
The executing body of the protocol information generating method may be a protocol information generating device, and the protocol information generating device may be a terminal device having a processor and a memory, for example, a control device in each industrial control system, such as a programmable controller, a server, a personal computer, or the like, and the embodiment of the present invention is not particularly limited.
As shown in fig. 1, a method for generating protocol information according to an embodiment of the present invention may include the following steps:
and step S110, reading a 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 initial address and byte number.
As shown in table one, a configuration file of a protocol is shown, where each row in the configuration file is a piece of configuration information, and each piece of configuration information includes information such as register address, byte number, name, default value, and the like.
Watch 1
Figure BDA0003068910930000041
It should be noted that, only part of information of each piece of configuration information is shown in table one, and the configuration information may further include a function code, a format, a unit, and the like, where the function code may be 02 read input state, the format may be a boul format, and the unit may be Status.
And step S120, sequentially dividing each piece of configuration information into corresponding configuration information groups according to a preset division rule according to the arrangement sequence of the initial addresses of the registers.
The preset division rule may be any division rule capable of achieving the following grouping purpose: each configuration information group comprises at least one piece of configuration information; for a configuration information group including at least two pieces of configuration information, the absolute value of the difference value 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 order, and the register start address of the first configuration information is smaller than the register start address of the second configuration information.
After a lot of creative work, the applicant finds that the format of the communication command in the Modbus RTU protocol is relatively fixed, the variables in the communication command include an operation code, a register start address, and a register address length, and the format requirements of the communication command in the Modbus RTU protocol can be summarized as follows: the register address is discontinuous to configure information, and a communication instruction is generated independently; the configuration information of the register addresses can be combined to generate a communication instruction, and can also generate a communication instruction respectively. Referring to table one again, it can be found that the first piece of configuration information and the fourth piece of configuration information in table one are configuration information with discontinuous register addresses, and are not continuous with register addresses of other configuration information, and the second piece of configuration information, the third piece of configuration information, and the fifth to fourteenth pieces of 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 sequentially divided into corresponding configuration information groups according to the preset division rule according to the continuity condition of the register address of each piece of configuration information.
Optionally, the order of the register start addresses may be a sequence of the register start addresses from small to large, and accordingly, the specific processing in step S120 may be as follows: sequentially reading configuration information according to the sequence of the initial addresses of the registers from small to large; when the configuration information read at the current time is not the first piece of configuration information and the difference value between the register initial address of the configuration information read at the current time and the register initial 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, dividing the configuration information read at the current time into a configuration information group to which the configuration information read at the previous time belongs or a new configuration information group; and under the condition that the configuration information read at the current time is not the first piece of configuration information and the difference value between the register initial address of the configuration information read at the current time and the register initial 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, dividing the configuration information read at the current time into new configuration information groups.
In some embodiments, when the arrangement order of the register start addresses is from small to large, one implementation manner of the preset partition rule may be as follows:
for the case that the configuration information read at the current time is the first piece of configuration information, a configuration information group can be created, and then the configuration information read at the current time is directly divided into the configuration information group.
In the case that the configuration information read at the present time is not the first piece of configuration information, and 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 previous time, it indicates that the configuration information read at the present time and the configuration information read at the previous time are configuration information with consecutive register addresses, so that the configuration information read at the present time can be divided into configuration information groups to which the configuration information read at the previous time belongs, or a new configuration information group can be created, and then the configuration information read at the present time is 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 a 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 is divided into the created new configuration information group.
The situation that the configuration information read at the current 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 current 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 indicates that the configuration information read at the current time and the configuration information read at the previous time are configuration information with discontinuous register addresses, so that a new configuration information group can be created, and then the configuration information read at the current time is divided into the created new configuration information group.
In addition, for the case that the configuration information read at the current time is not the first piece of configuration information, and the difference value between the register start address of the configuration information read at the current 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, it indicates that an error exists in the configuration file, and at this time, the configuration information read at the current time can be removed, and alarm information is generated to prompt a technician to perform troubleshooting.
Optionally, the order of the register start addresses may also be a sequence of the register start addresses from large to small, and accordingly, the specific processing in step S120 may be as follows: sequentially reading configuration information according to the sequence of the starting addresses of the registers from large to small; when the configuration information read at the current time is not the first piece of configuration information and the absolute value of the difference value between the register starting address of the configuration information read at the current time and the register starting address of the configuration information read at the previous time is equal to the byte number of the configuration information read at the current time, dividing the configuration information read at the current time into a configuration information group to which the configuration information read at the previous time belongs or a new configuration information group; and 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 starting address of the configuration information read at the 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 time, dividing the configuration information read at the current time into new configuration information groups.
In some embodiments, when the arrangement order of the register start addresses is from large to small, another implementation manner of the preset partition rule may be as follows:
for the case that the configuration information read at the current time is the first piece of configuration information, a configuration information group can be created, and then the configuration information read at the current time is directly divided into the configuration information group.
For the case that the configuration information read at the current 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 current 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 current time, it indicates that the configuration information read at the current time and the configuration information read at the previous time are configuration information with continuous register addresses, so that the configuration information read at the current time can be divided into the configuration information groups to which the configuration information read at the previous time belongs, or a new configuration information group can be created, and then the configuration information read at the current time is divided into the created new configuration information groups.
For the case that the configuration information read at the current 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 current 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 current time, it indicates that the configuration information read at the current time and the configuration information read at the previous time are configuration information with discontinuous register addresses, so that a new configuration information group can be created, and then the configuration information read at the current time is divided into the created new configuration information group.
Similar to the foregoing embodiment in which the start addresses of the registers are in the order from small to large, for the case that the configuration information read this time is not the first piece of configuration information, and the absolute value of the difference between the start address of the register of the configuration information read this time and the start address of the register of the configuration information read last time is smaller than the number of bytes of the configuration information read this time, it indicates that there is an error in the configuration file, and at this time, the configuration information read this time may be removed, and alarm information may be generated to prompt a technician to perform troubleshooting.
It should be noted that the implementation manner is not limited to the preset partition rule, and the preset partition rule may also be another partition rule. For example, a piece of configuration information may be randomly selected, and then all the configuration information is divided into two parts by using the configuration information as a boundary, and then the configuration information of the two parts is divided correspondingly.
Optionally, in consideration of the limitation of the register address length of the communication command, that is, the register address length threshold of the communication command, for example, the register address length of the communication command fixed in the Modbus RTU protocol, cannot exceed the maximum length of 255, or a manually set custom register address, such as 150, 180, etc., in this case, the specific process of dividing the configuration information read at the current 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 less than or equal to the register address length threshold value of the communication instruction, dividing the configuration information read at the current time into configuration information groups to which the configuration information read at the previous time belongs, and otherwise, dividing the configuration information read at the current time into new configuration information groups; 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 at the current time.
Optionally, the configuration information read at the current time may be further divided according to a relationship between the reading order and a preset dividing condition, and thus, the specific process of dividing the configuration information read at the current 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: and if the reading sequence of the current time meets the preset dividing condition, dividing the configuration information read at the current time into the configuration information group to which the configuration information read at the previous time belongs, and otherwise, dividing the configuration information read at the current time into a new configuration information group.
In some embodiments, the preset division condition may be a function expression with respect to at least one argument, the dependent variable of the function expression being a reading order, e.g.Y=2X、Y=2X+1、Y=2X2And 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 concluded that the current reading order does not satisfy the preset dividing condition, and at this time, the configuration information read at the current time can be divided into new configuration information groups.
And step S130, 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.
It should be noted that other information, such as a function code, exists in the communication instruction, and it is considered that the generation process of the other information is conventional in the art, and is not described herein again.
Referring to table one again, 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 configuration information;
configuration information group 4: the fifth piece of configuration information to the fourteenth piece of configuration information.
Accordingly, a communication command including the following key information may be generated:
communication instruction 1: register initial address 1, register address length 1;
and (3) communication command 2: register 10, register address length 2;
communication instruction 3: register 16, register address length 1;
and (4) communication instruction: register 144, register address length 10.
In the embodiment of the present invention, after the configuration file of the protocol is read, each piece of configuration information may be sequentially divided into the corresponding configuration information groups according to the arrangement order of the initial addresses of the registers and the preset division rule. Then, the configuration information group can be taken as a whole to generate a communication instruction corresponding to the configuration information group. Because the generated communication instruction corresponding to the configuration information group meets the format requirement of the communication instruction, the generated communication instruction cannot have an error condition as long as the configuration file has no error. Therefore, when the configuration file of the protocol is read, the corresponding communication instruction can be automatically generated, so that the manual generation of the communication instruction is replaced, the condition that the communication instruction is generated manually and is mistaken is avoided, and the labor cost is reduced.
Based on the protocol information generation method provided by the above embodiment, correspondingly, the invention also provides a specific implementation manner of the protocol information generation device applied to the protocol information generation method. Please see the examples below.
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 initial address and byte number;
the grouping module 220 is configured to sequentially divide each piece of configuration information into corresponding configuration information groups according to a preset division rule according to the arrangement order of the register start addresses; 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 value between the register starting address of first configuration information and the register starting address of 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 starting address of the first configuration information is smaller than the register starting address of the second configuration information;
an instruction generating module 230, configured to generate 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.
Optionally, the grouping module is further configured to:
sequentially reading configuration information according to the sequence of the initial addresses of the registers from small to large;
when the configuration information read at the current time is not the first piece of configuration information and the difference value between the register initial address of the configuration information read at the current time and the register initial 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, dividing the configuration information read at the current time into a configuration information group to which the configuration information read at the previous time belongs or a new configuration information group;
and under the condition that the configuration information read at the current time is not the first piece of configuration information and the difference value between the register initial address of the configuration information read at the current time and the register initial 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, dividing the configuration information read at the current time into new configuration information groups.
Optionally, the protocol information generating state further includes a control module, configured to:
and under the condition that the configuration information read at the current time is not the first piece of configuration information and the difference value between the register initial address of the configuration information read at the current 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 previous time, removing the configuration information read at the current time and generating alarm information.
Optionally, the grouping module is further configured to:
sequentially reading configuration information according to the sequence of the starting addresses of the registers from large to small;
when the configuration information read at the current time is not the first piece of configuration information and the absolute value of the difference value between the register starting address of the configuration information read at the current time and the register starting address of the configuration information read at the previous time is equal to the byte number of the configuration information read at the current time, dividing the configuration information read at the current time into a configuration information group to which the configuration information read at the previous time belongs or a new configuration information group;
and 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 starting address of the configuration information read at the 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 time, dividing the configuration information read at the current time into new configuration information groups.
Optionally, the control module is further configured to:
and under the condition that the configuration information read at the current 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 current 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 current time, removing the configuration information read at the current time and generating alarm information.
Optionally, the grouping module is further configured to:
if the sum value is less than or equal to the register address length threshold value of the communication instruction, dividing the configuration information read at the current time into configuration information groups to which the configuration information read at the previous time belongs, and otherwise, dividing the configuration information read at the current time into new configuration information groups;
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 at the current time.
Optionally, the grouping module is further configured to:
and if the reading sequence of the current time meets the preset dividing condition, dividing the configuration information read at the current time into the configuration information group to which the configuration information read at the previous time belongs, and otherwise, dividing the configuration information read at the current time into a new configuration information group.
Optionally, the preset dividing condition is a function expression about at least one independent variable, and the dependent variable of the function expression is a reading order.
In the embodiment of the present invention, after the configuration file of the protocol is read, each piece of configuration information may be sequentially divided into the corresponding configuration information groups according to the arrangement order of the initial addresses of the registers and the preset division rule. Then, the configuration information group can be taken as a whole to generate a communication instruction corresponding to the configuration information group. Because the generated communication instruction corresponding to the configuration information group meets the format requirement of the communication instruction, the generated communication instruction cannot have an error condition as long as the configuration file has no error. Therefore, when the configuration file of the protocol is read, the corresponding communication instruction can be automatically generated, so that the manual generation of the communication instruction is replaced, the condition that the communication instruction is generated manually and is mistaken is avoided, and the labor cost is reduced.
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 implements the steps in the various protocol information generation method embodiments described above when executing the computer program 32. Alternatively, the processor 30 implements the functions of the modules/units in the above-described device embodiments when executing the computer program 32.
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 implement the present invention. The one or more modules/units may be a series of computer program instruction segments capable of performing specific functions, which are used to describe the execution process 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, and the specific functions of each module are as follows:
the reading module is used for 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 initial address and 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 division 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 value between the register starting address of first configuration information and the register starting address of 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 starting address of the first configuration information is smaller than the register starting address of the second configuration information;
the command generation module is used for generating a communication command 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.
The terminal device 3 may be a desktop computer, a notebook, a palm computer, a cloud server, or other computing devices. The terminal device may include, but is not limited to, a processor 30, a memory 31. It will be understood by those skilled in the art that fig. 3 is only an example of the terminal device 3, and does not constitute a limitation to the terminal device 3, and may include more or less components than those shown, or combine some components, or different components, for example, the terminal device may also include an input-output device, a network access device, a bus, etc.
The Processor 30 may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic device, discrete hardware component, 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 also 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), and 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 and other programs and data required by the terminal device. The memory 31 may also be used to temporarily store 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-mentioned division of the functional units and modules is illustrated, and in practical applications, the above-mentioned function distribution may be performed by different functional units and modules according to needs, that is, the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-mentioned functions. Each functional unit and module in the embodiments may be integrated in one processing unit, or each unit may exist alone physically, or two or more units are integrated in one unit, and the integrated unit may be implemented in a form of hardware, or in a form of 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 processes of the units and modules in the system may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the above embodiments, the descriptions of the respective embodiments have respective emphasis, and reference may be made to the related descriptions of other embodiments for parts that are not described or illustrated in a certain embodiment.
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 implementation. 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 ways. For example, the above-described embodiments of the apparatus/terminal device are merely illustrative, and for example, the division of the modules or units is only one logical division, and there may be other divisions when actually implemented, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed 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 can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated modules/units, if implemented in the form of software functional units and sold or used as separate products, may be stored in a computer readable storage medium. Based on such understanding, all or part of the flow of the method according to the embodiments of the present invention may also be implemented by a computer program, which may be stored in a computer-readable storage medium, and when the computer program is executed by a processor, the steps of the method embodiments may be implemented. Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, usb disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM), Random Access Memory (RAM), electrical carrier wave signals, telecommunications signals, software distribution medium, and the like. It should be noted that the computer readable medium may contain content that is subject to appropriate increase or decrease as required by legislation and patent practice in jurisdictions, for example, in some jurisdictions, computer readable media does not include electrical carrier signals and telecommunications signals as is required by legislation and patent practice.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present invention, and not for limiting the same; although the present 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 solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not substantially depart from the spirit and scope of the embodiments of the present invention, and are intended to be included within the scope of the present invention.

Claims (10)

1. A method for generating protocol information, 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 initial address and byte number;
sequentially dividing each piece of configuration information into corresponding configuration information groups according to a preset division rule according to the arrangement sequence of the initial addresses of the registers; wherein each of the configuration information groups comprises at least one piece of configuration information; for the configuration information group comprising at least two pieces of configuration information, the absolute value of the difference value of the register starting address of first configuration information and the register starting address of 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 starting address of the first configuration information is smaller than the register starting 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 method for generating protocol information according to claim 1, wherein the sequentially dividing each piece of configuration information into the corresponding configuration information groups according to a preset division rule according to the arrangement order of the register start addresses comprises:
sequentially reading configuration information according to the sequence of the initial addresses of the registers from small to large;
when the configuration information read at the current time is not the first piece of configuration information and the difference value between the register initial address of the configuration information read at the current time and the register initial 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, dividing the configuration information read at the current time into a configuration information group or a new configuration information group to which the configuration information read at the previous time belongs;
and under the condition that the configuration information read at the current time is not the first piece of configuration information and the difference value between the register initial address of the configuration information read at the current time and the register initial 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, dividing the configuration information read at the current time into new configuration information groups.
3. The protocol information generating method according to claim 2, wherein after the sequentially reading the configuration information in the order of the register start address from small to large, the method further comprises:
and under the condition that the configuration information read at the current time is not the first piece of configuration information and the difference value between the register initial address of the configuration information read at the current time and the register initial address of the configuration information read at the previous time is less than the byte number of the configuration information read at the previous time, removing the configuration information read at the current time and generating alarm information.
4. The method for generating protocol information according to claim 1, wherein the sequentially dividing each piece of configuration information into the corresponding configuration information groups according to a preset division rule according to the arrangement order of the register start addresses comprises:
sequentially reading configuration information according to the sequence of the starting addresses of the registers from large to small;
when the configuration information read at the current time is not the first piece of configuration information and the absolute value of the difference value between the register starting address of the configuration information read at the current time and the register starting address of the configuration information read at the previous time is equal to the byte number of the configuration information read at the current time, dividing the configuration information read at the current time into a configuration information group to which the configuration information read at the previous time belongs or a new configuration information group;
and under the condition that the configuration information read at the current time is not the first piece of configuration information and the absolute value of the difference value between the register starting address of the configuration information read at the current 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 current time, dividing the configuration information read at the current time into new configuration information groups.
5. The protocol information generating method according to claim 4, wherein after the sequentially reading the configuration information in the order of the register start address from large to small, the method further comprises:
and under the condition that the configuration information read at the current 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 current 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 current time, removing the configuration information read at the current time and generating alarm information.
6. The method for generating protocol information according to claim 2 or 4, wherein the dividing the configuration information read at the current time into the configuration information group to which the configuration information read at the previous time belongs or a new configuration information group comprises:
if the sum value is less than or equal to the register address length threshold value of the communication instruction, dividing the configuration information read at the current time into a configuration information group to which the configuration information read at the previous time belongs, and otherwise, dividing the configuration information read at the current time into a new configuration information group;
wherein the sum 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 at the current time.
7. The method for generating protocol information according to claim 2 or 4, wherein the dividing the configuration information read at the current time into the configuration information group to which the configuration information read at the previous time belongs or a new configuration information group comprises:
if the reading sequence of the current time meets a preset dividing condition, dividing the configuration information read at the current time into a configuration information group to which the configuration information read at the previous time belongs, and otherwise, dividing the configuration information read at the current time into a new configuration information group.
8. The protocol information generating method according to claim 7, wherein the preset division condition is a function expression regarding at least one argument, and the dependent variable of the function expression is a reading order.
9. A protocol information generating apparatus, characterized by comprising:
the reading module is used for 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 initial address and 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 division rule; wherein each of the configuration information groups comprises at least one piece of configuration information; for the configuration information group comprising at least two pieces of configuration information, the absolute value of the difference value of the register starting address of first configuration information and the register starting address of 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 starting address of the first configuration information is smaller than the register starting address of the second configuration information;
the instruction generating 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 executing the computer program.
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 true CN113300883A (en) 2021-08-24
CN113300883B 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)

Cited By (3)

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

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20110296165A1 (en) * 2009-02-25 2011-12-01 Junko Suginaka Information processing apparatus, transmission information encryption method, and transmission information encryption program
US20150262706A1 (en) * 2014-03-14 2015-09-17 International Business Machines Corporation Combined rank and linear address incrementing utility for computer memory test operations
CN112073280A (en) * 2020-09-07 2020-12-11 合肥阳光新能源科技有限公司 Communication method and device based on Modbus protocol and communication equipment

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20110296165A1 (en) * 2009-02-25 2011-12-01 Junko Suginaka Information processing apparatus, transmission information encryption method, and transmission information encryption program
US20150262706A1 (en) * 2014-03-14 2015-09-17 International Business Machines Corporation Combined rank and linear address incrementing utility for computer memory test operations
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协议安全加固关键技术研究与实现"" *

Cited By (6)

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

Also Published As

Publication number Publication date
CN113300883B (en) 2023-05-02

Similar Documents

Publication Publication Date Title
CN113300883B (en) Protocol information generation method, device and terminal equipment
CN107832062B (en) Program updating method and terminal equipment
CN108363737B (en) Data format conversion method, device and equipment
CN106569806A (en) Method achieving adaptive PCIE bandwidth distribution of BIOS, BIOS and motherboard
CN111242164A (en) Decision result determination method, device and equipment
CN115114219A (en) PCI-E topological method, device, equipment and storage medium
CN111178513B (en) Convolution implementation method and device of neural network and terminal equipment
CN109254932B (en) Multi-network-port driving method, device and storage medium
CN107729577B (en) Data searching method based on multidimensional hash table, terminal equipment and storage medium
CN113177063B (en) Thermal reset method and related device of PCI bus equipment
CN111381905A (en) Program processing method, device and equipment
CN113055250B (en) Networking communication method, device, terminal equipment and storage medium
CN111384971A (en) Data processing method and device in finite field and decoder
CN111258733B (en) Embedded OS task scheduling method and device, terminal equipment and storage medium
CN109614246B (en) Message processing method and device and message processing server
CN114006819A (en) Detection strategy generation and device, and data transmission method and device
CN113765504A (en) Universal dynamic delay jitter elimination method, device, terminal and storage medium
CN113873026A (en) Dynamic timeout response method, device, terminal equipment and storage medium
CN111862894A (en) Backlight brightness adjusting method, device, terminal and readable storage medium
CN112421760A (en) Method and device for controlling exciting current of UPS (uninterrupted Power supply) isolation transformer
CN110738017A (en) Distributed integrated circuit simulation method and device, computing equipment and storage medium
CN114301807B (en) Double-system synchronous network cable fault testing device and method
CN110389917B (en) Storage device for graphic processor and configuration setting adjustment method
CN117633300A (en) Data indexing method, device, computer storage medium and acceleration card
CN111740405A (en) Starting control method, system and device of electrical equipment

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