Open jerryneedell opened 3 years ago
@jerryneedell I don't have this sensor. This might be related to #31. Can you please put a return
in set_led_local
to disabled it and try again with Debug enabled when you get a chance?
@admiralmaggie The issue was not due to the LED, it was catching that but I did dummy it out with a return,-- here is the result with _debug=True
pi@gjnpi4desk:~/projects/fingerprint $ python3 fingerprint_test.py
----------------
*** DEBUG ==> _send_packet length: 12
*** DEBUG ==> _send_packet data: ['ef', '01', 'ff', 'ff', 'ff', 'ff', '01', '00', '03', '0f', '00', '13']
*** DEBUG ==> _get_packet received data: ['ef', '01', 'ff', 'ff', 'ff', 'ff', '07', '00', '13', '00', '00', '00', '00', '00', '00', '50', '00', '03', 'ff', 'ff', 'ff', 'ff', '00', '02', '00', '0c', '04', '77']
*** DEBUG ==> _get_packet reply: ['00', '00', '00', '00', '00', '00', '50', '00', '03', 'ff', 'ff', 'ff', 'ff', '00', '02', '00', '0c']
*** DEBUG ==> _send_packet length: 13
*** DEBUG ==> _send_packet data: ['ef', '01', 'ff', 'ff', 'ff', 'ff', '01', '00', '04', '1f', '00', '00', '24']
*** DEBUG ==> _get_packet received data: ['ef', '01', 'ff', 'ff', 'ff', 'ff', '07', '00', '23', '00', '0f', '00', '00', '00', '00', '00', '00', '00', '00', '00', '00', '00', '00', '00', '00', '00', '00', '00', '00', '00', '00', '00', '00', '00', '00', '00', '00', '00', '00', '00', '00', '00', '00', '39']
*** DEBUG ==> _get_packet reply: ['00', '0f', '00', '00', '00', '00', '00', '00', '00', '00', '00', '00', '00', '00', '00', '00', '00', '00', '00', '00', '00', '00', '00', '00', '00', '00', '00', '00', '00', '00', '00', '00', '00']
Fingerprint templates: [0, 1, 2, 3]
*** DEBUG ==> _send_packet length: 12
*** DEBUG ==> _send_packet data: ['ef', '01', 'ff', 'ff', 'ff', 'ff', '01', '00', '03', '1d', '00', '21']
*** DEBUG ==> _get_packet received data: ['ef', '01', 'ff', 'ff', 'ff', 'ff', '07', '00', '05', '00', '00', '04', '00', '10']
*** DEBUG ==> _get_packet reply: ['00', '00', '04']
Number of templates found: 4
*** DEBUG ==> _send_packet length: 14
*** DEBUG ==> _send_packet data: ['ef', '01', 'ff', 'ff', 'ff', 'ff', '01', '00', '05', '0e', '06', '02', '00', '1c']
*** DEBUG ==> _get_packet received data: ['ef', '01', 'ff', 'ff', 'ff', 'ff', '07', '00', '03', '00', '00', '0a']
*** DEBUG ==> _get_packet reply: ['00']
*** DEBUG ==> _send_packet length: 12
*** DEBUG ==> _send_packet data: ['ef', '01', 'ff', 'ff', 'ff', 'ff', '01', '00', '03', '0f', '00', '13']
*** DEBUG ==> _get_packet received data: []
Traceback (most recent call last):
File "fingerprint_test.py", line 179, in <module>
if finger.read_sysparam() != adafruit_fingerprint.OK:
File "/home/pi/projects/fingerprint/adafruit_fingerprint.py", line 147, in read_sysparam
r = self._get_packet(28)
File "/home/pi/projects/fingerprint/adafruit_fingerprint.py", line 343, in _get_packet
raise RuntimeError("Failed to read data from sensor")
RuntimeError: Failed to read data from sensor
The problem has something to do with setting sysparam 6 I simplified the code to jusst read the sysparam twice then set the sysparam 6 to 2 and read the sysparam again and it fails the same way Note that sysparam 6 is already reading as 2 before the set_sysparam is even called...
pi@gjnpi4desk:~/projects/fingerprint $ python3 fingerprint_sys.py
----------------
*** DEBUG ==> _send_packet length: 12
*** DEBUG ==> _send_packet data: ['ef', '01', 'ff', 'ff', 'ff', 'ff', '01', '00', '03', '0f', '00', '13']
*** DEBUG ==> _get_packet received data: ['ef', '01', 'ff', 'ff', 'ff', 'ff', '07', '00', '13', '00', '00', '00', '00', '00', '00', '50', '00', '03', 'ff', 'ff', 'ff', 'ff', '00', '02', '00', '0c', '04', '77']
*** DEBUG ==> _get_packet reply: ['00', '00', '00', '00', '00', '00', '50', '00', '03', 'ff', 'ff', 'ff', 'ff', '00', '02', '00', '0c']
*** DEBUG ==> _send_packet length: 12
*** DEBUG ==> _send_packet data: ['ef', '01', 'ff', 'ff', 'ff', 'ff', '01', '00', '03', '0f', '00', '13']
*** DEBUG ==> _get_packet received data: ['ef', '01', 'ff', 'ff', 'ff', 'ff', '07', '00', '13', '00', '00', '00', '00', '00', '00', '50', '00', '03', 'ff', 'ff', 'ff', 'ff', '00', '02', '00', '0c', '04', '77']
*** DEBUG ==> _get_packet reply: ['00', '00', '00', '00', '00', '00', '50', '00', '03', 'ff', 'ff', 'ff', 'ff', '00', '02', '00', '0c']
*** DEBUG ==> _send_packet length: 14
*** DEBUG ==> _send_packet data: ['ef', '01', 'ff', 'ff', 'ff', 'ff', '01', '00', '05', '0e', '06', '02', '00', '1c']
*** DEBUG ==> _get_packet received data: ['ef', '01', 'ff', 'ff', 'ff', 'ff', '07', '00', '03', '00', '00', '0a']
*** DEBUG ==> _get_packet reply: ['00']
*** DEBUG ==> _send_packet length: 12
*** DEBUG ==> _send_packet data: ['ef', '01', 'ff', 'ff', 'ff', 'ff', '01', '00', '03', '0f', '00', '13']
*** DEBUG ==> _get_packet received data: []
Traceback (most recent call last):
File "fingerprint_sys.py", line 35, in <module>
if finger.read_sysparam() != adafruit_fingerprint.OK:
File "/home/pi/projects/fingerprint/adafruit_fingerprint.py", line 147, in read_sysparam
r = self._get_packet(28)
File "/home/pi/projects/fingerprint/adafruit_fingerprint.py", line 343, in _get_packet
raise RuntimeError("Failed to read data from sensor")
RuntimeError: Failed to read data from sensor
here is the code run
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT
import serial
import adafruit_fingerprint
# If using with a computer such as Linux/RaspberryPi, Mac, Windows with USB/serial converter:
uart = serial.Serial("/dev/ttyUSB0", baudrate=115200, timeout=1)
finger = adafruit_fingerprint.Adafruit_Fingerprint(uart)
finger._debug = True
##################################################
def sensor_reset():
"""Reset sensor"""
print("Resetting sensor...")
if finger.soft_reset() != adafruit_fingerprint.OK:
print("Unable to reset sensor!")
print("Sensor is reset.")
while True:
print("----------------")
if finger.read_sysparam() != adafruit_fingerprint.OK:
raise RuntimeError("Failed to get system parameters")
if finger.read_sysparam() != adafruit_fingerprint.OK:
raise RuntimeError("Failed to get system parameters")
if finger.set_sysparam(6, 2) != adafruit_fingerprint.OK:
raise RuntimeError("Unable to set package size to 128!")
if finger.read_sysparam() != adafruit_fingerprint.OK:
raise RuntimeError("Failed to get system parameters")
print("Package size (x128):", finger.data_packet_size)
print("Size of template library: ", finger.library_size)
print("r) soft reset")
print("x) quit")
print("----------------")
c = input("> ")
if c in ("x", "q"):
print("Exiting fingerprint example program")
# turn off LED
set_led_local(mode=4)
raise SystemExit
elif c == "r":
sensor_reset()
else:
print("Invalid choice: Try again")
ah -- adding a time.sleep(1) between the set_sysparam and read_ssyparam fixes it
pi@gjnpi4desk:~/projects/fingerprint $ python3 fingerprint_sys.py
----------------
*** DEBUG ==> _send_packet length: 12
*** DEBUG ==> _send_packet data: ['ef', '01', 'ff', 'ff', 'ff', 'ff', '01', '00', '03', '0f', '00', '13']
*** DEBUG ==> _get_packet received data: ['ef', '01', 'ff', 'ff', 'ff', 'ff', '07', '00', '13', '00', '00', '00', '00', '00', '00', '50', '00', '03', 'ff', 'ff', 'ff', 'ff', '00', '01', '00', '0c', '04', '76']
*** DEBUG ==> _get_packet reply: ['00', '00', '00', '00', '00', '00', '50', '00', '03', 'ff', 'ff', 'ff', 'ff', '00', '01', '00', '0c']
*** DEBUG ==> _send_packet length: 12
*** DEBUG ==> _send_packet data: ['ef', '01', 'ff', 'ff', 'ff', 'ff', '01', '00', '03', '0f', '00', '13']
*** DEBUG ==> _get_packet received data: ['ef', '01', 'ff', 'ff', 'ff', 'ff', '07', '00', '13', '00', '00', '00', '00', '00', '00', '50', '00', '03', 'ff', 'ff', 'ff', 'ff', '00', '01', '00', '0c', '04', '76']
*** DEBUG ==> _get_packet reply: ['00', '00', '00', '00', '00', '00', '50', '00', '03', 'ff', 'ff', 'ff', 'ff', '00', '01', '00', '0c']
*** DEBUG ==> _send_packet length: 14
*** DEBUG ==> _send_packet data: ['ef', '01', 'ff', 'ff', 'ff', 'ff', '01', '00', '05', '0e', '06', '02', '00', '1c']
*** DEBUG ==> _get_packet received data: ['ef', '01', 'ff', 'ff', 'ff', 'ff', '07', '00', '03', '00', '00', '0a']
*** DEBUG ==> _get_packet reply: ['00']
*** DEBUG ==> _send_packet length: 12
*** DEBUG ==> _send_packet data: ['ef', '01', 'ff', 'ff', 'ff', 'ff', '01', '00', '03', '0f', '00', '13']
*** DEBUG ==> _get_packet received data: ['ef', '01', 'ff', 'ff', 'ff', 'ff', '07', '00', '13', '00', '00', '00', '00', '00', '00', '50', '00', '03', 'ff', 'ff', 'ff', 'ff', '00', '02', '00', '0c', '04', '77']
*** DEBUG ==> _get_packet reply: ['00', '00', '00', '00', '00', '00', '50', '00', '03', 'ff', 'ff', 'ff', 'ff', '00', '02', '00', '0c']
Package size (x128): 2
Size of template library: 80
r) soft reset
x) quit
----------------
>
OK -- I deleted my last post -- the template compare test now works ok (I forgot to save the fingerprint file first) if I add the time.sleep(1) between the set_sysparam and read_sysparam...
I expect the delay can be less than 1 second, not sure why it is needed at all... or how to best accommodate this. Pehaps we could add a delay in the library after executing set_sysparam
edited to add... that works -- I added a time.sleep(.25) to set_sysparam just before the return and now the template_compare example works
@jerryneedell Good news! The delay makes sense. Changing the package size probably causes some sort of soft reboot on the device.
I tried the fingerprint_template_file compare on one of the new fingerprint sensors https://www.adafruit.com/product/4750 and it fails with this result. I have not looked into it yet and don't have a datasheet for this sensor :-(
The "simpletest" works ok.