eb4e5c6a3b405a07b05140fbf44c2993216f3c2a
[platform/core/csapi/usb.git] / Tizen.System.Usb / Usb / UsbInterruptEndpoint.cs
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 namespace Tizen.System.Usb
18 {
19     /// <summary>
20     /// USB Interrupt Endpoint class
21     /// </summary>
22     public class UsbInterruptEndpoint : UsbEndpoint
23     {
24         internal UsbInterruptEndpoint(Interop.UsbEndpointHandle handle) : base(handle)
25         {
26         }
27
28         /// <summary>
29         /// Gets interval for polling endpoint for data transfers, in frame counts (refer to USB protocol specification)
30         /// </summary>
31         public int PollingInterval
32         {
33             get
34             {
35                 return Interop.NativeGet<int>(_handle.GetInterval);
36             }
37         }
38
39         /// <summary>
40         /// Performs a USB transfer on given endpoint. Direction of transfer is determined by the endpoint.
41         /// </summary>
42         /// <param name="buffer">Suitably-sized data buffer for either input or output (depending on endpoint)</param>
43         /// <param name="length">
44         /// For writes, the number of bytes from data to be sent, for reads the maximum number of bytes to receive
45         /// into the data buffer
46         /// </param>
47         /// <param name="timeout">
48         /// Timeout (in milliseconds) that this function should wait before giving up due to no response being
49         /// received(for an unlimited timeout 0 value should be used)
50         /// </param>
51         /// <returns>transferred number of bytes actually transferred</returns>
52         /// <exception cref="InvalidOperationException">Throws excetion if device is disconnected or not opened for operation</exception>
53         /// <exception cref="TimeoutException">Throws excetion if transfer timed-out</exception>
54         public int Transfer(byte[] buffer, int length, uint timeout)
55         {
56             return TransferImpl(buffer, length, timeout);
57         }
58     }
59 }