Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import nfc
- #import mysql
- import os
- import sys
- #import tty
- #import termios
- #import logging
- import thread
- import time
- import RPi.GPIO as GPIO
- #import urllib2
- #def debug(message):
- # logging.debug(message)
- def read():
- # cardId=nfc.readNfc()
- # return cardId
- return nfc.readNfc()
- #def readNfc():
- # if(action==55):
- # cardId=read()
- # print(cardId)
- # time.sleep(1)
- def beep():
- #starting beeping in separate thread to not slow down whole application
- thr = thread.start_new_thread(beepAsync, ())
- def beepAsync():
- GPIO.output(13,True)
- time.sleep(0.5)
- GPIO.output(13,False)
- def initGpio():
- GPIO.setmode(GPIO.BOARD)
- # GPIO.setup(8, GPIO.OUT)
- GPIO.setup(13, GPIO.OUT)
- def main():
- # GPIO.cleanup()
- try:
- initGpio()
- while True:
- # os.system("sudo python /usr/lib/python2.7/webbrowser.py -t 'http://192.168.10.86/pi/userinfo.php?tagid=00001$
- cardId = read()
- beep()
- # print(cardId)
- time.sleep(1)
- #if not os.path.exits("/home/pi/Desktop/attendance2/"+cardId+".txt"):
- # os.system("sudo python /usr/lib/python2.7/webbrowser.py -t '192.168.xx.xx/pi/userinfo.php?tagid=0000101'")
- os.system("sudo touch /home/pi/Desktop/attendance2/temp/carduser/"+read()+".txt")
- os.system("sudo echo "+read()+" > /home/pi/Desktop/attendance2/temp/carduser/"+read()+".txt")
- print("hi")
- except KeyboardInterrupt:
- # GPIO.cleanup()
- pass
- # GPIO.cleanup()
- if __name__ == '__main__':
- print("----------========== Starting session! ==========----------")
- main()
Add Comment
Please, Sign In to add comment