Пример #1
0
        /// <summary>
        /// 打开HID设备
        /// </summary>
        /// <param name="deviceType">设备标准</param>
        /// <param name="deviceIndex">设备索引</param>
        /// <param name="vendorID">Vendor ID</param>
        /// <param name="productID">Product ID</param>
        /// <returns></returns>
        public INFCDevice Open(DeviceType deviceType, uint deviceIndex, ushort vendorID = 0x0416, ushort productID = 0x8020)
        {
            IntPtr deviceID = (IntPtr)(-1);
            int    or       = HfrdApi.Sys_Open(ref deviceID, deviceIndex, vendorID, productID);

            Win32.Sleep(5);
            if (or != 0)
            {
                throw new InvalidOperationException("打开设备失败,错误代码:" + or);
            }

            switch (deviceType)
            {
            case DeviceType.ISO14443A:
                throw new NotImplementedException();

            case DeviceType.ISO14443B:
                throw new NotImplementedException();

            case DeviceType.ISO15693:
                return(new NFC750_ISO15693(deviceID));

            default:
                throw new Exception("error code:" + or);
            }
        }
Пример #2
0
        /// <summary>
        /// 打开HID设备
        /// </summary>
        /// <param name="device">设备标准</param>
        /// <param name="deviceIndex">设备索引</param>
        /// <param name="vendorID">Vendor ID</param>
        /// <param name="productID">Product ID</param>
        /// <returns></returns>
        public int Open(INFCDevice device, uint deviceIndex, ushort vendorID = 0x0416, ushort productID = 0x8020)
        {
            IntPtr deviceID = (IntPtr)(-1);
            int    or       = HfrdApi.Sys_Open(ref deviceID, device.DeviceIndex, device.VendorID, device.ProductID);

            device.DeviceID = deviceID;

            return(or);
        }