home *** CD-ROM | disk | FTP | other *** search
- /* wgetct.c
- *
- * The Greenleaf Comm Library
- *
- * Copyright (C) 1989-90 Greenleaf Software Inc. All Rights Reserved.
- *
- * int asiwgetc_timed( port, stat, ticks )
- * int port; - Port 0..MAX_PORT-1
- * char *stat; - Where to put status if Wide Track buffer
- * int ticks; - The maximum number of clock ticks to wait before
- * returning a timeout error.
- *
- * DESCRIPTION
- * this function "gets" a character and it's status from the communications
- * port using interrupt mode. WideTrack Rx must be enabled.
- *
- * 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
- * ASNOWIDERX Wide Track receive not enabled for this channel.
- *
- * MODIFICATIONS
- *
- * 11-01-85 ""
- * Modified for release 2.0
- *
- * 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 asiwgetc_timed( int port, char *stat, int ticks )
- {
- int charstat;
- struct PORT_TABLE *p;
-
- p = _aschkcnl( port );
- if ( p == NULL )
- return(_aserror);
- if ( p->chmode_bits.is_rxerror == 0 )
- return( ASNOWIDERX );
- while ( p->chst_bits.rxempty == 1 ) {
- if ( ticks <= 0 )
- return( ASBUFREMPTY );
- timer(1);
- ticks--;
- }
- charstat = _asigetc( p );
- if ( stat != NULL )
- *stat = ( char ) (( charstat >> 8 ) & 0xff);
- return( charstat & 0xff);
- }
-