[go: up one dir, main page]

CN107479531B - Remote determination method of communication protocol frame format information of embedded PLC access equipment - Google Patents

Remote determination method of communication protocol frame format information of embedded PLC access equipment Download PDF

Info

Publication number
CN107479531B
CN107479531B CN201710639474.4A CN201710639474A CN107479531B CN 107479531 B CN107479531 B CN 107479531B CN 201710639474 A CN201710639474 A CN 201710639474A CN 107479531 B CN107479531 B CN 107479531B
Authority
CN
China
Prior art keywords
frame
embedded
embedded plc
port
test
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
CN201710639474.4A
Other languages
Chinese (zh)
Other versions
CN107479531A (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.)
Hangzhou Electronic Science and Technology University
Original Assignee
Hangzhou Electronic Science and Technology University
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 Hangzhou Electronic Science and Technology University filed Critical Hangzhou Electronic Science and Technology University
Priority to CN201710639474.4A priority Critical patent/CN107479531B/en
Publication of CN107479531A publication Critical patent/CN107479531A/en
Application granted granted Critical
Publication of CN107479531B publication Critical patent/CN107479531B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G05CONTROLLING; REGULATING
    • G05BCONTROL OR REGULATING SYSTEMS IN GENERAL; FUNCTIONAL ELEMENTS OF SUCH SYSTEMS; MONITORING OR TESTING ARRANGEMENTS FOR SUCH SYSTEMS OR ELEMENTS
    • G05B23/00Testing or monitoring of control systems or parts thereof
    • G05B23/02Electric testing or monitoring
    • G05B23/0205Electric testing or monitoring by means of a monitoring system capable of detecting and responding to faults
    • G05B23/0218Electric testing or monitoring by means of a monitoring system capable of detecting and responding to faults characterised by the fault detection method dealing with either existing or incipient faults
    • G05B23/0256Electric testing or monitoring by means of a monitoring system capable of detecting and responding to faults characterised by the fault detection method dealing with either existing or incipient faults injecting test signals and analyzing monitored process response, e.g. injecting the test signal while interrupting the normal operation of the monitored system; superimposing the test signal onto a control signal during normal operation of the monitored system
    • GPHYSICS
    • G05CONTROLLING; REGULATING
    • G05BCONTROL OR REGULATING SYSTEMS IN GENERAL; FUNCTIONAL ELEMENTS OF SUCH SYSTEMS; MONITORING OR TESTING ARRANGEMENTS FOR SUCH SYSTEMS OR ELEMENTS
    • G05B2219/00Program-control systems
    • G05B2219/20Pc systems
    • G05B2219/24Pc safety
    • G05B2219/24065Real time diagnostics

Landscapes

  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Engineering & Computer Science (AREA)
  • Automation & Control Theory (AREA)
  • Communication Control (AREA)

Abstract

本发明提供一种嵌入式PLC的接入设备通信协议帧格式信息远程确定方法。所述方法包括:获取测试帧;向嵌入式PLC发送所述测试帧,其中,所述测试帧由所述嵌入式PLC发送给接入设备,所述接入设备根据所述测试帧反馈测试结果;在第一时间内,确定是否从所述嵌入式PLC获取到正确的所述测试结果,其中,所述第一时间的起始时刻为完成向所述嵌入式PLC发送所述测试帧的时刻;若从所述嵌入式PLC获取到正确的测试结果,则根据所述测试帧确定正确的帧格式信息。本发明实现了对嵌入式PLC的接入设备通信协议帧格式信息的远程确定,提高了确定帧格式信息的效率。

The invention provides a method for remotely determining the communication protocol frame format information of an access device of an embedded PLC. The method includes: acquiring a test frame; sending the test frame to an embedded PLC, wherein the test frame is sent by the embedded PLC to an access device, and the access device feeds back a test result according to the test frame ; In the first time, determine whether the correct test result is obtained from the embedded PLC, wherein the starting moment of the first time is the moment when the test frame is sent to the embedded PLC ; If the correct test result is obtained from the embedded PLC, then determine the correct frame format information according to the test frame. The invention realizes the remote determination of the frame format information of the communication protocol of the access device of the embedded PLC, and improves the efficiency of determining the frame format information.

Description

嵌入式PLC的接入设备通信协议帧格式信息远程确定方法Remote determination method of communication protocol frame format information of embedded PLC access equipment

技术领域technical field

本发明涉及工业控制技术,尤其涉及一种嵌入式PLC的接入设备通信协议帧格式信息的远程确定方法。The invention relates to industrial control technology, in particular to a method for remotely determining the communication protocol frame format information of an embedded PLC access device.

背景技术Background technique

为了提高程序的开发效率,充分结合可编程控制器(Programmable LogicController,PLC)和专用控制器的优势,嵌入式PLC技术迅速发展起来。嵌入式PLC是对专用控制器采用PLC图形化的开发手段,充分利用了现有嵌入式处理器的强大处理功能,按需定制各类专用控制器,并采用图形化开发平台对专用控制器进行软件开发。即具备了专用控制器可定制的特点,又具备了PLC图形化的开发手段。现有的嵌入式PLC广泛用作监控系统中的监控主机,并通过接口或总线的方式将各类智能设备接入嵌入式PLC。接入的智能设备例如门禁、空调、UPS、油机、温湿度。这些智能设备与嵌入式PLC之间需要通过通信协议进行监视或控制信息的交互。In order to improve the efficiency of program development and fully combine the advantages of programmable logic controllers (Programmable Logic Controller, PLC) and dedicated controllers, embedded PLC technology has developed rapidly. Embedded PLC is a graphical development method for special-purpose controllers. It makes full use of the powerful processing functions of existing embedded processors, customizes various special-purpose controllers on demand, and uses a graphical development platform to develop special-purpose controllers. software development. That is to say, it has the characteristics of special-purpose controller that can be customized, and also has the development means of PLC graphics. The existing embedded PLC is widely used as the monitoring host in the monitoring system, and various intelligent devices are connected to the embedded PLC through interfaces or buses. Connected smart devices such as access control, air conditioner, UPS, oil generator, temperature and humidity. These intelligent devices and embedded PLC need to monitor or control information interaction through communication protocols.

现有的监控系统中,接入嵌入式PLC的智能设备根据类型或型号的不同,可能都对应不同的通信协议。现有的监控系统中所有的通信协议都存放在作为监控主机的嵌入式PLC内,在嵌入式PLC接入新设备时根据实际使用的设备情况进行协议配置,因此要求技术人员下站进行端口初始化、协议验证和编写等现场作业。In the existing monitoring system, the smart devices connected to the embedded PLC may correspond to different communication protocols according to different types or models. All communication protocols in the existing monitoring system are stored in the embedded PLC as the monitoring host. When the embedded PLC is connected to a new device, protocol configuration is performed according to the actual equipment used. Therefore, technicians are required to go to the station to initialize the port. , Protocol verification and writing and other on-site operations.

然而,随着现代无线通信事业的迅猛发展,大量监控系统不断涌现及扩容建设,嵌入式PLC的安装地点相对分布广泛且相互距离较远,现有的嵌入式PLC与接入设备的通信协议构造方式效率低下,使得新设备的接入困难。However, with the rapid development of the modern wireless communication business, a large number of monitoring systems continue to emerge and expand construction. The installation sites of embedded PLC are relatively widely distributed and far away from each other. The existing communication protocol structure between embedded PLC and access equipment The method is inefficient and makes it difficult to access new devices.

发明内容Contents of the invention

第一方面,本发明提供一种嵌入式PLC的接入设备通信协议帧格式信息的远程确定方法,应用于开发主机,包括:In the first aspect, the present invention provides a method for remotely determining the communication protocol frame format information of an embedded PLC access device, which is applied to a development host, including:

获取测试帧;Get the test frame;

向嵌入式可编程控制器PLC发送所述测试帧,其中,所述测试帧由所述嵌入式PLC发送给接入设备,所述接入设备根据所述测试帧反馈测试结果;Send the test frame to the embedded programmable controller PLC, wherein the test frame is sent to the access device by the embedded PLC, and the access device feeds back the test result according to the test frame;

在第一时间内,确定是否从所述嵌入式PLC获取到正确的所述测试结果,其中,所述第一时间的起始时刻为完成向所述嵌入式PLC发送所述测试帧的时刻;In the first time, determine whether the correct test result is obtained from the embedded PLC, wherein the starting moment of the first time is the moment when the test frame is sent to the embedded PLC;

若从所述嵌入式PLC获取到正确的测试结果,则根据所述测试帧确定正确的帧格式信息。If the correct test result is obtained from the embedded PLC, the correct frame format information is determined according to the test frame.

可选地,还包括:Optionally, also include:

若从所述嵌入式PLC没有获取到正确的测试结果,则生成错误提示信息,执行所述获取测试帧。If the correct test result is not obtained from the embedded PLC, an error prompt message is generated, and the acquisition of the test frame is executed.

可选地,在所述根据所述测试帧确定正确的帧格式信息之后,还包括:Optionally, after determining the correct frame format information according to the test frame, the method further includes:

获得外部输入的通信协议模型,所述通信协议模型内嵌有N个第一类子模型,所述第一类子模型内嵌有图形标记和依据所述正确的帧格式信息编辑的协议帧,所述N为大于或等于1的整数;Obtaining an externally input communication protocol model, the communication protocol model is embedded with N first-type sub-models, and the first-type sub-model is embedded with graphic marks and protocol frames edited according to the correct frame format information, The N is an integer greater than or equal to 1;

编译所述通信协议模型获取可执行代码,并将所述可执行代码发送至所述嵌入式PLC。compiling the communication protocol model to obtain executable code, and sending the executable code to the embedded PLC.

可选地,在所述获得外部输入的通信协议模型之后,还包括:Optionally, after obtaining the communication protocol model of external input, it also includes:

根据所述通信协议模型获取可识别调试源码;Obtaining an identifiable debugging source code according to the communication protocol model;

对所述可识别调试源码进行调试获得调试协议帧,并将所述调试协议帧发送至所述嵌入式PLC;Debugging the identifiable debugging source code to obtain a debugging protocol frame, and sending the debugging protocol frame to the embedded PLC;

接收并根据所述嵌入式PLC发送的应答信息获得调试结果。receiving and obtaining the debugging result according to the response information sent by the embedded PLC.

可选地,所述根据所述通信协议模型获取可识别调试源码,包括:Optionally, said obtaining an identifiable debugging source code according to said communication protocol model includes:

从所述通信协议模型中获取所述N个第一类子模型;Obtain the N first type sub-models from the communication protocol model;

获取所述可识别调试源码,所述可识别调试源码为由预设的可识别变量代替所述图形标记的N个第一类子模型。The identifiable debugging source code is obtained, and the identifiable debugging source code is N submodels of the first type in which the graphic marks are replaced by preset identifiable variables.

可选地,在所述向嵌入式PLC发送所述测试帧之前,还包括:Optionally, before sending the test frame to the embedded PLC, it also includes:

获取端口配置信息,根据所述端口配置信息设置端口初始化模型得到设置后的端口初始化模型,其中,所述端口配置信息包括端口读缓冲地址和端口写缓冲地址,所述端口读缓冲地址为所述嵌入式PLC预设读缓冲区的地址,所述端口写缓冲地址为所述嵌入式PLC预设写缓冲区的地址;Obtain port configuration information, set a port initialization model according to the port configuration information to obtain a set port initialization model, wherein the port configuration information includes a port read buffer address and a port write buffer address, and the port read buffer address is the The embedded PLC presets the address of the read buffer, and the port write buffer address is the address of the embedded PLC preset write buffer;

向所述嵌入式PLC发送所述设置后的端口初始化模型。sending the set port initialization model to the embedded PLC.

第二方面,本发明还提供一种嵌入式PLC的接入设备通信协议帧格式信息的远程确定方法,应用于嵌入式PLC,包括:In the second aspect, the present invention also provides a method for remotely determining the communication protocol frame format information of an embedded PLC access device, which is applied to an embedded PLC, including:

接收开发主机发送的测试帧;Receive the test frame sent by the development host;

发送所述测试帧至所述接入设备,sending the test frame to the access device,

