home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0020 - 0029 / ibm0020-0029 / ibm0028.tar / ibm0028 / GRLF-C-4.ZIP / GSAMP / GSAMP.ZIP / EXAMP30.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-11-09  |  1.2 KB  |  49 lines

  1. /*
  2.  *  EXAMP30.C
  3.  *
  4.  *  The Greenleaf Comm Library
  5.  *
  6.  *  Copyright (C) 1989 Greenleaf Software Inc.  All Rights Reserved.
  7.  *
  8.  *  This example program demonstrates the use of the asidiag function.
  9.  *  It turns on diagnostic mode in the UART, then transmits keystrokes
  10.  *  and reads results back.  Remember that diagnostic mode usually doesn't
  11.  *  work on the 16450.
  12.  *
  13.  */
  14. #include <stdio.h>
  15. #include <stdlib.h>
  16. #include "asiports.h"
  17. #include "ibmkeys.h"
  18. #include "gf.h"
  19.  
  20. void main( void );
  21.  
  22. void main()
  23. {
  24.     int c;
  25.     int status;
  26.  
  27.     status = asiopen( COM1, ASINOUT | BINARY | NORMALRX, 5, 5,
  28.                       1200L, P_NONE, 1, 8, ON, ON);
  29.     if ( status < ASSUCCESS ) {
  30.         printf( "Failed to open the port.  Status = %d\n", status );
  31.         exit( 1 );
  32.     }
  33.     asidiag( COM1, ON );
  34.     for ( ; ; ) {
  35.         if ( gfkbhit() ) {
  36.             c = getkey();
  37.             if ( c == ESC )
  38.                 exit( 0 );
  39.             if (asiputc( COM1, c ) < ASSUCCESS) {
  40.                 printf("Output failure!\n");
  41.                 exit( 2 );
  42.             }
  43.         }
  44.         c = asigetc( COM1 );
  45.         if ( c >= ASSUCCESS )
  46.             putc( c, stdout );
  47.    }
  48. }
  49.