示例#1
0
        /// <summary>
        /// Gets a list of bootloaders that are currently connected to USB.
        /// </summary>
        public static List <DeviceListItem> getConnectedBootloaders()
        {
            Guid bootloaderGuid = new Guid("82959cfa-7a2d-431f-a9a1-500b55d90950");

            List <DeviceListItem> bootloaders;

            try
            {
                List <UInt16>         bootloaderProductIDs = new List <UInt16>(Smc.bootloaderProductIDs);
                List <DeviceListItem> allBootloaders       = UsbDevice.getDeviceList(bootloaderGuid);
                bootloaders = new List <DeviceListItem>();
                foreach (DeviceListItem dli in allBootloaders)
                {
                    if (bootloaderProductIDs.Contains(dli.productId))
                    {
                        bootloaders.Add(dli);
                    }
                }
            }
            catch (NotImplementedException)
            {
                // use vendor and product instead
                bootloaders = UsbDevice.getDeviceList(0x1FFB, Smc.bootloaderProductIDs);
            }

            foreach (DeviceListItem dli in bootloaders)
            {
                Smc.setDeviceListItemText(dli);
            }

            return(bootloaders);
        }
示例#2
0
        /// <summary>
        /// Gets a list of devices that are currently connected to USB.
        /// </summary>
        public static List <DeviceListItem> getConnectedDevices()
        {
            List <DeviceListItem> devices;

            try
            {
                try
                {
                    devices = UsbDevice.getDeviceList(Smc.deviceInterfaceGuid);
                }
                catch (NotImplementedException)
                {
                    // use vendor and product instead
                    devices = UsbDevice.getDeviceList(Smc.vendorID, Smc.productIDs);
                }
            }
            catch (Exception e)
            {
                throw new Exception("There was an error getting the list of connected devices.", e);
            }

            foreach (DeviceListItem dli in devices)
            {
                Smc.setDeviceListItemText(dli);
            }

            return(devices);
        }