/* X500Demo.c: Demo program for X500 Compiler: BC++ 3.1, Turbo C ++ 1.01(3.01) (free from http://community.borland.com/museum) Compile mode: large Project: X500Demo.c ..\..\Lib\7188xcl.lib Hardware: 7188XC + X500 X500: COM3 (9-wire RS-232) [14/July/2005] by Liam */ #include #include #include #include #include "..\..\lib\7188xc.h" #define BUFSIZE 1024 char InpBuf[BUFSIZE],OutpBuf[BUFSIZE]; void main(void) { int iAction, quit, idata, iValue; InitLib(); InstallCom3(115200L, 8, 0, 1); Print("\r\n"); Print("****************************************\r\n"); Print("| 7188XC + X500 |\r\n"); Print("****************************************\r\n"); while(iAction!=4) { iAction=0; quit=0; Puts("\r\n"); Puts("1) Send & Receive data to/from COM1\r\n"); Puts("2) Set RTS status\r\n"); Puts("3) Get CTS status (0: CTS off, 1: CTS ON)\r\n"); Puts("\r\n"); Puts("4) Quits Demo program\r\n\r\n"); Puts("Choose an option and press [Enter]:"); Scanf("%d", &iAction); Puts("\r\n"); switch(iAction) { case 1: Print("Enter a string to COM port:"); Scanf("%s", &OutpBuf); ToComStr(3, OutpBuf); Delay(2); idata=ReadComn(3,InpBuf,BUFSIZE); InpBuf[idata]=0x0; Print("Read COM port==>%s,idata=%d\r\n",InpBuf,idata); if(!strcmp(OutpBuf,InpBuf)) Print("Send COM3 <==> Receiv COM3 -->Test OK\r\n"); else Print("Send COM3 <==> Receiv COM3 -->Test error\r\n"); break; case 2: Print("Input 0 or 1?\r\n"); Scanf("%d", &iValue); if(iValue) SetRtsActive_3(); else SetRtsInactive_3(); Print("The RTS status is %d\r\n", iValue); break; case 3: Print("CTS status of COM3 is:%d\r\n", GetCtsStatus_3()); break; case 4: default : quit=1; break; } if(!quit) { Puts("\r\nPlease press any key to continue...\r\n"); Getch(); } } }