Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No ability to list attached devices? #234

Open
thethiny opened this issue Jun 6, 2024 · 1 comment
Open

No ability to list attached devices? #234

thethiny opened this issue Jun 6, 2024 · 1 comment

Comments

@thethiny
Copy link

thethiny commented Jun 6, 2024

Description

running adb devices is how I get the names of my devices. If I don't have a device name I cannot connect to it. Is there an option to list all connected devices?

@fonix232
Copy link

You can use UsbTransport.find_all_adb_devices() to get a list of UsbTransport objects that correlate to devices. On each entry returned by the generator, you can get the serial_number attribute to get the serial number. Then you can use AdbDeviceUsb to connect to them.

Note: in some cases you can run into usb1.USBErrorAccess: LIBUSB_ERROR_ACCESS [-3] either while creating the AdbDeviceUsb instance or when you call connect() on it. This is caused by the standard ADB daemon running in the background and locking the device accessors, so just make sure you kill the ADB server before creating the device object and connecting to it:

def connect(self, serial: str):
    subprocess.Popen(["adb", "kill-server"]).communicate()
    device = AdbDeviceUsb(serial)
    device.connect()

I do concur however that a @classmethod device lister on both AdbDeviceUsb and AdbDeviceTcp (latter using mDNS) would be preferred.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants