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); } }
/// <summary> /// Will disconnect the scale /// </summary> public void Disconnect() { if (mScale != null) { mScale.CloseDevice(); mScale.Dispose(); mScale = null; } }
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(); }
public void Dispose() { hidDevice.CloseDevice(); }
public override void Disconnect() { _hid.CloseDevice(); InvokeDeviceRemoved(); }