Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

theclive

macrumors newbie
Original poster
Nov 4, 2009
2
0
I am wondering if an application that allows a user to turn on/off individual usb ports with simple keystrokes exists. Example: user hits key x once to turn off usb port, and x again (or another key) to turn on said usb port. While all other ports remain on (or off depedning on original state).

I assumed that since macs themselves can turn individual ports on and off, that an application would be able to as well. I thought this would be a relatively simple app, and that somebody would already have such developed (or something similiar) however i have been unable to find one as of yet.
 

Cromulent

macrumors 604
Oct 2, 2006
6,802
1,096
The Land of Hope and Glory
I am wondering if an application that allows a user to turn on/off individual usb ports with simple keystrokes exists. Example: user hits key x once to turn off usb port, and x again (or another key) to turn on said usb port. While all other ports remain on (or off depedning on original state).

I assumed that since macs themselves can turn individual ports on and off, that an application would be able to as well. I thought this would be a relatively simple app, and that somebody would already have such developed (or something similiar) however i have been unable to find one as of yet.

The simplest solution would be to route all read / write requests to the specific ports to /dev/null temporarily although this would be a major hack.

Doing it properly would be quite a task I imagine. You would have to check if a device is connected, if it is, is it active? Then you would need to unload the driver for the device whilst making sure that you do not cause any potential loss of data and reload the device driver when you want to reenable it.

Thinking about it I am not entirely sure that Mac OS X makes a distinction between individual USB ports anyway.

Edit: After having a quick poke around I'm not entirely sure. Firstly I'm not up to speed on the way that Mac OS X handles USB devices at a low level. It may well use IO Kit for it entirely which would complicate matters a little as it would mean that the standard BSD APIs were unavailable as far as I know.

Interesting idea but I don't think it is as simple as you think.

Frankly I have to ask why you are so keen on this? What language are you using anyway?
 

theclive

macrumors newbie
Original poster
Nov 4, 2009
2
0
The only reason i would even think that turning off an individual port is possible is because when i once plugged in a damaged iphone into my macbook pro, it turned off the port that it was plugged into. But my ipod which at the time was plugged into the other port remained connected and in use.

The reason is i want to use osx's built in voice command feature to control a variety of things in my room/apt: lights, heater, even the shower (not the temp).

I love the ability to create custom commands with osx. However osx does not interface well if at all with PIC microprocessors. Thus i wanted to use the power from usb ports as on/off logic controllers.

Unfortunately this is my final stumbling block. If windows had a similar voice command system as osx, i would be done. In windows i would not need to even mess with the usb ports, i could just send commands directly to the device however windows xp lacks a good voice command feature. And since i am unsure of how windows 7 will work with my software/hardware i dont want to dish out the cash for it just yet.
 

Flynnstone

macrumors 65816
Feb 25, 2003
1,438
96
Cold beer land
You can still use the PIC or any other microcontroller.
Go through a USB to serial device. RS232 or there might be some line level devices. FTDI perhaps.
I can program PIC devices via USB on my Mac.

You can see the USB ports in System Profiler. But I don't thinks its an easy task to turn them on or off.
 

larkost

macrumors 6502a
Oct 13, 2007
534
1
There are people doing PIC programming from the mac:

http://www.mactech.com/articles/mactech/Vol.20/20.02/PICMicrocontroller/index.html

I am not one of them, so beyond that link I really can't help you farther in that direction. I would suspect that there is not a way of telling the IOKit system to turn off power to specific USB ports, since this is probably not something that was in the specs. It is possible that the kext controlling the USB ports is in the darwin source code, and you could hack that in yourself, but that seems like a lot of work.
 

autorelease

macrumors regular
Oct 13, 2008
144
0
Achewood, CA
What you probably encountered when you plugged in a damaged iPhone was the overcurrent protection kicking in. I'm not familiar with the specifics, but if a device draws too much current from a USB host, the host kicks it off the bus to prevent damage. However, this is probably a feature of the USB controller chip and is not available to the OS.

A single USB port provides only 5V and 100mA, so there's no way you'd even be able to power a lamp from one. What you want is a box of power outlets, where each one is switched on by a USB-controlled relay. You could build one with a microcontroller and a USB-to-serial interface.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.