#include"..\..\lib\8000a.h" /* 87k_demo.c :This demo program is for 87K General Function in Com0. User must to know: 1.The com0's baudrate is 115200. User don't modify it. 2.User need to know the module's location in the MCU. Compiler: BC++ 3.1, Turbo C ++ 1.01(3.01) (free from http://community.borland.com/museum) MSC 6.0, MSVC 1.52. Compile mode: large Project: 87K_demo.c ..\Lib\(8000.Lib, 8000E.lib) Hardware: 8000 [24 May,2005] by Bill */ /* === English comments ========================================== This demo program is for all functions of 87K I/O modules . Users can refer the demo to excute every commands list in 87K I/O module's document. For example: $AAM, #AA, @AA, @AA6... etc. If users wants to use AI,AO,DI,DO,DIO, we have prepared several demos. Uers can copy the code from these demos then paste to their own program. === Chinese comments ========================================== 硂絛ㄒ琌皐癸 87K I/O 家舱场 ㄏノ把σ絛ㄒㄓㄏノ– 87K I/O 家舱㏑もい ㄒ $AAM, #AA, @AA, @AA6... 单单 安ㄏノ璶ㄏノ AI, AO, DI, DO, DIO 硂ㄇи竒非称 计瞷Θ絛ㄒ祘Α盢硂ㄇ祘Α絏钡狡籹祘Αいㄓㄏノ */ void main() { int quit1=0; unsigned long tickCnt; unsigned long starttick; unsigned char InBufCom0[60]; InitLib(); //Step 1: InstallCom_3(115200L,8,0,1); //(Baudrate,Data bit,Parity bit,Stop bit) //Step 2: //ChangeToSlot(7); //Step 3: starttick=GetTimeTicks(); // begin timer count while (!quit1) { SendCmdTo7000(3,"$01M",0); tickCnt=GetTimeTicks(); // begin timer count //Send command to COM0(Com port,command,Checksum=Disable) //For example: command="$00M" ===> Gets module name. //For detailed command sets,refer to //CD:\DCON\IO_Module\hw_dcon_on_87kUnit //Step 4: ReceiveResponseFrom7000_ms(3,InBufCom0,100,0); //COM port=0, //InBufCom0: Pointer of input buffer to receive response // from the 87K module, //Timeout=100ms, //Checksum=Disable //Step 5: if (memcmp (InBufCom0,"!01ZT-2018",10)) Print("T:% lu $01M response = %s (%lu) ms fail\n\r",GetTimeTicks()-starttick,InBufCom0,GetTimeTicks()-tickCnt); else Print("T:% lu $01M response = %s (%lu) ms OK\r",GetTimeTicks()-starttick,InBufCom0,GetTimeTicks()-tickCnt); SendCmdTo7000(3,"#010",0); tickCnt=GetTimeTicks(); // begin timer count ReceiveResponseFrom7000_ms(3,InBufCom0,100,0); if (memcmp (InBufCom0,">+15.",5)) Print("T:% lu #010 response = %s (%lu) ms \n\r",GetTimeTicks()-starttick,InBufCom0,GetTimeTicks()-tickCnt); else Print("T:% lu #010 response = %s (%lu) ms \r",GetTimeTicks()-starttick,InBufCom0,GetTimeTicks()-tickCnt); //Print("T:% lu #010 response = %s (%lu) ms \n\r",GetTimeTicks()-starttick,InBufCom0,GetTimeTicks()-tickCnt); SendCmdTo7000(3,"$01F",0); tickCnt=GetTimeTicks(); // begin timer count ReceiveResponseFrom7000_ms(3,InBufCom0,100,0); if (memcmp (InBufCom0,"!01A0.1",7)) Print("T:% lu $01F response = %s (%lu) ms fail\n\r",GetTimeTicks()-starttick,InBufCom0,GetTimeTicks()-tickCnt); else Print("T:% lu $01F response = %s (%lu) ms OK\r",GetTimeTicks()-starttick,InBufCom0,GetTimeTicks()-tickCnt); //Print("T:% lu $01F response = %s (%lu) ms \n\r",GetTimeTicks()-starttick,InBufCom0,GetTimeTicks()-tickCnt); SendCmdTo7000(3,"$012",0); tickCnt=GetTimeTicks(); // begin timer count ReceiveResponseFrom7000_ms(3,InBufCom0,100,0); if (memcmp (InBufCom0,"!01000A00",9)) Print("T:% lu $012 response = %s (%lu) ms OK\r",GetTimeTicks()-starttick,InBufCom0,GetTimeTicks()-tickCnt); else Print("T:% lu $012 response = %s (%lu) ms OK\r",GetTimeTicks()-starttick,InBufCom0,GetTimeTicks()-tickCnt); //Print("$012 response = %s (%lu) ms \n\r",InBufCom0,GetTimeTicks()-tickCnt); if (Kbhit()) { if (Getch()==27) quit1=1; } } //Step 6: RestoreCom0(); }