--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.System.Usb
+{
+ /// <summary>
+ /// Enumeration of isochronous endpoint's synchronization type
+ /// </summary>
+ public enum SynchronizationType
+ {
+ /// <summary>
+ /// Asynchronous
+ /// </summary>
+ Asynchronous = Interop.SynchronizationType.Async,
+ /// <summary>
+ /// Adaptive
+ /// </summary>
+ Adaptive = Interop.SynchronizationType.Adaptive,
+ /// <summary>
+ /// Synchronous
+ /// </summary>
+ Synchronous = Interop.SynchronizationType.Sync,
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.System.Usb
+{
+ /// <summary>
+ /// Enumeration of an endpoint's usage type
+ /// </summary>
+ public enum UsageType
+ {
+ /// <summary>
+ /// Data endpoint
+ /// </summary>
+ Data = Interop.UsageType.Data,
+ /// <summary>
+ /// Feedback endpoint
+ /// </summary>
+ Feedback = Interop.UsageType.Feedback,
+ /// <summary>
+ /// Implicit feedback Data endpoint
+ /// </summary>
+ Implicit = Interop.UsageType.Implicit,
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+namespace Tizen.System.Usb
+{
+ /// <summary>
+ /// USB Bulk Endpoint class
+ /// </summary>
+ public class UsbBulkEndpoint : UsbEndpoint
+ {
+ internal UsbBulkEndpoint(Interop.UsbEndpointHandle handle) : base(handle)
+ {
+ }
+
+ /// <summary>
+ /// Performs a USB transfer on given endpoint. Direction of transfer is determined by the endpoint
+ /// </summary>
+ /// <param name="buffer">Suitably-sized data buffer for either input or output (depending on endpoint)</param>
+ /// <param name="length">
+ /// For writes, the number of bytes from data to be sent, for reads the maximum number of bytes to receive
+ /// into the data buffer
+ /// </param>
+ /// <param name="timeout">
+ /// Timeout (in milliseconds) that this function should wait before giving up due to no response being
+ /// received(for an unlimited timeout 0 value should be used)
+ /// </param>
+ /// <returns>transferred number of bytes actually transferred</returns>
+ /// <exception cref="InvalidOperationException">Throws excetion if device is disconnected or not opened for operation</exception>
+ /// <exception cref="TimeoutException">Throws excetion if transfer timed-out</exception>
+ public int Transfer(byte[] buffer, int length, uint timeout)
+ {
+ return TransferImpl(buffer, length, timeout);
+ }
+ }
+}
_handle.Transfer(buffer, length, out transferred, timeout).ThrowIfFailed("Transfer failed");
return transferred;
}
+
+ internal static UsbEndpoint EndpointFactory(Interop.UsbEndpointHandle handle)
+ {
+ Interop.TransferType transferType;
+ handle.GetTransferType(out transferType).ThrowIfFailed("Failed to get transfer type from endpoint");
+ switch(transferType)
+ {
+ case Interop.TransferType.Bulk: return new UsbBulkEndpoint(handle);
+ case Interop.TransferType.Interrupt: return new UsbInterruptEndpoint(handle);
+ case Interop.TransferType.Isochronous: return new UsbIsochronousEndpoint(handle);
+ default: return new UsbEndpoint(handle);
+ }
+ }
}
}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.System.Usb
+{
+ /// <summary>
+ /// USB Interrupt Endpoint class
+ /// </summary>
+ public class UsbInterruptEndpoint : UsbEndpoint
+ {
+ internal UsbInterruptEndpoint(Interop.UsbEndpointHandle handle) : base(handle)
+ {
+ }
+
+ /// <summary>
+ /// Gets interval for polling endpoint for data transfers, in frame counts (refer to USB protocol specification)
+ /// </summary>
+ public int PollingInterval
+ {
+ get
+ {
+ return Interop.NativeGet<int>(_handle.GetInterval);
+ }
+ }
+
+ /// <summary>
+ /// Performs a USB transfer on given endpoint. Direction of transfer is determined by the endpoint.
+ /// </summary>
+ /// <param name="buffer">Suitably-sized data buffer for either input or output (depending on endpoint)</param>
+ /// <param name="length">
+ /// For writes, the number of bytes from data to be sent, for reads the maximum number of bytes to receive
+ /// into the data buffer
+ /// </param>
+ /// <param name="timeout">
+ /// Timeout (in milliseconds) that this function should wait before giving up due to no response being
+ /// received(for an unlimited timeout 0 value should be used)
+ /// </param>
+ /// <returns>transferred number of bytes actually transferred</returns>
+ /// <exception cref="InvalidOperationException">Throws excetion if device is disconnected or not opened for operation</exception>
+ /// <exception cref="TimeoutException">Throws excetion if transfer timed-out</exception>
+ public int Transfer(byte[] buffer, int length, uint timeout)
+ {
+ return TransferImpl(buffer, length, timeout);
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.System.Usb
+{
+ /// <summary>
+ /// USB Isochronous Endpoint class
+ /// </summary>
+ public class UsbIsochronousEndpoint : UsbEndpoint
+ {
+ internal UsbIsochronousEndpoint(Interop.UsbEndpointHandle handle) : base(handle)
+ {
+ }
+
+ /// <summary>
+ /// Gets synchronization type of this endpoint
+ /// </summary>
+ public SynchronizationType SynchronizationType
+ {
+ get
+ {
+ return (SynchronizationType)Interop.NativeGet<Interop.SynchronizationType>(_handle.GetSynchType);
+ }
+ }
+
+ /// <summary>
+ /// Gets usage type of this endpoint
+ /// </summary>
+ public UsageType UsageType
+ {
+ get
+ {
+ return (UsageType)Interop.NativeGet<Interop.UsageType>(_handle.GetUsageType);
+ }
+ }
+ }
+}