DoubleM (Moti M.)
Haifa,

Jan 18, 2014
13 Posts

ping

How can I perform an ethernet communication check like ping from ateasy8?

DrATEasy (Ron Y.)
Mission Viejo,

Jan 20, 2014
235 Posts

Re: ping

Simplest way is to execute the command ping through the command prompt and read back the response, you can use the StdIoProcess driver.  An example project is located in the ATEasy examples directory by default and named StdIoProcess.prj.

DrATEasy (Ron Y.)
Mission Viejo,

Jan 20, 2014
235 Posts

Re: ping

Another way is to use Windows Management Instrumentation (WMI) COM Component:

Declare :
ob, obSWbemSet, obSWbemEx, obSWbemProperty : Object

Code:
ob=GetObject("winmgmts:\\\\.\\root\\cimv2")
! the following method returns object collection
obSWbemSet=ob.ExecQuery("Select * from WIN32_Pingstatus where address = '" + "www.MarvinTest.com" + "'")          
if obSWbemSet.Count>=1
                ! Retrieve first ping result of type obSWbemEx
                obSWbemEx=obSWbemSet.ItemIndex(0)
                obSWbemProperty=obSWbemEx.Properties_.Item("StatusCode")
                print obSWbemProperty.Name
                print obSWbemProperty.Value
                obSWbemProperty=obSWbemEx.Properties_.Item("Address")
                print obSWbemProperty.Name
                print obSWbemProperty.Value
                obSWbemProperty=obSWbemEx.Properties_.Item("ReplySize")
                print obSWbemProperty.Name
                print obSWbemProperty.Value
endif

DoubleM (Moti M.)
Haifa,

Jun 5, 2014
13 Posts

Re: ping

got Run-time error #422 : 'Late-bound object does not have member 'ItemIndex'' found in 'Examples.Procedure1' in line 6

DrATEasy (Ron Y.)
Mission Viejo,

Jun 10, 2014
235 Posts

Re: ping

I was not able to replicate this. Maybe WMI need a reset or re-register.

In any case, you can use the the following ATEasy code that is using .Net Ping class as shown here instead:

! include System.System.Net.NetworkInformation under System.dll assembly, System.Net.NetworkInformation namewspace obsolete
! define pinSender : Ping, pingReply : PingReply

pingSender=new Ping ()
pingReply=pingSender.Send("www.marvintest.com")
if pingReply.Status=IPStatus.Success
    print "Address:"; pingReply.Address.ToString()
    print "RoundTrip time:"; pingReply.RoundtripTime
    print "Time to live:"; pingReply.Options.Ttl
    print "Don't fragment:"; pingReply.Options.DontFragment
else
    print "Error: "; pingReply.Status
endif
pingReply=Nothing
pingSender=Nothing

DoubleM (Moti M.)
Haifa,

Jun 12, 2014
13 Posts

Re: ping

sorry for asking but how to include System.System.Net.NetworkInformation under System.dll assembly ?

DoubleM (Moti M.)
Haifa,

Jun 12, 2014
13 Posts

Re: ping

with few changes the code is working:

! include System.Net.NetworkInformation under System.dll assembly
! define pingSender : SystemLib.Ping, pingReply : SystemLib.PingReply

pingSender=new SystemLib.Ping()
pingReply=pingSender.Send("www.marvintest.com")
if pingReply.Status=IPStatus.Success
    print "Address:"; pingReply.Address.ToString()
    print "RoundTrip time:"; pingReply.RoundtripTime
    print "Time to live:"; pingReply.Options.Ttl
    print "Don't fragment:"; pingReply.Options.DontFragment
else
    print "Error: "; pingReply.Status
endif
pingReply=Nothing
pingSender=Nothing



Please Note
You need to have a M@GIC account to participate in the Forums.
Not yet registered on our website? Click here to register today!

All content, information and opinions presented on the Marvin Test Solutions User Forums are those of the authors of the posts and messages and not Marvin Test Solutions'. All attachments and files are downloaded at your own risk. [Read More]