home *** CD-ROM | disk | FTP | other *** search
- /*
- * EXAMP49.C
- *
- * The Greenleaf Comm Library
- *
- * Copyright (C) 1989 Greenleaf Software Inc. All Rights Reserved.
- *
- * This example program demonstrates the use of the HMSetEscapeCode()
- * and HMSetEscapeCodeGuardTime() functions. It sets the two parameters
- * up, then allows the user to enter the escape sequence by pressing
- * the F1 key. It sets both parameters to their defaults, with the
- * character '+' and the guard time of 1 second.
- *
- */
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include "asiports.h"
- #include "ibmkeys.h"
- #include "gf.h"
-
- void my_putc( char c );
- void disconnect( void );
- void main( void );
-
- void main()
- {
- int status;
- int c;
-
- 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 );
- }
-
- HMWaitForOK( TICKS_PER_SECOND, NULL );
- HMSetUpEchoRoutine( my_putc );
-
- HMReset(COM1);
- HMSetEscapeCode( COM1, '+' );
- HMSetEscapeCodeGuardTime( COM1, 50 );
-
- for ( ; ; ) {
- if ( gfkbhit() ) {
- c = getkey();
- if ( c == ESC )
- exit( 0 );
- else if ( c == F1 )
- HMDial( COM1, "250-3778" );
- else if ( c == F2 )
- disconnect();
- else
- asiputc( COM1, c );
- }
- c = asigetc( COM1 );
- if ( c >= ASSUCCESS )
- putc( c, stdout );
- }
- }
-
- void my_putc( char c )
- {
- putc( c, stdout );
- }
-
- void disconnect()
- {
- printf( "\nDisconnecting...\n");
- while ( !istxempty( COM1 ) ) ;
- timer( TICKS_PER_SECOND + 1 );
- asiputs( COM1, "+++", -1 );
- while ( !istxempty( COM1 ) ) ;
- timer( TICKS_PER_SECOND * 2 );
- HMSetHookSwitch( COM1, 0 );
- }