Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
12-30-2006, 09:50 AM
|
#1
|
LQ Newbie
Registered: Dec 2006
Posts: 6
Rep: 
|
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

Last edited by mjrclark; 01-01-2007 at 02:44 AM.
|
|
|
12-31-2006, 08:26 PM
|
#2
|
Senior Member
Registered: Apr 2005
Location: Penguin land, with apple, no gates
Distribution: SlackWare > Debian testing woody(32) sarge etch lenny squeeze(+64) wheezy .. bullseye bookworm
Posts: 1,849
Rep: 
|
|
|
|
01-01-2007, 02:46 AM
|
#3
|
LQ Newbie
Registered: Dec 2006
Posts: 6
Original Poster
Rep: 
|
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.
|
|
|
01-01-2007, 04:47 AM
|
#4
|
LQ 5k Club
Registered: May 2003
Location: London, UK
Distribution: Fedora40
Posts: 6,153
|
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.
|
|
|
01-01-2007, 08:16 AM
|
#5
|
LQ Newbie
Registered: Dec 2006
Posts: 6
Original Poster
Rep: 
|
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
Last edited by mjrclark; 01-01-2007 at 09:54 AM.
|
|
|
01-01-2007, 10:15 AM
|
#6
|
LQ 5k Club
Registered: May 2003
Location: London, UK
Distribution: Fedora40
Posts: 6,153
|
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
|
|
|
01-02-2007, 12:02 AM
|
#7
|
Member
Registered: Dec 2004
Location: Malta
Distribution: Debian Sid
Posts: 866
Rep:
|
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.
|
|
|
01-20-2007, 06:23 PM
|
#8
|
Member
Registered: Aug 2005
Distribution: Debian amd64 with 32bit libs and Debian 32 bit laptop
Posts: 119
Rep:
|
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
|
|
|
01-20-2007, 09:41 PM
|
#9
|
Senior Member
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
|
If all you want to do is control fans, take a look at X10 device controllers. I've been using them for years.
|
|
|
01-20-2007, 09:52 PM
|
#10
|
Member
Registered: Aug 2005
Distribution: Debian amd64 with 32bit libs and Debian 32 bit laptop
Posts: 119
Rep:
|
hmm, interesting, I will look into it, looks promising and a source of many future projects
but lets solve mjrclark's problem
|
|
|
01-21-2007, 01:22 PM
|
#11
|
Senior Member
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
|
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.
|
|
|
01-22-2007, 07:45 PM
|
#12
|
Member
Registered: Aug 2005
Distribution: Debian amd64 with 32bit libs and Debian 32 bit laptop
Posts: 119
Rep:
|
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
|
|
|
01-22-2007, 10:31 PM
|
#13
|
Senior Member
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
|
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).
|
|
|
11-30-2008, 10:42 PM
|
#14
|
LQ Newbie
Registered: Dec 2007
Posts: 15
Rep:
|
Quote:
Originally Posted by mjrclark
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

|
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 05:59 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|