/********************************************************************* * * GUI_VNC_X_StartServer * * Function description * To start the server, the following steps are executed * - Make sure the TCP-IP stack is up and running * - Init the server context and attach it to the layer * - Start the thread (task) which runs the VNC server * Notes: * (1) The first part of the code initializes the TCP/IP stack. In a typical * application, this is not required, since the stack should have already been * initialized some other place. * This could be done in a different module. (TCPIP_AssertInit() ?) */ int GUI_VNC_X_StartServer(int LayerIndex, int ServerIndex) { /* Make sure the TCP/IP stack is initialized. (1) */ if (xn_rtip_init() != 0) { OS_SendString("GUI_VNC_X_StartServer: Init failed\n"); return 1; /* Error */ } { int interface; xn_bind_cs(0); /* append interface to device table */ interface = xn_interface_open_config(CS89X0_DEVICE, 0, (IOADDRESS)0x20000300,5,0); /* open interface */ if (interface < 0) { OS_SendString("GUI_VNC_X_StartServer: Can not open interface\n"); return 1; /* Error */ } xn_set_ip(interface, (PFBYTE)&_IPLocal[0], (PFBYTE)&_IPMask[0]); /* set IP address of interface */ HW_EnableEthernetIRQ(); /* Enable ethernet IRQ. Make sure it is done after xn_interface_open_config() */ } /* Init VNC context and attach to layer (so context is updated if the display-layer-contents change */ GUI_VNC_AttachToLayer(&_Context, LayerIndex); _Context.ServerIndex = ServerIndex; /* Create task for VNC Server */ OS_CREATETASK(&_VNCServer_TCB, "VNC Server", _ServerTask, 50, _StackVNCServer); return 0; /* O.k., server has been started */ }
int main(void) { OS_IncDI(); /* Initially disable interrupts */ OS_InitKern(); /* Initialize OS */ OS_InitHW(); /* Initialize Hardware for OS */ OS_Q_Create(&_MyQ, &_MyQBuffer, sizeof(_MyQBuffer)); /* You need to create at least one task before calling OS_Start() */ OS_CREATETASK(&TCBHP, "HP Task", HPTask, 100, StackHP); OS_CREATETASK(&TCBLP, "LP Task", LPTask, 50, StackLP); OS_DecRI(); /* Enable interrupts before sending */ OS_SendString("embOS OS_Q example"); OS_SendString("\n\nDemonstrating message passing\n"); OS_Start(); /* Start multitasking */ return 0; }
void DisplaySetup(void) { GUI_Init(); OS_SendString("GUI init done\n"); #ifdef __WEB_ENABLE GUI_VNC_X_StartServer(0, 0); OS_DebugSendString("VNC server init done\n"); #endif }
static void HPTask(void) { char* pData; while (1) { int Len; Len = OS_Q_GetPtr(&_MyQ, (void**)&pData); OS_Delay(10); if (Len) { /* Evaluate Message ... */ OS_SendString(pData); OS_Q_Purge(&_MyQ); } } }
void GUI_X_ErrorOut(const char *s) { OS_SendString(s); }
void GUI_X_Warn (const char *s) { OS_SendString(s); }
void GUI_X_Log (const char *s) { OS_SendString(s); }