home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0020 - 0029 / ibm0020-0029 / ibm0028.tar / ibm0028 / GRLF-C-4.ZIP / GSAMP / GSAMP.ZIP / EXAMP37.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-11-09  |  1.1 KB  |  49 lines

  1. /*
  2.  *  EXAMP37.C
  3.  *
  4.  *  The Greenleaf Comm Library
  5.  *
  6.  *  Copyright (C) 1989 Greenleaf Software Inc.  All Rights Reserved.
  7.  *
  8.  *  This program demonstrates the used of asimstat().  It monitors
  9.  *  the status lines on the modem until the user hits a key.
  10.  *
  11.  */
  12. #include <stdio.h>
  13. #include <stdlib.h>
  14. #include "asiports.h"
  15. #include "ibmkeys.h"
  16. #include "gf.h"
  17.  
  18. void main( void );
  19.  
  20. void main()
  21. {
  22.     int status;
  23.     int i;
  24.     int j;
  25.  
  26.     status = asiopen( COM1, ASINOUT | BINARY | NORMALRX, 1000, 1000,
  27.                       1200L, P_NONE, 1, 8, OFF, ON);
  28.     if ( status < ASSUCCESS ) {
  29.         printf( "Failed to open the port.  Status = %d\n", status );
  30.         exit( 1 );
  31.     }
  32.     asimrst( COM1 );
  33.     i = 0;
  34.     for (  ;  ;  ) {
  35.         if ( gfkbhit() )
  36.             break;
  37.         if ( (i++ % 20 ) == 0 )
  38.             printf("\n  CTS   DSR   RI    CD\n");
  39.         status = asimstat( COM1, IMMEDIATE );
  40.         for ( j = 0 ; j < 4 ; j++ ) {
  41.             printf( status & 0x10 ? "  ON  " : "  OFF " );
  42.             status >>= 1;
  43.         }
  44.         printf("\n");
  45.         timer( TICKS_PER_SECOND );
  46.    }
  47.    getkey();
  48. }
  49.