34
34
**Hardware:**
35
35
36
36
* `Fingerprint sensor <https://www.adafruit.com/product/751>`_ (Product ID: 751)
37
+ * `Panel Mount Fingerprint sensor <https://www.adafruit.com/product/4651>`_ (Product ID: 4651)
37
38
38
39
**Software and Dependencies:**
39
40
59
60
60
61
_GETIMAGE = const (0x01 )
61
62
_IMAGE2TZ = const (0x02 )
63
+ _FINGERPRINTSEARCH = const (0x04 )
62
64
_REGMODEL = const (0x05 )
63
65
_STORE = const (0x06 )
64
66
_LOAD = const (0x07 )
100
102
PASSVERIFY = const (0x21 )
101
103
MODULEOK = const (0x55 )
102
104
103
-
105
+ # pylint: disable=too-many-instance-attributes
104
106
class Adafruit_Fingerprint :
105
107
"""UART based fingerprint sensor."""
106
108
@@ -117,6 +119,8 @@ class Adafruit_Fingerprint:
117
119
device_address = None
118
120
data_packet_size = None
119
121
baudrate = None
122
+ system_id = None
123
+ status_register = None
120
124
121
125
def __init__ (self , uart , passwd = (0 , 0 , 0 , 0 )):
122
126
# Create object with UART for interface, and default 32-bit password
@@ -152,6 +156,8 @@ def read_sysparam(self):
152
156
r = self ._get_packet (28 )
153
157
if r [0 ] != OK :
154
158
raise RuntimeError ("Command failed." )
159
+ self .status_register = struct .unpack (">H" , bytes (r [1 :3 ]))[0 ]
160
+ self .system_id = struct .unpack (">H" , bytes (r [3 :5 ]))[0 ]
155
161
self .library_size = struct .unpack (">H" , bytes (r [5 :7 ]))[0 ]
156
162
self .security_level = struct .unpack (">H" , bytes (r [7 :9 ]))[0 ]
157
163
self .device_address = bytes (r [9 :13 ])
@@ -281,6 +287,20 @@ def finger_fast_search(self):
281
287
# print(r)
282
288
return r [0 ]
283
289
290
+ def finger_search (self ):
291
+ """Asks the sensor to search for a matching fingerprint starting at
292
+ slot 1. Stores the location and confidence in self.finger_id
293
+ and self.confidence. Returns the packet error code or OK success"""
294
+ self .read_sysparam ()
295
+ capacity = self .library_size
296
+ self ._send_packet (
297
+ [_FINGERPRINTSEARCH , 0x01 , 0x00 , 0x00 , capacity >> 8 , capacity & 0xFF ]
298
+ )
299
+ r = self ._get_packet (16 )
300
+ self .finger_id , self .confidence = struct .unpack (">HH" , bytes (r [1 :5 ]))
301
+ # print(r)
302
+ return r [0 ]
303
+
284
304
##################################################
285
305
286
306
def _get_packet (self , expected ):
0 commit comments