This project is read-only.

Accessing HID Devices

Jul 21, 2012 at 1:16 PM
Edited Jul 21, 2012 at 4:50 PM


 Hope you are fine. Remarkable work that you are doing. My appreciations. I have started work on HID USB Thermometer. I am using Temper USB. It came with monitoring software which is working fine. On Windows 7 device manager, USB Temper device is shown as HID Keyboard device.

I ran your SimpleHIDTest application. It detects the USB device in upper left box. But nothing is shown in the other text-boxes. Can you give the source code of SimpleHIDTest or create some documentation about how to use your library. Can you reply with few lines of code to tell how to start ? How to get HID devices list and how to read any input from one of the HID devices in the list. I am using C# and Visual Studio 2010. 

So far I have accessed the USB HID device:

SimpleHID.HIDManager hid_m = new HIDManager();     

 System.Collections.Generic.IEnumerable<SimpleHID.HIDInfoSet> device_list = SimpleHID.HIDManager.GetInfoSets();         

  SimpleHID.HIDDevice dev = new HIDDevice();           

String device_path = device_list.ElementAt(0).DevicePath;           


//Now hoe to read the temperature reading from the device ?

Much obliged,


Jul 31, 2012 at 6:17 PM

Hi Tayyab_ch,

Maybe you have solved your problems by now. The source code is here:


Oct 9, 2012 at 7:13 PM

Thanks for the reply. I have started working again on the USB Temper-gold device by following the code in SimpleHIDTestApplication. I found it veryuseful and thank you for uploading it. But when I try to read from the device through filestream in public void Init(string devicePath) function of HIDDevices.cs,via this updated code at the (end of the function):

fileStream = new FileStream(new SafeFileHandle(handle, false), FileAccess.Read | FileAccess.Write, hidCaps.InputReportByteLength, true);

bool can_read = fileStream.CanRead;      //true     

 bool isAsync = fileStream.IsAsync;         //true

 bool can_write = fileStream.CanWrite;  //true

  //long position = fileStream.Position;   //gives exception

 //long length = fileStream.Length;       //gives exception

byte[] b  = new byte[9];

b[0] = 0;              b[1] = 0x1;              b[2] = 0x82;              b[3] = 0x77;              b[4] = 0x01;              b[5] = 0;              b[6] = 0;              b[7] = 0;         b[8] = 0;

//this is the first set of bytes that the vendor software always send, but this does not open the device for reading

 fileStream.Write(b, 0, 9);     //this sometimes hangs the vendor software as well is the second byte contains 255

int a = 1;              while (a < 10)              {fileStream.Read(b, 0, 9); a+=1;} //works fine as long as the vendor software is running along

I can not read from the device, the Visual Studio 2010 hangs till I start the vendor provided software Temper-V23.4. As soon as I start the software, the visual studio 2010 comes out of hanging state and I can then read from the file stream. But the Visual Studio 2010 again hangs while reading if I turn off the vendor tool. I tried to sniff the packets traveling between USB and my computer using ( I checked the packet trace and found out that the vendor software sends different data packets of 8 bytes to device. I tried to write the same pattern from fileStream and got some corresponding data packets from the device. But there are many patterns and it gets very complex. 

Am I missing some code for initial communication with the device so that I donot have to run the vendor software ?

The test application just gives the device details and nothing is shown related to input or output report. 

Is there a way to find out, that what the device requires to allow reading ?

Once during my experiments, the vendor software gave error messages related to its C# libraries so I guess the vendor software is also made in C#. But those libraries are not in the installation folder.