Skip to content

Linux/OSX Raw API Libraries #5

Open
@MelbourneDeveloper

Description

@MelbourneDeveloper

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.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions