LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   HowDoI? Turn on/off usb light by time (http://www.linuxquestions.org/questions/linux-software-2/howdoi-turn-on-off-usb-light-by-time-514863/)

mjrclark 12-30-2006 09:50 AM

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
:scratch:

kaz2100 12-31-2006 08:26 PM

Hi

http://www.linuxquestions.org/questi...d.php?t=509328

Is this what you need??

Happy Penguins!

mjrclark 01-01-2007 02:46 AM

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.

tredegar 01-01-2007 04:47 AM

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.

mjrclark 01-01-2007 08:16 AM

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;
http://www.mail-archive.com/python-w.../msg02616.html
http://www.usb.org/phpbb/viewtopic.p...470&highlight=

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

root@mypc:/sys/bus/usb/devices# ls
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

tredegar 01-01-2007 10:15 AM

Hmmm, interesting.
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

davcefai 01-02-2007 12:02 AM

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.

Good Luck.

mike10 01-20-2007 06:23 PM

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

macemoneta 01-20-2007 09:41 PM

If all you want to do is control fans, take a look at X10 device controllers. I've been using them for years.

mike10 01-20-2007 09:52 PM

hmm, interesting, I will look into it, looks promising and a source of many future projects

but lets solve mjrclark's problem

macemoneta 01-21-2007 01:22 PM

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.

mike10 01-22-2007 07:45 PM

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

macemoneta 01-22-2007 10:31 PM

Quote:

Originally Posted by mike10
I want to do that know but would want the light to stay on till I read the email

It's pretty straight forward. In evolution (the email package I'm using), after email passes all filters, I run a script called 'newmail'. The script turns on the nightlight and sets a flag in a file. A background process checks the flag, and if set waits for the screen saver to deactivate (meaning that I'm at the PC). Once the screen saver deactivates, it clears the flag and turns off the nightlight. It's rather convenient, as you can have the nightlight plugged in anywhere in the house (even multiple locations).

werewolfy 11-30-2008 10:42 PM

Quote:

Originally Posted by mjrclark (Post 2563785)
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
:scratch:

I just read this thread, because I was looking for a way to switch off the internal UMTS modem in the Eee 901GO.

I wanted to try

# /sys/bus/usb/devices/6-0:1.0/power/state

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
# lsusb

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
/sys/bus/usb/devices/2-2/power/wakeup
and
/sys/bus/usb/devices/2-2/power/persist
do exactly.

Anyone?

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 08:52 PM.