home *** CD-ROM | disk | FTP | other *** search
- /*
- * EXAMP30.C
- *
- * The Greenleaf Comm Library
- *
- * Copyright (C) 1989 Greenleaf Software Inc. All Rights Reserved.
- *
- * This example program demonstrates the use of the asidiag function.
- * It turns on diagnostic mode in the UART, then transmits keystrokes
- * and reads results back. Remember that diagnostic mode usually doesn't
- * work on the 16450.
- *
- */
- #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, 5, 5,
- 1200L, P_NONE, 1, 8, ON, ON);
- if ( status < ASSUCCESS ) {
- printf( "Failed to open the port. Status = %d\n", status );
- exit( 1 );
- }
- asidiag( COM1, ON );
- for ( ; ; ) {
- if ( gfkbhit() ) {
- c = getkey();
- if ( c == ESC )
- exit( 0 );
- if (asiputc( COM1, c ) < ASSUCCESS) {
- printf("Output failure!\n");
- exit( 2 );
- }
- }
- c = asigetc( COM1 );
- if ( c >= ASSUCCESS )
- putc( c, stdout );
- }
- }