USB HID communication

P

perdrix

Hello,

I try to communicate in USB with an HID device.

I started with the following code found on the Internet:

if (WriteFile(WriteHandleToUSBDevice, OUTBuffer, 65, ref BytesWritten,
IntPtr.Zero)) //Blocking function, unless an "overlapped" structure is used
{
INBuffer[0] = 0;
recup_MC_15Pending = false;
//Now get the response packet from the firmware.
if (ReadFileManagedBuffer(ReadHandleToUSBDevice, INBuffer, 65, ref
BytesRead, IntPtr.Zero)) //Blocking function, unless an "overlapped"
structure is used
{
message = display(INBuffer); // we display the incoming data
in a TextBox
}
}

This code works, but only when we ask for a message through the
OUTBuffer. Otherwise the ReadFileManagedBuffer function is blocking.

Does somebody know how avoid this blocking ? Is it a simple way to write
an "overlapped structure" as suggested in the comment ?

Thank you for your answers

Jeff
 
J

Jeff Johnson

I try to communicate in USB with an HID device.

I can't remember its name off the top of my head, but I think on Codeplex or
a similar site there is a .NET wrapper for HID USB communication. I used it
successfully to talk to a scale.

I checked my files, and apparently I only grabbed the precompiled DLL.
There's no documentation, nor is there anything useful in the version info
or the metadata to help me identify where it came from. It's called
HidLibrary.dll.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top