コード例 #1
0
void CCommandProcessor::BusyWait ( const char * const paramBegin )
{
  const char * const delayEnd      = SkipCharsNotInSet( paramBegin, SPACE_AND_TAB );
  const char * const extraArgBegin = SkipCharsInSet   ( delayEnd,   SPACE_AND_TAB );

  if ( *paramBegin == 0 || *extraArgBegin != 0 )
  {
    PrintStr( "Invalid arguments." EOL );
    return;
  }

  const unsigned delayMs = ParseUnsignedIntArg( paramBegin );

  if ( delayMs == 0 || delayMs > 60 * 1000 )
  {
    PrintStr( "Invalid arguments." EOL );
    return;
  }

  const uint32_t oneMsIterationCount = GetBusyWaitLoopIterationCountFromUs( 1000 );

  for ( uint32_t i = 0; i < delayMs; ++i )
  {
    BusyWaitLoop( oneMsIterationCount );
  }

  Printf( "Waited %u ms." EOL, unsigned( delayMs ) );
}
コード例 #2
0
void CCommandProcessor::SimulateError ( const char * const paramBegin )
{
  if ( *paramBegin == 0 )
  {
    PrintStr( "Please specify the error type as an argument: 'command' or 'protocol'" EOL );
    return;
  }

  const char * const paramEnd      = SkipCharsNotInSet( paramBegin, SPACE_AND_TAB );
  const char * const extraArgBegin = SkipCharsInSet   ( paramEnd,   SPACE_AND_TAB );

  if ( *extraArgBegin != 0 )
  {
    PrintStr( "Invalid arguments." EOL );
    return;
  }

  if ( DoesStrMatch( paramBegin, paramEnd, "command", false ) )
  {
    throw std::runtime_error( "Simulated command error." );
  }

  if ( DoesStrMatch( paramBegin, paramEnd, "protocol", false ) )
  {
    m_simulateProcolError = true;
    return;
  }

  Printf( "Unknown error type \"%.*s\"." EOL, paramEnd - paramBegin, paramBegin );
}
コード例 #3
0
ファイル: hellocn.c プロジェクト: csl/PXACore
//
//The following routine prints out bug's information.
//
VOID __BUG(LPSTR lpszFileName,DWORD dwLineNum)
{
	BYTE    strBuff[12];
	PrintLine("BUG oencountered.");
	PrintStr("File name: ");
	PrintStr(lpszFileName);
	Hex2Str(dwLineNum,strBuff);
	PrintLine("Lines: ");
	PrintStr(strBuff);
}
コード例 #4
0
ファイル: console.c プロジェクト: ijie/HelloX_OS
//Initialization routine of Console object.
static BOOL ConInitialize(__CONSOLE* pConsole)
{
	__COMMON_OBJECT* hCom1  = NULL;
	if(NULL == pConsole)
	{
		return FALSE;
	}

	//Try to open COM1 interface.
	hCom1 = IOManager.CreateFile(
		(__COMMON_OBJECT*)&IOManager,
		CON_DEF_COMNAME,
		0,
		0,
		NULL);

	//debug
	PrintLine("hCom1="); PrintLine(hCom1);

	if(NULL == hCom1)
	{
		return FALSE;
	}

	pConsole->hComInt      = hCom1;
	pConsole->bInitialized = TRUE;
	pConsole->nRowNum      = CON_MAX_ROWNUM;
	pConsole->nColNum      = CON_MAX_COLNUM;

	//Create console read thread to process COM interface input message.
	pConsole->hConThread = KernelThreadManager.CreateKernelThread(
		(__COMMON_OBJECT*)&KernelThreadManager,
		0,
		KERNEL_THREAD_STATUS_READY,
		PRIORITY_LEVEL_HIGH,
		ConReadThread,
		NULL,
		NULL,
		CON_THREAD_NAME);

	PrintStr("pConsole=");
	PrintStr(pConsole);
	GotoHome();

	if(NULL == pConsole->hConThread)  //Failed to create thread.
	{
		IOManager.CloseFile((__COMMON_OBJECT*)&IOManager,pConsole->hComInt);
		pConsole->hComInt      = NULL;
		pConsole->bInitialized = FALSE;
		return FALSE;
	}
	return TRUE;
}
コード例 #5
0
void CWinsys::PrintJoystickInfo () const {
	if (joystick_active == false) {
		Message ("No joystick found");
		return;
	}
	PrintStr ("");
	PrintStr (SDL_JoystickName (0));
	int num_buttons = SDL_JoystickNumButtons (joystick);
	cout << "Joystick has " << num_buttons << " button" << (num_buttons == 1 ? "" : "s") << '\n';
	int num_axes = SDL_JoystickNumAxes (joystick);
	cout << "Joystick has " << num_axes << " ax" << (num_axes == 1 ? "i" : "e") << "s\n\n";
}
コード例 #6
0
ファイル: Integrate.c プロジェクト: brayest/MSP430
void COUNT_FUNC(char *arg)
{
	unsigned int CMD_OK = 0;
	char *CONTEO;
	switch( arg[0])
	{
	case '0':
		if (CNT_STATUS)
		{
			CNT_STATUS = 0;
			TA1CCTL0 &= ~CCIE;
			CMD_OK = 1;
			P1OUT = 0;
			BLK_STATUS = 0;
			GRL_STATUS = 0;
			CNT_STATUS = 0;

		}else CMD_OK=2;
		break;
	case '1':
		if (!CNT_STATUS)
		{
			CONTEO = strtok( NULL, " ");
			limit = DecStrToInt( CONTEO );
			if ( limit )
			{
				PrintStr("\n");
				PrintStr("> Numero de cuentas: \n");
				PrintDec(limit);
				TA1CCTL0 |= CCIE;
				CMD_OK = 1;
				CNT_STATUS = 1;
				BLK_STATUS = 0;
				GRL_STATUS = 0;
			}else CMD_OK = 0;
		}else CMD_OK = 2;
		break;
	}
	switch ( CMD_OK ){
	case 0:
		PrintStr( "> Invalid argument\n" );
		break;
	case 1:
		PrintStr( "> OK\n" );
		break;
	case 2:
		PrintStr( "> No change\n" );
		break;
	}
}
コード例 #7
0
ファイル: clibrary.c プロジェクト: fjrti/remix
/* print an unsigned integer to a stream without using printf/sprintf */
void PrintUnsigned(unsigned long Num, unsigned int Base, int FieldWidth, int ZeroPad, int LeftJustify, struct OutputStream *Stream)
{
    char Result[33];
    int ResPos = sizeof(Result);

    Result[--ResPos] = '\0';
    if (Num == 0)
        Result[--ResPos] = '0';
            
    while (Num > 0)
    {
        unsigned long NextNum = Num / Base;
        unsigned long Digit = Num - NextNum * Base;
        if (Digit < 10)
            Result[--ResPos] = '0' + Digit;
        else
            Result[--ResPos] = 'a' + Digit - 10;
        
        Num = NextNum;
    }
    
    if (FieldWidth > 0 && !LeftJustify)
        PrintRepeatedChar(ZeroPad ? '0' : ' ', FieldWidth - (sizeof(Result) - 1 - ResPos), Stream);
        
    PrintStr(&Result[ResPos], Stream);

    if (FieldWidth > 0 && LeftJustify)
        PrintRepeatedChar(' ', FieldWidth - (sizeof(Result) - 1 - ResPos), Stream);
}
コード例 #8
0
ファイル: string.c プロジェクト: caivega/HelloX_Kernel
//
//Print a string at a new line.
//
VOID PrintLine(LPSTR pszStr)
{
	//CD_PrintString(pszStr,TRUE);
	GotoHome();
	ChangeLine();
	PrintStr(pszStr);
}
コード例 #9
0
    void GameStateManager::push(std::function<StateErasure(std::string)> stateMaker)
    {
        std::string suid = PrintStr("%$", next_uid());
        stateModules.insert(make_pair(suid, std::vector<std::string>()));

        engine->ScriptEngine->BeginConfigGroup(suid.c_str());
        states.emplace_back(stateMaker(suid));
        engine->ScriptEngine->EndConfigGroup();

        if (states.back().haltsUpdate())
        {
            bool first = true;
            for (StateErasure& state : reverse(states))
            {
                if (first)
                {
                    first = false;
                    continue;
                }

                state.onPause();
                if (state.haltsUpdate())
                    break;
            }
        }
    }
