@@ -162,7 +162,7 @@ def get_image(self):
162
162
self ._send_packet ([_GETIMAGE ])
163
163
return self ._get_packet (12 )[0 ]
164
164
165
- def image_2_tz (self , slot ):
165
+ def image_2_tz (self , slot = 1 ):
166
166
"""Requests the sensor convert the image to a template, returns
167
167
the packet error code or OK success"""
168
168
self ._send_packet ([_IMAGE2TZ , slot ])
@@ -174,7 +174,7 @@ 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 ):
177
+ def store_model (self , location , charbuf = 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
180
self ._send_packet ([_STORE , charbuf , location >> 8 , location & 0xFF ])
@@ -186,22 +186,23 @@ 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 ):
190
- """
189
+ def load_model (self , location , charbuf = 1 ):
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"""
191
192
"""
192
193
self._send_packet([_LOAD, charbuf, location >> 8, location & 0xFF])
193
194
return self._get_packet(12)[0]
194
195
195
- def get_fpdata (self , buffer = 'char' , slot = 1 ):
196
+ def get_fpdata(self, buffer='char', charbuf =1):
196
197
""" Requests the sensor to transfer the fingerprint image or
197
198
template . Returns the data payload only ."""
198
- if slot != 1 or slot != 2 :
199
+ if charbuf != 1 or charbuf != 2:
199
200
# raise error or use default value?
200
- slot = 1
201
+ charbuf = 1
201
202
if buffer == 'image':
202
203
self._send_packet([_UPLOADIMAGE])
203
204
elif buffer == 'char':
204
- self ._send_packet ([_UPLOAD , slot ])
205
+ self._send_packet([_UPLOAD, charbuf ])
205
206
else:
206
207
raise RuntimeError('Uknown buffer type')
207
208
if self._get_packet(12)[0] == 0:
@@ -210,20 +211,19 @@ def get_fpdata(self, buffer='char', slot=1):
210
211
#print(res)
211
212
return res
212
213
213
- def send_fpdata (self , data , buffer = 'char' , slot = 1 ):
214
+ def send_fpdata(self, data, buffer='char', charbuf =1):
214
215
""" ONGOING """
215
- print (slot )
216
- if slot != 1 or slot != 2 :
216
+ if charbuf != 1 or charbuf != 2:
217
217
# raise error or use default value?
218
- slot = 2
218
+ charbuf = 2
219
219
if buffer == 'image':
220
220
self._send_packet([_DOWNLOADIMAGE])
221
221
elif buffer == 'char':
222
- self ._send_packet ([_DOWNLOAD , slot ])
222
+ self._send_packet([_DOWNLOAD, charbuf ])
223
223
else:
224
224
raise RuntimeError('Uknown buffer type')
225
225
if self._get_packet(12)[0] == 0:
226
- self ._send_data (data )
226
+ self._send_data(data)
227
227
#print('datasize: ' + str(len(res)))
228
228
#print(res)
229
229
return True
@@ -364,7 +364,6 @@ def _send_packet(self, data):
364
364
self._uart.write(bytearray(packet))
365
365
366
366
def _send_data(self, data):
367
- """ONGOING"""
368
367
print(len(data))
369
368
self.read_sysparam()
370
369
if self.data_packet_size == 0:
@@ -376,6 +375,7 @@ def _send_data(self, data):
376
375
elif self.data_packet_size == 3:
377
376
data_length = 256
378
377
378
+ i = 0
379
379
for i in range(int(len(data) / (data_length - 2))):
380
380
start = i * (data_length - 2)
381
381
end = (i + 1) * (data_length - 2)
0 commit comments