/* 7K87K.c: Demo program for 7K and 87K module general function. Compiler: BC++ 3.1, Turbo C++ 1.01 (3.01) MSVC 1.52 Compile mode: large Project: 7K87K.c ..\..\Lib\uPAC5000.lib Hardware: uPAC-5000 <== COM port ==> 7K or 87K modelue [Dec 30, 2011] by Liam === English comments ========================================== This demo program is for all functions of 7k and 87K I/O modules. Users can refer to the demo for executing all commands list in 7k and 87K I/O module's document. For example: $AAM, #AA, @AA, @AA6... etc. If users want to use AI,AO,DI,DO,DIO, we have prepared several demos. Users can copy the code from these demos then paste to your own program. === Chinese comments ========================================== 硂絛ㄒ琌皐癸 87K I/O 家舱场 ㄏノ把σ絛ㄒㄓㄏノ– 87K I/O 家舱㏑もい ㄒ $AAM, #AA, @AA, @AA6... 单单 安ㄏノ璶ㄏノ AI, AO, DI, DO, DIO 硂ㄇи竒非称 计瞷Θ絛ㄒ祘Α盢硂ㄇ祘Α絏钡狡籹祘Αいㄓㄏノ */ #include #include "..\..\lib\upac5000.h" void main(void) { unsigned char InBuf[16]; int iRet; InitLib(); /* InitLib() must be called before other functions in the library may be used */ //Step 1: InstallCom_2(115200L, 8, 0, 0); //(Baudrate, Data bit, Parity bit, Stop bit) //Step 2: SendCmdTo7000(2, "$01M", 0); /* COM2, Command="$AAM" which AA=01, Checksum=disabled For example: command="$01M" ===> Gets module name at address 01. For detailed command sets, refer to CD:Napdos\DCON\IO_Module\87k_modules.htm or CD:Napdos\7000\Manual\ */ //Step 3: ReceiveResponseFrom7000_ms(2, InBuf, 100, 0); /* COM2, Put received data to InBuf Timeout=100 ms Checksum=disabled */ //Step 4: if(iRet==NoError) Print("InBuf=%s\r\n", InBuf); else Print("timeout expired\r\n"); //Step 5: RestoreCom2(); }