bool InitServer() { srand(time(NULL)); //日志等级 INISection * configPath = g_serverIni.GetSection("config"); if (!configPath) { IME_ERROR("Miss section [config] in config ini"); return false; } std::string strLogLevel; if (!configPath->ReadString("loglevel",strLogLevel)) { IME_ERROR("Missing loglevel info"); return false; } sLog->SetLogLevel((char *)strLogLevel.c_str()); int debugmask = 0; if (!configPath->ReadInt("logdebug", debugmask)) { IME_ERROR("Missing logdebug"); return false; } IME_LOG("log debug %x", (unsigned int)debugmask); sLog->SetDebugLogMask((DebugLogFilters)debugmask); ////////////////////////////////////////////////////////////////////////// #ifdef LUA_USE_VERSION sSCript->Init(CScriptSupport::LUA_SCRIPT); sSCript->LoadScript(CSet::ScriptMainFile); #elif defined JAVASCRIPT_uSE_VERSION #endif if (!HandlerInit(MAIN_THREAD)) { IME_ERROR("man thread handler init fail"); return false; } //////// // if (!g_luaState.Init()) // { // IME_ERROR("luaState Init failed."); // return false; // } // //tolua_LuaExport_open(g_luaState.GetState()); // // if (!CLuaCtrl::Init()) // { // IME_ERROR("CLuaCtrl init error"); // return false; // } return true; }
void SerialStartup() { RingBufferInit( SerialInputBuffer, BUFFER_SIZE, &SerialInputRing ); RingBufferInit( SerialOutputBuffer, BUFFER_SIZE, &SerialOutputRing ); ReadGenerationCount=0; GenerationInit(&ReadGeneration, ReadGenerationCount); HandlerInit(&ReadGenerationCritObject); IsrRegisterHandler( SendBytesInterrupt, (void *) HAL_ISR_SERIAL_WRITE, IRQ_LEVEL_SERIAL_WRITE); IsrRegisterHandler( GetBytesInterrupt, (void *) HAL_ISR_SERIAL_READ, IRQ_LEVEL_SERIAL_READ); HalStartSerial(); }