We have a USB device here which has a EZ-USB FX chip on it and we "talk" to it via libusb-1.0
using LibUsbDotNet
. Using Windows everything works fine, but using Mono 3.12.1
under Ubuntu 14.04
it does not work. I did some investigation and testing and found out it can't initialize the device, where we use the following logic (this is from my test program, but the "real logic" is equivalent):
protected bool ResetDevice(UsbDevice Device)
{
Console.WriteLine("First ensure that the EZ-USB 8051 is RESET (CPUCS=1)");
if (!ControlTransfer(Device, new byte[] { 1 }))
return false;
Console.WriteLine ("Then allow the EZ-USB CPU to 're-enumerate' (CPUCS=0)");
if (!ControlTransfer(Device, new byte[] { 0 }))
return false;
Console.WriteLine("Reset done...");
return true;
}
public bool ControlTransfer(UsbDevice Device, byte[] data, short? value = null)
{
int written;
var setupPacket = SetupPacket(value);
return Device.ControlTransfer(ref setupPacket, data, data.Length, out written);
}
internal UsbSetupPacket SetupPacket(short? value = null)
{
var controlPacket = new UsbSetupPacket();
controlPacket.Request = 0xA0;
controlPacket.RequestType = 64;
controlPacket.Value = value ?? 0x07F92;
controlPacket.Index = 0;
return controlPacket;
}
I then used an USB analyzer to profile the commands sent via the USB-Port.
Using Windows I get the following:
which is correct and as you can see the device resets an can be used, but when using Linux I get the following:
Now instead of
01
and 00
the command sends 68
and A8
and so the device does nothing.
Does anyone have an idea what could be the reason of that? Why does it send the wrong data packet under Linux?
It seems this is a Bug of LibUsbDotNet (very likely THIS one), as a build of the current trunk
(v2.2.9) did solve this problem.