0

I have some machine that depending on Power being generated from a Solar array I want to be able to Turn On & Turn off these WIn 7 PC'S

I have the power output data going to a DB so that side is sorted

I understand about WAKE ON LAN magic packets etc

Is there an API that i can code this functionality to automate this process or is there a hardware gadget solution that i could hook the power switches on the mobo to etc ???

HoopSnake
  • 716
  • 1
  • 5
  • 17
  • WOL packets are not too hard to craft yourself, you can find lots of code samples for C# on the net. Hardly worth pulling in a library for that. – us2012 Feb 19 '13 at 03:51
  • You can build your own Windows service or Console Application that is always running on the background checking that Power output DB and when it hits the desired level you could turn off the computer programmatically. Check [this post](http://codehill.com/2009/01/shutdown-or-restart-the-computer-using-c/) – juanreyesv Feb 19 '13 at 03:53
  • http://stackoverflow.com/questions/102567/how-to-shutdown-the-computer-from-c-sharp – kenny Feb 19 '13 at 03:55

1 Answers1

0

A wake-on-lan packet is simply any network or transport level packet with a certain signature.

The expected signature is:

6 Bytes of a header (set to 0xFF)
16 repetitions of a target MAC Address (6 bytes each)
... for a total of 6 + 6 * 16 = 102 bytes

Note that these are typically sent (broadcasted rather) as a user-datagram (UDP) packet to port 7, or 9.

Here is a very detailed Wiki article: http://en.wikipedia.org/wiki/Wake-on-LAN

If you would like to look at a sample implementation in Go (I know its not C#, but you can get an idea of how it works), take a look at a magic_packet handler I wrote.

As far as remote power on (physical)

You can explore buying an IP power switch, which you can send a wake / shutdown command to over some managed interface (typically HTTP). These are commercially available and can cost a bit.

I think you can also go the route of building some type of micro-controller which can be triggered via Wifi to manage a relay connected to your PCs power switch. Lots of options :)

sabhiram
  • 897
  • 7
  • 10