2

I have a Raspberry Pi and SecuGen Hamster Plus fingerprint sensor.

I am trying to get fingerprint inputs from the sensor to Raspberry Pi using the following code.

import sys
import usb.core
import usb.util
VENDOR_ID=0x1162
PRODUCT_ID=0x1000
DATA_SIZE=64
device = usb.core.find(idVendor=VENDOR_ID, idProduct=PRODUCT_ID)
if device.is_kernel_driver_active(0):
    device.detach_kernel_driver(0)

try:
    device.set_configuration()
except usb.core.USBError as e:
    sys.exit("Could not set configuration: %s" % str(e))
endpoint = device[0][(0,0)][0]
print endpoint
data = []
swiped = False
print "Send a code..."
a = 0
while True:
    try:
        dev = device.read(endpoint.bEndpointAddress,endpoint.wMaxPacketSize)
        print dev
        data.append(dev.buffer_info())
        if len(data)>2:
            print data[a]
            a = a+1
        if not swiped:
            print "Reading..."
            swiped = True

    except usb.core.USBError as e:
        print e
        if e.args == ('Operation timed out',) and swiped:

            if len(data) < DATA_SIZE:
                swiped = False
                continue
                    else:
                break

I keep getting [Errno 110] Operation timed out as error. I am a noob in the hardware field. Can someone help me with the integration of Pi with fingerprint sensor?

1
  • Welcome to the Raspberry Pi bit of the Stack Exchange. Does the user executing the script (pi?) have access to the Finger scanner - I guess it does, as your code is reaching the main loop - but I am not a python expert. This does look like an interesting device and it does claim Linux support so don't give up just yet... 8-)
    – SlySven
    Feb 5, 2016 at 16:27

1 Answer 1

2

Well, it appears that there's a frustrating lack of documentation in every aspect of your project. I can't find a decent set of documentation on either PyUSB or your device, so my answer will have some necessary speculation.

Looking at this source code, device.read() accepts a timeout parameter, that should be defaulting to None. Further reading shows that if no timeout parameter is received, the default is used. Since you didn't specify a default, the code default is selected. _DEFAULT_TIMEOUT = 1000 (in milliseconds).

Essentially, your code is asking for input, and is waiting for anything at all to come from the selected device. If nothing comes within the designated time period (1 second), it errors. You could try setting the default as to be significantly higher, or you could just ignore the timeout errors (what I would do).

The best solution to the problem would be to use some kind of blocking read(), but as far as I can tell, PyUSB does not support it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.