Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing under macOS Apple Silicon #137

Closed
mcuee opened this issue Jun 5, 2021 · 24 comments
Closed

Testing under macOS Apple Silicon #137

mcuee opened this issue Jun 5, 2021 · 24 comments
Labels
Build Nuget, Solution and Project files related Examples Related to built-in examples FAQ Frequently Asked Questions

Comments

@mcuee
Copy link
Collaborator

mcuee commented Jun 5, 2021

Sorry but I can not seem to be able to build libusbdotnet under my Mac Mini M1. Just wondering if there is any reference. I have installed Visual Studion for Mac.

@mcuee
Copy link
Collaborator Author

mcuee commented Jun 5, 2021

Error messages are like this.

Target CoreCompile:
        /Applications/Visual Studio.app/Contents/Resources/lib/monodevelop/bin/MSBuild/Current/bin/Roslyn/csc.exe /noconfig /unsafe+ /checked- /nowarn:1701,1702,1701,1702,2008 /fullpaths /nostdlib+ /errorreport:prompt /warn:4 /define:TRACE;WIN;LIBUSBDOTNET;DEBUG;NETSTANDARD;NETSTANDARD2_0 /errorendlocation /preferreduilang:en-US /highentropyva+ /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/Microsoft.Win32.Primitives.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/mscorlib.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/netstandard.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.AppContext.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Collections.Concurrent.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Collections.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Collections.NonGeneric.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Collections.Specialized.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.ComponentModel.Composition.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.ComponentModel.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.ComponentModel.EventBasedAsync.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.ComponentModel.Primitives.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.ComponentModel.TypeConverter.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Console.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Core.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Data.Common.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Data.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Diagnostics.Contracts.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Diagnostics.Debug.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Diagnostics.FileVersionInfo.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Diagnostics.Process.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Diagnostics.StackTrace.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Diagnostics.TextWriterTraceListener.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Diagnostics.Tools.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Diagnostics.TraceSource.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Diagnostics.Tracing.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Drawing.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Drawing.Primitives.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Dynamic.Runtime.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Globalization.Calendars.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Globalization.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Globalization.Extensions.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.IO.Compression.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.IO.Compression.FileSystem.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.IO.Compression.ZipFile.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.IO.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.IO.FileSystem.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.IO.FileSystem.DriveInfo.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.IO.FileSystem.Primitives.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.IO.FileSystem.Watcher.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.IO.IsolatedStorage.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.IO.MemoryMappedFiles.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.IO.Pipes.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.IO.UnmanagedMemoryStream.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Linq.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Linq.Expressions.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Linq.Parallel.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Linq.Queryable.dll /reference:/Users/mcuee/.nuget/packages/system.memory/4.5.1/ref/netstandard2.0/System.Memory.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Net.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Net.Http.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Net.NameResolution.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Net.NetworkInformation.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Net.Ping.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Net.Primitives.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Net.Requests.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Net.Security.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Net.Sockets.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Net.WebHeaderCollection.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Net.WebSockets.Client.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Net.WebSockets.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Numerics.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.ObjectModel.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Reflection.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Reflection.Extensions.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Reflection.Primitives.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Resources.Reader.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Resources.ResourceManager.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Resources.Writer.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Runtime.CompilerServices.VisualC.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Runtime.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Runtime.Extensions.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Runtime.Handles.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Runtime.InteropServices.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Runtime.InteropServices.RuntimeInformation.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Runtime.Numerics.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Runtime.Serialization.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Runtime.Serialization.Formatters.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Runtime.Serialization.Json.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Runtime.Serialization.Primitives.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Runtime.Serialization.Xml.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Security.Claims.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Security.Cryptography.Algorithms.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Security.Cryptography.Csp.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Security.Cryptography.Encoding.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Security.Cryptography.Primitives.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Security.Cryptography.X509Certificates.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Security.Principal.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Security.SecureString.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.ServiceModel.Web.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Text.Encoding.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Text.Encoding.Extensions.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Text.RegularExpressions.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Threading.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Threading.Overlapped.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Threading.Tasks.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Threading.Tasks.Parallel.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Threading.Thread.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Threading.ThreadPool.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Threading.Timer.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Transactions.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.ValueTuple.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Web.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Windows.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Xml.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Xml.Linq.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Xml.ReaderWriter.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Xml.Serialization.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Xml.XDocument.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Xml.XmlDocument.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Xml.XmlSerializer.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Xml.XPath.dll /reference:/Users/mcuee/.nuget/packages/netstandard.library/2.0.3/build/netstandard2.0/ref/System.Xml.XPath.XDocument.dll /debug+ /debug:portable /filealign:512 /keyfile:LibUsbDotNet.snk /optimize- /out:obj/Debug/netstandard2.0/LibUsbDotNet.dll /target:library /warnaserror- /utf8output /deterministic+ /sourcelink:obj/Debug/netstandard2.0/LibUsbDotNet.sourcelink.json /langversion:latest obj/Debug/netstandard2.0//LibUsbDotNet.Version.cs AssemblyInfo.cs Descriptors/LangStringDescriptor.cs Descriptors/UsbDescriptor.cs Descriptors/UsbMemChunk.cs Generated/BosDescriptor.cs Generated/BosDevCapabilityDescriptor.cs Generated/BosType.cs Generated/Capability.cs Generated/ClassCode.cs Generated/ConfigDescriptor.cs Generated/ContainerIdDescriptor.cs Generated/Context.cs Generated/Context.ReleaseHandle.cs Generated/ControlSetup.cs Generated/DescriptorType.cs Generated/Device.cs Generated/Device.ReleaseHandle.cs Generated/DeviceDescriptor.cs Generated/DeviceHandle.cs Generated/DeviceHandle.ReleaseHandle.cs Generated/EndpointDescriptor.cs Generated/EndpointDirection.cs Generated/Error.cs Generated/HotplugCallbackFn.cs Generated/HotplugEvent.cs Generated/HotplugFlag.cs Generated/Interface.cs Generated/InterfaceDescriptor.cs Generated/IsoPacketDescriptor.cs Generated/IsoSyncType.cs Generated/IsoUsageType.cs Generated/LogLevel.cs Generated/NativeMethods.cs Generated/NativeMethods.Unsafe.cs Generated/Pollfd.cs Generated/PollfdAddedDelegate.cs Generated/PollfdRemovedDelegate.cs Generated/RequestRecipient.cs Generated/RequestType.cs Generated/Speed.cs Generated/SsEndpointCompanionDescriptor.cs Generated/SsUsbDeviceCapabilityAttributes.cs Generated/SsUsbDeviceCapabilityDescriptor.cs Generated/StandardRequest.cs Generated/SupportedSpeed.cs Generated/Transfer.cs Generated/TransferDelegate.cs Generated/TransferFlags.cs Generated/TransferStatus.cs Generated/TransferType.cs Generated/Usb20ExtensionAttributes.cs Generated/Usb20ExtensionDescriptor.cs Generated/Version.cs Info/UsbBaseInfo.cs Info/UsbConfigInfo.cs Info/UsbDeviceInfo.cs Info/UsbEndpointInfo.cs Info/UsbInterfaceInfo.cs LibUsb/AsyncTransfer.cs LibUsb/ErrorExtensions.cs LibUsb/IUsbContext.cs LibUsb/IUsbDevice.cs LibUsb/UnixNativeTimeval.cs LibUsb/UsbContext.cs LibUsb/UsbDevice.cs LibUsb/UsbDevice.Device.cs LibUsb/UsbDevice.DeviceHandle.cs LibUsb/UsbDevice.Endpoints.cs LibUsb/UsbDevice.Interfaces.cs LibUsb/UsbDeviceCollection.cs LibUsb/UsbEndpointBase.cs LibUsb/UsbEndpointReader.cs LibUsb/UsbEndpointWriter.cs LibUsb/UsbException.cs Main/EndpointType.cs Main/Helper.cs Main/PinnedHandle.cs Main/ReadEndpointID.cs Main/SafeContextHandle.cs Main/UsbConstants.cs Main/UsbCtrlFlags.cs Main/UsbDeviceFinder.cs Main/UsbRequestRecipient.cs Main/UsbRequestType.cs Main/UsbSetupPacket.cs Main/UsbStream.cs Main/WriteEndpointID.cs "obj/Debug/netstandard2.0/.NETStandard,Version=v2.0.AssemblyAttributes.cs" obj/Debug/netstandard2.0/LibUsbDotNet.AssemblyInfo.cs /warnaserror+:NU1605
        Using shared compilation with compiler from directory: /Applications/Visual Studio.app/Contents/Resources/lib/monodevelop/bin/MSBuild/Current/bin/Roslyn
        /Users/mcuee/build/libusb/LibUsbDotNet/src/LibUsbDotNet/Generated/HotplugCallbackFn.cs(37,45,37,68): error CS0117: 'NativeMethods' does not contain a definition for 'LibUsbCallingConvention'
        /Users/mcuee/build/libusb/LibUsbDotNet/src/LibUsbDotNet/Generated/TransferDelegate.cs(37,45,37,68): error CS0117: 'NativeMethods' does not contain a definition for 'LibUsbCallingConvention'
        /Users/mcuee/build/libusb/LibUsbDotNet/src/LibUsbDotNet/Generated/PollfdAddedDelegate.cs(37,45,37,68): error CS0117: 'NativeMethods' does not contain a definition for 'LibUsbCallingConvention'
