コード例 #1
0
ファイル: cmdline.c プロジェクト: borand/AVR
void cmdlineProcessInputString(void)
{
	u08 cmdIndex;
	u08 i=0;

	// save command in history
	cmdlineDoHistory(CMDLINE_HISTORY_SAVE);

	// find the end of the command (excluding arguments)
	// find first whitespace character in CmdlineBuffer
	while( !((CmdlineBuffer[i] == ' ') || (CmdlineBuffer[i] == 0)) ) i++;

	if(!i)
	{
		// command was null or empty
		// output a new prompt
		cmdlinePrintPrompt();
		// we're done
		return;
	}

	// search command list for match with entered command
	for(cmdIndex=0; cmdIndex<CmdlineNumCommands; cmdIndex++)
	{
		if( !strncmp(CmdlineCommandList[cmdIndex], CmdlineBuffer, i) )
		{
			// user-entered command matched a command in the list (database)
			// run the corresponding function
			CmdlineExecFunction = CmdlineFunctionList[cmdIndex];
			// new prompt will be output after user function runs
			// and we're done
			return;
		}
	}

	// if we did not get a match
	// output an error message
	cmdlinePrintError();
	// output a new prompt
	cmdlinePrintPrompt();
}
コード例 #2
0
ファイル: main.c プロジェクト: MaxRzv/VP2motion
int 
main(int argc, char **argv)
{
	char ch;

	cprintf("Main started\nVersion: ");
	cprintf(MAIN_VERSION);
	cprintf("\n");

	for (ch = 0; ch < 26; ch++) {
		osram_write(osram_init[ch]);
	};

	rs485Init();
	steppersInit();

	cmdlineInit();
	cmdlineAddCommand("help", do_help);
	cmdlineAddCommand("?", do_help);
	cmdlineAddCommand("dump", do_dump);
	cmdlineAddCommand("ls", do_ls);
	cmdlineAddCommand("dir", do_ls);
	cmdlineAddCommand("mv", do_rename);
	cmdlineAddCommand("rename", do_rename);
	cmdlineAddCommand("rm", do_rm);
	cmdlineAddCommand("delete", do_rm);
	cmdlineAddCommand("spi_speed", do_spi_speed);
	cmdlineAddCommand("osram", do_osram);
	cmdlineAddCommand("flash", do_flash);
	cmdlineAddCommand("readmem", do_readmem);
	cmdlineAddCommand("rd", do_rd);
	cmdlineAddCommand("wr", do_wr);
	cmdlineAddCommand("rd32", do_rd32);
	cmdlineAddCommand("wr32", do_wr32);
	cmdlineAddCommand("step", do_step);
	cmdlineAddCommand("build", do_build);
	cmdlineAddCommand("sendcmd", do_sendcmd);
	cmdlineAddCommand("reset", (void *)0xE000);
	cmdlinePrintPrompt();

	while (1) {
		if (getc_nowait(&ch)) {
			cmdlineInputFunc(ch);
		};
		cmdlineMainLoop();
		rs485MainLoop();
		steppersMainLoop();
	};

	cprintf("\ndone\n");
		
	return 0;
}
コード例 #3
0
ファイル: cmdline.c プロジェクト: borand/AVR
void cmdlineMainLoop(void)
{
	// do we have a command/function to be executed
	if(CmdlineExecFunction)
	{
		// run it
		CmdlineExecFunction();
		// reset
		CmdlineExecFunction = 0;
		// output new prompt
		cmdlinePrintPrompt();
	}
}
コード例 #4
0
ファイル: cmdline.c プロジェクト: borand/AVR
void cmdlineRepaint(void)
{
	u08* ptr;
	u08 i;

	// carriage return
	cmdlineOutputFunc(ASCII_CR);
	// print fresh prompt
	cmdlinePrintPrompt();
	// print the new command line buffer
	i = CmdlineBufferLength;
	ptr = CmdlineBuffer;
	while(i--) cmdlineOutputFunc(*ptr++);
}
コード例 #5
0
void setup_menu (void) {                                                        // function for setup menu
  char cmd;                                                                     // variable used as buffer for debug USART and debug menu service 
  menuInit();
  printf("\n\rPress CTRL+C if you want to exit menu and continue running program\n\r");
  cmdlinePrintPrompt();
  while (1) {
    cmd=TM_USART_Getc(MENU_USART);
    if(cmd==0x03) {                                                             // check for CTRL+C keypress send from terminal emulator
      printf("\n\rCTRL+C was detected, leaving menu\n\r");
      break;
     }
    cmdlineInputFunc(cmd);
    Delay(100);
    cmdlineMainLoop();
  }   
}