[comp.sys.att] VOICE/DATA toggle for 3B1

hartman@uiucdcsm.cs.uiuc.edu (10/11/87)

Does anyone have a program for the 3b1/7300 which will toggle ph0
between VOICE and DATA like F3 does from within the phone manager?
I am looking for something that can be placed in crontab to switch
my line to DATA at night.

-------------------------------------------------------------------
Mark Hartman			    ihnp4!uiucdcs!hartman

lenny@quincy.UUCP (Lenny Tropiano) (10/12/87)

In article <7600003@uiucdcsm>, hartman@uiucdcsm.cs.uiuc.edu writes:
> 
> Does anyone have a program for the 3b1/7300 which will toggle ph0
> between VOICE and DATA like F3 does from within the phone manager?
> I am looking for something that can be placed in crontab to switch
> my line to DATA at night.
> 

This is a feature given to us in the 3.51 release of the operating system.
A program called "phtoggle" toggles the phone line from VOICE->DATA, 
DATA->VOICE in any phone line configuration (ie. one or two line setup). 
Although there wasn't given any way to go to a particular mode (ie. set
it to DATA or set it to VOICE), if the cron got messed up then the
toggle would just reverse the lines to VOICE or DATA and it might be the
opposite one you wanted.

						-Lenny

BTW:  I don't know of an effective way to do this under 3.5 or less.
-- 
Lenny Tropiano                      ...seismo!uunet!godfre!quincy!lenny  -or-
American LP Systems, Inc.           ...cmcl2!phri!gor!helm!quincy!lenny  -or-
1777-18 Veterans Memorial Hwy.   	          ...mtune!quincy!lenny  -or
Islandia, New York 11722     +1 516-582-5525 ...ihnp4!icus!quincy!lenny

egray@fthood.UUCP (10/12/87)

To switch between VOICE and DATA, run the "phtoggle" program.  It takes
a few seconds to find the pid of the phone manager and kill it, so
if you're using it in a shell script, you'd better put in a few sleep's 
such as:

	phtoggle
	sleep 6
	<make your phone call>
	phtoggle

I'm not sure what version of Unix they sneeked that in, it's definately
in 3.51

Emmet P. Gray				US Army, HQ III Corps & Fort Hood
...!ihnp4!uiucuxc!fthood!egray		Attn: AFZF-DE-ENV
					Directorate of Engineering & Housing
					Environmental Management Office
					Fort Hood, TX 76544-5057

robert@pttesac.UUCP (Robert Rodriguez) (10/13/87)

In article <7600003@uiucdcsm> hartman@uiucdcsm.cs.uiuc.edu writes:
>
>Does anyone have a program for the 3b1/7300 which will toggle ph0
>between VOICE and DATA like F3 does from within the phone manager?
>I am looking for something that can be placed in crontab to switch
>my line to DATA at night.
>
>-------------------------------------------------------------------
>Mark Hartman			    ihnp4!uiucdcs!hartman

/*
 *
 * phstat	A quick hack to get the status of the phone line so
 *		we can decide whether or not to toggle it.
 *
 *		At home, I have only one line, so when I leave for work
 *		I want my phone line set to DATA.  I run a shell script
 *		from cron at 7:00 AM, that goes something like this:
 *
 *
 *		Status=`/usr/lbin/phstat /dev/ph0`
 *
 *		if [ "$Status" = "VOICE" ] ; then
 *		  /usr/bin/phtoggle
 *		fi
 *
 *
 *		Again, this was a quick hack, and I'm sure it could be
 *		done better, so no flames please.
 *
 *
 * Robert Rodriguez  {inhp4|ptsfa}!pttesac!robert
 */

#include	<sys/phone.h>

/*
 * We could include fcntl.h, but why ?
 */

#define		O_RDWR		2
#define		O_NDELAY	04

main(argc, argv)
int	argc;
char	**argv;
{
	int	fd;

	struct	updata	phdata;

	if(argc != 2) {
		printf("Usage: phstat <device>\n");
		exit(1);
	}

	if((fd = open(argv[1], O_RDWR | O_NDELAY)) != 0)
		exit(1);

	if((ioctl(fd, PIOCGETP, &phdata)) != 0)
		exit(1);

	if(phdata.c_lineparam & VOICE)
		printf("VOICE\n");
	else
		printf("DATA\n");

	close(fd);

	exit(0);
}


Hope this helps.....