home *** CD-ROM | disk | FTP | other *** search
- I B M C O M
-
- IBM RS232 interrupted driven communications routines. BBS version
- has small model lib file for ibmcom.
-
- Since the BBS version supplies only object,the following assumptions
- have been made:
-
- o Buffer input size is defined to be 2000 characters per
- port.
-
- o Buffer output size for putsi_com() routine is defined to be
- 80 characters.
-
- Purchasers of the source can change the above buffer size's. If you
- whish to obtain source and/or to see these routines continue to be
- supported with ehancements,bug fixes, protocals, terminal
- emulators,etc.
-
- Send $15 to:
-
- Intrinsic Computers
- RR 4
- Oak Ridge,NJ 07438
-
- Send $25 and we'll give you the latest
- version on a diskette plus code for a
- reentrant xmodem recieve protocal. We
- also are available for consulting.
-
-
- Description of Routines:
-
- int init_handl( int port_num)
- Initializes port_num interrupt routines.
- Must be called after init_port(),but before
- using any other routines. Returns FALSE if
- port_num is not 1 thru 4,otherwise TRUE.
-
- void init_buffer_out(int port_num)
- Sets up the circular buffers for interrupt
- output (specifically putsi_com()). Should
- be called only once.
-
- int init_port(int port_num,int baudrate,char parity,
- int data_bits,int stopbit)
- Must be called before init_handl(). It sets
- the port_num's baud rate,parity,etc..
- Variables used:
- port_num 1,2,3, or 4
- baudrate 3 or 300 for 300 baud
- 6 or 600 for 600 baud
- 12 or 1200 for 1200 baud
- 24 or 2400 for 2400 baud
- 48 or 4800 for 4800 baud
- 96 or 9600 for 9600 baud
- 19 or 19200 for 19200 baud
- 38 or 38400 for 38400 baud
- 56 for 56000 baud
- 112 for 112000 baud
- parity 'E' for even
- 'N' for none
- 'O' for odd
- data_bits 5,6,7, or 8
- stopbit 1 or 2
- Returns
- TRUE if params ok.
- FALSE if illegal params.
-
- int check_port_hw(int port_num)
-
- Used to check if a port error has occured or
- if no error it returns the number of char
- in the ports interrupt buffer. If error has
- occurred it returns the NEGATIVE of the port's
- line control register. In programmers terms
- if the return value is >= 0 you got the # chars
- in port_num's buffer, otherwise if its < 0, you
- got an error on the port. The error is cleared
- by calling this routine.
-
- int check_port_buf(int port_num)
-
- Returns port_num's buffer overflow status.
- 1 for yes its overflowed
- 0 for no overflow
-
- unsiged com_status(int port_num)
- Returns port_num's port status.
-
- void disable_txmit_int(int port_num)
-
- Turns off interrupt driven output. You DON'T
- call this unless you want to stop midstream
- the output of a string. Normally the
- interrupt handler inself will turn off Tx
- interrupts when it finishes the string.
-
- int disable_port_int(int port_num)
-
- Turns off interrutps for port_num. Returns FALSE if
- illegal port_num, otherwise TRUE.
-
- int reset_port(int port_num)
-
- Resets port_num so that it will not interrupt
- the IBM anymore. Used to halt communications
- Should be called before exiting your programs
- or interrupts will still be active and
- hang the machine (or worse). Returns FALSE if illegal
- port_num, otherwise TRUE.
-
- void putc_com(int port_num,char *string)
-
- Outputs the string to port_num
- Does not buffer the character. It uses a
- polling technique.
-
- int puts_com(int port_num,char *string,int num_char)
-
- Outputs the indicated num_char from string
- to port_num using a polling technique. Returns
- TRUE.
-
- int putsi_com(int port_num,char *string,int num_char)
-
- Same as puts_com() except it outputs the
- string using an interrupt driven technique.
- You must call init_buffer_out() once before
- ever using putsi_com. Returns TRUE if able to
- handle the string passed to it, otherwise FALSE.
- See the demo program for further explanation.
-
- unsigned char getc_com(int port_num)
-
- Gets a char from port_num's buffer.If the
- buffer is empty it returns 0xFF which could
- be a valid character. This routine should be
- used in conjunction with check_port_buf() to
- see if any characters are in the buffer
- before calling this routine. Returns char gotten.
-
- int gets_com(char *buffer,int num_bytes,int port_num)
-
- Gets num_bytes from port_num and puts it into buffer.
- Returns actual number of bytes transferred into buffer.
-
- void report_serial_status(unsigned error_code)
-
- Will print out a nice report of the port status if you pass
- it the port status (obtained from com_status(). Note, not
- all status bits are errors, some are normal.
-
- int set_porthw_parm(int port_num, int port_ad,
- int vector_num, unsigned char
- mask)
-
- Sets port_num hardware address parameters
- where port_ad is the base hardware address
- of the port, vector_num is the interrupt
- number, and mask is the mask for the 8259
- PIC. This routine generally is not needed
- for ports 1 & 2, however since ports 3 & 4
- hardware addressing is not standard this
- routine will allow you to change these
- parameters if your particluar hardware is
- different than the following defaults:
-
- Port 3 base hardware ad = 0x3e8
- vector number = 12
- mask = 0xef
-
- Port 4 base hardware ad = 0x2e8
- vector number = 11
- mask = 0xf7
-
- Returns TRUE if port_num is 1 tru 4,otherwise
- FALSE.
-
- Linking Instructions:
-
- Must be linked with a main(). Supplied object in
- BBS version is small model only.
-
-