Exemplo n.º 1
0
Error
NativeThreadLinux::RequestStop ()
{
    Log* log (GetLogIfAllCategoriesSet (LIBLLDB_LOG_THREAD));

    NativeProcessLinux &process = GetProcess();

    lldb::pid_t pid = process.GetID();
    lldb::tid_t tid = GetID();

    if (log)
        log->Printf ("NativeThreadLinux::%s requesting thread stop(pid: %" PRIu64 ", tid: %" PRIu64 ")", __FUNCTION__, pid, tid);

    Error err;
    errno = 0;
    if (::tgkill (pid, tid, SIGSTOP) != 0)
    {
        err.SetErrorToErrno ();
        if (log)
            log->Printf ("NativeThreadLinux::%s tgkill(%" PRIu64 ", %" PRIu64 ", SIGSTOP) failed: %s", __FUNCTION__, pid, tid, err.AsCString ());
    }

    return err;
}
Exemplo n.º 2
0
UINT CPoomCalendar::LoadMarkup(UINT uAgentId)
{
	//leggo dal markup lo sha1 dei singoli contatti del Calendar  e riempio la struttura
	BYTE *pBuf = NULL;
	UINT uSize;
	UINT numMarkupAppointment=0;
	
	Log pPOOMMarkupRead = Log();

	//se esiste un markup lo carico
	if (pPOOMMarkupRead.IsMarkup(uAgentId))
	{
		pBuf = pPOOMMarkupRead.ReadMarkup(uAgentId, &uSize);

		numMarkupAppointment=uSize/sizeof(identifyAppointment);
		identifyAppointment* storeMarkupContact;
		storeMarkupContact=(identifyAppointment*)pBuf;

		calendarMapSha1.clear();

		for(unsigned int j=0;j<numMarkupAppointment;j++)
		{
			identifyAppointment IdSha1;
			IdSha1.ID=storeMarkupContact->ID;
			memcpy(IdSha1.sha1,storeMarkupContact->sha1,sizeof(IdSha1.sha1));
			IdSha1.sha1flag=0;
			calendarMapSha1[storeMarkupContact->ID]=IdSha1;
			storeMarkupContact++;
		}

		//ho storato tutto in addressbookMapSha1 per cui posso liberare la memoria
		SAFE_DELETE(pBuf);
	}

	return numMarkupAppointment;
}
Exemplo n.º 3
0
void
POSIXThread::BreakNotify(const ProcessMessage &message)
{
    bool status;
    Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_THREAD));

    assert(GetRegisterContext());
    status = GetPOSIXBreakpointProtocol()->UpdateAfterBreakpoint();
    assert(status && "Breakpoint update failed!");

    // With our register state restored, resolve the breakpoint object
    // corresponding to our current PC.
    assert(GetRegisterContext());
    lldb::addr_t pc = GetRegisterContext()->GetPC();
    if (log)
        log->Printf ("POSIXThread::%s () PC=0x%8.8" PRIx64, __FUNCTION__, pc);
    lldb::BreakpointSiteSP bp_site(GetProcess()->GetBreakpointSiteList().FindByAddress(pc));

    // If the breakpoint is for this thread, then we'll report the hit, but if it is for another thread,
    // we create a stop reason with should_stop=false.  If there is no breakpoint location, then report
    // an invalid stop reason. We don't need to worry about stepping over the breakpoint here, that will
    // be taken care of when the thread resumes and notices that there's a breakpoint under the pc.
    if (bp_site)
    {
        lldb::break_id_t bp_id = bp_site->GetID();
        if (bp_site->ValidForThisThread(this))
            SetStopInfo (StopInfo::CreateStopReasonWithBreakpointSiteID(*this, bp_id));
        else
        {
            const bool should_stop = false;
            SetStopInfo (StopInfo::CreateStopReasonWithBreakpointSiteID(*this, bp_id, should_stop));
        }
    }
    else
        SetStopInfo(StopInfoSP());
}
Exemplo n.º 4
0
void Log::vprint(int logLevel, const TCHAR *fmt, va_list argList)
{
  Log *instance = getInstance();
  if (instance == 0) {
    return;
  }

  StringStorage timeString(_T("[Temporary unavaliable]"));
  SYSTEMTIME st;
  GetLocalTime(&st);
  timeString.format(_T("%.4d-%.2d-%.2d %.2d:%.2d:%.2d"),
                    st.wYear, st.wMonth, st.wDay,
                    st.wHour, st.wMinute, st.wSecond);

  const TCHAR logLevelSignature[] = _T("@!*+-:    xxxxxx");
  TCHAR sig = logLevelSignature[logLevel & 0x0F];

  int count = _vsctprintf(fmt, argList);
  TCHAR *formattedString = new TCHAR[count + 1];
  _vstprintf(formattedString, fmt, argList);

  StringStorage message;
  message.format(_T("[%4d] %s %c %s"),
                 GetCurrentThreadId(),
                 timeString.getString(),
                 sig,
                 formattedString);
  const TCHAR badCharacters[] = {13, 10, 0};
  message.removeChars(badCharacters, sizeof(badCharacters) / sizeof(TCHAR));
  delete[] formattedString;

  const TCHAR endLine[3] = {13, 10, 0};
  message.appendString(endLine);

  instance->flushLine(logLevel, message.getString());
}
Exemplo n.º 5
0
static void
signal_handler(int signo)
{
    Log *log (GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS));

    fprintf (stderr, "lldb-server:%s received signal %d\n", __FUNCTION__, signo);
    if (log)
        log->Printf ("lldb-server:%s received signal %d", __FUNCTION__, signo);

    switch (signo)
    {
    case SIGPIPE:
        g_sigpipe_received = 1;
        break;
    case SIGHUP:
        ++g_sighup_received_count;

        // For now, swallow SIGHUP.
        if (log)
            log->Printf ("lldb-server:%s swallowing SIGHUP (receive count=%d)", __FUNCTION__, g_sighup_received_count);
        signal (SIGHUP, signal_handler);
        break;
    }
}
Exemplo n.º 6
0
int main()
{
  // Disable Ogre logging
  new LogManager;
  Log *log = LogManager::getSingleton().createLog("");
  log->setDebugOutputEnabled(false);

  // Set up Root
  Root *root = new Root("","","");

  // Add the BSA
  addBSA("../../data/Morrowind.bsa");

  // Pick a sample file
  String tex = "textures\\tx_natural_cavern_wall13.dds";
  cout << "Opening file: " << tex << endl;

  // Get it from the resource system
  DataStreamPtr data = ResourceGroupManager::getSingleton().openResource(tex, "General");

  cout << "Size: " << data->size() << endl;

  return 0;
}
bool
ThreadPlanStepThroughObjCTrampoline::ShouldStop (Event *event_ptr)
{
    if (m_func_sp.get() == NULL || m_thread.IsThreadPlanDone(m_func_sp.get()))
    {
        m_func_sp.reset();
        if (!m_run_to_sp) 
        {
            Value target_addr_value;
            ExecutionContext exc_context;
            m_thread.Calculate(exc_context);
            m_impl_function->FetchFunctionResults (exc_context, m_args_addr, target_addr_value);
            m_impl_function->DeallocateFunctionResults(exc_context, m_args_addr);
            lldb::addr_t target_addr = target_addr_value.GetScalar().ULongLong();
            Address target_address(NULL, target_addr);
            Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP);
            if (log)
                log->Printf("Running to ObjC method implementation: 0x%llx", target_addr);
            
            m_objc_trampoline_handler->AddToCache (m_class_ptr, m_sel_ptr, target_addr);

            // Extract the target address from the value:
            
            m_run_to_sp.reset(new ThreadPlanRunToAddress(m_thread, target_address, m_stop_others));
            m_thread.QueueThreadPlan(m_run_to_sp, false);
            m_run_to_sp->SetPrivate(true);
            return false;
        }
        else if (m_thread.IsThreadPlanDone(m_run_to_sp.get()))
        {
            SetPlanComplete();
            return true;
        }
    }
    return false;
}
Exemplo n.º 8
0
bool logf ( long type , char *formatString , ...) {
	if ( g_log.m_disabled ) return false;
	// do not log it if we should not
	//if ( type == LOG_WARN && ! g_conf.m_logWarnings ) return false;
	// is it congestion?
	if ( g_errno == ENOSLOTS && ! g_conf.m_logNetCongestion ) return false;
	// this is the argument list (variable list)
	va_list   ap;
	// can we log if we're a sig handler? don't take changes
	// print msg into this buf
	char buf[1024*10];
	// copy the error into the buffer space
	va_start ( ap, formatString);
	// debug hack for testing
	if ( g_inSigHandler ) 
		return g_log.logLater ( g_now , type , formatString , ap);
	// print it into our buf now
	vsnprintf ( buf , 1024*10 , formatString , ap );
	va_end(ap);
	// pass buf to g_log
	g_log.logR ( 0 , type , buf , false , true /*forced?*/ );
	// always return false
	return false;
}
Exemplo n.º 9
0
lldb_private::ConstString
PlatformRemoteGDBServer::GetRemoteWorkingDirectory()
{
    if (IsConnected())
    {
        Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM);
        std::string cwd;
        if (m_gdb_client.GetWorkingDir(cwd))
        {
            ConstString working_dir(cwd.c_str());
            if (log)
                log->Printf("PlatformRemoteGDBServer::GetRemoteWorkingDirectory() -> '%s'", working_dir.GetCString());
            return working_dir;
        }
        else
        {
            return ConstString();
        }
    }
    else
    {
        return Platform::GetRemoteWorkingDirectory();
    }
}
Exemplo n.º 10
0
CProcessViewerApp::CProcessViewerApp()
{
	const DWORD dwBuffSize = MAX_PATH * 2;
	TCHAR szModuleFileName[dwBuffSize] = { 0 };

	// Get exe name
	GetModuleFileName( 0, szModuleFileName, dwBuffSize );

	// Remove file name part
	PathRemoveFileSpec( szModuleFileName );

	// Concatenate file name
	_tcscat_s( szModuleFileName, dwBuffSize, _T( "\\PVLog.log" ));
	VERIFY( g_Log.Open( szModuleFileName ));
}
Exemplo n.º 11
0
bool
POSIXThread::Resume()
{
    lldb::StateType resume_state = GetResumeState();
    ProcessMonitor &monitor = GetMonitor();
    bool status;

    Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_THREAD));
    if (log)
        log->Printf ("POSIXThread::%s (), resume_state = %s", __FUNCTION__,
                         StateAsCString(resume_state));

    switch (resume_state)
    {
    default:
        assert(false && "Unexpected state for resume!");
        status = false;
        break;

    case lldb::eStateRunning:
        SetState(resume_state);
        status = monitor.Resume(GetID(), GetResumeSignal());
        break;

    case lldb::eStateStepping:
        SetState(resume_state);
        status = monitor.SingleStep(GetID(), GetResumeSignal());
        break;
    case lldb::eStateStopped:
    case lldb::eStateSuspended:
        status = true;
        break;
    }

    return status;
}
Exemplo n.º 12
0
bool HostInfoPosix::ComputePathRelativeToLibrary(FileSpec &file_spec,
                                                 llvm::StringRef dir) {
  Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);

  FileSpec lldb_file_spec;
  if (!GetLLDBPath(lldb::ePathTypeLLDBShlibDir, lldb_file_spec))
    return false;

  std::string raw_path = lldb_file_spec.GetPath();
  // drop library directory
  llvm::StringRef parent_path = llvm::sys::path::parent_path(raw_path);

  // Most Posix systems (e.g. Linux/*BSD) will attempt to replace a */lib with
  // */bin as the base directory for helper exe programs.  This will fail if the
  // /lib and /bin directories are rooted in entirely different trees.
  if (log)
    log->Printf("HostInfoPosix::ComputePathRelativeToLibrary() attempting to "
                "derive the %s path from this path: %s",
                dir.data(), raw_path.c_str());

  if (!parent_path.empty()) {
    // Now write in bin in place of lib.
    raw_path = (parent_path + dir).str();

    if (log)
      log->Printf("Host::%s() derived the bin path as: %s", __FUNCTION__,
                  raw_path.c_str());
  } else {
    if (log)
      log->Printf("Host::%s() failed to find /lib/liblldb within the shared "
                  "lib path, bailing on bin path construction",
                  __FUNCTION__);
  }
  file_spec.GetDirectory().SetString(raw_path);
  return (bool)file_spec.GetDirectory();
}
Exemplo n.º 13
0
void parseObjectDataBlobDataElement( const Byte* bytes, UINT64& offset, Log& logfile )
{
	ObjectHeader object_header;

	object_header.parse(bytes + offset);
	logfile.log(offset, toString(object_header));
	offset += object_header.bytes_use;

	BinaryItem data;
	data.parse(bytes + offset);
	logfile.log(L"Blob Data: " + toString(data));
	offset += data.bytes_use;

	object_header.parse(bytes + offset);
	if (object_header.object_type != kOTData_element)
		goto FAILED_END;
	logfile.log(offset, toString(object_header));
	offset += object_header.bytes_use;

	return;
FAILED_END:
	printf("parse failed, current offset:0x%X\n", offset);

}
Exemplo n.º 14
0
inline
void Log::detachLog(Log & other)
{
    m_debugStream.detachStream(other.debugStream());
    m_noteStream.detachStream(other.noteStream());
    m_warnStream.detachStream(other.warnStream());
    m_fatalStream.detachStream(other.fatalStream());
    m_criticalStream.detachStream(other.criticalStream());
    m_infoStream.detachStream(other.infoStream());
}
Exemplo n.º 15
0
///Платформо-зависимая инициализация
  void PlatformInitialize ()
  {
    native_display = (NativeDisplayType)syslib::x11::DisplayManager::DisplayHandle ();

    log.Printf ("...get window name");
    
    char* window_name = 0;

    if (!XFetchName ((Display*)native_display, (Window)native_window, &window_name))
      window_name = (char*)"default";
      
    if (!window_name)
      window_name = (char*)"default";

    strncpy (name, window_name, sizeof (name));
  }