接收所述接入设备发送的测试结果,并将所述测试结果发送至所述开发主机,所述测试结果为所述接入设备根据所述测试帧反馈的结果。The test result sent by the access device is received, and the test result is sent to the development host, where the test result is a result fed back by the access device according to the test frame.

可选地,在所述将所述测试结果发送至所述开发主机之后,还包括:Optionally, after sending the test result to the development host, further include:

接收并加载所述开发主机发送的可执行代码,其中,所述可执行代码为开发主机对通信协议模型编译获得的代码,所述通信协议模型内嵌有N个第一类子模型,所述第一类子模型内嵌有图形标记和依据正确的帧格式信息编辑的协议帧,所述N为大于或等于1的整数。receiving and loading the executable code sent by the development host, wherein the executable code is the code obtained by compiling the communication protocol model by the development host, and the communication protocol model is embedded with N submodels of the first type, the The first type of sub-model is embedded with graphic marks and protocol frames edited according to correct frame format information, and N is an integer greater than or equal to 1.

可选地,在所述将所述测试结果发送至所述开发主机之后,还包括:Optionally, after sending the test result to the development host, further include:

接收所述开发主机发送的调试协议帧,并将所述调试协议帧发送至所述接入设备,其中,所述接入设备根据所述调试协议帧反馈应答信息;receiving the debugging protocol frame sent by the development host, and sending the debugging protocol frame to the access device, wherein the access device feeds back response information according to the debugging protocol frame;

接收所述应答信息,并将所述应答信息发送至所述开发主机。receiving the response information, and sending the response information to the development host.

可选地,在所述接收开发主机发送的测试帧之前,还包括:Optionally, before receiving the test frame sent by the development host, it also includes:

接收所述开发主机发送的设置后的端口初始化模型,并根据所述设置后的端口初始化模型对端口初始化配置;receiving the set port initialization model sent by the development host, and configuring the port initialization according to the set port initialization model;

其中,所述设置后的端口配置模型为写入端口配置信息后的端口配置模型,所述端口配置信息包括端口读缓冲地址和端口写缓冲地址,所述端口读缓冲地址为所述嵌入式PLC预设读缓冲区的地址,所述端口写缓冲地址为所述嵌入式PLC预设写缓冲区的地址。Wherein, the port configuration model after the setting is a port configuration model after writing port configuration information, and the port configuration information includes a port read buffer address and a port write buffer address, and the port read buffer address is the embedded PLC The address of the preset read buffer, the port write buffer address is the address of the embedded PLC preset write buffer.

本发明提供的方法通过获取测试帧;向嵌入式PLC发送所述测试帧,其中,所述测试帧由所述嵌入式PLC发送给接入设备,所述接入设备根据所述测试帧反馈测试结果;在第一时间内,确定是否从所述嵌入式PLC获取到正确的所述测试结果,其中,所述第一时间的起始时刻为完成向所述嵌入式PLC发送所述测试帧的时刻;若从所述嵌入式PLC获取到正确的测试结果,则根据所述测试帧确定正确的帧格式信息,实现了对嵌入式PLC的接入设备通信协议帧格式信息的远程确定,用户可以在开发主机上对每个嵌入式PLC的多个接入设备进行帧验证,根据反馈的测试结果可以对帧格式进行修改调整,提高了确定帧格式信息的效率。The method provided by the present invention obtains a test frame; sends the test frame to the embedded PLC, wherein the test frame is sent by the embedded PLC to the access device, and the access device feedbacks the test frame according to the test frame Result; within the first time, determine whether to obtain the correct described test result from the embedded PLC, wherein, the starting moment of the first time is to finish sending the test frame to the embedded PLC time; if the correct test result is obtained from the embedded PLC, then the correct frame format information is determined according to the test frame, and the remote determination of the access device communication protocol frame format information of the embedded PLC is realized, and the user can Frame verification is performed on multiple access devices of each embedded PLC on the development host, and the frame format can be modified and adjusted according to the feedback test results, which improves the efficiency of determining frame format information.

附图说明Description of drawings

为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图逐一简单地介绍,显而易见地,下面描述中的附图是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings that need to be used in the description of the embodiments or the prior art will be briefly introduced below one by one. Obviously, the accompanying drawings in the following description are For some embodiments of the present invention, those skilled in the art can also obtain other drawings based on these drawings without any creative work.

图1为本发明提供的一种嵌入式PLC的接入设备通信协议帧格式信息的远程确定方法流程图;Fig. 1 is the remote determination method flow chart of the access device communication protocol frame format information of a kind of embedded PLC provided by the present invention;

图2为一种开发主机与嵌入式PLC之间的通信系统示例;Fig. 2 is an example of a communication system between a development host and an embedded PLC;

图3为本发明提供的另一种嵌入式PLC的接入设备通信协议帧格式信息的远程确定方法流程图;Fig. 3 is the remote determination method flowchart of another kind of embedded PLC access device communication protocol frame format information provided by the present invention;

图4为本发明提供的再一种嵌入式PLC的接入设备通信协议帧格式信息的远程确定方法流程图;Fig. 4 is the flow chart of the remote determination method of another kind of embedded PLC access device communication protocol frame format information provided by the present invention;

图5为一种通信协议模型的示例;Fig. 5 is the example of a kind of communication protocol model;

图6为本发明提供的又一种嵌入式PLC的接入设备通信协议帧格式信息的远程确定方法流程图;FIG. 6 is a flow chart of a remote determination method for another embedded PLC access device communication protocol frame format information provided by the present invention;

图7为本发明提供的又一种嵌入式PLC的接入设备通信协议帧格式信息的远程确定方法流程图;FIG. 7 is a flow chart of a remote determination method for another embedded PLC access device communication protocol frame format information provided by the present invention;

图8为本发明提供的又一种嵌入式PLC的接入设备通信协议帧格式信息的远程确定方法流程图;FIG. 8 is a flow chart of a remote determination method for another embedded PLC access device communication protocol frame format information provided by the present invention;

图9为本发明提供的又一种嵌入式PLC的接入设备通信协议帧格式信息的远程确定方法流程图;9 is a flow chart of a remote determination method for another embedded PLC access device communication protocol frame format information provided by the present invention;

图10为本发明提供的又一种嵌入式PLC的接入设备通信协议帧格式信息的远程确定方法流程图;Fig. 10 is a flow chart of a remote determination method for another embedded PLC access device communication protocol frame format information provided by the present invention;

图11为本发明提供的又一种嵌入式PLC的接入设备通信协议帧格式信息的远程确定方法流程图;FIG. 11 is a flow chart of a remote determination method for another embedded PLC access device communication protocol frame format information provided by the present invention;

图12为本发明提供的一种嵌入式PLC的接入设备通信协议帧格式信息的远程确定装置;Fig. 12 is a device for remotely determining the communication protocol frame format information of an embedded PLC access device provided by the present invention;

图13为本发明提供的另一种嵌入式PLC的接入设备通信协议帧格式信息的远程确定装置;Fig. 13 is a device for remotely determining the communication protocol frame format information of another embedded PLC access device provided by the present invention;

图14为本发明提供的另一种嵌入式PLC的接入设备通信协议帧格式信息的远程确定装置;Fig. 14 is a device for remotely determining the communication protocol frame format information of another embedded PLC access device provided by the present invention;

图15为本发明提供的另一种嵌入式PLC的接入设备通信协议帧格式信息的远程确定装置;Fig. 15 is a device for remotely determining the communication protocol frame format information of another embedded PLC access device provided by the present invention;

图16为本发明提供的一种嵌入式PLC的接入设备通信协议帧格式信息的远程确定装置;Fig. 16 is a device for remotely determining the communication protocol frame format information of an embedded PLC access device provided by the present invention;

图17为本发明提供的另一种嵌入式PLC的接入设备通信协议帧格式信息的远程确定装置。FIG. 17 is another device for remotely determining the communication protocol frame format information of an embedded PLC access device provided by the present invention.

具体实施方式Detailed ways

为使本发明实施例的目的、技术方案和优点更加清楚,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments It is a part of embodiments of the present invention, but not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by persons of ordinary skill in the art without making creative efforts belong to the protection scope of the present invention.

图1为本发明提供的一种嵌入式PLC的接入设备通信协议帧格式信息的远程确定方法流程图。可选地,该方法的执行主体是开发主机,该开发主机可以是计算机、服务器等,在此不做限制。FIG. 1 is a flow chart of a method for remotely determining communication protocol frame format information of an embedded PLC access device provided by the present invention. Optionally, the execution subject of the method is a development host, and the development host may be a computer, a server, etc., which is not limited here.

如图1所示的实施例包括:The embodiment shown in Figure 1 includes:

S110,获取测试帧。S110, acquire a test frame.

所述测试帧可以是用户的外部输入的测试帧,也可以是根据用户外部输入的帧格式信息而生成测试帧,还可以是根据用户的外部输入在已有的资源库中选择的测试帧,本发明不限于此。所述测试帧可以是包含测试指令的协议帧,接入设备接收到包含所述测试指令的协议帧,则返回测试结果。The test frame may be a test frame input externally by the user, or may be a test frame generated according to frame format information externally input by the user, or may be a test frame selected in an existing resource library according to the external input of the user, The present invention is not limited thereto. The test frame may be a protocol frame containing a test instruction, and the access device returns a test result after receiving the protocol frame containing the test instruction.

表1为一种帧格式信息实施例。Table 1 is an embodiment of frame format information.

所述测试帧可以是用户根据接入设备的使用手册规定的可用帧格式信息而确定的。如表1所示的帧格式信息包括:起始码(start code information,SOI)、通信协议版本号(version number,VER)、接入设备地址(Access device address,ADR)、接入设备标识码(customer identification,CID1)、控制标识码(code identification,CID2)、命令信息的长度和校验(The length and check of the command information,LENGTH)、指令信息(commandinfomation,INFO)、校验和码(checksum code,CHECKSUM)、结束码(epilogcodeinformation,EOI)。所述测试帧中的指令信息可以为所述测试指令。The test frame may be determined by the user according to the available frame format information specified in the user manual of the access device. The frame format information shown in Table 1 includes: start code (start code information, SOI), communication protocol version number (version number, VER), access device address (Access device address, ADR), access device identification code (customer identification, CID1), control identification code (code identification, CID2), length and check of the command information (The length and check of the command information, LENGTH), command information (command information, INFO), checksum code ( checksum code, CHECKSUM), end code (epilogcode information, EOI). The instruction information in the test frame may be the test instruction.

以空调作为一种接入设备的实施例,所述VER是业内协议的版本号,预设为21H。ADR是空调的地址,例如空调地址为1,转换为十六进制数位01H。根据业内协议,CID1的字段固定为60H(60H为“分散空调类型”的代码)。CID2在作命令帧时,是控制标识码;作为响应信息时,是返回码RTN。An air conditioner is used as an example of an access device, and the VER is a version number of an industry protocol, which is preset as 21H. ADR is the address of the air conditioner. For example, the address of the air conditioner is 1, which is converted into a hexadecimal number 01H. According to the industry agreement, the field of CID1 is fixed at 60H (60H is the code of "distributed air conditioner type"). When CID2 is used as a command frame, it is the control identification code; when it is used as a response message, it is the return code RTN.

表1Table 1

S120,向嵌入式PLC发送所述测试帧,其中,所述测试帧由所述嵌入式PLC发送给接入设备,所述接入设备根据所述测试帧反馈测试结果。S120. Send the test frame to an embedded PLC, where the test frame is sent by the embedded PLC to an access device, and the access device feeds back a test result according to the test frame.

具体地,S120可以是开发主机与嵌入式PLC、接入设备之间,通过数据驱动的方法进行通信,实现测试帧的收发测试,从而验证所述测试帧的帧格式是否符合接入设备的通信协议要求。Specifically, S120 may be to communicate between the development host, the embedded PLC, and the access device through a data-driven method to realize the sending and receiving test of the test frame, thereby verifying whether the frame format of the test frame conforms to the communication protocol of the access device. protocol requirements.

