public static async Task <USBDevice> SelectConfiguration(this USBDevice device, byte configuration) { var updatedDevice = await device.USB.JSRuntime.InvokeAsync <USBDevice>(SELECT_CONFIGURATION_METHOD, device, configuration); updatedDevice.AttachUSB(device.USB); return(updatedDevice); }
public static async Task <USBDevice> ClaimInterface(this USBDevice device, byte interfaceNumber) { var updatedDevice = await device.USB.JSRuntime.InvokeAsync <USBDevice>(CLAIM_INTERFACE_METHOD, device, interfaceNumber); updatedDevice.AttachUSB(device.USB); return(updatedDevice); }
public static async Task <USBDevice> Reset(this USBDevice device) { var updatedDevice = await device.USB.JSRuntime.InvokeAsync <USBDevice>(RESET_DEVICE_METHOD, device); updatedDevice.AttachUSB(device.USB); return(updatedDevice); }
public async Task <USBDevice> RequestDevice(USBDeviceRequestOptions options = null) { var internalOptions = new _USBDeviceRequestOptions(); if (options != null) { internalOptions.filters = options.Filters.Select(f => new _USBDeviceFilter { classCode = f.ClassCode, productId = f.ProductId, protocolCode = f.ProtocolCode, serialNumber = f.SerialNumber, subClassCode = f.SubClassCode, vendorId = f.VendorId }).ToList(); } else { internalOptions.filters = _emptyFilters; } USBDevice device = null; try { device = await JSRuntime.Current.InvokeAsync <USBDevice>(REQUEST_DEVICE_METHOD, internalOptions); } catch (Exception ex) { Console.WriteLine(ex.GetBaseException().Message); } return(device); }
public static async Task <USBDevice> SelectAlternateInterface(this USBDevice device, byte interfaceNumber, byte alternateSetting) { var updatedDevice = await device.USB.JSRuntime.InvokeAsync <USBDevice>(SELECT_ALTERNATE_INTERFACE_METHOD, device, interfaceNumber, alternateSetting); updatedDevice.AttachUSB(device.USB); return(updatedDevice); }
public static async Task <USBDevice> ClearHalt(this USBDevice device, string direction, byte endpointNumber) { var updatedDevice = await device.USB.JSRuntime.InvokeAsync <USBDevice>(CLEAR_HALT_METHOD, device, direction, endpointNumber); updatedDevice.AttachUSB(device.USB); return(updatedDevice); }
public static Task <USBInTransferResult> TransferIn(this USBDevice device, USBEndpoint endpoint, long length) { if (endpoint == null) { throw new ArgumentNullException(nameof(endpoint)); } return(device.TransferIn(endpoint.EndpointNumber, length)); }
public Task Disconnected(USBDevice device) { if (this.OnDisconnect != null && this.OnDisconnect.GetInvocationList().Length > 0) { this.OnDisconnect.Invoke(device); } return(Task.CompletedTask); }
public static Task <USBDevice> ClearHalt(this USBDevice device, USBEndpoint endpoint) { if (endpoint == null) { throw new ArgumentNullException(nameof(endpoint)); } return(device.ClearHalt(endpoint.Direction, endpoint.EndpointNumber)); }
public static Task <USBDevice> SelectConfiguration(this USBDevice device, USBConfiguration configuration) { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } return(device.SelectConfiguration(configuration.ConfigurationValue)); }
public static Task <USBDevice> ReleaseInterface(this USBDevice device, USBInterface usbInterface) { if (usbInterface == null) { throw new ArgumentNullException(nameof(usbInterface)); } return(device.ReleaseInterface(usbInterface.InterfaceNumber)); }
public static Task <USBDevice> ReleaseBulkInterface(this USBDevice device) { var bulkInterface = device.Configuration.Interfaces.FirstOrDefault(i => i.Alternates.Any(a => a.Endpoints.Any(e => e.Type == USBEndpointType.Bulk))); if (bulkInterface == null) { throw new InvalidOperationException("This devices doesn't have a Bulk interface"); } return(device.ReleaseInterface(bulkInterface.InterfaceNumber)); }
public static Task <USBDevice> SelectAlternateInterface(this USBDevice device, USBInterface usbInterface, USBAlternateInterface usbAlternateInterface) { if (usbInterface == null) { throw new ArgumentNullException(nameof(usbInterface)); } if (usbAlternateInterface == null) { throw new ArgumentNullException(nameof(usbAlternateInterface)); } return(device.SelectAlternateInterface(usbInterface.InterfaceNumber, usbAlternateInterface.AlternateSetting)); }
internal static void AttachUSB(this USBDevice device, USB usb) => device.USB = usb;
public static Task <USBDevice> ClaimInterface(this USBDevice device, byte interfaceNumber) { return(JSRuntime.Current.InvokeAsync <USBDevice>(CLAIM_INTERFACE_METHOD, device, interfaceNumber)); }
public static Task <USBDevice> ClearHalt(this USBDevice device, string direction, byte endpointNumber) { return(JSRuntime.Current.InvokeAsync <USBDevice>(CLEAR_HALT_METHOD, device, direction, endpointNumber)); }
public static Task <USBInTransferResult> TransferIn(this USBDevice device, byte endpointNumber, long length) { return(JSRuntime.Current.InvokeAsync <USBInTransferResult>(TRANSFER_IN_METHOD, device, endpointNumber, length)); }
public static Task <USBDevice> SelectConfiguration(this USBDevice device, byte configuration) { return(JSRuntime.Current.InvokeAsync <USBDevice>(SELECT_CONFIGURATION_METHOD, device, configuration)); }
public static Task <USBDevice> Reset(this USBDevice device) => JSRuntime.Current.InvokeAsync <USBDevice>(RESET_DEVICE_METHOD, device);
public static Task <USBOutTransferResult> TransferOut(this USBDevice device, USBEndpoint endpoint, byte[] data) { return(device.TransferOut(endpoint.EndpointNumber, data)); }
public static Task <USBOutTransferResult> TransferOut(this USBDevice device, byte endpointNumber, byte[] data) { return(JSRuntime.Current.InvokeAsync <USBOutTransferResult>(TRANSFER_OUT_METHOD, device, endpointNumber, data)); }
public static Task <USBDevice> ReleaseInterface(this USBDevice device, byte interfaceNumber) { return(JSRuntime.Current.InvokeAsync <USBDevice>(RELEASE_INTERFACE_METHOD, device, interfaceNumber)); }
public static Task <USBInTransferResult> ControlTransferIn(this USBDevice device, USBControlTransferParameters setup, long length) { return(JSRuntime.Current.InvokeAsync <USBInTransferResult>(CONTROL_TRANSFER_IN_METHOD, device, setup, length)); }
public static Task <USBDevice> Open(this USBDevice device) => JSRuntime.Current.InvokeAsync <USBDevice>(OPEN_DEVICE_METHOD, device);
public static Task <USBDevice> Close(this USBDevice device) => JSRuntime.Current.InvokeAsync <USBDevice>(CLOSE_DEVICE_METHOD, device);
public static Task <USBOutTransferResult> ControlTransferOut(this USBDevice device, USBControlTransferParameters setup, byte[] data) { return(JSRuntime.Current.InvokeAsync <USBOutTransferResult>(CONTROL_TRANSFER_OUT_METHOD, device, setup, data)); }
public static Task <USBDevice> SelectAlternateInterface(this USBDevice device, byte interfaceNumber, byte alternateSetting) { return(JSRuntime.Current.InvokeAsync <USBDevice>(SELECT_ALTERNATE_INTERFACE_METHOD, device, interfaceNumber, alternateSetting)); }