Applies to:
PcVue |
||
|
||
Summary:
This article describes a way, from PcVue, to make a ping and to retrieve the result. When we talk about the ping function, we usually advise to use the SNMP protocol, but sometimes, the device does not support SNMP or the PcVue license does not have this protocol… So, one solution is to use a Scada Basic program where we execute a ping command, we send the result in a file and we recover it in a buffer to analyze it. |
||
|
||
Details:
The attached project, developped with PcVue 12, gives an example. The file where the ping result is sent, is located in TP folder of the project. In this sample, we enter the IP address into a text variable and we display the result into another text variable.
He are the two functions used:
Sub Make_Ping() @PINGS.ComOk=””; ‘We send the result of the cmd prompt to the TP folder, in the file Test.txt SYSTEM(“SYSTEM”,CMD); End sub Sub Analyze_Ping() ‘StaticSize, Corresponds to the length of: “Reply from : bytes=32” (words and size will change according to the language) Handle = ALLOC_BUFFER(1024); Handle = FILETOBUF(“Test.txt”); SEQ_BUFFER(“BEGIN”, Handle); Size=StaticSize + TEXTVAR(“TEXTLEN”, “@PINGS.IPAd”) ; ‘We add the length of the IP Address ‘Result, We retrieve the second line from the file ‘Reply, We expect seometing like Reply from xxx.xxx.xxx.xxx: octets=32 If(CMPSTRING(Result, Reply) == 0) Then Free_Buffer(Handle); End sub Sample project: MakePing.zip
|
||
|
||
|
Created on: 10 Aug 2022 Last update: 30 May 2024