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
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