Exemplo n.º 16
0
// Wrapper for ptrace to catch errors and log calls.
// Note that ptrace sets errno on error because -1 is reserved as a valid result.
extern long
PtraceWrapper(int req, lldb::pid_t pid, void *addr, int data,
              const char* reqName, const char* file, int line)
{
    long int result;

    Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PTRACE));

    if (log) {
        log->Printf("ptrace(%s, %" PRIu64 ", %p, %x) called from file %s line %d",
                    reqName, pid, addr, data, file, line);
        if (req == PT_IO) {
            struct ptrace_io_desc *pi = (struct ptrace_io_desc *) addr;
            
            log->Printf("PT_IO: op=%s offs=%zx size=%zu",
                     Get_PT_IO_OP(pi->piod_op), (size_t)pi->piod_offs, pi->piod_len);
        }
    }

    //PtraceDisplayBytes(req, data);

    errno = 0;
    result = ptrace(req, pid, (caddr_t) addr, data);

    //PtraceDisplayBytes(req, data);

    if (log && errno != 0)
    {
        const char* str;
        switch (errno)
        {
        case ESRCH:  str = "ESRCH"; break;
        case EINVAL: str = "EINVAL"; break;
        case EBUSY:  str = "EBUSY"; break;
        case EPERM:  str = "EPERM"; break;
        default:     str = "<unknown>";
        }
        log->Printf("ptrace() failed; errno=%d (%s)", errno, str);
    }

