home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware 1 2 the Maxx
/
sw_1.zip
/
sw_1
/
PROGRAM
/
PCL4C30.ZIP
/
LOOPBACK.C
< prev
next >
Wrap
Text File
|
1992-01-20
|
1KB
|
65 lines
/*
** --- loopback.c ---
**
** EXAMPLE CODE: Performs loopback test of selected port.
**
** 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; /* COM port */
int BaudCode = Baud300; /* Code for 300 baud */
char RxBuf[16]; /* PCL receive buffer */
/*** Main ***/
main(argc,argv)
int argc;
char *argv[];
{
char c;
int i;
int Code;
char *ptr;
/* get comm port */
if(argc!=2)
{printf("Usage: 'LOOPBACK 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("LOOPBACK: Testing COM%d -- ",1+Port);
/* setup receive buffer -- even if don't use it */
ErrorCheck( SioRxBuf(Port,RxBuf,Size16) );
/* reset the port */
ErrorCheck( SioReset(Port,BaudCode) );
/* do the LOOPBACK test ! */
Code = SioLoopBack(Port);
if(Code >= 0) printf("OK");
else SioError( Code );
SioDone(Port);
} /* end main */
int ErrorCheck(Code)
int Code;
{/* trap PCL error codes */
if(Code<0)
{SioError(Code);
exit(1);
}
} /* end ErrorCheck */