Author Topic: Wake on LAN  (Read 1526 times)

Andy P.

  • Newbie
  • *
  • Posts: 4
    • View Profile
Wake on LAN
« on: 2012.09.08, 12:28:51 »
Code: [Select]
/*magic.cmd*/
/*Wake on Lan in REXX*/
MAC = '11:22:33:44:55:66';
SAY MAC;
A = X2C(SUBSTR(MAC,1,2));
B = X2C(SUBSTR(MAC,4,2));
C = X2C(SUBSTR(MAC,7,2));
D = X2C(SUBSTR(MAC,10,2));
E = X2C(SUBSTR(MAC,13,2));
F = X2C(SUBSTR(MAC,16,2));
X = A||B||C||D||E||F;
call RxFuncAdd 'SockLoadFuncs', 'rxsock', 'SockLoadFuncs';
call SockLoadFuncs('*'); 
SCT = SockSocket('AF_INET', 'SOCK_DGRAM', 'IPPROTO_UDP');
RC = SockSetSockOpt(SCT, 'SOL_SOCKET', 'SO_BROADCAST', '1');
RC = SockIOCtl(SCT, 'FIONBIO', '0');
adr.!family = 'AF_INET';
adr.!addr   = '255.255.255.255';
adr.!port   = 9;
S = COPIES(D2C(255) ,6);
T = COPIES(X ,16);
G = COPIES(D2C(0) ,6);
RC = SockConnect(SCT, "adr.!");
STG = S||T||G;
SAY STG;
RC = SockSend(SCT, STG);
call SockSoClose SCT;
exit;

jep

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 421
    • View Profile
Re: Wake on LAN
« Reply #1 on: 2012.09.10, 08:32:05 »
Hello,

Neat!

Is it possible with rexx to find out the MAC address on the computers on the LAN?

Would it be interesting to only specify/use the hostname of the computer and with that run the magic.cmd code to wake that specific computer.

//Jan-Erik

DougB

  • Sr. Member
  • ****
  • Posts: 407
    • View Profile
Re: Wake on LAN
« Reply #2 on: 2012.09.10, 17:05:14 »
I have tried it on the four of the five computers, that I have, where it should work. Only one will power on. Of course, it isn't the one that I would like to use it on. I suspect that the problem is that windows turns off the feature by default, and the eCS drivers (Multimac for Intel, Multimac for NVIDIA, and GENMAC for Broadcom) doesn't enable it at shutdown. The one that does work, is a Realtek 8139, using the RTSND driver. I need to find more time to play with this, but it does look like it does what it is supposed to do.  Thanks...   :)

DougB

  • Sr. Member
  • ****
  • Posts: 407
    • View Profile
Re: Wake on LAN
« Reply #3 on: 2012.09.10, 17:55:18 »
Yes, you need to enable magic packets in the windows drivers. Then, the machines will turn on. However, if you run eCS, the driver seems to know nothing about enabling magic packet support, and the machine will not power on after running eCS. I tried this with my Lenovo ThinkPad T510, using the Multimac Intel driver from e1000e-0.2.3.wpi. Some other eCS drivers may work.

DougB

  • Sr. Member
  • ****
  • Posts: 407
    • View Profile
Re: Wake on LAN
« Reply #4 on: 2012.09.10, 23:00:14 »
More information:

With my A8N-SLI motherboard, using the driver from nveth-0.1.10.wpi, I went to windows XP, and enabled the magic packets option in the driver. Now it will wake up, even after running eCS. This happens to be the one that I want to be able to wake up, so that is good.

On my IBM ThinkPad T43 (1871-W8M), I can't seem to convince it to work. I suspect that I may not have found the right BIOS, and/or, windows settings, yet.

On my antique IBM ThinkPad A22e, turning on the setting in the BIOS did the trick.

It appears that the eCS drivers may not mess with the magic packets feature, but it also appears that my Lenovo T510, using the Multimac Intel driver from e1000e-0.2.3.wpi, does turn off the feature, unless it is specifically enabled by the driver at shutdown. This is probably a "security" feature. So, the driver needs to enable magic packets at shutdown for Magic.CMD to be able to turn it back on. Not important for what I want to do, but it may help others.

I suspect that it is NOT a good idea to enable laptops to power on with a magic packet anyway. If it gets one at an unexpected time, it may cause system damage.

Now, the next question that I have, is how can one tell a remote computer to shut down (cleanly, of course), from a program? I can see this being useful to power on the machine that I want to backup to, do the backup, then tell it to shut down. Of course, the shutdown is really an indication that "this" machine is finished. some other machine may also be doing a backup, and it would not be good to pull the plug on that.

