home *** CD-ROM | disk | FTP | other *** search
- /* asigetpa.c
- *
- * The Greenleaf Comm Library
- *
- * Copyright (C) 1985-1990 Greenleaf Software Inc. All Rights Reserved.
- *
- * int asigetparms(port, baud, wordlen, parity, stopbits, dtr, rts)
- * int port; - Port 0..MAX_PORT-1
- * long *baud; - Put baud rate here (decoded integer value)
- * int *wordlen; - Put word length here (5,6,7,8)
- * int *parity; - Put parity here
- * int *stopbits; - Stopbits (1 or 2) go here
- * int *dtr; - DTR state (ON or OFF)
- * int *rts; - RTS state (ON or OFF)
- *
- * DESCRIPTION
- *
- * Read the current state of the port initialization from the 8250 and place
- * it in user variables. If any arg (except port) is NULL, that means don't
- * transfer that variable.
- *
- * SIDE EFFECTS
- * none.
- *
- * RETURNS
- *
- * Value Meaning
- * ------- --------
- * ASSUCCESS port initialized (no error)
- * ASINVPORT Requested port is out of range
- * ASNOTSETUP Requested port not setup with asifirst()
- *
- * MODIFICATIONS
- *
- * 03-12-86 wordlen,parity,stopbits values were receiving
- * values internal to 8250. This was changed
- * to return values consistent with asiinit()'s
- * parameters.
- *
- * Mon 05-Jun-1989 13:48:35
- * Modified to return BAUD38K, BAUD56K and BAUD115K
- *
- */
- #include <stdio.h>
- #include "gf.h"
- #include "asiports.h"
-
- int GF_CONV asigetparms(port,baud,wordlen,parity,stopbits,dtr,rts)
- int port;
- long *baud;
- int *wordlen,*parity,*stopbits,*dtr,*rts;
- {
-
- struct PORT_TABLE *p;
- int creg;
- unsigned int divisor;
-
- if((p=_aschkcnl(port))==NULL)
- return(_aserror);
- if (baud) {
- divisor = _asgetdivisor( p->base_8250 );
- creg=_asinb( p->base_8250 + 3 );
- if ( divisor > 0 )
- *baud = 115200L / divisor;
- else
- *baud = -1L;
- }
- if(wordlen)
- *wordlen=(creg&3)+5;
- if(stopbits)
- *stopbits=((creg>>2)&1)+1;
- if(parity) {
- creg&=0x38;
- switch(creg) {
- case 0:
- *parity = P_NONE;
- break;
- case 8:
- *parity = P_ODD;
- break;
- case 0x18:
- *parity = P_EVEN;
- break;
- case 0x28:
- *parity = P_S_STICK;
- break;
- case 0x38:
- *parity = P_M_STICK;
- break;
- }
- }
- creg=_asinb(p->base_8250+4);
- if(dtr)
- *dtr=creg&1;
- if(rts)
- *rts=(creg>>1)&1;
- return(ASSUCCESS);
-
- }