From 62d1712718af7279156e791c3a6c665d1b3cd7ae Mon Sep 17 00:00:00 2001 From: Dinesh Dwivedi Date: Tue, 11 Jul 2017 21:18:48 +0530 Subject: [PATCH] [USB] Add UsbDeviceInformation class Change-Id: I9f8d7e954912ca7f522350c670302d45a04c976e Signed-off-by: Dinesh Dwivedi --- Tizen.System.Usb/Usb/UsbDevice.cs | 12 +++ Tizen.System.Usb/Usb/UsbDeviceInformation.cs | 116 +++++++++++++++++++++++++++ 2 files changed, 128 insertions(+) create mode 100644 Tizen.System.Usb/Usb/UsbDeviceInformation.cs diff --git a/Tizen.System.Usb/Usb/UsbDevice.cs b/Tizen.System.Usb/Usb/UsbDevice.cs index 3e18f9c..c2a5903 100644 --- a/Tizen.System.Usb/Usb/UsbDevice.cs +++ b/Tizen.System.Usb/Usb/UsbDevice.cs @@ -131,6 +131,18 @@ namespace Tizen.System.Usb } /// + /// Device information such as version, class, subclass etc. + /// + public UsbDeviceInformation DeviceInformation + { + get + { + ThrowIfDisposed(); + return new UsbDeviceInformation(this); + } + } + + /// /// String associated with device. /// public UsbDeviceStrings Strings diff --git a/Tizen.System.Usb/Usb/UsbDeviceInformation.cs b/Tizen.System.Usb/Usb/UsbDeviceInformation.cs new file mode 100644 index 0000000..8bf2ce9 --- /dev/null +++ b/Tizen.System.Usb/Usb/UsbDeviceInformation.cs @@ -0,0 +1,116 @@ +/* + * 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 +{ + /// + /// Device information for USB device. + /// + public class UsbDeviceInformation + { + private readonly UsbDevice _device; + + internal UsbDeviceInformation(UsbDevice device) + { + _device = device; + } + + /// + /// USB specification release number as binary-coded decimal. + /// + /// Throws exception if user has insufficient permission on device. + public int UsbVersion + { + get + { + _device.ThrowIfDisposed(); + return Interop.NativeGet(_device._handle.GetBcdUsb); + } + } + + /// + /// Gets device class. + /// + public int Class + { + get + { + _device.ThrowIfDisposed(); + return Interop.NativeGet(_device._handle.GetClass); + } + } + + /// + /// Gets device sub class. + /// + public int Subclass + { + get + { + _device.ThrowIfDisposed(); + return Interop.NativeGet(_device._handle.GetSubClass); + } + } + + /// + /// Gets device protocol. + /// + public int Protocol + { + get + { + _device.ThrowIfDisposed(); + return Interop.NativeGet(_device._handle.GetProtocol); + } + } + + /// + /// Gets vendor id. + /// + public int VendorId + { + get + { + _device.ThrowIfDisposed(); + return Interop.NativeGet(_device._handle.GetIdVendor); + } + } + + /// + /// Gets product id. + /// + public int ProductId + { + get + { + _device.ThrowIfDisposed(); + return Interop.NativeGet(_device._handle.GetIdProduct); + } + } + + /// + /// Gets device release number in binary-coded decimal. + /// + public int DeviceVersion + { + get + { + _device.ThrowIfDisposed(); + return Interop.NativeGet(_device._handle.GetBcdDevice); + } + } + } +} -- 2.7.4