⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dcet3000.c

📁 一个通讯程序源码
💻 C
📖 第 1 页 / 共 2 页
字号:
/*+-------------------------------------------------------------------------	dceT3000.c - DCE-specific portion of generic SCO UUCP dialer	Driver for Telebit T3000	wht@n4hgf.Mt-Park.GA.USdialing registers for V.32T3000SA - Version LA3.00 - Active Configuration B1  E0  L2  M0  P   Q2  V1  X12  Y0 &C1 &D2 &G0 &J0 &L0 &Q0 &R3 &S0 &T4 &X0 S000=0   S001=0   S002:1   S003=13  S004=10  S005=8   S006=2   S007=40 S008=2   S009=6   S010=14  S011:50  S012=50  S018=0   S025=5   S026=1  S038=0   S041=0   S045=0   S046=0   S047=4   S048:1   S050:6   S051:252S056=17  S057=19  S058:2   S059=0   S060=0   S061=1   S062:25  S063=0  S064=0   S068=255 S069=0   S090=0   S093=8   S094=1   S100=0   S102=0  S104=0   S105=1   S111=255 S112=1   S180=2   S181=1   S183=25  S190=1  S253=10  S254=255 S255=255 --------------------------------------------------------------------------*//*+:EDITS:*//*:09-10-1992-13:59-wht@n4hgf-ECU release 3.20 *//*:08-22-1992-15:38-wht@n4hgf-ECU release 3.20 BETA *//*:05-11-1992-17:51-wht@gyro-convert dceT2500 for a preliminary version */#include "dialer.h"/* * DCE_DTR_low_msec - milliseconds to hold DTR low to ensure DCE *                    sees the transition; this value may be changed *                    as necessary before each call to lflash_DTR(), * but, generally, a constant value will do. */long DCE_DTR_low_msec = 500;/* * DCE_DTR_high_msec - milliseconds DTR must remain high before the *                     DCE may be expected to be ready to be commanded */long DCE_DTR_high_msec = 1000L;/* * DCE_write_pace_msec - milliseconds to pause between each character *                       sent to the DCE (zero if streaming I/O is *                       permitted); this value may be changed as * necessary before each call to lwrite(), but, generally, a constant * value will do.  Note that this value is used to feed a value to Nap(), * which has a granularity of .010 seconds on UNIX/386, .020 on XENIX/286 * and .050 seconds on XENIX/86. */long DCE_write_pace_msec = 10;/* * DCE_name     - short name for DCE * DCE_revision - revision number for this module */char *DCE_name = "Telebit T3000";char *DCE_revision = "x1.10";/* * DCE_hangup_CBAUD - baud rate to use for hanging up DCE *                    and readying it for dial in access *                    (BXXX mask); use a value of zero if the speed *                    specified by the invoker is to be used. * This value is useful for DCEs such as the early Hayes 2400 * which are so unfortunately compatible with their 1200 predecessor * that they refuse to answer at 2400 baud unless you last spoke to * them at that rate. For such bad boys, use B2400 below. */int DCE_hangup_CBAUD = 0;/* int DCE_hangup_CBAUD = B2400; *//* * DCE_results - a table of DCE response strings and a token *               code for each; when you call lread() or lread_ignore(), *               if the read routine detects one of the strings, * the appropriate code is returned.  If no string matches, then * lread()/lread_ignore examines the DCE result string for a * numeric value; if one is found, the numeric value or'd with * 0x40000000 is returned (in this way, e.g., you can read "modem * S registers").  If nothing agrees with this search, lread() * will abort the program with RC_FAIL|RCE_TIMOUT, lread_ignore() * will return -1.  You may use any value between 0 and 0x3FFFFFFF. * This module is the only consumer  of the codes, although they * are decoded by gendial.c's _lread() *//* flag bits */#define rfConnect		0x00800000#define rfMASK			0x0000FFFF	/* mask off rfBits *//* unique codes */#define rOk				0#define rNoCarrier		1#define rError			2#define rNoDialTone 	3#define rBusy			4#define rNoAnswer		5#define rRring			6#define rDialing		7#define rConnect300		(   300 | rfConnect)#define rConnect1200	(  1200 | rfConnect)#define rConnect2400	(  1200 | rfConnect)#define rConnect9600	(  9600 | rfConnect)#define rConnect19200	( 19200 | rfConnect)#define rConnect38400	( 38400 | rfConnect)DCE_RESULT DCE_results[] ={	{ "OK",						rOk,			},	{ "NO CARRIER",				rNoCarrier,		},	{ "ERROR",					rError			},	{ "NO DIALTONE",			rNoDialTone,	},	{ "BUSY",					rBusy			},	{ "NO ANSWER",				rNoAnswer		},	{ "DIALING",				rDialing		},	{ "RRING",					rRring			},	{ "CONNECT 300",			rConnect300		},	{ "CONNECT 1200",			rConnect1200	},	{ "CONNECT 2400",			rConnect2400	},	{ "CONNECT 9600",			rConnect9600	},	{ "CONNECT 19200",			rConnect19200	},	{ "CONNECT 38400",			rConnect38400	},	{ (char *)0,				-1				}		/* end table */};#include "tbit.sync.h"/*+-------------------------------------------------------------------------	DCE_baud_to_CBAUD(baud) - check for valid baud rates supported by DCE  DCE dependent function must validate baud rates supported by DCE  returns baud rate in struct termio c_cflag fashion  or terminates program with error--------------------------------------------------------------------------*/intDCE_baud_to_CBAUD(baud)unsigned int baud;{	switch(baud)	{		case 110:  return(B110);		case 300:  return(B300);		case 1200: return(B1200);		case 2400: return(B2400);		case 9600: return(B9600);#if defined(B19200)		case 19200: return(B19200);#else#ifdef EXTA		case 19200: return(EXTA);#endif#endif#if defined(B38400)		case 38400: return(B38400);#else#ifdef EXTB		case 38400: return(EXTB);#endif#endif	}	myexit(RC_FAIL | RCE_SPEED);#if defined(OPTIMIZE) || defined(__OPTIMIZE__)	/* don't complain */	return(0);	/* keep gcc from complaining about no rtn at end */#endif}	/* end of DCE_baud_to_CBAUD *//*+-------------------------------------------------------------------------	init_T3000() - init T3000 from scratch, assuming nothing	reset to factory defaults, then set    E0          no local echo in command mode    &C1         DCD follows carrier    &D2         disconnect on DTR loss    M0          speaker off    Q2          generate reult codes only for originating use    V1          verbal result codes    X12         fullest result code set    S0=1        answer on first ring    S2=255        escape to unusual value    S11=50      50 msec DTMF timing    S45=0       disable remote access    S48=1       all 8 bits are significant    S50=0       use automatic connect speed determination    S51=252     set serial port baud rate automatically (no typeahead)    S58=2       DTE uses CTS/RTS flow control.	S61=0       send BREAK (rather than go to command mode)	S62=25      BREAK duration 250 msec (default is 150)	S63=0       send BREAK in sequence    S64=1       ignore characters sent by DTE while answering    S66=0       don't lock interface speed, just go with the flow.    S69=0       omit XON/XOFF flow control    S68=255     DCE uses whatever flow control DTE uses    S111=255    accept any protocolThe nvram is set to factory + E0 Q0 &C1 &D2 S51=252 --------------------------------------------------------------------------*/voidinit_T3000(){register itmp;int maxretry = 4;char *init0="AT&F E0 Q0 &C1 &D2 S51=252 &w M0 Q2 V1 X12\r";char *init1="ATS0=1 S2=255 S11=50 S45=0 S48=1 S50=0 \r";char *init2="ATS58=2 S61=0 S62=25 S63=0 S62=25 S64=1 S66=0 S68=255 S111=255\r";	DEBUG(1,"--> initializing %s on ",DCE_name);	DEBUG(1,"%s\n",dce_name);	lflash_DTR();	sync_Telebit();	/*	 * set to factory default (bless them for this command)	 * and a few initial beachhead values	 */	for(itmp = 0; itmp < maxretry; itmp++)	{		lwrite(init0);		if(lread(5) == rOk)			break;	}	if(itmp == maxretry)	{		DEBUG(1,"INIT FAILED (init0)\n",0);		myexit(RC_FAIL | RCE_TIMOUT);	}	/*	 * send initialization string 1	 */	for(itmp = 0; itmp < maxretry; itmp++)	{		lwrite(init1);		if(lread(5) == rOk)			break;	}	if(itmp == maxretry)	{		DEBUG(1,"INIT FAILED (init1)\n",0);		myexit(RC_FAIL | RCE_TIMOUT);	}	/*	 * send initialization string 2	 */	for(itmp = 0; itmp < maxretry; itmp++)	{		lwrite(init2);		if(lread(5) == rOk)			break;	}	if(itmp == maxretry)	{		DEBUG(1,"INIT FAILED (init2)\n",0);		myexit(RC_FAIL | RCE_TIMOUT);	}}	/* end of init_T3000 *//*+-------------------------------------------------------------------------	DCE_hangup() - issue hangup command to DCEThis function should do whatever is necessary to ensure1) any active connection is terminated2) the DCE is ready to receive an incoming call if DTR is asserted3) the DCE will not accept an incoming call if DTR is falseThe function should return when done.Any necessary switch setting or other configuration necessary for thisfunction to succeed should be documented at the top of the module.--------------------------------------------------------------------------*/voidDCE_hangup(){	DEBUG(4,"--> hanging up %s\n",dce_name);	init_T3000();}	/* end of DCE_hangup *//*+-------------------------------------------------------------------------	DCE_dial(telno_str) - dial a remote DCEThis function should connect to the remote DCE and use any successindication to modify the tty baud rate if necessary before returning.Upon successful connection, return 0.Upon unsuccessful connection, return RC_FAIL or'd with an appropriateRCE_XXX value from dialer.h.lwrite() is used to write to the DCE.lread() and lread_ignore() are used to read from the DCE.  Read timeoutsfrom calling lread() will result automatically in the proper error

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -