MelbourneDeveloper / Device.Net

A C# cross platform connected device framework
MIT License
619 stars 119 forks source link

Use WinUsb_GetPipePolicy #72

Open MelbourneDeveloper opened 5 years ago

MelbourneDeveloper commented 5 years ago

Seems like the method for getting buffer sizes for Usb on Windows is wrong.

    The buffer length must be a multiple of the maximum endpoint packet size.
    The length must be less than or equal to the value of MAXIMUM_TRANSFER_SIZE retrieved by WinUsb_GetPipePolicy.

There are no restrictions on the size of the buffer if RAW_IO is not set as the pipe's policy type. If the size of the buffer is greater than the maximum transfer length reported by MAXIMUM_TRANSFER_SIZE, WinUSB divides the request into smaller requests and submits them serially to the host controller.

https://docs.microsoft.com/en-us/windows/desktop/api/winusb/nf-winusb-winusb_writepipe#remarks

Raised here: https://github.com/MelbourneDeveloper/Device.Net/issues/67#issuecomment-507046234

MelbourneDeveloper commented 5 years ago

@realivanjx

This is based on your comment. I will try to fix this soon.