/* UpDate.c: Demo for UDP Search Work with MiniOS7 utility Compiler: BC++ 3.1, Turbo C++ 1.01(3.01) Compile mode: Large Project: Client.c ..\lib\7186el.Lib ..\lib\tcp_dm32.lib ..\lib\FW_nnnnn.LIB Hordware: uPAC-7186EX [Dec 19, 2008] by Liam [Dec 23, 2010] by Nicholas */ #include #include #include #include "..\lib\7186e.h" #include "..\lib\Tcpip32.h" #include "..\lib\MFW.h" #define BUFSIZE 1460 /* read/write buffer size */ char *MsgVersion="v1.0.00[" __DATE__ "]"; int ET_QuitPROG_CMD00(PTCPREADDATA p) { if(!strncmpi(p->ReadUartChar, "00quit", 6)) { DisableWDT(); exit(0); } else TcpPrint(p->Socket, 1, "%s", "Error!"); return 0; } int VcomVersion(PTCPREADDATA p) // COMMAND [01] { TcpPrint(p->Socket, 1, "01%s\r", MsgVersion); return 1; } char *GetModuleName(void) /* User's program must support this function for UDP search */ { return "uPAC-7186E-XS"; //You can define any string you like } int VcomServerName(PTCPREADDATA p) // COMMAND [10] { TcpPrint(p->Socket, 1, "10%s\r",GetModuleName()); return 1; } char *GetAliasName(void) /* User's program must support this function for UDP search */ { return "test1" ; } void XS_UserInit(int argc,char *argv[]) { extern int bAcceptBroadcast; extern unsigned long ACKDELAY; /* variable in tcp.c */ //extern long MAXTXTOUT; void UserLoop(void); char version[20]; InitLib(); bAcceptBroadcast=0; ACKDELAY=200; /* XS_GetVersion(version); Print("[X-Server library]: version=%s ",version); XS_GetLibDate(version); Print("date=%s\r\n",version); GetTcpipLibDate(version); Print("Tcpip library version:%X, Library Date is %s\r\n",GetTcpipLibVer(),version); */ XS_AddSystemLoopFun(UserLoop); /* Add UDP search function */ bAcceptBroadcast=1; // allow to receive the UDP broadcast XS_AddUdpSocket(&XS_UdpSearch); // add the default TCP server (listen port: 10000) XS_AddServer(&Port10K); pXS_Port10kCmd[0]=ET_QuitPROG_CMD00; // 00quit pXS_Port10kCmd[1]=VcomVersion; pXS_Port10kCmd[10]=VcomServerName; // command 10 (called after the defination of ET_Module_Name, line 763) pXS_Port10kCmd[33]=XS_LoadFile_33; // Command 33 is used to download files in VCOM3 using port 10000 and is used to download files to modules /* if you using sockets, add the following two lines*/ XS_AddSystemLoopFun(XS_SocketLoopFun); XS_StartSocket(); //MAXTXTOUT=6000UL; } void XS_UserEnd(void) { XS_StopSocket(); DisableWDT(); } void UserLoop(void) { int key; if(Kbhit()) { switch((key=Getch())) { case 27: QuitMain=1; break; default: break; } } } void main(int argc,char *argv[]) { XS_main(argc,argv); /* call the XS library main function. */ }