home *** CD-ROM | disk | FTP | other *** search
- /* tty.c : a demonstration program for rsdrv.c, a dumb terminal
- *
- * by J. Leppäjärvi (so-jml@stekt.oulu.fi) (C) 1990
- *
- * For Borland's turbo C, all memory models.
- *
- * This program can be used, copied and modified freely. It
- * is provided 'as is' with no warranty of any kind.
- */
-
- #include <bios.h>
- #include "rsdrv.h"
-
- /* send break routine */
-
- void sendbreak()
- {
- long btime = 0L;
-
- /* set up wait for 5 timer ticks (approx. 250 ms) */
-
- btime = biostime(0,btime) + 5L;
-
- rsbreak(1);
-
- while(biostime(0,btime) < btime);
-
- rsbreak(0);
- }
-
- main()
- {
- int rdx, ch;
-
- /* initialize - com2:1200N81 */
-
- rsinit(2,1200,PARITY_NONE | STOP_1 | BITS_8);
-
- /* copy the keyboard input to the rs-port
- * and rs-input on the screen, bios is used
- * to avoid dos interference (ctrl-C check)
- */
-
- while(1)
- {
- if (bioskey(1))
- {
- /* F10 ends the program, F9 sends a break */
-
- if ((ch = bioskey(0)) == 0x4400) break;
- else if (ch == 0x4300) sendbreak();
-
- rsputc(ch);
- }
- if ((ch = rsgetc()) >= 0) putch(ch);
- }
-
- /* 'turn off' rs-interrupts */
-
- rsend();
- }