/* X503Demo.c: Demo program for X503 Compiler: MSC 6.0 MSVC 1.52 Compile mode: large Project: X503Demo.c ..\..\Lib\7188xbl.lib Hardware: 7188XB + X503 X503: COM3 (5-wire RS-232) [14/July/2005] by Liam */ #include #include #include "..\..\lib\7188xb.h" #define BUFSIZE 1024 char OutpBuf[BUFSIZE], InpBuf[BUFSIZE]; void main(void) { int idata, iAction, iValue, quit; char buf[100]; InitLib(); InstallCom(3, 115200L, 8, 0, 1); Print("\r\n"); Print("****************************************\r\n"); Print("| 7188XB + X503 |\r\n"); Print("****************************************\r\n"); while(iAction!=4) { iAction=0; quit=0; Print("\r\n"); Print("1) Send & Receive data to/from COM1:\r\n"); Print("2) Set RTS status \r\n"); Print("3) Get CTS status (0: CTS off, 1: CTS ON)\r\n"); Print("\r\n"); Print("4) Quits Demo program\r\n\r\n"); Print("Choose an option and press [Enter]:"); LineInput(buf, 99); sscanf(buf, "%d", &iAction); switch(iAction) { // Send & Receive data to/from COM1 case 1: Print("\r\n"); Print("Send & Receive data to/from COM3\r\n"); Print("Enter a string to COM port:"); LineInput(buf, 99); sscanf(buf, "%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; // Set RTS status case 2: Print("\r\n"); Print("Input 0 or 1? "); LineInput(buf, 99); sscanf(buf, "%d", &iValue); if(iValue) SetRtsActive_3(); else SetRtsInactive_3(); Print("\r\nThe RTS status is %d\r\n", iValue); break; // Get CTS status case 3: Print("\r\nCTS status of COM3 is:%d\r\n", GetCtsStatus_3()); break; case 4: quit=1; RestoreCom(3); break; default: quit=1; break; } if(quit!=1) { Print("\r\nPress any key to continue...\r\n"); Getch(); } } }