DougB

  • Sr. Member
  • ****
  • Posts: 407
    • View Profile
Re: Wake on LAN
« Reply #5 on: 2012.09.14, 17:46:24 »
Quote
On my IBM ThinkPad T43 (1871-W8M), I can't seem to convince it to work. I suspect that I may not have found the right BIOS, and/or, windows settings, yet.

Exactly. It seems that you need to enable the LAN ROM feature, before you can enable the magic packet feature. Oddly enough, once it is enabled, you can turn off the ROM feature again.

So, the bottom line is that the script works, but the user does need to do more than just use the script to make it turn a machine on. It also looks like the Multimac project will need to support the feature, depending on what windows version, and NIC is being used. I have no idea what other operating systems would need to make them allow a power on.

Andy P.

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Wake on LAN
« Reply #6 on: 2012.09.15, 21:26:30 »
There is no need to care especially about WakeOnLan in MultiMac. If the drivers don't touch the registers, everything is fine. Fortunately, WakeOnLan works on BIOS level and is similar to WakeOnKeyboard. There are only few points:
1.) Some computer manufacturer sells their machines with power off=S5 to meet certain green terms. Swich this back to S3.
2.) OSes have the possibility to mix this up. Windows (what else) will do this by change the registers of network cards to not listen to magic packets.
So you have to configure the card driver to set the network card back to listening. There are some rare Linux distributions that do this too, but the major part does switch WakeonLan back on at shutdown.
3.) There are some network cards with especially no WakeOnLan (e.G some 3Com), that can't be turn. If in doubt, read the manual of the Card.

WakeOnLan standards specifies a password for magic packets. Some network cards can be set to check a WakeOnLan-passwort before waking up the computer. I don't know which card uses this, nor how the password can be set. If you have such card, the password goes to the variable G (default 0x000000000000) in the same manner like the variable X.
The Mac can be found with the command line: arp -a

To say this clear:
This little rexx script is just a finger exercise and have no copyright value in my point of view, so I gave no copyright disclaimer. Feel free to use it.
As usual for WakeOnLan, you are not sticked to eCs- computers. Also Windows-, Linux- and MAC- driven computers can be awakened. Even non-computer systems can be switched on (If they know about WakeOnLan). In my case, I wrote this to switch on my satellite receiver from my eCs-Box ;)
Andy
« Last Edit: 2012.09.15, 21:35:49 by Andy P. »

DougB

  • Sr. Member
  • ****
  • Posts: 407
    • View Profile
Re: Wake on LAN
« Reply #7 on: 2012.09.16, 16:50:07 »
Quote
There is no need to care especially about WakeOnLan in MultiMac.

Unfortunately, that is not true, for two main reasons:

1) There needs to be a way for eCS to turn on the feature. It seems that in most cases, it is disabled. If the user does not have another OS installed, that is capable of turning it on, it can't be done. It seems that BIOS no longer has control over that, as it did in earlier machines. BIOS can prevent it from being turned on, but it cannot turn it on by itself.

2) It seems that newer machines (my Lenovo ThinkPad T510, for instance), will not leave that setting turned on, unless the driver enables it at shutdown (obviously some sort of security feature). So, if I run Win7, and enable magic packets, I can shut down, and I can use your program (well done, by the way) to turn it back on. Now, if I boot to eCS, it works fine, until I shut down, then I cannot turn it back on, using magic packets, until I run windows again, and that requires a manual power on, using the machine switch, not magic packets.

Those two "problems" should be addressed, and Multimac seems to be the way that it needs to be done (at least for the the devices operated by the Multimac driver).

I have opened an incident in TRAC for Multimac. Whether it will be fixed, or not, is up to the developers.

eirik

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: Wake on LAN
« Reply #8 on: 2012.09.17, 21:04:03 »
There is obviously more to suspend and resume than many of us expected.  While it would be nice to have suspend and resume working including wake up of LAN, I view it more important to get the other FnFX buttons working, in particular the one so that eCS laptop users can hook their PC to a beamer and use eCS for their presentations (rather than going to their Win partitions).  In addition to increasing the value of eCS for current users, this is also a nice way of reminding other computer users that there are other platforms than Win out there that do the job (at least as well as Win does).

How far are we from a workable solution.  I do not know as reports vary depending on what hardware people have.  For example on my Lenovo Thinkpad T410, the sound mute button works (and integrates with pmtpos2), the Fn buttons for adjusting brightness and light up the keyboard work, while volume adjustment does not work.

Constructive regards / Eirik