图2为一种开发主机与嵌入式PLC之间的通信系统示例。该系统包括:开发主机、嵌入式PLC、接入设备。所述开发主机通过以太网连接所述嵌入式PLC,所述嵌入式PLC通过通信端口连接所述接入设备。所述嵌入式PLC中包含多个存储区,例如所示的X区、Y区和D区,其中,所述D区中至少包括读缓冲区(Read Buffer,RB)和写缓冲区(Write Buffer,WB)。嵌入式的通信端口配置有端口读缓冲地址1和端口写缓冲地址1。接入设备配置有端口读缓冲地址2和端口写缓冲地址2。Figure 2 is an example of a communication system between a development host and an embedded PLC. The system includes: development host, embedded PLC, access equipment. The development host is connected to the embedded PLC through Ethernet, and the embedded PLC is connected to the access device through a communication port. Contain a plurality of storage areas in the described embedded PLC, for example shown X area, Y area and D area, wherein, comprise at least read buffer (Read Buffer, RB) and write buffer (Write Buffer) in the described D area , WB). The embedded communication port is configured with port read buffer address 1 and port write buffer address 1. The access device is configured with port read buffer address 2 and port write buffer address 2.

所述嵌入式PLC的通信端口在端口初始化过程中,将端口读缓冲地址1配置为所述D区的RB的地址;将端口写缓冲地址1配置为所述D区的WB的地址。由此,所述通信端口从接入设备接收到的数据直接存入所述D区的RB的地址,而所述D区的WB更新的数据也将被所述通信端口写入对应的接入设备。在如图2所示的一种向嵌入式PLC发送所述测试帧的实现方式中,开发主机通过以太网与嵌入式PLC通信,且开发主机通过所述以太网的连接读取或设置嵌入式PLC的D区中的数据。In the port initialization process of the communication port of the embedded PLC, the port read buffer address 1 is configured as the address of the RB in the D area; the port write buffer address 1 is configured as the address of the WB in the D area. Thus, the data received by the communication port from the access device is directly stored in the address of the RB in the D area, and the updated data of the WB in the D area will also be written into the corresponding access device by the communication port. equipment. In an implementation of sending the test frame to the embedded PLC as shown in Figure 2, the development host communicates with the embedded PLC through the Ethernet, and the development host reads or sets the embedded PLC through the connection of the Ethernet. Data in the D area of the PLC.

可选地,所述开发主机包含存储区,所述存储区中预设有写数据缓冲区和读数据缓冲区。所述开发主机获取所述测试帧后填入所述写数据缓冲区中,另外,开发主机通过以太网将测试帧下发到所述嵌入式PLC的WB中。在所述嵌入式PLC中,通信端口根据所述测试帧中包含的接入设备地址描述,将所述WB中的测试帧发送给接入设备。若所述测试帧的帧格式信息都正确,则所述接入设备能够正确接收到所述测试帧并解析获取所述测试帧中的测试指令等信息。Optionally, the development host includes a storage area, and the storage area is preset with a write data buffer and a read data buffer. The development host obtains the test frame and fills it into the write data buffer. In addition, the development host sends the test frame to the WB of the embedded PLC via Ethernet. In the embedded PLC, the communication port sends the test frame in the WB to the access device according to the address description of the access device included in the test frame. If the frame format information of the test frame is correct, the access device can correctly receive the test frame and parse and obtain information such as test instructions in the test frame.

所述接入设备可以包括门禁、空调、智能供电模块、油机、温湿度感测装置、电梯系统或工业自动化机器。The access device may include access control, air conditioner, intelligent power supply module, oil generator, temperature and humidity sensing device, elevator system or industrial automation machine.

S130,在第一时间内,确定是否从所述嵌入式PLC获取到正确的所述测试结果,其中,所述第一时间的起始时刻为完成向所述嵌入式PLC发送所述测试帧的时刻。S130, within a first time, determine whether the correct test result is obtained from the embedded PLC, wherein the starting moment of the first time is the time when the test frame is sent to the embedded PLC time.

所述第一时间根据具体的网络情况、嵌入式PLC与接入设备通信的速率和情况来确定,例如可以设所述第一时间为10s。The first time is determined according to specific network conditions, the rate and situation of communication between the embedded PLC and the access device, for example, the first time may be set as 10s.

S130具体包含了确定是否从所述嵌入式PLC获取到测试结果,以及确定获取到的测试结果是否正确。S130 specifically includes determining whether the test result is obtained from the embedded PLC, and determining whether the obtained test result is correct.

在各线路正确接线、端口配置正确、操作规范的情况下,S130的一种实现方式可以是:在第一时间(例如10s)内,每隔第二时间(例如0.5s)向所述嵌入式PLC的RB询问一次是否有数据更新。若第一时间内嵌入式PLC的RB有更新的数据,则获取到开发主机的读数据缓冲区中,开发主机进一步确定获取到的测试结果是否正确,若正确则进入S141,若错误则继续每隔第二时间向所述嵌入式PLC的RB询问一次是否有数据更新,直到获取到正确的测试结果或在第一时间结束时确定所述测试帧的帧格式信息错误。若在第一时间结束时确定所述测试帧的帧格式信息错误,则生成错误提示信息,执行所述获取测试帧,并向用户显示该测试帧的帧格式信息为错误的提示信息。若第一时间内嵌入式PLC的RB没有更新的数据,则确定所述测试帧的帧格式信息错误,生成错误提示信息,执行所述获取测试帧,并向用户显示该测试帧的帧格式信息为错误的提示信息。Under the condition that each line is correctly wired, the port configuration is correct, and the operation is regulated, one implementation of S130 may be: within the first time (for example, 10s), send the embedded The PLC's RB inquires once whether there is a data update. If the RB of the embedded PLC has updated data within the first time, it will be obtained in the read data buffer of the development host, and the development host will further determine whether the obtained test result is correct, if it is correct, then enter S141, if it is wrong, continue every Query the RB of the embedded PLC every second time whether there is data update, until the correct test result is obtained or the frame format information of the test frame is determined to be wrong at the end of the first time. If it is determined that the frame format information of the test frame is wrong at the end of the first time, an error prompt message is generated, the acquisition of the test frame is performed, and a prompt message that the frame format information of the test frame is wrong is displayed to the user. If the RB of embedded PLC does not have updated data within the first time, then determine that the frame format information of the test frame is wrong, generate an error message, execute the described acquisition of the test frame, and display the frame format information of the test frame to the user For the error message.

其中,所述每隔第二时间向所述嵌入式PLC的RB查看一次是否有数据更新的一种实现方式可以是:每隔所述第二时间,开发主机向嵌入式PLC发送一读命令,所述读命令包括所述嵌入式PLC的RB的地址以及读取数据长度。所述嵌入式PLC响应所述读命令检索RB中是否存储有满足所述读取数据长度的数据,若存在则发送给所述开发主机。Wherein, an implementation of checking whether there is data update to the RB of the embedded PLC every second time may be: every second time, the development host sends a read command to the embedded PLC, The read command includes the address of the RB of the embedded PLC and the length of the read data. In response to the read command, the embedded PLC retrieves whether there is data satisfying the read data length stored in the RB, and if so, sends it to the development host.

所述每隔第二时间向所述嵌入式PLC的RB查看一次是否有数据更新的另一种实现方式可以是:每隔所述第二时间,开发主机向嵌入式PLC发送一读命令,所述读命令包括所述嵌入式PLC的RB的地址。所述嵌入式PLC响应所述读命令检索RB中是否存储有数据,若有数据则发送给所述开发主机并清空RB中的存储。Another implementation of checking whether there is data update to the RB of the embedded PLC every second time may be: every second time, the development host sends a read command to the embedded PLC, so The read command includes the address of the RB of the embedded PLC. The embedded PLC responds to the read command to search whether there is data stored in the RB, and if there is data, it sends it to the development host and clears the storage in the RB.

若所述测试帧的帧格式信息都正确,则所述接入设备根据所述测试帧获得正确的测试结果,并将该正确的测试结果反馈给所述嵌入式PLC。所述嵌入式PLC的通信端口接到所述正确的测试结果时,根据端口读缓冲地址1将所述正确的测试结果读取至所述D区的RB中。所述开发主机监测到所述RB中更新了数据则获取所述数据,开发主机确定更新的数据为正确的测试结果。If the frame format information of the test frame is correct, the access device obtains a correct test result according to the test frame, and feeds back the correct test result to the embedded PLC. When the communication port of the embedded PLC receives the correct test result, it reads the correct test result into the RB of the D area according to the port read buffer address 1. The development host monitors that the data is updated in the RB and acquires the data, and the development host determines that the updated data is a correct test result.

S141,若从所述嵌入式PLC获取到正确的测试结果,则根据所述测试帧确认正确的帧格式信息。S141. If a correct test result is obtained from the embedded PLC, confirm correct frame format information according to the test frame.

所述测试结果是否正确,可以是由开发主机自动根据嵌入式PLC是否有反馈信息来确定,或自动根据嵌入式PLC反馈的信息内容是否正确来确定;也可以是由用户根据嵌入式PLC是否有反馈信息来确定,或根据嵌入式PLC反馈的信息内容是否正确来确定。Whether the test result is correct can be determined automatically by the development host according to whether the embedded PLC has feedback information, or whether the information content fed back by the embedded PLC is correct; it can also be determined by the user according to whether the embedded PLC has It can be determined based on the feedback information, or according to whether the content of the information fed back by the embedded PLC is correct.

所述确定正确的帧格式信息可以是开发主机获取生成测试帧所应用的帧格式为所述正确的帧格式信息,开发主机在确定正确的帧格式信息之后可以是保存入存储器,也可以是开发主机将正确的帧格式信息向用户显示或发送到其他终端,本发明不限于此。The correct frame format information can be determined by the development host to acquire the frame format used to generate the test frame as the correct frame format information. After the correct frame format information is determined, the development host can save it into the memory, or develop The host computer displays the correct frame format information to the user or sends it to other terminals, and the present invention is not limited thereto.

本实施例提供的方法通过获取测试帧;向嵌入式PLC发送所述测试帧,其中,所述测试帧由所述嵌入式PLC发送给接入设备,所述接入设备根据所述测试帧反馈测试结果;在第一时间内,确定是否从所述嵌入式PLC获取到正确的所述测试结果,其中,所述第一时间的起始时刻为完成向所述嵌入式PLC发送所述测试帧的时刻;若从所述嵌入式PLC获取到正确的测试结果,则根据所述测试帧确定正确的帧格式信息,实现了对嵌入式PLC的接入设备通信协议帧格式信息的远程确定,用户可以在开发主机上对每个嵌入式PLC的多个接入设备进行帧验证,根据反馈的测试结果可以对帧格式进行修改调整,提高了确定帧格式信息的效率。The method provided in this embodiment obtains a test frame; sends the test frame to the embedded PLC, wherein the test frame is sent to the access device by the embedded PLC, and the access device feeds back the test frame according to the test frame Test result; within the first time, determine whether to obtain the correct described test result from the embedded PLC, wherein, the starting moment of the first time is to finish sending the test frame to the embedded PLC If the correct test result is obtained from the embedded PLC, the correct frame format information is determined according to the test frame, and the remote determination of the communication protocol frame format information of the access device of the embedded PLC is realized, and the user Frame verification can be performed on multiple access devices of each embedded PLC on the development host, and the frame format can be modified and adjusted according to the feedback test results, which improves the efficiency of determining frame format information.

图3为本发明提供的另一种嵌入式PLC的接入设备通信协议帧格式信息的远程确定方法流程图。表2为返回码的一种实施例。FIG. 3 is a flow chart of another method for remotely determining communication protocol frame format information of an embedded PLC access device provided by the present invention. Table 2 is an embodiment of the return code.

在图1所示实施例的基础上,图3所示的实施例还包括:On the basis of the embodiment shown in Figure 1, the embodiment shown in Figure 3 also includes:

S142,若从所述嵌入式PLC没有获取到正确的测试结果,则生成错误提示信息,执行所述S110。S142. If the correct test result is not obtained from the embedded PLC, generate an error message, and execute S110.

所述没有获取到正确的测试结果可以是没有获取到返回信息,也可以是获取到异常的返回信息,例如获得的测试结果中以返回码描述异常情况。接入设备根据接收到的测试帧反馈测试结果,测试结果包含所述返回码,返回码的一种实施例参见所述表2。例如:所述测试结果中包含的返回码为00H时,所述测试结果为正确的测试结果,其他返回码都为错误的测试结果,在此不做限制,也可以由其他代码标识。The failure to obtain the correct test result may mean that no return information is obtained, or abnormal return information is obtained, for example, the abnormal situation is described by a return code in the obtained test result. The access device feeds back the test result according to the received test frame, and the test result includes the return code. For an embodiment of the return code, see Table 2. For example: when the return code included in the test result is 00H, the test result is a correct test result, and all other return codes are wrong test results, which are not limited here and can also be identified by other codes.

在获取到错误的测试结果之后,还可以向用户显示该测试帧的帧格式信息为错误的错误提示信息,并在该错误提示信息中写入所述返回码,或写入根据所述返回码确定的错误类型信息,所述错误类型信息可以包括“VER错误”、“CHECKSUM错误”、“CID2无效”或、“无效数据”。其中,所述“无效数据”对应在关机状态下进行“开机”之外的参数设置,或开机状态下设置的参数超出范围,或数据帧格式错误。After the wrong test result is obtained, the error message that the frame format information of the test frame is wrong can also be displayed to the user, and the return code can be written in the error message, or written according to the return code. Determined error type information, the error type information may include "VER error", "CHECKSUM error", "CID2 invalid" or "invalid data". Wherein, the "invalid data" corresponds to the parameter setting other than "starting" in the off state, or the parameters set in the power on state are out of range, or the format of the data frame is wrong.

表2Table 2

返回码return code 表示意义Meaning 00H00H 帧格式信息正确时反馈Feedback when the frame format information is correct 01H01H VER错误时反馈Feedback when VER is wrong 02H02H CHECKSUM错误时反馈Feedback when CHECKSUM is wrong 04H04H CID2无效时反馈Feedback when CID2 is invalid 06H06H 无效数据时反馈Feedback on invalid data

执行所述S110具体可以是,用户在参考了所述提示信息后,根据所述错误类型信息修改了原帧格式信息,以新的帧格式信息生成一新的测试帧。再次执行S110直至获取正确的测试结果,根据正确的测试结果对应的测试帧确定正确的帧格式信息。Executing S110 may specifically be that after referring to the prompt information, the user modifies the original frame format information according to the error type information, and generates a new test frame with the new frame format information. Execute S110 again until the correct test result is obtained, and determine the correct frame format information according to the test frame corresponding to the correct test result.

本实施例通过若从所述嵌入式PLC没有获取到正确的测试结果,则生成错误提示信息,执行所述S110,实现了在帧验证错误时获取新的测试帧,用户能够获知帧格式信息有错,则更换原本的帧格式信息重新进行验证,本实施例通过向用户提供错误提示信息,进一步提高了确定帧格式信息的效率。In this embodiment, if the correct test result is not obtained from the embedded PLC, an error prompt message is generated, and the S110 is executed, so that a new test frame is obtained when the frame verification error occurs, and the user can know that the frame format information is valid. If it is wrong, replace the original frame format information and perform verification again. This embodiment further improves the efficiency of determining the frame format information by providing error prompt information to the user.

图4为本发明提供的再一种嵌入式PLC的接入设备通信协议帧格式信息的远程确定方法流程图。FIG. 4 is a flow chart of another method for remotely determining communication protocol frame format information of an embedded PLC access device provided by the present invention.

在图1或图3所示实施例的基础上,图4所述的实施例在S141之后,还包括:On the basis of the embodiment shown in FIG. 1 or FIG. 3 , the embodiment described in FIG. 4 further includes after S141:

S151,获得外部输入的通信协议模型,所述通信协议模型内嵌有N个第一类子模型,所述第一类子模型内嵌有图形标记和依据所述正确的帧格式信息编辑的协议帧,所述N为大于或等于1的整数。S151. Obtain an externally input communication protocol model, the communication protocol model is embedded with N first-type sub-models, and the first-type sub-model is embedded with a graphic mark and a protocol edited according to the correct frame format information frame, the N is an integer greater than or equal to 1.

S152,编译所述通信协议模型获取可执行代码,并将所述可执行代码发送至所述嵌入式PLC。S152. Compile the communication protocol model to obtain executable code, and send the executable code to the embedded PLC.

在确定了正确的测试结果对应的测试帧后,用户依据所述测试帧使用的帧格式信息进行通信协议模型的编辑。所述通信协议模型可以具体为以梯形图语言编写的PLC程序代码,并在图形语言中嵌入了C语言程序。所述第一类子模型可以为包含有图形标记和协议帧的C语言程序。在通信协议模型的第一类子模型中写入了M个协议帧,每个协议帧都是依据正确的帧格式信息编辑的,M为大于或等于1的整数。After determining the test frame corresponding to the correct test result, the user edits the communication protocol model according to the frame format information used by the test frame. The communication protocol model may specifically be a PLC program code written in a ladder language, and a C language program is embedded in the graphic language. The first type of sub-model may be a C language program including graphic markers and protocol frames. M protocol frames are written in the first sub-model of the communication protocol model, each protocol frame is edited according to the correct frame format information, and M is an integer greater than or equal to 1.

图5为一种通信协议模型的示例。图5所示的通信协议模型中,X1、X2、X3、X4、X5、X6都为触发条件。在X1触发条件满足后X1闭合或X2、X3触发条件满足后,然后在X4或X5触发条件满足时检测X6是否满足,若X6也满足时,发送数据帧。Figure 5 is an example of a communication protocol model. In the communication protocol model shown in Figure 5, X1, X2, X3, X4, X5, and X6 are all trigger conditions. After the trigger condition of X1 is met, X1 is closed or the trigger conditions of X2 and X3 are met, and then when the trigger condition of X4 or X5 is met, it is detected whether X6 is satisfied, and if X6 is also satisfied, the data frame is sent.

开发主机对获得的所述通信协议模型进行编译获得用于在嵌入式PLC中运行的可执行代码,并将可执行代码下载到所述嵌入式PLC中,如果所述通信协议模型编辑的过程中按标准实施,所述嵌入式PLC可以正常运行所述通信协议模型。The development host compiles the obtained communication protocol model to obtain executable code for running in the embedded PLC, and downloads the executable code to the embedded PLC, if the communication protocol model is edited in the process According to standard implementation, the embedded PLC can normally run the communication protocol model.

本实施例通过获得外部输入的通信协议模型,并编译通信协议模型获得可执行代码,发送可执行代码至嵌入式PLC,完成了嵌入式PLC针对接入设备的通信协议模型的远程构建。In this embodiment, by obtaining an externally input communication protocol model, compiling the communication protocol model to obtain executable code, and sending the executable code to the embedded PLC, the remote construction of the communication protocol model of the embedded PLC for the access device is completed.

图6为本发明提供的又一种嵌入式PLC的接入设备通信协议帧格式信息的远程确定方法流程图。在图4所示实施例的基础上,图6所示的实施例在所述S151之后,还包括调试过程:6 is a flow chart of another method for remotely determining the communication protocol frame format information of an embedded PLC access device provided by the present invention. On the basis of the embodiment shown in Figure 4, the embodiment shown in Figure 6 also includes a debugging process after the S151:

S160,根据所述通信协议模型获取可识别调试源码。S160. Acquire an identifiable debugging source code according to the communication protocol model.

S170,对所述可识别调试源码进行调试获得调试协议帧,并将所述调试协议帧发送至所述嵌入式PLC。S170. Debug the identifiable debugging source code to obtain a debugging protocol frame, and send the debugging protocol frame to the embedded PLC.

S180,接收并根据所述嵌入式PLC发送的应答信息获得调试结果。S180. Receive and obtain a debugging result according to the response information sent by the embedded PLC.

所述开发主机可以是电脑(personal computer,PC)端,现有技术中已有多种PC端开发软件,然而这些开发软件无法识别由图形语言编写的PLC程序中的图元和图形标记,无法对包含有图形语言的所述通信协议模型进行直接调试。本实施例根据所述通信协议模型获取所述可识别调试源码,所述可识别调试源码可以是用C语言编写的与设备通信的协议代码,其中可以包含的图形标记被开发主机中预设的嵌入式PLC工具识别并转换成对应的可识别变量。在开发主机端使用常见的C语言程序开发软件对可识别调试源码编译和运行。由此对所述可识别调试源码进行单步、断点、变量修改等调试。The development host can be a computer (personal computer, PC) end, and there are many kinds of PC end development software in the prior art, but these development software cannot recognize the graphic elements and graphic marks in the PLC program written by the graphic language, and cannot The communication protocol model including the graphical language is directly debugged. In this embodiment, the identifiable debugging source code is acquired according to the communication protocol model, and the identifiable debugging source code may be a protocol code written in C language for communicating with a device, and the graphic marks that may be included are preset in the development host The embedded PLC tool recognizes and converts into corresponding recognizable variables. Use the common C language program development software on the development host to compile and run the identifiable debugging source code. In this way, single-step, breakpoint, variable modification and other debugging are performed on the identifiable debugging source code.

在上述实施例中,S160进一步可以包括:从所述通信协议模型中获取所述N个第一类子模型;获取所述可识别调试源码,所述可识别调试源码为由预设的可识别变量代替所述图形标记的N个第一类子模型。In the above embodiment, S160 may further include: obtaining the N first type sub-models from the communication protocol model; obtaining the identifiable debugging source code, where the identifiable debugging source code is a preset identifiable variable substituted for the graphically labeled N first-class submodels.

具体地,可以是开发主机在所述通信协议模型中将由C语言编辑的第一子模型提取出来,例如图5中的“发送数据帧”功能块,由此实现对所述通信协议模型中第一类子模型的调试准备。Specifically, it may be that the development host extracts the first sub-model edited by C language in the communication protocol model, such as the "send data frame" function block in Fig. 5, thereby implementing the first sub-model in the communication protocol model Debug preparation for a class of submodels.

所述第一类子模型中包括图形标记,比如触点X0、X1等,由于常见的PC端开发软件包含的C语言程序开发软件不能识别图形标记,开发主机侧的嵌入式PLC工具需要预先将这些图形标记转换为可识别的信息。所述可识别的信息可以是符合C语言编程标准的可识别变量。所述预设的对应关系包括变量与图形标记之间的一一对应关系。Include graphic mark in described first class sub-model, such as contact X0, X1 etc., because the C language program development software that common PC terminal development software comprises can not recognize graphic mark, the embedded PLC tool of development host side needs to pre-set These graphic marks translate into recognizable information. The identifiable information may be an identifiable variable conforming to the C language programming standard. The preset correspondence includes a one-to-one correspondence between variables and graphic marks.

开发主机在调试过程中,将所述可识别调试源码运行发出的调试协议帧发送给嵌入式PLC,并可对协议帧的构成、发送过程、协议帧应答帧以及嵌入式PLC运行状态进行查看、编辑等调试。所述调试协议帧是指调试过程中发出的用于调试的协议帧。During the debugging process, the development host sends the debugging protocol frame issued by the identifiable debugging source code to the embedded PLC, and can view the composition of the protocol frame, the sending process, the protocol frame response frame and the running status of the embedded PLC, Editing and other debugging. The debugging protocol frame refers to a protocol frame for debugging sent during the debugging process.

在所述对应关系的一种实现方式中,所述图形标记的数据存储于图2中嵌入式PLC的存储单元中,所述可识别变量的数据存储于开发主机预设的存储区中,所述对应关系的转换实现了嵌入式PLC存储区替换为开发主机的存储单元且相互映射。具体地,嵌入式PLC存储区的X区、Y区、D区分别与开发主机的Xm区、Ym区和Dm区相互映射。所述相互映射,是指嵌入式PLC存储区的X区、Y区或D区数据变化时向开发主机发送更新的数据;或则开发主机中Xm区、Ym区或Dm区数据变化时向嵌入式PLC发送更新的数据。In an implementation of the corresponding relationship, the data of the graphic mark is stored in the storage unit of the embedded PLC in Figure 2, and the data of the identifiable variable is stored in the storage area preset by the development host, so The conversion of the above corresponding relationship realizes the replacement of the embedded PLC storage area with the storage unit of the development host and maps each other. Specifically, the X area, Y area, and D area of the embedded PLC storage area are respectively mapped to the Xm area, Ym area, and Dm area of the development host. Described reciprocal mapping refers to the data that is updated to the development mainframe when the data in the X district, Y district or D district of the embedded PLC storage area changes; type PLC to send updated data.

