def commsListener(): # ================== _FUNCTIONS.logMessage('COMMS','Starting...') while True: try: s = socket.socket() s.bind(('', _GLOBALS.listenerPort)) s.listen(5) while True: c, addr = s.accept() message = c.recv(1024) _FUNCTIONS.logMessage('COMMS','<-'+str(addr[0])+'#'+message) response=commsProcessor(message) c.sendall(response) _FUNCTIONS.logMessage('COMMS','->'+str(addr[0])+'#'+response) c.close() except socket.error, msg: _FUNCTIONS.logMessage('ERROR','COMMS - '+str(msg)) except KeyboardInterrupt: _FUNCTIONS.logMessage('LOG','Exiting...'); s.close() sys.exit(0)
import _FUNCTIONS, _GLOBALS import RPi.GPIO as GPIO import time, os, sys _GLOBALS.init() while True: # read currentTemp, adjusting as necessary readTime=_FUNCTIONS.readLight() try: time.sleep(60-readTime) except (KeyboardInterrupt): print _FUNCTIONS.logMessage('LOG','Light - Exiting...') sys.exit(0)
_FUNCTIONS.logMessage('COMMS','<-'+str(addr[0])+'#'+message) response=commsProcessor(message) c.sendall(response) _FUNCTIONS.logMessage('COMMS','->'+str(addr[0])+'#'+response) c.close() except socket.error, msg: _FUNCTIONS.logMessage('ERROR','COMMS - '+str(msg)) except KeyboardInterrupt: _FUNCTIONS.logMessage('LOG','Exiting...'); s.close() sys.exit(0) except: _FUNCTIONS.logMessage('COMMS',str(sys.exc_info()[0])) _FUNCTIONS.logMessage('ERROR','COMMS - '+str(sys.exc_info()[0])) finally: pass try: c.close() except: pass try: s.close() except: pass time.sleep(60) _FUNCTIONS.logMessage('COMMS','RESTARTING...')
import _FUNCTIONS, _GLOBALS, _LCD, _COMMS import RPi.GPIO as GPIO import time, os, sys _GLOBALS.init() _LCD.init() _FUNCTIONS.initialiseGPIO() _FUNCTIONS.turnHeatingOff() count=0 while True: _FUNCTIONS.cycle("SLOW") try: time.sleep(9) except (KeyboardInterrupt): print _LCD.lcdDisplay('SHUTTING DOWN !','') _FUNCTIONS.logMessage('LOG','Exiting...') GPIO.cleanup() sys.exit(0)