/* header file for the comm_int.obj functions */ /* <%Z%%M% %Q% sccs %I%> */ /**************************************************************************** com_int.h: Date Written: 11/3/95 Written by: John LaBatt Project: COMDEMO.MAK Purpose: This is the include file for our structure for opening a com port the functions are located in comm_int.obj ****************************************************************************/ /* constants for the different settings for the com port */ #define BAUD38400 0x120 #define BAUD19200 0x100 #define BAUD9600 0xE0 #define BAUD4800 0xC0 #define BAUD2400 0xA0 #define BAUD1200 0x80 #define BAUD600 0x60 #define BAUD300 0x40 #define BAUD150 0x20 #define BAUD110 0x00 #define NOPARITY 0x00 #define ODDPARITY 0x08 #define EVENPARITY 0x18 #define STOP1 0x00 #define STOP2 0x04 #define BITS7 0x02 #define BITS8 0x03 /* XONXOFF for both modem_ready, modem_ctrl */ #define XONXOFF 0x04 /* XON/XOFF handshake */ /* CTS, DSR, RI, DCD for modem_ready/modem_status only */ #define CTS 0x10 /* CTS in */ #define DSR 0x20 /* DSR in */ #define DCD 0x80 /* DCD in */ #define RI 0x40 /* RI in (not usable as handshake) */ /* RTS, DTR for modem_ctrl */ #define RTS 0x02 /* RTS out */ #define DTR 0x01 /* DTR out */ #define BSIZE 255 #define ByTe unsigned char /* funny caps so don't interfere with user */ typedef struct { int num; /* 0 to 3, 0 = COM1, 1 = COM2, etc. */ int intr; /* 2 to 15, interrupt line */ int intr_ctrl; /* interrupt controller address */ ByTe mask; /* my interrupt mask bit */ ByTe old_mask; /* old interrupt mask bit */ long old_vec; /* saved interrupt vector for this line */ int mode; /* != 0 => new mode setting */ int old_DL; /* save area for old baud divisor */ ByTe old_LCR; /* save area for old line control register */ ByTe old_MCR; /* save area for old modem control register */ ByTe old_IER; /* save area for old intr enable register */ ByTe pend_XONXOFF; /* != 0 => this XON or XOFF must be sent */ int addr; /* port I/O address, 0 => set by open_comm */ int start_rcv; /* buf_used count to allow new chars */ int stop_rcv; /* buf_used count to disallow new chars */ ByTe modem_status; /* current modem status register */ ByTe modem_ready; /* modem status bits for output handshake */ ByTe modem_on; /* modem control bits currently on */ ByTe modem_ctrl; /* modem control bits to be used for handshake */ } CoMm_PoRt; typedef struct { char far* buf; /* pointer to character buffer */ char far* buf_end; /* pointer past end of character buffer */ int size; /* size of buffer */ int used; /* chars in buffer */ char far* buf_get; /* points to next char to read from buffer */ char far* buf_put; /* points to next free space in buffer */ } CoMm_BuFfEr; typedef struct comm_cb_s { CoMm_PoRt port; /* port information */ CoMm_BuFfEr inbuf; /* input buffer */ CoMm_BuFfEr outbuf; /* output buffer */ } COMM_CB; extern COMM_CB com_port; extern char inchars[]; extern char outchars[]; #define comm_cb(name,num,mode,modem_ready,i_modem_ctrl,modem_ctrl,inb,outb) \ COMM_CB name = \ {{num, \ num == 0 ? 4 : (num == 1 ? 3 : 0), \ 0,0,0,0,mode,0,0,0,0,0,0, \ sizeof inb - 40,sizeof inb - 20, \ 0,modem_ready,i_modem_ctrl,modem_ctrl}, \ {&inb[0],0,sizeof inb,0,0,0}, \ {&outb[0],0,sizeof outb,0,0,0} \ }; /* Prototypes for functions contained in comm_int.obj */ int far all_sent(struct comm_cb_s far *); int far close_comm(struct comm_cb_s far *); int far drop_RTS(struct comm_cb_s far *); int far open_comm(struct comm_cb_s far *); int far raise_RTS(struct comm_cb_s far *); int far read_comm(struct comm_cb_s far *); int far write_comm(struct comm_cb_s far *, int);