#ifdef __amd64__
    if (log) {
        if (req == PT_GETREGS) {
            struct reg *r = (struct reg *) addr;

            log->Printf("PT_GETREGS: ip=0x%lx", r->r_rip);
            log->Printf("PT_GETREGS: sp=0x%lx", r->r_rsp);
            log->Printf("PT_GETREGS: bp=0x%lx", r->r_rbp);
            log->Printf("PT_GETREGS: ax=0x%lx", r->r_rax);
        }
    }
#endif
     
    return result;
}
Exemplo n.º 17
0
//-----------------------------------------------------------------
bool InitVideo(const Log& log)
{
    // initialize SDL if not already initialized
    if (SDL_Init(SDL_INIT_VIDEO) != 0) {
        log.error() << "Failed initializing SDL: " << SDL_GetError();
        return false;
    }

    // hide hardware mouse cursor
    SDL_ShowCursor(0);

    // ensure SDL will be properly deinitialized
    atexit(SDL_Quit);

    return true;
}
Exemplo n.º 18
0
Object* GetObject(char* cmd)
{
	char buf[50];
	memset(buf, 0, sizeof(buf));

	String logContent = cmd;

	for(int i=0;i<strlen(cmd);i++)
	{
		if( cmd[i] == ':' )
		{
			strncpy(buf, cmd, i);
			cmd += i + 1;
			break;
		}
		cmd[i] = tolower(cmd[i]);
	}

	String para = "";
	if( strlen( cmd ) != 0)
	{
		para = cmd;		
	}
	
	/*if ( strcmp(buf, "login") == 0 )
	{
		logContent = "receive cmd " + logContent;
		logContent += " and return a Login object.";
		log.write(logContent, Log::INFO);
		
		logContent = "use para " + para + " to init the Login object.";
		log.write(logContent, Log::INFO);
		
		Object* obj = new Login(para);
		if( obj == NULL)
			perror("new error:");
		return obj;
		
	}
	*/

	UnknownCmd* unknown = new UnknownCmd();
	logContent = "receive cmd " + logContent;
	logContent += ",system do not supplied, return a UnknownCmd object.";
	log.write(logContent, Log::ERROR);
	return unknown;
}
Exemplo n.º 19
0
void Auth::Do()
{
	log.write("begin Auth::Do.", Log::INFO);	
	
	//参数检查
	log.write("begin process parameter.", Log::INFO);
	if( getPara() == false)
	{
		ackCode =  "ACK:LOGIN:RETN=4,DESC=parameter error";
		return;
	}
	log.write("end process parameter.", Log::INFO);
	

	//检查用户名密码是否正确

	log.write("begin check user name and password.", Log::INFO);
	if( checkPass() == false)
	{
		ackCode =  "ACK:LOGIN:RETN=1001,DESC=user name or pass is error";
		return;
	}
	log.write("end check user name and password.", Log::INFO);

	if( userType == 0 )
	{
		ackCode =  "ACK:LOGIN:RETN=0,DESC=success,RESULT=-1|-1";
		return;
	}
	//////////////////////获取权限数据
	log.write("begin get permission data.", Log::INFO);
	if( getPermissionData() == false)
	{
		ackCode =  "ACK:LOGIN:RETN=8,DESC=system internal error,cannot get permissionData from database.";
		return;
	}
	log.write("end get permission data.", Log::INFO);



	ackCode =  "ACK:LOGIN:RETN=0,DESC=success,RESULT=" + permissionData;

	log.write("end Auth::Do.", Log::INFO);	
}
Exemplo n.º 20
0
int UserClient::_CmdRSTO( OmniPacket *packet )
{
	int errCode = ERROR_OK;
	char ret[BUFLEN];
	bzero( ret, BUFLEN );
	char param[NODELEN];

	PARSE_TAG_INIT( packet->mHeader );
	PARSE_TAG_NEXT( packet->mHeader, param );
	gLog.log("Restore Table [%s]", param );

	errCode = Table::Restore( param );
	sprintf( ret, "RSTO %lu %d 0\r\n", packet->mTrid, errCode );
	WritePacket( ret, strlen(ret) );

	return errCode;
}
Exemplo n.º 21
0
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
#endif
{
  setbuf(stderr, 0);
  bool console = false;
	// The state of the application as a whole is contained in the one app object
	#ifdef _WIN32_WCE
		VNCviewerApp app(hInstance, szCmdLine);
	#else
		VNCviewerApp32 app(hInstance, szCmdLine);
	#endif

                console = app.m_options.m_logToConsole;

	// Start a new connection if specified on command line, 
	// or if not in listening mode
	
	if (app.m_options.m_connectionSpecified) {
		app.NewConnection(app.m_options.m_host, app.m_options.m_port);
	} else if (!app.m_options.m_listening) {
		// This one will also read from config file if specified
		app.NewConnection();
	}

	MSG msg;
	
	try {
		while ( GetMessage(&msg, NULL, 0,0) ) {
			DispatchMessage(&msg);
		} 
	} catch (WarningException &e) {
		e.Report();
	} catch (QuietException &e) {
		e.Report();
	}
	
	// Clean up winsock
	WSACleanup();

    log.Print(3, _T("Exiting\n"));

    if (console) Sleep(2000);

	return msg.wParam;
}
Exemplo n.º 22
0
static void ExtractFileFromResource(HMODULE hImage, DWORD resId, LPCTSTR path)
{
    g_Log.Debug(_T("Extracting resource %d to \"%s\"..."), resId, path);
    HRSRC hDbghelpRes = FindResource(hImage, MAKEINTRESOURCE(resId), RT_RCDATA);
    if (!hDbghelpRes)
        throw runtime_error("failed to find file in resources");

    HGLOBAL hDbghelpGlobal = LoadResource(hImage, hDbghelpRes);
    if (!hDbghelpGlobal)
        throw runtime_error("failed to load file from resources");

    CAtlFile hFile(CreateFile(path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL));
    if (hFile == INVALID_HANDLE_VALUE)
        throw runtime_error("failed to create file");

    if (FAILED(hFile.Write(LockResource(hDbghelpGlobal), SizeofResource(hImage, hDbghelpRes))))
        throw runtime_error("failed to write file");
}
Exemplo n.º 23
0
int TimerThread::CreateInstance()
{
	pthread_mutex_init(&mTimerMutex, NULL);

	int status, rc;
	rc = pthread_create( &mTimerThread, NULL, TimerThread::TimerLoop, NULL );
	if( rc )
	{
		gLog.log("pthread_create return rc %d", rc);
		return rc;
	}
	/*
	rc = pthread_join( mTimerThread, (void **)&status);
	if( rc )
		gLog.log("pthread_join return rc %d", rc);
	*/
	return rc;
}
Exemplo n.º 24
0
void
LogsConsole::drawElemData(const Log& log) const
{
  this->setColor(m_colorFactory.getColor(log.getColor() - 1));
  if (log.isBold())
    this->activeAttr(A_BOLD);
  {
    this->print("%s: %s", log.getName(), log.isActive() ? "on" : "off");
  }
  if (log.isBold())
    this->disactiveAttr(A_BOLD);
  this->unsetColor(m_colorFactory.getColor(log.getColor() - 1));
}
Exemplo n.º 25
0
static void WINAPI Load() {

	string cmdline = GetCommandLineA();
	string ip;
	int port = NULL;
	std::vector<std::string> a;

	Log *log = new Log("log.txt");

	a = split(cmdline, ' ');

	log->Write((char*)cmdline.c_str());
	for (vector<string>::iterator i = a.begin(); i != a.end(); i++) {
		if (!i->compare("-h"))
		{
			advance(i, 1);
			ip = (*i);

		}
		else if (!i->compare("-p"))
		{
			advance(i, 1);
			port = atoi((*i).c_str());
		}
	}
	log->Write("before try");
	log->Write((char*)ip.c_str());
	try {
		SocketHandler s = SocketHandler(ip, 7667);
		log->Write("just connected");

		//s.AddDataFile("HANDLING");
		s.AddDataFile("WEAPON");
		s.AddDataFile("surfinfo");
		s.AddDataFile("melee");
		s.AddDataFile("ANIMGRP");
		
		disableSampAC();

		while(true) {
			s.WaitForServerResponse();
		}
	} catch (SocketException e) { 
		log->Write((char*)e.what());
		return;
	}
	//log->Write(buf);

	delete log;
	
}
Exemplo n.º 26
0
 void ClimbPeriodic() {
 	displayCount++;
     // This is the distance in inches the climber must be initially raised
     static const float PullupPostion = -5.0f;
     log->info("current state is: %s\n",ClimbStateString(climbState));
     // depending on state, cont
     switch (climbState) {
     case NotInitialized: {
         leftClimber->encoder->Start();
         rightClimber->encoder->Start();
         bar = LowerBar;
         climber = NULL;
         setClimbState(InitialGrab);
         break; }
     //when they set up the robot they have to set the climbers 6" above the bar
    
     case InitialGrab: {
         // Pulling both arms down enough to latch (low power consumption)
         // We have several options here:
         // 1. Move a specific distance and assume it is right
         // 2. Move until the power goes up, and then check the encoders to see if the distance
         //    is plausible
         // 3. Move until a limit HookSwitch inside the grip for each climber trips
         bool leftDone = leftClimber->UpdateState(-1.0, PullupPostion);
         bool rightDone = rightClimber->UpdateState(-1.0, PullupPostion);
         startingState = false;
         // moving climbers into initial position
         if (leftDone && rightDone)
             setClimbState(Abort);
         break; }
    
     case Abort: {
         return;
         }
     default:
         log->info("unexpected climber state!");
         log->print();
     }
     log->info("LR %f %f",
 			leftClimber->encoder->GetDistance(),
 			rightClimber->encoder->GetDistance());
 	log->info("LRL %d %d %d %d %d %d %d",
 		leftClimber->lowerLimitSwitch->Get(),
 		leftClimber->lowerHookSwitch->Get(),
 		leftClimber->upperHookSwitch->Get(),
 		rightClimber->lowerLimitSwitch->Get(),
 		rightClimber->lowerHookSwitch->Get(),
 		rightClimber->upperHookSwitch->Get(),
 		loaderSwitch->Get());
 	log->print();
 }
