windows – How to enumerate all connected USB devices’ device path?

MSDN says that there’s a generic USB device interface class named GUID_DEVINTERFACE_USB_DEVICE with the GUID {A5DCBF10-6530-11D2-901F-00C04FB951ED}: The system-supplied USB hub driver registers instances of GUID_DEVINTERFACE_USB_DEVICE to notify the system and applications of the presence of USB devices that are attached to a USB hub. Here’s a code example that seems to do what you want … Read more

USB Connection Delegate on Swift

Eric Aya’s answer is already quite good, but here’s a Swift 3 adaptation. I wrapped most of the ugly stuff in a USBWatcher class; set yourself as the delegate of this object to receive notifications. You can copy/paste the following into a playground to see it work — the example just logs a message to … Read more

Automatically launch app on USB (through autorun?)

First of all, some people choose to disable autorun for security reasons; but Windows computers up to Vista have it enabled. Edit: Apparently the functionality was removed from Windows 7 onwards. Put a file named autorun.inf in the root of your USB flash drive. This is what’s in mine: [Autorun] Open=PStart.exe Action=Start portable apps Icon=diskicon.ico … Read more

Transferring data USB

I was trying to send data over the wrong baud rate. Here’s the code that works. Posting it for everyone who is using FTDI devices and needs help. private Runnable mLoop = new Runnable() { @Override public void run() { UsbDevice dev = sDevice; if (dev == null) return; UsbManager usbm = (UsbManager) getSystemService(USB_SERVICE); UsbDeviceConnection … Read more

Power off an USB device in software on Windows

Some USB hubs have the ability to turn power off to its downstream devices. “Is it possible to power up ports on a USB hub from Ubuntu?” https://askubuntu.com/questions/149242/is-it-possible-to-power-up-ports-on-a-usb-hub-from-ubuntu Which points to some c source for hub-ctrl.c See: http://www.gniibe.org/development/ac-power-control-by-USB-hub/index I tested this on Ubuntu with a Dream-Cheeky USB LED unit, and it did seem to turn … Read more