none
Controlling USB hub port power from user mode application RRS feed

  • Question

  • Hi!

    I'm currently working in a project where we have devices connected through USB hubs to a PC running Windows XP.

    I want to be able to turn off and on one of the device connected to a USB hub port by controlling the output power from the port. The USB hub supports individual power switching and I have been able to do this from a Linux PC. 
    Since our customer wants to use the default USB hub driver, usbhub.sys, I can't use libusb for Windows or WinUSB. Therefore I have used SetupDI API and Cfgmgr32 to access the hub. I can enumerate the devices and find the port to which the device I want to power off is connected. The part I can't get to work is the actual powering off.
    In the USB specification there is a Clear Port Feature request and I think this is what is used when doing this with libusb for Linux.

    So my question is how to do this in Windows from a user mode application? I have tried to do it by calling DeviceIoControl with the hub as device and IOCTL_USB_HUB_CYCLE_PORT as control code but it doesn't work. The call returns ok but the power to the device is not turned off.

    Hoping the answer is out there.

    /Anders

    Sunday, June 9, 2013 1:59 PM

Answers

  • You are correct that there is no support in Windows for controlling the port power state of any USB ports, particularly from an application.  Disabling the downstream device will not result in turning power (Vbus) off on the port.  The port may be suspended, but in the suspend state, Vbus is still ON. 

    A problem with cutting Vbus is that without Vbus, there is no way to detect device attach or detach events on the port. 

    Monday, June 10, 2013 8:25 PM

All replies

  • I believe IOCTL_USB_HUB_CYCLE_PORT simulates a plug and unplug event.  I am not aware of anything that will do what you want, but you might try disabling the device and see if there is inteligance to recognize that the power can be turned off.


    Don Burn Windows Filesystem and Driver Consulting Website: http://www.windrvr.com Blog: http://msmvps.com/blogs/WinDrvr

    Sunday, June 9, 2013 2:36 PM
  • You want to control the power to the hub itself or each downstream port on the hub?

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Sunday, June 9, 2013 5:21 PM
  • I want to control the power on a specific downstream port on the hub.
    Monday, June 10, 2013 6:06 AM
  • Yes, I'm starting to realize that there might not be any support for it. But that seems strange to me since the USB 2.0 specification includes the functionality for it and many hubs have support for this. I suppose it's the usbhub driver that has not implemented any support for this?

    Do you mean disabling the downstream device and see if the hub then turns off the power on that port? Could be worth a try. However, will it still be possible to turn the power on?

    Thanks for your answer.

    Monday, June 10, 2013 6:29 AM
  • You are correct that there is no support in Windows for controlling the port power state of any USB ports, particularly from an application.  Disabling the downstream device will not result in turning power (Vbus) off on the port.  The port may be suspended, but in the suspend state, Vbus is still ON. 

    A problem with cutting Vbus is that without Vbus, there is no way to detect device attach or detach events on the port. 

    Monday, June 10, 2013 8:25 PM
  • Thanks Randy.
    The device connected to the hub is powered by the VBUS from the hub port. Our customer has a problem where the device connected to the hub stops working. The idea was, as a quick workaround, to use software to cut the VBUS and then turn on VBUS again to restart the device. This has been verified to work by manually disconnecting the VBUS.
    If this can't be done due to lack of support in the driver I suppose I have to discuss with our customer if using another driver is an option. Alternatively creating our own driver but that will increase time and cost.

    To bad they are not using Linux. ;)

    Thank you all for your help.

    Tuesday, June 11, 2013 8:43 AM
  • Hi Anders,

    I also want to reset  USB device by controlling the USB port power,did you find the way to do this?

    Wayne 

    Wednesday, March 25, 2015 9:08 AM