在所述对应关系中,D区和Dm区的映射进一步包括,所述Dm区包括读数据映射区RBm和写数据映射区WBm,RBm与RB数据映射,WBm与WB数据映射;开发主机运行可识别调试源码时,发送的协议帧写入到WBm,WBm的新数据通过以太网发送到WB;嵌入式PLC检测到WB数据有变化,将新数据(即调试协议帧)发送给接入设备。In the corresponding relationship, the mapping between the D area and the Dm area further includes that the Dm area includes a read data mapping area RBm and a write data mapping area WBm, RBm and RB data mapping, WBm and WB data mapping; the development host can run When identifying the debugging source code, the sent protocol frame is written to WBm, and the new data of WBm is sent to WB through Ethernet; the embedded PLC detects that there is a change in WB data, and sends the new data (that is, the debugging protocol frame) to the access device.

WBm中更新的数据通过以太网发送给所述WB的过程具体包括:所述开发主机根据以太网传输协议将WBm中更新的数据封装打包,将封装打包好的数据通过以太网传输至所述嵌入式PLC,嵌入式PLC从封装打包好的数据中获取WBm中更新的数据存入所述WB中。The process of sending the updated data in WBm to the WB via Ethernet specifically includes: the development host encapsulates and packages the updated data in WBm according to the Ethernet transmission protocol, and transmits the packaged and packaged data to the embedded computer via Ethernet. Type PLC, the embedded PLC obtains the updated data in WBm from the packaged data and stores them in the WB.

本实施例通过从所述通信协议模型中获取所述N个第一类子模型;获取所述可识别调试源码,所述可识别调试源码为由预设的可识别变量代替所述图形标记的N个第一类子模型,实现了图形语言程序到C语言程序的转换,将不可识别的通信协议模型转换为可识别调试源码。In this embodiment, the N first-type sub-models are obtained from the communication protocol model; the identifiable debugging source code is obtained, and the identifiable debugging source code is replaced by a preset identifiable variable for the graphic mark The N sub-models of the first category realize the conversion from the graphic language program to the C language program, and convert the unrecognizable communication protocol model into recognizable debugging source code.

图7为本发明提供的又一种嵌入式PLC的接入设备通信协议帧格式信息的远程确定方法流程图。在图1~图6所示任一实施例的基础上,图7所示的实施例在所述S120之前,还包括端口初始化模型设置过程:Fig. 7 is a flow chart of another method for remotely determining the communication protocol frame format information of an embedded PLC access device provided by the present invention. On the basis of any of the embodiments shown in FIGS. 1 to 6, the embodiment shown in FIG. 7 also includes a port initialization model setting process before S120:

S111,获取端口配置信息,根据所述端口配置信息设置端口初始化模型得到设置后的端口初始化模型,其中,所述端口配置信息包括端口读缓冲地址1和端口写缓冲地址1,所述端口读缓冲地址1为所述嵌入式PLC预设读缓冲区的地址,所述端口写缓冲地址1为所述嵌入式PLC预设写缓冲区的地址。S111. Obtain port configuration information, and set a port initialization model according to the port configuration information to obtain a set port initialization model, wherein the port configuration information includes port read buffer address 1 and port write buffer address 1, and the port read buffer Address 1 is the address of the embedded PLC preset read buffer, and the port write buffer address 1 is the address of the embedded PLC preset write buffer.

S112,向所述嵌入式PLC发送所述设置后的端口初始化模型。S112. Send the set port initialization model to the embedded PLC.

所述端口配置信息还包括通信速率、数据位、停止位等端口描述。所述嵌入式PLC由所述设置后的端口初始化模型进行通信端口的初始化配置。所述端口初始化模型具体为一用于配置通信端口的程序代码,所述根据所述端口配置信息设置端口初始化模型的方法具体可以为将所述端口配置信息写入所述用于配置通信端口的硬件寄存器中。The port configuration information also includes port descriptions such as communication rate, data bits, and stop bits. The embedded PLC performs initialization configuration of the communication port by the port initialization model after the setting. The port initialization model is specifically a program code for configuring a communication port, and the method for setting the port initialization model according to the port configuration information may specifically be writing the port configuration information into the in hardware registers.

本实施例通过获取端口配置信息,根据所述端口配置信息设置端口初始化模型得到设置后的端口初始化模型,其中,所述端口配置信息包括端口读缓冲地址1和端口写缓冲地址1,所述端口读缓冲地址1为所述嵌入式PLC预设读缓冲区的地址,所述端口写缓冲地址1为所述嵌入式PLC预设写缓冲区的地址;向所述嵌入式PLC发送所述设置后的端口初始化模型。确定了所述嵌入式PLC的通信端口的读写地址,以设置后的端口初始化模型实现了对嵌入式PLC的通信端口初始化配置。In this embodiment, by obtaining port configuration information, setting the port initialization model according to the port configuration information to obtain the set port initialization model, wherein the port configuration information includes port read buffer address 1 and port write buffer address 1, and the port Read buffer address 1 is the address of the preset read buffer of the embedded PLC, and the port write buffer address 1 is the address of the preset write buffer of the embedded PLC; after sending the setting to the embedded PLC The port initialization model. The read-write address of the communication port of the embedded PLC is determined, and the initialization configuration of the communication port of the embedded PLC is realized with the port initialization model after setting.

图8为本发明提供的又一种嵌入式PLC的接入设备通信协议帧格式信息的远程确定方法流程图。图8所示方法的执行主体可以是嵌入式PLC。如图8所示的实施例包括:FIG. 8 is a flow chart of another method for remotely determining the communication protocol frame format information of an embedded PLC access device provided by the present invention. The execution subject of the method shown in FIG. 8 may be an embedded PLC. The embodiment shown in Figure 8 includes:

S810,接收开发主机发送的测试帧,所述测试帧为包括测试指令的协议帧。S810. Receive a test frame sent by the development host, where the test frame is a protocol frame including a test instruction.

所述测试帧的帧格式信息参见表1。嵌入式PLC的D区为一预设的读写缓冲区,包括读缓冲区(Read Buffer,RB)和写缓冲区(Write Buffer,WB)。其中,所述嵌入式PLC的通信端口在端口初始化过程中,将端口读缓冲地址1配置为所述D区的读缓冲区(Read Buffer,RB)的地址;将端口写缓冲地址1配置为所述D区的写缓冲区(Write Buffer,WB)的地址。由此,所述通信端口从接入设备接收到的数据直接存入所述D区的RB的地址,而所述D区的WB更新的数据也将被所述通信端口写入对应的接入设备。For the frame format information of the test frame, refer to Table 1. The D area of the embedded PLC is a preset read and write buffer, including a read buffer (Read Buffer, RB) and a write buffer (Write Buffer, WB). Wherein, the communication port of the embedded PLC is in the port initialization process, the port read buffer address 1 is configured as the address of the read buffer (Read Buffer, RB) of the D area; the port write buffer address 1 is configured as the The address of the write buffer (Write Buffer, WB) of the D area. Thus, the data received by the communication port from the access device is directly stored in the address of the RB in the D area, and the updated data of the WB in the D area will also be written into the corresponding access device by the communication port. equipment.

所述开发主机包含有存储区,所述存储区中预设有写数据缓冲区和读数据缓冲区。开发主机获取所述测试帧后填入所述写数据缓冲区中,开发主机通过网络下发到所述嵌入式PLC,嵌入式PLC从开发主机接收所述测试帧,并写入WB中。The development host includes a storage area, and the storage area is preset with a write data buffer and a read data buffer. The development host obtains the test frame and fills it into the write data buffer, the development host sends it to the embedded PLC through the network, and the embedded PLC receives the test frame from the development host and writes it into the WB.

S820,发送所述测试帧至所述接入设备。S820. Send the test frame to the access device.

在所述嵌入式PLC中,通信端口将所述WB中的测试帧发送出去;所述测试帧中包含了所述接入设备地址,与所述结束设备地址相等的接入设备会对所述测试帧进行处理。若所述测试帧的帧格式信息都正确,则所述接入设备能够正确解析和获取所述测试帧中的测试指令等信息。In the embedded PLC, the communication port sends the test frame in the WB; the test frame contains the address of the access device, and the access device equal to the address of the end device will respond to the Test frames are processed. If the frame format information of the test frame is correct, the access device can correctly parse and acquire information such as test instructions in the test frame.

S830,接收所述接入设备发送的测试结果,并将所述测试结果发送至所述开发主机,所述测试结果为所述接入设备根据所述测试帧反馈的结果。S830. Receive a test result sent by the access device, and send the test result to the development host, where the test result is a result fed back by the access device according to the test frame.

具体地,接入设备根据测试帧的帧格式是否正确,返回相应的返回码,返回码的类型参见表2。所述测试结果中包含的返回码为00H时,所述测试结果为正确的测试结果,其他返回码都为错误的测试结果。Specifically, the access device returns a corresponding return code according to whether the frame format of the test frame is correct, and the type of the return code is shown in Table 2. When the return code included in the test result is 00H, the test result is a correct test result, and all other return codes are wrong test results.

将所述测试结果发送至所述开发主机的一种实现方式可以是:在第一时间(例如10s)内,开发主机每隔第二时间(例如0.5s)向所述嵌入式PLC的RB询问一次是否有数据更新。An implementation manner of sending the test result to the development host may be: within the first time (for example, 10s), the development host asks the RB of the embedded PLC every second time (for example, 0.5s) Whether there is data update at a time.

若第一时间内嵌入式PLC的RB有更新的数据,则获取到开发主机的读数据缓冲区RBm中。If the RB of the embedded PLC has updated data within the first time, it will be acquired in the read data buffer RBm of the development host.

若第一时间内嵌入式PLC的RB没有更新的数据,则开发主机确定所述测试帧的帧格式信息错误。If the RB of the embedded PLC has no updated data within the first time, the development host determines that the frame format information of the test frame is wrong.

其中,所述每隔第二时间向所述嵌入式PLC的RB查看一次是否有数据更新的一种实现方式可以是:每隔所述第二时间,开发主机向嵌入式PLC发送一读命令,所述读命令包括所述嵌入式PLC的RB的地址以及读取数据长度。所述嵌入式PLC响应所述读命令,将RB中读取范围内的数据发送给所述开发主机;开发主机存储数据到RBm并对数据进行检查和进一步调试。Wherein, an implementation of checking whether there is data update to the RB of the embedded PLC every second time may be: every second time, the development host sends a read command to the embedded PLC, The read command includes the address of the RB of the embedded PLC and the length of the read data. The embedded PLC responds to the read command and sends the data within the read range in the RB to the development host; the development host stores the data in the RBm and checks and further debugs the data.

所述每隔第二时间向所述嵌入式PLC的RB查看一次是否有数据更新的另一种实现方式可以是:每隔所述第二时间,开发主机向嵌入式PLC发送一读命令,所述读命令包括所述嵌入式PLC的RB的地址。所述嵌入式PLC响应所述读命令检索RB中是否有新数据,若有新数据则发送给所述开发主机并清空RB中的存储。Another implementation of checking whether there is data update to the RB of the embedded PLC every second time may be: every second time, the development host sends a read command to the embedded PLC, so The read command includes the address of the RB of the embedded PLC. The embedded PLC responds to the read command to retrieve whether there is new data in the RB, and if there is new data, it sends it to the development host and clears the storage in the RB.

