Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Computer States

Reply
Thread Tools

Computer States

 
 
Brandon B.
Guest
Posts: n/a
 
      12-18-2009
Hey all,

I'm looking for a way to programmatically wake the computer up from
sleep state, preferably at a certain time, rather than after certain
amount of time, but ill make due with whatever solution there might be.
any suggestions or help is much appreciated. i've been searching for a
couple weeks on and off for a way to do this, and can only find the
wake-on-lan, or wake-on wan (would work fine for some, but id rather
this feature not fail should the user not have a router or an internet
connection.)

Thanks in Advance,

X
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
David Masover
Guest
Posts: n/a
 
      12-18-2009
On Thursday 17 December 2009 10:04:20 pm Brandon B. wrote:
> I'm looking for a way to programmatically wake the computer up from
> sleep state, preferably at a certain time, rather than after certain
> amount of time, but ill make due with whatever solution there might be.


I suspect most BIOSes have this feature, but I have no idea how to access it
programmatically. I did find this:

http://sourceforge.net/projects/nvram-wakeup/

I have no idea how well it works, though, and it's probably going to be
system-specific.

 
Reply With Quote
 
 
 
 
Brandon B.
Guest
Posts: n/a
 
      12-18-2009
> I suspect most BIOSes have this feature, but I have no idea how to
> access it


i was thinking about bios features, but being able to access and change
certain features of it will either give the user alot of hassle or
myself in having to change things on the many different bios versions
there are, if it is even possible to change it programmatically, not to
mention the warning label that would have to be included by going that
route.

> programmatically. I did find this:
>
> http://sourceforge.net/projects/nvram-wakeup/


will definetly have to check this out, might be able to salvage
something from it, with a bit of research.

> I have no idea how well it works, though, and it's probably going to be
> system-specific.


i would like to have it be cross-platform, but i dont have a problem
with testing for the OS is need be, thanks David.
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
Phillip Gawlowski
Guest
Posts: n/a
 
      12-18-2009
On 18.12.2009 05:28, Brandon B. wrote:
>> I suspect most BIOSes have this feature, but I have no idea how to
>> access it

>
> i was thinking about bios features, but being able to access and change
> certain features of it will either give the user alot of hassle or
> myself in having to change things on the many different bios versions
> there are, if it is even possible to change it programmatically, not to
> mention the warning label that would have to be included by going that
> route.


You probably want to access http://en.wikipedia.org/wiki/ACPI
How you do that is OS specific, since it's fairly lowlevel. A very
superficial search for "Ruby ACPI library" didn't produce any real hits,
so it might be that you have to go low level to call the Windows, Linux,
and Mac OS X APIs for ACPI.

However, it is my understanding that ACPI can't wake a computer from a
Hibernating/Suspend to Disk (ACPI S4) from within the sleep state.

Hope this helps at least a little.

--
Phillip Gawlowski

 
Reply With Quote
 
Brandon B.
Guest
Posts: n/a
 
      12-18-2009
> You probably want to access http://en.wikipedia.org/wiki/ACPI
> How you do that is OS specific, since it's fairly lowlevel. A very
> superficial search for "Ruby ACPI library" didn't produce any real hits,
> so it might be that you have to go low level to call the Windows, Linux,
> and Mac OS X APIs for ACPI.


yea, i expected as much, which if fine, i just dont know how to go about
doing so... maybe there is a way to send a "wake-up" packet to the ram,
or nvram, and have it execute it from there at a given time? dont know
too much about what can and cant be performed like that so, if im way
off base, please forgive me.

> However, it is my understanding that ACPI can't wake a computer from a
> Hibernating/Suspend to Disk (ACPI S4) from within the sleep state.
> Hope this helps at least a little.


yea it has helped, thank you. i have found a linux wake up procedure
that i might be able to tether to my needs, if it works

<CODE>
#!/usr/bin/ruby
require 'time'
wake_time = Time.parse(ARGV[0])
wake_time += 24 * 60 * 60 if wake_time < Time.now
File.open('/proc/acpi/alarm', 'w') {|f| f << wake_time.utc.strftime
(%Y-%m-%d %H:%M:%S')}
system('/etc/acpi/sleep.sh force')
</CODE>

like i said, this is for linux, obviously, which if it works takes out
one of my issues, but what i dont know is if there is anything like the
above file locations for windows or mac?

well, ill keep looking around, maybe i can dig up something else using
this as a search tool, any additional help or advice is much
appreciated.
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
Phillip Gawlowski
Guest
Posts: n/a
 
      12-18-2009
On 18.12.2009 21:00, Brandon B. wrote:

> yea, i expected as much, which if fine, i just dont know how to go about
> doing so... maybe there is a way to send a "wake-up" packet to the ram,
> or nvram, and have it execute it from there at a given time? dont know
> too much about what can and cant be performed like that so, if im way
> off base, please forgive me.


You'd've to read the ACPI spec, I'm afraid, what does what, if you want
to go really, really low level, since I stay away from the Dark Arts.

> like i said, this is for linux, obviously, which if it works takes out
> one of my issues, but what i dont know is if there is anything like the
> above file locations for windows or mac?


With Windows, there's the win32api gem (pre-installed in the Once Click
Installer and/or the new RubyInstaller), providing access to the Windows
API, so you can call the Windows system calls to send the computer to
sleep. Or, maybe, you can shell out to "shutdown", but I'm not well
versed in Windows CLI tools, at least to send to computer to sleep. I'm
pretty sure that WakeOn needs an API call, though.

With Macs, and this is from my dim memory, there's CocoaRuby (I think
that's what it is called, googling for "cocoa ruby" should unearth
something), which accomplishes roughly the same as the win32api gem.

Keep in mind, you can run into binary compatibility issues on Windows
(depending on the Ruby variant installed, there's mswin32, and mingw32,
the latter being included in the new RubyInstaller), as well as on Mac
(depending on the Mac Os X API changes).

And that ain't even touching on JRuby. So, "true" cross-platform
compatibility will be difficult, to say the least.

Mind, just pick the Ruby versions you are able to report, and you'll be
fine, don't let me scare you.

--
Phillip Gawlowski

 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
state machine implementation (similar states) Enno Luebbers VHDL 3 09-07-2005 03:51 PM
PARTY IN THE STATES HackaX0rus The Lounge 11 07-05-2005 06:17 AM
ICMP not keeping states? (PIX 6.3.3) Michael Cisco 2 10-05-2004 03:09 AM
Still newbie question : Dialog between states machines. Fred Bartoli VHDL 7 02-07-2004 10:10 PM
[VHDL] a testbench question (bringing out states) - noob Yttrium VHDL 7 10-15-2003 06:03 PM



Advertisments