...

@mcuee mcuee changed the title How to install under macOS Apple Silicon How to build under macOS Apple Silicon Jun 5, 2021
@mcuee
Copy link
Collaborator Author

mcuee commented Jun 5, 2021

Interestingly the old 2.2.8 binary still works under my Mac Mini M1 with Rosetta 2 and Homebrew x86_64 Mono.

build/libusb/LibUsbDotNet_Bin.2.2.8 ❯ mono BenchmarkCon.exe vid=0x04d8 pid=0xfa2e
WARNING: The runtime version supported by this application is unavailable.
Using default runtime: v4.0.30319
LibUsbDotNet USB Benchmark v2.2.8.104
Copyright (c) 2010 Travis Robinson. <libusbdotnet@gmail.com>
website: http://sourceforge.net/projects/libusbdotnet
Benchmark device 04D8:FA2E opened..
Loop Test Information
	Vid / Pid       : 04D8h / FA2Eh
	Interface #     : 00h
	Priority        : Normal
	Buffer Size     : 4096
	Buffer Count    : 1
	Display Refresh : 1000 (ms)
	Transfer Timeout: 5000 (ms)
	Retry Count     : 0
	Verify Data     : Off

Bulk Read (Ep81h) max packet size: 32
Bulk Write (Ep01h) max packet size: 32

While the test is running:
Press 'Q' to quit
Press 'T' for test details
Press 'I' for status information
Press 'R' to reset averages

Press 'Q' to exit, any other key to begin..

Avg. Bytes/s: 307378.55 Transfers: 68 Bytes/s: 307378.55
Avg. Bytes/s: 303850.26 Transfers: 142 Bytes/s: 300678.73
Avg. Bytes/s: 300323.81 Transfers: 214 Bytes/s: 293603.41
Avg. Bytes/s: 303059.95 Transfers: 291 Bytes/s: 310932.91
Avg. Bytes/s: 301035.61 Transfers: 363 Bytes/s: 293122.20
Avg. Bytes/s: 301424.38 Transfers: 437 Bytes/s: 303346.07
Avg. Bytes/s: 302214.12 Transfers: 512 Bytes/s: 306899.24
qAvg. Bytes/s: 298860.72 Transfers: 580 Bytes/s: 275816.99
stopped Ep81h thread.
stopped Ep01h thread.
Loop Test Information
	Vid / Pid       : 04D8h / FA2Eh
	Interface #     : 00h
	Priority        : Normal
	Buffer Size     : 4096
	Buffer Count    : 1
	Display Refresh : 1000 (ms)
	Transfer Timeout: 5000 (ms)
	Retry Count     : 0
	Verify Data     : Off

Bulk Read (Ep81h) max packet size: 32
	Total Bytes     : 2379776
	Total Transfers : 581
	Avg. Bytes/sec  : 298453.02
	Elapsed Time    : 7.97 seconds

Bulk Write (Ep01h) max packet size: 32
	Total Bytes     : 2379776
	Total Transfers : 581
	Avg. Bytes/sec  : 298844.74
	Elapsed Time    : 7.96 seconds

Press any key to exit..

@mcuee
Copy link
Collaborator Author

mcuee commented Jun 5, 2021

Mono info.

build/libusb/LibUsbDotNet_Bin.2.2.8 took 11s ❯ which mono
/usr/local/bin/mono
build/libusb/LibUsbDotNet_Bin.2.2.8 ❯ mono --version
Mono JIT compiler version 6.12.0.122 (tarball Wed Feb 24 16:02:31 GMT 2021)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
	TLS:
	SIGSEGV:       altstack
	Notification:  kqueue
	Architecture:  amd64
	Disabled:      none
	Misc:          softdebug
	Interpreter:   yes
	LLVM:          supported, not enabled.
	Suspend:       hybrid
	GC:            sgen (concurrent by default)

