#!/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()