summaryrefslogtreecommitdiff
path: root/nfc_bulk.py
blob: ad6f8965f5f97c47292da0218d7c575c2dc97ae2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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()