home *** CD-ROM | disk | FTP | other *** search
- /*
- * asiflow.c
- * contains: asiflow()
- *
- * The Greenleaf Comm Library
- *
- *Copyright (C) 1985-1990 Greenleaf Software Inc. All Rights Reserved.
- */
-
- #include <stdio.h>
- #include "gf.h"
- #include "asiports.h"
-
- /*
- * int
- * asiflow(port,low_water,hi_water,ctrl,ctsctrl)
- *
- * ARGUMENT
- * (int) port = port 0..MAX_PORT-1
- * (int) low_water = Integer % of receive buffer at which RTS is asserted
- * (int) hi_water = Integer % of receive buffer at which RTS is deasserted
- * (int) ctrl = ON/OFF (1/0) to enable/disable RTS control
- * (int) ctsctrl = Controls what to do with CTS. (see below)
- *
- * DESCRIPTION
- * This function enables/disables automatic control of the RTS signal on
- * the RS-232 interface. When enabled and the number of characters in
- * the receive buffer is at or above the hi_water point the RTS signal will
- * be de-asserted. When sufficient characters have been removed from
- * the receive buffer to bring the count at or below the low_water point
- * the RTS signal will again be asserted.
- *
- * Truth table for ctrl && ctsctrl
- *
- * ctrl ctsctrl action
- *
- * 0 0 disable RTS and CTS checking & control
- * 0 1 does nothing (invalid parameter)
- * 1 0 enable RTS control, disable CTS checking
- * 1 1 enable RTS control and CTS checking
- *
- * SIDE EFFECTS
- * Offsets into buffer computed will not be exact due to integer math;
- * they are within 1% in any case, with a floor of 1 byte.
- *
- * RETURNS
- *
- * Value Meaning
- * ------- --------
- * ASSUCCESS Successful
- * ASINVPORT Requested port is out of range
- * ASNOTSETUP Requested port not setup with asifirst()
- * ASINVPAR hi or lo water <1 or >99
- *
- *
- * AUTHOR
- * "" 19-FEB-1987 14:10:19.61
- *
- * MODIFICATIONS
- *
- *
- */
-
- int GF_CONV asiflow(port,low_water,hi_water,ctrl,ctsctrl)
- int port,low_water,hi_water;
- int ctrl,ctsctrl;
- {
- struct PORT_TABLE *p;
-
- if(!ctrl&&ctsctrl)
- return(ASINVPAR);
- if((p=_aschkcnl(port))==NULL)
- return(_aserror);
- if(ctrl) {
- if((low_water<1)||(low_water>99)||(hi_water<1)||
- (hi_water>99))
- return (ASINVPAR);
- p->rts_lowater=(unsigned)(((long)p->rx_size * (long)low_water)/(long)100)&0x0000ffff;
- if(p->rts_lowater==0)
- ++p->rts_lowater;
- p->rts_hiwater=(unsigned)(((long)p->rx_size * (long)hi_water) / (long)100)&0x0000ffff;
- if(p->rts_hiwater==0)
- ++p->rts_hiwater;
- _asrts(p->base_8250,(p->rx_count<p->rts_hiwater)?1:0,p);
- p->chmode_bits.is_rtscontrol=1;
- if(ctsctrl)
- p->chmode_bits.cts_low_holds_tx_interrupts=1;
- else {
- p->chmode_bits.cts_low_holds_tx_interrupts=0;
- if(p->chst_bits.txwcts) {
- p->chst_bits.txwcts=0;
- _asiprime(p);
- }
- }
- } else {
- p->chmode_bits.is_rtscontrol=p->chmode_bits.cts_low_holds_tx_interrupts=0;
- if(p->chst_bits.txwcts) {
- p->chst_bits.txwcts=0;
- _asiprime(p);
- }
- }
- return(ASSUCCESS);
- }
-
-