# A ctypes wrapper around libfprint, a C lib for fingerprint scanners. import ctypes lib = ctypes.cdll.LoadLibrary("libfprint.so") # # Enums... # # enum fp_driver_type ( DRIVER_PRIMITIVE, DRIVER_IMAGING, ) = map(ctypes.c_int, xrange(0, 2)) # enum fp_scan_type ( FP_SCAN_TYPE_PRESS, # press FP_SCAN_TYPE_SWIPE, # swipe ) = map(ctypes.c_int, xrange(0, 2)) class usb_id(ctypes.Structure): _fields_ = [ ('vendor', ctypes.c_uint16), ('product', ctypes.c_uint16), ('driver_data', ctypes.c_ulong), ] # # 'Hidden' types, i.e. types that should not be accessed internally by apps # (defined in fprint_internal.h) # fp_dscv_dev = None fp_dscv_print = None fp_dev = None class fp_driver(ctypes.Structure): _fields_ = [ ('id', ctypes.c_uint16), ('name', ctypes.c_char_p), ('full_name', ctypes.c_char_p), ('id_table', usb_id), ('type', ctypes.c_int), # fp_driver_type ('scan_type', ctypes.c_int), # fp_scan_type ('priv', ctypes.c_void_p), # Device operations ('discover', ctypes.CFUNCTYPE( c_int, # Returntype? POINTER(libusb_device_descriptor), ctypes.c_uint32_p), # int (*discover)(struct libusb_device_descriptor *dsc, uint32_t *devtype); # int (*open)(struct fp_dev *dev, unsigned long driver_data); # void (*close)(struct fp_dev *dev); # int (*enroll_start)(struct fp_dev *dev); # int (*enroll_stop)(struct fp_dev *dev); # int (*verify_start)(struct fp_dev *dev); # int (*verify_stop)(struct fp_dev *dev, gboolean iterating); # int (*identify_start)(struct fp_dev *dev); # int (*identify_stop)(struct fp_dev *dev, gboolean iterating); }; ] fp_print_data = None fp_img = None # enum fp_finger Some enum... ( LEFT_THUMB, # thumb (left hand) LEFT_INDEX, # index finger (left hand) LEFT_MIDDLE, # middle finger (left hand) LEFT_RING, # ring finger (left hand) LEFT_LITTLE, # little finger (left hand) RIGHT_THUMB, # thumb (right hand) RIGHT_INDEX, # index finger (right hand) RIGHT_MIDDLE, # middle finger (right hand) RIGHT_RING, # ring finger (right hand) RIGHT_LITTLE, # little finger (right hand) ) = map(ctypes.c_int, xrange(1, 11)) # Drivers lib.fp_driver_get_name.restype = ctypes.POINTER(ctypes.c_char) lib.fp_driver_get_name.argtypes = [ctypes.POINTER(fp_driver)] driver_get_name = lib.fp_driver_get_name discover_devs = lib.fp_discover_devs if __name__ == '__main__': print discover_devs() import pdb; pdb.set_trace()