Is USB power always enabled ? And if not, how to write a driver

痞子三分冷 提交于 2019-12-21 04:58:13

问题


I have a device that came with an AC power adapter where the connector is a mini USB plug. The device however doesn't seem to power itself from a computer's USB port (using a standard USB-mini USB cable) unless a specific driver is installed. The driver is only available for Windows. I would like to charge the device from USB plugs on different platforms.

My question is: why isn't power getting to the device without the driver? Is a driver always required for a USB port to start giving power? Or is it this device that's specifically made not to take a charge unless some software routine triggers it to do so?

I guess my question can be summarized as: Is power not present on the USB cable or is it present but the device ignoring it. If the answer is the former, I'll be trying to figure out how to write software that will enable the voltage to always be present.

Thanks


回答1:


Why isn't power getting to the device without the driver?

USB ports are always powered when the computer is on and the USB control software hasn't detected current overdraw.

Is a driver always required for a USB port to start giving power?

No, the USB port is always required to start off providing power to the device, otherwise the device could never initiate a connection.

Or is it this device that's specifically made not to take a charge unless some software routine triggers it to do so?

This can be complex. To meet the USB spec a device cannot pull more than a few mA until it's registered with the computer.

However, nearly every computer allows the USB port to pull the full 500mA (and more) before it'll shut the power off.

The device you're charging is being nice by not pulling any significant power until the computer gives permission.

Writing software won't help, the device has to register with the USB bus, which will best be done with the driver.

However, the plug in charger doesn't do that. It likely has shorted the two data lines of the USB plug together, which signals the USB device that it's not connected to a computer and can pull the full 500mA without waiting.

Take a USB extension cable, cut off the jacket, and short the data lines (green and yellow, sometimes) together on the end going to the USB device, and leave them cut without touching anything on the end going to the PC, and leave the read and black power wires connected through.

It might work. If not, take the wall charger apart and find out what it's doing with each of the four USB wires, and see if you can duplicate that.




回答2:


This might be helpful if you are targeting a linux system.




回答3:


This seems to be platform-specific. In Linux, USB ports are always energized, while on Windows they don't. Thumbdrives with LEDs turn off when unmounted in windows, but in Linux they stay lit. My cellphone's manual says that it can't be charged by a PC, but I regularly do on my linux machine, I guess that's because they don't have a driver and windows won't power up without one.




回答4:


Have you tried plugging it into a 'dumb' USB port - like the one on a car charger? Those ports are pure power and don't create a USB network. I think.




回答5:


Unless you have the hardware specs from the manufacturer, I think you are out of luck. You could try reverse engineering the driver to see what it does, but I'd expect it would be cheaper and easier just to buy one with cross platform drivers or charges without the driver.



来源:https://stackoverflow.com/questions/971486/is-usb-power-always-enabled-and-if-not-how-to-write-a-driver

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!