/////////////////////////////////////////////////////////////
//COMRX.CPP for asyn serial communication (only RX)
//edited by Xiong Guangming and Gong Jianwei
//Turbo C++3.0
/////////////////////////////////////////////////////////////
#include <stdio.h>
#include <dos.h>
#include <conio.h>
//以下为主函数
void main()
{
unsigned char unChar;
short bExit_Flag=0;
OpenPort(); //打开串口
fprintf(stdout, "\n\nReady to Receive DATA\n"
"press [ESC] to quit...\n\n");
do {
if (kbhit())
{
unChar=getch();
/* Look for an ESC key */
switch (unChar)
{
case 0x1B: //ESC的ASCII值为27
bExit_Flag = 1; /* Exit program */
break;
//You may want to handle other keys here
}
}
unChar = read_char(); //从缓冲区中读数
if (unChar != 0xff)
{
fprintf(stdout,"%c",unChar);
}
} while (!bExit_Flag);