// either everything is good, or throw exception // Meaning InputReport // This function is slightly different, as we must return the number of bytes read. private int ReadRaw(byte[] buffer, int length = -1) { int bytes_read = 0; try{ AssertValidDev(); if (length < 0) { length = buffer.Length; } bytes_read = HidApi.hid_read_timeout(DeviceHandle, buffer, (uint)length, readTimeoutInMillisecs); /* * if (bytes_read < 0) * { * throw new Exception("Failed to Read."); * } */ } catch (Exception ex) { Console.WriteLine(ex); } return(bytes_read); }
// either everything is good, or throw exception // Meaning InputReport // This function is slightly different, as we must return the number of bytes read. private int ReadRaw(byte[] buffer, int length = -1) { AssertValidDev(); if (length < 0) { length = buffer.Length; } int bytes_read = HidApi.hid_read_timeout(DeviceHandle, buffer, (uint)length, readTimeoutInMillisecs); if (bytes_read < 0) { throw new Exception("Failed to Read."); } return(bytes_read); }