コード例 #1
0
ファイル: command.c プロジェクト: gleicon/archive
void main () {
  
  char buf[1024];
  char *args[64];
  char pwd[128];
  
  init_banner();
  for (;;)
    {
      /*
       * Prompt for and read a command.
       */
      // user@host[pwd] : 
      printf ("%s@%s[%s]: ", getusername() , gethost(), getcwd(pwd, sizeof(pwd)) );

      if (gets (buf) == NULL)
	{
	  printf ("\n");
	  exit (0);
	}

      /*
       * Split the string into arguments.
       */
      
      parse (buf, args);

      /*
       * Execute the command.
       */
      
      execute (args);
    }
}
コード例 #2
0
ファイル: ap_serial.c プロジェクト: afrendybayu/kapalinduk
static portTASK_FUNCTION( vComRxTask, pvParameters )		{
signed char cExpectedByte, cByteRxed;
portBASE_TYPE xResyncRequired = pdFALSE, xErrorOccurred = pdFALSE;
portBASE_TYPE xGotChar;
int ch, mm=0;
char s[30];

	/* Just to stop compiler warnings. */
	( void ) pvParameters;
	vTaskDelay(1);
	
	//vSerialPutString(xPort, "mulakan\r\n", 9);
	
	init_banner();
	//set_env_default();
	baca_konfig_rom();					// hardware/iap.c
	//load_data_rtc();
	
	cmd_shell();
	st_hw.init++;
	
	#ifdef PAKAI_RTC
		//init_RTC_sh();
		start_uptime();
	#endif
	
	#ifdef PAKAI_SDCARD
		st_hw.sdc = 0;
		//disk_initialize(SDC);
		disk_initialize(0);
		set_fs_mount();
		cek_fs_free();
		//mount_disk(0);		// 0: SDCARD
		//uprintf("Cek Memori SDCARD: ...");
		//cek_free_cluster();
		st_hw.sdc = 1;
	#endif
	
	#ifdef configUSE_IDLE_HOOK
		st_hw.init++;
	#endif

	do	{
		vTaskDelay(100);
	} while (st_hw.init != uxTaskGetNumberOfTasks());
	
	//vTaskDelay(100);
	#ifdef PAKAI_SDCARD
	//uprintf("Cek Memori SDCARD: ...");
	//cek_free_cluster();
	#endif
	vTaskDelay(100);
	sprintf(s, "%s$ ", PROMPT);
	
	
	#ifdef PAKAI_FREERTOS_CLI		// gak jadi pake FreeRTOS-CLI
	uprintf(s);
	vRegisterCLICommands();
	
	for(;;)	{
		//uprintf("Merdeka!!!\r\n");
		//vSerialPutString(xPort, "tes\r\n", 5);
		xGotChar = xSerialGetChar( xPort, &ch, 10 );
		if( xGotChar == pdTRUE )		{
			//if( xSerialGetChar( xPort, &ch, comRX_BLOCK_TIME ) )		{ // comRX_BLOCK_TIME = 0xffff
			//tinysh_char_in((unsigned char) ch);
			toogle_led_utama();
			if ((uchr) ch=='\r')	{
				sprintf(s, "\r\n%s$ ", PROMPT);
				uprintf(s);
			}
		}
		vTaskDelay(10);
	}
	#endif
	
	#ifdef PAKAI_TINYSH
	tinysh_set_prompt(s);
	tinysh_char_in('\r');
	vTaskDelay(500);
	for( ;; )	{
		//vTaskDelay(10);
		//printf("testing\r\n");
		xGotChar = xSerialGetChar( xPort, &ch, 10 );
		
		if( xGotChar == pdTRUE )		{
			tinysh_char_in((unsigned char) ch);
			toogle_led_utama();
		}
		if (st_hw.mm>=120)	{			// cron tiap 1 menit
		//if (st_hw.mm >= 10)	{			// cron tiap 10detik
		//if (st_hw.mm>=2)		{			// cron tiap 1 detik
			st_hw.mm = 0;
			st_hw.uuwaktu++;
			#ifdef PAKAI_FILE_SIMPAN
			simpan_file_data();
			#endif
		}
		
		qrprintf(0);
	}
	#endif	
	
	for( ;; )	{
		vTaskDelay(10);
	}
}