void CommandLine(void)
{
	u08 c;
	/* Variable to Run or stop program */
	Run = TRUE;

	/* Clears the screen and sets the cursor under the Title */
	vt100ClearScreen();
	vt100SetCursorPos(1,0);

	rprintfProgStrM("\r\n\t\t\tStepper Motor Driver - Serial Console\r\n");

	cmdlineInit();
	cmdlineSetOutputFunc(uartSendByte);

	cmdlineAddCommand("quit", quitCommandLine);
	cmdlineAddCommand("help", helpDisplay);
	cmdlineAddCommand("step", runMotor);

	cmdlineInputFunc('\r');

	while(Run)
	{
		while( uartReceiveByte(&c) )
			cmdlineInputFunc(c);

		cmdlineMainLoop();

	}

	rprintfCRLF();
	rprintf("Program halted.");


}
Beispiel #2
0
void goCmdline(void)
{
	u08 c;

	// print welcome message
	vt100ClearScreen();
	vt100SetCursorPos(1,0);
	rprintfProgStrM("\r\nWelcome to the Command Line Test Suite!\r\n");

	// initialize cmdline system
	cmdlineInit();

	// direct cmdline output to uart (serial port)
	cmdlineSetOutputFunc(uartSendByte);

	// add commands to the command database
	cmdlineAddCommand("exit",		exitFunction);
	cmdlineAddCommand("help",		helpFunction);
	cmdlineAddCommand("dumpargs1",	dumpArgsStr);
	cmdlineAddCommand("dumpargs2",	dumpArgsInt);
	cmdlineAddCommand("dumpargs3",	dumpArgsHex);

	// send a CR to cmdline input to stimulate a prompt
	cmdlineInputFunc('\r');

	// set state to run
	Run = TRUE;

	// main loop
	while(Run)
	{
		// pass characters received on the uart (serial port)
		// into the cmdline processor
		while(uartReceiveByte(&c)) cmdlineInputFunc(c);

		// run the cmdline execution functions
		cmdlineMainLoop();
	}

	rprintfCRLF();
	rprintf("Exited program!\r\n");
}
Beispiel #3
0
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;
}
Beispiel #4
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();
  }   
}
Beispiel #5
0
/*------------------------------------------------------------------------------------*/
void tkCmd(void * pvParameters)
{

u08 c;
u08 ticks;
( void ) pvParameters;

	while ( !startTask )
		vTaskDelay( ( TickType_t)( 100 / portTICK_RATE_MS ) );

	cmdlineInit();
	cmdlineSetOutputFunc(pvFreeRTOS_UART1_writeChar);

	cmdlineAddCommand((u08 *)("cls"), cmdClearScreen );
	cmdlineAddCommand((u08 *)("help"), cmdHelpFunction);
	cmdlineAddCommand((u08 *)("reset"), cmdResetFunction);
	cmdlineAddCommand((u08 *)("read"), cmdReadFunction);
	cmdlineAddCommand((u08 *)("write"), cmdWriteFunction);
	cmdlineAddCommand((u08 *)("redial"), cmdRedialFunction);
	cmdlineAddCommand((u08 *)("status"), cmdStatusFunction);


	// Espero la notificacion para arrancar
	vTaskDelay( ( TickType_t)( 500 / portTICK_RATE_MS ) );

	snprintf_P( cmd_printfBuff,sizeof(cmd_printfBuff),PSTR("starting tkCmd..\r\n\0"));
	FreeRTOS_write( &pdUART1, cmd_printfBuff, sizeof(cmd_printfBuff) );

	ticks = 1;
	FreeRTOS_ioctl( &pdUART1,ioctlSET_TIMEOUT, &ticks );

	// loop
	for( ;; )
	{
		u_clearWdg(WDG_CMD);

		c = '\0';	// Lo borro para que luego del un CR no resetee siempre el timer.
		// el read se bloquea 50ms. lo que genera la espera.
		while ( FreeRTOS_read( &pdUART1, &c, 1 ) == 1 ) {
			cmdlineInputFunc(c);
		}

		/* run the cmdline execution functions */
		cmdlineMainLoop();
	}
}
Beispiel #6
0
void tkCmd(void * pvParameters)
{

u08 c;

( void ) pvParameters;

	// !!! Requiere que este inicializado el FRTOS porque usa semaforos.
	MCP_init();		// IO ports for hardware

	vTaskDelay( (portTickType)( 1000 / portTICK_RATE_MS ) );

	initDebugRtc();
	initBlueTooth();

	vt100ClearScreen(CMD_UART);

	// Inicializo los parametros de trabajo ( leo la internal EE ).
	loadSystemParams();

	// Inicializo la memoria. Leo el estado de los punteros ( leo la external EE).
	BD_init();
	//
	vTaskDelay( (portTickType)( 100 / portTICK_RATE_MS ) );
	snprintf_P( cmd_printfBuff,CHAR128,PSTR("\r\n.INIT EEmem BD: wrPtr=%d, rdPtr=%d, recUsed=%d, recFree=%d\r\n\0"),  BD_getWRptr(),  BD_getRDptr(), BD_getRcsUsed(), BD_getRcsFree() );
	logPrintStr(LOG_NONE, cmd_printfBuff);
	switch (mcpDevice) {
	case MCP23008:
#ifdef CHANNELS_3
		snprintf_P( cmd_printfBuff,CHAR128,PSTR("System: 3 analogIn,2 digitalIn\r\n\0"));
#endif
#ifdef CHANNELS_8
		snprintf_P( cmd_printfBuff,CHAR128,PSTR("System: 8 analogIn,2 digitalIn\r\n\0"));
#endif
		break;
	case MCP23018:
		snprintf_P( cmd_printfBuff,CHAR128,PSTR("System: 3 analogIn,2 digitalIn,4 valves\r\n\0"));
		break;
	default:
		snprintf_P( cmd_printfBuff,CHAR128,PSTR("ERROR !! No analog system detected\r\n\0"));
		break;
	}
	logPrintStr(LOG_NONE, cmd_printfBuff);

	// Inicializo el sistema de consignas.
	initConsignas();
	switch (systemVars.consigna.tipo) {
	case CONS_NONE:
		snprintf_P( cmd_printfBuff,CHAR128,PSTR("Init consignas: none\r\n\0"));
		break;
	case CONS_DOBLE:
		snprintf_P( cmd_printfBuff,CHAR128,PSTR("Init consignas: doble\r\n\0"));
		break;
	default:
		snprintf_P( cmd_printfBuff,CHAR128,PSTR("Init consignas: ERROR\r\n\0"));
		break;
	}
	logPrintStr(LOG_NONE, cmd_printfBuff);
	//


	// Init Banner.
	snprintf_P( cmd_printfBuff,CHAR128,PSTR("\r\nSpymovil %s %s"), SP5K_MODELO, SP5K_VERSION);
	logPrintStr(LOG_NONE, cmd_printfBuff);
	snprintf_P( cmd_printfBuff,CHAR128,PSTR(" %d-%s-%s"), NRO_CHANNELS, EE_TYPE, FTYPE);
	logPrintStr(LOG_NONE, cmd_printfBuff);
	snprintf_P( cmd_printfBuff,CHAR128,PSTR(" %s %s\r\n\0"), SP5K_REV, SP5K_DATE );
	logPrintStr(LOG_NONE, cmd_printfBuff);

#ifdef MEMINFO
	snprintf_P( &cmd_printfBuff,CHAR128,PSTR("HE_Uart0TxQueue=%lu\r\n\0"), HE_Uart0TxQueue );
	logPrintStr(LOG_NONE, &cmd_printfBuff);
	snprintf_P( &cmd_printfBuff,CHAR128,PSTR("HE_Uart1RxQueue=%lu\r\n\0"), HE_Uart1RxQueue );
	logPrintStr(LOG_NONE, &cmd_printfBuff);
	snprintf_P( &cmd_printfBuff,CHAR128,PSTR("HE_Uart1TxQueue=%lu\r\n\0"), HE_Uart1TxQueue );
	logPrintStr(LOG_NONE, &cmd_printfBuff);
	snprintf_P( &cmd_printfBuff,CHAR128,PSTR("HE_I2Cbus=%lu\r\n\0"), HE_I2Cbus );
	logPrintStr(LOG_NONE, &cmd_printfBuff);
	snprintf_P( &cmd_printfBuff,CHAR128,PSTR("HE_CmdUart=%lu\r\n\0"), HE_CmdUart );
	logPrintStr(LOG_NONE, &cmd_printfBuff);
	snprintf_P( &cmd_printfBuff,CHAR128,PSTR("HE_GprsUart=%lu\r\n\0"), HE_GprsUart );
	logPrintStr(LOG_NONE, &cmd_printfBuff);
	snprintf_P( &cmd_printfBuff,CHAR128,PSTR("HE_digitalIn=%lu\r\n\0"), HE_digitalIn );
	logPrintStr(LOG_NONE, &cmd_printfBuff);
	snprintf_P( &cmd_printfBuff,CHAR128,PSTR("HE_systemVars=%lu\r\n\0"), HE_systemVars );
	logPrintStr(LOG_NONE, &cmd_printfBuff);
	snprintf_P( &cmd_printfBuff,CHAR128,PSTR("HE_BD=%lu\r\n\0"), HE_BD );
	logPrintStr(LOG_NONE, &cmd_printfBuff);
	snprintf_P( &cmd_printfBuff,CHAR128,PSTR("HE_tkCmd=%lu\r\n\0"), HE_tkCmd );
	logPrintStr(LOG_NONE, &cmd_printfBuff);
	snprintf_P( &cmd_printfBuff,CHAR128,PSTR("HE_tkDigitalIn=%lu\r\n\0"), HE_tkDigitalIn );
	logPrintStr(LOG_NONE, &cmd_printfBuff);
	snprintf_P( &cmd_printfBuff,CHAR128,PSTR("HE_tkData=%lu\r\n\0"), HE_tkData );
	logPrintStr(LOG_NONE, &cmd_printfBuff);
	snprintf_P( &cmd_printfBuff,CHAR128,PSTR("HE_tkControl=%lu\r\n\0"), HE_tkControl );
	logPrintStr(LOG_NONE, &cmd_printfBuff);
	snprintf_P( &cmd_printfBuff,CHAR128,PSTR("HE_tkGprs=%lu\r\n\0"), HE_tkGprs );
	logPrintStr(LOG_NONE, &cmd_printfBuff);

#endif

	// Habilito al resto del sistema a arrancar
	if (xSemaphoreTake( sem_systemVars, MSTOTAKESYSTEMVARSSEMPH ) == pdTRUE ) {
		systemVars.initStatus = TRUE;
		xSemaphoreGive( sem_systemVars );
	}

	for( ;; )
	{

		// Para medir el uso del stack
		tkCmd_uxHighWaterMark = uxTaskGetStackHighWaterMark( NULL );

		clearWdg(WDG_CMD);
		while(xUartGetChar(CMD_UART, &c, (50 / portTICK_RATE_MS ) ) ) {
			cmdlineInputFunc(c);
			// Cada caracer recibido reinicio el timer.
			restartTimerTerminal();
		}
		/* run the cmdline execution functions */
		cmdlineMainLoop();

	}

}