Skip to content

Commit 4971ed2

Browse files
some fixes
1 parent 667b492 commit 4971ed2

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

adafruit_fingerprint.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ def get_image(self):
162162
self._send_packet([_GETIMAGE])
163163
return self._get_packet(12)[0]
164164

165-
def image_2_tz(self, slot):
165+
def image_2_tz(self, slot=1):
166166
"""Requests the sensor convert the image to a template, returns
167167
the packet error code or OK success"""
168168
self._send_packet([_IMAGE2TZ, slot])
@@ -174,7 +174,7 @@ def create_model(self):
174174
self._send_packet([_REGMODEL])
175175
return self._get_packet(12)[0]
176176

177-
def store_model(self, location, charbuf):
177+
def store_model(self, location, charbuf=1):
178178
"""Requests the sensor store the model into flash memory and assign
179179
a location. Returns the packet error code or OK success"""
180180
self._send_packet([_STORE, charbuf, location >> 8, location & 0xFF])
@@ -186,22 +186,23 @@ def delete_model(self, location):
186186
self._send_packet([_DELETE, location >> 8, location & 0xFF, 0x00, 0x01])
187187
return self._get_packet(12)[0]
188188

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"""
191192
"""
192193
self._send_packet([_LOAD, charbuf, location >> 8, location & 0xFF])
193194
return self._get_packet(12)[0]
194195
195-
def get_fpdata(self, buffer='char', slot=1):
196+
def get_fpdata(self, buffer='char', charbuf=1):
196197
"""Requests the sensor to transfer the fingerprint image or
197198
template. Returns the data payload only."""
198-
if slot != 1 or slot != 2:
199+
if charbuf != 1 or charbuf != 2:
199200
# raise error or use default value?
200-
slot = 1
201+
charbuf = 1
201202
if buffer == 'image':
202203
self._send_packet([_UPLOADIMAGE])
203204
elif buffer == 'char':
204-
self._send_packet([_UPLOAD, slot])
205+
self._send_packet([_UPLOAD, charbuf])
205206
else:
206207
raise RuntimeError('Uknown buffer type')
207208
if self._get_packet(12)[0] == 0:
@@ -210,20 +211,19 @@ def get_fpdata(self, buffer='char', slot=1):
210211
#print(res)
211212
return res
212213
213-
def send_fpdata(self, data, buffer='char', slot=1):
214+
def send_fpdata(self, data, buffer='char', charbuf=1):
214215
"""ONGOING"""
215-
print(slot)
216-
if slot != 1 or slot != 2:
216+
if charbuf != 1 or charbuf != 2:
217217
# raise error or use default value?
218-
slot = 2
218+
charbuf = 2
219219
if buffer == 'image':
220220
self._send_packet([_DOWNLOADIMAGE])
221221
elif buffer == 'char':
222-
self._send_packet([_DOWNLOAD, slot])
222+
self._send_packet([_DOWNLOAD, charbuf])
223223
else:
224224
raise RuntimeError('Uknown buffer type')
225225
if self._get_packet(12)[0] == 0:
226-
self._send_data(data)
226+
self._send_data(data)
227227
#print('datasize: ' + str(len(res)))
228228
#print(res)
229229
return True
@@ -364,7 +364,6 @@ def _send_packet(self, data):
364364
self._uart.write(bytearray(packet))
365365

366366
def _send_data(self, data):
367-
"""ONGOING"""
368367
print(len(data))
369368
self.read_sysparam()
370369
if self.data_packet_size == 0:
@@ -376,6 +375,7 @@ def _send_data(self, data):
376375
elif self.data_packet_size == 3:
377376
data_length = 256
378377

378+
i = 0
379379
for i in range(int(len(data) / (data_length - 2))):
380380
start = i * (data_length - 2)
381381
end = (i + 1) * (data_length - 2)

0 commit comments

Comments
 (0)