home *** CD-ROM | disk | FTP | other *** search
- /* _isstat.c
- *
- * The Greenleaf Comm Library
- *
- * Copyright (C) 1985-1990 Greenleaf Software Inc. All Rights Reserved.
- *
- * int _isstat(port,option,cmd)
- * int port; - Port 0..15
- * int option; - What to check
- * int cmd; - What to do
- *
- * DESCRIPTION
- * Check whether or not some condition exists. This function supports
- * Flags and basic line and modem status Groups of the is*() macros defined in
- * asiports.h.
- *
- * SIDE EFFECTS
- * none.
- *
- * RETURNS
- *
- * Returns 1 or 0 depending whether or not the condition the condition
- * is true or false. Also can return the following error returns.
- *
- * Value Meaning
- * ------- --------
- * ASINVPORT Requested port is out of range
- * ASNOTSETUP Requested port not setup with asifirst()
- * ASINVPAR Invalid parameter
- *
- * MODIFICATIONS
- * 10-29-85 David Nienhiser
- * David Nienhiser 11-FEB-1987 13:15:43.68
- * Case 11 in switch statement was checking bit 2 (TERI) instead of
- * bit 3 (DRLSD)
- */
- #include <stdio.h>
- #include "gf.h"
- #include "asiports.h"
-
- int GF_CONV _isstat(port,option,cmd)
- int port,option,cmd;
- {
- struct PORT_TABLE *p;
- unsigned temp;
-
- if((p=_aschkcnl(port))==NULL)
- return(_aserror);
- if ((option!=CUMULATIVE)&&(option!=IMMEDIATE)) return (ASINVPAR);
- switch(cmd) {
-
- case 1: /* Has a receiver overrun error occurred */
- temp=(option==CUMULATIVE)?p->line_stat:
- (unsigned)_asinb(p->base_8250+5);
- return((temp&2)?TRUE:FALSE);
-
- case 2: /* Has a parity error occurred */
- temp=(option==CUMULATIVE)?p->line_stat:
- (unsigned)_asinb(p->base_8250+5);
- return((temp&0x0004)?TRUE:FALSE);
-
- case 3: /* Has a framing error occurred */
- temp=(option==CUMULATIVE)?p->line_stat:
- (unsigned)_asinb(p->base_8250+5);
- return((temp&0x0008)?TRUE:FALSE);
-
- case 4: /* Has a break signal been received */
- temp=(option==CUMULATIVE)?p->line_stat:
- (unsigned)_asinb(p->base_8250+5);
- return((temp&0x0010)?TRUE:FALSE);
-
- case 5: /* Return the state of CTS */
- temp=(option==CUMULATIVE)?p->modem_stat:
- (unsigned)_asinb(p->base_8250+6);
- return((temp&0x0010)?TRUE:FALSE);
-
- case 6: /* Return the state of DSR */
- temp=(option==CUMULATIVE)?p->modem_stat:
- (unsigned)_asinb(p->base_8250+6);
- return((temp&0x0020)?TRUE:FALSE);
-
- case 7: /* Return the state of Carrier Detect */
- temp=(option==CUMULATIVE)?p->modem_stat:
- (unsigned)_asinb(p->base_8250+6);
- return((temp&0x0080)?TRUE:FALSE);
-
- case 8: /* Return the state of Ring Indicator */
- temp=(option==CUMULATIVE)?p->modem_stat:
- (unsigned)_asinb(p->base_8250+6);
- return((temp&0x0040)?TRUE:FALSE);
-
- case 9: /* Has there been a change in CTS */
- temp=(option==CUMULATIVE)?p->modem_stat:
- (unsigned)_asinb(p->base_8250+6);
- return((temp&0x0001)?TRUE:FALSE);
-
- case 10: /* Has there been a change in DSR */
- temp=(option==CUMULATIVE)?p->modem_stat:
- (unsigned)_asinb(p->base_8250+6);
- return((temp&0x0002)?TRUE:FALSE);
-
- case 11: /* Has there been a change in CD */
- temp=(option==CUMULATIVE)?p->modem_stat:
- (unsigned)_asinb(p->base_8250+6);
- return((temp&0x0008)?TRUE:FALSE);
-
- case 12: /* Has there been a change in RI */
- temp=(option==CUMULATIVE)?p->modem_stat:
- (unsigned)_asinb(p->base_8250+6);
- return((temp&0x0004)?TRUE:FALSE);
-
- default:
- return(ASINVPAR);
- }
- }
-
- /* Check character counter with parameter, return true if character counter
- is the same as or greater than the count parameter.
- */
- int GF_CONV isxmrxcnt(port,count)
- int port;
- unsigned count;
- {
- extern int _aserror;
- struct PORT_TABLE * GF_CONV _aschkcnl(),*p;
- if((p=_aschkcnl(port))==NULL)
- return(_aserror);
- return((p->rx_accum>=count)?TRUE:FALSE);
-
- }
-