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 / EXAMP03.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-11-09  |  1.1 KB  |  45 lines

  1. /*
  2.  *  EXAMP03.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 asiputs and asigetc_timed().
  9.  *  We send an "AT" string to the modem, and wait to get characters back.
  10.  *  Eventually the program will timeout when no new characters have been
  11.  *  read in for 2 seconds.
  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, 100, 100,
  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.     asiputs( COM1, "AT\r", -1 );
  34.     for ( ; ; ) {
  35.         c = asigetc_timed( COM1, 2*TICKS_PER_SECOND );
  36.         if ( c >= ASSUCCESS )
  37.             putc( c, stdout );
  38.         else {
  39.             printf("Timeout waiting for character\n");
  40.             asiquit( -1 );
  41.             exit( 1 );
  42.         }
  43.     }
  44. }
  45.