若所述测试帧的帧格式信息都正确,则所述接入设备根据所述测试帧获得正确的测试结果,并将该正确的测试结果反馈给所述嵌入式PLC。所述嵌入式PLC的通信端口接到所述正确的测试结果时,根据端口读缓冲地址1将所述正确的测试结果读取至所述D区的RB中。所述开发主机监测到所述RB中更新了数据则获取所述新数据,开发主机进一步可以确定新数据是否为正确的测试结果。If the frame format information of the test frame is correct, the access device obtains a correct test result according to the test frame, and feeds back the correct test result to the embedded PLC. When the communication port of the embedded PLC receives the correct test result, it reads the correct test result into the RB of the D area according to the port read buffer address 1. The development host acquires the new data after monitoring that the data in the RB is updated, and the development host can further determine whether the new data is a correct test result.

本实施例通过接收开发主机发送的测试帧;发送所述测试帧至所述接入设备,接收所述接入设备发送的测试结果,并将所述测试结果发送至所述开发主机,所述测试结果为所述接入设备根据所述测试帧反馈的结果,实现了对嵌入式PLC的接入设备通信协议帧格式信息的远程确定,用户可以在开发主机上对每个嵌入式PLC的多个接入设备进行帧验证,根据反馈的测试结果可以对帧格式进行修改调整,提高了确定帧格式信息的效率。In this embodiment, by receiving the test frame sent by the development host; sending the test frame to the access device, receiving the test result sent by the access device, and sending the test result to the development host, the The test result is that the access device has realized the remote determination of the communication protocol frame format information of the access device of the embedded PLC according to the result of the feedback of the test frame. Each access device performs frame verification, and the frame format can be modified and adjusted according to the feedback test results, which improves the efficiency of determining frame format information.

图9为本发明提供的又一种嵌入式PLC的接入设备通信协议帧格式信息的远程确定方法流程图。在图8的基础上,图9所示的实施例在所述S830之后,还包括:FIG. 9 is a flow chart of another method for remotely determining communication protocol frame format information of an embedded PLC access device provided by the present invention. On the basis of FIG. 8, the embodiment shown in FIG. 9 further includes after S830:

S841,接收并加载所述开发主机发送的可执行代码,其中,所述可执行代码为开发主机对通信协议模型编译获得的代码,所述通信协议模型内嵌有N个第一类子模型,所述第一类子模型内嵌有图形标记和依据正确的帧格式信息编辑的协议帧,所述N为大于或等于1的整数S841. Receive and load the executable code sent by the development host, where the executable code is the code obtained by compiling the communication protocol model by the development host, and the communication protocol model is embedded with N submodels of the first type, The first type of sub-model is embedded with a graphic mark and a protocol frame edited according to the correct frame format information, and the N is an integer greater than or equal to 1

本实施例通过接收并加载所述开发主机发送的可执行代码,实现了对嵌入式PLC的接入设备通信协议远程构造,提高了通信协议构造的效率。In this embodiment, by receiving and loading the executable code sent by the development host, the remote construction of the communication protocol for the access device of the embedded PLC is realized, and the efficiency of the communication protocol construction is improved.

图10为本发明提供的又一种嵌入式PLC的接入设备通信协议帧格式信息的远程确定方法流程图。在图8或图9所示任一实施例的基础上,图10所示的实施例在所述S830之后,还包括调试过程:FIG. 10 is a flow chart of another method for remotely determining communication protocol frame format information of an embedded PLC access device provided by the present invention. On the basis of any embodiment shown in FIG. 8 or FIG. 9, the embodiment shown in FIG. 10 also includes a debugging process after S830:

S842,接收所述开发主机发送的调试协议帧,并将所述调试协议帧发送至所述接入设备,其中,所述接入设备根据所述调试协议帧反馈应答信息。S842. Receive a debugging protocol frame sent by the development host, and send the debugging protocol frame to the access device, where the access device feeds back response information according to the debugging protocol frame.

具体地,所述通信协议模型内嵌有N个第一类子模型,所述第一类子模型内嵌有图形标记和依据正确的帧格式信息编辑的协议帧;开发主机从通信协议模型中获取所述N个第一类子模型;获取所述可识别调试源码,所述可识别调试源码为由预设的可识别变量代替所述图形标记的N个第一类子模型;在对可识别源码调试过程中发出所述调试协议帧。开发主机在调试过程中,将所述通信协议模型中内嵌的协议帧发送给嵌入式PLC。Specifically, the communication protocol model is embedded with N first-type sub-models, and the first-type sub-models are embedded with graphic marks and protocol frames edited according to correct frame format information; Obtain the N first-type sub-models; obtain the identifiable debugging source code, the identifiable debugging source code is the N first-type sub-models replaced by the preset identifiable variables; The debug protocol frame is sent out during source code debugging. During the debugging process, the development host sends the protocol frame embedded in the communication protocol model to the embedded PLC.

其中,嵌入式PLC中存储区包含D区,D区还与所述开发主机的Dm区数据映射。所述Dm区包括读数据映射区RBm和写数据映射区WBm,D区包括读数据映射区RBm和写数据映射区WBm,RBm与RB数据映射,WBm与WB数据映射。Wherein, the storage area in the embedded PLC includes the D area, and the D area is also mapped with the Dm area data of the development host. The Dm area includes a read data mapping area RBm and a write data mapping area WBm, the D area includes a read data mapping area RBm and a write data mapping area WBm, RBm is mapped to RB data, and WBm is mapped to WB data.

其中,所述WBm与WB实现数据映射的方式包括:开发主机在更新WBm数据时,向嵌入式PLC发送新数据以更新WB的数据。Wherein, the manner of implementing data mapping between WBm and WB includes: when updating WBm data, the development host sends new data to the embedded PLC to update WB data.

WBm中更新的数据通过以太网发送给所述WB的过程具体包括:所述开发主机根据以太网传输协议将WBm中更新的数据封装打包,将封装打包好的数据通过以太网传输至所述嵌入式PLC,嵌入式PLC从封装打包好的数据中获取WBm中更新的数据存入所述WB中。WB中存入的数据通过嵌入式PLC的通信端口发送给接入设备。在调试过程中,所述WBm中更新的数据和WB中存入的数据就是所述调试协议帧。The process of sending the updated data in WBm to the WB via Ethernet specifically includes: the development host encapsulates and packages the updated data in WBm according to the Ethernet transmission protocol, and transmits the packaged and packaged data to the embedded computer via Ethernet. Type PLC, the embedded PLC obtains the updated data in WBm from the packaged data and stores them in the WB. The data stored in the WB is sent to the access device through the communication port of the embedded PLC. During the debugging process, the updated data in the WBm and the data stored in the WB are the debugging protocol frames.

S843,接收所述应答信息,并将所述应答信息发送至所述开发主机。S843. Receive the response information, and send the response information to the development host.

接入设备发送给嵌入式PLC的数据由通信端口写入所述RB中,RB更新的数据通过以太网写入所述RBm。在调试过程中,所述RBm更新的数据就是接入设备根据所述调试协议帧反馈的应答信息。本实施例通过所述RBm与所述RB数据映射实现所述S843。开发主机可以通过软件开发环境中的调试命令,控制调试协议帧的发送过程以及应答信息的接收过程,从而可以实现对通信协议模型的调试。The data sent by the access device to the embedded PLC is written into the RB through the communication port, and the updated data of the RB is written into the RBm through the Ethernet. During the debugging process, the data updated by the RBm is the response information fed back by the access device according to the debugging protocol frame. In this embodiment, the S843 is implemented by mapping the RBm and the RB data. The development host can control the sending process of the debugging protocol frame and the receiving process of the response information through the debugging command in the software development environment, so as to realize the debugging of the communication protocol model.

调试过程可以是在S830之后执行,也可以是在所述S841之后发现嵌入式PLC无法正常运行所述通信协议模型时执行,本发明不限于此。The debugging process may be executed after S830, or may be executed after S841 when it is found that the embedded PLC cannot run the communication protocol model normally, and the present invention is not limited thereto.

本实施例中嵌入式PLC通过接收所述开发主机发送的调试协议帧,并将所述调试协议帧发送至所述接入设备,其中,所述接入设备根据所述调试协议帧反馈应答信息;接收所述应答信息,并将所述应答信息发送至所述开发主机。实现了开发主机侧调试过程的调试协议帧发送、接收和处理,进而实现在开发主机对可识别调试源码的调试。In this embodiment, the embedded PLC receives the debugging protocol frame sent by the development host, and sends the debugging protocol frame to the access device, wherein the access device feeds back response information according to the debugging protocol frame ; Receive the response information, and send the response information to the development host. The debugging protocol frame sending, receiving and processing of the debugging process on the development host side is realized, and then the debugging of the identifiable debugging source code is realized on the development host.

图11为本发明提供的又一种嵌入式PLC的接入设备通信协议帧格式信息的远程确定方法流程图。在图8~图10任一所示实施例的基础上,图11所示的实施例在所述S810之前,还包括:Fig. 11 is a flow chart of another method for remotely determining the communication protocol frame format information of the access device of the embedded PLC provided by the present invention. On the basis of any of the embodiments shown in FIGS. 8 to 10 , the embodiment shown in FIG. 11 also includes before S810:

S800,接收所述开发主机发送的设置后的端口初始化模型,并根据所述设置后的端口初始化模型对端口初始化配置;S800. Receive the set port initialization model sent by the development host, and configure the port initialization according to the set port initialization model;

其中,所述设置后的端口配置模型为写入端口配置信息后的端口配置模型,所述端口配置信息包括端口读缓冲地址和端口写缓冲地址,所述端口读缓冲地址为所述嵌入式PLC预设读缓冲区的地址,所述端口写缓冲地址为所述嵌入式PLC预设写缓冲区的地址。Wherein, the port configuration model after the setting is a port configuration model after writing port configuration information, and the port configuration information includes a port read buffer address and a port write buffer address, and the port read buffer address is the embedded PLC The address of the preset read buffer, the port write buffer address is the address of the embedded PLC preset write buffer.

所述端口配置信息还包括通信速率、数据位、停止位等端口描述。所述嵌入式PLC由所述端口初始化模型进行通信端口的初始化配置。所述端口初始化模型具体为一用于配置通信端口的程序代码。The port configuration information also includes port descriptions such as communication rate, data bits, and stop bits. The embedded PLC uses the port initialization model to initialize the configuration of the communication port. The port initialization model is specifically a program code for configuring the communication port.

本实施例通过接收所述开发主机发送的端口初始化模型,并根据所述端口初始化程序对端口初始化配置,设置了所述嵌入式PLC的通信端口的读写地址,实现了对嵌入式PLC的通信端口初始化配置。In this embodiment, by receiving the port initialization model sent by the development host, and configuring the port initialization according to the port initialization program, the read-write address of the communication port of the embedded PLC is set, and the communication to the embedded PLC is realized. Port initialization configuration.

图12为本发明提供的一种嵌入式PLC的接入设备通信协议帧格式信息的远程确定装置。如图12所述的装置包括:Fig. 12 is a device for remotely determining the communication protocol frame format information of an embedded PLC access device provided by the present invention. The device as described in Figure 12 includes:

第一获取模块11,用于获取测试帧;The first obtaining module 11 is used to obtain the test frame;

第一发送模块12,用于向嵌入式PLC发送所述测试帧,其中,所述测试帧由所述嵌入式PLC发送给接入设备,所述接入设备根据所述测试帧反馈测试结果;The first sending module 12 is configured to send the test frame to the embedded PLC, wherein the test frame is sent to the access device by the embedded PLC, and the access device feeds back a test result according to the test frame;

第一接收模块13,用于在第一时间内,确定是否从所述嵌入式PLC获取到正确的所述测试结果,其中,所述第一时间的起始时刻为完成向所述嵌入式PLC发送所述测试帧的时刻;The first receiving module 13 is used to determine whether the correct test result is obtained from the embedded PLC within a first time, wherein the starting moment of the first time is to complete sending to the embedded PLC The moment when the test frame is sent;

第二获取模块14,用于若从所述嵌入式PLC获取到正确的测试结果,则根据所述测试帧确定正确的帧格式信息。The second obtaining module 14 is configured to determine correct frame format information according to the test frame if the correct test result is obtained from the embedded PLC.

图12所示实施例的装置对应地可用于执行图1所示方法实施例中开发主机执行的步骤,其实现原理和技术效果类似,此处不再赘述。The device in the embodiment shown in FIG. 12 can be correspondingly used to execute the steps performed by the development host in the method embodiment shown in FIG. 1 , and its implementation principles and technical effects are similar, and will not be repeated here.