コード例 #10
0
ファイル: SHELL.C プロジェクト: KimZhou/HelloX_STM32
//Default handler if no proper handler is located.
VOID  DefaultHandler(LPSTR pstr)
{
	LPSTR strPrompt = "You entered incorrect command name.";
	GotoHome();
	ChangeLine();
	PrintStr(strPrompt);
	return;
}
コード例 #11
0
ファイル: assign2_3.c プロジェクト: EdwardC/project
void test(){
	int j;
	
  for(j = 0; j < 10; j++){
    PrintStr("loop in test() \n");
  }
  ThreadExit(0);
}
コード例 #12
0
// init the state
void InitState_MainMenu()
{
	// initialize the text
	InitText();
	
	// draw the menu
	PrintStr(9, 9, "Pentago!");
	PrintStr(11, 11, "New Game");
	PrintStr(11, 13, "How To Play");
	PrintStr(11, 15, "Credits");
	
	// draw the selector
	SetTile(10, 11 + (2 * currentOpt), 127);
	
	// fade in
	FadeIn(1, true);
}
コード例 #13
0
int main(int argc,char *argv[]) {
	HString H,T,Sub,S;
	char str[]="123456";
	char arr[]="12345678";
	StrAssign(&H,str);
	StrAssign(&T,arr);
	PrintStr(H);
	printf("\n");
	PrintStr(T);
	printf("\n");
	printf("Length:%d,compare:%d\n",StrLength(H),StrCompare(H,T));
	SubString(&Sub,H,2,3);
	PrintStr(Sub);
	printf("\n");
	StrConcat(&S,H,T);
	printf("\n");
	PrintStr(S);
}
コード例 #14
0
ファイル: assign2_3.c プロジェクト: EdwardC/project
int main(){
  int i;
  ThreadId tid = ThreadFork(test, 2);
  ThreadJoin(tid);

  for(i = 0; i < 10; i++){
    PrintStr("loop in main() \n");
  }
}
コード例 #15
0
void CGenericSerialConsole::Backspace ( void )
{
  // If at the beginning, or if the command is empty...
  if ( m_cursorPos == m_cmdBeginPos )
  {
    Bell();
    return;
  }

  // If at the end...
  if ( m_cursorPos == m_cmdEndPos )
  {
    m_buffer[ m_cmdEndPos ] = 0;
    PrintStr( "\x08 \x08" ); // Go left one character, space (deletes the character), go left one character again.
    m_cmdEndPos = GetCircularPosMinusOne( m_cmdEndPos, BUF_LEN  );
    m_cursorPos = m_cmdEndPos;
    return;
  }


  // NOTE: If the following logic changes much, remeber to update MAX_TX_BUFFER_SIZE_NEEDED.

  // Move the cursor left one position.
  m_cursorPos = GetCircularPosMinusOne( m_cursorPos, BUF_LEN );
  PrintStr( "\x1B[D" );

  // Shift characters downwards one position, and print each one.
  for ( uint32_t i = m_cursorPos; i != GetCircularPosMinusOne( m_cmdEndPos, BUF_LEN ); i = ( i + 1 ) % BUF_LEN )
  {
    m_buffer[ i ] = m_buffer[ (i + 1) % BUF_LEN ];
    PrintChar( m_buffer[ i ] );
  }

  // Delete the last character by writing a space.
  PrintChar( ' ' );

  // Move the terminal cursor left to match our current cursor position.
  const uint32_t distanceToEnd = GetCircularDistance( m_cursorPos, m_cmdEndPos, BUF_LEN );
  if ( distanceToEnd > 0 )
    Printf( "\x1B[%uD", unsigned( distanceToEnd ) );  // Move left n positions.

  m_cmdEndPos = GetCircularPosMinusOne( m_cmdEndPos, BUF_LEN );
}
コード例 #16
0
ファイル: thread.c プロジェクト: EdwardC/project
int main(){
	int i;
	ThreadFork(test, 2);

	for(i=0; i<10; i++){
		PrintStr("loop in main() \n");
	}

	Halt();
}
コード例 #17
0
ファイル: Integrate.c プロジェクト: brayest/MSP430
void TEST_FUNC(char *arg){
	char *token;
	unsigned int Period;
	unsigned int CMD_OK = 0;
	switch( arg[0] ){
	case '0':
		if (BLK_STATUS){
			TA0CCTL0 &= ~CCIE;
			P1OUT = 0;
			BLK_STATUS = 0;
			GRL_STATUS = 0;
			CNT_STATUS = 0;
			CMD_OK = 1;
		} else CMD_OK = 2;
		break;
	case '1':
		if (!BLK_STATUS){
			token = strtok( NULL, " ");
			Period = DecStrToInt( token );
			if( Period ){
				TA0CCTL0 |= CCIE;
				TA0CCR0 = Period;
				BLK_STATUS = 1;
				GRL_STATUS = 0;
				CNT_STATUS = 0;
				CMD_OK = 1;
			} else CMD_OK = 0;
		}  else CMD_OK = 2;
		break;
	}
	switch ( CMD_OK ){
	case 0:
		PrintStr( "> Invalid argument\n" );
		break;
	case 1:
		PrintStr( "> OK\n" );
		break;
	case 2:
		PrintStr( "> No change\n" );
		break;
	}
}
コード例 #18
0
ファイル: main.c プロジェクト: Aditya-Balaji/Projects12-14
void ClearScr()
{
    // Clear display(weird logic I used to make this work)

    SendByte(0x01, FALSE);
    PrintNum(50);
    SetCursorPos(0,0);
    PrintStr(" ");
    SetCursorPos(0,0);

}
コード例 #19
0
// init the state
void InitState_GameOver()
{
	// initialize the text
	InitText();
	
	// draw it out
	PrintStr(10, 1, "Game Over!");
	
	if(wonPlayer == 0)
		PrintStr(10, 13, "Tie Game!");
	else if(wonPlayer == 1)
		PrintStr(8, 13, "Player 1 Won!");
	else if(wonPlayer == 2)
		PrintStr(8, 13, "Player 2 Won!");
	
	PrintStr(1, 26, "Press B to return to menu");
	
	// fade in
	FadeIn(1, true);
}
コード例 #20
0
ファイル: Integrate.c プロジェクト: brayest/MSP430
void GRN_LED_FUNC(char *arg)
{
	unsigned int CMD_OK = 0;
	switch( arg[0] )
	{
		case '0':
			if (GRL_STATUS)
			{
				P1OUT &= ~GR_LED;
				GRL_STATUS = 0;
				BLK_STATUS = 0;
				CNT_STATUS = 0;
				CMD_OK = 1;
			}
			else CMD_OK = 2;
			break;
		case '1':
			if (!GRL_STATUS)
			{
				P1OUT |= GR_LED;
				GRL_STATUS = 1;
				BLK_STATUS = 0;
				CNT_STATUS = 0;
				CMD_OK = 1;
			}
			else CMD_OK = 2;
			break;
	}
	switch ( CMD_OK )
	{
		case 0:
			PrintStr( "> Invalid argument\n" );
			break;
		case 1:
			PrintStr( "> OK\n" );
			break;
		case 2:
			PrintStr( "> No change\n" );
			break;
	}
}
コード例 #21
0
void CGenericSerialConsole::RightArrow ( void )
{
  if ( m_cursorPos == m_cmdEndPos )
  {
    Bell();
    return;
  }

  m_cursorPos = ( m_cursorPos + 1 ) % BUF_LEN;

  PrintStr( "\x1B[C" );  // Move right.
}
コード例 #22
0
void CGenericSerialConsole::LeftArrow ( void )
{
  if ( m_cursorPos == m_cmdBeginPos )
  {
    Bell();
    return;
  }

  m_cursorPos = GetCircularPosMinusOne( m_cursorPos, BUF_LEN );

  PrintStr( "\x1B[D" );  // Move left.
}
コード例 #23
0
void CCommandProcessor::PrintMemory ( const char * const paramBegin )
{
  const char * const addrEnd       = SkipCharsNotInSet( paramBegin, SPACE_AND_TAB );
  const char * const countBegin    = SkipCharsInSet   ( addrEnd,    SPACE_AND_TAB );
  const char * const countEnd      = SkipCharsNotInSet( countBegin, SPACE_AND_TAB );
  const char * const extraArgBegin = SkipCharsInSet   ( countEnd,   SPACE_AND_TAB );

  if ( *paramBegin == 0 || *countBegin == 0 || *extraArgBegin != 0 )
  {
    PrintStr( "Invalid arguments." EOL );
    return;
  }

  assert( countBegin > paramBegin );

  const unsigned addr  = ParseUnsignedIntArg( paramBegin );
  const unsigned count = ParseUnsignedIntArg( countBegin );

  // SerialPrint( "Addr : %u" EOL, unsigned(addr ) );
  // SerialPrint( "Count: %u" EOL, unsigned(count) );

  if ( count == 0 )
  {
    PrintStr( "Invalid arguments." EOL );
    return;
  }

  // We could calculate the maximum byte count more accurately using the USB buffer sizes.
  // Routine HexDump() has also logic to calculate the number of characters needed in advance.
  if ( count > 1024 )
  {
    PrintStr( "Due to the USB buffer size limit and the watchdog period, the byte count cannot exceed 1024 bytes with the current implementation." EOL );
    return;
  }

  HexDump( (const void *) addr, size_t( count ), EOL );
}
コード例 #24
0
// for testing:
void CScore::PrintScorelist (size_t list_idx) const {
	if (list_idx >= Scorelist.size()) return;
	const TScoreList *list = &Scorelist[list_idx];

	if (list->numScores < 1) {
		PrintStr ("no entries in this score list");
	} else {
		for (int i=0; i<list->numScores; i++) {
			string line = "player: " + list->scores[i].player;
			line += " points: " + Int_StrN (list->scores[i].points);
			line += " herrings: " + Int_StrN (list->scores[i].herrings);
			line += " time: " + Float_StrN (list->scores[i].time, 2);
			PrintString (line);
		}
	}
}
コード例 #25
0
ファイル: main.c プロジェクト: jessedewaard/ati2.3a5
THREAD(Thread1, arg)
{
	LcdSetCursorPosition(0,4);
	PrintStr("Ingedrukt");
	int licht = 1;

    for (;;) {
		LcdSetCursorPosition(1,11);
		PrintStr("\1");
		LcdSetCursorPosition(1,12);
		PrintStr("\2");
		LcdSetCursorPosition(1,13);
		PrintStr("\3");
		LcdSetCursorPosition(0,15);
		PrintStr("\4");
		LcdSetCursorPosition(1,15);
		PrintStr("\5");
        NutSleep(100);
		LcdSetCursorPosition(0,0);
		PrintStr("000");		

    	char buffer [16];
		int n;
		char kb = KbGetKey();
		if(kb < 125 && kb > 0){
			n = sprintf(buffer,"%d",kb);
			LcdSetCursorPosition(0,(3-n));
			PrintStr(buffer);
		}
		if(kb == 13){
			if(licht == 1){
				licht = 0;
			}else{
				licht = 1;
			}
			LcdBackLight(licht);
			
		}
		//PrintStr(sprintf("%s",KbGetKey()));
		NutSleep(100);

    }
}
コード例 #26
0
ファイル: main.c プロジェクト: Aditya-Balaji/Projects12-14
void main(void)
{
    WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
    while(1)
    {
    InitializeLcm();
    _delay_cycles(1000);


    PrintStr("Hello World");
    SetCursorPos(1,0);    //Go to second line start
    _delay_cycles(100000);
    PrintNum(42);
    _delay_cycles(1000000);
    ClearScr();
    }

}
コード例 #27
0
ファイル: Str.c プロジェクト: SoftEtherVPN/SoftEtherVPN
// Display a string with arguments
void PrintArgs(char *fmt, va_list args)
{
	wchar_t *ret;
	wchar_t *fmt_wchar;
	char *tmp;
	// Validate arguments
	if (fmt == NULL)
	{
		return;
	}

	fmt_wchar = CopyStrToUni(fmt);
	ret = InternalFormatArgs(fmt_wchar, args, true);

	tmp = CopyUniToStr(ret);
	PrintStr(tmp);
	Free(tmp);

	Free(ret);
	Free(fmt_wchar);
}
コード例 #28
0
ファイル: IntvQuestion.c プロジェクト: luowei/oc-hello
void PrintStr( char *str, char *start )
{
    if( str == NULL ) return;
    
    if( *start == '\0' )
    {
        if( IsValid( str ) ) printf("%s \n",str);
    }
    
    for( char *ptmp = start; *ptmp != '\0'; ptmp++ )
    {
        char tmp = *start;
        *start = *ptmp;
        *ptmp = tmp;
        
        PrintStr( str, start+1 );
        
        tmp = *start;
        *start = *ptmp;
        *ptmp = tmp;
    }  
}
コード例 #29
0
void CCommandProcessor::DisplayResetCause ( void )
{
  PrintStr( "Reset cause: " );

  const uint32_t resetCause = rstc_get_reset_cause( RSTC );

  switch ( resetCause )
  {
  case RSTC_GENERAL_RESET:
    PrintStr( "General" );
    break;

  case RSTC_BACKUP_RESET:
    PrintStr( "Backup" );
    break;

  case RSTC_WATCHDOG_RESET:
    PrintStr( "Watchdog" );
    break;

  case RSTC_SOFTWARE_RESET:
    PrintStr( "Software" );
    break;

  case RSTC_USER_RESET:
    PrintStr( "User" );
    break;

  default:
    PrintStr( "<unknown>" );
    assert( false );
    break;
  }

  PrintStr( EOL );
}
コード例 #30
0
ファイル: server.cpp プロジェクト: cdaffara/symbiandump-os2
// void CBrdSession::ServiceL(const RMessage& aMessage)
void CBrdSession::ServiceL(const RMessage2& aMessage)
    {

    CBrdServer *server = (CBrdServer*)Server();
    
    switch (aMessage.Function())
        {
        case EAnvlPrintInt:
            server->iControl->WriteText(_L("int=%d\n"), aMessage.Int0());
            aMessage.Complete(KErrNone);
            break;
        case EAnvlPrintStr:
            {
			
			TInt desLen = aMessage.GetDesLength(0);

			HBufC8* buf=HBufC8::NewL(desLen);

            TPtr8 bufPtr = buf->Des();

            // Message().ReadL(desPtr,bufPtr);
            
			aMessage.ReadL(0,bufPtr);

			PrintStr(bufPtr);
            aMessage.Complete(KErrNone);
            
            delete buf;
            buf = NULL;
            
            }
            break;
        case EAnvlPrintfStr:
            {

			TInt desLen = aMessage.GetDesLength(0);

			HBufC8* buf=HBufC8::NewL(desLen);
    
    		CleanupStack::PushL(buf);
    		
            TPtr8 bufPtr = buf->Des();
            
			// Message().ReadL(desPtr,bufPtr);

			aMessage.ReadL(0,bufPtr);

			desLen = aMessage.GetDesLength(1);

			HBufC8* buf2=HBufC8::NewL(desLen);
            
            CleanupStack::PushL(buf2);
    		
            TPtr8 bufPtr2 = buf2->Des();
			
            // Message().ReadL(desPtr,bufPtr2);
            
			aMessage.ReadL(0,bufPtr2);

            PrintfStr(bufPtr, bufPtr2);
            aMessage.Complete(KErrNone);

			CleanupStack::Pop();
    		CleanupStack::Pop();
    
            delete buf;
			buf = NULL;
            delete buf2;
			buf2 = NULL;
            
            }
            break;
        case EAnvlPrintfInt:
            {
            
			TInt desLen = aMessage.GetDesLength(0);
			
			HBufC8* buf=HBufC8::NewL(desLen);
           
            TPtr8 bufPtr = buf->Des();
                       
			// Message().ReadL(desPtr,bufPtr);
            
			aMessage.ReadL(0,bufPtr);

            PrintfInt(bufPtr, aMessage.Int1());
            
            aMessage.Complete(KErrNone);
            delete buf;
            buf = NULL;
            
            }
            break;
        case EAnvlNumberOfSessions:
            aMessage.Complete(server->NumberOfSessions());
            break;
        default:
            PanicClient(EPanicUnknownFunction);
            break;
        }
    }