home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / communic / rsdrv / tty.c < prev   
Encoding:
C/C++ Source or Header  |  1990-02-26  |  1.1 KB  |  62 lines

  1. /* tty.c : a demonstration program for rsdrv.c, a dumb terminal 
  2.  *
  3.  * by J. Leppäjärvi (so-jml@stekt.oulu.fi) (C) 1990
  4.  *
  5.  * For Borland's turbo C, all memory models.
  6.  *
  7.  * This program can be used, copied and modified freely. It 
  8.  * is provided 'as is' with no warranty of any kind.
  9.  */
  10.  
  11. #include <bios.h>
  12. #include "rsdrv.h"
  13.  
  14. /* send break routine */
  15.  
  16. void sendbreak()
  17. {
  18.  long btime = 0L;
  19.  
  20.  /* set up wait for 5 timer ticks (approx. 250 ms) */
  21.  
  22.  btime = biostime(0,btime) + 5L;
  23.  
  24.  rsbreak(1);
  25.  
  26.  while(biostime(0,btime) < btime);
  27.  
  28.  rsbreak(0);
  29. }
  30.  
  31. main()
  32. {
  33.  int rdx, ch;
  34.  
  35.  /* initialize - com2:1200N81 */
  36.  
  37.  rsinit(2,1200,PARITY_NONE | STOP_1 | BITS_8);
  38.  
  39.  /* copy the keyboard input to the rs-port 
  40.   * and rs-input on the screen, bios is used
  41.   * to avoid dos interference (ctrl-C check)
  42.   */
  43.  
  44.  while(1)
  45.  {
  46.   if (bioskey(1)) 
  47.   {
  48.    /* F10 ends the program, F9 sends a break */
  49.    
  50.    if ((ch = bioskey(0)) == 0x4400) break;
  51.    else if (ch == 0x4300) sendbreak();
  52.     
  53.    rsputc(ch);
  54.   }
  55.   if ((ch = rsgetc()) >= 0) putch(ch);
  56.  }
  57.  
  58.  /* 'turn off' rs-interrupts */
  59.  
  60.  rsend();
  61. }
  62.