diff options
author | Vegard Storheil Eriksen <zyp@jvnv.net> | 2016-09-18 22:46:37 +0200 |
---|---|---|
committer | Vegard Storheil Eriksen <zyp@jvnv.net> | 2016-09-18 22:46:37 +0200 |
commit | ca4a152653036bd3d3ab99e5af7f029b1d726bab (patch) | |
tree | f6a050da33a105bb94e44ce85ad45d435aca0441 /nfc_bulk.py | |
parent | 7c379452d368bafbbe1fe3cea621295424ced1e1 (diff) |
Changed to plain bulk interface.
Diffstat (limited to 'nfc_bulk.py')
-rwxr-xr-x | nfc_bulk.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/nfc_bulk.py b/nfc_bulk.py new file mode 100755 index 0000000..ad6f896 --- /dev/null +++ b/nfc_bulk.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python + +import usb1, libusb1 +import time, struct + +ctx = usb1.LibUSBContext() + +dev = ctx.getByVendorIDAndProductID(0x1d50, 0x60f8) + +if not dev: + print 'Device not found.' + exit(1) + +handle = dev.open() +handle.claimInterface(1) + +def transfer_cb(t): + data = t.getBuffer()[:t.getActualLength()] + + print time.strftime('%H:%M:%S'), + print 'Card detected. UID: %s' % ':'.join('%02x' % ord(c) for c in data) + + return True + +th = usb1.USBTransferHelper() +th.setEventCallback(libusb1.LIBUSB_TRANSFER_COMPLETED, transfer_cb) + +t = handle.getTransfer() +t.setBulk(0x81, 64, th) +t.submit() + +while 1: + ctx.handleEvents() |