Is the modem still connected (Summary)

Rohit Mehrotra rohit at dmdev.UUCP
Wed Sep 5 02:57:44 AEST 1990


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 469



More information about the Comp.unix.internals mailing list