2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 namespace Tizen.System.Usb
22 /// USB Endpoint class
24 public class UsbEndpoint
26 internal readonly Interop.UsbEndpointHandle _handle;
28 internal UsbEndpoint(Interop.UsbEndpointHandle handle)
34 /// Gets number of this endpoint
40 return Interop.NativeGet<int>(_handle.GetNumber);
45 /// Gets direction of this endpoint
47 public EndpointDirection Direction
51 return (EndpointDirection)Interop.NativeGet<Interop.EndpointDirection>(_handle.GetDirection);
56 /// Gets max packet size of given endpoint
58 public int MaxPacketSize
62 return Interop.NativeGet<int>(_handle.GetMaxPacketSize);
66 protected int TransferImpl(byte[] buffer, int length, uint timeout)
69 _handle.Transfer(buffer, length, out transferred, timeout).ThrowIfFailed("Transfer failed");
73 internal static UsbEndpoint EndpointFactory(Interop.UsbEndpointHandle handle)
75 Interop.TransferType transferType;
76 handle.GetTransferType(out transferType).ThrowIfFailed("Failed to get transfer type from endpoint");
79 case Interop.TransferType.Bulk: return new UsbBulkEndpoint(handle);
80 case Interop.TransferType.Interrupt: return new UsbInterruptEndpoint(handle);
81 case Interop.TransferType.Isochronous: return new UsbIsochronousEndpoint(handle);
82 default: return new UsbEndpoint(handle);