LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 03-31-2005, 07:19 PM   #1
NovHak
LQ Newbie
 
Registered: Mar 2005
Distribution: Debian "Sarge"
Posts: 6

Rep: Reputation: 0
Wake-on-ring and null-modem


Dear forum members and contributors,

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);
}
Am I good on this one?

Olivier
 
Old 06-29-2009, 01:47 AM   #2
HazByn
LQ Newbie
 
Registered: Mar 2009
Location: Malaysia
Posts: 11

Rep: Reputation: 0
Hi there,

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.
 
Old 06-29-2009, 08:43 AM   #3
NovHak
LQ Newbie
 
Registered: Mar 2005
Distribution: Debian "Sarge"
Posts: 6

Original Poster
Rep: Reputation: 0
Try to compile and execute the code I posted in this thread. Maybe it will work... You have to put the device filename as its only argument.

Hope this helps !
 
Old 06-29-2009, 12:24 PM   #4
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,390
Blog Entries: 2

Rep: Reputation: 900Reputation: 900Reputation: 900Reputation: 900Reputation: 900Reputation: 900Reputation: 900Reputation: 900
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 TIOCMSET ioctl() 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.

--- rod.
 
Old 06-29-2009, 06:50 PM   #5
NovHak
LQ Newbie
 
Registered: Mar 2005
Distribution: Debian "Sarge"
Posts: 6

Original Poster
Rep: Reputation: 0
Thanks Rod, interesting answer ! Funny that it comes more than four years later
 
Old 06-30-2009, 08:00 AM   #6
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,390
Blog Entries: 2

Rep: Reputation: 900Reputation: 900Reputation: 900Reputation: 900Reputation: 900Reputation: 900Reputation: 900Reputation: 900
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?

--- rod.
 
Old 06-30-2009, 09:20 AM   #7
NovHak
LQ Newbie
 
Registered: Mar 2005
Distribution: Debian "Sarge"
Posts: 6

Original Poster
Rep: Reputation: 0
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 !
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Null modem cable question msills Linux - Hardware 1 11-09-2005 06:15 PM
DSE 56K external modem does not hear fax ring tones johanns Linux - Hardware 2 04-28-2005 05:36 PM
PPP over null modem haxcess Linux - Networking 1 01-25-2005 05:01 PM
how to connect null-modem-cable jiawj Red Hat 1 11-25-2004 04:00 PM
Null Modem lolmc Linux - Networking 1 02-13-2002 10:17 AM


All times are GMT -5. The time now is 06:59 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration