home *** CD-ROM | disk | FTP | other *** search
/ World of Shareware - Software Farm 2 / wosw_2.zip / wosw_2 / CPROG / ASYNCPEC.ZIP / TERMINAL.C < prev   
C/C++ Source or Header  |  1989-05-03  |  1KB  |  42 lines

  1. /************************************************************/
  2. /************************************************************/
  3. /* Simple terminal program for Microsoft C 5.1 */
  4. /* Copyright 1989, Quinn-Curtis  */
  5. /************************************************************/
  6. /************************************************************/
  7.  
  8. # include <stdlib.h>
  9. # include <stdio.h>
  10. # include "asyncpec.h"
  11.  
  12.      int err;
  13.      char transmit_ch;
  14.      char receive_ch;
  15.  
  16. void main()
  17.  
  18. { /* Com port 1, 9600 baud, no parity, 1 stop bit, 8 data bits */
  19.   open_com(0,9600,0,1,8,&err);
  20.   do {
  21.      do {
  22.        transmit_ch = getche();  /* Get Character with echo */
  23.        if (transmit_ch != 27) send_com(transmit_ch,&err);
  24.        /* Grab characters until CR or ESC */
  25.      } while ((transmit_ch != 13) && (transmit_ch != 27));
  26.      putch(10); /* Send a LF to screen */
  27.      do { /* Read com buffer until no characters left */
  28.        check_com(&receive_ch,&err);
  29.        if (err==0) {
  30.          putch(receive_ch);  /* If good character the write to screen*/
  31.          if (receive_ch==13) putch(10);  /* Add LF if CR */
  32.        }
  33.        else if (err==7){
  34.            putch(receive_ch);
  35.            printf("BUFFER OVERRUN");
  36.            reset_buffer();
  37.         }
  38.      } while (err == 0);
  39.   } while (transmit_ch != 27); /* Exit program by pressing ESC key */
  40.   close_com();
  41. }
  42.