Find all the devices on the serial buss and store the results in a
        class member object.
10127
def findConnectedDevices(self):
        
        tmpTimeout = self._serial.timeout
        self._serial.timeout = 0.01

        for dev in range(128):
            device = self._getDeviceID(dev)

            if device is not None and int(device) not in self._deviceConfig:
                config = self._deviceConfig.setdefault(int(device), {})
                self._deviceCallback(device, config)
                self._log and self._log.info(
                    "Found device '%s' with configuration: %s", device, config)

        self._serial.timeout = tmpTimeout
1255138
def autoscan():
    
    for port in serial.tools.list_ports.comports():
        if is_micropython_usb_device(port):
            connect_serial(port[0])
723331
function(callback) {
    var ports = [];
    var newPortToDevice = [];
    // get all devices
    var responses = 0;
    var devices = Espruino.Core.Serial.devices;
    if (!devices || devices.length==0) {
         portToDevice = newPortToDevice;
      return callback(ports, false);
    }
    var shouldCallAgain = false;
    devices.forEach(function (device) {
      //console.log("getPorts -->",device.name);
      device.getPorts(function(devicePorts, instantPorts) {
        //console.log("getPorts <--",device.name);
        if (instantPorts===false) shouldCallAgain = true;
        if (devicePorts) {
          devicePorts.forEach(function(port) {
            var ignored = false;
            if (Espruino.Config.SERIAL_IGNORE)
              Espruino.Config.SERIAL_IGNORE.split("|").forEach(function(wildcard) {
                var regexp = "^"+wildcard.replace(/\./g,"\\.").replace(/\*/g,".*")+"$";
                if (port.path.match(new RegExp(regexp)))
                  ignored = true;
              });

            if (!ignored) {
              if (port.usb && port.usb[0]==0x0483 && port.usb[1]==0x5740)
                port.description = "Espruino board";
              ports.push(port);
              newPortToDevice[port.path] = device;
            }
          });
        }
        responses++;
        if (responses == devices.length) {
          portToDevice = newPortToDevice;
          ports.sort(function(a,b) {
            if (a.unimportant && !b.unimportant) return 1;
            if (b.unimportant && !a.unimportant) return -1;
            return 0;
          });
          callback(ports, shouldCallAgain);
        }
      });
    });
  }
1252255
def device_info(self):
        
        info = {
            'serial': self.serial,
            'model': self.model,
            'build_info': self.build_info,
            'user_added_info': self._user_added_device_info
        }
        return info
628950
private static List<String> getDeviceDescriptionsLowLevel()
	{
		final Context ctx = new Context();
		final int err = LibUsb.init(ctx);
		if (err != 0) {
			slogger.error("LibUsb initialization error {}: {}", -err, LibUsb.strError(err));
			return Collections.emptyList();
		}
		try {
			final DeviceList list = new DeviceList();
			final int res = LibUsb.getDeviceList(ctx, list);
			if (res < 0) {
				slogger.error("LibUsb device list error {}: {}", -res, LibUsb.strError(res));
				return Collections.emptyList();
			}
			try {
				return StreamSupport.stream(list.spliterator(), false).map(UsbConnection::printInfo)
						.collect(Collectors.toList());
			}
			finally {
				LibUsb.freeDeviceList(list, true);
			}
		}
		finally {
			LibUsb.exit(ctx);
		}
	}
1305018
def listports():
    
    detected = False
    for port in serial.tools.list_ports.comports():
        detected = True
        if port.vid:
            micropythonPort = ''
            if is_micropython_usb_device(port):
                micropythonPort = ' *'
            print('USB Serial Device {:04x}:{:04x}{} found @{}{}\r'.format(
                  port.vid, port.pid,
                  extra_info(port), port.device, micropythonPort))
        else:
            print('Serial Device:', port.device)
    if not detected:
        print('No serial devices detected')
883123
def devices(self):
        ''
        return self.fs is not None and [JFSDevice(d, self, parentpath=self.rootpath) for d in self.fs.devices.iterchildren()] or [x for x in []]
