home *** CD-ROM | disk | FTP | other *** search
- /*
- * EXAMP38.C
- *
- * The Greenleaf Comm Library
- *
- * Copyright (C) 1989 Greenleaf Software Inc. All Rights Reserved.
- *
- * This example program is used to demonstrate the use of isrxempty(),
- * isrxfull(), and isrxempty().
- *
- */
- #include <stdio.h>
- #include <stdlib.h>
- #include "asiports.h"
- #include "ibmkeys.h"
- #include "gf.h"
-
- void do_shell( void );
- void main( void );
-
- void main()
- {
- int status;
- int c;
-
- status = asiopen( COM1, ASINOUT | BINARY | NORMALRX, 15, 15,
- 1200L, P_NONE, 1, 8, OFF, ON);
- 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 );
- else if ( c == F1 )
- do_shell();
- else
- asiputc( COM1, c );
- }
- c = asigetc( COM1 );
- if ( c >= ASSUCCESS )
- putc( c, stdout );
- }
- }
-
- void do_shell()
- {
- printf( "Interrupts will continue to run while you in DOS!\n");
- printf( "Type EXIT to return to this program.\n");
- system( "command" );
- if ( isrxovflow( COM1 ) )
- printf( "Receive buffer overflowed while you were gone!\n");
- if ( isrxfull( COM1 ) )
- printf( "Receive buffer is now full!\n" );
- if ( isrxempty( COM1 ) )
- printf( "Receive buffer is empty!\n" );
- }