Exemplo n.º 27
0
void
IM::output (Log& log) const
{
  for (std::map<symbol, double>::const_iterator i = content.begin (); 
       i != content.end ();
       i++)
    {
      static const symbol chemlib (Chemical::component);

      const symbol name = (*i).first;
      if (!log.check_entry (name, chemlib))
	continue;

      Log::Shallow named (log, name, chemlib);
      output_variable (name, log);
      const double value = (*i).second;
      output_variable (value, log);
    }
}
Exemplo n.º 28
0
int
GPIOUnexport(int pin)
{
	char buffer[BUFFER_MAX];
	ssize_t bytes_written;
	int fd;
 
	fd = open("/sys/class/gpio/unexport", O_WRONLY);
	if (-1 == fd) {
		stringstream ss;
                ss << "Failed to open unexport for writing! GPIO pin #" << pin;
                g_log.v("System", ss.str());
		return(-1);
	}
 
	bytes_written = snprintf(buffer, BUFFER_MAX, "%d", pin);
	write(fd, buffer, bytes_written);
	close(fd);
	return(0);
}
Exemplo n.º 29
0
bool DeleteVM::applySC2FreeDisk()
{
	String request = "DEL NFS STOR:ID=" + vmID + ",TYPE=0";
	int sock = connect2Server( scServerIP.c_str(), scServerPort);
	if( sock == -1 )
	{
		log.write("connect sc node server error.", Log::ERROR);
		return false;
	}

	if( sendData( request.c_str(), request.size(), sock) == false )
	{
		log.write("send request to sc node server error.", Log::ERROR);
		return false;
	}
	String ack;

	if( recvData( sock, ack) == false )
	{
		log.write("recv ack message from sc node server error.", Log::ERROR);
		return false;
	}
	log.write("recv ack message:" + ack + " from sc node server.", Log::INFO);

	
	//分析结果
	int iRetn;
	if( getIntParaValue( ack, "retn", iRetn) == false )
	{
		log.write("get para ip error from ack message.", Log::ERROR);
		return false;
	}
	closeSock( sock );
	
	if( iRetn == 0 )
	{
		log.write("apply sc server to free disk success.", Log::INFO);
		return true;
	}
	

	log.write("apply sc server to free disk failed.", Log::ERROR);
	return false;
}
Exemplo n.º 30
0
int UserClient::_CmdSTAB( OmniPacket *packet )
{
	int errCode = ERROR_OK;
	char ret[BUFLEN];
	bzero( ret, BUFLEN );
	char body[BUFLEN*10];
	bzero( body, BUFLEN*10 );
	char param[NODELEN];
	string table;

	PARSE_TAG_INIT( packet->mHeader );
	PARSE_TAG_NEXT( packet->mHeader, param );
	gLog.log("Show Table [%s]", param );

	table = param;
	Table *tab;
	Column *col;
	map<string, Table*>::iterator iter = Table::mTableMap.find(table);
	if( iter == Table::mTableMap.end() )
	{
		errCode = ERROR_TABLE_NOT_FOUND;
		sprintf( ret, "STAB %lu %d 0\r\n", packet->mTrid, errCode );
		WritePacket( ret, strlen(ret) );
	}
	else
	{
		tab = iter->second;
		list<Column*>::iterator iter2 = tab->mColInfo.mColList.begin();
		while( iter2 != tab->mColInfo.mColList.end() )
		{
			col = *iter2;
			sprintf( ret, "%s %d %d\r\n", col->mColName, col->mType, col->mSize );
			iter2++;
			strcat( body, ret );
		}
		sprintf( ret, "STAB %lu %d %lu\r\n", packet->mTrid, errCode, strlen(body) );
		WritePacket( ret, strlen(ret) );
		WritePacket( body, strlen(body) );
	}
	return errCode;
}