""" Arguments gpio2php.py 6;2;3 "/var/www/kana" "buttons" 9061 """ buttons = sys.argv[1].split(";") global path path = sys.argv[2] dataname = sys.argv[3] socket_port = sys.argv[4] Socket.Start(socket_port) print "Socket Started" for button in buttons: Gpio.pull_up(button) print buttons try: while True: data = False for button in buttons: result = Gpio.read(button) if(result)=="0": data = button if data: if data == last_data: lock = Lock.check(timeout,time_end) time_end = lock[0] lock = lock[1]
sys.stdout.write("Configuration: " + configurationFile + "\n") else: sys.stdout.write("Configuration: " + configurationFile + " failed to load\n") sys.exit(1) sys.stdout.write("Collector: gpio\n") sys.stdout.write("--------------------------\n") sys.stdout.write("waiting for IO...\n") sys.stdout.write("To exit press [Ctrl-C]\n") ButtonsThread = threading.Thread(target=Gpio.Buttons, args=(triggers,)) ButtonsThread.daemon = True ButtonsThread.start() try: while True: buttonPressed = Gpio.getState() action = TriggersINI.checkTrigger(triggers, buttonPressed) # print action if action is not False: sys.stdout.write("GPIO: "+buttonPressed+"\n") sys.stdout.write("\n") sys.stdout.write("COMMAND: "+action+"\n") sys.stdout.write("-------------\n") Commands.send(action) buttonPressed = False time.sleep(0.020) except KeyboardInterrupt: sys.stdout.write("-----------------------\n") sys.stdout.write("GPIO Triggers OFF\n") if raspberrypi: