Menu

Device.open() only run once.

Help
2008-10-21
2012-12-06
  • Igor Brites

    Igor Brites - 2008-10-21

    Hello, everyone.

    I am trying to recover data from a fingerprint reader. And all I get back is this:

    10
    0
    1000
    0
    10000
    0
    100000
    0
    11111111111111111111111110000000
    0
    1010110
    11111111111111111111111110101010
    11
    11111111111111111111111110010001
    1110
    11111111111111111111111111111110
    1100
    1010100
    10
    1
    0
    10000
    1101
    11111111111111111111111111101110
    1100
    1000000
    10100
    10
    1100
    1000100
    10110
    100
    10
    1110000
    1100
    10001
    1100
    1000000
    10100
    10
    1100
    1000100
    1111
    10001
    10110
    1011
    10
    11111111111111111111111111000000
    1100
    1000000
    1101
    11111111111111111111111111100000
    0
    10000
    1111
    10000
    1100
    1000100
    10100
    10
    1100
    1000000
    1110
    11111111111111111111111111110001

    But when I try to do it again, the program stops at the method device.open(). So I wanted to know what are these numbers (if they really are fingerprints) or only device data. And why it stops running. May someone help me?

    Here is my code.

    *******************************************************************************

    import ch.ntb.usb.*;
    import ch.ntb.usb.testApp.TransferMode;

    public class Test extends DeviceInfo{
       
        Device dev;
        Usb_Bus usb_Bus;
       
        public void initValue() {
           
           
           
            setIdVendor((short) 0x045e);
            setIdProduct((short) 0x00bd);
            setTimeOut(2000);
            setConfig(1);
            setInterface(0);
            setAltInterface(-1);
            setEntraEPBulk(0x81);
            setSleepTimeout(2000);
            setMaxDataSize(USB.FULLSPEED_MAX_BULK_PACKET_SIZE);
            setMode(new TransferMode(TransferMode.Bulk));
           
        }
       
        public void open(){
           
            dev = USB.getDevice(getIdVendor(), getIdProduct());
            try {
                dev.open(getConfig(), getInterface(), getAltInterface());
                dev.setResetOnFirstOpen(true, 2000);
                System.out.println("Device opened.");
            } catch (USBException e) {
                e.printStackTrace();
            }
                   
        }
       
        public void read(){
           
            if (dev != null) {
               
                byte[] data = new byte[dev.getMaxPacketSize()];
                int valueData = 0;
                try {
                    StringBuffer sb = new StringBuffer();
                    valueData = dev.readBulk(getInEPBulk(), data, dev.getMaxPacketSize(), getTimeOut(), true);
                    for (int i = 0; i < valueData; i++) {
                        String s = Integer.toBinaryString(data[i]);
                        sb.append(s);
                        sb.append("\n");
                    }
                    /*int[] c = new int[valueData];
                    for (int b : c) {
                        String d = Integer.toBinaryString(b);
                        System.out.println(d);
                    }*/
                   
                    System.out.println(sb.toString());
                } catch (USBException e) {
                    e.printStackTrace();
                }
               
            } else {
                System.out.println("None device opened.");
            }
           
        }

        public void reset(){
           
            if (dev!=null) {
                try {
                    dev.reset();
                    System.out.println("Reseted.");
                } catch (USBException e) {
                    e.printStackTrace();
                }
            } else {
                System.out.println("None device to reset.");
            }
           
        }

        public void close(){
           
            try {
                if(dev != null){
                    dev.close();
                    System.out.println("Device closed.");
                }
            } catch (USBException e) {
                System.out.println("None device opened.");
            }
           
        }
       
       
       
    }

    *******************************************************************************

    public class TestMain {
       
        public static void main(String[] args) {
           
            Test test = new Test();
            test.initValue();
            test.OPEN();
            test.read();
            test.reset();
            System.exit(1);
           
        }

    }

    ********************************************************************************

    DeviceInfo has onli setters and getters.

    Thanks everyone.

    P.S.: My english isn't too god, so I'm sorry if I have made a mistake.

     
    • andi

      andi - 2008-10-30

      Hi

      Without knowing the specification of your finger print reader it's hard to tell if this data makes sense. You may find some example data on the net.
      Do you get an exception when opening the device or does it just hang?
      You could try to reset the device instead of closing it (a reset also closes the device) and then open it as usual.

      Regards, Spandi

       
    • Igor Brites

      Igor Brites - 2008-11-01

      Hello there!!

      I managed to stop the error. I used the command System.exit (0); Before I was using index 1 instead of 0. But now I have another problem. The applet UsbView, as well as the application LibUSB-Win32 is not finding my fingerprint reader. It is connected, works with the application of DigitalPersona, but is not found by the API. What can this be? Thank you for your cooperation.

       
      • andi

        andi - 2008-11-08

        UsbView only finds your device if it shows up in the Device Manager. If it's not there no device driver has been installed for that device.
        Have a look at this page: http://libusbjava.sourceforge.net/wp/?page_id=8

         

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.