home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_300 / 307_01 / te.c < prev    next >
C/C++ Source or Header  |  1990-03-20  |  1KB  |  54 lines

  1. /*
  2. HEADER:     ;
  3. TITLE:        Simple terminal emulator for COMX driver;
  4. VERSION:    1.0;
  5.  
  6. DESCRIPTION:    "Demonstration/test program for COMX device driver.";
  7.  
  8. KEYWORDS:    Serial communications, terminal emulator;
  9. SYSTEM:     MS-DOS v2 or later;
  10. FILENAME:    TE.C;
  11.  
  12. SEE-ALSO:    COMX, COMX.C, RS232.C;
  13. AUTHORS:    Hugh Daschbach;
  14. COMPILERS:    Microsoft v5.0,v5.1;
  15. */
  16. /*----------------------------------------------------------------------*/
  17. /* te.c: Simple terminal emulator for use with COMX.SYS
  18.  */
  19. #include <stdio.h>
  20. #include <stdlib.h>
  21. #include <signal.h>
  22. #include <conio.h>
  23. #include "rs232.h"
  24. #include "comx.h"
  25.  
  26. static int port = 0;
  27. static int quit = 0;
  28.  
  29. static void sigint(sig)
  30. {
  31.     quit = 1;
  32. }
  33.  
  34. main(int argc, char *argv[])
  35. {
  36.     int i;
  37.  
  38.     if (argc > 1)
  39.     port = atoi(argv[1]);
  40.     signal(SIGINT, sigint);
  41.     rs232_init(port, 9600L, 'e', 1, 7);
  42.     rs232_prot(port, PROT_XIN | PROT_XOUT);
  43.     while (rs232_getc(port) >= 0)
  44.     ;
  45.     while (quit == 0)
  46.     {
  47.     while ((i = rs232_getc(port)) >= 0)
  48.         putch(i);
  49.     if (kbhit())
  50.         rs232_putc(port, getch() & 0x7f);
  51.     }
  52.     return(0);
  53. }
  54.