home *** CD-ROM | disk | FTP | other *** search
- /*
- * EXAMP03.C
- *
- * The Greenleaf Comm Library
- *
- * Copyright (C) 1989 Greenleaf Software Inc. All Rights Reserved.
- *
- * This example program demonstrates the use of asiputs and asigetc_timed().
- * We send an "AT" string to the modem, and wait to get characters back.
- * Eventually the program will timeout when no new characters have been
- * read in for 2 seconds.
- *
- */
- #include <stdio.h>
- #include <stdlib.h>
- #include "asiports.h"
- #include "ibmkeys.h"
- #include "gf.h"
-
- void main( void );
-
- void main()
- {
- int c;
- int status;
-
- status = asiopen( COM1, ASINOUT | BINARY | NORMALRX, 100, 100,
- 1200L, P_NONE, 1, 8, ON, ON);
- if ( status < ASSUCCESS ) {
- printf( "Failed to open the port. Status = %d\n", status );
- exit( 1 );
- }
- asiputs( COM1, "AT\r", -1 );
- for ( ; ; ) {
- c = asigetc_timed( COM1, 2*TICKS_PER_SECOND );
- if ( c >= ASSUCCESS )
- putc( c, stdout );
- else {
- printf("Timeout waiting for character\n");
- asiquit( -1 );
- exit( 1 );
- }
- }
- }