bulkTransferIn method
Implementation
@override
Future<Uint8List> bulkTransferIn(
UsbEndpoint endpoint, int maxLength, int timeout) async {
assert(_devHandle != null, 'Device not open');
assert(endpoint.direction == UsbEndpoint.DIRECTION_IN,
'Endpoint\'s direction should be in');
var actualLengthPtr = ffi.calloc<Int32>();
var dataPtr = ffi.calloc<Uint8>(maxLength);
try {
var result = _libusb.libusb_bulk_transfer(
_devHandle!,
endpoint.endpointAddress,
dataPtr,
maxLength,
actualLengthPtr,
timeout,
);
if (result != libusb_error.LIBUSB_SUCCESS) {
throw 'bulkTransferIn error: ${_libusb.describeError(result)}';
}
return Uint8List.fromList(dataPtr.asTypedList(actualLengthPtr.value));
} finally {
ffi.calloc.free(actualLengthPtr);
ffi.calloc.free(dataPtr);
}
}