@@ -174,10 +174,10 @@ def create_model(self):
174
174
self ._send_packet ([_REGMODEL ])
175
175
return self ._get_packet (12 )[0 ]
176
176
177
- def store_model (self , location , charbuf = 1 ):
177
+ def store_model (self , location , slot = 1 ):
178
178
"""Requests the sensor store the model into flash memory and assign
179
179
a location. Returns the packet error code or OK success"""
180
- self ._send_packet ([_STORE , charbuf , location >> 8 , location & 0xFF ])
180
+ self ._send_packet ([_STORE , slot , location >> 8 , location & 0xFF ])
181
181
return self ._get_packet (12 )[0 ]
182
182
183
183
def delete_model (self , location ):
@@ -186,22 +186,22 @@ def delete_model(self, location):
186
186
self ._send_packet ([_DELETE , location >> 8 , location & 0xFF , 0x00 , 0x01 ])
187
187
return self ._get_packet (12 )[0 ]
188
188
189
- def load_model (self , location , charbuf = 1 ):
189
+ def load_model (self , location , slot = 1 ):
190
190
"""Requests the sensor to load a model from the given memory location
191
- to the given charbuf . Returns the packet error code or success"""
192
- self ._send_packet ([_LOAD , charbuf , location >> 8 , location & 0xFF ])
191
+ to the given slot . Returns the packet error code or success"""
192
+ self ._send_packet ([_LOAD , slot , location >> 8 , location & 0xFF ])
193
193
return self ._get_packet (12 )[0 ]
194
194
195
- def get_fpdata (self , buffer = 'char' , charbuf = 1 ):
195
+ def get_fpdata (self , buffer = 'char' , slot = 1 ):
196
196
"""Requests the sensor to transfer the fingerprint image or
197
197
template. Returns the data payload only."""
198
- if charbuf != 1 or charbuf != 2 :
198
+ if slot != 1 or slot != 2 :
199
199
# raise error or use default value?
200
- charbuf = 1
200
+ slot = 2
201
201
if buffer == 'image' :
202
202
self ._send_packet ([_UPLOADIMAGE ])
203
203
elif buffer == 'char' :
204
- self ._send_packet ([_UPLOAD , charbuf ])
204
+ self ._send_packet ([_UPLOAD , slot ])
205
205
else :
206
206
raise RuntimeError ('Uknown buffer type' )
207
207
if self ._get_packet (12 )[0 ] == 0 :
@@ -210,16 +210,16 @@ def get_fpdata(self, buffer='char', charbuf=1):
210
210
#print(res)
211
211
return res
212
212
213
- def send_fpdata (self , data , buffer = 'char' , charbuf = 1 ):
213
+ def send_fpdata (self , data , buffer = 'char' , slot = 1 ):
214
214
"""Requests the sensor to receive data, either a fingerprint image or
215
215
a character/template data. Data is the payload only."""
216
- if charbuf != 1 or charbuf != 2 :
216
+ if slot != 1 or slot != 2 :
217
217
# raise error or use default value?
218
- charbuf = 2
218
+ slot = 2
219
219
if buffer == 'image' :
220
220
self ._send_packet ([_DOWNLOADIMAGE ])
221
221
elif buffer == 'char' :
222
- self ._send_packet ([_DOWNLOAD , charbuf ])
222
+ self ._send_packet ([_DOWNLOAD , slot ])
223
223
else :
224
224
raise RuntimeError ('Uknown buffer type' )
225
225
if self ._get_packet (12 )[0 ] == 0 :
@@ -240,7 +240,7 @@ def read_templates(self):
240
240
self .templates = []
241
241
self .read_sysparam ()
242
242
temp_r = [0x0c , ]
243
- for j in range (int (self .library_size / 250 )):
243
+ for j in range (int (self .library_size / 256 )):
244
244
self ._send_packet ([_TEMPLATEREAD , j ])
245
245
r = self ._get_packet (44 )
246
246
if r [0 ] == OK :
@@ -261,7 +261,12 @@ def finger_fast_search(self):
261
261
# high speed search of slot #1 starting at page 0x0000 and page #0x00A3
262
262
#self._send_packet([_HISPEEDSEARCH, 0x01, 0x00, 0x00, 0x00, 0xA3])
263
263
# or page #0x03E9 to accommodate modules with up to 1000 capacity
264
- self ._send_packet ([_HISPEEDSEARCH , 0x01 , 0x00 , 0x00 , 0x03 , 0xE9 ])
264
+ #self._send_packet([_HISPEEDSEARCH, 0x01, 0x00, 0x00, 0x03, 0xE9])
265
+ # or base the page on module's capacity
266
+ self .read_sysparam ()
267
+ capacity = self .library_size
268
+ self ._send_packet ([_HISPEEDSEARCH , 0x01 , 0x00 , 0x00 , capacity >> 8 ,
269
+ capacity & 0xFF ])
265
270
r = self ._get_packet (16 )
266
271
self .finger_id , self .confidence = struct .unpack ('>HH' , bytes (r [1 :5 ]))
267
272
return r [0 ]
0 commit comments