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 / EXAMP06.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-12-11  |  1.0 KB  |  38 lines

  1. /*
  2.  *  EXAMP06.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 asiputb() and asigets_timed().
  9.  *  We send an "AT" string to the modem, and wait to get characters back.
  10.  *  The asigetb_timed will get as many characters as possible until the
  11.  *  timeout time is used up.
  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 count;
  25.     int status;
  26.     char buffer[81];
  27.  
  28.     status = asiopen( COM1, ASINOUT | BINARY | NORMALRX, 100, 100,
  29.                       1200L, P_NONE, 1, 8, ON, ON);
  30.     if ( status < ASSUCCESS ) {
  31.         printf( "Failed to open the port.  Status = %d\n", status );
  32.         exit( 1 );
  33.     }
  34.     asiputb( COM1, "AT\r", 3 );
  35.     count = asigets_timed( COM1, buffer, 81, '\r', TICKS_PER_SECOND*2 );
  36.     printf( "Read in %d characters, string=%s\n", count, buffer );
  37. }
  38.