I am experiencing a similar issue with the USB2.0 API and C#. I have written a suitable C# wrapper for the API library and I am successfully getting a number of the functions to work with no problem. However, having created a suitable hardware arrangement to trigger bus errors (using the C++ demo code as a reference) my calls to USB2GetBusErros is always returning zero count via the integer return value.
When run with the demo program it consistently returns an increasing error count as the timer cycles during Loopback testing. I have adapted my wrapper code to many variations. With and without marshalling on both return value and input argument. Other functions in the library that return an integer are working including USB2GetDeviceInfo. I have tried duplicating the wrapper syntax for this function and still no success with the call to USB2GetBusErrors.
The code below is current WIP but as I said I have tried with and without marshalling and even with and without calling convention defined.
Code:
[FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] [/SIZE][/FONT][DllImport("USB2Dll.dll"/*, CallingConvention = CallingConvention.Cdecl*/)] [return: MarshalAs(UnmanagedType.I4)] internal static extern int USB2GetBusErrors([In] [MarshalAs(UnmanagedType.I4)] int iDeviceNum); [/SIZE][/FONT]
Code:
private int _totalBUSErrors = 0; private int _totalOperations = 0; private int _totalErrors = 0; [FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]while (PMUSB2.USB2TestIsRunning()) { if (PMUSB2.USB2GetLoopbackResults(operations, errors)) { _totalOperations = operations[instance._id]; _totalErrors = errors[instance._id]; _totalBUSErrors = PMUSB2.USB2GetBusErrors(instance._id); } } [/COLOR][/SIZE][/FONT] [/COLOR][/SIZE][/FONT] [/COLOR][/SIZE][/FONT]
Many Thanks.
Leave a comment: