本文介绍了使用C#在Beckhoff PLC上检测代码更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Beckhoff PLC,该PLC运行的是使用TwinCat3开发的软件.有没有办法使用C#应用程序检索正在运行的软件? TwinCAT.Ads库似乎没有提供这种功能.

I have a Beckhoff PLC that's running a software developed with TwinCat3. Is there a way to retrieve the running software using C# application ? The TwinCAT.Ads library does not seem to offer such functionality.

该计划是为了能够将在线资源与本地存储的备份进行比较,以检测服务技术人员进行的任何计划外代码更改.

The plan is to be able to compare what is online with a backup stored locally to detect any unplanned code changes made by Service Technician.

例如,我可以从PLC检索哈希码并从本地备份生成哈希值,看看它们是否匹配.

It would be enough for me if I could for example retrieve a hash code from the PLC and generate hash from a local backup and see if they match.

也许有更好的方法来检测这种变化吗?

Is there perhaps a better way to detect such changes ?

我是Beckhoff PLC/TwinCat3的新手,因此非常感谢您提供有关此问题的所有信息.

I am new to Beckhoff PLC / TwinCat3 so all information regarding this matter is much appreciated.

我应该补充一点,C#应用程序将使检查计划外的代码更改的过程自动化,并且仅对其进行标记,以便工程师可以批准或拒绝更改.

I should add that the C# application will automate the process of checking for unplanned code changes and only flag it so that an engineer can approve or reject the changes.

推荐答案

TwinCAT 3包含数据类型PlcAppSystemInfo,其中包含有关PLC项目以及系统的某些信息.请参阅此链接.可以从全局变量_AppInfo

TwinCAT 3 contains a data type of PlcAppSystemInfo, which contains some information of the PLC project as well as the system. See this link. The data can be found from a global variable _AppInfo

AppTimestamp是上次更改应用程序软件时的DT(DATE_AND_TIME).从Beckhoff文档中,我会感觉到它会在每次重新启动后重置(" PLC应用程序启动时的时间"),但是当我测试时,它在重新启动和关闭电源时保持不变.当我更新PLC应用程序时,日期随着在线更改和下载而更改.

The AppTimestamp is DT (DATE_AND_TIME) of the time when application software was last changed. From Beckhoff documentation I would get a feeling that it would reset after each reboot ("Time at the start of the PLC application") but when I tested it kept the same when rebooting and powering off. When I updated the PLC application, the date changed with both online change and download.

据我所知,您可以读取应用程序上次更新的日期和时间,并比较应用程序是否更改.您没有说是否已经知道如何使用C#读取变量,我想您知道如何使用 ReadAny ,因此只需读取值fom变量_AppInfo.AppTimeStamp.

So, as far as I know, you can read the date and time when the application was last updated and compare if it changes. You didn't say if you already know how to use c# to read variables, I suppose you know how to use ReadAny so just read the value fom variable _AppInfo.AppTimeStamp.

这篇关于使用C#在Beckhoff PLC上检测代码更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-29 01:56