home *** CD-ROM | disk | FTP | other *** search
- /*
- * EXAMP44.C
- *
- * The Greenleaf Comm Library
- *
- * Copyright (C) 1989 Greenleaf Software Inc. All Rights Reserved.
- *
- * This example program demonstrates opening a port using asiinit(),
- * asifirst(), and asistart(). These three routines normally are called
- * automatically by asiopen(), along with asdtr() and asrts().
- *
- */
- #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, ASINOUT | BINARY | NORMALRX, 100, 100 );
- if ( status < ASSUCCESS ) {
- printf( "Failed to asifirst the port. Status = %d\n", status );
- exit( 1 );
- }
- status = asiinit( COM1, 1200L, P_NONE, 1, 8);
- if ( status < ASSUCCESS ) {
- printf( "Failed on asiinit. Status = %d\n", status );
- exit( 1 );
- }
- status = asistart( COM1, ASINOUT );
- if ( status < ASSUCCESS ) {
- printf( "Failed on asistart. Status = %d\n", status );
- exit( 1 );
- }
- for ( ; ; ) {
- if ( gfkbhit() ) {
- c = getkey();
- if ( c == ESC )
- exit( 0 );
- asiputc( COM1, c );
- }
- c = asigetc( COM1 );
- if ( c >= ASSUCCESS )
- putc( c, stdout );
- }
- }
-