home *** CD-ROM | disk | FTP | other *** search
/ BURKS 2 / BURKS_AUG97.ISO / BURKS / SOFTWARE / LIBS / PCL4C43.ZIP / MINIMAL.C (.txt) < prev    next >
Text File  |  1995-03-27  |  999b  |  41 lines

  1. /*
  2. **   minimal.c (3/3/95)
  3. */
  4.  
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #include <malloc.h>
  8. #include <dos.h>
  9. #include "pcl4c.h"
  10.  
  11. #define CTLZ 0x1a
  12.  
  13. void main(void)
  14. {int i, Seg;
  15.  char far *Ptr;
  16.  /* setup 128 byte receive buffer */
  17.  Ptr = (char far *) _fmalloc(128+16);
  18.  Seg = FP_SEG(Ptr) + ((FP_OFF(Ptr)+15)>>4);
  19.  SioRxBuf(COM1,Seg,Size128);
  20.  /* set port parmameters & reset port */
  21.  SioParms(COM1,NoParity,OneStopBit,WordLength8);
  22.  SioReset(COM1,Baud9600);
  23.  printf("\nMINIMAL: COM%d @ 9600 Baud: Type ^Z to quit\n",1+COM1);
  24.  /* enter terminal loop */
  25.  while(1)
  26.    {/* was key pressed ? */
  27.     if(SioKeyPress())
  28.       {i = SioKeyRead();
  29.        if((char)i==CTLZ)
  30.          {/* restore COM port status & exit */
  31.           SioDone(COM1);
  32.           exit(0);
  33.          }
  34.        else SioPutc(COM1,(char)i);
  35.       } /* end if */
  36.     /* any incoming over serial port ? */
  37.     i = SioGetc(COM1,0);
  38.     if(i>-1) SioCrtWrite((char)i);
  39.    } /* end while */
  40. } /* end main */
  41.