/// <summary> /// Opens an endpoint for writing /// </summary> /// <param name="writeEndpointID">Endpoint number for read operations.</param> /// <param name="endpointType">The type of endpoint to open.</param> /// <returns>A <see cref="UsbEndpointWriter"/> class ready for writing. If the specified endpoint is already been opened, the original <see cref="UsbEndpointWriter"/> class is returned.</returns> public virtual UsbEndpointWriter OpenEndpointWriter(WriteEndpointID writeEndpointID, EndpointType endpointType) { foreach (UsbEndpointBase activeEndpoint in ActiveEndpoints) { if (activeEndpoint.EpNum == (byte)writeEndpointID) { return((UsbEndpointWriter)activeEndpoint); } } UsbEndpointWriter epNew = new UsbEndpointWriter(this, writeEndpointID, endpointType); return((UsbEndpointWriter)mActiveEndpoints.Add(epNew)); }
/// <summary> /// Opens an endpoint for writing /// </summary> /// <param name="writeEndpointID">Endpoint number for read operations.</param> /// <param name="endpointType">The type of endpoint to open.</param> /// <returns>A <see cref="UsbEndpointWriter"/> class ready for writing. If the specified endpoint is already been opened, the original <see cref="UsbEndpointWriter"/> class is returned.</returns> public virtual UsbEndpointWriter OpenEndpointWriter(WriteEndpointID writeEndpointID, EndpointType endpointType) { foreach (UsbEndpointBase activeEndpoint in ActiveEndpoints) { if (activeEndpoint.EpNum == (byte)writeEndpointID) { return((UsbEndpointWriter)activeEndpoint); } } byte altIntefaceID = mClaimedInterfaces.Count == 0 ? UsbAltInterfaceSettings[0] : UsbAltInterfaceSettings[mClaimedInterfaces[mClaimedInterfaces.Count - 1]]; UsbEndpointWriter epNew = new UsbEndpointWriter(this, altIntefaceID, writeEndpointID, endpointType); return((UsbEndpointWriter)mActiveEndpoints.Add(epNew)); }
/// <summary> /// Opens an endpoint for reading /// </summary> /// <param name="readEndpoint">Endpoint number for read operations.</param> /// <param name="readBufferSize">Size of the read buffer allocated for the <see cref="UsbEndpointReader.DataReceived"/> event.</param> /// <returns>An <see cref="UsbEndpointReader"/> class ready for reading. /// If the specified endpoint has allready been opened, the original <see cref="UsbEndpointReader"/> object will be returned. /// </returns> public UsbEndpointReader OpenBulkEndpointReader(ReadEndpoints readEndpoint, int readBufferSize) { UsbEndpointReader epNew = new UsbEndpointReader(this, EndpointTypes.Bulk, 0, readBufferSize, readEndpoint); return((UsbEndpointReader)mActiveEndpoints.Add(epNew)); }