LinuxQuestions.org
Visit Jeremy's Blog.
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
  Search this Thread
Old 08-26-2005, 02:05 AM   #1
ttumelty
LQ Newbie
 
Registered: Apr 2004
Distribution: Slackware & Gentoo & Ubuntu
Posts: 22

Rep: Reputation: 15
Detecting Carrier Status


To detect modem carrier status would this work :

#include <termios.h>
#include <unistd.h>


int fd;
int status;



int detectCarrier(void)
{
ioctl(fd, TIOCMGET, &status ); // get modem

status &= UART_MSR_DCD;

if ( status == 0 ) // carrier detected
res = TIOCM_CAR;
else if ( status != 0 ) // carrier not detected
res = 0;

return res;
}
 
Old 08-27-2005, 12:00 AM   #2
randyding
Member
 
Registered: May 2004
Posts: 552

Rep: Reputation: 31
I've always used a different macro, which may be the same, not sure.
ioctl(fd,TIOCMGET,&flags);
carrier_detected= 0!=(flags&TIOCM_CD);
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
NO CARRIER Error aventiskhan Linux - Networking 0 08-13-2005 03:21 AM
No carrier? ak-87 Linux - Hardware 2 04-24-2005 07:51 AM
No Carrier message PortOS Linux - Networking 3 03-27-2005 09:03 PM
no carrier on linmodem rustik Linux - Laptop and Netbook 6 03-22-2005 09:12 AM
Carrier in linux? lpriyamb Linux - Newbie 3 09-27-2003 01:27 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:58 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration