Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Somehow return actual number of bytes read? #85
When calling ReadAsync(), it would be nice to know how many bytes were actually read. In some cases, especially with Bulk transfers, its possible to receive less bytes than the requested number of bytes from the USB device based on the protocol being used. Would it would be possible to add an optional parameter that would return the number of bytes actually read? Right now it looks to just be zero filled.
Good call on this.
Should the array be truncated to the size returned?
Should the result be a list and that list be truncated?
Should the result be a struct with the count?
For maintainability I would say truncate, but for performance struct. Generally I prefer maintainability over performance...
My initial thought was truncating the size of the byte array returned, but for larger data transfers that could be a significant performance hit. Really, just need the ability to obtain the number of actual bytes read - this could just be an 'int' defined in IDevice. Same thing could be added for WriteAsync(), to get the actual number of bytes written (although probably not as necessary).