home *** CD-ROM | disk | FTP | other *** search
- /* getct.c
- *
- * The Greenleaf Comm Library
- *
- * Copyright (C) 1985-1990 Greenleaf Software Inc. All Rights Reserved.
- *
- * int asigetc_timed( port, ticks )
- * int port; - Port 0..MAX_PORTS-1
- * int ticks;
- *
- * DESCRIPTION
- * this function "gets" a character from the communications port
- * using interrupt mode. It will wait for up to the tick count for
- * a character if the buffer is empty.
- *
- * SIDE EFFECTS
- * none.
- *
- * RETURNS
- *
- * Value Meaning
- * ------ -------
- * 0 thru 255 Return value equals character received
- * ASINVPORT Requested port is out of range
- * ASNOTSETUP Requested port not setup with asifirst()
- * ASBUFREMPTY Requested port's buffer is empty
- *
- * MODIFICATIONS
- *
- * 11-01-85 ""
- * Modified for release 2.0
- *
- * 23-FEB-1987 08:55:40.44
- * removed call to _aschkcnl(), replaced with in-line code for speed.
- *
- * Mark Nelson 07-DEC-1989
- * Converted to use timed option in 3.0
- */
- #include <stdio.h>
- #include "gf.h"
- #include "asiports.h"
-
- int GF_CONV asigetc_timed( int port, int ticks )
- {
- struct PORT_TABLE *p;
-
- if ( port < 0 || port >= MAX_PORT ) {
- _aserror = ASINVPORT ;
- return( ASINVPORT );
- }
- if ( as_chnl == NULL || ( p = as_chnl->tblport[port].ptb ) == NULL ) {
- _aserror = ASNOTSETUP;
- return( ASNOTSETUP );
- }
- _aserror= ASSUCCESS;
- while ( p->chst_bits.rxempty == 1 )
- {
- if ( ticks <= 0 )
- return( ASBUFREMPTY );
- ticks--;
- timer(1);
- }
- return( _asigetc( p ) );
- }
-