@mcuee
Copy link
Collaborator Author

mcuee commented Jun 5, 2021

I can actually Mono xbuild to build 2.2.8 source.


BenchmarkCon/bin/Debug ❯ which xbuild
/Library/Frameworks/Mono.framework/Versions/Current/Commands/xbuild
BenchmarkCon/bin/Debug ❯ ls
BenchmarkCon.exe        BenchmarkCon.pdb        LibUsbDotNet.pdb
BenchmarkCon.exe.config LibUsbDotNet.dll
BenchmarkCon/bin/Debug ❯ cp /usr/local/lib/libusb-1.0.dylib .
BenchmarkCon/bin/Debug ❯ ls
BenchmarkCon.exe        BenchmarkCon.pdb        LibUsbDotNet.pdb
BenchmarkCon.exe.config LibUsbDotNet.dll        libusb-1.0.dylib
BenchmarkCon/bin/Debug ❯ mono BenchmarkCon.exe vid=0x04d8 pid=0xfa2e
WARNING: The runtime version supported by this application is unavailable.
Using default runtime: v4.0.30319
LibUsbDotNet USB Benchmark v2.2.8.104
Copyright (c) 2010 Travis Robinson. <libusbdotnet@gmail.com>
website: http://sourceforge.net/projects/libusbdotnet
Benchmark device 04D8:FA2E opened..
Loop Test Information
	Vid / Pid       : 04D8h / FA2Eh
	Interface #     : 00h
	Priority        : Normal
	Buffer Size     : 4096
	Buffer Count    : 1
	Display Refresh : 1000 (ms)
	Transfer Timeout: 5000 (ms)
	Retry Count     : 0
	Verify Data     : Off

Bulk Read (Ep81h) max packet size: 32
Bulk Write (Ep01h) max packet size: 32

While the test is running:
Press 'Q' to quit
Press 'T' for test details
Press 'I' for status information
Press 'R' to reset averages

Press 'Q' to exit, any other key to begin..

Avg. Bytes/s: 306858.06 Transfers: 68 Bytes/s: 306858.06
Avg. Bytes/s: 297491.27 Transfers: 140 Bytes/s: 289155.21
Avg. Bytes/s: 299738.26 Transfers: 215 Bytes/s: 304024.77
Avg. Bytes/s: 300723.37 Transfers: 289 Bytes/s: 303622.59
Avg. Bytes/s: 300756.17 Transfers: 363 Bytes/s: 300884.38
Avg. Bytes/s: 300108.49 Transfers: 435 Bytes/s: 296885.10
Avg. Bytes/s: 300569.01 Transfers: 510 Bytes/s: 303268.13
qAvg. Bytes/s: 300907.29 Transfers: 584 Bytes/s: 303259.57
stopped Ep81h thread.
stopped Ep01h thread.
Loop Test Information
	Vid / Pid       : 04D8h / FA2Eh
	Interface #     : 00h
	Priority        : Normal
	Buffer Size     : 4096
	Buffer Count    : 1
	Display Refresh : 1000 (ms)
	Transfer Timeout: 5000 (ms)
	Retry Count     : 0
	Verify Data     : Off

Bulk Read (Ep81h) max packet size: 32
	Total Bytes     : 2396160
	Total Transfers : 585
	Avg. Bytes/sec  : 300919.80
	Elapsed Time    : 7.96 seconds

Bulk Write (Ep01h) max packet size: 32
	Total Bytes     : 2396160
	Total Transfers : 585
	Avg. Bytes/sec  : 300899.25
	Elapsed Time    : 7.96 seconds

Press any key to exit..

@mcuee
Copy link
Collaborator Author

mcuee commented Jun 6, 2021

Is the following considered a success for the build process under macOS? Sorry I have no clue on dotnet under macOS.

libUsbdotNet on master ❯ dotnet pack src/LibUsbDotNet/LibUsbDotNet.csproj -c Release
Microsoft (R) Build Engine version 16.10.0+4242f381a for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

  Determining projects to restore...
  Restored /Users/mcuee/build/libusb/libusbdotnet_backup/LibUsbDotNet/src/LibUsbDotNet/LibUsbDotNet.csproj (in 676 ms).
  1 of 2 projects are up-to-date for restore.
  LibUsbDotNet -> /Users/mcuee/build/libusb/libusbdotnet_backup/LibUsbDotNet/src/LibUsbDotNet/bin/Release/netstandard2.0/win-x86/LibUsbDotNet.dll
  LibUsbDotNet -> /Users/mcuee/build/libusb/libusbdotnet_backup/LibUsbDotNet/src/LibUsbDotNet/bin/Release/netstandard2.0/win-x64/LibUsbDotNet.dll
  LibUsbDotNet.LibUsb.refs -> /Users/mcuee/build/libusb/libusbdotnet_backup/LibUsbDotNet/src/refs/bin/Release/netstandard2.0/LibUsbDotNet.dll
  LibUsbDotNet -> /Users/mcuee/build/libusb/libusbdotnet_backup/LibUsbDotNet/src/LibUsbDotNet/bin/Release/netcoreapp2.1/linux-arm64/LibUsbDotNet.dll
  LibUsbDotNet -> /Users/mcuee/build/libusb/libusbdotnet_backup/LibUsbDotNet/src/LibUsbDotNet/bin/Release/netcoreapp2.1/win-x86/LibUsbDotNet.dll
  LibUsbDotNet -> /Users/mcuee/build/libusb/libusbdotnet_backup/LibUsbDotNet/src/LibUsbDotNet/bin/Release/netcoreapp2.1/linux-x64/LibUsbDotNet.dll
  LibUsbDotNet -> /Users/mcuee/build/libusb/libusbdotnet_backup/LibUsbDotNet/src/LibUsbDotNet/bin/Release/netcoreapp2.1/osx-x64/LibUsbDotNet.dll
  LibUsbDotNet -> /Users/mcuee/build/libusb/libusbdotnet_backup/LibUsbDotNet/src/LibUsbDotNet/bin/Release/netcoreapp2.1/win-x64/LibUsbDotNet.dll
  LibUsbDotNet -> /Users/mcuee/build/libusb/libusbdotnet_backup/LibUsbDotNet/src/LibUsbDotNet/bin/Release/netstandard2.0/linux-x64/LibUsbDotNet.dll
  LibUsbDotNet -> /Users/mcuee/build/libusb/libusbdotnet_backup/LibUsbDotNet/src/LibUsbDotNet/bin/Release/netstandard2.0/osx-x64/LibUsbDotNet.dll
  LibUsbDotNet -> /Users/mcuee/build/libusb/libusbdotnet_backup/LibUsbDotNet/src/LibUsbDotNet/bin/Release/netstandard2.0/linux-arm/LibUsbDotNet.dll
  LibUsbDotNet -> /Users/mcuee/build/libusb/libusbdotnet_backup/LibUsbDotNet/src/LibUsbDotNet/bin/Release/netcoreapp2.1/linux-arm/LibUsbDotNet.dll
  LibUsbDotNet -> /Users/mcuee/build/libusb/libusbdotnet_backup/LibUsbDotNet/src/LibUsbDotNet/bin/Release/netstandard2.0/linux-arm64/LibUsbDotNet.dll
  LibUsbDotNet.LibUsb.refs -> /Users/mcuee/build/libusb/libusbdotnet_backup/LibUsbDotNet/src/refs/bin/Release/netstandard2.0/LibUsbDotNet.dll

But then the test failed. I am using Rosetta x86_64 emulation here under my Mac Mini M1.

libUsbdotNet on master ❯ dotnet test src/LibUsbDotNet.Tests/LibUsbDotNet.Tests.csproj -p:RuntimeIdentifier=osx.10.12-x64
  Determining projects to restore...
  Restored /Users/mcuee/build/libusb/libusbdotnet_backup/LibUsbDotNet/src/LibUsbDotNet/LibUsbDotNet.csproj (in 555 ms).
  1 of 2 projects are up-to-date for restore.
  LibUsbDotNet -> /Users/mcuee/build/libusb/libusbdotnet_backup/LibUsbDotNet/src/LibUsbDotNet/bin/Debug/netcoreapp2.1/osx.10.12-x64/LibUsbDotNet.dll
  LibUsbDotNet.LibUsb.refs -> /Users/mcuee/build/libusb/libusbdotnet_backup/LibUsbDotNet/src/refs/bin/Debug/netstandard2.0/LibUsbDotNet.dll
  LibUsbDotNet.Tests -> /Users/mcuee/build/libusb/libusbdotnet_backup/LibUsbDotNet/src/LibUsbDotNet.Tests/bin/Debug/netcoreapp3.1/osx.10.12-x64/LibUsbDotNet.Tests.dll
Test run for /Users/mcuee/build/libusb/libusbdotnet_backup/LibUsbDotNet/src/LibUsbDotNet.Tests/bin/Debug/netcoreapp3.1/osx.10.12-x64/LibUsbDotNet.Tests.dll (.NETCoreApp,Version=v3.1)
Microsoft (R) Test Execution Command Line Tool Version 16.10.0
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
The active test run was aborted. Reason: Test host process crashed : Assertion failed: (NULL == darwin_cached_devices.next), function darwin_init, file os/darwin_usb.c, line 587.


Test Run Aborted.

@mcuee
Copy link
Collaborator Author

mcuee commented Jun 6, 2021

My main target is actually to run the examples as I have the associated HW (Benchmark USB device) to carry out the tests. For the old 2.2.8 release (released back in 29-Oct-2010) I can only run the benchmarkcon console application but it is actually the most important app for me. The other GUI examples will just crash.

@mcuee
Copy link
Collaborator Author

mcuee commented Jun 6, 2021

Right now the examples seem to point to .NET Framework 4.5, and not .Net 5.0, or .NetCore 3.1/5.0.

@qmfrederik
Copy link
Contributor

@mcuee "Modern" C#/.NET code should work just fine when compiled for arm/rpi.

This project (still) uses MSBuild.Sdk.Extras, an add-on to the build process, in an attempt to work around some issues which existed when building cross-platform .NET code in the early days of .NET Core.

Updating this has been on my backburner for quite a while (admittedly, too long). Let me see if I can free up time the coming weeks to get this done. It will make things easier for everyone.

The goal still is:

  • To make the .NET bindings just "tiny" wrappers around the native, C code
  • Be compatible with the libusb packages which exist for the various platforms
  • Support all platforms which .NET Core supports
  • Ship with a compiled version of libusb for platforms which don't ship with libusb

@mcuee
Copy link
Collaborator Author

mcuee commented Jun 7, 2021

@qmfrederik That will be great. I would like to use BenchmarkCon to test both libusbdotnet and libusb in Windows/Linux/Mac, I did that last time when I was able to build libusbdotnet using SharpDevelop under Windows and MonoDevelop under Linux/Mac.

@mcuee
Copy link
Collaborator Author

mcuee commented Jun 8, 2021

Here is the build log for BenchmarkCon with latest git under macOS. Looks like Core LibUsbDotNet project is fine but not the example yet.

LibUsbDotNet on  master [!] took 3s ❯ dotnet build src/BenchmarkCon/BenchmarkCon.csproj -c Release
Microsoft (R) Build Engine version 16.10.0+4242f381a for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

  Determining projects to restore...
  Restored /Users/mcuee/build/libusb/LibUsbDotNet/src/BenchmarkCon/BenchmarkCon.csproj (in 207 ms).
  1 of 2 projects are up-to-date for restore.
  LibUsbDotNet -> /Users/mcuee/build/libusb/LibUsbDotNet/src/LibUsbDotNet/bin/Release/netcoreapp3.1/LibUsbDotNet.dll
/Users/mcuee/build/libusb/LibUsbDotNet/src/BenchmarkCon/BenchmarkConsole.cs(126,20): error CS0246: The type or namespace name 'UsbTransfer' could not be found (are you missing a using directive or an assembly reference?) [/Users/mcuee/build/libusb/LibUsbDotNet/src/BenchmarkCon/BenchmarkCon.csproj]

Build FAILED.

/Users/mcuee/build/libusb/LibUsbDotNet/src/BenchmarkCon/BenchmarkConsole.cs(126,20): error CS0246: The type or namespace name 'UsbTransfer' could not be found (are you missing a using directive or an assembly reference?) [/Users/mcuee/build/libusb/LibUsbDotNet/src/BenchmarkCon/BenchmarkCon.csproj]
    0 Warning(s)
    1 Error(s)

@mcuee
Copy link
Collaborator Author

mcuee commented Jun 8, 2021

