- summary: MonoUsbControlSetup.SetData create another GCHandle --> MonoUsbControlSetup.SetData creates another GCHandle
I'm using Ubuntu 10.10 64 bits, and I've been doing a lot of testing trying to get my app working with V-USB. When I use device.ControlTransfer I see that the buffer is sent incorrectly (I used Wireshark for debug).
Digging into the code, I manage to solve it doing this changes:
public void SetData(IntPtr pData, int offset, int length)
{
//PinnedHandle p = new PinnedHandle(data);
Byte[] temp = new byte[length];
Marshal.Copy(pData, temp, offset, length);
//p.Dispose();
Marshal.Copy(temp, 0, PtrData, length);
}
I also made changes to MonoUsbControlSetupHandle:
public MonoUsbControlSetupHandle(byte requestType, byte request, short value, short index, IntPtr pData, int length)
: this(requestType, request, value, index, (short)(ushort)length)
{
if (pData != null)
mSetupPacket.SetData(pData, 0, length);
}
I believe that the real problem belongs to PinnedHandle.cs, which is not able to realize that "data" is already a GCHangle, so creates a new one.
But, the changes I made are sufficient for me.
I hope it helps!
Gustavo.