home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware 1 2 the Maxx
/
sw_1.zip
/
sw_1
/
PROGRAM
/
PCL4C30.ZIP
/
NORESET.C
< prev
next >
Wrap
Text File
|
1992-01-20
|
2KB
|
87 lines
/*
**
** --- noreset.c ---
**
** EXAMPLE CODE: Gain control w/o resetting UART.
**
** (1) Start your communications program such as PROCOMM
** (2) Select "DOS gateway" to get the DOS prompt.
** (3) Start this program. You will gain control of the
** COM port without resetting the UART or dropping the
** modem carrier.
** (4) When done, exit this program, then type EXIT to
** return to MSDOS.
**
** For more information, see documentation.
**
** This example program (not the PCL4C library) is donated to
** the Public Domain by MarshallSoft Computing, Inc. It is
** provided as an example of the use of the PCL4C.
**
*/
#include <stdio.h>
#include "pcl4c.h"
#define FALSE 0
#define TRUE !FALSE
#define ESC 0x1b
/*** Global Variables ***/
int Port;
char RxBuf[16]; /* PCL4C receive buffer */
/*** Main ***/
main(argc,argv)
int argc;
char *argv[];
{
char c;
char *ptr;
int i, rc;
/* get comm port */
if(argc!=2)
{printf("Usage: 'NORESET port' where port is 1,2,3, or 4\n");
exit(1);
}
ptr = argv[1];
if((*ptr<'1')||(*ptr>'4'))
{printf("COM port must be 1 to 4, not %s\n",ptr);
exit(1);
}
Port = atoi(ptr) - 1;
printf("NORESET: COM%d\n",1+Port);
/* setup receive buffer */
ErrorCheck( SioRxBuf(Port,RxBuf,Size16) );
/* 'reset' the port */
ErrorCheck( SioReset(Port,NORESET) );
printf("Enter terminal loop ( COM%d )\n",1+Port);
printf("Type ESC to quit !\n");
/* enter terminal loop */
while(TRUE)
{/* was key pressed ? */
if(SioKeyPress())
{i = SioKeyRead();
if((char)i==ESC)
{/* restore COM port status & exit */
SioDone(Port);
exit(1);
}
else SioPutc(Port,i);
} /* end if */
/* any incoming over serial port ? */
i = SioGetc(Port,0);
if(i>-1) SioCrtWrite(i);
} /* end while */
} /* end main */
int ErrorCheck(Code)
int Code;
{/* trap PCL error codes */
if(Code<0)
{SioError(Code);
exit(1);
}
} /* end ErrorCheck */