home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / progmisc / djasy10d.zip / ATEST.C < prev    next >
C/C++ Source or Header  |  1992-09-11  |  908b  |  55 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <dos.h>
  4. #include <io.h>
  5.  
  6. #include "djasync.h"
  7.  
  8. #ifdef __GNUC__
  9. #include    <gppconio.h>
  10. #else
  11. #include    <conio.h>
  12. #endif
  13.  
  14. #include    <dos.h>
  15.  
  16. main(int ac, char** av)
  17. {
  18.   int port = ac > 1 ? atoi(av[1]) - 1 : 0;
  19.   int show = ac > 2;
  20.   int msec = ac > 2 ? atoi(av[2]) : 0;
  21.     
  22.   if (!async_init(port))
  23.       return 1;
  24.  
  25.   while (1)
  26.   {
  27.     int x,y;
  28.  
  29.     if (kb_ready())
  30.     {
  31.       char ch = kb_rx();
  32.       if (ch == '~')
  33.         exit(0);
  34.       async_tx(port,ch);
  35.     }
  36.  
  37.     if (show) {
  38.         if (msec)
  39.             delay(msec);
  40.         x=wherex();
  41.         y=wherey();
  42.         gotoxy(1,1);
  43.         cprintf("%04d %04d",async_cnt(port),async_overflow(port));
  44.         gotoxy(x,y);
  45.     }
  46.         
  47.     if (async_ready(port))
  48.     {
  49.       char c = async_rx(port);
  50.       write(1, &c, 1);
  51.     }
  52.   }
  53.   return 0;
  54. }
  55.