Created
November 16, 2010 16:20
-
-
Save swinton/702005 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| import serial, sys | |
| DEVICE='/dev/cu.usbserial-A7006gOH' | |
| IDS={ | |
| '28001D71E1': 'Ross', | |
| '0800D9D1AB': 'Steve', | |
| } | |
| def puts(msg): | |
| sys.stdout.write(msg + "\n") | |
| sys.stdout.flush() | |
| def rfid_reader(): | |
| puts("Opening " + DEVICE) | |
| ser=serial.Serial(DEVICE, 2400, timeout=1) | |
| try: | |
| while ser.isOpen(): | |
| data=ser.readline() | |
| id=IDS.get(data[:-1], False) | |
| if id: yield id | |
| except KeyboardInterrupt: | |
| ser.close() | |
| return | |
| if __name__ == "__main__": | |
| for id in rfid_reader(): | |
| puts("Hello, %s" % id) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment