c# Detect incoming data from usb port

时间:2016-03-04 18:10:56

标签: c# usb fingerprint libusb

Hi I'm working on a project using a fingerprint reader. I would like to know if there is any way to detect incoming data from that device, what I want to do is: When data detected from the fingerprint reader show a form(the form show data from the user detected), but I been searching for methods, and all of them use libraries, if there any way to solve it, without libraries? Thanks.

The reader is a U.are.U. 4500, in using their SDK, but there is any method that check is the fingerprint reader is sending data.

I download LibUSB.net, I would to know if I can solve this problem using this librarie.

1 个答案:

答案 0 :(得分:0)

听起来你需要这样的东西:

// event handler
protected void ScanDetected(sender object, args e)
{
    Fingerprint fp = //data received
    RespondToScan(fp);
}

internal void RespondToScan(Fingerprint _fp)
{
   Person who = GetPersonWithFingerprint(_fp);
   PersonForm pf = new PersonForm(who);
   pf.ShowDialog();
}

internal Person GetPersonWithFingerprint(Fingerprint _fp)
{
    Person person = null;
    if (lotsOfSquigglyLinesAndSuch)
    {
       person = new Person();
       person.FirstName = "John";
       person.LastName = "Dillinger";
       . . .
    }
    else if (someOtherCharacteristic)
    {
       . . .
    }
    return person;
}

// Form that will be invoked and display user's data:
class PersonForm: Form
. . .
string _firstname;
string _lastname;
public PersonForm(Person person)
{
    _firstname = person.FirstName;
    . . .             
}

private void FormShow(sender object, eventargs e)
{
    textboxFirstName.Text = _firstName;
    . . .  
}

// class to hold data
public class Person
{
    string FirstName { get; set; }
    string LastName { get; set; }
    Picture Mugshot { get; set; }
    . . .
}

当然,这只是伪代码,可以让您大致了解如何继续 - 只要我能正确理解您的情况。