rohit@dmdev.UUCP (Rohit Mehrotra) (09/04/90)
Hi,
Sometime back I had posted in just about all the news groups
asking if some one knew as to how to find out if the modem is
still connected on the other end or how to find out the state
of the carrier detect signal.
I received a lot of replies showing interest in this query, but
none actually helping with specific ioctl calls, to find out.
I then contacted Mr Tony Vincent and Mr Ray Jang in Sun Technical
support, and they helped me finally in providing the correct
solution.
I want to thank Mr Tony Vincent for actually providing the correct
code, and Mr Ray Jang for taking the time to find out the correct
environment in which the program provided by Tony would work.
PLATFORM:
This solution works ONLY on SunOS4.1 and has been tested on SS1.
If any one can help on any other platform please EMAIL me the
response and I would test it and then post it in another summary.
SOLUTION:
Only the software carrier detect should be enabled. If the
hardware carrier detect is enabled then the program would not
only hang but also give errors like: Device Not Found etc.
This is an undocumented feature in SunOS 4.1. The ttytab entry
should have the status as : off local secure. This ensures that
only software carrier detect signal is used.
/********************** Cut Here ******************************/
/* check is carier is on */
#include <stdio.h>
#include <sys/ioctl.h>
#include <sys/ttycom.h>
#include <fcntl.h>
#include <errno.h>
main(c,v)
int c;
char *v[];
{
char p[16];
int st;
int fd;
if(c < 1)
{
printf("usage: %s ttyport\n",v[0]);
exit(1);
}
sprintf(p,"/dev/%s\0",v[1]);
printf("Port to be opened %s\n",p);
fd=open(p,O_RDWR|O_NDELAY,0666);
fflush(stdout);
if(fd < 0)
{
printf("Can't open %s %d\n",p,errno);
perror(p);
fflush(stdout);
exit(1);
}
ioctl(fd,TIOCMGET,&st);
if(st & TIOCM_CD) printf("carrier on\n");
else printf("carrier off\n");
close(fd);
}
--
Rohit Mehrotra
Fleet Credit Corporation
8325 NW 53rd St, Miami, Fl 33166.
E-MAIL Address uunet!dmdev!rohit VOICE 1-(305)-477-0390 Ext 469rohit@dmdev.UUCP (Rohit Mehrotra) (09/05/90)
Hi , I have a Unix question on platforms other than SunOS4.1. I have the solution for SunOS4.1. I had posted this question earlier in different newsgroups, however no body seems to know the answer. I do know it now for SunOS4.1. Q) How do I find out inside a C program (which dials out on a serial port) as to whether the modem is still connected to the remote machine, or for some reason it has lost connection. i.e. if the carrier detect signal is still on or not. I think that some ioctl call would have to be used, but I am not sure which and how? If you do happen to know or if someone you know happens to know I would appreciate your help. I Have The Solution For SunOS4.1. Solutions On Any Other Variants Of Unix Are Welcome. Please EMAIL the responses directly, and I would post a summary. Thanks Rohit EMAIL: dmdev!rohit@uunet.uucp -- Rohit Mehrotra Fleet Credit Corporation 8325 NW 53rd St, Miami, Fl 33166. E-MAIL Address uunet!dmdev!rohit VOICE 1-(305)-477-0390 Ext 469