There is a warning when building main libusbdotnet library.


LibUsbDotNet on  master [!] ❯ dotnet pack src/LibUsbDotNet/LibUsbDotNet.csproj -c Release
Microsoft (R) Build Engine version 16.10.0+4242f381a for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

  Determining projects to restore...
  All projects are up-to-date for restore.
  LibUsbDotNet -> /Users/mcuee/build/libusb/LibUsbDotNet/src/LibUsbDotNet/bin/Release/netcoreapp3.1/LibUsbDotNet.dll
/usr/local/share/dotnet/sdk/5.0.300/Sdks/NuGet.Build.Tasks.Pack/buildCrossTargeting/NuGet.Build.Tasks.Pack.targets(221,5): warning NU5048: The 'PackageIconUrl'/'iconUrl' element is deprecated. Consider using the 'PackageIcon'/'icon' element instead. Learn more at https://aka.ms/deprecateIconUrl [/Users/mcuee/build/libusb/LibUsbDotNet/src/LibUsbDotNet/LibUsbDotNet.csproj]
  Successfully created package '/Users/mcuee/build/libusb/LibUsbDotNet/src/LibUsbDotNet/bin/Release/LibUsbDotNet.3.0.97-alpha.nupkg'.
  Successfully created package '/Users/mcuee/build/libusb/LibUsbDotNet/src/LibUsbDotNet/bin/Release/LibUsbDotNet.3.0.97-alpha.snupkg'.

LibUsbDotNet on  master [!] took 4s ❯ ls -la src/LibUsbDotNet/bin/Release                        
total 96
drwxr-xr-x  5 mcuee  staff    160 Jun  8 20:09 .
drwxr-xr-x  5 mcuee  staff    160 Jun  8 20:09 ..
-rw-r--r--  1 mcuee  staff  26955 Jun  8 20:09 LibUsbDotNet.3.0.97-alpha.nupkg
-rw-r--r--  1 mcuee  staff  18796 Jun  8 20:09 LibUsbDotNet.3.0.97-alpha.snupkg
drwxr-xr-x  5 mcuee  staff    160 Jun  8 20:09 netcoreapp3.1

@qmfrederik
Copy link
Contributor

@mcuee Yes, you are correct. The benchmark library uses async transfers which haven't been ported yet to the 3.0 series. That's causing the errors you are seeing.

On a related note - I'd like to add some sort of integration tests to LibUsbDotNet. Do you have any tips for that? (E.g. a QEMU VM with emulated USB devices, a Linux kernel driver which loads phony devices,...)?

@mcuee
Copy link
Collaborator Author

mcuee commented Jun 9, 2021

Yes from the very beginning of working with Travis Robinson on libusb-win32/libusbdotnet/libusbk back in 2009/2010 time, we were thinking about how to carry out tests, in the end he settled on using PIC MCU based USB examples as both of us were familiar with PIC USB stuff. Later Tarvis ported it to AVR32 as we need high speed USB examples as well and I got the support from Microchip/Atmel with some tools for Travis at that time. Pete Batard (original developer of libusb-1.0 Windows backend) actually ported the example to ARM as well.
https://github.com/mcuee/libusbk/tree/master/BmFW
https://code.google.com/archive/p/usb-travis/downloads (Arduino Due example from Pete)

I admit I knew very little about dotnet so I was not able to support it, but I did use the libusbdotnet benchmark example extensively over the years as a testing tool for my engagement in libusb-1.0 project as it is cross-platform. It is great that you took over libusbdotnet project from Travis.

I was also involved in pyusb and we had similar discussion as well. Right now Jonas has to disable the HW based tests as he does not have the necessary HW. Original pyusb developer adopted the same PIC MCU based approach but new developer does not have the HW. A virtual testing device mentioned by Emmanuel Blot (developer of pyftdi) is interesting.
pyusb/pyusb#235

@mcuee
Copy link
Collaborator Author

mcuee commented Jun 9, 2021

Using a QEMU VM to emulate the USB device may be a good idea if it is possible, I am not familiar with QEMU myself. Or maybe a Raspberry Pi running Linux USB Gadget driver.
https://github.com/torvalds/linux/blob/master/drivers/usb/gadget/function/f_loopback.c
https://www.isticktoit.net/?p=1383
https://www.kernel.org/doc/html/latest/usb/gadget-testing.html

Raspberry Pi Pico may be interesting as well.
https://github.com/raspberrypi/pico-examples/tree/master/usb

Under Windows there is this one (older version of WDK has similar stuff but was obsolete).
https://docs.microsoft.com/en-us/windows-hardware/drivers/usbcon/developing-windows-drivers-for-emulated-usb-host-controllers-and-devices

OLD WDK USB Emulation sample (I tested it last time back in July 2011):
https://community.osr.com/discussion/207981/wdk-dsr-usb-loopback-example-performance

@qmfrederik
Copy link
Contributor

Thanks, @mcuee . Both the Linux loopback driver and the QEMU approach look interesting, then. I'll explore them a bit further.

The QEMU/VirtualBox approach has the advantage that it should be trivial to set up a "standard" test environment which we can use on developer desktops and in CI systems, and we can run the test on different platforms (e.g. Windows or Linux as a guest).

