Open() public abstract method

Makes a connection to the USB HID class device, or throws an exception if the connection cannot be made.
public abstract Open ( ) : HidStream
return HidStream
示例#1
0
    public void Check()
    {
        var devices = loader.GetDevices(vid, pid);

        signerCount = devices.Count();
        if (devices.Count() == 0)//直接移除设备
        {
            atcdevice = null;
            stream    = null;
            return;
        }
        if (atcdevice == null)//打开设备
        {
            atcdevice = devices.First();
            stream    = atcdevice.Open();
            return;
        }
        bool bFind = false;

        foreach (var d in devices)
        {
            if (d.DevicePath == atcdevice.DevicePath)
            {//same
                bFind = true;
            }
        }
        //找不到设备了
        if (!bFind)
        {
            atcdevice = null;
            stream    = null;
        }
    }
示例#2
0
    public static int CheckDevice()
    {
        var devices     = loader.GetDevices(0x0483, 0x572b);
        var signerCount = devices.Count();

        if (devices.Count() == 0)//直接移除设备
        {
            atcdevice = null;
            stream    = null;
            return(0);
        }
        if (atcdevice == null)//打开设备
        {
            atcdevice = devices.First();
            stream    = atcdevice.Open();
            return(signerCount);
        }
        bool bFind = false;

        foreach (var d in devices)
        {
            if (d.DevicePath == atcdevice.DevicePath)
            {//same
                bFind = true;
            }
        }
        //找不到设备了
        if (!bFind)
        {
            atcdevice = null;
            stream    = null;
        }
        return(signerCount);
    }