Control USB port's power?

Does anybody know how to control USB pins on a certain USB port? I think it is definately possible in assembler but what about C++ or C#?

I want to be able to use USB battery as a power supply for an LED or something like that. So then a program would power it on and power it off making it flash.

I know it sounds pointless but I need to do it for something awesome.

I also know that it might require a custom driver.


USB is not trivial, so I guess you'll have some problems (mis)using it. You would be /much/ better off (IMHO) with standard serial ports, which have been used for stuff like that for ages, with plenty of examples available. If you don't have serial port available on your target machine, you can use USB->Serial interface cable.

That being said, you'll probably want to take a look @: http://sourceforge.net/projects/libusbdotnet/

LP, Dejan


You can't simply toggle pins on a USB port. Period. USB is a serial protocol. The connector contains

  • Power. The Host can control the power lines as it can cut the power in case of overload. This is something done by the USB host driver, which means the driver of the host adapter in the PC. This does not mean any custom device driver you might need for hardware that doesn't use any of the device classes the OS already ships drivers.
  • Data. The data is sent via a serial protocol, so there is no way to control those pins if you're using USB.
  • If you want to get some IO ports you need more logic. You need at least something that follows the USB protocol, which means some kind of microcontroller (or a special USB device controller like the FTDI USB controllers. The FT232 and FT245 are especially nice to work with). For a low-end microcontroller based solution the V-USB driver for AVR controllers might be interesting.

    For easy bit-banging IO pins on the PC use the parallel port. USB is really not made nor suited for that.


    According to http://www.gniibe.org/development/ac-power-control-by-USB-hub/index

    USB 2.0 nominally supports per-port power switching:

    Hub Descriptor:
    [...]
      wHubCharacteristic 0x0089
        Per-port power switching
    [...]
    

    Sadly, the author reports that while may hubs' firmware claims to support this, the manufacturers have cut corners on the circuit board.

    链接地址: http://www.djcxy.com/p/81290.html

    上一篇: 通过USB控制简单的继电器开关

    下一篇: 控制USB端口的电源?