The Linux USB gadget driver/USB loopback device look very interesting because they involve much less overhead. On the other hand, it may be more difficult to deploy to CI environments (we'll have to test).

@qmfrederik
Copy link
Contributor

but I did use the libusbdotnet benchmark example extensively over the years as a testing tool for my engagement in libusb-1.0 project as it is cross-platform

As it stands, the benchmark example doesn't work on the master (v3) branch because async transfers are not implemented. .NET has a new model for async I/O and I would like to see if we can use that model. This will take some time.

I'll have a look at the v2 branch, and see if I can the v2 version to compile correctly with .NET core. It should enable you to use the benchmark tool on all platforms which .NET Core supports. I only want to make changes related to build tooling on the v2 branch, the master branch is for refactoring work.

@mcuee
Copy link
Collaborator Author

mcuee commented Jun 9, 2021

Please refer to #138.

Now you can use v2 branch under macOS if you need async examples. It also works under Windows and Linux.

@mcuee
Copy link
Collaborator Author

mcuee commented Jun 10, 2021

BTW, benchmarkcon can be very flexible and test any FW with loopback FW (interrupt transfer, bulk transfer and isochronous transfer).

Test done back in 2013.

With Cypress's cystream firmware and tested under Mac OS X
Lion 10.7.5 using a Mac Mini 2011 (lowest spec version but
upgradedto 8GB RAM).

Firmware: http://www.cypress.com/?app=forum&id=167&rID=48493
( http://www.cypress.com/?docID=35838 )

Board: An ADC demo board from ADI, just take out the
EEPROM of the Cypress EZ-USB FX2LP and download
the above firmware. The one from Cypress's original
download does not seem to work with a bare board.

  1. Bulk IN:
mymacmini:libusbdotnet xiaofanc$ mono benchmarkcon.exe notestselect
mode=async buffercount=3 buffersize=512000 read list intf=0 altf=2
LibUsbDotNet USB Benchmark v2.2.9.110
Copyright (c) 2010 Travis Robinson. <libusbdotnet@gmail.com>
website: http://sourceforge.net/projects/libusbdotnet
1. 0AC8:3420 Vimicro Corp. - PROLiNK PCC3220
2. 0424:2513
3. 05AC:8006
4. 04B4:1003 Cypress - CY-Stream
5. 046D:C52B Logitech - USB Receiver
6. 05E3:0606 USB2.0 Hub
7. 04F2:0760 Chicony - USB Keyboard
8. 0424:2513
9. 05AC:8006

Select device (1-9) :4

Benchmark device 04B4:1003 opened..
Read Test Information
        Vid / Pid       : 04B4h / 1003h
        Interface #     : 00h
        Alt Interface # : 02h
        Priority        : Normal
        Buffer Size     : 512000
        Buffer Count    : 3
        Display Refresh : 1000 (ms)
        Transfer Timeout: 5000 (ms)
        Retry Count     : 0
        Verify Data     : Off

Bulk Read (Ep82h) max packet size: 512

While the test is running:
Press 'Q' to quit
Press 'T' for test details
Press 'I' for status information
Press 'R' to reset averages

Press 'Q' to exit, any other key to begin..

Avg. Bytes/s: 42361222.34 Transfers: 78 Bytes/s: 42361222.34
Avg. Bytes/s: 42320001.89 Transfers: 161 Bytes/s: 42281337.65
Avg. Bytes/s: 42310223.27 Transfers: 244 Bytes/s: 42291267.97
Avg. Bytes/s: 42305613.48 Transfers: 327 Bytes/s: 42292067.65
Avg. Bytes/s: 42297725.02 Transfers: 409 Bytes/s: 42266296.59
Avg. Bytes/s: 42297154.03 Transfers: 492 Bytes/s: 42294340.58
Avg. Bytes/s: 42295392.80 Transfers: 575 Bytes/s: 42284955.79
Avg. Bytes/s: 42297763.00 Transfers: 657 Bytes/s: 42314390.76
Avg. Bytes/s: 42301449.86 Transfers: 740 Bytes/s: 42330656.46
Avg. Bytes/s: 42302915.56 Transfers: 823 Bytes/s: 42315987.79
Avg. Bytes/s: 42301713.23 Transfers: 906 Bytes/s: 42289794.96
Avg. Bytes/s: 42301286.45 Transfers: 988 Bytes/s: 42296571.66
Avg. Bytes/s: 42291623.03 Transfers: 1071 Bytes/s: 42176931.51
Avg. Bytes/s: 42294080.76 Transfers: 1153 Bytes/s: 42326207.39
Avg. Bytes/s: 42295638.78 Transfers: 1236 Bytes/s: 42317294.07
Avg. Bytes/s: 42296145.17 Transfers: 1319 Bytes/s: 42303687.44
Avg. Bytes/s: 42295165.08 Transfers: 1401 Bytes/s: 42279406.21
Avg. Bytes/s: 42294071.29 Transfers: 1484 Bytes/s: 42275617.21
Avg. Bytes/s: 42295073.27 Transfers: 1567 Bytes/s: 42312996.29
Avg. Bytes/s: 42294467.66 Transfers: 1649 Bytes/s: 42282897.80
Avg. Bytes/s: 42294064.18 Transfers: 1732 Bytes/s: 42286049.76
Avg. Bytes/s: 42295081.65 Transfers: 1815 Bytes/s: 42316324.88
Avg. Bytes/s: 42297401.95 Transfers: 1898 Bytes/s: 42348204.77
Avg. Bytes/s: 42295991.08 Transfers: 1980 Bytes/s: 42263360.81
Avg. Bytes/s: 42296343.01 Transfers: 2063 Bytes/s: 42304740.27
Avg. Bytes/s: 42297118.75 Transfers: 2146 Bytes/s: 42316409.16
Avg. Bytes/s: 42297571.81 Transfers: 2229 Bytes/s: 42309289.11
Avg. Bytes/s: 42297500.03 Transfers: 2311 Bytes/s: 42295549.01
Avg. Bytes/s: 42297181.76 Transfers: 2394 Bytes/s: 42288322.05
Avg. Bytes/s: 42295655.81 Transfers: 2476 Bytes/s: 42251154.05
Avg. Bytes/s: 42296231.67 Transfers: 2559 Bytes/s: 42313417.60
Avg. Bytes/s: 42296041.33 Transfers: 2642 Bytes/s: 42290173.72
Avg. Bytes/s: 42297247.42 Transfers: 2725 Bytes/s: 42335674.80
Avg. Bytes/s: 42298009.45 Transfers: 2807 Bytes/s: 42323348.61
qAvg. Bytes/s: 42298709.36 Transfers: 2890 Bytes/s: 42322393.54
waiting for Ep82h thread..
stopped Ep82h thread.
Read Test Information
        Vid / Pid       : 04B4h / 1003h
        Interface #     : 00h
        Alt Interface # : 02h
        Priority        : Normal
        Buffer Size     : 512000
        Buffer Count    : 3
        Display Refresh : 1000 (ms)
        Transfer Timeout: 5000 (ms)
        Retry Count     : 0
        Verify Data     : Off

Bulk Read (Ep82h) max packet size: 512
        Total Bytes     : 1480192000
        Total Transfers : 2891
        Avg. Bytes/sec  : 42298578.08
        Elapsed Time    : 34.99 seconds

Press any key to exit..
  1. Bulk Out:
mymacmini:libusbdotnet xiaofanc$ mono benchmarkcon.exe notestselect
mode=async buffercount=3 buffersize=512000 write list intf=0 altf=2
LibUsbDotNet USB Benchmark v2.2.9.110
Copyright (c) 2010 Travis Robinson. <libusbdotnet@gmail.com>
website: http://sourceforge.net/projects/libusbdotnet
1. 0AC8:3420 Vimicro Corp. - PROLiNK PCC3220
2. 0424:2513
3. 05AC:8006
4. 04B4:1003 Cypress - CY-Stream
5. 046D:C52B Logitech - USB Receiver
6. 05E3:0606 USB2.0 Hub
7. 04F2:0760 Chicony - USB Keyboard
8. 0424:2513
9. 05AC:8006

Select device (1-9) :4

Benchmark device 04B4:1003 opened..
Write Test Information
        Vid / Pid       : 04B4h / 1003h
        Interface #     : 00h
        Alt Interface # : 02h
        Priority        : Normal
        Buffer Size     : 512000
        Buffer Count    : 3
        Display Refresh : 1000 (ms)
        Transfer Timeout: 5000 (ms)
        Retry Count     : 0
        Verify Data     : Off

Bulk Write (Ep06h) max packet size: 512

While the test is running:
Press 'Q' to quit
Press 'T' for test details
Press 'I' for status information
Press 'R' to reset averages

Press 'Q' to exit, any other key to begin..

Avg. Bytes/s: 33653249.82 Transfers: 62 Bytes/s: 33653249.82
Avg. Bytes/s: 33696334.00 Transfers: 128 Bytes/s: 33736907.63
Avg. Bytes/s: 33711716.76 Transfers: 194 Bytes/s: 33741590.06
Avg. Bytes/s: 33724198.28 Transfers: 260 Bytes/s: 33760939.94
Avg. Bytes/s: 33727165.83 Transfers: 326 Bytes/s: 33738861.29
Avg. Bytes/s: 33726895.56 Transfers: 392 Bytes/s: 33725560.65
Avg. Bytes/s: 33733388.90 Transfers: 458 Bytes/s: 33772006.97
Avg. Bytes/s: 33734434.38 Transfers: 524 Bytes/s: 33741691.14
Avg. Bytes/s: 33734688.42 Transfers: 590 Bytes/s: 33736705.54
Avg. Bytes/s: 33733688.54 Transfers: 656 Bytes/s: 33724752.84
Avg. Bytes/s: 33731763.39 Transfers: 722 Bytes/s: 33712640.44
Avg. Bytes/s: 33740115.41 Transfers: 788 Bytes/s: 33831752.31
Avg. Bytes/s: 33743801.84 Transfers: 854 Bytes/s: 33787877.88
Avg. Bytes/s: 33750047.74 Transfers: 920 Bytes/s: 33831074.89
Avg. Bytes/s: 33754725.81 Transfers: 986 Bytes/s: 33820070.66
Avg. Bytes/s: 33754332.92 Transfers: 1052 Bytes/s: 33748464.48
Avg. Bytes/s: 33759914.85 Transfers: 1118 Bytes/s: 33849137.34
Avg. Bytes/s: 33762226.39 Transfers: 1184 Bytes/s: 33801430.60
Avg. Bytes/s: 33764327.95 Transfers: 1250 Bytes/s: 33802073.02
Avg. Bytes/s: 33763273.15 Transfers: 1316 Bytes/s: 33743308.41
Avg. Bytes/s: 33762098.46 Transfers: 1382 Bytes/s: 33738692.87
Avg. Bytes/s: 33762986.64 Transfers: 1448 Bytes/s: 33781595.27
Avg. Bytes/s: 33780352.80 Transfers: 1515 Bytes/s: 34160083.57
Avg. Bytes/s: 33786154.61 Transfers: 1582 Bytes/s: 33917878.87
Avg. Bytes/s: 33787511.59 Transfers: 1648 Bytes/s: 33820070.66
Avg. Bytes/s: 33787615.46 Transfers: 1714 Bytes/s: 33790209.12
Avg. Bytes/s: 33786114.57 Transfers: 1780 Bytes/s: 33747183.74
Avg. Bytes/s: 33785083.43 Transfers: 1846 Bytes/s: 33757297.50
Avg. Bytes/s: 33782308.29 Transfers: 1912 Bytes/s: 33704872.90
Avg. Bytes/s: 33782498.61 Transfers: 1978 Bytes/s: 33788013.01
Avg. Bytes/s: 33779467.52 Transfers: 2044 Bytes/s: 33688878.34
Avg. Bytes/s: 33777754.53 Transfers: 2109 Bytes/s: 33723976.15
Avg. Bytes/s: 33774517.01 Transfers: 2175 Bytes/s: 33671389.08
Avg. Bytes/s: 33773335.60 Transfers: 2241 Bytes/s: 33734449.03
Avg. Bytes/s: 33771535.33 Transfers: 2307 Bytes/s: 33710521.67
Avg. Bytes/s: 33771064.07 Transfers: 2373 Bytes/s: 33754599.90
Avg. Bytes/s: 33769935.23 Transfers: 2439 Bytes/s: 33729398.24
Avg. Bytes/s: 33769135.34 Transfers: 2505 Bytes/s: 33739602.40
Avg. Bytes/s: 33766695.23 Transfers: 2571 Bytes/s: 33674341.85
Avg. Bytes/s: 33765846.03 Transfers: 2637 Bytes/s: 33732798.94
Avg. Bytes/s: 33765091.06 Transfers: 2703 Bytes/s: 33734954.19
Avg. Bytes/s: 33763252.00 Transfers: 2769 Bytes/s: 33688105.88
Avg. Bytes/s: 33761786.95 Transfers: 2835 Bytes/s: 33700435.92
Avg. Bytes/s: 33760922.01 Transfers: 2901 Bytes/s: 33723810.46
Avg. Bytes/s: 33759345.95 Transfers: 2966 Bytes/s: 33689154.78
qAvg. Bytes/s: 33758200.16 Transfers: 3032 Bytes/s: 33706789.24
waiting for Ep06h thread..
stopped Ep06h thread.
Write Test Information
        Vid / Pid       : 04B4h / 1003h
        Interface #     : 00h
        Alt Interface # : 02h
        Priority        : Normal
        Buffer Size     : 512000
        Buffer Count    : 3
        Display Refresh : 1000 (ms)
        Transfer Timeout: 5000 (ms)
        Retry Count     : 0
        Verify Data     : Off

Bulk Write (Ep06h) max packet size: 512
        Total Bytes     : 1552896000
        Total Transfers : 3033
        Avg. Bytes/sec  : 33758522.83
        Elapsed Time    : 46.00 seconds

Press any key to exit..

@mcuee mcuee added Build Nuget, Solution and Project files related Examples Related to built-in examples FAQ Frequently Asked Questions labels Jun 11, 2021
@mcuee mcuee closed this as completed Jun 11, 2021
@mcuee mcuee reopened this Jun 11, 2021
@mcuee
Copy link
Collaborator Author

mcuee commented Jun 15, 2021

Somehow this no longer works (CyStreamer FW) since I can not change to a different alternative interface. I will need to check again.

@mcuee
Copy link
Collaborator Author

mcuee commented Jun 27, 2021

I have made some progress with Linux USB Gadget here. Still learning how to configure the usb gadget. The HW devices are really cheap (eg: Raspberry Pi Zero, Orange Pi Zero).
pyusb/pyusb#235

@mcuee
Copy link
Collaborator Author

mcuee commented Jul 22, 2021

@qmfrederik I will highly recommend the following US$49 Cypress FX3 development board.
https://www.cypress.com/documentation/development-kitsboards/cyusb3kit-003-ez-usb-fx3-superspeed-explorer-kit

@mcuee
Copy link
Collaborator Author

mcuee commented Jul 22, 2021

Benchmarkcon results under my Mac Mini M1 (8GB RAM, 256GB SSD).


libusbdotnet_v2 on  v2 took 18s ❯ ./stage/BenchmarkCon/bin/Release/net5.0/BenchmarkCon list notestselect buffercount=3 buffersize=32768 loop mode=async
LibUsbDotNet USB Benchmark v2.2.0.0
Copyright (c) 2010 Travis Robinson. <libusbdotnet@gmail.com>
website: http://sourceforge.net/projects/libusbdotnet
1. 04B4:00F1 Cypress - FX3
2. 046D:C52B Logitech - USB Receiver
3. 047F:C025 Plantronics C320-M
4. 1A40:0201 
5. 0AC8:3420 Vimicro Corp. - PROLiNK PCC3220
6. 1A40:0201 
7. 0BDA:5411 Generic - 4-Port USB 2.0 Hub
8. 05E3:0749 Generic - USB3.0 Card Reader
9. 0BDA:0411 Generic - 4-Port USB 3.0 Hub
10. 0BDA:0411 Generic - 4-Port USB 3.0 Hub
11. 0BDA:5411 Generic - 4-Port USB 2.0 Hub

Select device (1-11) :1

Benchmark device 04B4:00F1 opened..
Loop Test Information
	Vid / Pid       : 04B4h / 00F1h
	Interface #     : 00h
	Alt Interface # : 00h
	Priority        : Normal
	Buffer Size     : 32768
	Buffer Count    : 3
	Display Refresh : 1000 (ms)
	Transfer Timeout: 5000 (ms)
	Retry Count     : 0
	Verify Data     : Off

Bulk Read (Ep81h) max packet size: 1024
Bulk Write (Ep01h) max packet size: 1024

While the test is running:
Press 'Q' to quit
Press 'T' for test details
Press 'I' for status information
Press 'R' to reset averages

Press 'Q' to exit, any other key to begin..
Avg. Bytes/s: 281226203.00 Transfers: 8086 Bytes/s: 281226203.00
Avg. Bytes/s: 288942931.94 Transfers: 17199 Bytes/s: 296153452.65
Avg. Bytes/s: 291884573.12 Transfers: 26336 Bytes/s: 297587420.67
Avg. Bytes/s: 293362093.71 Transfers: 35470 Bytes/s: 297707201.40
Avg. Bytes/s: 294178361.38 Transfers: 44600 Bytes/s: 297393131.68
Avg. Bytes/s: 294741105.78 Transfers: 53733 Bytes/s: 297520426.37
Avg. Bytes/s: 295190625.51 Transfers: 62869 Bytes/s: 297862455.43
Avg. Bytes/s: 295488757.12 Transfers: 72000 Bytes/s: 297557922.46
Avg. Bytes/s: 295693625.44 Transfers: 81130 Bytes/s: 297319243.79
Avg. Bytes/s: 295910920.67 Transfers: 90252 Bytes/s: 297857662.74
Avg. Bytes/s: 296073306.84 Transfers: 99385 Bytes/s: 297687636.52
Avg. Bytes/s: 296204760.63 Transfers: 108519 Bytes/s: 297642661.24
Avg. Bytes/s: 296320007.38 Transfers: 117654 Bytes/s: 297695970.59
Avg. Bytes/s: 296410631.73 Transfers: 126781 Bytes/s: 297583831.34
qAvg. Bytes/s: 296493732.55 Transfers: 135920 Bytes/s: 297651376.26
stopped Ep81h thread.
stopped Ep01h thread.
Loop Test Information
	Vid / Pid       : 04B4h / 00F1h
	Interface #     : 00h
	Alt Interface # : 00h
	Priority        : Normal
	Buffer Size     : 32768
	Buffer Count    : 3
	Display Refresh : 1000 (ms)
	Transfer Timeout: 5000 (ms)
	Retry Count     : 0
	Verify Data     : Off

Bulk Read (Ep81h) max packet size: 1024
	Total Bytes     : 4453859328
	Total Transfers : 135921
	Avg. Bytes/sec  : 296490308.47
	Elapsed Time    : 15.02 seconds

Bulk Write (Ep01h) max packet size: 1024
	Total Bytes     : 4822728704
	Total Transfers : 147178
	Avg. Bytes/sec  : 321044531.44
	Elapsed Time    : 15.02 seconds

Press any key to exit..

@mcuee
Copy link
Collaborator Author

mcuee commented Sep 16, 2021

Thanks, @mcuee . Both the Linux loopback driver and the QEMU approach look interesting, then. I'll explore them a bit further.

The QEMU/VirtualBox approach has the advantage that it should be trivial to set up a "standard" test environment which we can use on developer desktops and in CI systems, and we can run the test on different platforms (e.g. Windows or Linux as a guest).

The Linux USB gadget driver/USB loopback device look very interesting because they involve much less overhead. On the other hand, it may be more difficult to deploy to CI environments (we'll have to test).

@qmfrederik
Maybe the dummy_hcd module will make it work. That is a software emulated device controller which works on normal Linux PC.
Please take a look at this discussion: vpelletier/python-functionfs#20

@mcuee mcuee changed the title How to build under macOS Apple Silicon Testing under macOS Apple Silicon Jan 30, 2022
@mcuee
Copy link
Collaborator Author

mcuee commented May 8, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Build Nuget, Solution and Project files related Examples Related to built-in examples FAQ Frequently Asked Questions
Projects
None yet
Development

No branches or pull requests

2 participants