图13为本发明提供的另一种嵌入式PLC的接入设备通信协议帧格式信息的远程确定装置。在图12所示实施例的基础上,如图13所示的实施例还包括:FIG. 13 is another device for remotely determining the communication protocol frame format information of an embedded PLC access device provided by the present invention. On the basis of the embodiment shown in Figure 12, the embodiment shown in Figure 13 also includes:

错误提示模块15,用于若从所述嵌入式PLC没有获取到正确的测试结果,则生成错误提示信息。The error prompting module 15 is used for generating error prompting information if the correct test result is not obtained from the embedded PLC.

图13所示实施例的装置对应地可用于执行图1或图3所示方法实施例中开发主机执行的步骤,其实现原理和技术效果类似,此处不再赘述。The device in the embodiment shown in FIG. 13 can be correspondingly used to execute the steps performed by the development host in the method embodiment shown in FIG. 1 or FIG. 3 , and its implementation principles and technical effects are similar, and will not be repeated here.

图14为本发明提供的另一种嵌入式PLC的接入设备通信协议帧格式信息的远程确定装置。在图12或图13所示实施例的基础上,如图14所示的实施例还包括:Fig. 14 is another device for remotely determining the communication protocol frame format information of an embedded PLC access device provided by the present invention. On the basis of the embodiment shown in Figure 12 or Figure 13, the embodiment shown in Figure 14 also includes:

第三获取模块16,用于在所述根据所述测试帧确定正确的帧格式信息之后,获得外部输入的通信协议模型,所述通信协议模型内嵌有N个第一类子模型,所述第一类子模型内嵌有图形标记和依据所述正确的帧格式信息编辑的协议帧,所述N为大于或等于1的整数。The third obtaining module 16 is used to obtain an externally input communication protocol model after the correct frame format information is determined according to the test frame, the communication protocol model is embedded with N first-type sub-models, the The first type of sub-model is embedded with a graphic mark and a protocol frame edited according to the correct frame format information, and the N is an integer greater than or equal to 1.

编译模块18,用于编译所述通信协议模型获取可执行代码。The compiling module 18 is configured to compile the communication protocol model to obtain executable codes.

所述第一发送模块12,还用于将所述可执行代码通过网络发送至所述嵌入式PLC。The first sending module 12 is further configured to send the executable code to the embedded PLC through the network.

图14所示实施例的装置对应地可用于执行图1或图3或图4所示方法实施例中开发主机执行的步骤,其实现原理和技术效果类似,此处不再赘述。The device in the embodiment shown in FIG. 14 can be correspondingly used to execute the steps performed by the development host in the method embodiment shown in FIG. 1 or FIG. 3 or FIG. 4 , and its implementation principles and technical effects are similar, and will not be repeated here.

图15为本发明提供的另一种嵌入式PLC的接入设备通信协议帧格式信息的远程确定装置。在图14所示实施例的基础上,如图15所示的实施例还包括:FIG. 15 is another device for remotely determining the communication protocol frame format information of an embedded PLC access device provided by the present invention. On the basis of the embodiment shown in Figure 14, the embodiment shown in Figure 15 also includes:

调试模块17,用于在所述获得外部输入的通信协议模型之后,根据所述通信协议模型获取可识别调试源码;对所述可识别调试源码进行调试获得调试协议帧。The debugging module 17 is configured to obtain an identifiable debugging source code according to the communication protocol model after the externally input communication protocol model is obtained; debug the identifiable debugging source code to obtain a debugging protocol frame.

所述第一发送模块12,还用于将所述调试协议帧发送至所述嵌入式PLC。The first sending module 12 is further configured to send the debugging protocol frame to the embedded PLC.

所述第一接收模块13,还用于接收并根据所述嵌入式PLC发送的应答信息获得调试结果。The first receiving module 13 is further configured to receive and obtain a debugging result according to the response information sent by the embedded PLC.

在上述实施例中,所述调试模块17进一步用于:从所述通信协议模型中获取所述N个第一类子模型;获取所述可识别调试源码,所述可识别调试源码为由预设的可识别变量代替所述图形标记的N个第一类子模型。In the above embodiment, the debugging module 17 is further configured to: obtain the N first-type sub-models from the communication protocol model; obtain the identifiable debugging source code, and the identifiable debugging source code is a predetermined Let the identifiable variables replace the N first-class submodels of the graphical markers.

所述调试模块17从所述通信协议模型中提取出所述第一类子模型;根据预设的对应关系,将所述第一类子模型中所述图形标记替换为可识别变量;获取图形标记已替换为可识别变量的第一类子模型为所述可识别调试源码。The debugging module 17 extracts the first type of sub-model from the communication protocol model; replaces the graphic mark in the first type of sub-model with an identifiable variable according to a preset correspondence; obtains a graphic The sub-models of the first type marked with identifiable variables are the identifiable debugging source codes.

在上述实施例中,所述第一获取模块11还用于:在所述向嵌入式PLC发送所述测试帧之前,获取端口配置信息,根据所述端口配置信息设置端口初始化模型得到设置后的端口初始化模型,其中,所述端口配置信息包括端口读缓冲地址和端口写缓冲地址,所述端口读缓冲地址为所述嵌入式PLC预设读缓冲区的地址,所述端口写缓冲地址为所述嵌入式PLC预设写缓冲区的地址;In the above embodiment, the first obtaining module 11 is also used for: before sending the test frame to the embedded PLC, obtain the port configuration information, set the port initialization model according to the port configuration information to obtain the set A port initialization model, wherein the port configuration information includes a port read buffer address and a port write buffer address, the port read buffer address is the address of the embedded PLC preset read buffer, and the port write buffer address is the Describe the address of the embedded PLC preset write buffer;

所述第一发送模块12还用于:向所述嵌入式PLC发送所述设置后的端口初始化模型。The first sending module 12 is further configured to: send the set port initialization model to the embedded PLC.

图15所示实施例的装置对应地可用于执行图1、图3、图4、图6或图7所示方法实施例中开发主机执行的步骤,其实现原理和技术效果类似,此处不再赘述。The device of the embodiment shown in FIG. 15 can be used to execute the steps performed by the development host in the method embodiment shown in FIG. 1, FIG. 3, FIG. 4, FIG. 6 or FIG. Let me repeat.

图16为本发明提供的一种嵌入式PLC的接入设备通信协议帧格式信息的远程确定装置。在如图16所示的实施例中,包括:Fig. 16 is a device for remotely determining the communication protocol frame format information of an embedded PLC access device provided by the present invention. In the embodiment shown in Figure 16, including:

第二接收模块21,用于接收开发主机发送的测试帧。The second receiving module 21 is configured to receive the test frame sent by the development host.

发送模块22,用于发送所述测试帧至所述接入设备,并将测试结果发送至所述开发主机,所述测试结果为所述接入设备根据所述测试帧反馈的结果。The sending module 22 is configured to send the test frame to the access device, and send a test result to the development host, where the test result is a result fed back by the access device according to the test frame.

第三接收模块23,用于接收所述接入设备发送的所述测试结果。The third receiving module 23 is configured to receive the test result sent by the access device.

图16所示实施例的装置对应地可用于执行图8所示方法实施例中嵌入式PLC执行的步骤,其实现原理和技术效果类似,此处不再赘述。The device in the embodiment shown in FIG. 16 can be correspondingly used to execute the steps performed by the embedded PLC in the method embodiment shown in FIG. 8 , and its implementation principle and technical effect are similar, and will not be repeated here.

图17为本发明提供的另一种嵌入式PLC的接入设备通信协议帧格式信息的远程确定装置。在图16所示实施例的基础上,如图17所示的实施例还包括程序加载模块24;FIG. 17 is another device for remotely determining the communication protocol frame format information of an embedded PLC access device provided by the present invention. On the basis of the embodiment shown in Figure 16, the embodiment shown in Figure 17 also includes a program loading module 24;

所述第二接收模块21,还用于在所述将所述测试结果发送至所述开发主机之后,所述开发主机发送的可执行代码,其中,所述可执行代码为开发主机对通信协议模型编译获得的代码,所述通信协议模型内嵌有N个第一类子模型,所述第一类子模型内嵌有图形标记和依据正确的帧格式信息编辑的协议帧,所述N为大于或等于1的整数;The second receiving module 21 is also used for the executable code sent by the development host after the test result is sent to the development host, wherein the executable code is the communication protocol between the development host and the development host. The code obtained by model compilation, the communication protocol model is embedded with N first-type sub-models, and the first-type sub-model is embedded with graphic marks and protocol frames edited according to correct frame format information, and the N is an integer greater than or equal to 1;

所述程序加载模块24,用于加载所述可执行代码。The program loading module 24 is configured to load the executable code.

在上述实施例中,所述第二接收模块21,还用于在所述将所述测试结果发送至所述开发主机之后,接收所述开发主机发送的调试协议帧;In the above embodiment, the second receiving module 21 is further configured to receive the debugging protocol frame sent by the development host after the test result is sent to the development host;

所述发送模块22,还用于将所述调试协议帧发送至所述接入设备,并将应答信息发送至所述开发主机,其中,所述接入设备根据所述调试协议帧反馈所述应答信息;The sending module 22 is further configured to send the debugging protocol frame to the access device, and send response information to the development host, wherein the access device feeds back the response message;

所述第三接收模块23,还用于接收所述应答信息。The third receiving module 23 is further configured to receive the response information.

在上述实施例中,所述第二接收模块21,还用于在所述接收开发主机发送的测试帧之前,接收所述开发主机发送的设置后的端口初始化模型;In the above embodiment, the second receiving module 21 is further configured to receive the set port initialization model sent by the development host before receiving the test frame sent by the development host;

所述程序加载模块24,还用于根据所述设置后的端口初始化模型对端口初始化配置;其中,所述设置后的端口配置模型为写入端口配置信息后的端口配置模型,所述端口配置信息包括端口读缓冲地址和端口写缓冲地址,所述端口读缓冲地址为所述嵌入式PLC预设读缓冲区的地址,所述端口写缓冲地址为所述嵌入式PLC预设写缓冲区的地址。The program loading module 24 is also configured to initialize and configure ports according to the set port initialization model; wherein, the set port configuration model is a port configuration model after writing port configuration information, and the port configuration The information includes a port read buffer address and a port write buffer address, the port read buffer address is the address of the embedded PLC preset read buffer, and the port write buffer address is the address of the embedded PLC preset write buffer address.

图17所示实施例的装置对应地可用于执行图8~图11任一所示方法实施例中嵌入式PLC执行的步骤,其实现原理和技术效果类似,此处不再赘述。The device in the embodiment shown in FIG. 17 can be correspondingly used to execute the steps performed by the embedded PLC in any one of the method embodiments shown in FIG. 8 to FIG. 11 .

最后应说明的是:以上各实施例仅用以说明本发明的技术方案,而非对其限制;尽管参照前述各实施例对本发明进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分或者全部技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本发明各实施例技术方案的范围。Finally, it should be noted that: the above embodiments are only used to illustrate the technical solutions of the present invention, rather than limiting them; although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: It is still possible to modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements for some or all of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the technical solutions of the various embodiments of the present invention. scope.

Claims (8)

1.一种嵌入式PLC的接入设备通信协议帧格式信息的远程确定方法,应用于开发主机,其特征在于,包括:1. a remote method for determining the access device communication protocol frame format information of an embedded PLC, applied to the development host, characterized in that, comprising: 获取测试帧;Get the test frame; 向嵌入式可编程控制器PLC发送所述测试帧,其中,所述测试帧由所述嵌入式PLC发送给接入设备,所述接入设备根据所述测试帧反馈测试结果;Send the test frame to the embedded programmable controller PLC, wherein the test frame is sent to the access device by the embedded PLC, and the access device feeds back the test result according to the test frame; 在第一时间内,确定是否从所述嵌入式PLC获取到正确的所述测试结果,其中,所述第一时间的起始时刻为完成向所述嵌入式PLC发送所述测试帧的时刻;In the first time, determine whether the correct test result is obtained from the embedded PLC, wherein the starting moment of the first time is the moment when the test frame is sent to the embedded PLC; 若从所述嵌入式PLC获取到正确的测试结果,则根据所述测试帧确定正确的帧格式信息;If the correct test result is obtained from the embedded PLC, then determine the correct frame format information according to the test frame; 其中,在所述根据所述测试帧确定正确的帧格式信息之后,还包括:Wherein, after the correct frame format information is determined according to the test frame, it also includes: 获得外部输入的通信协议模型,所述通信协议模型内嵌有N个第一类子模型,所述第一类子模型内嵌有图形标记和依据所述正确的帧格式信息编辑的协议帧,所述N为大于或等于1的整数;Obtaining an externally input communication protocol model, the communication protocol model is embedded with N first-type sub-models, and the first-type sub-model is embedded with graphic marks and protocol frames edited according to the correct frame format information, The N is an integer greater than or equal to 1; 编译所述通信协议模型获取可执行代码,并将所述可执行代码发送至所述嵌入式PLC。compiling the communication protocol model to obtain executable code, and sending the executable code to the embedded PLC. 2.根据权利要求1所述的方法,其特征在于,还包括:2. The method according to claim 1, further comprising: 若从所述嵌入式PLC没有获取到正确的测试结果,则生成错误提示信息,执行所述获取测试帧。If the correct test result is not obtained from the embedded PLC, an error prompt message is generated, and the acquisition of the test frame is executed. 3.根据权利要求1所述的方法,其特征在于,在所述获得外部输入的通信协议模型之后,还包括:3. The method according to claim 1, characterized in that, after said obtaining the externally input communication protocol model, further comprising: 根据所述通信协议模型获取可识别调试源码;Obtaining an identifiable debugging source code according to the communication protocol model; 对所述可识别调试源码进行调试获得调试协议帧,并将所述调试协议帧发送至所述嵌入式PLC;Debugging the identifiable debugging source code to obtain a debugging protocol frame, and sending the debugging protocol frame to the embedded PLC; 接收并根据所述嵌入式PLC发送的应答信息获得调试结果。receiving and obtaining the debugging result according to the response information sent by the embedded PLC. 4.根据权利要求3所述的方法,其特征在于,所述根据所述通信协议模型获取可识别调试源码,包括:4. The method according to claim 3, wherein said obtaining identifiable debugging source code according to said communication protocol model comprises: 从所述通信协议模型中获取所述N个第一类子模型;Obtain the N first type sub-models from the communication protocol model; 获取所述可识别调试源码,所述可识别调试源码为由预设的可识别变量代替所述图形标记的N个第一类子模型。The identifiable debugging source code is obtained, and the identifiable debugging source code is N submodels of the first type in which the graphic marks are replaced by preset identifiable variables. 5.根据权利要求1所述的方法,其特征在于,在所述向嵌入式PLC发送所述测试帧之前,还包括:5. method according to claim 1, is characterized in that, before described sending described test frame to embedded PLC, also comprises: 获取端口配置信息,根据所述端口配置信息设置端口初始化模型得到设置后的端口初始化模型,其中,所述端口配置信息包括端口读缓冲地址和端口写缓冲地址,所述端口读缓冲地址为所述嵌入式PLC预设读缓冲区的地址,所述端口写缓冲地址为所述嵌入式PLC预设写缓冲区的地址;Obtain port configuration information, set a port initialization model according to the port configuration information to obtain a set port initialization model, wherein the port configuration information includes a port read buffer address and a port write buffer address, and the port read buffer address is the The embedded PLC presets the address of the read buffer, and the port write buffer address is the address of the embedded PLC preset write buffer; 向所述嵌入式PLC发送所述设置后的端口初始化模型。sending the set port initialization model to the embedded PLC. 6.一种嵌入式PLC的接入设备通信协议帧格式信息的远程确定方法,应用于嵌入式可编程控制器PLC,其特征在于,包括:6. A remote method for determining the access device communication protocol frame format information of an embedded PLC, applied to an embedded programmable controller PLC, characterized in that, comprising: 接收开发主机发送的测试帧;Receive the test frame sent by the development host; 发送所述测试帧至所述接入设备;sending the test frame to the access device; 接收所述接入设备发送的测试结果,并将所述测试结果发送至所述开发主机,所述测试结果为所述接入设备根据所述测试帧反馈的结果;receiving a test result sent by the access device, and sending the test result to the development host, where the test result is a result fed back by the access device according to the test frame; 其中,在所述将所述测试结果发送至所述开发主机之后,还包括:Wherein, after the test result is sent to the development host, it also includes: 接收并加载所述开发主机发送的可执行代码,其中,所述可执行代码为开发主机对通信协议模型编译获得的代码,所述通信协议模型内嵌有N个第一类子模型,所述第一类子模型内嵌有图形标记和依据正确的帧格式信息编辑的协议帧,所述N为大于或等于1的整数。receiving and loading the executable code sent by the development host, wherein the executable code is the code obtained by compiling the communication protocol model by the development host, and the communication protocol model is embedded with N submodels of the first type, the The first type of sub-model is embedded with graphic marks and protocol frames edited according to correct frame format information, and N is an integer greater than or equal to 1. 7.根据权利要求6所述的方法,其特征在于,在所述将所述测试结果发送至所述开发主机之后,还包括:7. The method according to claim 6, further comprising: after sending the test result to the development host: 接收所述开发主机发送的调试协议帧,并将所述调试协议帧发送至所述接入设备,其中,所述接入设备根据所述调试协议帧反馈应答信息;receiving the debugging protocol frame sent by the development host, and sending the debugging protocol frame to the access device, wherein the access device feeds back response information according to the debugging protocol frame; 接收所述应答信息,并将所述应答信息发送至所述开发主机。receiving the response information, and sending the response information to the development host. 8.根据权利要求6所述的方法,其特征在于,在所述接收开发主机发送的测试帧之前,还包括:8. The method according to claim 6, further comprising: before receiving the test frame sent by the development host: 接收所述开发主机发送的设置后的端口初始化模型,并根据所述设置后的端口初始化模型对端口初始化配置;receiving the set port initialization model sent by the development host, and configuring the port initialization according to the set port initialization model; 其中,所述设置后的端口初始化模型为写入端口配置信息后的端口初始化模型,所述端口配置信息包括端口读缓冲地址和端口写缓冲地址,所述端口读缓冲地址为所述嵌入式PLC预设读缓冲区的地址,所述端口写缓冲地址为所述嵌入式PLC预设写缓冲区的地址。Wherein, the port initialization model after the setting is a port initialization model after writing port configuration information, and the port configuration information includes a port read buffer address and a port write buffer address, and the port read buffer address is the embedded PLC The address of the preset read buffer, the port write buffer address is the address of the embedded PLC preset write buffer.
CN201710639474.4A 2017-07-31 2017-07-31 Remote determination method of communication protocol frame format information of embedded PLC access equipment Active CN107479531B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710639474.4A CN107479531B (en) 2017-07-31 2017-07-31 Remote determination method of communication protocol frame format information of embedded PLC access equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710639474.4A CN107479531B (en) 2017-07-31 2017-07-31 Remote determination method of communication protocol frame format information of embedded PLC access equipment

Publications (2)

Publication Number Publication Date
CN107479531A CN107479531A (en) 2017-12-15
CN107479531B true CN107479531B (en) 2019-08-20

Family

ID=60598539

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710639474.4A Active CN107479531B (en) 2017-07-31 2017-07-31 Remote determination method of communication protocol frame format information of embedded PLC access equipment

Country Status (1)

Country Link
CN (1) CN107479531B (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108737389B (en) * 2018-05-02 2021-12-10 杭州句力科技有限公司 Method and device for modifying communication protocol of elevator outbound display panel
CN110205479A (en) * 2019-06-13 2019-09-06 浦项(张家港)不锈钢股份有限公司 A kind of stainless steel annealing pickling line PLC network communication diagnosis and processing method
EP4031946A1 (en) * 2019-09-20 2022-07-27 Nordson Corporation Flexible map with application data identifiers for plc communications
CN111756858B (en) * 2020-07-03 2023-05-26 潍柴动力股份有限公司 Remote development processing system, method and device for embedded equipment
CN112565026B (en) * 2021-02-20 2021-06-04 支付宝(杭州)信息技术有限公司 Test frame generation method, device and equipment

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101404596A (en) * 2008-11-17 2009-04-08 福建星网锐捷网络有限公司 Multi-topological environmental test method, system and equipment
CN101542863A (en) * 2006-09-01 2009-09-23 功率监视器公司 Method and apparatus for a power line communications test system
CN105763392A (en) * 2016-02-19 2016-07-13 中国人民解放军理工大学 Industrial control protocol fuzzing test method based on protocol state
CN205490608U (en) * 2016-03-01 2016-08-17 上海铁路通信有限公司 Automatic test equipment of railway signal controlgear
CN106680578A (en) * 2017-02-22 2017-05-17 中国电子信息产业集团有限公司第六研究所 High-precision PLC analog quantity output module tool testing method and system

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101542863A (en) * 2006-09-01 2009-09-23 功率监视器公司 Method and apparatus for a power line communications test system
CN101404596A (en) * 2008-11-17 2009-04-08 福建星网锐捷网络有限公司 Multi-topological environmental test method, system and equipment
CN105763392A (en) * 2016-02-19 2016-07-13 中国人民解放军理工大学 Industrial control protocol fuzzing test method based on protocol state
CN205490608U (en) * 2016-03-01 2016-08-17 上海铁路通信有限公司 Automatic test equipment of railway signal controlgear
CN106680578A (en) * 2017-02-22 2017-05-17 中国电子信息产业集团有限公司第六研究所 High-precision PLC analog quantity output module tool testing method and system

Also Published As

Publication number Publication date
CN107479531A (en) 2017-12-15

Similar Documents

Publication Publication Date Title
CN107479531B (en) Remote determination method of communication protocol frame format information of embedded PLC access equipment
CN109597374B (en) I/O virtualization for debugging
JP6901206B2 (en) Linking devices in a process plant using I/O abstraction field device configurations - Patents.com
CN107710149B (en) Method and system for generating PLC code using connectivity model
JP5942446B2 (en) Support device and support program
US10534354B2 (en) Device maintenance apparatus, device maintenance system, device maintenance method, device maintenance program, and storage medium
CN108009081B (en) Engineering design tool cooperation device and engineering design tool cooperation method
JP2001202324A (en) Process control configuration system to be used together with profibus device network
JP2001202323A (en) Process control configuration system for use with AS interface device network
US20090132060A1 (en) Foundation fieldbus simulation system
US20080077370A1 (en) System and method for integrating a process control system into a training simulator
JP2002268707A (en) Controller and tool, and system constituted of the same
JP2013546056A (en) Field device with self-description
US7356773B1 (en) Wizard builder, for application software, building a setup wizard which sets up a defacto interface between the application program and monitoring or control equipment
CN105467857A (en) Method for power station simulation
CN109696832B (en) Method for supporting an installation process of an automated system
US20210072720A1 (en) Method For Facilitating Control System Testing And Simulation
CN113010188B (en) Modular measurement and control system generation method and device, computer equipment and memory
WO2014204635A1 (en) Cyber-physical systems programmable logic controller
US8050784B2 (en) Integrated programmer reference for industrial control device data
CN105938337A (en) Microcomputer controller secondary development cloud platform and usage method and configuration update method
WO2013005350A1 (en) Symbol table generation method, method for communication with peripheral apparatus and programmable logic controller
CN108614704B (en) Code compiling method and device
US11269658B2 (en) Method for parameterizing a field device
JP5079166B1 (en) Symbol table generation method, communication method with peripheral device, and programmable logic controller

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
EE01 Entry into force of recordation of patent licensing contract

Application publication date: 20171215

Assignee: TEDERIC Machinery Co.,Ltd.

Assignor: Hangzhou Electronic Science and Technology Univ

Contract record no.: X2019330000055

Denomination of invention: Method for remotely determining frame format information of access device communication protocol of embedded PLC

Granted publication date: 20190820

License type: Common License

Record date: 20191226

EE01 Entry into force of recordation of patent licensing contract