/****************************************** This demo show how to use i8172_ReadAIHex to read analog input data via FR-2017 For more detail information about how to use i8172_ReadAIHex, please refer to RFnet.h Compiler: BC++ 3.1, Turbo C++ 1.01 (free from http://community.borland.com/museun) Compile mode: Large [Jun, 2010] by Martin ******************************************/ #include #include "..\lib\8000E.h" #include "..\lib\8172.h" void main(void) { short iSlot,iPort,iGroup,i,chIndex,bitMode,aiHex,ret =0,iStatus; int ID; char cTemp[10]; short AI[16]; short maxCh; InitLib(); start: Print("Please input slot number (0 ~ %d): ",GetNumberOfSlot()-1); LineInput(cTemp,10); sscanf(cTemp,"%d",&iSlot); ID=i8172_Init(iSlot); if(ID<0) { Print("There is no I-8172 at slot %d\n",iSlot); goto start; } Print("Please input port number (0 ~ 1): "); LineInput(cTemp,10); sscanf(cTemp,"%d",&iPort); Print("Please input Group (8 ~ 15): "); LineInput(cTemp,10); sscanf(cTemp,"%d",&iGroup); Print("Please input Bit Mode (12 or 16 ):"); LineInput(cTemp,10); sscanf(cTemp,"%d",&bitMode); Print("Please input total AI Channel (1 or 8 or 16):"); LineInput(cTemp,10); sscanf(cTemp,"%d",&maxCh); Print("Press any key to quit.\n\r"); for(;;) { // return 0 off line, 1 on line iStatus = i8172_ReadInputGroupStatus(iSlot,iPort, iGroup); if(!iStatus) { Print("Connection between Input I/O and 8172 is broken, Check the wiring ! \r"); } else { ret = i8172_ReadAIHex(iSlot,iPort, iGroup , bitMode,&chIndex, & aiHex); AI[chIndex]=aiHex; for(chIndex=0;chIndex 0) Print("\r"); else { Print("\n timeout \n\r"); } } if (Kbhit()) {Getch(); return;} } }