home *** CD-ROM | disk | FTP | other *** search
- /*
- * EXAMP01.C
- *
- * The Greenleaf Comm Library
- *
- * Copyright (C) 1989 Greenleaf Software Inc. All Rights Reserved.
- *
- * This example program demonstrates the use of polled I/O. A more fully
- * developed polled I/O example is found in the demo program POLL.C.
- * Note that asiopen() won't work properly with polled mode, as it makes
- * a call to asistart(), turning on interrupts.
- *
- */
- #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 = asifirst( COM1, BINARY | NORMALRX, 100, 100);
- if ( status > ASSUCCESS )
- status = asiinit( COM1, 1200L, P_NONE, 1, 8 );
- if ( status < ASSUCCESS ) {
- printf( "Failed to open the port. Status = %d\n", status );
- exit( 1 );
- }
- for ( ; ; ) {
- if ( gfkbhit() ) {
- c = getkey();
- if ( c == ESC )
- exit( 0 );
- asputc( COM1, c );
- }
- c = asgetc( COM1 );
- if ( c >= ASSUCCESS )
- putc( c, stdout );
- }
- }
-