s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) print "Temp sensor is connecting ... \n" s.connect((TCP_IP, TCP_PORT)) except socket.error, (value, message): if s: s.close print "Could not Open socket" + message sys.exit(0) while True: try: sleep(2) try: temp,state= readtempnow() if state: Led_con(temp) print (str(temp)) s.sendall(str(temp)) else: s.sendall('Error Occured \n') s.close cleanup() break #need to add ability to find a way to send the info # to the user even if this socket error (using Email) except socket.error, e: print "Error %s" % e cleanup() sys.exit(0)
import wiringpi2 as wiringpi from time import sleep from xmlpar import xmlpar from readtempnow import readtempnow id,name,pmax,pmin,dmax,dmin= xmlpar() exvalue= "Expected Result: only the Gread Led is flashing" print "\n setup will be called "+exvalue+"\n" setup() #test the temp sensor only exvalue= "Expected Result: Temp within the room temp and (test ) not above dmax ; not below dmin" print "\n readtempnow() will be called "+exvalue+"\n" temp=readtempnow() if(temp> dmin and temp <dmax): print "\n it is within the plimits and the reading is "+str(temp)+"\n" else: print "\n it is not within the plimits and the reading is "+str(temp)+"\n" sleep(3) #test the green only exvalue="Expected Result: The green will be on for 3 sec" print "\n green() will be called "+exvalue+"\n" green(1) sleep(3) green(2) #test the red only exvalue="Expected Result: The redwill be on for 3 sec"