/*
timer.c: Uses the DT2_AddTimer() function to print string via COM1.
  
Compiler: BC++ 3.1, 
          Turbo C++ 1.01(3.01) (free from http://cc.codegear.com/free/cpp)

Compile mode: Large

Project: Client.c
         ..\lib\7186el.Lib
         ..\lib\tcp_dm32.lib
         ..\lib\FW_nnnnn.LIB
         
Hordware: uPAC-7186EX

[Nov 04, 2008] by Liam
*/

#include<stdlib.h>
#include<conio.h>
#include<stdio.h>
#include "..\lib\7186e.h"
#include "..\lib\Tcpip32.h"
#include "..\lib\MFW.h"

void printHello(void);

void XS_UserInit(int argc,char *argv[])
{
	char version[20];
	int i;

	InitLib();

	XS_GetVersion(version);
	Print("[X-Server library]: version=%s ", version);
	XS_GetLibDate(version);
	Print("date=%s\r\n", version);
	Print("Tcpip library version:%X, Library Date is %s\r\n", GetTcpipLibVer(), version);

	XS_AddSystemLoopFun(UserLoop); /* need add this line for the library 0.9.100 date after 2004/06/02 */

	DT2_AddTimer(500, 1, printHello);	//the function "printHello" is called every 500ms
}

void XS_UserEnd(void)
{
 	DT2_DeleteTimer(1);  //DT_DeleteTimer(id,number); number= the number of DT_AddTimer used
}

void UserLoop(void)
{ 
   	//DT_DeleteTimer(1,5);
	if(Kbhit()){
		switch(Getch()){
			case 27:		//27 = ESC
				QuitMain=1;
				break;
		}
	}
}

void main(int argc,char *argv[])
{
	XS_main(argc, argv); /* call the XS library main function. */
}

void printHello(void){
	 Print("Hello!	");
}


