Hi,
Does anyone have experience with the LibUsbDotNet C# USB Library?
As hardware I’m using the power switch reference project on an Atmega328p. As V-USB version I’m using: vusb-20100715. When using the provided Windows command line tool my hardware works.
Now I’m trying to get the LibUsbDotNet C# USB Library to work, without success.
See: Support forum LibUsbDotNet C# USB Library
Does anyone have V-USB working in combination with the LibUsbDotNet C# USB Library?
MaMu
Experience with LibUsbDotNet C# USB Library
Re: Experience with LibUsbDotNet C# USB Library
have you tried break-pointing right before "ControlTransfer" and examining the packet before it's sent?
I have great success using LibUsbDotNet, I have made an LCD display which uses control transfers for text, brightness, and contrast setting, when I did it, I always made sure that the values for bmRequestType and bRequest were valid, it sounds like you are just putting in values from textboxes, are the values valid?
why are you always explicitly casting the UsbDevice object to interfaces? why not just call methods on usbDevice?
I have great success using LibUsbDotNet, I have made an LCD display which uses control transfers for text, brightness, and contrast setting, when I did it, I always made sure that the values for bmRequestType and bRequest were valid, it sounds like you are just putting in values from textboxes, are the values valid?
why are you always explicitly casting the UsbDevice object to interfaces? why not just call methods on usbDevice?
Re: Experience with LibUsbDotNet C# USB Library
_frank26080115 wrote:have you tried break-pointing right before "ControlTransfer" and examining the packet before it's sent?
Of course! The debugger is always good idea!
Because I built my own hardware I'm using an old laptop for testing. I'll install the lightweight debugger.
_frank26080115 wrote:I have great success using LibUsbDotNet, I have made an LCD display which uses control transfers for text, brightness, and contrast setting, when I did it, I always made sure that the values for bmRequestType and bRequest were valid, it sounds like you are just putting in values from textboxes, are the values valid?
After I couldn't get it to work I added the textboxes so I can easily experiment with different values.
_frank26080115 wrote:why are you always explicitly casting the UsbDevice object to interfaces? why not just call methods on usbDevice?
I got the code from the provided examples, I'll try without the cast.
Re: Experience with LibUsbDotNet C# USB Library
I'll install the lightweight debugger.
I meant: use the Visual Studio debugger
here's a bit from my own code
Code: Select all
public bool SetContrast(byte contrast)
{
if (IsConnected == false)
return false;
UsbSetupPacket packet = new UsbSetupPacket((byte)UsbRequestType.TypeVendor, (byte)RequestCommand.SetContrast, (short)contrast, 0, 0);
int temp1;
object temp2 = null;
return MyUsbDevice.ControlTransfer(ref packet, temp2, 0, out temp1);
}
Re: Experience with LibUsbDotNet C# USB Library
IT WORKS!
I removed the cast from the UsbDevice object and integrate your code snippet into my program. After a bit of experimenting with some values it worked.
Thanks a lot!
_frank26080115 wrote:here's a bit from my own codeCode: Select all
public bool SetContrast(byte contrast)
{
if (IsConnected == false)
return false;
UsbSetupPacket packet = new UsbSetupPacket((byte)UsbRequestType.TypeVendor, (byte)RequestCommand.SetContrast, (short)contrast, 0, 0);
int temp1;
object temp2 = null;
return MyUsbDevice.ControlTransfer(ref packet, temp2, 0, out temp1);
}
I removed the cast from the UsbDevice object and integrate your code snippet into my program. After a bit of experimenting with some values it worked.
Thanks a lot!