It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming Python Forum

Bug in getting the expected result

Bug in getting the expected result

Postby Geeta on Thu Oct 05, 2006 12:28 pm

Hello All,
I have written a program which in while 1 loop will keep checking the pinging of some pc.If it is not pinging, it will simply try to restart it using VISION ICE command line commands.Here is this program :-

#Imports
import sys
import os
sys.path = sys.path + [os.getenv('BOOTLIB')]
# Import the Boot Library
import boot_library as Lib

TgtDownCount = (0)
TgtDownCountReset = (0)
expectedValue = (0)
MaxTgtDownValue = (3)
while 1:
#Check whether the target is up and running
x = os.system("ping 10.1.20.169")
#Check for validity "0" if connected
#print "X value is : " + x
if expectedValue == x:
print "Connected"
else:
# Do nothing
print "Not Connected"
print "Trying to re-connect"
TgtDownCount = TgtDownCount + 1
if MaxTgtDownValue > TgtDownCount:
TgtDownCount = TgtDownCountReset
# Reconnect the Target commands
Lib.ResetTarget()
Lib.RunTarget()
print "Re-connected"

This program is working fine.Problem Im facing is if the pc goes down in between, this code won't go to else part unless and until I press ctrl C.If I press ctrl C, it will enter the else part n re-connect...What I want is as soon as pc goes down, automatically it shall get re-connected through this script..
Please help me out at the earliest...
Thanks a lot.
Regards,
Geeta
Geeta
 
Posts: 0
Joined: Thu Oct 05, 2006 11:38 am

Who is online

Users browsing this forum: No registered users and 0 guests