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); } }
public bool WriteData(byte[] aData) { if (_disposed || !_hid.IsOpen) { return(false); } return(_hid.Write(aData, 100)); }
/// <summary> /// Will Tare the scale /// </summary> /// <remarks> ///Page 56 http://www.usb.org/developers/hidpage/pos1_02.pdf /// Byte 0 must be 2 to set report id /// Byte 1 first bit = enforce zero return ie 0x01 /// Byte 1 second bit = tare ie 0x02 /// </remarks> public void Tare() { CheckStatusAndThrow(); mScale.Write(new byte[] { 0x02, 0x02 }); }