HowDoI? Turn on/off usb light by time
I have a usb mini-lava lamp. I would light to have it come on and turn off at specific times, to act as an alarm. It is a dum device, just drawing power from the USB port outside the USB spec.
Firstly, does a programme exist to let me do this?
If not, how would I go about programming it?
I found a simple usb-handling programme from the Barry project, it searches for Blackberries then tells them to request higher power. It all looks fairly simple, but I cannot find out what command to use to set the power level on the usb post
Source code from Barry;http://belnet.dl.sourceforge.net/sou...rry/bcharge.cc
My original post on ubuntuforums.org :http://www.ubuntuforums.org/showthread.php?t=327138
Is this what you need??
Yes, that is what I need. Unfortunately, it does not work!
The output produced is as follows;
$:/sys/bus/usb/devices/6-1/power$ echo "0" > /sys/bus/usb/devices/6-0:1.0/power/state
bash: /sys/bus/usb/devices/6-0:1.0/power/state: Permission denied
This happens when prefixing echo with sudo, putting sudo just after the ">" and both.
Try sudo -i
That will give you a "root shell"
Then give your command echo "0" > /sys/bus/usb/devices/6-0:1.0/power/state
It should work.
Type exit or <CRTL><D> to exit from the root shell.
Thank you for your continuing help.A few other people have said this is impossible in software. They seem to really believe it is impossible, two examples;
I tried your suggestion, the result is below.
root@mypc:/sys/bus/usb/devices# echo "0" > /sys/bus/usb/devices/6-1:1.0/power/state
-bash: echo: write error: Invalid argument
1-0:1.0 2-0:1.0 5-0:1.0 6-1:1.0 usb1 usb4
1-2 3-0:1.0 6-0:1.0 6-1:1.1 usb2 usb5
1-2:1.0 4-0:1.0 6-1 6-1:1.2 usb3 usb6
root@mypc:/sys/bus/usb/devices# rm /sys/bus/usb/devices/6-1:1.1/power/state
rm: cannot remove `/sys/bus/usb/devices/6-1:1.1/power/state': Operation not permitted
It could well be that there simply isn't a way to power-off a USB port.
If it has suitable intelligence (and your lamp is unlikely to!) I expect you can send a USB device a command that turns it off, or, more likely, puts it "to sleep". This isn't much help to you though.
You could try looking at the datasheets for USB controllers, and see if there is the facility to do what you want, at hardware level, but I suspect the answer is "no" from what I have read so far. You'll have to choose another sort of alarm, or build yourself a special USB device that will remove power from another USB device further down the line. Not a trivial project! Sorry
Depending on how handy you are with a soldering iron, one possibility is to use the parallel port to switch a relay.
Get hold of the Coffee Howto. This will tell you what to do.
You might want to use a parallel port card, not the one on your MB so that if you short the port the damage will be limited to the card.
From what I have observed it is my understanding that you might be able to stop the computer from sending power on that usb channel but that means nothing plugged into the usb drive will work\
perhaps you could use the parts from an external hdd or something like that
I like the idea of using a parallel port but I would not solder I would splice a cable
I want to know if you can use the usb the way you want to though cause if it dose I will do the same with a laptop and a set of fans
If all you want to do is control fans, take a look at X10 device controllers. I've been using them for years.
hmm, interesting, I will look into it, looks promising and a source of many future projects
but lets solve mjrclark's problem
It may not be possible to turn the power off to a USB port; it's power leads may be hard wired to a power source, not under the control of software.
For mjrclark's problem, software control of a light, the X10 controller and interfaces are perfect. For example, I have used a nightlight to indicate that I have new mail. The mini-lava light only uses the USB port for power; there are many low cost USB chargers that will allow the mini-lava light to be controlled by X10.
This meets the minimum requirement at minimal cost, but also opens many additional home automation possibilities.
I do not know the specks for usb so I cant comment but I see how to get the lava lamp to work.
[QUOTE macemoneta]I have used a nightlight to indicate that I have new mail[/QUOTE] I want to do that know but would want the light to stay on till I read the email
I wanted to try
like one poster proposed, but on my system there is no such file.
I kept googling and finally found out this:
# echo suspend > /sys/bus/usb/devices/2-2/power/level
To find out the device name (2-2 here), use
# dmesg | grep NAME_OF_YOUR_DEVICE
if necessary, look up the device's name with
Curiously enough, the numbers given in lsusb are not the correct one's... I have still to find out why this is the case.
I tried this on a USB mouse, and the LED went out all right :)
To switch the port on again, pass either "auto" or "on".
"auto" suspends the port automatically after the period of time specified in /sys/bus/usb/devices/2-2/power/autosuspend (in seconds), "on" (not surprisingly ;o) leaves it on all the time.
On mobile devices, using "auto" for all ports might prove beneficial.
I still have to figure out, what
I think one can find out more about this in the documentation (Documentation/usb/power-management.txt I think) found in the Linux Kernel sources.
So simple... I do love Linux, I can tell you that ;)
|All times are GMT -5. The time now is 03:51 AM.|