Exemplo n.º 1
0
        /// <summary>
        /// Triggered when the device is unplugged
        /// </summary>
        private void _usbDevice_EvtDeviceDisconnected()
        {
            Log.Debug("Words+ Key has been unplugged");

            _usbDevice.Close();
            actuatorState = State.Stopped;

            // start the timer to periodically check
            _timer.Start();
        }
Exemplo n.º 2
0
Arquivo: Reader.cs Projeto: tate98/USB
 public void StartListening()
 {
     USBDevice?.Close();
     DeviceListener.DeviceDisconnected += DevicePoller_DeviceDisconnected;
     DeviceListener.DeviceInitialized  += DevicePoller_DeviceInitialized;
     DeviceListener.Start();
 }
Exemplo n.º 3
0
 private void CloseUSB()
 {
     if (_usbDevice != null && !_usbDevice.IsOpen)
     {
         _usbDevice.OnUsbDataReceived -= _usbDevice_OnUsbDataReceived;
         _usbDevice.Close();
     }
     _usbDevice = null;
 }
Exemplo n.º 4
0
        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();
                }
            }
        }