ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
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.
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.
A friend of mine is far away from home where he needs to boot his computer remotely. This computer is connected to a running one via a null-modem cable. Assuming his computer has the wake-on-ring feature enabled, and the pins no. 9 of each computer are connected via the null-modem cable, is it possible to set pin 9 of the running computer so that it wakes the other one?
Here's the program I wrote to achieve this:
Code:
#include <unistd.h>
#include <termios.h>
#include <sys/ioctl.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <errno.h>
char *procname;
int open_port (char *device)
{
int fd;
fd=open(device,O_RDWR|O_NOCTTY|O_NDELAY);
if (fd == -1)
perror(procname);
else
fcntl(fd,F_SETFL,0);
return(fd);
}
void ring (int fd)
{
int status;
if (ioctl(fd,TIOCMGET,&status))
perror(procname);
status|=TIOCM_RNG;
if (ioctl(fd,TIOCMSET,&status))
perror(procname);
}
int main (int argc,char *argv[])
{
int res;
procname=argv[0];
if (argc != 2)
{
fprintf(stderr,"%s: Wrong number of arguments!\n",argv[0]);
exit(1);
}
res=open_port(argv[1]);
if (res == -1)
{
exit(2);
}
ring(res);
close(res);
exit(0);
}
How do i test WOR (wake on ring) could someone provide me the correct steps?.I have to machine A (Ubuntu) and B (Ubuntu) and connected via null modem cable.
The RI pin of a PC serial port is an input. As such, you cannot control it, only read its status. If the peer computer is properly configured, you should be able to wake it by asserting the RI input. You can do this by cabling the RI input of the sleeping computer to one of the pins that are controllable outputs of the controlling computer. Those pins include DTR and RTS. You would then programmatically assert the pin using the TIOCMSETioctl() call.
Most commercially available cables that I have seen do not use the RI pin. You may have to get a cable made or make it yourself. If the application requires only the 'wake-up' function, then your cable should only require two conductors: RTS or DTR, and a signal ground.
Hmmm. I see. I saw the new response by HazByn, and didn't bother to check the date of the original post. Bad on me for responding to a hijacked thread.
So, did you ever get your scheme implemented?
IMHO it's a good thing that you replied, since you gave me the answer I was looking for. Eventually I don't remember we managed to have a working WOR and my program didn't work, which is normal according to your answer. Next time we will make a custom cable !
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.