예제 #1
0
        public static void Main(String[] args)
        {
            var        hidDevices = new HidEnumerator().Enumerate(VendorId, ProductId);
            IHidDevice device     = null;

            try
            {
                device = hidDevices.Single(hd => hd.Capabilities.UsagePage == -256);
                device.Write(ReadTemperateureCommand);
                var data = device.Read();
                while (data.Status != HidDeviceData.ReadStatus.Success)
                {
                    ;
                }
                device.CloseDevice();

                CultureInfo ci = new CultureInfo(System.Threading.Thread.CurrentThread.CurrentCulture.Name);
                ci.NumberFormat.NumberDecimalSeparator = ".";
                System.Threading.Thread.CurrentThread.CurrentCulture = ci;

                Console.Write("{\"in\":" + Convert(data.Data[3], data.Data[4]) + ",\"out\":" + Convert(data.Data[5], data.Data[6]) + "}");
            }
            catch (Exception e)
            {
                Console.Write("Device is not connected");
                Console.ReadLine();
                Environment.Exit(-1);
            }
        }
예제 #2
0
 /// <summary>
 /// Will disconnect the scale
 /// </summary>
 public void Disconnect()
 {
     if (mScale != null)
     {
         mScale.CloseDevice();
         mScale.Dispose();
         mScale = null;
     }
 }
예제 #3
0
        public HidConsoleDevice(IHidDevice device)
        {
            HidDevice = device;
            HidDevice.OpenDevice();

            ManufacturerString = GetManufacturerString(HidDevice);
            ProductString      = GetProductString(HidDevice);
            VendorId           = (ushort)HidDevice.Attributes.VendorId;
            ProductId          = (ushort)HidDevice.Attributes.ProductId;
            RevisionBcd        = (ushort)HidDevice.Attributes.Version;

            HidDevice.MonitorDeviceEvents = true;
            HidDevice.ReadReport(HidDeviceReportEvent);

            HidDevice.CloseDevice();
        }
예제 #4
0
 public void Dispose()
 {
     hidDevice.CloseDevice();
 }
 public override void Disconnect()
 {
     _hid.CloseDevice();
     InvokeDeviceRemoved();
 }