/* WinUSBNet library * (C) 2010 Thomas Bleeker (www.madwizard.org) * * Licensed under the MIT license, see license.txt or: * http://www.opensource.org/licenses/mit-license.php */ using System; namespace MadWizard.WinUSBNet { /// /// USB device details /// public class USBDeviceDescriptor { /// /// Windows path name for the USB device /// public string PathName { get; private set; } /// /// USB vendor ID (VID) of the device /// public int VID { get; private set; } /// /// USB product ID (PID) of the device /// public int PID { get; private set; } /// /// Manufacturer name, or null if not available /// public string Manufacturer { get; private set; } /// /// Product name, or null if not available /// public string Product { get; private set; } /// /// Device serial number, or null if not available /// public string SerialNumber { get; private set; } /// /// Friendly device name, or path name when no /// further device information is available /// public string FullName { get { if (Manufacturer != null && Product != null) return Product + " - " + Manufacturer; else if (Product != null) return Product; else if (SerialNumber != null) return SerialNumber; else return PathName; } } /// /// Device class code as defined in the interface descriptor /// This property can be used if the class type is not defined /// int the USBBaseClass enumeraiton /// public byte ClassValue { get; private set; } /// /// Device subclass code /// public byte SubClass { get; private set; } /// /// Device protocol code /// public byte Protocol { get; private set; } /// /// Device class code. If the device class does /// not match any of the USBBaseClass enumeration values /// the value will be USBBaseClass.Unknown /// public USBBaseClass BaseClass { get; private set; } internal USBDeviceDescriptor(string path, API.USB_DEVICE_DESCRIPTOR deviceDesc, string manufacturer, string product, string serialNumber) { PathName = path; VID = deviceDesc.idVendor; PID = deviceDesc.idProduct; Manufacturer = manufacturer; Product = product; SerialNumber = serialNumber; ClassValue = deviceDesc.bDeviceClass; SubClass = deviceDesc.bDeviceSubClass; Protocol = deviceDesc.bDeviceProtocol; // If interface class is of a known type (USBBaseeClass enum), use this // for the InterfaceClass property. BaseClass = USBBaseClass.Unknown; if (Enum.IsDefined(typeof(USBBaseClass), (int)deviceDesc.bDeviceClass)) { BaseClass = (USBBaseClass)(int)deviceDesc.bDeviceClass; } } } }