Device.Net icon indicating copy to clipboard operation
Device.Net copied to clipboard

Linux/OSX Raw API Libraries

Open MelbourneDeveloper opened this issue 7 years ago • 2 comments

Linux and MacOS are now supported. See this wiki entry. However, this has been done via LibUsbDotNet. I'd like to build libraries that are not dependent on LibUsbDotNet, and possibly not dependent on LibUsb. Contributions on this are very welcome.

The UsbDevice is a base class that doesn't depends on IUsbInterfaceManager to inject the platform specifics in. The IUsbInterface class is where the platform specifics need to be implemented:

    public interface IUsbInterface : IDisposable
    {
        IUsbInterfaceEndpoint ReadEndpoint { get; set; }
        IList<IUsbInterfaceEndpoint> UsbInterfaceEndpoints { get; }
        IUsbInterfaceEndpoint WriteEndpoint { get; set; }
        IUsbInterfaceEndpoint InterruptWriteEndpoint { get; set; }
        IUsbInterfaceEndpoint InterruptReadEndpoint { get; set; }
        //TODO: Remove these. They should come from the endpoint... or be specified there
        ushort ReadBufferSize { get; }
        ushort WriteBufferSize { get; }
        Task WriteAsync(byte[] data, CancellationToken cancellationToken = default);
        Task<ReadResult> ReadAsync(uint bufferLength, CancellationToken cancellationToken = default);
        byte InterfaceNumber { get; }
        Task ClaimInterface();

        /// <summary>
        /// This is for internal use and should need to be called. This will probably be removed in future versions.
        /// TODO
        /// </summary>
        void RegisterDefaultEndpoints();
    }

The WindowsUsbInterface is an example of such an interface.

Bare in mind that these interfaces are quite cluttered and need some work, so refactoring is always an option.

MelbourneDeveloper avatar Jul 25 '18 22:07 MelbourneDeveloper

I have LibUsb working on MacOS. I am now building a bridge library (#35) between Device.Net and LibUsb so that it can be used for Hid/USB access on Mac.

MelbourneDeveloper avatar Feb 02 '19 23:02 MelbourneDeveloper

There is now a MacOS sample part of Device.Net.LibUsb. It works. However, I'd still like to build a clean library from the ground up. I'd like it if someone would have a go at this. LibUsb is just a stop gap measure for now.

MelbourneDeveloper avatar Feb 03 '19 20:02 MelbourneDeveloper