607728
def plugged_usbs(multiple=True) -> map or dict:
    

    class FindPenDrives(object):
        # From https://github.com/pyusb/pyusb/blob/master/docs/tutorial.rst
        def __init__(self, class_):
            self._class = class_

        def __call__(self, device):
            # first, let's check the device
            if device.bDeviceClass == self._class:
                return True
            # ok, transverse all devices to find an
            # interface that matches our class
            for cfg in device:
                # find_descriptor: what's it?
                intf = usb.util.find_descriptor(cfg, bInterfaceClass=self._class)
                if intf is not None:
                    try:
                        product = intf.device.product.lower()
                    except ValueError as e:
                        if 'langid' in str(e):
                            raise OSError('Cannot get "langid". Do you have permissions?')
                        else:
                            raise e
                    if 'crw' not in product and 'reader' not in product:
                        return True
            return False

    def get_pendrive(pen: usb.Device) -> dict:
        manufacturer = pen.manufacturer.strip() or str(pen.idVendor)
        model = pen.product.strip() or str(pen.idProduct)
        serial_number = pen.serial_number.strip()
        hid = Naming.hid(manufacturer, serial_number, model)
        return {
            '_id': hid,  # Make live easier to DeviceHubClient by using _id
            'hid': hid,
            '@type': 'USBFlashDrive',
            'serialNumber': serial_number,
            'model': model,
            'manufacturer': manufacturer,
            'vendorId': pen.idVendor,
            'productId': pen.idProduct
        }

    result = usb.core.find(find_all=multiple, custom_match=FindPenDrives(CLASS_MASS_STORAGE))
    if multiple:
        return map(get_pendrive, result)
    else:
        if not result:
            raise NoUSBFound()
        return get_pendrive(result)
334422
def pick_device

      devices = AdbExtended::Adb.devices

      if devices.size == 0
        puts 'No devices found'
        exit 1
      end

      if devices.size == 1
        return devices[0][:serial]
      end

      table = Terminal::Table.new do |t|
        header_row = %w(# Model Serial)

        t << header_row
        t << :separator
        devices.each_with_index {|value, index|
          row = [index + 1, value[:model], value[:serial]]
          t.add_row row
        }
      end

      puts table

      accepted_inputs = *(1..devices.size).map {|i| i.to_s}
      index = ask("Select a device (1 - #{devices.size}):", :limited_to => accepted_inputs).to_i - 1
      devices[index][:serial]
    end
697067
def _get_gpu_pci_devices(self):
        """"""
        pci_device_list = self._get_pci_devices()

        gpu_list = []
        items = pci_device_list['Items']
        for item in items:
            if item['ClassCode'] in CLASSCODE_FOR_GPU_DEVICES:
                if item['SubclassCode'] in SUBCLASSCODE_FOR_GPU_DEVICES:
                    gpu_list.append(item)
        return gpu_list
244558
def parse_devices(self):
        """"""
        devices = []
        for device in self._channel_dict["devices"]:
            devices.append(Device(device, self._is_sixteen_bit, self._ignore_list))
        return devices
1018611
private boolean serialClassFoundToDocument(ClassDoc[] classes) {
        for (int i = 0; i < classes.length; i++) {
            if (serialClassInclude(classes[i])) {
                return true;
            }
        }
        return false;
    }
249487
def devices(self):
        ''''''
        out = self.run_cmd('devices') #subprocess.check_output([self.adb_path(), 'devices']).decode("utf-8")
        if 'adb server is out of date' in out:
            out = self.run_cmd('devices')
        match = "List of devices attached"
        index = out.find(match)
        if index < 0:
            raise EnvironmentError("adb is not working.")
        return dict(re.findall(r'([^\s]+)\t(\w+)', out))
566380
def devices():
    '''
    
    '''
    out = __salt__['cmd.run_all']("blkid -o export")
    salt.utils.fsutils._verify_run(out)

    return salt.utils.fsutils._blkid_output(out['stdout'], fs_type='btrfs')
49318
def devices(self):
        
        eax = self.attributes.get('devices')
        if eax is None:
            eax = self._all_devices
        if not isinstance(eax, list):
            eax = [eax]
        return [str(dev) for dev in eax]
240316
function (callback) {
        var result = [];

        var devices = findBlinkSticks();
        var i = 0;

        var finder = function() {

            if (i == devices.length) {
                if (callback) callback(result);
            } else {
                devices[i].getSerial(function (err, serial) {
                    result.push(serial);
                    i += 1;
                    finder();
                });
            }
        };

        finder();
    }
1314307
def _find_device(self, idVendor, idProduct):
        """"""
        for bus in usb.busses():
            for device in bus.devices:
                if (device.idVendor == idVendor and
                    device.idProduct == idProduct):
                    return device
        return None