source: main/pyfprint/trunk/src/fprint.py @ 11526

Last change on this file since 11526 was 11526, checked in by uli, 11 years ago

Add inital project files.

File size: 2.6 KB
Line 
1# A ctypes wrapper around libfprint, a C lib for fingerprint scanners.
2import ctypes
3
4lib = ctypes.cdll.LoadLibrary("libfprint.so")
5
6#
7# Enums...
8#
9
10# enum fp_driver_type
11(
12    DRIVER_PRIMITIVE,
13    DRIVER_IMAGING,
14) = map(ctypes.c_int, xrange(0, 2))
15
16# enum fp_scan_type
17(
18    FP_SCAN_TYPE_PRESS,  # press
19    FP_SCAN_TYPE_SWIPE,  # swipe
20) = map(ctypes.c_int, xrange(0, 2))
21
22
23class usb_id(ctypes.Structure):
24    _fields_ = [
25        ('vendor', ctypes.c_uint16),
26        ('product', ctypes.c_uint16),
27        ('driver_data', ctypes.c_ulong),
28        ]
29
30
31
32#
33# 'Hidden' types, i.e. types that should not be accessed internally by apps
34# (defined in fprint_internal.h)
35#
36fp_dscv_dev = None
37fp_dscv_print = None
38fp_dev = None
39class fp_driver(ctypes.Structure):
40    _fields_ = [
41        ('id', ctypes.c_uint16),
42        ('name', ctypes.c_char_p),
43        ('full_name', ctypes.c_char_p),
44        ('id_table', usb_id),
45        ('type', ctypes.c_int),       # fp_driver_type
46        ('scan_type', ctypes.c_int),  # fp_scan_type
47        ('priv', ctypes.c_void_p),
48        #  Device operations
49        ('discover', ctypes.CFUNCTYPE(
50            c_int,  # Returntype?
51            POINTER(libusb_device_descriptor), ctypes.c_uint32_p),
52        # int (*discover)(struct libusb_device_descriptor *dsc, uint32_t *devtype);
53        # int (*open)(struct fp_dev *dev, unsigned long driver_data);
54        # void (*close)(struct fp_dev *dev);
55        # int (*enroll_start)(struct fp_dev *dev);
56        # int (*enroll_stop)(struct fp_dev *dev);
57        # int (*verify_start)(struct fp_dev *dev);
58        # int (*verify_stop)(struct fp_dev *dev, gboolean iterating);
59        # int (*identify_start)(struct fp_dev *dev);
60        # int (*identify_stop)(struct fp_dev *dev, gboolean iterating);
61};
62     
63        ]
64fp_print_data = None
65fp_img = None
66
67# enum fp_finger   Some enum...
68(
69    LEFT_THUMB, # thumb (left hand)
70    LEFT_INDEX,  # index finger (left hand)
71    LEFT_MIDDLE,  # middle finger (left hand)
72    LEFT_RING,  # ring finger (left hand)
73    LEFT_LITTLE,  # little finger (left hand)
74    RIGHT_THUMB,  # thumb (right hand)
75    RIGHT_INDEX,  # index finger (right hand)
76    RIGHT_MIDDLE,  # middle finger (right hand)
77    RIGHT_RING,  # ring finger (right hand)
78    RIGHT_LITTLE,  # little finger (right hand)
79) = map(ctypes.c_int, xrange(1, 11))
80
81
82
83# Drivers
84
85lib.fp_driver_get_name.restype = ctypes.POINTER(ctypes.c_char)
86lib.fp_driver_get_name.argtypes = [ctypes.POINTER(fp_driver)]
87driver_get_name = lib.fp_driver_get_name
88
89
90discover_devs = lib.fp_discover_devs
91
92
93if __name__ == '__main__':
94    print discover_devs()
95    import pdb; pdb.set_trace()
Note: See TracBrowser for help on using the repository browser.