sensorRefreshSecs = 90 oldRaw = "" lastRead = 0 tempUnits = "Celsius" loopCount = 0 sensorList = "" sensors = {} enableTXpinsAsGpio = "0" enableSPIpinsAsGpio = "0" authentication = "digest" quick = False output = {} readParams() if U.getIPNumber() > 0: U.toLog(-1, " getsensors no ip number exiting ", doPrint=True) time.sleep(10) exit() myPID = str(os.getpid()) U.killOldPgm(myPID, G.program + ".py") # kill old instances of myself if they are still running NSleep = int(sensorRefreshSecs) if G.networkType in G.useNetwork and U.getNetwork() == 1: if U.getIPNumber() > 0: print datetime.datetime.now().strftime( "%Y%m%d-%H:%M:%S" ) + " " + G.program + " no ip number working, giving up" time.sleep(10)
readParams() if U.getNetwork < 1: U.toLog(-1, u" network not active, sleeping ") time.sleep(500)# == 500 secs exit(0) # if not connected to network pass if G.wifiType !="normal": U.toLog(-1, u" no need to receiving commands in adhoc mode pausing receive GPIO commands") time.sleep(500) exit(0) U.toLog(-1, u" proceding with normal on no ad-hoc network") U.getIPNumber() getcurentCMDS() print datetime.datetime.now().strftime("%Y%m%d-%H:%M:%S")+" receive GPIO commands started, listing to port: "+ str(PORT) restartMaster = False try: # Create the server, binding on port 9999 server = SocketServer.TCPServer((G.ipAddress, PORT), MyTCPHandler) except Exception, e: #### trying to kill the process thats blocking the port# U.toLog(-1, u"in Line '%s' has error='%s'" % (sys.exc_traceback.tb_lineno, e)) U.toLog(-1, "getting socket does not work, trying to reset "+ str(PORT),doPrint=True ) ret = subprocess.Popen("sudo ss -apn | grep :"+str(PORT),shell=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE).communicate()[0]
resetPin = -1 badSelfTest = 0 lastWriteCalibration = 0 CALlast = 0 G.debug = 5 loopCount = 0 NSleep = 100 sensors = {} sensor = G.program quick = False BNO055sensor ={} myPID = str(os.getpid()) U.killOldPgm(myPID,G.program+".py")# kill old instances of myself if they are still running if U.getIPNumber() > 0: time.sleep(10) exit() readParams() time.sleep(1) lastRead = time.time() U.echoLastAlive(G.program) lastValueDefault = {"EULER":{"heading":0,"roll":0,"pitch":0},"MAG":{"x":0,"y":0,"z":0},"GRAV":{"x":0,"y":0,"z":0},"ACC":{"x":0,"y":0,"z":0},"LIN":{"x":0,"y":0,"z":0}} lastRead = time.time()
if U.getNetwork < 1: U.toLog(-1, u" network not active, sleeping ") time.sleep(500) # == 500 secs exit(0) # if not connected to network pass if G.wifiType != "normal": U.toLog( -1, u" no need to receiving commands in adhoc mode pausing receive GPIO commands" ) time.sleep(500) exit(0) U.toLog(-1, u" proceding with normal on no ad-hoc network") U.getIPNumber() getcurentCMDS() print datetime.datetime.now().strftime( "%Y%m%d-%H:%M:%S" ) + " receive GPIO commands started, listing to port: " + str(PORT) restartMaster = False try: # Create the server, binding on port 9999 server = SocketServer.TCPServer((G.ipAddress, PORT), MyTCPHandler) except Exception, e: #### trying to kill the process thats blocking the port# U.toLog( -1,