protected async Task Run() { USBDevice device = await this._usb.RequestDevice(new USBDeviceRequestOptions { Filters = _filters }); if (device != null) { try { device = await device.Open(); device = await device.SelectConfiguration(device.Configuration); // device = await device.SelectConfiguration(1); device = await device.ClaimBulkInterface(); this._logger.LogInformation("PinPad selected:"); this._logger.LogInformation(device); this._logger.LogInformation("PinPad information:"); var info = await this.Open(device); if (info == null) { this._logger.LogWarning("Unable to read device info..."); } else { this._logger.LogInformation(info); } } catch (Exception exc) { this._logger.LogError(exc); } finally { await Close(device); await device.ReleaseBulkInterface(); await device.Close(); } } }
protected async Task RequestDevices() { USBDevice device = null; if (string.IsNullOrEmpty(this.productId) && string.IsNullOrEmpty(this.vendorId)) { device = await this._usb.RequestDevice(); } else { device = await this._usb.RequestDevice(new USBDeviceRequestOptions { Filters = new List <USBDeviceFilter> { new USBDeviceFilter { VendorId = 0x079b, ProductId = 0x0028 }, new USBDeviceFilter { VendorId = 0x1753, ProductId = 0xC902 } // new USBDeviceFilter { VendorId = Convert.ToUInt16(this.vendorId, 16) , ProductId = Convert.ToUInt16(this.productId, 16) } } }); } if (device != null) { device = await device.Open(); device = await device.SelectConfiguration(device.Configuration); // device = await device.SelectConfiguration(1); device = await device.ClaimBulkInterface(); this._logger.LogInformation(device); var outResult = await device.TransferOut(2, new byte[] { 1, 2, 3 }); this._logger.LogInformation("Write response:"); this._logger.LogInformation(outResult); var inResult = await device.TransferIn(1, 3); this._logger.LogInformation("Read response:"); this._logger.LogInformation(inResult); } }