LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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


Reply
  Search this Thread
Old 12-30-2006, 09:50 AM   #1
mjrclark
LQ Newbie
 
Registered: Dec 2006
Posts: 6

Rep: Reputation: Disabled
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.
 
Old 12-31-2006, 08:26 PM   #2
kaz2100
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,832

Rep: Reputation: 108Reputation: 108
Hi

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

Is this what you need??

Happy Penguins!
 
Old 01-01-2007, 02:46 AM   #3
mjrclark
LQ Newbie
 
Registered: Dec 2006
Posts: 6

Original Poster
Rep: Reputation: Disabled
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.
 
Old 01-01-2007, 04:47 AM   #4
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Fedora38
Posts: 6,147

Rep: Reputation: 435Reputation: 435Reputation: 435Reputation: 435Reputation: 435
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.
 
Old 01-01-2007, 08:16 AM   #5
mjrclark
LQ Newbie
 
Registered: Dec 2006
Posts: 6

Original Poster
Rep: Reputation: Disabled
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.
 
Old 01-01-2007, 10:15 AM   #6
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Fedora38
Posts: 6,147

Rep: Reputation: 435Reputation: 435Reputation: 435Reputation: 435Reputation: 435
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
 
Old 01-02-2007, 12:02 AM   #7
davcefai
Member
 
Registered: Dec 2004
Location: Malta
Distribution: Debian Sid
Posts: 863

Rep: Reputation: 45
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.
 
Old 01-20-2007, 06:23 PM   #8
mike10
Member
 
Registered: Aug 2005
Distribution: Debian amd64 with 32bit libs and Debian 32 bit laptop
Posts: 119

Rep: Reputation: 16
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
 
Old 01-20-2007, 09:41 PM   #9
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 344Reputation: 344Reputation: 344Reputation: 344
If all you want to do is control fans, take a look at X10 device controllers. I've been using them for years.
 
Old 01-20-2007, 09:52 PM   #10
mike10
Member
 
Registered: Aug 2005
Distribution: Debian amd64 with 32bit libs and Debian 32 bit laptop
Posts: 119

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

but lets solve mjrclark's problem
 
Old 01-21-2007, 01:22 PM   #11
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 344Reputation: 344Reputation: 344Reputation: 344
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.
 
Old 01-22-2007, 07:45 PM   #12
mike10
Member
 
Registered: Aug 2005
Distribution: Debian amd64 with 32bit libs and Debian 32 bit laptop
Posts: 119

Rep: Reputation: 16
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
 
Old 01-22-2007, 10:31 PM   #13
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 344Reputation: 344Reputation: 344Reputation: 344
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).
 
Old 11-30-2008, 10:42 PM   #14
werewolfy
LQ Newbie
 
Registered: Dec 2007
Posts: 15

Rep: Reputation: 0
Quote:
Originally Posted by mjrclark View Post
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
 
  


Reply

Tags
lamp, light, programming, usb



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
FC5 light blue stripes all over the desktop from time to time SofNine Fedora 8 05-10-2006 08:48 PM
LXer: Time for Mac Users to See the OSS Light? LXer Syndicated Linux News 0 01-19-2006 12:46 PM
USB Flashdrive light does not turn off when unmounted josedsilva Linux - Hardware 5 12-29-2005 01:08 AM
HOWDOI implicitily configure a USB NIC to be eth(whatever) zareous Linux - Hardware 2 07-20-2005 01:15 AM
Time to turn on Google? rayban General 9 03-08-2005 02:46 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:02 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration