void ClientSession::HandleLeaveRoomRequest( LeaveRoomRequest& inPacket ) { m_RecvBuffer.Read( (char*)&inPacket, inPacket.m_Size ); int roomNumber = inPacket.m_RoomNumber; if ( !g_RoomManager->CheckRoom( roomNumber ) ) { ++m_ErrorNumber; return; } if ( !g_RoomManager->LeaveRoom( roomNumber, m_PlayerID ) ) { LogD( "[Disconnected from:]ClientSession::HandleLeaveRoomRequest LeaveRoom Error \n" ); Disconnect(); } EnterRoomResult outPacket; outPacket.m_RoomNumber = roomNumber; if ( !Broadcast( &outPacket ) ) { LogD( "[Disconnected from:]ClientSession::HandleLeaveRoomRequest Broadcast Fail \n" ); Disconnect(); } LogD( "Leave Room! ID:%d ROOM:%d \n", m_PlayerID, roomNumber ); g_RoomManager->PrintClientList(); // 테스트 프린트 }
int main() { // Find and open the correct framebuffer device. int fb_fd = open(FB_PATH, O_RDONLY); if (fb_fd < 0) { char * errstr = strerror(errno); char * errmsg = (char *)calloc(ERR_BUFFER_SIZE, sizeof(char)); strncpy(errmsg, "External: Could not open framebuffer device: ", 45); strncpy(errmsg + 45, errstr, ERR_BUFFER_SIZE - 45); LogE(errmsg); return(1); } const char * mode_str = getenv("ANDROSS_MODE"); if (mode_str == NULL) { mode_str = ""; } int ret; if (strcmp(mode_str, "FB_PARAMS") == 0) { LogD("External: Running in Param mode."); ret = writeFBParams(FD_STDOUT, fb_fd); } else if (strcmp(mode_str, "FB_DATA") == 0) { LogD("External: Running in Data mode."); const char * fb_bytes_str = getenv("ANDROSS_FRAMEBUFFER_BYTES"); int fb_bytes = atoi(fb_bytes_str); ret = writeFBData(FD_STDOUT, fb_fd, fb_bytes); } else { LogD("External: Running in True mode."); ret = 0; } return ret; }
void ClientSession::HandleStopCorpsRequest( StopCorpsRequest& inPacket ) { m_RecvBuffer.Read( (char*)&inPacket, inPacket.m_Size ); int corpsID = inPacket.m_CorpsID; if ( !m_GameRoom->GetCorpsByCorpsID( corpsID ) ) { ++m_ErrorNumber; return; } if ( m_ErrorNumber > m_ErrorNumberMax ) { LogD( "[Disconnected from:]ClientSession::HandleStopCorpsRequest Error MAX \n" ); Disconnect(); } // MOVE!!!!!!; // 미구현 그냥 클라쪽 패킷만 일단 구현 StopCorpsResult outPacket; outPacket.m_CorpsID = corpsID; if ( !Broadcast( &outPacket ) ) { LogD( "[Disconnected from:]ClientSession::HandleStopCorpsRequest BroadCast fail \n" ); Disconnect(); } LogD( "CorpsStopped! CorpID:%d PlayerID:%d \n", corpsID, m_PlayerID ); }
void onLibHookedByMonoHooker(const char *sofilename, soinfo *soinfo) { if (strstr(sofilename, VICTIM_MONO) && soinfo) { #ifdef DEBUG LogD("<%s> hooking: %s, %s(%x)", __FUNCTION__, sofilename, soinfo->name, (int)soinfo->base); #endif for (int i = 0; i < sizeof(gHookSymbols) / sizeof(gHookSymbols[0]); i++) { HOOK_SYMBOL hook = gHookSymbols[i]; if (*hook.old_func == NULL) inlineHookSymbol(soinfo, hook.symbol, hook.new_func, hook.old_func); } for (int i = 0; i < sizeof(gFindSymbols) / sizeof(gFindSymbols[0]); i++) { FIND_SYMBOL find = gFindSymbols[i]; if (*find.func == NULL) *find.func = dlsym(soinfo, find.symbol); } #ifdef DEBUG for(int i =0; i < sizeof(gHookSymbols)/sizeof(gHookSymbols[0]); i++) { HOOK_SYMBOL hook = gHookSymbols[i]; if(*(int *)(hook.old_func) == 0) LogD("<HookSymbol> symbol %s not found (new = 0x%x)", hook.symbol, (int)hook.new_func); } for(int i =0; i < sizeof(gFindSymbols)/sizeof(gFindSymbols[0]); i++) { FIND_SYMBOL find = gFindSymbols[i]; if(*(int *)(gFindSymbols[i].func) == 0) LogD("<FindSymbol> symbol %s not found", gFindSymbols[i].symbol); } #endif } }
/** * This function will delete the data from CacheData list. * * @param cache the cache pointer * @param name the cache data name * * @return error code */ static CacheErrCode delData(pCache const cache, const char* name) { CacheErrCode errorCode = CACHE_NO_ERR; pCacheData data = cache->dataHead, dataTemp; /* lock the thread pool synchronized lock */ cache->pool->lock(cache->pool); assert((name != NULL) && (strlen(name) <= CACHE_NAME_MAX)); /* check cache initialize */ if (cache->dataHead == NULL) { LogD("the %s's data list is NULL,delete data fail", cache->name); errorCode = CACHE_NO_VALUE; } /* search the data from list*/ if (errorCode == CACHE_NO_ERR) { if (strcmp(data->name, name)) { /* list head */ for (;;) { if (data->next == NULL) {/* list tail */ LogD("could not find %s", name); errorCode = CACHE_NAME_ERROR; break; } else { if (!strcmp(data->next->name, name)) { break; } else { data = data->next; } } } } } if (errorCode == CACHE_NO_ERR) { /* delete data is head node */ if (data == cache->dataHead) { /* the list has one node */ if ((cache->dataHead == cache->dataTail) && (cache->dataHead != NULL)) { cache->dataHead = cache->dataTail = NULL; } else { /* the list has more than one node*/ cache->dataHead = data->next; } } else if (data->next == cache->dataTail) {/* delete data is tail node */ cache->dataTail = data; cache->dataTail->next = NULL; data = data->next; /* data will be freed in the end */ } else { dataTemp = data->next; data->next = data->next->next; data = dataTemp; /* data will be freed in the end */ } free(data->value); data->value = NULL; free(data); data = NULL; dataTemp = NULL; LogD("delete %s data node is success", name); } /* unlock the thread pool synchronized lock */ cache->pool->unlock(cache->pool); return errorCode; }
void ACacheManager::LoadCacheFromDisk() { LogD(0, "LoadCacheFromDisk()\n"); ProjectionMapper *projectionMapper = ProjectionMapper::InstancePtr(); auto alias_ChannelsRAMCache = m_ChannelsRAMCache; m_ChannelsDiskCache->LoadData( [projectionMapper](char *filename, uint &idx_x, uint &idx_y) mutable -> bool { LogD(0, "[Lambda]: (char *filename, uint &idx_x, uint &idx_y)(%s, *idx_x*, *idx_y*)\n", filename); double lat, lng; if (sscanf(filename, "%lf,%lf.csv", &lat, &lng) == 2) { try { projectionMapper->LatLng2IndexXY(lat, lng, idx_x, idx_y); } catch(std::out_of_range& e) { return false; } LogD(0, "%lf %lf -> idx_(x, y)=(%d, %d)\n", lat, lng, idx_x, idx_y); return true; } return false; },[alias_ChannelsRAMCache](uint x, uint y, std::vector<SpectrumChannel>& vec) -> void { LogD(0, "[Lambda]: (std::vector<SpectrumChannel>& vec, uint x, uint y)(*vec*, %d, %d)\n", x, y); alias_ChannelsRAMCache->Push(x, y, vec); }); }
/////////////////////////////////////////////////////////// // 비동기 입력 WSARecv()에 의해서, 입력이 완료 되면 콜백으로 RecvCompletion 실행 void CALLBACK RecvCompletion( DWORD dwError, DWORD cbTransferred, LPWSAOVERLAPPED lpOverlapped, DWORD dwFlags ) { // lpOverlapped 인자를 OverlappedIO 형태로 형변환 하면 // 해당 구조체의 멤버 변수 mObject => ClientSession* // 바로 이 포인터가 비동기 입력 WSARecv로 보낸 ClientSession 객체의 주소값 // PostRecv 멤소드에서 mOverlappedRecv.mObject = this ; 이 부분 참조 ClientSession* fromClient = static_cast<OverlappedIO*>( lpOverlapped )->m_Object; // Overlapped IO 완료 했음. 카운트 감소 fromClient->DecOverlappedRequest(); if ( !fromClient->IsConnected() ) return; /// 에러 발생시 해당 세션 종료 if ( dwError || cbTransferred == 0 ) { LogD( "[Disconnected from:]ClientSession::RecvCompletion dwError \n" ); fromClient->Disconnect(); return; } /// 받은 데이터 처리 fromClient->OnRead( cbTransferred ); /// 다시 받기 if ( false == fromClient->PostRecv() ) { LogD( "[Disconnected from:]ClientSession::RecvCompletion PostRecv \n" ); fromClient->Disconnect(); return; } }
void ClientSession::HandleEnterRoomRequest( EnterRoomRequest& inPacket ) { m_RecvBuffer.Read( (char*)&inPacket, inPacket.m_Size ); int roomNumber = inPacket.m_RoomNumber; // g_RoomManager->AddRoom( ); if ( !g_RoomManager->EnterRoom( roomNumber, m_PlayerID ) ) { LogD( "[Disconnected from:]ClientSession::HandleEnterRoomRequest Enter Room \n" ); Disconnect(); } EnterRoomResult outPacket; outPacket.m_RoomNumber = m_GameRoom->GetRoomNumber(); if ( !Broadcast( &outPacket ) ) { //Log( "[Disconnected from:]ClientSession::HandleEnterRoomRequest Broadcast Fail \n" ); //Disconnect(); } LogD( "Enter Room! ID:%d ROOM:%d \n", m_PlayerID, m_GameRoom->GetRoomNumber( ) ); g_RoomManager->PrintClientList(); // 테스트 프린트 }
void ClientSession::HandleGameOverRequest( GameOverRequest& inPacket ) { m_RecvBuffer.Read( (char*)&inPacket, inPacket.m_Size ); bool isWon = inPacket.m_IsWon; int playerID = inPacket.m_PlayerId; // GM이 아니면 아웃 if ( playerID < 101 && playerID > 199 ) { LogD( "[Disconnected from:]ClientSession::HandleGameOverRequest GM out \n" ); Disconnect( ); return; } GameOverResult outPacket; outPacket.m_PlayerId = playerID; outPacket.m_IsWon = isWon; outPacket.m_KilledCorpsNum = m_KilledCorpsNum; outPacket.m_DeathCorpsNum = m_DeathCorpsNum; outPacket.m_TotalMyCorpsNum = m_TotalMyCorpsNum; LogD( "[GameOverMessage][%d]%d \n", inPacket.m_PlayerId, isWon ); /// 채팅은 바로 방송 하면 끝 if ( !Broadcast( &outPacket ) ) { LogD( "[Disconnected from:]ClientSession::HandleGameOverRequest Broadcast Fail \n" ); Disconnect(); } }
/* * Console application entry * Usage: * imgsdk input output * Notice: * 1. input & onput support *.jpg or *.png * 2. support input and output image type are not same * 3. vert.shdr & frag.shdr must be prepared */ int main(int argc, char **argv) { if (3 != argc) { Log("Usage:\n"); Log(" %s input output\n", argv[0]); return -1; } SdkEnv *env = newDefaultSdkEnv(); if (NULL == env) { LogE("Failed get SdkEnv instance\n"); } setInputImagePath (env, argv[1]); setOutputImagePath (env, argv[2]); sdkMain (env); setEffectCmd (env, "{\"effect\":\"Normal\"}"); onSdkDraw (env); Bitmap_t *img = (Bitmap_t *) env->userData.param; uint32_t begin_t = getCurrentTime(); glBindTexture(GL_TEXTURE, env->handle.texture2Idx); memset (img->base, 0, img->width * img->height * img->form); // copy pixels from GPU memory to CPU memory int x = 0; int y = 0; GLint fmt = GL_RGBA; if (IMAGE_JPG == env->userData.inputImageType) { fmt = GL_RGB; } glReadPixels(x, y, img->width, img->height, fmt, GL_UNSIGNED_BYTE, img->base); int errCode = glGetError (); if (GL_NO_ERROR != errCode ) { Log ("Failed read pixles, error code:0x%04x\n", errCode); } uint32_t finish_t = getCurrentTime(); LogD("Read pixel data cost %d ms\n", (finish_t - begin_t)); begin_t = getCurrentTime(); if (NULL != env->userData.outputPath) { if (saveImage (env->userData.outputPath, img) < 0) { LogE ("Failed saveImage\n"); } else { finish_t = getCurrentTime(); LogD("Save %s cost %d ms\n", env->userData.outputPath, (finish_t - begin_t)); } } freeSdkEnv(env); //onSdkDestroy(env); }
void ClientSession::HandleMoveCorpsRequest( MoveCorpsRequest& inPacket ) { m_RecvBuffer.Read( (char*)&inPacket, inPacket.m_Size ); int corpsID = inPacket.m_CorpsID; float nowX = inPacket.m_NowX; float nowZ = inPacket.m_NowZ; float targetX = inPacket.m_TargetX; float targetZ = inPacket.m_TargetZ; PositionInfo destination; destination.m_EyePoint = { nowX, 0.0f, nowZ }; destination.m_LookAtPoint = { targetX, 0.0f, targetZ }; Corps* corps = m_GameRoom->GetCorpsByCorpsID( corpsID ); if ( !corps ) { ++m_ErrorNumber; return; } // 가드나 킹이 이동 요청해옴 if ( UnitType::UNIT_GUARD == corps->GetUnitType( ) || UnitType::UNIT_KING == corps->GetUnitType( ) ) { LogD( "[Error] [%d]Type Move Request \n", corpsID ); ++m_ErrorNumber; return; } if ( m_ErrorNumber > m_ErrorNumberMax ) { LogD( "[Disconnected from:]ClientSession::HandleMoveCorpsRequest Error MAX \n" ); Disconnect(); } // Corps를 탐색 한 후 Corps의 정체를 파악 // -- 적합한 이동인지 판정 후 스케쥴러에 등록 // // 이후 스케쥴러는 해당 타이밍 마다 액션을 꺼내서 수행 // 이동 액션은 내부적으로 Corps의 상황을 파악하여 // 방향과 속도 등의 정보를 담아서 타이머 발생 때 마다 Result Packet을 보낸다. MovePosition* action = new MovePosition( ); action->SetGameRoom( m_GameRoom ); action->SetOwnerCorps( corps ); action->SetDestination( destination ); m_GameRoom->AddActionToScheduler( action, 0 ); LogD( "CorpsMoved CorpID:%d PlayerID:%d DesX:%f DesZ:%f \n", corpsID, m_PlayerID, destination.m_EyePoint.x, destination.m_EyePoint.z ); }
/** * @param argv - To be passed directly to execv. argv[0] must be the full path * to the binary you want to execute. * @param output_buf - The buffer in which to store the child process's output. * @param buf_len - To be passed to read(). Passing 0 for this and toss_bytes * will result in no accesses being made to output_buf, making it safe to * pass NULL. * @param fd - The fd on the child process from which to capture output. 1 and 2 * are probably the only values that make sense. * @param toss_bytes - Bytes to skip at the beginning of the child process's * output. It is unsafe for this to be greater than the size of your * buffer. */ static inline int execForOutput(char ** argv, uint8_t * output_buf, int buf_len, int fd, int toss_bytes) { int pipefd[2]; pipe(pipefd); LogD("NBridge: Reading fd %d from %s with args:", fd, argv[0]); char ** arg = argv + 1; while (*arg != NULL) { LogD("\t%s", *arg); ++arg; } int cpid = fork(); if (cpid == 0) { close(pipefd[0]); dup2(pipefd[1], fd); execv(argv[0], argv); } close(pipefd[1]); if (toss_bytes > 0) { int bytes_tossed = read(pipefd[0], output_buf, toss_bytes); if (bytes_tossed != toss_bytes) { LogE("NBridge: Error skipping junk! Only tossed %d bytes.", bytes_tossed); return -1; } else { LogD("NBridge: Skipped %d bytes.", bytes_tossed); } } int bytes_read = 0; int reads = 0; int child_status = -1; while (bytes_read < buf_len) { int bytes_read_this_time = read(pipefd[0], output_buf + bytes_read, buf_len - bytes_read); if (bytes_read_this_time < 0) { char * errmsg = strerror(errno); LogE("NBridge: Error while reading from subprocess:"); LogE(errmsg); return 255; } if (bytes_read_this_time == 0) { break; } bytes_read += bytes_read_this_time; reads++; } LogD("NBridge: Read %d of %d bytes from subprocess with %d reads.", bytes_read, buf_len, reads); close(pipefd[0]); return waitpid(cpid, &child_status, 0); }
/** * This function will add CacheData to list. * * @param cache the cache pointer * @param name the name of CacheData * @param length the value length * @param value the value point * @param valueChangedListener the changed value's callback function * * @return error code */ static CacheErrCode addData(pCache const cache, const char* name, uint8_t length, uint16_t* value, void* (*valueChangedListener)(void *arg)) { CacheErrCode errorCode = CACHE_NO_ERR; pCacheData data; /* lock the thread pool synchronized lock */ cache->pool->lock(cache->pool); data = (pCacheData) malloc(sizeof(CacheData)); assert(data != NULL); if (hasData(cache, name) != NULL) {/* the data must not exist in list */ LogD("the name of %s data is already exist in cache data list", name); errorCode = CACHE_NAME_ERROR; } else { strcpy(data->name, name); } if (errorCode == CACHE_NO_ERR) { if (length > CACHE_LENGTH_MAX) { LogD("the name %s is too long,can't add to list", name); errorCode = CACHE_LENGTH_ERROR; } else { data->length = length; } } if (errorCode == CACHE_NO_ERR) { /* malloc data value space */ data->value = (uint16_t*) malloc(length * sizeof(uint16_t)); assert(data->value != NULL); memcpy(data->value, value, length * sizeof(uint16_t)); data->valueChangedListener = valueChangedListener; data->next = NULL; /* if list is NULL ,then head node is equal of tail node*/ if (cache->dataHead == NULL) { cache->dataHead = cache->dataTail = data; } else if ((cache->dataHead == cache->dataTail) /* the list has one node */ && (cache->dataHead != NULL)) { cache->dataHead->next = data; cache->dataTail = data; } else { /* the list has more than one node*/ cache->dataTail->next = data; cache->dataTail = data; } LogD("add %s to data list is success", name); } else if (errorCode != CACHE_NO_ERR) { free(data); data = NULL; } /* unlock the thread pool synchronized lock */ cache->pool->unlock(cache->pool); return errorCode; }
void ClientSession::HandleGenerateCorpsRequest( GenerateCorpsRequest& inPacket ) { m_RecvBuffer.Read( (char*)&inPacket, inPacket.m_Size ); UnitType unitType = inPacket.m_UnitType; float nowX = inPacket.m_NowX; float nowZ = inPacket.m_NowZ; float lookX = inPacket.m_LookX; float lookZ = inPacket.m_LookZ; int playerID = inPacket.m_PlayerId; // gm만 리퀘스트를 할수있게... 치트 테스트를 위해 잠시 꺼둠 // if ( playerID < 101 && playerID > 199 ) // { // Disconnect(); // return; // } PositionInfo position; position.m_EyePoint = { nowX, 0.0f, nowZ }; position.m_LookAtPoint = { lookX, 0.0f, lookZ }; const Corps* corps = m_GameRoom->GenerateCorps( playerID, unitType, position ); if ( !corps ) { return; } GenerateCorpsResult outPacket; outPacket.m_UnitType = unitType; outPacket.m_NowX = nowX; outPacket.m_NowZ = nowZ; outPacket.m_LookX = lookX; outPacket.m_LookZ = lookZ; outPacket.m_CorpsID = corps->GetCorpsID(); outPacket.m_PlayerId = corps->GetPlayerID( ); outPacket.m_FormationType = corps->GetFormationType(); outPacket.m_UnitNum = corps->GetUnitNum(); if ( !Broadcast( &outPacket ) ) { LogD( "[Disconnected from:]ClientSession::HandleGenerateCorpsRequest Broadcast Fail \n" ); Disconnect(); } LogD( "GenerateCorps! Type:%d CorpID:%d PlayerID:%d \n", unitType, corps->GetCorpsID( ), m_PlayerID ); }
void ConnectionWrapper::close() { // This will close socket too only if flag BEV_OPT_CLOSE_ON_FREE is set if (bufEvent != nullptr) { bufferevent_free(bufEvent); } LogD(TAG, "Connection closed fd=" + std::to_string(fd)); }
void SampleLightCO(void){ unsigned long ulADC0_Value[1]; SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_3); ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_PROCESSOR, 0); ADCSequenceStepConfigure(ADC0_BASE, 3, 0, ADC_CTL_CH0 | ADC_CTL_IE | ADC_CTL_END); ADCSequenceEnable(ADC0_BASE, 3); ADCIntClear(ADC0_BASE, 3); while(1){ ADCProcessorTrigger(ADC0_BASE, 3); while(!ADCIntStatus(ADC0_BASE, 3, false)){ } ADCIntClear(ADC0_BASE, 3); ADCSequenceDataGet(ADC0_BASE, 3, ulADC0_Value); Log("Breath Level = "); LogD(ulADC0_Value[0]); Log("\r"); SysCtlDelay(SysCtlClockGet() / 12); } }
void QueryListener::onEvent(bufferevent *bufEvent, short events, void *arg) { QueryListener *_this = static_cast<QueryListener *>(arg); evutil_socket_t fd = bufferevent_getfd(bufEvent); // If socket is closed - delete it from the collection if (events & BEV_EVENT_EOF) { LogD(TAG, "event: BEV_EVENT_EOF fd=" + std::to_string(fd)); _this->connections.erase(bufEvent); } if (events & BEV_EVENT_ERROR) { LogD(TAG, "event: BEV_EVENT_ERROR fd=" + std::to_string(fd)); } }
ConnectionWrapper::ConnectionWrapper(bufferevent *bufEvent, const std::string &authKey) : bufEvent(bufEvent), authKey(authKey), fd(-1) { if (bufEvent != nullptr) { fd = bufferevent_getfd(bufEvent); LogD(TAG, "Connection established fd=" + std::to_string(fd)); } }
void GenerateCorpOnce::OnBegin() { LogD( "[%d]GenerateCorpOnce OnBegin \n", m_PlayerID ); m_ActionStatus = ACTION_TICK; m_GameRoom->AddActionToScheduler( this, 0 ); }
ACacheManager::~ACacheManager() { LogD(0, "~ACacheManager()\n"); if (m_ChannelsRAMCache != nullptr) delete m_ChannelsRAMCache; if (m_ChannelsDiskCache != nullptr) delete m_ChannelsDiskCache; }
void MovePosition::OnTick() { // onTick의 역할은? LogD( "MovePosition OnTick \n" ); m_ActionStatus = ACTION_END; m_OwnerCorps->DoNextAction( this, 0 ); }
/* * Class: com_example_signlanguagerecognitionsystem_RecognitionService * Method: initialize * Signature: ()V */ JNIEXPORT void JNICALL Java_tw_edu_ntust_jojllman_wearableapplication_BLE_RecognitionService_initialize (JNIEnv *enc, jobject obj) { slr_system.m_SLRM.SetFeatureType("GLOVE"); slr_system.m_SLRM.Reset(); int n = slr_system.m_SLRM.m_database.m_signMotionFileName.size(); LogD(TAG, "Database size: %d", n); }
void ACacheManager::PushIntoCache(double lat, double lng, uint x, uint y, std::vector<SpectrumChannel>& vec) { LogD(0, "PushIntoCache(%lf, %lf, %d, %d, *vec*)\n", lat, lng, x, y); if (m_ChannelsRAMCache == nullptr || m_ChannelsDiskCache == nullptr) throw MakeException(std::runtime_error, std::string("You have to initialize the cache before calling ") + __func__ + "() function"); m_ChannelsRAMCache->Push(x, y, vec); m_ChannelsDiskCache->WriteData(lat, lng, vec); }
void GenerateCorpAction::OnBegin( ) { LogD( "[%d]GenerateCorps OnBegin \n", m_PlayerID); m_LastGeneratedTime = GetTickCount64(); m_ActionStatus = ACTION_TICK; m_GameRoom->AddActionToScheduler( this, 0 ); }
void ACacheManager::InitializeCache(uint cell_width_count, uint cell_height_count) { LogD(0, "InitializeCache(%d, %d)\n", cell_width_count, cell_height_count); if (m_ChannelsRAMCache != nullptr || m_ChannelsDiskCache != nullptr) throw MakeException(std::runtime_error, std::string("The cache is already initialized.. which is a problem!")); m_ChannelsRAMCache = new SpectrumChannelsRAMCache(cell_width_count, cell_height_count); m_ChannelsDiskCache = new SpectrumChannelsDiskCache(GetCurrentConfiguration()); }
void QueryListener::onAccept(evconnlistener *listener, evutil_socket_t fd, sockaddr *addr, int sock_len, void *arg) { LogD(TAG, "Accepted new connection with fd=" + std::to_string(fd)); // When a new connection caught, connect it with bufferevent event_base* base = evconnlistener_get_base(listener); bufferevent *bufferevent = bufferevent_socket_new(base, fd, BEV_OPT_CLOSE_ON_FREE); // Connect read, write and event callbacks to bufferevent of the connection bufferevent_setcb(bufferevent, onRead, onWrite, onEvent, arg); bufferevent_enable(bufferevent, (EV_READ | EV_WRITE)); }
int writeFBData(int output_fd, int fb_fd, int fb_bytes) { void * bytes = malloc(fb_bytes); int bytes_read = read(fb_fd, bytes, fb_bytes); if (bytes_read < fb_bytes) { LogE("External: Only read %d bytes from framebuffer!", bytes_read); return 1; } LogD("External: read %u bytes from framebuffer.", bytes_read); int bytes_written = write(output_fd, bytes, fb_bytes); if (bytes_written < fb_bytes) { LogE("External: Only wrote %d bytes!", bytes_written); return 1; } LogD("External: wrote %u bytes.", bytes_written); return 0; }
void ClientSession::HandleChangeCorpsFormationRequest( ChangeCorpsFormationRequest& inPacket ) { m_RecvBuffer.Read( (char*)&inPacket, inPacket.m_Size ); int corpsID = inPacket.m_CorpsID; FormationType formation = inPacket.m_FormationType; Corps* corps = m_GameRoom->GetCorpsByCorpsID( corpsID ); if ( !corps || FormationType::FORMATION_NONE == formation) { ++m_ErrorNumber; return; } if ( m_ErrorNumber > m_ErrorNumberMax ) { LogD( "[Disconnected from:]ClientSession::HandleChangeCorpsFormationRequest Error Max \n" ); Disconnect(); } // 이미 동일 포메이션이면 무시 if ( formation == corps->GetFormationType() ) { return; } // 내 콥스 맵에서 포메이션바꿔주자 corps->ChangeFormation( formation ); // ChangeCorpsFormationResult outPacket; // outPacket.m_CorpsID = corpsID; // outPacket.m_FormationType = formation; // // if ( !Broadcast( &outPacket ) ) // { // Log( "[Disconnected from:]ClientSession::HandleChangeCorpsFormationRequest BoradCast Fail \n" ); // Disconnect(); // } LogD( "Corps Change Formation CorpID:%d Formation:%d \n", corpsID, formation ); }
void Disasm(uint8_t* ram, uint32_t start) { LogV("starting disassembly at: 0x%08x", start); uint32_t pc = start; int end = 1024 * 1024 * 16; while(ram[--end] == 0); while(pc <= end){ int hasRead = 0; uint8_t read8(){ hasRead++; return ram[pc++]; } uint32_t read16(){ uint16_t ret = read8(); ret |= read8() << 8; return ret; } uint32_t read32(){ uint32_t ret = read8(); ret |= read8() << 8; ret |= read8() << 16; ret |= read8() << 24; return ret; } DIns ins = read8(); LAssert(ins < DINS_NUM, "illegal instruction: 0x%02x", ins); int n = printf("\t%s ", dinsNames[ins]); for(int i = 0; i < InsNumOps(ins); i++){ DVals op = read8(); LAssert(op < DVALS_NUM, "illegal operand value: 0x%02x", op); char numStr[64] = {0}; if(OpHasNextWord(op)) sprintf(numStr, "0x%02x", read32()); LogD("op: %d", op); char str[64]; n += printf("%s", StrReplace(str, valNames[op], "nw", numStr)); if(i < InsNumOps(ins) - 1) n += printf(", "); } printf("%*s", 40 - n, "; "); printf("0x%08x | ", pc - hasRead); for(int i = 0; i < hasRead; i++) printf("%02x ", ram[pc - hasRead + i]); printf("\n"); } }
/* * Class: com_example_signlanguagerecognitionsystem_RecognitionService * Method: run_recognize * Signature: ()V */ JNIEXPORT jboolean JNICALL Java_tw_edu_ntust_jojllman_wearableapplication_BLE_RecognitionService_run_1recognize (JNIEnv *enc, jobject obj) { jboolean ok = false; if (slr_system.motionDataQ[0].empty()) LogD(TAG, "Data[0] is empty."); if (slr_system.motionDataQ[1].empty()) LogD(TAG, "Data[1] is empty."); while (!slr_system.motionDataQ[0].empty() && !slr_system.motionDataQ[1].empty()) { slr_system.m_SLRM.RecognizeProcessing(slr_system.motionDataQ[0].at(0), slr_system.motionDataQ[1].at(0)); slr_system.motionDataQ[0].pop_front(); slr_system.motionDataQ[1].pop_front(); if (slr_system.m_SLRM.IsRecognition) { ok = true; slr_system.m_SLRM.IsRecognition = false; } } return ok; }